-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
SortedDictionary Behaves Differently Across .NET Core Platforms #43802
Comments
Tagging subscribers to this area: @eiriktsarpalis, @jeffhandley |
When you create your
The default string comparer can have different results based on the running environment (such as platform or culture). Here's an earlier instance of this expected behavior, specifically about Windows vs. macOS/Linux and the ICU library: #20109. It's generally best practice to avoid using string comparison defaults so you don't run into this kind of issue: https://docs.microsoft.com/en-us/dotnet/standard/base-types/best-practices-strings#specifying-string-comparisons-explicitly It looks like you're sorting |
Thank you @dagood I can confirm in the toy program it works as expected.
You are correct; I am working on converting this tool to .NET Core/Dotnet Tool - https://github.com/aolszowka/VisualStudioSolutionSorter/. This actually kicked out due to using the Ubuntu Build Agent, but shows that I should be testing this logic across all .NET Core platforms.
Based on the fact that this is documented as so, perhaps it would be worthwhile to submit a feature request to dotnet/roslyn to have an analyzer cover this? I do not see any open items for this yet. Historically I have used this excellent Roslyn Analyzer from @meziantou https://github.com/meziantou/Meziantou.Analyzer/tree/master/docs. Specifically this warning https://github.com/meziantou/Meziantou.Analyzer/blob/master/docs/Rules/MA0001.md should probably be enhanced to cover this (I will file a separate bug report), but considering how common this maybe perhaps it is worth elevating to a built in? As far as this issue goes, if this is by design I am OK closing with with a |
For the record, .NET 5 will try to use ICU by default on Windows as well. See the breaking change doc for more info. |
Closing this in favour of the related ICU issues. |
Description
SortedDictionary
appears to behave differently across .NET Core Platforms.I have created the following GitHub Repository that demonstrates this issue: https://github.com/aolszowka/DotNetCoreSortedDictionaryCrossPlatform
The crux of the issue can be highlighted in this NUnit Test:
This unit test will pass on Windows based platforms but fail in Ubuntu and MacOS (at least the build agents as provided by GitHub Actions).
Furthermore this issue appears to be length dependent, as the following will pass on all platforms:
I have not bothered to narrow this down due to the limits on GitHub Actions (not looking to burn all my CI Minutes right now).
Configuration
This is using windows-latest, ubuntu-latest, macos-latest as defined by GitHub Actions here: https://github.com/actions/virtual-environments.
You should be able to clone this repository and instantly have GitHub spin up the appropriate CI environments for you allowing you to test across all platforms serviced by GitHub Actions.
Other information
In searching existing bug reports I may be affected by one of the following, but I am not familiar enough with the runtime to know if this is the case:
Neither of these cases mentions the length of the string being in play. In the issues however they all appears to be using various forms of localization/localized strings.
Here are the results from my area in GitHub Actions:
Windows
Ubuntu
MacOS
Thank you
The text was updated successfully, but these errors were encountered: