-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Description
Description
There is a following documentation.
https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-environment-variables#set-invariant-mode
A value set in the project file or runtimeconfig.json has a higher priority than the environment variable.
When switch is defined at runtimeconfig.json level. it should not be overwritten by environment variable setting.
But when using .NET 9/.NET 10. This behavior seems be changed. (Environment variable has higher priority)
Reproduction Steps
- Create console application
- Modify csproj and add following settings
<TargetFramework>net9.0</TargetFramework> <InvariantGlobalization>true</InvariantGlobalization>
- Modify Program.cs with following code
static void Main(string[] args) { var data = new[] { "aaa", "BBB", "ccc" }; var sorted = data.OrderBy(x => x, StringComparer.InvariantCulture); foreach (var s in sorted) Console.WriteLine(s); }
- Add
Properties/launchSettings.jsonwith following content{ "profiles": { "Default": { "commandName": "Project", "commandLineArgs": "", "environmentVariables": { "DOTNET_SYSTEM_GLOBALIZATION_INVARIANT": "false" } } } } - Launch application with .NET 9
Expected behavior
It's expected Ordinal sorted results are shown (InvariantGlobalization is enabled)
BBB
aaa
ccc
Actual behavior
InvariantCulture sorted results are shown (InvariantGlobalization is disabled)
aaa
BBB
ccc
Regression?
When running application on .NET 8 (net80).
It works as expected.
So it's breaking changes or regression.
I've confirmed relating PR(#87672) and Breaking changes in .NET 9 but can't find related information.
I'm wondering if the changes in behavior are intentional or not.
If it's intentional changes, it need to fix documentation.
Known Workarounds
No response
Configuration
No response
Other information
It seems behavior changes are introduced at v9.0.0-preview.1.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status