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
This code shows the following warning on Code Analysis
Warning CA1305 Because the behavior of 'string.Format(string, object)' could vary based on the current user's locale settings, replace this call in 'FeatureController.IsFeatureEnabled(FeatureEnum, Dictionary<string, string>)' with a call to 'string.Format(IFormatProvider, string, params object[])'. If the result of 'string.Format(IFormatProvider, string, params object[])' will be displayed to the user, specify 'CultureInfo.CurrentCulture' as the 'IFormatProvider' parameter. Otherwise, if the result will be stored and accessed by software, such as when it is persisted to disk or to a database, specify 'CultureInfo.InvariantCulture'.
Question is, how do I handle this warning in .NET 4.5 while sticking with string interpolation. I know 4.6 does have FormattableString which can help resolve this warning.
The text was updated successfully, but these errors were encountered:
I'm also seeing this warning for code where I don't understand why. The following code results in this warning when compiled for .Net Framework 4.6.1
publicstaticclassClass1{publicstaticstringMethod(stringsomeValue){return$"A string with {someValue} embedded in it.";}}
Warning CA1305 Because the behavior of 'string.Format(string, object)' could vary based on the current user's locale settings, replace this call in 'Class1.Method(string)' with a call to 'string.Format(IFormatProvider, string, params object[])'. If the result of 'string.Format(IFormatProvider, string, params object[])' will be displayed to the user, specify 'CultureInfo.CurrentCulture' as the 'IFormatProvider' parameter. Otherwise, if the result will be stored and accessed by software, such as when it is persisted to disk or to a database, specify 'CultureInfo.InvariantCulture'. NetFramework
Why get a warning when you embed a string? Is this a bug in the analyser, or am I missing something?
VS2015
$"Enabled Check for {feature.ToString()}"
This code shows the following warning on Code Analysis
Warning CA1305 Because the behavior of 'string.Format(string, object)' could vary based on the current user's locale settings, replace this call in 'FeatureController.IsFeatureEnabled(FeatureEnum, Dictionary<string, string>)' with a call to 'string.Format(IFormatProvider, string, params object[])'. If the result of 'string.Format(IFormatProvider, string, params object[])' will be displayed to the user, specify 'CultureInfo.CurrentCulture' as the 'IFormatProvider' parameter. Otherwise, if the result will be stored and accessed by software, such as when it is persisted to disk or to a database, specify 'CultureInfo.InvariantCulture'.
Question is, how do I handle this warning in .NET 4.5 while sticking with string interpolation. I know 4.6 does have FormattableString which can help resolve this warning.
The text was updated successfully, but these errors were encountered: