dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
14.96k stars 4.65k forks source link

[iOS/HybridGlobalization] RegionInfo instantiated by two-letter code is missing information #102937

Closed tipa closed 3 months ago

tipa commented 3 months ago

Description

When creating a RegionInfo object with a two-letter code, the returned object doesn't contain the expected information, e.g. NativeName, EnglishName or DisplayName

Reproduction Steps

.NET iOS project with HybridGlobalization=true in csproj

Expected behavior

var a = new RegionInfo(1031).Name; // "DE" -> OK
var b = new RegionInfo("de-DE").Name; // "DE" -> OK
var c = new RegionInfo("DE").Name; // "DE" -> OK
var d = new RegionInfo("DE").NativeName; // "Deutschland" -> OK
var e = new RegionInfo("DE").EnglishName; // "Germany" -> OK

Actual behavior

var a = new RegionInfo(1031).Name; // "DE" -> OK
var b = new RegionInfo("de-DE").Name; // "DE" -> OK
var c = new RegionInfo("DE").Name; // "" -> NOK
var d = new RegionInfo("DE").NativeName; // "" -> NOK
var e = new RegionInfo("DE").EnglishName; // "" -> NOK

Regression?

No response

Known Workarounds

var regions = CultureInfo.GetCultures(CultureTypes.SpecificCultures)
    .Select(x => new RegionInfo(x.Name))
    .Where(x => x.Name == "DE")
    .ToList();

Configuration

Installed Workload Id      Manifest Version       Installation Source
---------------------------------------------------------------------
macos                      14.2.8053/8.0.100      SDK 8.0.300        
ios                        17.2.8053/8.0.100      SDK 8.0.300        

Other information

On other platforms (e.g. Android or macOS), the issue is not present

dotnet-policy-service[bot] commented 3 months ago

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

tarekgh commented 3 months ago

CC @vitek-karas

mkhamoyan commented 3 months ago

@tipa This is fixed in .net 9. Hybrid mode was introduced as experimental mode on .net 8 and some of the functionalities were missing which is causing to this behaviour.