Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new RegionInfo("NO").NativeName returns different strings depending on the capitalization of the country code #39991

Closed
castholm opened this issue Jul 28, 2020 · 3 comments · Fixed by #40052

Comments

@castholm
Copy link

castholm commented Jul 28, 2020

Norway has two official native names in its two official written standards; Norge in Bokmål and Noreg in Nynorsk.

When initializing a new RegionInfo with a Norwegian country code it will have a different value for its NativeName property depending solely on whether you capitalized the country code or not.

The official documentation for the RegionInfo(string) constructor specifies that case is not significant.

What's even worse is that depending on which capitalization you use the first time you initialize a RegionInfo instance the results will be cached and be returned on subsequent initializations of instances regardless of capitalization.

Quick sample code that demonstrates the issue:

using System;
using System.Globalization;

namespace ConsoleApp1
{
    public static class Program
    {
        public static void Main(string[] args)
        {
            Console.WriteLine(new RegionInfo("NO").NativeName);
            Console.WriteLine(new RegionInfo("no").NativeName);
        }
    }
}
Noreg
Noreg

If we change the order we initialize the instances, we get a completely different output:

using System;
using System.Globalization;

namespace ConsoleApp1
{
    public static class Program
    {
        public static void Main(string[] args)
        {
            Console.WriteLine(new RegionInfo("no").NativeName);
            Console.WriteLine(new RegionInfo("NO").NativeName);
        }
    }
}
Norge
Norge

It is expected that both capitalizations of the country code should return the same NativeName regardless of which is used first.

.NET Core version: 3.1.302
OS: Windows 10, version 2004, build 19041.388

@Dotnet-GitSync-Bot Dotnet-GitSync-Bot added area-System.Globalization untriaged New issue has not been triaged by the area owner labels Jul 28, 2020
@ghost
Copy link

ghost commented Jul 28, 2020

Tagging subscribers to this area: @tarekgh, @safern, @krwq
See info in area-owners.md if you want to be subscribed.

@tarekgh tarekgh added bug and removed untriaged New issue has not been triaged by the area owner labels Jul 28, 2020
@tarekgh tarekgh added this to the Future milestone Jul 28, 2020
@tarekgh
Copy link
Member

tarekgh commented Jul 28, 2020

@castholm did you try the repro with .NET 5.0?

@tarekgh
Copy link
Member

tarekgh commented Jul 28, 2020

I submitted a PR for this issue.

@ghost ghost locked as resolved and limited conversation to collaborators Dec 8, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants