Question Details

No question body available.

Tags

c# formatting globalization

Answers (1)

May 31, 2026 Score: 0 Rep: 8,053 Quality: Low Completeness: 80%

Seems like it used to be somewhat documented before - see older docs link:

Note that System.Globalization.CultureInfo.CurrentUICulture is used only to retrieve localized resources by using an instance of the System.Resources.ResourceManager class.

Note the comments in the code from the commit that added support for enforcing the guidelines and cites the guidelines as to why it's "inappropriate":

// Sample message // 1. UICultureStringRule - 'TestClass.TestMethod()' passes 'Thread.CurrentUICulture' as the 'IFormatProvider' parameter to 'TestClass.CalleeMethod(string, IFormatProvider)'. // This property returns a culture that is inappropriate for formatting methods. If the result of 'TestClass.CalleeMethod(string, IFormatProvider)' 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'. // 2. UICultureRule -'TestClass.TestMethod()' passes 'CultureInfo.CurrentUICulture' as the 'IFormatProvider' parameter to 'TestClass.Callee(IFormatProvider, string)'. // This property returns a culture that is inappropriate for formatting methods. If the result of 'TestClass.Callee(IFormatProvider, string)' will be based on input from the user, // specify 'CultureInfo.CurrentCulture' as the 'IFormatProvider' parameter. Otherwise, if the result will based on input stored and accessed by software, such as when it is loaded // from disk or from a database, specify 'CultureInfo.InvariantCulture'.