You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Context: b1079a0
Context: https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1305
Context: https://learn.microsoft.com/dotnet/csharp/tutorials/string-interpolation#how-to-create-a-culture-specific-result-string-with-string-interpolation
In b1079a0, we found a real bug where omitting
`CultureInfo.InvariantCulture` caused problems under certain locales.
Let's take this a step further by making `CA1305` a build error.
In every case I found, it seemed that invariant culture was fine, and
some might be bugs?
This also catches cases like this that use the current culture:
$"My integer: {x}"
Where we should do this instead:
FormattableString.Invariant($"My integer: {x}")
Only a single instance for displaying a localized string/error
message from MSBuild seemed like it needed the current culture:
string.Format (CultureInfo.CurrentCulture, Resources.XA2000, assembly);
And this one might not even matter, as `assembly` is a string.
For on-device app execution, add a new
`Android.Util.Log.FormatProvider` property, which is used by all the
log methods. This mirrors [`TextWriter.FormatProvider`][1]:
namespace Android.Util {
partial class Log {
public static IFormatProvider FormatProvider { get; set; } = CultureInfo.CurrentCulture;
public static int Debug (string tag, string format, params object[] args) =>
Debug (tag, string.Format (FormatProvider, format, args));
}
}
Some projects that are not shipped I didn't enable yet, to keep this
change smaller:
* Projects in `build-tools`
* MSBuild test projects
* Use `src/.editorconfig`; see also
[`.editorconfig` File hierarchy and precedence][0]
Finally, `build-tools/automation/guardian/source.gdnsuppress` needed
to be updated because the existing `Log.Wtf()` methods were changed
to use the new `Log.FormatProvider` property.
[0]: https://learn.microsoft.com/visualstudio/ide/create-portable-custom-editor-options#file-hierarchy-and-precedence
[1]: https://learn.microsoft.com/en-us/dotnet/api/system.io.textwriter.formatprovider?view=net-8.0
@@ -530,7 +531,7 @@ public void RegisterNativeMembers (JniType nativeClass, Type type, ReadOnlySpan<
530
531
}
531
532
532
533
if(minfo==null)
533
-
thrownewInvalidOperationException(String.Format("Specified managed method '{0}' was not found. Signature: {1}",mname.ToString(),signature.ToString()));
534
+
thrownewInvalidOperationException(FormattableString.Invariant($"Specified managed method '{mname.ToString()}' was not found. Signature: {signature.ToString()}"));
0 commit comments