-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
[release/6.0] Fix calling NLS with Cultures has alternative sort names #62155
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Tagging subscribers to this area: @tarekgh, @safern |
am11
reviewed
Nov 29, 2021
src/libraries/System.Private.CoreLib/src/System/Globalization/CultureData.Nls.cs
Outdated
Show resolved
Hide resolved
…CultureData.Nls.cs Co-authored-by: Adeel Mujahid <3840695+am11@users.noreply.github.com>
CC @ericstj @danmoseley for awareness. CC @safern as he was the one reviewed the original change. |
@tarekgh thanks for the ping, I agree this mails sense for you to submit to tactics. |
ericstj
approved these changes
Nov 30, 2021
ericstj
added
the
NO-MERGE
The PR is not ready for merge yet (see discussion for detailed reasons)
label
Nov 30, 2021
safern
approved these changes
Nov 30, 2021
Marking as NO MERGE until branch is open. |
stephentoub
approved these changes
Dec 1, 2021
tarekgh
added
Servicing-approved
Approved for servicing release
and removed
Servicing-consider
Issue for next servicing release review
labels
Dec 2, 2021
Approved by @SteveMCarroll |
safern
removed
the
NO-MERGE
The PR is not ready for merge yet (see discussion for detailed reasons)
label
Dec 15, 2021
ghost
locked as resolved and limited conversation to collaborators
Jan 14, 2022
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #61977
Backport of #61992 to release/6.0
/cc @tarekgh
Customer Impact
This issue is a regression from .NET 5.0 when getting the supported codepages for cultures. This regression is causing failures in the SQL clients which upgraded to .NET 6.0. Here are some links demonstrating such failures:
dotnet/SqlClient#1319 (comment)
dotnet/SqlClient#1396 (comment)
dotnet/efcore#26812 (comment)
The regression happens only with a small set of cultures having alternative sorts (more details about that are below) and only happens on Windows.
Details:
In .NET we depend on the ICU library for globalization. There are some cultural properties which are not supported by ICU. Example of that culture's ANSI codepage. For such properties, we used to hardcode the values in .NET 5.0. In .NET 6.0 when running on Windows OS, we started to call Windows to get a better-updated value.
Usually, cultures support one collation behavior. Some cultures support more than one collation behavior though. For example, the Spanish culture
es-ES
supports alternative traditional collationes-ES_tradnl
. Internally we have two names for the cultures. These two names will have the same value in the usual cases. But the names will differ only with the cultures that have alternative sorts. One name is the normal culture name likees-ES_tradnl
. The second name which we'll use when calling ICU likees-ES@collation=tradnl
.The bug we have in .NET is when calling Windows to get the properties like the ANSI codepage, we mistakenly used the name we use to call ICU instead of using the normal culture name. That causes the call to fail, and we return a zero value for the codepage. The problem happens only with the cultures which have alternative collation. Here is the list of such cultures:
The fix is simple that is using the correct name when calling Windows.
Testing
The change is merged to main branch and passed all regression tests. Added a specific test to catch the reported problem. Also, manually checked all culture names to ensure the fix will work fine with all cultures.
Risk
The risk is low as the change is scoped to Windows and the change is using the correct culture names which work fine with Windows. I cannot see this change can cause any problem.