Skip to content

CultureInfo.GetCultureInfo("root") is an accepted but incomplete culture which can raise NullReferenceException on internals #132429

Description

@rjgotten

Description

"und" is the correct BCP-47 tag for the "undetermined language" and maps correctly to CultureInfo.InvariantCulture when using CultureInfo.GetCultureInfo("und").

"root" is the alternative moniker used by CLDR.
When using CultureInfo.GetCultureInfo("root") it does not throw a CultureNotFoundException.
Rather it returns an incomplete unknown culture with LCID 4096.
And if one attempts to read NumberFormat off of it:

> System.Globalization.CultureInfo.GetCultureInfo("root").NumberFormat
System.NullReferenceException: Object reference not set to an instance of an object.
  + System.Globalization.NumberFormatInfo.InitializeInvariantAndNegativeSignFlags()
  + System.Globalization.CultureInfo.get_NumberFormat()

Reproduction Steps

Open any C# repl and execute:
System.Globalization.CultureInfo.GetCultureInfo("root").NumberFormat

Expected behavior

Either CultureInfo.GetCultureInfo("root") throws a CultureNotFoundException or it produces an actual intact culture.

Actual behavior

CultureInfo.GetCultureInfo("root") is accepted as a valid, recognized culture and does not throw a CultureNotFoundException - however what it produces is in fact not an actual intact culture.

Regression?

No response

Known Workarounds

No response

Configuration

.NET version: .NET 10
OS: Windows 11

Other information

No response

Activity

  1. added
    untriaged
    on Aug 17, 2026
  2. dotnet-policy-service commented on Aug 17, 2026

    @dotnet-policy-service
    Contributor

    Tagging subscribers to this area: @dotnet/area-system-globalization
    See info in area-owners.md if you want to be subscribed.

  3. removed
    untriaged
    on Aug 17, 2026
  4. added this to the 12.0.0 milestone on Aug 17, 2026
  5. tarekgh commented on Aug 18, 2026

    @tarekgh
    Member

    @rjgotten, thanks for reporting it. If you are blocked by any mean, you may consider using und or Invariant culture for that. We can look at the NumberFormat issue when having root name. Or we can just map `root to Invariant culture.

  6. rjgotten commented on Aug 27, 2026

    @rjgotten
    Author

    @tarekgh
    I'd honestly just reject root with a CultureNotFoundException since it isn't a valid BCP-47 identifier — which is what .NET's CultureInfo converges on after abandoning LCIDs.

  7. rjgotten commented on Sep 4, 2026

    @rjgotten
    Author

    @tarekgh
    Toyed some more with this. In case you weren't aware yet, accessing
    CultureInfo.GetCultureInfo("root") before CultureInfo.GetCultureInfo("") poisons the well.
    "root" returns a CultureInfo instance with Name = "" so it appears to take the cache position belonging to the invariant culture.

    Anything resolving the invariant culture as "" rather than as an explicit CultureInfo.InvariantCulture afterwards is broken.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions