📉Languages - NKS0044

Use CultureManager.CurrentCult

This analyzer provides the following strings:

ContextString

Error List

Caller uses CultureInfo.CurrentUICulture instead of CultureManager.CurrentCult

Suggestion Box

Use CultureManager.CurrentCult instead of CultureInfo.CurrentUICulture

Description

CultureManager.CurrentCult gives you a current culture that is set by the kernel settings without affecting the host system.

Extended Description

This code analyzer detects the usage of CurrentUICulture from the CultureInfo class found in the System.Globalizaiton namespace.

The CultureInfo.CurrentUICulture property gives you your current UI culture for your applications. However, Nitrocid is not a GUI application, so we've decided to make our own culture handler that respects your kernel settings.

It's advisable to use the CultureManager.CurrentCult property so that your mod can respect the kernel settings when it comes to cultures.

Analysis Comparison

To get a brief insight about how this analyzer works, compare the two code blocks shown to you below:

Before the fix

Somewhere in your mod code...
public static void MyFunction()
{
    var culture = CultureInfo.CurrentUICulture;
}

After the fix

Somewhere in your mod code...
public static void MyFunction()
{
    var culture = CultureManager.CurrentCult;
}

Suppression

You can suppress this suggestion by including it in the appropriate place, whichever is convenient.

For more information about how to suppress any warning issued by the Nitrocid analyzer, visit the below page:

Recommendation

We recommend that every caller which use this function use the recommended abovementioned method.

Last updated