CultureInfo.GetCultureInfo("root") is an accepted but incomplete culture which can raise NullReferenceException on internals
- Dominant language
- C#
- Stars
- 18.3k
- Forks
- 5.6k
- PR merge metrics
- PR metrics pending
Description
### 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_
Contributor guide
Research direction
Start by reproducing the issue in a C# REPL with CultureInfo.GetCultureInfo("root").NumberFormat and inspect the CultureInfo and NumberFormat behavior described in the report. Trace the globalization implementation from CultureInfo.GetCultureInfo; done means "root" either throws CultureNotFoundException or returns an intact culture without the NullReferenceException.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 65/100