You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Here are a couple of tests that have different behavior on Windows, macOS and Linux. The failure always seems to happen when StringComparison.CurrentCulture is used. The results on Azure DevOps are as follows:
Do note these tests were intentionally made evil to try to find bugs in our own IndexOf implementations, they aren't intended as real-world data, but extreme edge cases. Whatever the case, I would expect StringComparison.CurrentCulture to behave consistently across operating systems.
Whatever the case, I would expect StringComparison.CurrentCulture to behave consistently across operating systems.
This is by design. Perhaps we should surface this more in the documentation?
As much as I think I may have preferred to have consistent behavior as well, you're not even guaranteed consistent behavior on Windows either (for a variety of reasons).
Great. Exactly what I needed to know. Inconsistent behavior does seem to make StringComparer.CurrentCulture practically useless for applications built on .NET Core/.NET Stanadard, though.
Yes, I suggest improving visibility of this behavior in the docs so it can be taken into account when designing tests.
As indicated in the discussions this is by design as .NET depends on the OS or ICU for globalization support. We are improving the story in .NET 5.0 as we started supporting ICU on Windows which will allow getting more consistent results when running on different OS's. Also, we are going to support App local ICU which can be used to ensure exact behavior when running anywhere.
Here are a couple of tests that have different behavior on Windows, macOS and Linux. The failure always seems to happen when
StringComparison.CurrentCulture
is used. The results on Azure DevOps are as follows:Do note these tests were intentionally made evil to try to find bugs in our own
IndexOf
implementations, they aren't intended as real-world data, but extreme edge cases. Whatever the case, I would expectStringComparison.CurrentCulture
to behave consistently across operating systems.I briefly scanned the documentation for
IndexOf
and the Best Practices for Using Strings in .NET, but don't see any obvious references to this difference in behavior across operating systems. Is this intentional, or a bug?The text was updated successfully, but these errors were encountered: