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: 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 a problem 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, really?
Some projects that are not shipped I didn't enable yet, to keep this
change smaller:
* Projects in `build-tools`
* MSBuild test projects
@@ -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