From 7f5d7116592c08eee147e6c69b3317c966d2f4d0 Mon Sep 17 00:00:00 2001 From: Ilona Tomkowicz <32700855+ilonatommy@users.noreply.github.com> Date: Fri, 29 Dec 2023 12:14:23 +0000 Subject: [PATCH 01/22] Unblock all tests. --- .../tests/CollectionsTests.cs | 12 ++--- .../tests/LateBindingTests.cs | 10 ++-- .../tests/LikeOperatorTests.cs | 4 +- .../tests/ObjectTypeTests.cs | 4 +- .../tests/OperatorsTests.Comparison.cs | 24 +++++----- .../tests/StringTypeTests.cs | 4 +- .../tests/StringsTests.cs | 12 ++--- .../CaseInsensitiveHashCodeProviderTests.cs | 10 ++-- .../tests/CollectionsUtilTests.cs | 6 +-- .../tests/HashtableTests.cs | 4 +- ...meObjectCollectionBase.ConstructorTests.cs | 2 +- .../NameObjectCollectionBase.CopyToTests.cs | 4 +- ...eObjectCollectionBase.GetAllValuesTests.cs | 4 +- ...ObjectCollectionBase.GetEnumeratorTests.cs | 4 +- .../NameObjectCollectionBase.KeysTests.cs | 12 ++--- .../NameObjectCollectionBase.ReadOnlyTests.cs | 2 +- .../NameObjectCollectionBase.RemoveAtTests.cs | 6 +-- .../NameObjectCollectionBase.SetItemTests.cs | 2 +- .../NameValueCollection.AddNVCTests.cs | 8 ++-- ...ameValueCollection.AddStringStringTests.cs | 6 +-- .../NameValueCollection.ClearTests.cs | 2 +- .../NameValueCollection.CopyToTests.cs | 6 +-- .../NameValueCollection.CtorTests.cs | 10 ++-- .../NameValueCollection.GetIntTests.cs | 2 +- .../NameValueCollection.GetItemTests.cs | 2 +- .../NameValueCollection.GetKeyTests.cs | 2 +- .../NameValueCollection.GetStringTests.cs | 2 +- .../NameValueCollection.GetValuesIntTests.cs | 2 +- ...ameValueCollection.GetValuesStringTests.cs | 2 +- .../NameValueCollection.RemoveTests.cs | 4 +- .../NameValueCollection.SetItemTests.cs | 10 ++-- .../NameValueCollection.SetTests.cs | 10 ++-- .../OrderedDictionaryTests.cs | 6 +-- .../OutOfBoundsRegression.cs | 4 +- .../Mono/DataRowComparerTest.cs | 8 ++-- .../Mono/DataRowExtensionsTest.cs | 4 +- .../Mono/DataTableExtensionsTest.cs | 8 ++-- .../Mono/EnumerableRowCollectionTest.cs | 12 ++--- .../System/Data/DataRowComparerTests.cs | 12 ++--- .../System/Data/DataRowExtensionsTests.cs | 10 ++-- .../EnumerableRowCollectionExtensionsTests.cs | 10 ++-- .../Data/TypedTableBaseExtensionsTests.cs | 6 +-- .../System/Data/DataTableExtensionsTest.cs | 2 +- .../tests/Functional/MailAddressTest.cs | 4 +- .../XsltArgumentList.cs | 2 +- .../System.Runtime.Caching/MemoryCacheTest.cs | 46 +++++-------------- .../tests/DataContractJsonSerializer.cs | 4 +- .../tests/DataContractSerializer.cs | 2 +- .../GetStringComparerTests.cs | 2 +- .../System/StringComparer.cs | 8 ++-- .../System/StringComparerTests.cs | 4 +- .../System/StringGetHashCodeTests.cs | 2 +- .../System/StringTests.cs | 6 +-- .../System/Text/RuneTests.cs | 2 +- .../CollectionTests.Specialized.Write.cs | 2 +- src/libraries/tests.proj | 3 +- 56 files changed, 170 insertions(+), 193 deletions(-) diff --git a/src/libraries/Microsoft.VisualBasic.Core/tests/CollectionsTests.cs b/src/libraries/Microsoft.VisualBasic.Core/tests/CollectionsTests.cs index 35195353a2ed6a..d387d548b41153 100644 --- a/src/libraries/Microsoft.VisualBasic.Core/tests/CollectionsTests.cs +++ b/src/libraries/Microsoft.VisualBasic.Core/tests/CollectionsTests.cs @@ -74,7 +74,7 @@ public static void Add_RelativeIndex() Assert.Equal(item1, coll[3]); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Fact] public static void Add_RelativeKey() { var coll = new Collection(); @@ -175,7 +175,7 @@ public static void RemoveAt_InvalidIndex_ThrowsArgumentOutOfRangeException() Assert.Throws("Index", () => coll.RemoveAt(-1)); // Index < 0 } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Fact] public static void Remove_Key() { var coll = CreateKeyedCollection(10); @@ -185,7 +185,7 @@ public static void Remove_Key() Assert.False(coll.Contains("Key3")); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Fact] public static void Remove_InvalidKey_ThrowsArgumentException() { var coll = CreateKeyedCollection(10); @@ -242,7 +242,7 @@ public static void Contains() Assert.False(coll.Contains(new Foo())); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Fact] public static void Contains_ByKey() { var coll = CreateKeyedCollection(10); @@ -275,7 +275,7 @@ public static void Item_Get_InvalidIndex_ThrowsIndexOutOfRangeException() Assert.Throws(() => coll[(object)Guid.Empty]); // Neither string nor int } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Fact] public static void Item_GetByKey() { Collection coll = CreateKeyedCollection(10); @@ -291,7 +291,7 @@ public static void Item_GetByKey() Assert.Equal(CreateValue(11), coll[(object)'X']); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Fact] public static void Item_GetByKey_InvalidIndex_ThrowsIndexOutOfRangeException() { Collection coll = CreateKeyedCollection(10); diff --git a/src/libraries/Microsoft.VisualBasic.Core/tests/LateBindingTests.cs b/src/libraries/Microsoft.VisualBasic.Core/tests/LateBindingTests.cs index 3d66733224abea..a04e4b0b29333e 100644 --- a/src/libraries/Microsoft.VisualBasic.Core/tests/LateBindingTests.cs +++ b/src/libraries/Microsoft.VisualBasic.Core/tests/LateBindingTests.cs @@ -9,7 +9,7 @@ namespace Microsoft.VisualBasic.CompilerServices.Tests { public class LateBindingTests { - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Theory] [MemberData(nameof(LateCall_TestData))] public void LateCall(object obj, Type objType, string name, object[] args, string[] paramNames, bool[] copyBack, Func getResult, object expected) { @@ -17,14 +17,14 @@ public void LateCall(object obj, Type objType, string name, object[] args, strin Assert.Equal(expected, getResult(obj)); } - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Theory] [MemberData(nameof(LateGet_TestData))] public void LateGet(object obj, Type objType, string name, object[] args, string[] paramNames, bool[] copyBack, object expected) { Assert.Equal(expected, LateBinding.LateGet(obj, objType, name, args, paramNames, copyBack)); } - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Theory] [MemberData(nameof(LateSet_TestData))] public void LateSet(object obj, Type objType, string name, object[] args, string[] paramNames, Func getResult, object expected) { @@ -32,7 +32,7 @@ public void LateSet(object obj, Type objType, string name, object[] args, string Assert.Equal(expected, getResult(obj)); } - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Theory] [MemberData(nameof(LateSetComplex_TestData))] public void LateSetComplex(object obj, Type objType, string name, object[] args, string[] paramNames, bool missing, bool valueType) { @@ -81,7 +81,7 @@ public void LateIndexSet_MissingMember(object obj, object[] args, string[] param Assert.Throws(() => LateBinding.LateIndexSet(obj, args, paramNames)); } - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Theory] [MemberData(nameof(LateIndexSetComplex_TestData))] public void LateIndexSetComplex(object obj, object[] args, string[] paramNames, bool missing, bool valueType) { diff --git a/src/libraries/Microsoft.VisualBasic.Core/tests/LikeOperatorTests.cs b/src/libraries/Microsoft.VisualBasic.Core/tests/LikeOperatorTests.cs index 892fbc5c31b5e1..1452be5b7fb333 100644 --- a/src/libraries/Microsoft.VisualBasic.Core/tests/LikeOperatorTests.cs +++ b/src/libraries/Microsoft.VisualBasic.Core/tests/LikeOperatorTests.cs @@ -9,7 +9,7 @@ namespace Microsoft.VisualBasic.CompilerServices.Tests { public class LikeOperatorTests { - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Theory] [MemberData(nameof(LikeObject_TestData))] [MemberData(nameof(LikeString_TestData))] public void LikeObject(object source, object pattern, object expectedBinaryCompare, object expectedTextCompare) @@ -18,7 +18,7 @@ public void LikeObject(object source, object pattern, object expectedBinaryCompa Assert.Equal(expectedTextCompare, LikeOperator.LikeObject(source, pattern, CompareMethod.Text)); } - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Theory] [MemberData(nameof(LikeString_TestData))] public void LikeString(string source, string pattern, bool expectedBinaryCompare, bool expectedTextCompare) { diff --git a/src/libraries/Microsoft.VisualBasic.Core/tests/ObjectTypeTests.cs b/src/libraries/Microsoft.VisualBasic.Core/tests/ObjectTypeTests.cs index d520d69d6cb6f6..f1e4b8ac6935f1 100644 --- a/src/libraries/Microsoft.VisualBasic.Core/tests/ObjectTypeTests.cs +++ b/src/libraries/Microsoft.VisualBasic.Core/tests/ObjectTypeTests.cs @@ -287,7 +287,7 @@ public static IEnumerable GetObjectValuePrimitive_TestData() // Add more... } - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Theory] [MemberData(nameof(LikeObj_TestData))] public void LikeObj(object left, object right, object expectedBinaryCompare, object expectedTextCompare) { @@ -323,7 +323,7 @@ public static IEnumerable LikeObj_NullReference_TestData() yield return new object[] { null, "*" }; } - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Theory] [MemberData(nameof(ObjTst_TestData))] public void ObjTst(object x, object y, bool textCompare, object expected) { diff --git a/src/libraries/Microsoft.VisualBasic.Core/tests/OperatorsTests.Comparison.cs b/src/libraries/Microsoft.VisualBasic.Core/tests/OperatorsTests.Comparison.cs index 9e300ec063a232..f90fd7d819824c 100644 --- a/src/libraries/Microsoft.VisualBasic.Core/tests/OperatorsTests.Comparison.cs +++ b/src/libraries/Microsoft.VisualBasic.Core/tests/OperatorsTests.Comparison.cs @@ -1107,7 +1107,7 @@ public static IEnumerable Compare_InvalidObjects_TestData() yield return new object[] { new object(), new char[] { '8' } }; } - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Theory] [MemberData(nameof(Compare_Primitives_TestData))] public void CompareObjectEqual_Invoke_ReturnsExpected(object left, object right, bool greater, bool equal, bool less) { @@ -1171,7 +1171,7 @@ public class CompareObjectEqual public static string op_Equality(OperatorsTests left, CompareObjectEqual right) => "tcejbomotsuc"; } - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Theory] [MemberData(nameof(Compare_Primitives_TestData))] public void CompareObjectGreater_Invoke_ReturnsExpected(object left, object right, bool greater, bool equal, bool less) { @@ -1235,7 +1235,7 @@ public class CompareObjectGreater public static string op_GreaterThan(OperatorsTests left, CompareObjectGreater right) => "tcejbomotsuc"; } - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Theory] [MemberData(nameof(Compare_Primitives_TestData))] public void CompareObjectGreaterEqual_Invoke_ReturnsExpected(object left, object right, bool greater, bool equal, bool less) { @@ -1298,7 +1298,7 @@ public class CompareObjectGreaterEqual public static string op_GreaterThanOrEqual(OperatorsTests left, CompareObjectGreaterEqual right) => "tcejbomotsuc"; } - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Theory] [MemberData(nameof(Compare_Primitives_TestData))] public void CompareObjectLess_Invoke_ReturnsExpected(object left, object right, bool greater, bool equal, bool less) { @@ -1362,7 +1362,7 @@ public class CompareObjectLess public static string op_LessThan(OperatorsTests left, CompareObjectLess right) => "tcejbomotsuc"; } - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Theory] [MemberData(nameof(Compare_Primitives_TestData))] public void CompareObjectLessEqual_Invoke_ReturnsExpected(object left, object right, bool greater, bool equal, bool less) { @@ -1425,7 +1425,7 @@ public class CompareObjectLessEqual public static string op_LessThanOrEqual(OperatorsTests left, CompareObjectLessEqual right) => "tcejbomotsuc"; } - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Theory] [MemberData(nameof(Compare_Primitives_TestData))] public void CompareObjectNotEqual_Invoke_ReturnsExpected(object left, object right, bool greater, bool equal, bool less) { @@ -1490,7 +1490,7 @@ public class CompareObjectNotEqual } - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Theory] [MemberData(nameof(Compare_Primitives_TestData))] public void ConditionalCompareObjectEqual_Invoke_ReturnsExpected(object left, object right, bool greater, bool equal, bool less) { @@ -1554,7 +1554,7 @@ public class ConditionalCompareObjectEqual public static bool op_Equality(OperatorsTests left, ConditionalCompareObjectEqual right) => true; } - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Theory] [MemberData(nameof(Compare_Primitives_TestData))] public void ConditionalCompareObjectGreater_Invoke_ReturnsExpected(object left, object right, bool greater, bool equal, bool less) { @@ -1618,7 +1618,7 @@ public class ConditionalCompareObjectGreater public static bool op_GreaterThan(OperatorsTests left, ConditionalCompareObjectGreater right) => true; } - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Theory] [MemberData(nameof(Compare_Primitives_TestData))] public void ConditionalCompareObjectGreaterEqual_Invoke_ReturnsExpected(object left, object right, bool greater, bool equal, bool less) { @@ -1681,7 +1681,7 @@ public class ConditionalCompareObjectGreaterEqual public static bool op_GreaterThanOrEqual(OperatorsTests left, ConditionalCompareObjectGreaterEqual right) => true; } - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Theory] [MemberData(nameof(Compare_Primitives_TestData))] public void ConditionalCompareObjectLess_Invoke_ReturnsExpected(object left, object right, bool greater, bool equal, bool less) { @@ -1745,7 +1745,7 @@ public class ConditionalCompareObjectLess public static bool op_LessThan(OperatorsTests left, ConditionalCompareObjectLess right) => true; } - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Theory] [MemberData(nameof(Compare_Primitives_TestData))] public void ConditionalCompareObjectLessEqual_Invoke_ReturnsExpected(object left, object right, bool greater, bool equal, bool less) { @@ -1808,7 +1808,7 @@ public class ConditionalCompareObjectLessEqual public static bool op_LessThanOrEqual(OperatorsTests left, ConditionalCompareObjectLessEqual right) => true; } - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Theory] [MemberData(nameof(Compare_Primitives_TestData))] public void ConditionalCompareObjectNotEqual_Invoke_ReturnsExpected(object left, object right, bool greater, bool equal, bool less) { diff --git a/src/libraries/Microsoft.VisualBasic.Core/tests/StringTypeTests.cs b/src/libraries/Microsoft.VisualBasic.Core/tests/StringTypeTests.cs index 76d390ea840e61..8d4d2842766d7f 100644 --- a/src/libraries/Microsoft.VisualBasic.Core/tests/StringTypeTests.cs +++ b/src/libraries/Microsoft.VisualBasic.Core/tests/StringTypeTests.cs @@ -363,7 +363,7 @@ public void MidStmtStr_ArgumentException(string str, int start, int length, stri Assert.Throws(() => StringType.MidStmtStr(ref str, start, length, insert)); } - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Theory] [MemberData(nameof(StrCmp_TestData))] public void StrCmp(string left, string right, int expectedBinaryCompare, int expectedTextCompare) { @@ -388,7 +388,7 @@ public static IEnumerable StrCmp_TestData() yield return new object[] { "abc", "ABC", 32, 0 }; } - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Theory] [InlineData(null, null, true, true)] [InlineData("", null, true, true)] [InlineData("", "*", true, true)] diff --git a/src/libraries/Microsoft.VisualBasic.Core/tests/StringsTests.cs b/src/libraries/Microsoft.VisualBasic.Core/tests/StringsTests.cs index 037412ed582757..27967fa777fe10 100644 --- a/src/libraries/Microsoft.VisualBasic.Core/tests/StringsTests.cs +++ b/src/libraries/Microsoft.VisualBasic.Core/tests/StringsTests.cs @@ -431,7 +431,7 @@ public void InStr_BinaryCompare(string string1, string string2, int expected) Assert.Equal(expected, Strings.InStr(1, string1, string2, CompareMethod.Binary)); } - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Theory] [InlineData("A", "a", 1)] [InlineData("Aa", "a", 1)] public void InStr_TextCompare(string string1, string string2, int expected) @@ -479,7 +479,7 @@ public void InStrRev_BinaryCompare(string stringCheck, string stringMatch, int s Assert.Equal(expected, Strings.InStrRev(stringCheck, stringMatch, start, CompareMethod.Binary)); } - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Theory] [InlineData("A", "a", 1, 1)] [InlineData("aA", "a", 2, 2)] public void InStrRev_TextCompare(string stringCheck, string stringMatch, int start, int expected) @@ -779,7 +779,7 @@ public void Trim_Valid(string str, string expected) Assert.Equal(expected, Strings.Trim(str)); } - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Theory] [InlineData("", "", null, 1, -1, CompareMethod.Text, null)] [InlineData("", null, "", 1, -1, CompareMethod.Text, null)] [InlineData("", "", "", 1, -1, CompareMethod.Text, null)] @@ -815,7 +815,7 @@ public void Space(int number, string expected) Assert.Equal(expected, Strings.Space(number)); } - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Theory] [InlineData(null, null, -1, CompareMethod.Text, new string[] { "" })] [InlineData(null, "", -1, CompareMethod.Text, new string[] { "" })] [InlineData("", null, -1, CompareMethod.Text, new string[] { "" })] @@ -833,14 +833,14 @@ public void Split(string expression, string delimiter, int limit, CompareMethod Assert.Equal(expected, Strings.Split(expression, delimiter, limit, compare)); } - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Theory] [InlineData("A, B, C", ", ", 0, CompareMethod.Text)] public void Split_IndexOutOfRangeException(string expression, string delimiter, int limit, CompareMethod compare) { Assert.Throws< IndexOutOfRangeException>(() => Strings.Split(expression, delimiter, limit, compare)); } - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Theory] [InlineData("a", "a", 0, 0)] [InlineData("a", "b", -1, -1)] [InlineData("b", "a", 1, 1)] diff --git a/src/libraries/System.Collections.NonGeneric/tests/CaseInsensitiveHashCodeProviderTests.cs b/src/libraries/System.Collections.NonGeneric/tests/CaseInsensitiveHashCodeProviderTests.cs index 18b2e7421682c6..a90472206c8da2 100644 --- a/src/libraries/System.Collections.NonGeneric/tests/CaseInsensitiveHashCodeProviderTests.cs +++ b/src/libraries/System.Collections.NonGeneric/tests/CaseInsensitiveHashCodeProviderTests.cs @@ -13,7 +13,7 @@ namespace System.Collections.Tests { public class CaseInsensitiveHashCodeProviderTests { - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Theory] [InlineData("hello", "HELLO", true)] [InlineData("hello", "hello", true)] [InlineData("HELLO", "HELLO", true)] @@ -29,7 +29,7 @@ public void Ctor_Empty_GetHashCodeCompare(object a, object b, bool expected) Assert.Equal(expected, provider.GetHashCode(a) == provider.GetHashCode(b)); } - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Theory] [InlineData("hello", "HELLO", true)] [InlineData("hello", "hello", true)] [InlineData("HELLO", "HELLO", true)] @@ -63,7 +63,7 @@ public void Ctor_Empty_ChangeCurrentCulture_GetHashCodeCompare(object a, object } } - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Theory] [InlineData("hello", "HELLO", true)] [InlineData("hello", "hello", true)] [InlineData("HELLO", "HELLO", true)] @@ -94,7 +94,7 @@ public void Ctor_CultureInfo_ChangeCurrentCulture_GetHashCodeCompare(object a, o } } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Fact] [ActiveIssue("https://github.com/dotnet/runtime/issues/37069", TestPlatforms.Android | TestPlatforms.LinuxBionic)] [ActiveIssue("https://github.com/dotnet/runtime/issues/95338", typeof(PlatformDetection), nameof(PlatformDetection.IsHybridGlobalizationOnOSX))] public void Ctor_CultureInfo_GetHashCodeCompare_TurkishI() @@ -135,7 +135,7 @@ public void GetHashCode_NullObj_ThrowsArgumentNullException() AssertExtensions.Throws("obj", () => new CaseInsensitiveHashCodeProvider().GetHashCode(null)); } - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Theory] [InlineData("hello", "HELLO", true)] [InlineData("hello", "hello", true)] [InlineData("HELLO", "HELLO", true)] diff --git a/src/libraries/System.Collections.NonGeneric/tests/CollectionsUtilTests.cs b/src/libraries/System.Collections.NonGeneric/tests/CollectionsUtilTests.cs index 9b46116d50ed23..e5735bdbbbb7ef 100644 --- a/src/libraries/System.Collections.NonGeneric/tests/CollectionsUtilTests.cs +++ b/src/libraries/System.Collections.NonGeneric/tests/CollectionsUtilTests.cs @@ -8,7 +8,7 @@ namespace System.Collections.Tests { public static class CollectionsUtilTests { - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Fact] public static void CreateCaseInsensitiveHashtable() { Hashtable hashtable = CollectionsUtil.CreateCaseInsensitiveHashtable(); @@ -20,7 +20,7 @@ public static void CreateCaseInsensitiveHashtable() AssertExtensions.Throws(null, () => hashtable.Add("key1", "value1")); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Fact] public static void CreateCaseInsensitiveHashtable_Capacity() { Hashtable hashtable = CollectionsUtil.CreateCaseInsensitiveHashtable(15); @@ -33,7 +33,7 @@ public static void CreateCaseInsensitiveHashtable_Capacity() AssertExtensions.Throws(null, () => hashtable.Add("key1", "value1")); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Fact] public static void CreateCaseInsensitiveHashtable_IDictionary() { Hashtable hashtable1 = CollectionsUtil.CreateCaseInsensitiveHashtable(); diff --git a/src/libraries/System.Collections.NonGeneric/tests/HashtableTests.cs b/src/libraries/System.Collections.NonGeneric/tests/HashtableTests.cs index c0fddb75701b64..e172e121feac85 100644 --- a/src/libraries/System.Collections.NonGeneric/tests/HashtableTests.cs +++ b/src/libraries/System.Collections.NonGeneric/tests/HashtableTests.cs @@ -779,7 +779,7 @@ public void Values_ModifyingHashtable_ModifiesCollection() } } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Fact] public void HashCodeProvider_Set_ImpactsSearch() { var hash = new ComparableHashtable(CaseInsensitiveHashCodeProvider.DefaultInvariant, StringComparer.OrdinalIgnoreCase); @@ -834,7 +834,7 @@ public void HashCodeProvider_Comparer_IncompatibleGetSet_Throws() AssertExtensions.Throws(null, () => hash.Comparer = StringComparer.OrdinalIgnoreCase); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Fact] public void Comparer_Set_ImpactsSearch() { var hash = new ComparableHashtable(CaseInsensitiveHashCodeProvider.DefaultInvariant, StringComparer.OrdinalIgnoreCase); diff --git a/src/libraries/System.Collections.Specialized/tests/NameObjectCollectionBase/NameObjectCollectionBase.ConstructorTests.cs b/src/libraries/System.Collections.Specialized/tests/NameObjectCollectionBase/NameObjectCollectionBase.ConstructorTests.cs index e34009b7c97fb2..9ede42f1d18d42 100644 --- a/src/libraries/System.Collections.Specialized/tests/NameObjectCollectionBase/NameObjectCollectionBase.ConstructorTests.cs +++ b/src/libraries/System.Collections.Specialized/tests/NameObjectCollectionBase/NameObjectCollectionBase.ConstructorTests.cs @@ -20,7 +20,7 @@ public void Constructor_Provider_Comparer() Assert.Equal(0, coll.Count); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Fact] public void Constructor_Int_Provider_Comparer() { #pragma warning disable CS0618 // Type or member is obsolete diff --git a/src/libraries/System.Collections.Specialized/tests/NameObjectCollectionBase/NameObjectCollectionBase.CopyToTests.cs b/src/libraries/System.Collections.Specialized/tests/NameObjectCollectionBase/NameObjectCollectionBase.CopyToTests.cs index d8eb5ae5777d72..74b351ff4007ce 100644 --- a/src/libraries/System.Collections.Specialized/tests/NameObjectCollectionBase/NameObjectCollectionBase.CopyToTests.cs +++ b/src/libraries/System.Collections.Specialized/tests/NameObjectCollectionBase/NameObjectCollectionBase.CopyToTests.cs @@ -7,7 +7,7 @@ namespace System.Collections.Specialized.Tests { public class NameObjectCollectionBaseCopyToTests { - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Theory] [InlineData(0, 0)] [InlineData(0, 5)] [InlineData(10, 0)] @@ -39,7 +39,7 @@ public void CopyTo(int count, int index) Assert.Equal(previousCount, copyArray.Length); } - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Theory] [InlineData(0)] [InlineData(10)] public void CopyTo_Invalid(int count) diff --git a/src/libraries/System.Collections.Specialized/tests/NameObjectCollectionBase/NameObjectCollectionBase.GetAllValuesTests.cs b/src/libraries/System.Collections.Specialized/tests/NameObjectCollectionBase/NameObjectCollectionBase.GetAllValuesTests.cs index b9a64ecc30aedb..941b943be7ab0f 100644 --- a/src/libraries/System.Collections.Specialized/tests/NameObjectCollectionBase/NameObjectCollectionBase.GetAllValuesTests.cs +++ b/src/libraries/System.Collections.Specialized/tests/NameObjectCollectionBase/NameObjectCollectionBase.GetAllValuesTests.cs @@ -7,7 +7,7 @@ namespace System.Collections.Specialized.Tests { public class GetAllValuesTests { - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Theory] [InlineData(0, typeof(object))] [InlineData(0, typeof(Foo))] [InlineData(10, typeof(object))] @@ -33,7 +33,7 @@ private static void VerifyGetAllValues(NameObjectCollectionBase nameObjectCollec } } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Fact] public static void GetAllValues_Invalid() { MyNameObjectCollection nameObjectCollection = new MyNameObjectCollection(); diff --git a/src/libraries/System.Collections.Specialized/tests/NameObjectCollectionBase/NameObjectCollectionBase.GetEnumeratorTests.cs b/src/libraries/System.Collections.Specialized/tests/NameObjectCollectionBase/NameObjectCollectionBase.GetEnumeratorTests.cs index 3f7ec1338bf876..7d1c06f066a113 100644 --- a/src/libraries/System.Collections.Specialized/tests/NameObjectCollectionBase/NameObjectCollectionBase.GetEnumeratorTests.cs +++ b/src/libraries/System.Collections.Specialized/tests/NameObjectCollectionBase/NameObjectCollectionBase.GetEnumeratorTests.cs @@ -7,7 +7,7 @@ namespace System.Collections.Specialized.Tests { public class NameObjectCollectionBaseGetEnumeratorTests { - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Theory] [InlineData(0)] [InlineData(10)] public void GetEnumerator(int count) @@ -29,7 +29,7 @@ public void GetEnumerator(int count) } } - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Theory] [InlineData(0)] [InlineData(10)] public void GetEnumerator_Invalid(int count) diff --git a/src/libraries/System.Collections.Specialized/tests/NameObjectCollectionBase/NameObjectCollectionBase.KeysTests.cs b/src/libraries/System.Collections.Specialized/tests/NameObjectCollectionBase/NameObjectCollectionBase.KeysTests.cs index db56a194ad67a1..f1edcf9aad34a3 100644 --- a/src/libraries/System.Collections.Specialized/tests/NameObjectCollectionBase/NameObjectCollectionBase.KeysTests.cs +++ b/src/libraries/System.Collections.Specialized/tests/NameObjectCollectionBase/NameObjectCollectionBase.KeysTests.cs @@ -7,7 +7,7 @@ namespace System.Collections.Specialized.Tests { public class NameObjectCollectionBaseKeysTests { - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Theory] [InlineData(0)] [InlineData(10)] public void Keys_PreservesInstance(int count) @@ -16,7 +16,7 @@ public void Keys_PreservesInstance(int count) Assert.Same(nameObjectCollection.Keys, nameObjectCollection.Keys); } - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Theory] [InlineData(0)] [InlineData(10)] public void Keys_GetEnumerator(int count) @@ -40,7 +40,7 @@ public void Keys_GetEnumerator(int count) } } - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Theory] [InlineData(0)] [InlineData(10)] public void Keys_GetEnumerator_Invalid(int count) @@ -85,7 +85,7 @@ public void Keys_GetEnumerator_Invalid(int count) Assert.Throws(() => enumerator.Reset()); } - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Theory] [InlineData(0)] [InlineData(10)] public void Keys_Properties(int count) @@ -97,7 +97,7 @@ public void Keys_Properties(int count) Assert.False(keysCollection.IsSynchronized); } - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Theory] [InlineData(0, 0)] [InlineData(0, 5)] [InlineData(10, 0)] @@ -145,7 +145,7 @@ private static void Keys_CopyTo_Helper(MyNameObjectCollection nameObjectCollecti Assert.Equal(previousCount, keysArray.Length); } - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Theory] [InlineData(0)] [InlineData(10)] public void Keys_CopyTo_Invalid(int count) diff --git a/src/libraries/System.Collections.Specialized/tests/NameObjectCollectionBase/NameObjectCollectionBase.ReadOnlyTests.cs b/src/libraries/System.Collections.Specialized/tests/NameObjectCollectionBase/NameObjectCollectionBase.ReadOnlyTests.cs index e05a2e78936c5c..05af2efe640003 100644 --- a/src/libraries/System.Collections.Specialized/tests/NameObjectCollectionBase/NameObjectCollectionBase.ReadOnlyTests.cs +++ b/src/libraries/System.Collections.Specialized/tests/NameObjectCollectionBase/NameObjectCollectionBase.ReadOnlyTests.cs @@ -7,7 +7,7 @@ namespace System.Collections.Specialized.Tests { public class NameObjectCollectionBaseReadOnlyTests { - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Fact] public void IsReadOnly_Set() { MyNameObjectCollection nameObjectCollection = Helpers.CreateNameObjectCollection(10); diff --git a/src/libraries/System.Collections.Specialized/tests/NameObjectCollectionBase/NameObjectCollectionBase.RemoveAtTests.cs b/src/libraries/System.Collections.Specialized/tests/NameObjectCollectionBase/NameObjectCollectionBase.RemoveAtTests.cs index fe99de5af1b7da..4ec96a64fd9ea7 100644 --- a/src/libraries/System.Collections.Specialized/tests/NameObjectCollectionBase/NameObjectCollectionBase.RemoveAtTests.cs +++ b/src/libraries/System.Collections.Specialized/tests/NameObjectCollectionBase/NameObjectCollectionBase.RemoveAtTests.cs @@ -7,7 +7,7 @@ namespace System.Collections.Specialized.Tests { public class NameObjectCollectionBaseRemoveAtTests { - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Fact] public void RemoveAt() { MyNameObjectCollection nameObjectCollection = Helpers.CreateNameObjectCollection(10); @@ -59,7 +59,7 @@ public void RemoveAt() } } - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Theory] [InlineData(0)] [InlineData(10)] public void RemoveAt_InvalidIndex_ThrowsArgumentOutOfRangeException(int count) @@ -69,7 +69,7 @@ public void RemoveAt_InvalidIndex_ThrowsArgumentOutOfRangeException(int count) AssertExtensions.Throws("index", () => nameObjectCollection.RemoveAt(count)); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Fact] public void RemoveAt_ReadOnly_ThrowsNotSupportedException() { MyNameObjectCollection nameObjectCollection = Helpers.CreateNameObjectCollection(1); diff --git a/src/libraries/System.Collections.Specialized/tests/NameObjectCollectionBase/NameObjectCollectionBase.SetItemTests.cs b/src/libraries/System.Collections.Specialized/tests/NameObjectCollectionBase/NameObjectCollectionBase.SetItemTests.cs index 398aab7fabf132..c1f1bd54acfcbf 100644 --- a/src/libraries/System.Collections.Specialized/tests/NameObjectCollectionBase/NameObjectCollectionBase.SetItemTests.cs +++ b/src/libraries/System.Collections.Specialized/tests/NameObjectCollectionBase/NameObjectCollectionBase.SetItemTests.cs @@ -7,7 +7,7 @@ namespace System.Collections.Specialized.Tests { public class NameObjectCollectionBaseSetItemTests { - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Fact] public void Set_ObjectAtIndex_ModifiesCollection() { var noc = new MyNameObjectCollection(); diff --git a/src/libraries/System.Collections.Specialized/tests/NameValueCollection/NameValueCollection.AddNVCTests.cs b/src/libraries/System.Collections.Specialized/tests/NameValueCollection/NameValueCollection.AddNVCTests.cs index 82578fb7de13a0..538b9c924ce2a1 100644 --- a/src/libraries/System.Collections.Specialized/tests/NameValueCollection/NameValueCollection.AddNVCTests.cs +++ b/src/libraries/System.Collections.Specialized/tests/NameValueCollection/NameValueCollection.AddNVCTests.cs @@ -8,7 +8,7 @@ namespace System.Collections.Specialized.Tests { public class NameValueCollectionAddNameValueCollectionTests { - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Theory] [InlineData(0, 0)] [InlineData(0, 5)] [InlineData(5, 0)] @@ -43,7 +43,7 @@ public void Add(int count1, int count2) } } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Fact] public void Add_ExistingKeys() { NameValueCollection nameValueCollection1 = new NameValueCollection(); @@ -61,7 +61,7 @@ public void Add_ExistingKeys() Assert.Equal(new string[] { value2, value1 }, nameValueCollection2.GetValues(name)); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Fact] public void Add_MultipleValues() { NameValueCollection nameValueCollection1 = new NameValueCollection(); @@ -104,7 +104,7 @@ public void Add_NameValueCollection_WithNullKeys() Assert.Equal(nullKeyValue1 + "," + nullKeyValue2, nameValueCollection3[null]); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Fact] public void Add_NameValueCollection_WithNullValues() { NameValueCollection nameValueCollection1 = new NameValueCollection(); diff --git a/src/libraries/System.Collections.Specialized/tests/NameValueCollection/NameValueCollection.AddStringStringTests.cs b/src/libraries/System.Collections.Specialized/tests/NameValueCollection/NameValueCollection.AddStringStringTests.cs index 28ba9d7ad71ad0..dc148f198c3581 100644 --- a/src/libraries/System.Collections.Specialized/tests/NameValueCollection/NameValueCollection.AddStringStringTests.cs +++ b/src/libraries/System.Collections.Specialized/tests/NameValueCollection/NameValueCollection.AddStringStringTests.cs @@ -8,7 +8,7 @@ namespace System.Collections.Specialized.Tests { public class NameValueCollectionAddStringStringTests { - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Fact] public void Add() { NameValueCollection nameValueCollection = new NameValueCollection(); @@ -82,7 +82,7 @@ public void Add_NullName() Assert.False(nameValueCollection.HasKeys()); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Fact] public void Add_NullValue() { NameValueCollection nameValueCollection = new NameValueCollection(); @@ -108,7 +108,7 @@ public void Add_NullValue() Assert.True(nameValueCollection.HasKeys()); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Fact] public void Add_AddingValueToExistingName_AppendsValueToOriginalValue() { var nameValueCollection = new NameValueCollection(); diff --git a/src/libraries/System.Collections.Specialized/tests/NameValueCollection/NameValueCollection.ClearTests.cs b/src/libraries/System.Collections.Specialized/tests/NameValueCollection/NameValueCollection.ClearTests.cs index acdf6b442eabb4..b15395c354d111 100644 --- a/src/libraries/System.Collections.Specialized/tests/NameValueCollection/NameValueCollection.ClearTests.cs +++ b/src/libraries/System.Collections.Specialized/tests/NameValueCollection/NameValueCollection.ClearTests.cs @@ -7,7 +7,7 @@ namespace System.Collections.Specialized.Tests { public class NameValueCollectionClearTests { - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Theory] [InlineData(0)] [InlineData(10)] public void Clear(int count) diff --git a/src/libraries/System.Collections.Specialized/tests/NameValueCollection/NameValueCollection.CopyToTests.cs b/src/libraries/System.Collections.Specialized/tests/NameValueCollection/NameValueCollection.CopyToTests.cs index 409ccd25c8ab41..2daff0ba450f96 100644 --- a/src/libraries/System.Collections.Specialized/tests/NameValueCollection/NameValueCollection.CopyToTests.cs +++ b/src/libraries/System.Collections.Specialized/tests/NameValueCollection/NameValueCollection.CopyToTests.cs @@ -7,7 +7,7 @@ namespace System.Collections.Specialized.Tests { public class NameValueCollectionCopyToTests { - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Theory] [InlineData(0, 0)] [InlineData(0, 1)] [InlineData(5, 0)] @@ -37,7 +37,7 @@ public void CopyTo(int count, int index) } } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Fact] public void CopyTo_MultipleValues_SameName() { NameValueCollection nameValueCollection = new NameValueCollection(); @@ -51,7 +51,7 @@ public void CopyTo_MultipleValues_SameName() Assert.Equal(nameValueCollection[0], dest[0]); } - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Theory] [InlineData(0)] [InlineData(5)] public void CopyTo_Invalid(int count) diff --git a/src/libraries/System.Collections.Specialized/tests/NameValueCollection/NameValueCollection.CtorTests.cs b/src/libraries/System.Collections.Specialized/tests/NameValueCollection/NameValueCollection.CtorTests.cs index c7106153faf89f..20cf0fe5af5123 100644 --- a/src/libraries/System.Collections.Specialized/tests/NameValueCollection/NameValueCollection.CtorTests.cs +++ b/src/libraries/System.Collections.Specialized/tests/NameValueCollection/NameValueCollection.CtorTests.cs @@ -46,7 +46,7 @@ public void Ctor_Int_Provider_Comparer() Assert.False(((ICollection)nameValueCollection).IsSynchronized); } - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Theory] [InlineData(0)] [InlineData(5)] public void Ctor_Int(int capacity) @@ -85,7 +85,7 @@ public static IEnumerable Ctor_NameValueCollection_TestData() yield return new object[] { Helpers.CreateNameValueCollection(10) }; } - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Theory] [MemberData(nameof(Ctor_NameValueCollection_TestData))] public void Ctor_NameValueCollection(NameValueCollection nameValueCollection1) { @@ -126,7 +126,7 @@ public static IEnumerable Ctor_Int_NameValueCollection_TestData() yield return new object[] { 15, Helpers.CreateNameValueCollection(10) }; } - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Theory] [MemberData(nameof(Ctor_Int_NameValueCollection_TestData))] public void Ctor_Int_NameValueCollection(int capacity, NameValueCollection nameValueCollection1) { @@ -156,7 +156,7 @@ public static IEnumerable Ctor_Int_IEqualityComparer_TestData() yield return new object[] { 10, null }; } - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Theory] [MemberData(nameof(Ctor_Int_IEqualityComparer_TestData))] public void Ctor_Int_IEqualityComparer(int capacity, IEqualityComparer equalityComparer) { @@ -170,7 +170,7 @@ public static IEnumerable Ctor_IEqualityComparer_TestData() yield return new object[] { null }; } - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Theory] [MemberData(nameof(Ctor_IEqualityComparer_TestData))] public void Ctor_IEqualityComparer(IEqualityComparer equalityComparer) { diff --git a/src/libraries/System.Collections.Specialized/tests/NameValueCollection/NameValueCollection.GetIntTests.cs b/src/libraries/System.Collections.Specialized/tests/NameValueCollection/NameValueCollection.GetIntTests.cs index ba652ced4b86ba..c8b4fdc6c996e2 100644 --- a/src/libraries/System.Collections.Specialized/tests/NameValueCollection/NameValueCollection.GetIntTests.cs +++ b/src/libraries/System.Collections.Specialized/tests/NameValueCollection/NameValueCollection.GetIntTests.cs @@ -7,7 +7,7 @@ namespace System.Collections.Specialized.Tests { public class NameValueCollectionGetIntTests { - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Theory] [InlineData(0)] [InlineData(5)] public void Get_InvalidIndex_ThrowsArgumentOutOfRangeException(int count) diff --git a/src/libraries/System.Collections.Specialized/tests/NameValueCollection/NameValueCollection.GetItemTests.cs b/src/libraries/System.Collections.Specialized/tests/NameValueCollection/NameValueCollection.GetItemTests.cs index c6e723e1a52f5d..82e63d654e47c2 100644 --- a/src/libraries/System.Collections.Specialized/tests/NameValueCollection/NameValueCollection.GetItemTests.cs +++ b/src/libraries/System.Collections.Specialized/tests/NameValueCollection/NameValueCollection.GetItemTests.cs @@ -7,7 +7,7 @@ namespace System.Collections.Specialized.Tests { public class NameValueCollectionGetItemTests { - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Theory] [InlineData(0)] [InlineData(5)] public void Item_Get_InvalidIndex_ThrowsArgumentOutOfRangeException(int count) diff --git a/src/libraries/System.Collections.Specialized/tests/NameValueCollection/NameValueCollection.GetKeyTests.cs b/src/libraries/System.Collections.Specialized/tests/NameValueCollection/NameValueCollection.GetKeyTests.cs index 4e0b496448802b..c283053d0c70c9 100644 --- a/src/libraries/System.Collections.Specialized/tests/NameValueCollection/NameValueCollection.GetKeyTests.cs +++ b/src/libraries/System.Collections.Specialized/tests/NameValueCollection/NameValueCollection.GetKeyTests.cs @@ -7,7 +7,7 @@ namespace System.Collections.Specialized.Tests { public class NameValueCollectionGetKeyTests { - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Theory] [InlineData(0)] [InlineData(5)] public void Get_InvalidIndex_ThrowsArgumentOutOfRangeException(int count) diff --git a/src/libraries/System.Collections.Specialized/tests/NameValueCollection/NameValueCollection.GetStringTests.cs b/src/libraries/System.Collections.Specialized/tests/NameValueCollection/NameValueCollection.GetStringTests.cs index d61cabe1900b39..47c6e1db59e8d4 100644 --- a/src/libraries/System.Collections.Specialized/tests/NameValueCollection/NameValueCollection.GetStringTests.cs +++ b/src/libraries/System.Collections.Specialized/tests/NameValueCollection/NameValueCollection.GetStringTests.cs @@ -7,7 +7,7 @@ namespace System.Collections.Specialized.Tests { public class NameValueCollectionGetStringTests { - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Theory] [InlineData(0)] [InlineData(5)] public void Get_NoSuchName_ReturnsNull(int count) diff --git a/src/libraries/System.Collections.Specialized/tests/NameValueCollection/NameValueCollection.GetValuesIntTests.cs b/src/libraries/System.Collections.Specialized/tests/NameValueCollection/NameValueCollection.GetValuesIntTests.cs index b179a4b6bfd2c8..dc7bfaca4f64c2 100644 --- a/src/libraries/System.Collections.Specialized/tests/NameValueCollection/NameValueCollection.GetValuesIntTests.cs +++ b/src/libraries/System.Collections.Specialized/tests/NameValueCollection/NameValueCollection.GetValuesIntTests.cs @@ -7,7 +7,7 @@ namespace System.Collections.Specialized.Tests { public class NameValueCollectionGetValuesIntTests { - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Theory] [InlineData(0)] [InlineData(5)] public void GetValues_InvalidIndex_ThrowsArgumentOutOfRangeException(int count) diff --git a/src/libraries/System.Collections.Specialized/tests/NameValueCollection/NameValueCollection.GetValuesStringTests.cs b/src/libraries/System.Collections.Specialized/tests/NameValueCollection/NameValueCollection.GetValuesStringTests.cs index b7deb3badfc452..0371dc9e20ad84 100644 --- a/src/libraries/System.Collections.Specialized/tests/NameValueCollection/NameValueCollection.GetValuesStringTests.cs +++ b/src/libraries/System.Collections.Specialized/tests/NameValueCollection/NameValueCollection.GetValuesStringTests.cs @@ -7,7 +7,7 @@ namespace System.Collections.Specialized.Tests { public class NameValueCollectionGetValuesStringTests { - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Theory] [InlineData(0)] [InlineData(5)] public void GetValues_NoSuchName_ReturnsNull(int count) diff --git a/src/libraries/System.Collections.Specialized/tests/NameValueCollection/NameValueCollection.RemoveTests.cs b/src/libraries/System.Collections.Specialized/tests/NameValueCollection/NameValueCollection.RemoveTests.cs index 65e582c346a642..34e48ae0ba55d8 100644 --- a/src/libraries/System.Collections.Specialized/tests/NameValueCollection/NameValueCollection.RemoveTests.cs +++ b/src/libraries/System.Collections.Specialized/tests/NameValueCollection/NameValueCollection.RemoveTests.cs @@ -8,7 +8,7 @@ namespace System.Collections.Specialized.Tests { public class NameValueCollectionRemoveTests { - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Theory] [InlineData(0)] [InlineData(5)] public void Remove(int count) @@ -46,7 +46,7 @@ public void Remove(int count) } } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Fact] public void Remove_MultipleValues_SameName() { NameValueCollection nameValueCollection = new NameValueCollection(); diff --git a/src/libraries/System.Collections.Specialized/tests/NameValueCollection/NameValueCollection.SetItemTests.cs b/src/libraries/System.Collections.Specialized/tests/NameValueCollection/NameValueCollection.SetItemTests.cs index dc9e8bb14598be..de3e23ecd4086f 100644 --- a/src/libraries/System.Collections.Specialized/tests/NameValueCollection/NameValueCollection.SetItemTests.cs +++ b/src/libraries/System.Collections.Specialized/tests/NameValueCollection/NameValueCollection.SetItemTests.cs @@ -7,7 +7,7 @@ namespace System.Collections.Specialized.Tests { public class NameValueCollectionSetItemTests { - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Fact] public void Item_Set() { NameValueCollection nameValueCollection = new NameValueCollection(); @@ -22,7 +22,7 @@ public void Item_Set() } } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Fact] public void Item_Set_OvewriteExistingValue() { NameValueCollection nameValueCollection = new NameValueCollection(); @@ -35,7 +35,7 @@ public void Item_Set_OvewriteExistingValue() Assert.Equal(new string[] { value }, nameValueCollection.GetValues(name)); } - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Theory] [InlineData(0)] [InlineData(5)] public void Item_Set_NullName(int count) @@ -53,7 +53,7 @@ public void Item_Set_NullName(int count) Assert.Equal(newNullNameValue, nameValueCollection[null]); } - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Theory] [InlineData(0)] [InlineData(5)] public void Item_Set_NullValue(int count) @@ -74,7 +74,7 @@ public void Item_Set_NullValue(int count) Assert.Null(nameValueCollection[nullValueName]); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Fact] public void Item_Set_IsCaseSensitive() { NameValueCollection nameValueCollection = new NameValueCollection(); diff --git a/src/libraries/System.Collections.Specialized/tests/NameValueCollection/NameValueCollection.SetTests.cs b/src/libraries/System.Collections.Specialized/tests/NameValueCollection/NameValueCollection.SetTests.cs index 79e8c037ed15bf..6873b3e8a22d24 100644 --- a/src/libraries/System.Collections.Specialized/tests/NameValueCollection/NameValueCollection.SetTests.cs +++ b/src/libraries/System.Collections.Specialized/tests/NameValueCollection/NameValueCollection.SetTests.cs @@ -7,7 +7,7 @@ namespace System.Collections.Specialized.Tests { public class NameValueCollectionSetTests { - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Fact] public void Set() { NameValueCollection nameValueCollection = new NameValueCollection(); @@ -23,7 +23,7 @@ public void Set() } } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Fact] public void Set_OvewriteExistingValue() { NameValueCollection nameValueCollection = new NameValueCollection(); @@ -36,7 +36,7 @@ public void Set_OvewriteExistingValue() Assert.Equal(new string[] { value }, nameValueCollection.GetValues(name)); } - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Theory] [InlineData(0)] [InlineData(5)] public void Set_NullName(int count) @@ -54,7 +54,7 @@ public void Set_NullName(int count) Assert.Equal(newNullNameValue, nameValueCollection.Get(null)); } - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Theory] [InlineData(0)] [InlineData(5)] public void Set_NullValue(int count) @@ -75,7 +75,7 @@ public void Set_NullValue(int count) Assert.Null(nameValueCollection.Get(nullValueName)); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Fact] public void Set_IsCaseSensitive() { NameValueCollection nameValueCollection = new NameValueCollection(); diff --git a/src/libraries/System.Collections.Specialized/tests/OrderedDictionary/OrderedDictionaryTests.cs b/src/libraries/System.Collections.Specialized/tests/OrderedDictionary/OrderedDictionaryTests.cs index f24d0cd7892e34..ac1163d28c0410 100644 --- a/src/libraries/System.Collections.Specialized/tests/OrderedDictionary/OrderedDictionaryTests.cs +++ b/src/libraries/System.Collections.Specialized/tests/OrderedDictionary/OrderedDictionaryTests.cs @@ -35,7 +35,7 @@ public void CreatingWithDifferentCapacityValues() } // public OrderedDictionary(IEqualityComparer comparer); - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Fact] public void PassingEqualityComparers() { var d1 = new OrderedDictionary(StringComparer.InvariantCultureIgnoreCase); @@ -55,7 +55,7 @@ public void PassingEqualityComparers() } // public OrderedDictionary(int capacity, IEqualityComparer comparer); - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Fact] public void PassingCapacityAndIEqualityComparer() { var d1 = new OrderedDictionary(-1000, StringComparer.InvariantCultureIgnoreCase); @@ -626,7 +626,7 @@ public void KeysAndValuesPropertiesNotSupportWritableIList(bool testKeysProperty Assert.Throws(() => list.RemoveAt(0)); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Fact] public void IListedKeysPropertyCanUseCustomEqualityComparer() { var orderedDictionary = new OrderedDictionary(StringComparer.InvariantCultureIgnoreCase); diff --git a/src/libraries/System.Collections/tests/Generic/Dictionary/HashCollisionScenarios/OutOfBoundsRegression.cs b/src/libraries/System.Collections/tests/Generic/Dictionary/HashCollisionScenarios/OutOfBoundsRegression.cs index 37297f382c0a36..9080852c8d6826 100644 --- a/src/libraries/System.Collections/tests/Generic/Dictionary/HashCollisionScenarios/OutOfBoundsRegression.cs +++ b/src/libraries/System.Collections/tests/Generic/Dictionary/HashCollisionScenarios/OutOfBoundsRegression.cs @@ -42,7 +42,7 @@ public static void OutOfBoundsRegression() } } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Fact] public static void ComparerImplementations_Dictionary_WithWellKnownStringComparers() { Type nonRandomizedOrdinalComparerType = typeof(object).Assembly.GetType("System.Collections.Generic.NonRandomizedStringEqualityComparer+OrdinalComparer", throwOnError: true); @@ -118,7 +118,7 @@ static void RunDictionaryTest( } } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Fact] public static void ComparerImplementations_HashSet_WithWellKnownStringComparers() { Type nonRandomizedOrdinalComparerType = typeof(object).Assembly.GetType("System.Collections.Generic.NonRandomizedStringEqualityComparer+OrdinalComparer", throwOnError: true); diff --git a/src/libraries/System.Data.Common/tests/System.Data.DataSetExtensions.Tests/Mono/DataRowComparerTest.cs b/src/libraries/System.Data.Common/tests/System.Data.DataSetExtensions.Tests/Mono/DataRowComparerTest.cs index c3350234eacc76..6d4ddbe9b3f58d 100644 --- a/src/libraries/System.Data.Common/tests/System.Data.DataSetExtensions.Tests/Mono/DataRowComparerTest.cs +++ b/src/libraries/System.Data.Common/tests/System.Data.DataSetExtensions.Tests/Mono/DataRowComparerTest.cs @@ -45,7 +45,7 @@ public void Default() Assert.Same(c1, c2); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Fact] public void EqualsTest() { DataRowComparer c = DataRowComparer.Default; @@ -123,7 +123,7 @@ public void EqualsTest() Assert.False(c.Equals(r1, r4), "#H2"); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Fact] public void Equals_Rows_Detached() { DataRowComparer c = DataRowComparer.Default; @@ -160,7 +160,7 @@ public void Equals_Rows_Detached() Assert.True(c.Equals(r2, r3), "#C3"); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Fact] public void Equals_Rows_Deleted() { DataRowComparer c = DataRowComparer.Default; @@ -216,7 +216,7 @@ public void Equals_Rows_Deleted() } } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Fact] public void GetHashCodeWithVersions() { DataSet ds = new DataSet(); diff --git a/src/libraries/System.Data.Common/tests/System.Data.DataSetExtensions.Tests/Mono/DataRowExtensionsTest.cs b/src/libraries/System.Data.Common/tests/System.Data.DataSetExtensions.Tests/Mono/DataRowExtensionsTest.cs index 3cf12c4d4648d2..a03fc946672ebd 100644 --- a/src/libraries/System.Data.Common/tests/System.Data.DataSetExtensions.Tests/Mono/DataRowExtensionsTest.cs +++ b/src/libraries/System.Data.Common/tests/System.Data.DataSetExtensions.Tests/Mono/DataRowExtensionsTest.cs @@ -55,7 +55,7 @@ DataRow SetupRow() return row; } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Fact] public void Field_T_DBNullFieldValue() { DataRow row = SetupRow(); @@ -69,7 +69,7 @@ public void Field_T_DBNullFieldValue() Assert.Null(i); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Fact] public void Field_T_DBNullFieldValue_ValueType() { DataRow row = SetupRow(); diff --git a/src/libraries/System.Data.Common/tests/System.Data.DataSetExtensions.Tests/Mono/DataTableExtensionsTest.cs b/src/libraries/System.Data.Common/tests/System.Data.DataSetExtensions.Tests/Mono/DataTableExtensionsTest.cs index edda9c89df4f95..479807057113e7 100644 --- a/src/libraries/System.Data.Common/tests/System.Data.DataSetExtensions.Tests/Mono/DataTableExtensionsTest.cs +++ b/src/libraries/System.Data.Common/tests/System.Data.DataSetExtensions.Tests/Mono/DataTableExtensionsTest.cs @@ -42,7 +42,7 @@ public class DataTableExtensionsTest { private string _testDataSet = "Mono/testdataset1.xml"; - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Fact] public void CopyToDataTableNoArgNoRows() { DataTable dt = new DataTable(); @@ -53,7 +53,7 @@ public void CopyToDataTableNoArgNoRows() Assert.Throws(() => dt.AsEnumerable().CopyToDataTable()); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Fact] public void CopyToDataTableNoArg() { DataTable dt = new DataTable(); @@ -65,7 +65,7 @@ public void CopyToDataTableNoArg() Assert.Equal("foo", dst.Rows[0]["CName"]); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Fact] public void CopyToDataTableTableArgNoRows() { DataTable dt = new DataTable(); @@ -75,7 +75,7 @@ public void CopyToDataTableTableArgNoRows() dt.AsEnumerable().CopyToDataTable(dst, LoadOption.PreserveChanges); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Fact] public void AsEnumerable() { DataSet ds = new DataSet(); diff --git a/src/libraries/System.Data.Common/tests/System.Data.DataSetExtensions.Tests/Mono/EnumerableRowCollectionTest.cs b/src/libraries/System.Data.Common/tests/System.Data.DataSetExtensions.Tests/Mono/EnumerableRowCollectionTest.cs index ba292235291e37..a1f0dd6ec13ff8 100644 --- a/src/libraries/System.Data.Common/tests/System.Data.DataSetExtensions.Tests/Mono/EnumerableRowCollectionTest.cs +++ b/src/libraries/System.Data.Common/tests/System.Data.DataSetExtensions.Tests/Mono/EnumerableRowCollectionTest.cs @@ -41,7 +41,7 @@ public class EnumerableRowCollectionTest { private string _testDataSet = "Mono/testdataset1.xml"; - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Fact] public void QueryWhere() { var ds = new DataSet(); @@ -68,7 +68,7 @@ where line.Field("Score") > 80 } } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Fact] public void QueryWhereSelect () { var ds = new DataSet (); @@ -89,7 +89,7 @@ where line.Field ("Score") > 80 } } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Fact] public void QueryWhereSelectOrderBy () { var ds = new DataSet (); @@ -119,7 +119,7 @@ orderby line.Field ("ID") } } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Fact] public void QueryWhereSelectOrderByDescending () { var ds = new DataSet (); @@ -149,7 +149,7 @@ orderby line.Field ("ID") descending } } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Fact] public void ThenBy () { var ds = new DataSet (); @@ -179,7 +179,7 @@ orderby line.Field ("Gender"), line.Field ("ID") } } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Fact] public void ThenByDescending () { var ds = new DataSet (); diff --git a/src/libraries/System.Data.Common/tests/System.Data.DataSetExtensions.Tests/System/Data/DataRowComparerTests.cs b/src/libraries/System.Data.Common/tests/System.Data.DataSetExtensions.Tests/System/Data/DataRowComparerTests.cs index 7652cfe9dac9dc..db2a3420cde136 100644 --- a/src/libraries/System.Data.Common/tests/System.Data.DataSetExtensions.Tests/System/Data/DataRowComparerTests.cs +++ b/src/libraries/System.Data.Common/tests/System.Data.DataSetExtensions.Tests/System/Data/DataRowComparerTests.cs @@ -278,7 +278,7 @@ public static IEnumerable Equals_TestData() }; } - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Theory] [MemberData(nameof(Equals_TestData))] public void Equals_Rows_ReturnsExpected(DataRow row1, DataRow row2, bool expected) { @@ -286,7 +286,7 @@ public void Equals_Rows_ReturnsExpected(DataRow row1, DataRow row2, bool expecte Assert.Equal(expected, DataRowComparer.Default.Equals(row2, row1)); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Fact] public void Equals_NullStringValueInStringArray_CanBeCompared() { var table = new DataTable("Table"); @@ -307,7 +307,7 @@ public void Equals_NullStringValueInStringArray_CanBeCompared() Assert.False(DataRowComparer.Default.Equals(row3, row2)); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Fact] public void Equals_DeletedRow_ThrowsInvalidOperationException() { var table = new DataTable("Table"); @@ -342,7 +342,7 @@ public static IEnumerable GetHashCode_TestData() yield return new object[] { multidimensionalArray, multidimensionalArray.GetHashCode() }; } - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Theory] [MemberData(nameof(GetHashCode_TestData))] public void GetHashCode_HasColumns_ReturnsExpected(object value, int expected) { @@ -362,7 +362,7 @@ public void GetHashCode_NoColumns_ReturnsZero() Assert.Equal(0, DataRowComparer.Default.GetHashCode(table.NewRow())); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Fact] public void GetHashCode_OneColumn_DoesNotReturnZero() { var comparer = DataRowComparer.Default; @@ -379,7 +379,7 @@ public void GetHashCode_NullRow_ThrowsArgumentNullException() AssertExtensions.Throws("row", () => DataRowComparer.Default.GetHashCode(null)); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Fact] public void GetHashCode_DeletedRow_ThrowsInvalidOperationException() { var table = new DataTable("Table"); diff --git a/src/libraries/System.Data.Common/tests/System.Data.DataSetExtensions.Tests/System/Data/DataRowExtensionsTests.cs b/src/libraries/System.Data.Common/tests/System.Data.DataSetExtensions.Tests/System/Data/DataRowExtensionsTests.cs index e9acec3f8c4460..340eb77e7d60a2 100644 --- a/src/libraries/System.Data.Common/tests/System.Data.DataSetExtensions.Tests/System/Data/DataRowExtensionsTests.cs +++ b/src/libraries/System.Data.Common/tests/System.Data.DataSetExtensions.Tests/System/Data/DataRowExtensionsTests.cs @@ -93,7 +93,7 @@ public void Field_ColumnVersion_NullColumnThrows() AssertExtensions.Throws("column", () => DataRowExtensions.Field(row, column: null, version: DataRowVersion.Default)); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Fact] public void Field_NonNullable_Enum() { DataTable table = new DataTable("test"); @@ -105,7 +105,7 @@ public void Field_NonNullable_Enum() Assert.Equal(SomeEnum.Foo, table.Rows[0].Field("col")); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Fact] public void Field_Nullable_Enum() { DataTable table = new DataTable("test"); @@ -136,7 +136,7 @@ public void SetField_IndexValue_NullColumnThrows() Assert.Throws(() => DataRowExtensions.SetField(row, columnIndex: -1, value: 0)); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Fact] public void SetField_IndexValue_NullValueReplacedByDBNull() { DataTable table = new DataTable("test"); @@ -161,7 +161,7 @@ public void SetField_NameValue_NullColumnNameThrows() AssertExtensions.Throws("name", () => DataRowExtensions.SetField(row, columnName: null, value: 0)); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Fact] public void SetField_NameValue_NullValueReplacedByDBNull() { DataTable table = new DataTable("test"); @@ -187,7 +187,7 @@ public void SetField_ColumnValue_NullColumnThrows() AssertExtensions.Throws("column", () => DataRowExtensions.SetField(row, column: null, value: 0)); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Fact] public void SetField_ColumnValue_NullValueReplacedByDBNull() { DataTable table = new DataTable("test"); diff --git a/src/libraries/System.Data.Common/tests/System.Data.DataSetExtensions.Tests/System/Data/EnumerableRowCollectionExtensionsTests.cs b/src/libraries/System.Data.Common/tests/System.Data.DataSetExtensions.Tests/System/Data/EnumerableRowCollectionExtensionsTests.cs index 0806c4a586eb80..2c7a483cd2b663 100644 --- a/src/libraries/System.Data.Common/tests/System.Data.DataSetExtensions.Tests/System/Data/EnumerableRowCollectionExtensionsTests.cs +++ b/src/libraries/System.Data.Common/tests/System.Data.DataSetExtensions.Tests/System/Data/EnumerableRowCollectionExtensionsTests.cs @@ -33,7 +33,7 @@ public override int Compare(T x, T y) return (table, one, two, three); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Fact] public void Where_SuccessfullyFindRow() { TypedTableBase table = new TestTypedTable(); @@ -51,7 +51,7 @@ public void Where_SuccessfullyFindRow() Assert.Same(two, filtered.First()); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Fact] public void OrderBy_AddSortExpressionValidation() { var (table, one, two, three) = InstantiateTable(); @@ -65,7 +65,7 @@ public void OrderBy_AddSortExpressionValidation() Assert.Equal(new DataRow[] { zero, one, two, three }, compared); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Fact] public void OrderByDescending_AddSortExpressionValidation() { var (table, one, two, three) = InstantiateTable(); @@ -79,7 +79,7 @@ public void OrderByDescending_AddSortExpressionValidation() Assert.Equal(new DataRow[] { four, three, two, one }, comparedBackwards); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Fact] public void ThenBy_AddSortExpressionValidation() { var (table, one, two, three) = InstantiateTable(); @@ -97,7 +97,7 @@ public void ThenBy_AddSortExpressionValidation() } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Fact] public void ThenByDescending_AddSortExpressionValidation() { var (table, one, two, three) = InstantiateTable(); diff --git a/src/libraries/System.Data.Common/tests/System.Data.DataSetExtensions.Tests/System/Data/TypedTableBaseExtensionsTests.cs b/src/libraries/System.Data.Common/tests/System.Data.DataSetExtensions.Tests/System/Data/TypedTableBaseExtensionsTests.cs index 02d2b2153d3d0d..ef8516dfc3e163 100644 --- a/src/libraries/System.Data.Common/tests/System.Data.DataSetExtensions.Tests/System/Data/TypedTableBaseExtensionsTests.cs +++ b/src/libraries/System.Data.Common/tests/System.Data.DataSetExtensions.Tests/System/Data/TypedTableBaseExtensionsTests.cs @@ -44,7 +44,7 @@ public class TestTypedTable : TypedTableBase where T : DataRow public TestTypedTable() : base() { } } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Fact] public void ElementAtOrDefault_ValidIndex() { TypedTableBase table = new TestTypedTable(); @@ -54,7 +54,7 @@ public void ElementAtOrDefault_ValidIndex() Assert.Same(zero, table.ElementAtOrDefault(0)); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Fact] public void ElementAtOrDefault_InvalidIndex() { TypedTableBase table = new TestTypedTable(); @@ -64,7 +64,7 @@ public void ElementAtOrDefault_InvalidIndex() Assert.Same(default(DataRow), table.ElementAtOrDefault(1)); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Fact] public void Select_ToListOfInts() { TypedTableBase table = new TestTypedTable(); diff --git a/src/libraries/System.Data.Common/tests/System/Data/DataTableExtensionsTest.cs b/src/libraries/System.Data.Common/tests/System/Data/DataTableExtensionsTest.cs index 3c88b4a785bcc3..9d73511e9b07a9 100644 --- a/src/libraries/System.Data.Common/tests/System/Data/DataTableExtensionsTest.cs +++ b/src/libraries/System.Data.Common/tests/System/Data/DataTableExtensionsTest.cs @@ -51,7 +51,7 @@ public void AsDataView_NullSource_ThrowsArgumentNullException() AssertExtensions.Throws("source", () => DataTableExtensions.AsDataView(null)); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Fact] public void AsDataView_Source_Succeeds() { DataView dv = _dt.AsEnumerable().Where(r => r.Field("alias").Length > 6).AsDataView(); diff --git a/src/libraries/System.Net.Mail/tests/Functional/MailAddressTest.cs b/src/libraries/System.Net.Mail/tests/Functional/MailAddressTest.cs index 70c30ee55a86a3..019ceee0d41b2b 100644 --- a/src/libraries/System.Net.Mail/tests/Functional/MailAddressTest.cs +++ b/src/libraries/System.Net.Mail/tests/Functional/MailAddressTest.cs @@ -210,7 +210,7 @@ public void EqualsTest2() Assert.Equal(n, n2); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Fact] public void GetHashCodeTest() { var n = new MailAddress("Mr. Bar "); @@ -218,7 +218,7 @@ public void GetHashCodeTest() Assert.Equal(n.GetHashCode(), n2.GetHashCode()); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Fact] public void GetHashCodeTest2() { var n = new MailAddress("Mr. Bar "); diff --git a/src/libraries/System.Private.Xml/tests/Xslt/XslCompiledTransformApi/XsltArgumentList.cs b/src/libraries/System.Private.Xml/tests/Xslt/XslCompiledTransformApi/XsltArgumentList.cs index d28d2bf7a840f5..5cdf85852f87c5 100644 --- a/src/libraries/System.Private.Xml/tests/Xslt/XslCompiledTransformApi/XsltArgumentList.cs +++ b/src/libraries/System.Private.Xml/tests/Xslt/XslCompiledTransformApi/XsltArgumentList.cs @@ -3252,7 +3252,7 @@ public void AddExtObject32(object param, XslInputType xslInputType, ReaderType r [InlineData("sort.xsl", "sort.txt", XslInputType.Navigator, ReaderType.XmlValidatingReader, OutputType.Writer, NavType.XPathDocument)] [InlineData("sort.xsl", "sort.txt", XslInputType.Navigator, ReaderType.XmlValidatingReader, OutputType.TextWriter, NavType.XPathDocument)] - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Theory] public void AddExtObject33(object param0, object param1, XslInputType xslInputType, ReaderType readerType, OutputType outputType, NavType navType) { ExObj obj = new ExObj(0, _output); diff --git a/src/libraries/System.Runtime.Caching/tests/System.Runtime.Caching/MemoryCacheTest.cs b/src/libraries/System.Runtime.Caching/tests/System.Runtime.Caching/MemoryCacheTest.cs index 293d959a01674d..5550b59c4d88ef 100644 --- a/src/libraries/System.Runtime.Caching/tests/System.Runtime.Caching/MemoryCacheTest.cs +++ b/src/libraries/System.Runtime.Caching/tests/System.Runtime.Caching/MemoryCacheTest.cs @@ -70,8 +70,6 @@ public static bool SupportsPhysicalMemoryMonitor } public static bool DoesNotSupportPhysicalMemoryMonitor => !SupportsPhysicalMemoryMonitor; - public static bool IsNotHybridGlobalizationOnBrowser => PlatformDetection.IsNotHybridGlobalizationOnBrowser; - private bool IsFullFramework = RuntimeInformation.FrameworkDescription.StartsWith(".NET Framework", StringComparison.OrdinalIgnoreCase); private PokerMemoryCache CreatePokerMemoryCache(string name, string throwOnDisposed) @@ -86,7 +84,7 @@ private PokerMemoryCache CreatePokerMemoryCache(string name, string throwOnDispo return new PokerMemoryCache("MyCache", config); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Fact] public void ConstructorParameters() { MemoryCache mc; @@ -238,7 +236,7 @@ public void DefaultInstanceDefaults() mc.Trim(0); } - [ConditionalFact(nameof(SupportsPhysicalMemoryMonitor), nameof(IsNotHybridGlobalizationOnBrowser))] + [Fact] public void ConstructorValues() { var config = new NameValueCollection(); @@ -260,10 +258,7 @@ public void ConstructorValues() Assert.Equal(TimeSpan.FromMinutes(70), mc.PollingInterval); } - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] - [InlineData("true")] - [InlineData("false")] - [InlineData(null)] + [Theory, InlineData("true"), InlineData("false"), InlineData(null)] public void Indexer(string throwOnDisposed) { var mc = CreatePokerMemoryCache("MyCache", throwOnDisposed); @@ -308,10 +303,7 @@ public void Indexer(string throwOnDisposed) } } - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] - [InlineData("true")] - [InlineData("false")] - [InlineData(null)] + [Theory, InlineData("true"), InlineData("false"), InlineData(null)] //[ActiveIssue("https://github.com/dotnet/runtime/issues/1429")] public void Contains(string throwOnDisposed) { @@ -409,10 +401,7 @@ public void CreateCacheEntryChangeMonitor() Assert.True (monitor.HasChanged); } - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] - [InlineData("true")] - [InlineData("false")] - [InlineData(null)] + [Theory, InlineData("true"), InlineData("false"), InlineData(null)] public void AddOrGetExisting_String_Object_DateTimeOffset_String(string throwOnDisposed) { var mc = CreatePokerMemoryCache("MyCache", throwOnDisposed); @@ -686,10 +675,7 @@ public void AddOrGetExisting_CacheItem_CacheItemPolicy() Assert.Equal("AddOrGetExisting (CacheItem item, CacheItemPolicy policy)", mc.Calls[0]); } - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] - [InlineData("true")] - [InlineData("false")] - [InlineData(null)] + [Theory, InlineData("true"), InlineData("false"), InlineData(null)] public void Set_String_Object_CacheItemPolicy_String(string throwOnDisposed) { var mc = CreatePokerMemoryCache("MyCache", throwOnDisposed); @@ -915,10 +901,7 @@ public void Set_CacheItem_CacheItemPolicy() Assert.Equal("Set (string key, object value, CacheItemPolicy policy, string regionName = null)", mc.Calls[1]); } - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] - [InlineData("true")] - [InlineData("false")] - [InlineData(null)] + [Theory, InlineData("true"), InlineData("false"), InlineData(null)] public void Remove(string throwOnDisposed) { var mc = CreatePokerMemoryCache("MyCache", throwOnDisposed); @@ -1027,10 +1010,7 @@ public void Remove(string throwOnDisposed) } } - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] - [InlineData("true")] - [InlineData("false")] - [InlineData(null)] + [Theory, InlineData("true"), InlineData("false"), InlineData(null)] public void GetValues(string throwOnDisposed) { var mc = CreatePokerMemoryCache("MyCache", throwOnDisposed); @@ -1131,7 +1111,7 @@ public void ChangeMonitors() // Due to internal implementation details Trim has very few easily verifiable scenarios // ActiveIssue: https://github.com/dotnet/runtime/issues/36488 - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotArm64Process), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotArm64Process))] [InlineData("true"), InlineData("false"), InlineData(null)] public void Trim(string throwOnDisposed) { @@ -1182,7 +1162,7 @@ public void Trim(string throwOnDisposed) } } - [ConditionalFact(nameof(SupportsPhysicalMemoryMonitor), nameof(IsNotHybridGlobalizationOnBrowser))] + [ConditionalFact(nameof(SupportsPhysicalMemoryMonitor))] public void TestExpiredGetValues() { var config = new NameValueCollection(); @@ -1528,9 +1508,8 @@ public async Task GetCacheItem() public class MemoryCacheTestExpires4 { public static bool SupportsPhysicalMemoryMonitor => MemoryCacheTest.SupportsPhysicalMemoryMonitor; - public static bool IsNotHybridGlobalizationOnBrowser => MemoryCacheTest.IsNotHybridGlobalizationOnBrowser; - [ConditionalFact(nameof(SupportsPhysicalMemoryMonitor), nameof(IsNotHybridGlobalizationOnBrowser))] + [ConditionalFact(nameof(SupportsPhysicalMemoryMonitor))] [SkipOnPlatform(TestPlatforms.LinuxBionic, "https://github.com/dotnet/runtime/issues/93106")] public async Task TestCacheShrink() { @@ -1589,9 +1568,8 @@ public async Task TestCacheShrink() public class MemoryCacheTestExpires5 { public static bool SupportsPhysicalMemoryMonitor => MemoryCacheTest.SupportsPhysicalMemoryMonitor; - public static bool IsNotHybridGlobalizationOnBrowser => MemoryCacheTest.IsNotHybridGlobalizationOnBrowser; - [ConditionalFact(nameof(SupportsPhysicalMemoryMonitor), nameof(IsNotHybridGlobalizationOnBrowser))] + [ConditionalFact(nameof(SupportsPhysicalMemoryMonitor))] [SkipOnPlatform(TestPlatforms.LinuxBionic, "https://github.com/dotnet/runtime/issues/93106")] public async Task TestCacheExpiryOrdering() { diff --git a/src/libraries/System.Runtime.Serialization.Json/tests/DataContractJsonSerializer.cs b/src/libraries/System.Runtime.Serialization.Json/tests/DataContractJsonSerializer.cs index effd1426556eee..58d8a6eb3026e3 100644 --- a/src/libraries/System.Runtime.Serialization.Json/tests/DataContractJsonSerializer.cs +++ b/src/libraries/System.Runtime.Serialization.Json/tests/DataContractJsonSerializer.cs @@ -2599,7 +2599,7 @@ public static void DCJS_VerifyDateTimeForFormatStringDCJsonSerSetting() Assert.Equal(value, actual); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))] [ActiveIssue("https://github.com/dotnet/runtime/issues/60462", TestPlatforms.iOS | TestPlatforms.tvOS)] public static void DCJS_VerifyDateTimeForFormatStringDCJsonSerSettings() { @@ -2660,7 +2660,7 @@ public static void DCJS_VerifyDateTimeForFormatStringDCJsonSerSettings() Assert.True(actual6 == dateTime); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))] public static void DCJS_VerifyDateTimeForDateTimeFormat() { var jsonTypes = new JsonTypes(); diff --git a/src/libraries/System.Runtime.Serialization.Xml/tests/DataContractSerializer.cs b/src/libraries/System.Runtime.Serialization.Xml/tests/DataContractSerializer.cs index a7ffda68b113aa..0d543eca0c99a0 100644 --- a/src/libraries/System.Runtime.Serialization.Xml/tests/DataContractSerializer.cs +++ b/src/libraries/System.Runtime.Serialization.Xml/tests/DataContractSerializer.cs @@ -3542,7 +3542,7 @@ public static void DCS_BasicPerSerializerRoundTripAndCompare_SampleTypes() } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Fact] public static void DCS_BasicPerSerializerRoundTripAndCompare_DataSet() { diff --git a/src/libraries/System.Runtime/tests/System.Globalization.Extensions.Tests/GetStringComparerTests.cs b/src/libraries/System.Runtime/tests/System.Globalization.Extensions.Tests/GetStringComparerTests.cs index 17801793edd566..1c2f6bb9554f6d 100644 --- a/src/libraries/System.Runtime/tests/System.Globalization.Extensions.Tests/GetStringComparerTests.cs +++ b/src/libraries/System.Runtime/tests/System.Globalization.Extensions.Tests/GetStringComparerTests.cs @@ -19,7 +19,7 @@ public void GetStringComparer_Invalid() AssertExtensions.Throws("options", () => new CultureInfo("tr-TR").CompareInfo.GetStringComparer(CompareOptions.OrdinalIgnoreCase | CompareOptions.IgnoreCase)); } - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [ConditionalTheory(typeof(PlatformDetection))] [ActiveIssue("https://github.com/dotnet/runtime/issues/95338", typeof(PlatformDetection), nameof(PlatformDetection.IsHybridGlobalizationOnOSX))] [InlineData("hello", "hello", "fr-FR", CompareOptions.IgnoreCase, 0, 0)] [InlineData("hello", "HELLo", "fr-FR", CompareOptions.IgnoreCase, 0, 0)] diff --git a/src/libraries/System.Runtime/tests/System.Runtime.Extensions.Tests/System/StringComparer.cs b/src/libraries/System.Runtime/tests/System.Runtime.Extensions.Tests/System/StringComparer.cs index ec855aca2d8842..06eab156813892 100644 --- a/src/libraries/System.Runtime/tests/System.Runtime.Extensions.Tests/System/StringComparer.cs +++ b/src/libraries/System.Runtime/tests/System.Runtime.Extensions.Tests/System/StringComparer.cs @@ -94,7 +94,7 @@ public static IEnumerable UpperLowerCasing_TestData() } } - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Theory] [MemberData(nameof(UpperLowerCasing_TestData))] public static void CreateWithCulturesTest(string lowerForm, string upperForm, string cultureName) { @@ -112,7 +112,7 @@ public static void CreateWithCulturesTest(string lowerForm, string upperForm, st Assert.Equal(sc.GetHashCode((object) lowerForm), sc.GetHashCode((object) upperForm)); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Fact] public static void InvariantTest() { Assert.True(StringComparer.InvariantCulture.Equals("test", "test"), "Same casing strings with StringComparer.InvariantCulture should be equal"); @@ -199,7 +199,7 @@ public static IEnumerable CreateFromCultureAndOptionsData() { "abcd", "ABcd", "en-US", CompareOptions.StringSort, false }, }; - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))] [MemberData(nameof(CreateFromCultureAndOptionsData))] [MemberData(nameof(CreateFromCultureAndOptionsStringSortData))] public static void CreateFromCultureAndOptions(string actualString, string expectedString, string cultureName, CompareOptions options, bool result) @@ -211,7 +211,7 @@ public static void CreateFromCultureAndOptions(string actualString, string expec Assert.Equal(result, sc.Equals((object)actualString, (object)expectedString)); } - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))] [MemberData(nameof(CreateFromCultureAndOptionsData))] public static void CreateFromCultureAndOptionsStringSort(string actualString, string expectedString, string cultureName, CompareOptions options, bool result) { diff --git a/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/StringComparerTests.cs b/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/StringComparerTests.cs index b6160f82fcea42..3027c870855b5d 100644 --- a/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/StringComparerTests.cs +++ b/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/StringComparerTests.cs @@ -16,7 +16,7 @@ public void Create_InvalidArguments_Throws() AssertExtensions.Throws("culture", () => StringComparer.Create(null, ignoreCase: true)); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Fact] public void Create_CreatesValidComparer() { StringComparer c = StringComparer.Create(CultureInfo.InvariantCulture, ignoreCase: true); @@ -117,7 +117,7 @@ public void CreateCultureOptions_InvalidArguments_Throws() Assert.Throws(() => StringComparer.Create(null, CompareOptions.None)); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Fact] public void CreateCultureOptions_CreatesValidComparer() { StringComparer c = StringComparer.Create(CultureInfo.InvariantCulture, CompareOptions.IgnoreCase); diff --git a/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/StringGetHashCodeTests.cs b/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/StringGetHashCodeTests.cs index 765558c60ad6a8..b37ba0a5d051fb 100644 --- a/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/StringGetHashCodeTests.cs +++ b/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/StringGetHashCodeTests.cs @@ -61,7 +61,7 @@ public static IEnumerable GetHashCode_TestData() () => { return CultureInfo.CurrentCulture.CompareInfo.GetHashCode("abc", CompareOptions.OrdinalIgnoreCase); } }; - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Theory] [MemberData(nameof(GetHashCodeOrdinalIgnoreCase_TestData))] public void GetHashCode_OrdinalIgnoreCase_ReturnsSameHashCodeAsUpperCaseOrdinal(string input) { diff --git a/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/StringTests.cs b/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/StringTests.cs index 7cc19ecc0ec6a6..4b17dc4442af62 100644 --- a/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/StringTests.cs +++ b/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/StringTests.cs @@ -912,7 +912,7 @@ public static void GetHashCode_OfSpan_MatchesOfString() Assert.NotEqual("abc".GetHashCode(), string.GetHashCode("ABC".AsSpan())); // case differences } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))] public static void GetHashCode_CompareInfo() { // ordinal @@ -932,7 +932,7 @@ public static void GetHashCode_CompareInfo() Assert.Equal("aeiXXabc".GetHashCode(StringComparison.InvariantCultureIgnoreCase), CultureInfo.InvariantCulture.CompareInfo.GetHashCode("aeiXXabc", CompareOptions.IgnoreCase)); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Fact] public static void GetHashCode_CompareInfo_OfSpan() { // ordinal @@ -954,7 +954,7 @@ public static void GetHashCode_CompareInfo_OfSpan() public static IEnumerable GetHashCode_StringComparison_Data => StringComparisons.Select(value => new object[] { value }); - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Theory] [MemberData(nameof(GetHashCode_StringComparison_Data))] public static void GetHashCode_StringComparison(StringComparison comparisonType) { diff --git a/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/Text/RuneTests.cs b/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/Text/RuneTests.cs index 01f43253dcf577..bedc97060d2cc1 100644 --- a/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/Text/RuneTests.cs +++ b/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/Text/RuneTests.cs @@ -57,7 +57,7 @@ public static void Casing_Invariant(int original, int upper, int lower) Assert.Equal(new Rune(lower), Rune.ToLowerInvariant(rune)); } - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsIcuGlobalization), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsIcuGlobalization))] [InlineData('0', '0', '0')] [InlineData('a', 'A', 'a')] [InlineData('i', 'I', 'i')] diff --git a/src/libraries/System.Text.Json/tests/Common/CollectionTests/CollectionTests.Specialized.Write.cs b/src/libraries/System.Text.Json/tests/Common/CollectionTests/CollectionTests.Specialized.Write.cs index d7459be339a967..0947ccbdfc8954 100644 --- a/src/libraries/System.Text.Json/tests/Common/CollectionTests/CollectionTests.Specialized.Write.cs +++ b/src/libraries/System.Text.Json/tests/Common/CollectionTests/CollectionTests.Specialized.Write.cs @@ -9,7 +9,7 @@ namespace System.Text.Json.Serialization.Tests { public abstract partial class CollectionTests { - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Fact] public async Task Write_SpecializedCollection() { Assert.Equal(@"{""Data"":4}", await Serializer.SerializeWrapper(new BitVector32(4))); diff --git a/src/libraries/tests.proj b/src/libraries/tests.proj index 36e0fcb49e3d00..88fd8d7848b78c 100644 --- a/src/libraries/tests.proj +++ b/src/libraries/tests.proj @@ -80,10 +80,9 @@ - + - From 709da38f7b3cc003ca5c1c3d8247f78bf3f8cea0 Mon Sep 17 00:00:00 2001 From: Ilona Tomkowicz <32700855+ilonatommy@users.noreply.github.com> Date: Fri, 29 Dec 2023 12:14:52 +0000 Subject: [PATCH 02/22] SortKey is Invariant now. --- docs/design/features/globalization-hybrid-mode.md | 4 ++-- .../src/System/Globalization/CompareInfo.cs | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/docs/design/features/globalization-hybrid-mode.md b/docs/design/features/globalization-hybrid-mode.md index fa70e222badffa..79b2a340192564 100644 --- a/docs/design/features/globalization-hybrid-mode.md +++ b/docs/design/features/globalization-hybrid-mode.md @@ -19,6 +19,8 @@ Hybrid has higher priority than sharding or custom modes, described in globaliza **SortKey** +In HybridGlobalization mode Invariant way of SortKey calculation is used. From this reason, the following APIs will work in the same way as they do when `Invariant=true`: + Affected public APIs: - System.Globalization.CompareInfo.GetSortKey - System.Globalization.CompareInfo.GetSortKeyLength @@ -43,8 +45,6 @@ Indirectly affected APIs (the list might not be complete): - System.Net.Mail.MailAddress.GetHashCode - System.Xml.Xsl.XslCompiledTransform.Transform -Web API does not have an equivalent, so they throw `PlatformNotSupportedException`. - **Case change** Affected public APIs: diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.cs index 7d46be4685e0dc..54d22b7e2bfb23 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.cs @@ -1451,8 +1451,9 @@ private SortKey CreateSortKeyCore(string source, CompareOptions options) => GlobalizationMode.UseNls ? NlsCreateSortKey(source, options) : #if TARGET_BROWSER + // JS cannot create locale-sensitive sort key, use invaraint functions instead. GlobalizationMode.Hybrid ? - throw new PlatformNotSupportedException(GetPNSEText("SortKey")) : + InvariantCreateSortKey(source, options) : #endif IcuCreateSortKey(source, options); From 6e72858e44994d37bbfd0e22ef3447bf4ac1eb60 Mon Sep 17 00:00:00 2001 From: Ilona Tomkowicz <32700855+ilonatommy@users.noreply.github.com> Date: Fri, 29 Dec 2023 14:12:49 +0000 Subject: [PATCH 03/22] Missing SortKey changes + fix HashCode. --- .../src/System/Globalization/CompareInfo.cs | 13 +++---- .../CompareInfo/CompareInfoTests.cs | 36 ------------------- 2 files changed, 7 insertions(+), 42 deletions(-) diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.cs index 54d22b7e2bfb23..b418e70a576edb 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.cs @@ -1496,7 +1496,7 @@ private int GetSortKeyCore(ReadOnlySpan source, Span destination, Co NlsGetSortKey(source, destination, options) : #if TARGET_BROWSER GlobalizationMode.Hybrid ? - throw new PlatformNotSupportedException(GetPNSEText("SortKey")) : + InvariantGetSortKey(source, destination, options)) : #endif IcuGetSortKey(source, destination, options); @@ -1533,7 +1533,7 @@ private int GetSortKeyLengthCore(ReadOnlySpan source, CompareOptions optio NlsGetSortKeyLength(source, options) : #if TARGET_BROWSER GlobalizationMode.Hybrid ? - throw new PlatformNotSupportedException(GetPNSEText("SortKey")) : + InvariantGetSortKeyLength(source, options) : #endif IcuGetSortKeyLength(source, options); @@ -1572,7 +1572,12 @@ public int GetHashCode(ReadOnlySpan source, CompareOptions options) // Pass the flags down to NLS or ICU unless we're running in invariant // mode, at which point we normalize the flags to Ordinal[IgnoreCase]. +#if TARGET_BROWSER + if (!GlobalizationMode.Invariant && !GlobalizationMode.Hybrid) + // JS cannot create locale-sensitive HashCode, use invaraint functions instead +#else if (!GlobalizationMode.Invariant) +#endif { return GetHashCodeOfStringCore(source, options); } @@ -1608,10 +1613,6 @@ public int GetHashCode(ReadOnlySpan source, CompareOptions options) private unsafe int GetHashCodeOfStringCore(ReadOnlySpan source, CompareOptions options) => GlobalizationMode.UseNls ? NlsGetHashCodeOfString(source, options) : -#if TARGET_BROWSER - GlobalizationMode.Hybrid ? - throw new PlatformNotSupportedException(GetPNSEText("HashCode")) : -#endif IcuGetHashCodeOfString(source, options); public override string ToString() => "CompareInfo - " + Name; diff --git a/src/libraries/System.Runtime/tests/System.Globalization.Tests/CompareInfo/CompareInfoTests.cs b/src/libraries/System.Runtime/tests/System.Globalization.Tests/CompareInfo/CompareInfoTests.cs index 72d03ec00e3c82..baa2fe2a22fe30 100644 --- a/src/libraries/System.Runtime/tests/System.Globalization.Tests/CompareInfo/CompareInfoTests.cs +++ b/src/libraries/System.Runtime/tests/System.Globalization.Tests/CompareInfo/CompareInfoTests.cs @@ -355,42 +355,6 @@ public void SortKeyKanaTest(CompareInfo compareInfo, string string1, string stri SortKeyTest(compareInfo, string1, string2, options, expected); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsHybridGlobalizationOnBrowser))] - public void SortKeyTestNotSupported() - { - try - { - s_invariantCompare.GetSortKey(""); - AssertNotReached(); - } - catch(PlatformNotSupportedException pnse) - { - Assert.Equal(GetPNSEText("SortKey"), pnse.Message); - } - try - { - s_invariantCompare.GetSortKeyLength(ReadOnlySpan.Empty); - AssertNotReached(); - } - catch(PlatformNotSupportedException pnse) - { - Assert.Equal(GetPNSEText("SortKey"), pnse.Message); - } - - try - { - s_invariantCompare.GetHashCode("", CompareOptions.None); - AssertNotReached(); - } - catch(PlatformNotSupportedException pnse) - { - Assert.Equal(GetPNSEText("HashCode"), pnse.Message); - } - - string GetPNSEText(string funcName) => $"{funcName} is not supported when HybridGlobalization=true. Disable it to load larger ICU bundle, then use this option."; - void AssertNotReached() => Assert.Fail(); - } - [DllImport("kernel32", CharSet = CharSet.Unicode)] private static extern int CompareStringEx(string lpLocaleName, uint dwCmpFlags, string lpString1, int cchCount1, string lpString2, int cchCount2, IntPtr lpVersionInformation, IntPtr lpReserved, int lParam); private const int NORM_LINGUISTIC_CASING = 0x08000000; // use linguistic rules for casing From 2d7a0370e85f63e14ba10bc54594d1be5dafd18b Mon Sep 17 00:00:00 2001 From: Ilona Tomkowicz <32700855+ilonatommy@users.noreply.github.com> Date: Fri, 29 Dec 2023 14:27:17 +0000 Subject: [PATCH 04/22] Typo --- .../src/System/Globalization/CompareInfo.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.cs index b418e70a576edb..cefd7f976d8dc2 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.cs @@ -1496,7 +1496,7 @@ private int GetSortKeyCore(ReadOnlySpan source, Span destination, Co NlsGetSortKey(source, destination, options) : #if TARGET_BROWSER GlobalizationMode.Hybrid ? - InvariantGetSortKey(source, destination, options)) : + InvariantGetSortKey(source, destination, options) : #endif IcuGetSortKey(source, destination, options); From b896c17f9ceaeff40cb33cc9e67de2447e3db6b5 Mon Sep 17 00:00:00 2001 From: Ilona Tomkowicz <32700855+ilonatommy@users.noreply.github.com> Date: Fri, 29 Dec 2023 14:51:54 +0000 Subject: [PATCH 05/22] Revert unbocking tests connected with CompareOptions PNSE. --- .../tests/LateBindingTests.cs | 10 ++++---- .../tests/LikeOperatorTests.cs | 4 ++-- .../tests/ObjectTypeTests.cs | 4 ++-- .../tests/OperatorsTests.Comparison.cs | 24 +++++++++---------- .../tests/StringTypeTests.cs | 4 ++-- .../tests/StringsTests.cs | 12 +++++----- .../CaseInsensitiveHashCodeProviderTests.cs | 1 + .../Mono/DataRowComparerTest.cs | 2 +- .../Mono/DataTableExtensionsTest.cs | 2 +- .../Mono/EnumerableRowCollectionTest.cs | 12 +++++----- .../tests/DataContractJsonSerializer.cs | 4 ++-- .../tests/DataContractSerializer.cs | 2 +- src/libraries/tests.proj | 3 ++- 13 files changed, 43 insertions(+), 41 deletions(-) diff --git a/src/libraries/Microsoft.VisualBasic.Core/tests/LateBindingTests.cs b/src/libraries/Microsoft.VisualBasic.Core/tests/LateBindingTests.cs index a04e4b0b29333e..a95f101731dfc0 100644 --- a/src/libraries/Microsoft.VisualBasic.Core/tests/LateBindingTests.cs +++ b/src/libraries/Microsoft.VisualBasic.Core/tests/LateBindingTests.cs @@ -9,7 +9,7 @@ namespace Microsoft.VisualBasic.CompilerServices.Tests { public class LateBindingTests { - [Theory] + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] [MemberData(nameof(LateCall_TestData))] public void LateCall(object obj, Type objType, string name, object[] args, string[] paramNames, bool[] copyBack, Func getResult, object expected) { @@ -17,14 +17,14 @@ public void LateCall(object obj, Type objType, string name, object[] args, strin Assert.Equal(expected, getResult(obj)); } - [Theory] + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] [MemberData(nameof(LateGet_TestData))] public void LateGet(object obj, Type objType, string name, object[] args, string[] paramNames, bool[] copyBack, object expected) { Assert.Equal(expected, LateBinding.LateGet(obj, objType, name, args, paramNames, copyBack)); } - [Theory] + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] [MemberData(nameof(LateSet_TestData))] public void LateSet(object obj, Type objType, string name, object[] args, string[] paramNames, Func getResult, object expected) { @@ -74,14 +74,14 @@ public void LateIndexSet(object obj, object[] args, string[] paramNames, Func(() => LateBinding.LateIndexSet(obj, args, paramNames)); } - [Theory] + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] [MemberData(nameof(LateIndexSetComplex_TestData))] public void LateIndexSetComplex(object obj, object[] args, string[] paramNames, bool missing, bool valueType) { diff --git a/src/libraries/Microsoft.VisualBasic.Core/tests/LikeOperatorTests.cs b/src/libraries/Microsoft.VisualBasic.Core/tests/LikeOperatorTests.cs index 1452be5b7fb333..892fbc5c31b5e1 100644 --- a/src/libraries/Microsoft.VisualBasic.Core/tests/LikeOperatorTests.cs +++ b/src/libraries/Microsoft.VisualBasic.Core/tests/LikeOperatorTests.cs @@ -9,7 +9,7 @@ namespace Microsoft.VisualBasic.CompilerServices.Tests { public class LikeOperatorTests { - [Theory] + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] [MemberData(nameof(LikeObject_TestData))] [MemberData(nameof(LikeString_TestData))] public void LikeObject(object source, object pattern, object expectedBinaryCompare, object expectedTextCompare) @@ -18,7 +18,7 @@ public void LikeObject(object source, object pattern, object expectedBinaryCompa Assert.Equal(expectedTextCompare, LikeOperator.LikeObject(source, pattern, CompareMethod.Text)); } - [Theory] + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] [MemberData(nameof(LikeString_TestData))] public void LikeString(string source, string pattern, bool expectedBinaryCompare, bool expectedTextCompare) { diff --git a/src/libraries/Microsoft.VisualBasic.Core/tests/ObjectTypeTests.cs b/src/libraries/Microsoft.VisualBasic.Core/tests/ObjectTypeTests.cs index f1e4b8ac6935f1..d520d69d6cb6f6 100644 --- a/src/libraries/Microsoft.VisualBasic.Core/tests/ObjectTypeTests.cs +++ b/src/libraries/Microsoft.VisualBasic.Core/tests/ObjectTypeTests.cs @@ -287,7 +287,7 @@ public static IEnumerable GetObjectValuePrimitive_TestData() // Add more... } - [Theory] + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] [MemberData(nameof(LikeObj_TestData))] public void LikeObj(object left, object right, object expectedBinaryCompare, object expectedTextCompare) { @@ -323,7 +323,7 @@ public static IEnumerable LikeObj_NullReference_TestData() yield return new object[] { null, "*" }; } - [Theory] + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] [MemberData(nameof(ObjTst_TestData))] public void ObjTst(object x, object y, bool textCompare, object expected) { diff --git a/src/libraries/Microsoft.VisualBasic.Core/tests/OperatorsTests.Comparison.cs b/src/libraries/Microsoft.VisualBasic.Core/tests/OperatorsTests.Comparison.cs index f90fd7d819824c..9e300ec063a232 100644 --- a/src/libraries/Microsoft.VisualBasic.Core/tests/OperatorsTests.Comparison.cs +++ b/src/libraries/Microsoft.VisualBasic.Core/tests/OperatorsTests.Comparison.cs @@ -1107,7 +1107,7 @@ public static IEnumerable Compare_InvalidObjects_TestData() yield return new object[] { new object(), new char[] { '8' } }; } - [Theory] + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] [MemberData(nameof(Compare_Primitives_TestData))] public void CompareObjectEqual_Invoke_ReturnsExpected(object left, object right, bool greater, bool equal, bool less) { @@ -1171,7 +1171,7 @@ public class CompareObjectEqual public static string op_Equality(OperatorsTests left, CompareObjectEqual right) => "tcejbomotsuc"; } - [Theory] + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] [MemberData(nameof(Compare_Primitives_TestData))] public void CompareObjectGreater_Invoke_ReturnsExpected(object left, object right, bool greater, bool equal, bool less) { @@ -1235,7 +1235,7 @@ public class CompareObjectGreater public static string op_GreaterThan(OperatorsTests left, CompareObjectGreater right) => "tcejbomotsuc"; } - [Theory] + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] [MemberData(nameof(Compare_Primitives_TestData))] public void CompareObjectGreaterEqual_Invoke_ReturnsExpected(object left, object right, bool greater, bool equal, bool less) { @@ -1298,7 +1298,7 @@ public class CompareObjectGreaterEqual public static string op_GreaterThanOrEqual(OperatorsTests left, CompareObjectGreaterEqual right) => "tcejbomotsuc"; } - [Theory] + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] [MemberData(nameof(Compare_Primitives_TestData))] public void CompareObjectLess_Invoke_ReturnsExpected(object left, object right, bool greater, bool equal, bool less) { @@ -1362,7 +1362,7 @@ public class CompareObjectLess public static string op_LessThan(OperatorsTests left, CompareObjectLess right) => "tcejbomotsuc"; } - [Theory] + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] [MemberData(nameof(Compare_Primitives_TestData))] public void CompareObjectLessEqual_Invoke_ReturnsExpected(object left, object right, bool greater, bool equal, bool less) { @@ -1425,7 +1425,7 @@ public class CompareObjectLessEqual public static string op_LessThanOrEqual(OperatorsTests left, CompareObjectLessEqual right) => "tcejbomotsuc"; } - [Theory] + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] [MemberData(nameof(Compare_Primitives_TestData))] public void CompareObjectNotEqual_Invoke_ReturnsExpected(object left, object right, bool greater, bool equal, bool less) { @@ -1490,7 +1490,7 @@ public class CompareObjectNotEqual } - [Theory] + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] [MemberData(nameof(Compare_Primitives_TestData))] public void ConditionalCompareObjectEqual_Invoke_ReturnsExpected(object left, object right, bool greater, bool equal, bool less) { @@ -1554,7 +1554,7 @@ public class ConditionalCompareObjectEqual public static bool op_Equality(OperatorsTests left, ConditionalCompareObjectEqual right) => true; } - [Theory] + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] [MemberData(nameof(Compare_Primitives_TestData))] public void ConditionalCompareObjectGreater_Invoke_ReturnsExpected(object left, object right, bool greater, bool equal, bool less) { @@ -1618,7 +1618,7 @@ public class ConditionalCompareObjectGreater public static bool op_GreaterThan(OperatorsTests left, ConditionalCompareObjectGreater right) => true; } - [Theory] + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] [MemberData(nameof(Compare_Primitives_TestData))] public void ConditionalCompareObjectGreaterEqual_Invoke_ReturnsExpected(object left, object right, bool greater, bool equal, bool less) { @@ -1681,7 +1681,7 @@ public class ConditionalCompareObjectGreaterEqual public static bool op_GreaterThanOrEqual(OperatorsTests left, ConditionalCompareObjectGreaterEqual right) => true; } - [Theory] + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] [MemberData(nameof(Compare_Primitives_TestData))] public void ConditionalCompareObjectLess_Invoke_ReturnsExpected(object left, object right, bool greater, bool equal, bool less) { @@ -1745,7 +1745,7 @@ public class ConditionalCompareObjectLess public static bool op_LessThan(OperatorsTests left, ConditionalCompareObjectLess right) => true; } - [Theory] + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] [MemberData(nameof(Compare_Primitives_TestData))] public void ConditionalCompareObjectLessEqual_Invoke_ReturnsExpected(object left, object right, bool greater, bool equal, bool less) { @@ -1808,7 +1808,7 @@ public class ConditionalCompareObjectLessEqual public static bool op_LessThanOrEqual(OperatorsTests left, ConditionalCompareObjectLessEqual right) => true; } - [Theory] + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] [MemberData(nameof(Compare_Primitives_TestData))] public void ConditionalCompareObjectNotEqual_Invoke_ReturnsExpected(object left, object right, bool greater, bool equal, bool less) { diff --git a/src/libraries/Microsoft.VisualBasic.Core/tests/StringTypeTests.cs b/src/libraries/Microsoft.VisualBasic.Core/tests/StringTypeTests.cs index 8d4d2842766d7f..76d390ea840e61 100644 --- a/src/libraries/Microsoft.VisualBasic.Core/tests/StringTypeTests.cs +++ b/src/libraries/Microsoft.VisualBasic.Core/tests/StringTypeTests.cs @@ -363,7 +363,7 @@ public void MidStmtStr_ArgumentException(string str, int start, int length, stri Assert.Throws(() => StringType.MidStmtStr(ref str, start, length, insert)); } - [Theory] + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] [MemberData(nameof(StrCmp_TestData))] public void StrCmp(string left, string right, int expectedBinaryCompare, int expectedTextCompare) { @@ -388,7 +388,7 @@ public static IEnumerable StrCmp_TestData() yield return new object[] { "abc", "ABC", 32, 0 }; } - [Theory] + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] [InlineData(null, null, true, true)] [InlineData("", null, true, true)] [InlineData("", "*", true, true)] diff --git a/src/libraries/Microsoft.VisualBasic.Core/tests/StringsTests.cs b/src/libraries/Microsoft.VisualBasic.Core/tests/StringsTests.cs index 27967fa777fe10..037412ed582757 100644 --- a/src/libraries/Microsoft.VisualBasic.Core/tests/StringsTests.cs +++ b/src/libraries/Microsoft.VisualBasic.Core/tests/StringsTests.cs @@ -431,7 +431,7 @@ public void InStr_BinaryCompare(string string1, string string2, int expected) Assert.Equal(expected, Strings.InStr(1, string1, string2, CompareMethod.Binary)); } - [Theory] + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] [InlineData("A", "a", 1)] [InlineData("Aa", "a", 1)] public void InStr_TextCompare(string string1, string string2, int expected) @@ -479,7 +479,7 @@ public void InStrRev_BinaryCompare(string stringCheck, string stringMatch, int s Assert.Equal(expected, Strings.InStrRev(stringCheck, stringMatch, start, CompareMethod.Binary)); } - [Theory] + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] [InlineData("A", "a", 1, 1)] [InlineData("aA", "a", 2, 2)] public void InStrRev_TextCompare(string stringCheck, string stringMatch, int start, int expected) @@ -779,7 +779,7 @@ public void Trim_Valid(string str, string expected) Assert.Equal(expected, Strings.Trim(str)); } - [Theory] + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] [InlineData("", "", null, 1, -1, CompareMethod.Text, null)] [InlineData("", null, "", 1, -1, CompareMethod.Text, null)] [InlineData("", "", "", 1, -1, CompareMethod.Text, null)] @@ -815,7 +815,7 @@ public void Space(int number, string expected) Assert.Equal(expected, Strings.Space(number)); } - [Theory] + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] [InlineData(null, null, -1, CompareMethod.Text, new string[] { "" })] [InlineData(null, "", -1, CompareMethod.Text, new string[] { "" })] [InlineData("", null, -1, CompareMethod.Text, new string[] { "" })] @@ -833,14 +833,14 @@ public void Split(string expression, string delimiter, int limit, CompareMethod Assert.Equal(expected, Strings.Split(expression, delimiter, limit, compare)); } - [Theory] + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] [InlineData("A, B, C", ", ", 0, CompareMethod.Text)] public void Split_IndexOutOfRangeException(string expression, string delimiter, int limit, CompareMethod compare) { Assert.Throws< IndexOutOfRangeException>(() => Strings.Split(expression, delimiter, limit, compare)); } - [Theory] + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] [InlineData("a", "a", 0, 0)] [InlineData("a", "b", -1, -1)] [InlineData("b", "a", 1, 1)] diff --git a/src/libraries/System.Collections.NonGeneric/tests/CaseInsensitiveHashCodeProviderTests.cs b/src/libraries/System.Collections.NonGeneric/tests/CaseInsensitiveHashCodeProviderTests.cs index a90472206c8da2..01790bbf3dc593 100644 --- a/src/libraries/System.Collections.NonGeneric/tests/CaseInsensitiveHashCodeProviderTests.cs +++ b/src/libraries/System.Collections.NonGeneric/tests/CaseInsensitiveHashCodeProviderTests.cs @@ -97,6 +97,7 @@ public void Ctor_CultureInfo_ChangeCurrentCulture_GetHashCodeCompare(object a, o [Fact] [ActiveIssue("https://github.com/dotnet/runtime/issues/37069", TestPlatforms.Android | TestPlatforms.LinuxBionic)] [ActiveIssue("https://github.com/dotnet/runtime/issues/95338", typeof(PlatformDetection), nameof(PlatformDetection.IsHybridGlobalizationOnOSX))] + [ActiveIssue("https://github.com/dotnet/runtime/issues/95503", typeof(PlatformDetection), nameof(PlatformDetection.IsHybridGlobalizationOnBrowser))] public void Ctor_CultureInfo_GetHashCodeCompare_TurkishI() { var cultureNames = Helpers.TestCultureNames; diff --git a/src/libraries/System.Data.Common/tests/System.Data.DataSetExtensions.Tests/Mono/DataRowComparerTest.cs b/src/libraries/System.Data.Common/tests/System.Data.DataSetExtensions.Tests/Mono/DataRowComparerTest.cs index 6d4ddbe9b3f58d..0e8fb95a74e6df 100644 --- a/src/libraries/System.Data.Common/tests/System.Data.DataSetExtensions.Tests/Mono/DataRowComparerTest.cs +++ b/src/libraries/System.Data.Common/tests/System.Data.DataSetExtensions.Tests/Mono/DataRowComparerTest.cs @@ -216,7 +216,7 @@ public void Equals_Rows_Deleted() } } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] public void GetHashCodeWithVersions() { DataSet ds = new DataSet(); diff --git a/src/libraries/System.Data.Common/tests/System.Data.DataSetExtensions.Tests/Mono/DataTableExtensionsTest.cs b/src/libraries/System.Data.Common/tests/System.Data.DataSetExtensions.Tests/Mono/DataTableExtensionsTest.cs index 479807057113e7..7f6d7bb12c0f29 100644 --- a/src/libraries/System.Data.Common/tests/System.Data.DataSetExtensions.Tests/Mono/DataTableExtensionsTest.cs +++ b/src/libraries/System.Data.Common/tests/System.Data.DataSetExtensions.Tests/Mono/DataTableExtensionsTest.cs @@ -75,7 +75,7 @@ public void CopyToDataTableTableArgNoRows() dt.AsEnumerable().CopyToDataTable(dst, LoadOption.PreserveChanges); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] public void AsEnumerable() { DataSet ds = new DataSet(); diff --git a/src/libraries/System.Data.Common/tests/System.Data.DataSetExtensions.Tests/Mono/EnumerableRowCollectionTest.cs b/src/libraries/System.Data.Common/tests/System.Data.DataSetExtensions.Tests/Mono/EnumerableRowCollectionTest.cs index a1f0dd6ec13ff8..ba292235291e37 100644 --- a/src/libraries/System.Data.Common/tests/System.Data.DataSetExtensions.Tests/Mono/EnumerableRowCollectionTest.cs +++ b/src/libraries/System.Data.Common/tests/System.Data.DataSetExtensions.Tests/Mono/EnumerableRowCollectionTest.cs @@ -41,7 +41,7 @@ public class EnumerableRowCollectionTest { private string _testDataSet = "Mono/testdataset1.xml"; - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] public void QueryWhere() { var ds = new DataSet(); @@ -68,7 +68,7 @@ where line.Field("Score") > 80 } } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] public void QueryWhereSelect () { var ds = new DataSet (); @@ -89,7 +89,7 @@ where line.Field ("Score") > 80 } } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] public void QueryWhereSelectOrderBy () { var ds = new DataSet (); @@ -119,7 +119,7 @@ orderby line.Field ("ID") } } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] public void QueryWhereSelectOrderByDescending () { var ds = new DataSet (); @@ -149,7 +149,7 @@ orderby line.Field ("ID") descending } } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] public void ThenBy () { var ds = new DataSet (); @@ -179,7 +179,7 @@ orderby line.Field ("Gender"), line.Field ("ID") } } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] public void ThenByDescending () { var ds = new DataSet (); diff --git a/src/libraries/System.Runtime.Serialization.Json/tests/DataContractJsonSerializer.cs b/src/libraries/System.Runtime.Serialization.Json/tests/DataContractJsonSerializer.cs index 58d8a6eb3026e3..effd1426556eee 100644 --- a/src/libraries/System.Runtime.Serialization.Json/tests/DataContractJsonSerializer.cs +++ b/src/libraries/System.Runtime.Serialization.Json/tests/DataContractJsonSerializer.cs @@ -2599,7 +2599,7 @@ public static void DCJS_VerifyDateTimeForFormatStringDCJsonSerSetting() Assert.Equal(value, actual); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] [ActiveIssue("https://github.com/dotnet/runtime/issues/60462", TestPlatforms.iOS | TestPlatforms.tvOS)] public static void DCJS_VerifyDateTimeForFormatStringDCJsonSerSettings() { @@ -2660,7 +2660,7 @@ public static void DCJS_VerifyDateTimeForFormatStringDCJsonSerSettings() Assert.True(actual6 == dateTime); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] public static void DCJS_VerifyDateTimeForDateTimeFormat() { var jsonTypes = new JsonTypes(); diff --git a/src/libraries/System.Runtime.Serialization.Xml/tests/DataContractSerializer.cs b/src/libraries/System.Runtime.Serialization.Xml/tests/DataContractSerializer.cs index 0d543eca0c99a0..a7ffda68b113aa 100644 --- a/src/libraries/System.Runtime.Serialization.Xml/tests/DataContractSerializer.cs +++ b/src/libraries/System.Runtime.Serialization.Xml/tests/DataContractSerializer.cs @@ -3542,7 +3542,7 @@ public static void DCS_BasicPerSerializerRoundTripAndCompare_SampleTypes() } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] public static void DCS_BasicPerSerializerRoundTripAndCompare_DataSet() { diff --git a/src/libraries/tests.proj b/src/libraries/tests.proj index 88fd8d7848b78c..36e0fcb49e3d00 100644 --- a/src/libraries/tests.proj +++ b/src/libraries/tests.proj @@ -80,9 +80,10 @@ - + + From de22e70d54092d20453a1f66a6f72edc1844642a Mon Sep 17 00:00:00 2001 From: Ilona Tomkowicz <32700855+ilonatommy@users.noreply.github.com> Date: Fri, 29 Dec 2023 18:04:56 +0000 Subject: [PATCH 06/22] Hashing uses Invariant mode -these tests should be skipped. --- .../System/StringComparer.cs | 6 +++--- .../System.Runtime.Tests/System/StringGetHashCodeTests.cs | 2 +- .../tests/System.Runtime.Tests/System/Text/RuneTests.cs | 3 ++- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/libraries/System.Runtime/tests/System.Runtime.Extensions.Tests/System/StringComparer.cs b/src/libraries/System.Runtime/tests/System.Runtime.Extensions.Tests/System/StringComparer.cs index 06eab156813892..cccd56a3d7adea 100644 --- a/src/libraries/System.Runtime/tests/System.Runtime.Extensions.Tests/System/StringComparer.cs +++ b/src/libraries/System.Runtime/tests/System.Runtime.Extensions.Tests/System/StringComparer.cs @@ -87,7 +87,7 @@ public static IEnumerable UpperLowerCasing_TestData() yield return new object[] { "abcd", "ABCD", "en-US" }; yield return new object[] { "latin i", "LATIN I", "en-US" }; - if (PlatformDetection.IsNotInvariantGlobalization && !PlatformDetection.IsAndroid && !PlatformDetection.IsLinuxBionic) + if (PlatformDetection.IsNotInvariantGlobalization && PlatformDetection.IsNotHybridGlobalizationOnBrowser && !PlatformDetection.IsAndroid && !PlatformDetection.IsLinuxBionic) { yield return new object[] { "turky \u0131", "TURKY I", "tr-TR" }; yield return new object[] { "turky i", "TURKY \u0130", "tr-TR" }; @@ -199,7 +199,7 @@ public static IEnumerable CreateFromCultureAndOptionsData() { "abcd", "ABcd", "en-US", CompareOptions.StringSort, false }, }; - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))] + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] [MemberData(nameof(CreateFromCultureAndOptionsData))] [MemberData(nameof(CreateFromCultureAndOptionsStringSortData))] public static void CreateFromCultureAndOptions(string actualString, string expectedString, string cultureName, CompareOptions options, bool result) @@ -211,7 +211,7 @@ public static void CreateFromCultureAndOptions(string actualString, string expec Assert.Equal(result, sc.Equals((object)actualString, (object)expectedString)); } - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))] + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] [MemberData(nameof(CreateFromCultureAndOptionsData))] public static void CreateFromCultureAndOptionsStringSort(string actualString, string expectedString, string cultureName, CompareOptions options, bool result) { diff --git a/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/StringGetHashCodeTests.cs b/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/StringGetHashCodeTests.cs index b37ba0a5d051fb..ce2e88ade3abad 100644 --- a/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/StringGetHashCodeTests.cs +++ b/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/StringGetHashCodeTests.cs @@ -89,7 +89,7 @@ public static IEnumerable GetHashCodeOrdinalIgnoreCase_TestData() { yield return new object[] { "AaBbCcDdEeFfGgHh".Insert(i, "\u00E9" /* LATIN SMALL LETTER E WITH ACUTE */) }; yield return new object[] { "AaBbCcDdEeFfGgHh".Insert(i, "\u044D" /* CYRILLIC SMALL LETTER E */) }; - if (PlatformDetection.IsNotHybridGlobalizationOnOSX) + if (PlatformDetection.IsNotHybridGlobalizationOnOSX && PlatformDetection.IsNotHybridGlobalizationOnBrowser) yield return new object[] { "AaBbCcDdEeFfGgHh".Insert(i, "\u0131" /* LATIN SMALL LETTER DOTLESS I */) }; } diff --git a/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/Text/RuneTests.cs b/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/Text/RuneTests.cs index bedc97060d2cc1..fdf8bef6ef7dc2 100644 --- a/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/Text/RuneTests.cs +++ b/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/Text/RuneTests.cs @@ -57,7 +57,8 @@ public static void Casing_Invariant(int original, int upper, int lower) Assert.Equal(new Rune(lower), Rune.ToLowerInvariant(rune)); } - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsIcuGlobalization))] + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsIcuGlobalizationAndNotHybridOnBrowser))] + // HybridGlobalization on Browser uses Invariant HashCode and SortKey, so its effect does not match this of ICU [InlineData('0', '0', '0')] [InlineData('a', 'A', 'a')] [InlineData('i', 'I', 'i')] From 5778cd0c3ac6e72a5943268de4e300d344c0afff Mon Sep 17 00:00:00 2001 From: Ilona Tomkowicz <32700855+ilonatommy@users.noreply.github.com> Date: Tue, 2 Jan 2024 15:11:58 +0000 Subject: [PATCH 07/22] Add active issue. --- .../OutOfBoundsRegression.cs | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/libraries/System.Collections/tests/Generic/Dictionary/HashCollisionScenarios/OutOfBoundsRegression.cs b/src/libraries/System.Collections/tests/Generic/Dictionary/HashCollisionScenarios/OutOfBoundsRegression.cs index 9080852c8d6826..454c728fcd5b9f 100644 --- a/src/libraries/System.Collections/tests/Generic/Dictionary/HashCollisionScenarios/OutOfBoundsRegression.cs +++ b/src/libraries/System.Collections/tests/Generic/Dictionary/HashCollisionScenarios/OutOfBoundsRegression.cs @@ -336,15 +336,22 @@ private static void ValidateBehaviorOfInternalComparerVsPublicComparer(IEquality { publicComparer = EqualityComparer.Default; } - - foreach (var pair in new[] { - ("Hello", "Hello"), // exactly equal - ("Hello", "Goodbye"), // not equal at all - ("Hello", "hello"), // case-insensitive equal - ("Hello", "He\u200dllo"), // equal under linguistic comparer - ("Hello", "HE\u200dLLO"), // equal under case-insensitive linguistic comparer - ("\u0430\u0431\u0432\u0433\u0434\u0435\u0451\u0436\u0437\u0438\u0439\u043A\u043B\u043C\u043D\u043E\u043F\u0440\u0441\u0442\u0443\u0444\u0445\u0446\u0447\u0448\u0449\u044C\u044B\u044A\u044D\u044E\u044F", "\u0410\u0411\u0412\u0413\u0414\u0415\u0401\u0416\u0417\u0418\u0419\u041A\u041B\u041C\u041D\u041E\u041F\u0420\u0421\u0422\u0423\u0424\u0425\u0426\u0427\u0428\u0429\u042C\u042B\u042A\u042D\u042E\u042F"), // Cyrillic, case-insensitive equal - }) + //https://github.com/dotnet/runtime/issues/96400, "equal under linguistic comparer" fails + var testData = PlatformDetection.IsHybridGlobalizationOnBrowser ? + new[] {("Hello", "Hello"), // exactly equal + ("Hello", "Goodbye"), // not equal at all + ("Hello", "hello"), // case-insensitive equal + ("Hello", "HE\u200dLLO"), // equal under case-insensitive linguistic comparer + ("\u0430\u0431\u0432\u0433\u0434\u0435\u0451\u0436\u0437\u0438\u0439\u043A\u043B\u043C\u043D\u043E\u043F\u0440\u0441\u0442\u0443\u0444\u0445\u0446\u0447\u0448\u0449\u044C\u044B\u044A\u044D\u044E\u044F", "\u0410\u0411\u0412\u0413\u0414\u0415\u0401\u0416\u0417\u0418\u0419\u041A\u041B\u041C\u041D\u041E\u041F\u0420\u0421\u0422\u0423\u0424\u0425\u0426\u0427\u0428\u0429\u042C\u042B\u042A\u042D\u042E\u042F") // Cyrillic, case-insensitive equal + } : + new[] {("Hello", "Hello"), // exactly equal + ("Hello", "Goodbye"), // not equal at all + ("Hello", "hello"), // case-insensitive equal + ("Hello", "He\u200dllo"), // equal under linguistic comparer + ("Hello", "HE\u200dLLO"), // equal under case-insensitive linguistic comparer + ("\u0430\u0431\u0432\u0433\u0434\u0435\u0451\u0436\u0437\u0438\u0439\u043A\u043B\u043C\u043D\u043E\u043F\u0440\u0441\u0442\u0443\u0444\u0445\u0446\u0447\u0448\u0449\u044C\u044B\u044A\u044D\u044E\u044F", "\u0410\u0411\u0412\u0413\u0414\u0415\u0401\u0416\u0417\u0418\u0419\u041A\u041B\u041C\u041D\u041E\u041F\u0420\u0421\u0422\u0423\u0424\u0425\u0426\u0427\u0428\u0429\u042C\u042B\u042A\u042D\u042E\u042F") // Cyrillic, case-insensitive equal + }; + foreach (var pair in testData) { bool arePairElementsExpectedEqual = publicComparer.Equals(pair.Item1, pair.Item2); Assert.Equal(arePairElementsExpectedEqual, internalComparer.Equals(pair.Item1, pair.Item2)); From d0666cd2497812132ace4103a2047ded287f42e7 Mon Sep 17 00:00:00 2001 From: Ilona Tomkowicz <32700855+ilonatommy@users.noreply.github.com> Date: Tue, 2 Jan 2024 17:09:21 +0000 Subject: [PATCH 08/22] feedback --- .../System/Globalization/CompareInfo.Icu.cs | 22 ++++++++++++++++ .../Globalization/CompareInfo.Invariant.cs | 10 ++++++++ .../src/System/Globalization/CompareInfo.cs | 25 +------------------ 3 files changed, 33 insertions(+), 24 deletions(-) diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.Icu.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.Icu.cs index f2c7dd254ae2ff..2c5a2c61590b21 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.Icu.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.Icu.cs @@ -692,6 +692,12 @@ private unsafe SortKey IcuCreateSortKey(string source, CompareOptions options) Debug.Assert(!GlobalizationMode.Invariant); Debug.Assert(!GlobalizationMode.UseNls); +#if TARGET_BROWSER + // JS cannot create locale-sensitive sort key, use invaraint functions instead. + if (GlobalizationMode.Hybrid) + return InvariantCreateSortKey(source, options); +#endif + if ((options & ValidCompareMaskOffFlags) != 0) { throw new ArgumentException(SR.Argument_InvalidFlag, nameof(options)); @@ -743,6 +749,11 @@ private unsafe int IcuGetSortKey(ReadOnlySpan source, Span destinati Debug.Assert(!GlobalizationMode.UseNls); Debug.Assert((options & ValidCompareMaskOffFlags) == 0); +#if TARGET_BROWSER + if (GlobalizationMode.Hybrid) + return InvariantGetSortKey(source, destination, options); +#endif + // It's ok to pass nullptr (for empty buffers) to ICU's sort key routines. int actualSortKeyLength; @@ -785,6 +796,11 @@ private unsafe int IcuGetSortKeyLength(ReadOnlySpan source, CompareOptions Debug.Assert(!GlobalizationMode.UseNls); Debug.Assert((options & ValidCompareMaskOffFlags) == 0); +#if TARGET_BROWSER + if (GlobalizationMode.Hybrid) + return InvariantGetSortKeyLength(source, options); +#endif + // It's ok to pass nullptr (for empty buffers) to ICU's sort key routines. fixed (char* pSource = &MemoryMarshal.GetReference(source)) @@ -833,6 +849,12 @@ private unsafe int IcuGetHashCodeOfString(ReadOnlySpan source, CompareOpti Debug.Assert(!GlobalizationMode.UseNls); Debug.Assert((options & (CompareOptions.Ordinal | CompareOptions.OrdinalIgnoreCase)) == 0); +#if TARGET_BROWSER + // JS cannot create locale-sensitive HashCode, use invaraint functions instead + if (GlobalizationMode.Hybrid) + return InvariantGetHashCode(source, options); +#endif + // according to ICU User Guide the performance of ucol_getSortKey is worse when it is called with null output buffer // the solution is to try to fill the sort key in a temporary buffer of size equal 4 x string length // (The ArrayPool used to have a limit on the length of buffers it would cache; this code was avoiding diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.Invariant.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.Invariant.cs index 739f461cc8628b..a26ba62928bcd2 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.Invariant.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.Invariant.cs @@ -126,5 +126,15 @@ private static int InvariantGetSortKeyLength(ReadOnlySpan source, CompareO return byteLength; } + + private static int InvariantGetHashCode(ReadOnlySpan source, CompareOptions options) + { + if ((options & CompareOptions.IgnoreCase) == 0) + { + return string.GetHashCode(source); + } + + return string.GetHashCodeOrdinalIgnoreCase(source); + } } } diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.cs index cefd7f976d8dc2..3e2afe57b37e74 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.cs @@ -1450,11 +1450,6 @@ public SortKey GetSortKey(string source) private SortKey CreateSortKeyCore(string source, CompareOptions options) => GlobalizationMode.UseNls ? NlsCreateSortKey(source, options) : -#if TARGET_BROWSER - // JS cannot create locale-sensitive sort key, use invaraint functions instead. - GlobalizationMode.Hybrid ? - InvariantCreateSortKey(source, options) : -#endif IcuCreateSortKey(source, options); /// @@ -1494,10 +1489,6 @@ public int GetSortKey(ReadOnlySpan source, Span destination, Compare private int GetSortKeyCore(ReadOnlySpan source, Span destination, CompareOptions options) => GlobalizationMode.UseNls ? NlsGetSortKey(source, destination, options) : -#if TARGET_BROWSER - GlobalizationMode.Hybrid ? - InvariantGetSortKey(source, destination, options) : -#endif IcuGetSortKey(source, destination, options); /// @@ -1531,10 +1522,6 @@ public int GetSortKeyLength(ReadOnlySpan source, CompareOptions options = private int GetSortKeyLengthCore(ReadOnlySpan source, CompareOptions options) => GlobalizationMode.UseNls ? NlsGetSortKeyLength(source, options) : -#if TARGET_BROWSER - GlobalizationMode.Hybrid ? - InvariantGetSortKeyLength(source, options) : -#endif IcuGetSortKeyLength(source, options); public override bool Equals([NotNullWhen(true)] object? value) @@ -1572,22 +1559,12 @@ public int GetHashCode(ReadOnlySpan source, CompareOptions options) // Pass the flags down to NLS or ICU unless we're running in invariant // mode, at which point we normalize the flags to Ordinal[IgnoreCase]. -#if TARGET_BROWSER - if (!GlobalizationMode.Invariant && !GlobalizationMode.Hybrid) - // JS cannot create locale-sensitive HashCode, use invaraint functions instead -#else if (!GlobalizationMode.Invariant) -#endif { return GetHashCodeOfStringCore(source, options); } - if ((options & CompareOptions.IgnoreCase) == 0) - { - return string.GetHashCode(source); - } - - return string.GetHashCodeOrdinalIgnoreCase(source); + return InvariantGetHashCode(source, options); } else { From 65236ab9f26b06059b1deabb57e461714baef11a Mon Sep 17 00:00:00 2001 From: Ilona Tomkowicz <32700855+ilonatommy@users.noreply.github.com> Date: Wed, 3 Jan 2024 11:26:33 +0000 Subject: [PATCH 09/22] Feedback --- .../GetStringComparerTests.cs | 2 +- .../System.Runtime.Extensions.Tests/System/StringComparer.cs | 1 + .../tests/System.Runtime.Tests/System/StringGetHashCodeTests.cs | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/libraries/System.Runtime/tests/System.Globalization.Extensions.Tests/GetStringComparerTests.cs b/src/libraries/System.Runtime/tests/System.Globalization.Extensions.Tests/GetStringComparerTests.cs index 1c2f6bb9554f6d..ccb3aa052591c8 100644 --- a/src/libraries/System.Runtime/tests/System.Globalization.Extensions.Tests/GetStringComparerTests.cs +++ b/src/libraries/System.Runtime/tests/System.Globalization.Extensions.Tests/GetStringComparerTests.cs @@ -19,7 +19,7 @@ public void GetStringComparer_Invalid() AssertExtensions.Throws("options", () => new CultureInfo("tr-TR").CompareInfo.GetStringComparer(CompareOptions.OrdinalIgnoreCase | CompareOptions.IgnoreCase)); } - [ConditionalTheory(typeof(PlatformDetection))] + [Theory] [ActiveIssue("https://github.com/dotnet/runtime/issues/95338", typeof(PlatformDetection), nameof(PlatformDetection.IsHybridGlobalizationOnOSX))] [InlineData("hello", "hello", "fr-FR", CompareOptions.IgnoreCase, 0, 0)] [InlineData("hello", "HELLo", "fr-FR", CompareOptions.IgnoreCase, 0, 0)] diff --git a/src/libraries/System.Runtime/tests/System.Runtime.Extensions.Tests/System/StringComparer.cs b/src/libraries/System.Runtime/tests/System.Runtime.Extensions.Tests/System/StringComparer.cs index cccd56a3d7adea..3c6b9e2dfd8bde 100644 --- a/src/libraries/System.Runtime/tests/System.Runtime.Extensions.Tests/System/StringComparer.cs +++ b/src/libraries/System.Runtime/tests/System.Runtime.Extensions.Tests/System/StringComparer.cs @@ -87,6 +87,7 @@ public static IEnumerable UpperLowerCasing_TestData() yield return new object[] { "abcd", "ABCD", "en-US" }; yield return new object[] { "latin i", "LATIN I", "en-US" }; + // https://github.com/dotnet/runtime/issues/95503 if (PlatformDetection.IsNotInvariantGlobalization && PlatformDetection.IsNotHybridGlobalizationOnBrowser && !PlatformDetection.IsAndroid && !PlatformDetection.IsLinuxBionic) { yield return new object[] { "turky \u0131", "TURKY I", "tr-TR" }; diff --git a/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/StringGetHashCodeTests.cs b/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/StringGetHashCodeTests.cs index ce2e88ade3abad..d2b2bffe60f9cc 100644 --- a/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/StringGetHashCodeTests.cs +++ b/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/StringGetHashCodeTests.cs @@ -89,6 +89,7 @@ public static IEnumerable GetHashCodeOrdinalIgnoreCase_TestData() { yield return new object[] { "AaBbCcDdEeFfGgHh".Insert(i, "\u00E9" /* LATIN SMALL LETTER E WITH ACUTE */) }; yield return new object[] { "AaBbCcDdEeFfGgHh".Insert(i, "\u044D" /* CYRILLIC SMALL LETTER E */) }; + // https://github.com/dotnet/runtime/issues/95503 if (PlatformDetection.IsNotHybridGlobalizationOnOSX && PlatformDetection.IsNotHybridGlobalizationOnBrowser) yield return new object[] { "AaBbCcDdEeFfGgHh".Insert(i, "\u0131" /* LATIN SMALL LETTER DOTLESS I */) }; } From 0721f459d4c7b04e66ae0ca152b0210cce9cda0d Mon Sep 17 00:00:00 2001 From: Ilona Tomkowicz <32700855+ilonatommy@users.noreply.github.com> Date: Wed, 3 Jan 2024 11:29:27 +0000 Subject: [PATCH 10/22] Better documentation. --- docs/design/features/globalization-hybrid-mode.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/design/features/globalization-hybrid-mode.md b/docs/design/features/globalization-hybrid-mode.md index 79b2a340192564..9435e04b1e01d8 100644 --- a/docs/design/features/globalization-hybrid-mode.md +++ b/docs/design/features/globalization-hybrid-mode.md @@ -19,7 +19,7 @@ Hybrid has higher priority than sharding or custom modes, described in globaliza **SortKey** -In HybridGlobalization mode Invariant way of SortKey calculation is used. From this reason, the following APIs will work in the same way as they do when `Invariant=true`: +In HybridGlobalization mode Invariant way of SortKey calculation is used. Comparison functions are locale-sensitive while hasing function are not, one of the side effects are described in the issue: https://github.com/dotnet/runtime/issues/96400. The following APIs will work in the same way as they do when `Invariant=true`: Affected public APIs: - System.Globalization.CompareInfo.GetSortKey From 56257415721de5936f5a7ec206ac55767c4f412f Mon Sep 17 00:00:00 2001 From: Ilona Tomkowicz <32700855+ilonatommy@users.noreply.github.com> Date: Wed, 17 Jan 2024 12:19:15 +0000 Subject: [PATCH 11/22] Add new tests + sanitize string before invariant comparison. --- .../OutOfBoundsRegression.cs | 24 ++---- .../System/Globalization/CompareInfo.Icu.cs | 9 +- .../Globalization/CompareInfo.WebAssembly.cs | 21 +++++ .../CompareInfo/CompareInfoTests.HashCode.cs | 85 +++++++++++++++++++ .../System.Globalization.Tests.csproj | 1 + 5 files changed, 122 insertions(+), 18 deletions(-) create mode 100644 src/libraries/System.Runtime/tests/System.Globalization.Tests/CompareInfo/CompareInfoTests.HashCode.cs diff --git a/src/libraries/System.Collections/tests/Generic/Dictionary/HashCollisionScenarios/OutOfBoundsRegression.cs b/src/libraries/System.Collections/tests/Generic/Dictionary/HashCollisionScenarios/OutOfBoundsRegression.cs index 454c728fcd5b9f..d6809b65a09418 100644 --- a/src/libraries/System.Collections/tests/Generic/Dictionary/HashCollisionScenarios/OutOfBoundsRegression.cs +++ b/src/libraries/System.Collections/tests/Generic/Dictionary/HashCollisionScenarios/OutOfBoundsRegression.cs @@ -336,22 +336,14 @@ private static void ValidateBehaviorOfInternalComparerVsPublicComparer(IEquality { publicComparer = EqualityComparer.Default; } - //https://github.com/dotnet/runtime/issues/96400, "equal under linguistic comparer" fails - var testData = PlatformDetection.IsHybridGlobalizationOnBrowser ? - new[] {("Hello", "Hello"), // exactly equal - ("Hello", "Goodbye"), // not equal at all - ("Hello", "hello"), // case-insensitive equal - ("Hello", "HE\u200dLLO"), // equal under case-insensitive linguistic comparer - ("\u0430\u0431\u0432\u0433\u0434\u0435\u0451\u0436\u0437\u0438\u0439\u043A\u043B\u043C\u043D\u043E\u043F\u0440\u0441\u0442\u0443\u0444\u0445\u0446\u0447\u0448\u0449\u044C\u044B\u044A\u044D\u044E\u044F", "\u0410\u0411\u0412\u0413\u0414\u0415\u0401\u0416\u0417\u0418\u0419\u041A\u041B\u041C\u041D\u041E\u041F\u0420\u0421\u0422\u0423\u0424\u0425\u0426\u0427\u0428\u0429\u042C\u042B\u042A\u042D\u042E\u042F") // Cyrillic, case-insensitive equal - } : - new[] {("Hello", "Hello"), // exactly equal - ("Hello", "Goodbye"), // not equal at all - ("Hello", "hello"), // case-insensitive equal - ("Hello", "He\u200dllo"), // equal under linguistic comparer - ("Hello", "HE\u200dLLO"), // equal under case-insensitive linguistic comparer - ("\u0430\u0431\u0432\u0433\u0434\u0435\u0451\u0436\u0437\u0438\u0439\u043A\u043B\u043C\u043D\u043E\u043F\u0440\u0441\u0442\u0443\u0444\u0445\u0446\u0447\u0448\u0449\u044C\u044B\u044A\u044D\u044E\u044F", "\u0410\u0411\u0412\u0413\u0414\u0415\u0401\u0416\u0417\u0418\u0419\u041A\u041B\u041C\u041D\u041E\u041F\u0420\u0421\u0422\u0423\u0424\u0425\u0426\u0427\u0428\u0429\u042C\u042B\u042A\u042D\u042E\u042F") // Cyrillic, case-insensitive equal - }; - foreach (var pair in testData) + foreach (var pair in new[] { + ("Hello", "Hello"), // exactly equal + ("Hello", "Goodbye"), // not equal at all + ("Hello", "hello"), // case-insensitive equal + ("Hello", "He\u200dllo"), // equal under linguistic comparer + ("Hello", "HE\u200dLLO"), // equal under case-insensitive linguistic comparer + ("\u0430\u0431\u0432\u0433\u0434\u0435\u0451\u0436\u0437\u0438\u0439\u043A\u043B\u043C\u043D\u043E\u043F\u0440\u0441\u0442\u0443\u0444\u0445\u0446\u0447\u0448\u0449\u044C\u044B\u044A\u044D\u044E\u044F", "\u0410\u0411\u0412\u0413\u0414\u0415\u0401\u0416\u0417\u0418\u0419\u041A\u041B\u041C\u041D\u041E\u041F\u0420\u0421\u0422\u0423\u0424\u0425\u0426\u0427\u0428\u0429\u042C\u042B\u042A\u042D\u042E\u042F"), // Cyrillic, case-insensitive equal + }) { bool arePairElementsExpectedEqual = publicComparer.Equals(pair.Item1, pair.Item2); Assert.Equal(arePairElementsExpectedEqual, internalComparer.Equals(pair.Item1, pair.Item2)); diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.Icu.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.Icu.cs index 2c5a2c61590b21..a25f22eaca341e 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.Icu.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.Icu.cs @@ -850,9 +850,14 @@ private unsafe int IcuGetHashCodeOfString(ReadOnlySpan source, CompareOpti Debug.Assert((options & (CompareOptions.Ordinal | CompareOptions.OrdinalIgnoreCase)) == 0); #if TARGET_BROWSER - // JS cannot create locale-sensitive HashCode, use invaraint functions instead if (GlobalizationMode.Hybrid) - return InvariantGetHashCode(source, options); + { + // JS cannot create locale-sensitive HashCode, use invaraint functions instead + // empty chars influence invariant hashing algo but do not influence ICU hashing algo, + // Hybrid wants to behave like ICU + ReadOnlySpan sanitizedSource = RemoveEmptyChars(source); + return InvariantGetHashCode(sanitizedSource, options); + } #endif // according to ICU User Guide the performance of ucol_getSortKey is worse when it is called with null output buffer diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.WebAssembly.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.WebAssembly.cs index dab9c1aac0ba70..dc19cb4a7dfd99 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.WebAssembly.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.WebAssembly.cs @@ -119,6 +119,27 @@ private unsafe int JsIndexOfCore(ReadOnlySpan source, ReadOnlySpan t return idx; } + private char[] emptyCharsToRemove = { + '\u200d', '\u200b', '\u200c', '\uFEFF', '\u200E', '\u200F', + '\u2060', '\u2063', '\u2061', '\u2062', '\u2064', '\u180E', + '\u202A', '\u202B', '\u202D', '\u202E', '\u2066', '\u2067', + '\u2068', '\u2069', '\u202C' + }; + + private ReadOnlySpan RemoveEmptyChars(ReadOnlySpan source) + { + char[] result = new char[source.Length]; + int resultIndex = 0; + foreach (char c in source) + { + if (Array.IndexOf(emptyCharsToRemove, c) == -1) + { + result[resultIndex++] = c; + } + } + return result.AsSpan(0, resultIndex); + } + private static bool IndexingOptionsNotSupported(CompareOptions options) => (options & CompareOptions.IgnoreSymbols) == CompareOptions.IgnoreSymbols; diff --git a/src/libraries/System.Runtime/tests/System.Globalization.Tests/CompareInfo/CompareInfoTests.HashCode.cs b/src/libraries/System.Runtime/tests/System.Globalization.Tests/CompareInfo/CompareInfoTests.HashCode.cs new file mode 100644 index 00000000000000..88822ae5ed622a --- /dev/null +++ b/src/libraries/System.Runtime/tests/System.Globalization.Tests/CompareInfo/CompareInfoTests.HashCode.cs @@ -0,0 +1,85 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Buffers; +using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Reflection; +using System.Text; +using Xunit; + +namespace System.Globalization.Tests +{ + public class CompareInfoHashCodeTests : CompareInfoTestsBase + { + public class CustomComparer : StringComparer + { + private readonly CompareInfo _compareInfo; + private readonly CompareOptions _compareOptions; + + public CustomComparer(CompareInfo cmpInfo) + { + _compareInfo = cmpInfo; + _compareOptions = CompareOptions.IgnoreCase; + } + + public override int Compare(string x, string y) => + _compareInfo.Compare(x, y, _compareOptions); + + public override bool Equals(string x, string y) => + _compareInfo.Compare(x, y, _compareOptions) == 0; + + public override int GetHashCode(string obj) => + _compareInfo.GetHashCode(obj, _compareOptions); + } + + + public static IEnumerable HashCodeLocalized_TestData() + { + yield return new object[] { s_invariantCompare, "foo", "Foo", CompareOptions.IgnoreCase }; + yield return new object[] { new CultureInfo("pl-PL").CompareInfo, "igloo", "İGLOO", CompareOptions.IgnoreCase }; + yield return new object[] { new CultureInfo("pl-PL").CompareInfo, "igloo", "IGLOO", CompareOptions.IgnoreCase }; + + if (!PlatformDetection.IsHybridGlobalizationOnBrowser) + { + yield return new object[] { new CultureInfo("ja-JP").CompareInfo, "\u30A2", "\u3042", CompareOptions.IgnoreKanaType }; // HG: equal: True, hashCodesEqual: False + yield return new object[] { new CultureInfo("en-GB").CompareInfo, "café", "cafe\u0301", CompareOptions.IgnoreNonSpace | CompareOptions.IgnoreKanaType }; // HG: equal: True, hashCodesEqual: False + yield return new object[] { new CultureInfo("en-GB").CompareInfo, "100", "100!", CompareOptions.IgnoreSymbols }; // HG: equal: True, hashCodesEqual: False + yield return new object[] { new CultureInfo("tr-TR").CompareInfo, "igloo", "İGLOO", CompareOptions.IgnoreCase }; // HG: equal: True, hashCodesEqual: False + yield return new object[] { new CultureInfo("tr-TR").CompareInfo, "igloo", "IGLOO", CompareOptions.IgnoreCase }; // HG: equal: False, hashCodesEqual: True + } + + } + + [Theory] + [MemberData(nameof(HashCodeLocalized_TestData))] + public void HashCodeLocalized(CompareInfo cmpInfo, string str1, string str2, CompareOptions options) + { + bool areEqual = cmpInfo.Compare(str1, str2, options) == 0; + var hashCode1 = cmpInfo.GetHashCode(str1, options); + var hashCode2 = cmpInfo.GetHashCode(str2, options); + bool areHashCodesEqual = hashCode1 == hashCode2; + if (areEqual) + { + Assert.True(areHashCodesEqual); + } + else + { + Assert.False(areHashCodesEqual); + } + + // implication of the above behavior: + Dictionary customDictionary = new Dictionary(new CustomComparer(cmpInfo)); + customDictionary.Add(str1, 0); + if (customDictionary.ContainsKey(str2)) + { + Assert.True(areHashCodesEqual); + } + else + { + customDictionary.Add(str2, 1); + Assert.False(areHashCodesEqual); + } + } + } +} diff --git a/src/libraries/System.Runtime/tests/System.Globalization.Tests/System.Globalization.Tests.csproj b/src/libraries/System.Runtime/tests/System.Globalization.Tests/System.Globalization.Tests.csproj index e5ba39e62b7a70..6319571112d964 100644 --- a/src/libraries/System.Runtime/tests/System.Globalization.Tests/System.Globalization.Tests.csproj +++ b/src/libraries/System.Runtime/tests/System.Globalization.Tests/System.Globalization.Tests.csproj @@ -22,6 +22,7 @@ + From 90024bdd71d7fb9ac72d6df0529b3016887c47be Mon Sep 17 00:00:00 2001 From: Ilona Tomkowicz <32700855+ilonatommy@users.noreply.github.com> Date: Wed, 17 Jan 2024 12:26:09 +0000 Subject: [PATCH 12/22] Comment + more cases. --- .../CompareInfo/CompareInfoTests.HashCode.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/libraries/System.Runtime/tests/System.Globalization.Tests/CompareInfo/CompareInfoTests.HashCode.cs b/src/libraries/System.Runtime/tests/System.Globalization.Tests/CompareInfo/CompareInfoTests.HashCode.cs index 88822ae5ed622a..d2e9a2bf2ec553 100644 --- a/src/libraries/System.Runtime/tests/System.Globalization.Tests/CompareInfo/CompareInfoTests.HashCode.cs +++ b/src/libraries/System.Runtime/tests/System.Globalization.Tests/CompareInfo/CompareInfoTests.HashCode.cs @@ -37,11 +37,14 @@ public override int GetHashCode(string obj) => public static IEnumerable HashCodeLocalized_TestData() { yield return new object[] { s_invariantCompare, "foo", "Foo", CompareOptions.IgnoreCase }; + yield return new object[] { s_invariantCompare, "igloo", "İGLOO", CompareOptions.IgnoreCase }; + yield return new object[] { s_invariantCompare, "igloo", "IGLOO", CompareOptions.IgnoreCase }; yield return new object[] { new CultureInfo("pl-PL").CompareInfo, "igloo", "İGLOO", CompareOptions.IgnoreCase }; yield return new object[] { new CultureInfo("pl-PL").CompareInfo, "igloo", "IGLOO", CompareOptions.IgnoreCase }; if (!PlatformDetection.IsHybridGlobalizationOnBrowser) { + // ActiveIssue: https://github.com/dotnet/runtime/issues/96400 yield return new object[] { new CultureInfo("ja-JP").CompareInfo, "\u30A2", "\u3042", CompareOptions.IgnoreKanaType }; // HG: equal: True, hashCodesEqual: False yield return new object[] { new CultureInfo("en-GB").CompareInfo, "café", "cafe\u0301", CompareOptions.IgnoreNonSpace | CompareOptions.IgnoreKanaType }; // HG: equal: True, hashCodesEqual: False yield return new object[] { new CultureInfo("en-GB").CompareInfo, "100", "100!", CompareOptions.IgnoreSymbols }; // HG: equal: True, hashCodesEqual: False From 7acf408f8e0cd47811cb8771e36415fb0423f605 Mon Sep 17 00:00:00 2001 From: Ilona Tomkowicz <32700855+ilonatommy@users.noreply.github.com> Date: Wed, 17 Jan 2024 14:01:31 +0000 Subject: [PATCH 13/22] Clean CI. --- .../CompareInfo/CompareInfoTests.HashCode.cs | 29 ++++++++++++++----- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/src/libraries/System.Runtime/tests/System.Globalization.Tests/CompareInfo/CompareInfoTests.HashCode.cs b/src/libraries/System.Runtime/tests/System.Globalization.Tests/CompareInfo/CompareInfoTests.HashCode.cs index d2e9a2bf2ec553..05b535d09ba8b6 100644 --- a/src/libraries/System.Runtime/tests/System.Globalization.Tests/CompareInfo/CompareInfoTests.HashCode.cs +++ b/src/libraries/System.Runtime/tests/System.Globalization.Tests/CompareInfo/CompareInfoTests.HashCode.cs @@ -33,8 +33,7 @@ public override int GetHashCode(string obj) => _compareInfo.GetHashCode(obj, _compareOptions); } - - public static IEnumerable HashCodeLocalized_TestData() + public static IEnumerable HashCodeLocalized_TestData(bool testCollection) { yield return new object[] { s_invariantCompare, "foo", "Foo", CompareOptions.IgnoreCase }; yield return new object[] { s_invariantCompare, "igloo", "İGLOO", CompareOptions.IgnoreCase }; @@ -45,17 +44,25 @@ public static IEnumerable HashCodeLocalized_TestData() if (!PlatformDetection.IsHybridGlobalizationOnBrowser) { // ActiveIssue: https://github.com/dotnet/runtime/issues/96400 - yield return new object[] { new CultureInfo("ja-JP").CompareInfo, "\u30A2", "\u3042", CompareOptions.IgnoreKanaType }; // HG: equal: True, hashCodesEqual: False yield return new object[] { new CultureInfo("en-GB").CompareInfo, "café", "cafe\u0301", CompareOptions.IgnoreNonSpace | CompareOptions.IgnoreKanaType }; // HG: equal: True, hashCodesEqual: False - yield return new object[] { new CultureInfo("en-GB").CompareInfo, "100", "100!", CompareOptions.IgnoreSymbols }; // HG: equal: True, hashCodesEqual: False + yield return new object[] { new CultureInfo("en-GB").CompareInfo, "café", "cafe\u0301", CompareOptions.IgnoreNonSpace | CompareOptions.IgnoreKanaType }; // HG: equal: True, hashCodesEqual: False yield return new object[] { new CultureInfo("tr-TR").CompareInfo, "igloo", "İGLOO", CompareOptions.IgnoreCase }; // HG: equal: True, hashCodesEqual: False yield return new object[] { new CultureInfo("tr-TR").CompareInfo, "igloo", "IGLOO", CompareOptions.IgnoreCase }; // HG: equal: False, hashCodesEqual: True } - + + if (!testCollection) + // in ICU: IgnoreKanaType and IgnoreSymbols are not respected + // when using custom comparer. For equal hashes, ContainsKey returns false + if (!PlatformDetection.IsHybridGlobalizationOnBrowser) + { + // ActiveIssue: https://github.com/dotnet/runtime/issues/96400 + yield return new object[] { new CultureInfo("en-GB").CompareInfo, "100", "100!", CompareOptions.IgnoreSymbols }; // HG: equal: True, hashCodesEqual: False + yield return new object[] { new CultureInfo("ja-JP").CompareInfo, "\u30A2", "\u3042", CompareOptions.IgnoreKanaType }; // HG: equal: True, hashCodesEqual: False + } } [Theory] - [MemberData(nameof(HashCodeLocalized_TestData))] + [MemberData(nameof(HashCodeLocalized_TestData), parameters: false)] public void HashCodeLocalized(CompareInfo cmpInfo, string str1, string str2, CompareOptions options) { bool areEqual = cmpInfo.Compare(str1, str2, options) == 0; @@ -70,8 +77,16 @@ public void HashCodeLocalized(CompareInfo cmpInfo, string str1, string str2, Com { Assert.False(areHashCodesEqual); } + } + + [Theory] + [MemberData(nameof(HashCodeLocalized_TestData), parameters: true)] + public void CollectionWithCustomComparer(CompareInfo cmpInfo, string str1, string str2, CompareOptions options) + { + var hashCode1 = cmpInfo.GetHashCode(str1, options); + var hashCode2 = cmpInfo.GetHashCode(str2, options); + bool areHashCodesEqual = hashCode1 == hashCode2; - // implication of the above behavior: Dictionary customDictionary = new Dictionary(new CustomComparer(cmpInfo)); customDictionary.Add(str1, 0); if (customDictionary.ContainsKey(str2)) From 89c55adb3ec53151f7445d27a94ee0637a67e77b Mon Sep 17 00:00:00 2001 From: Ilona Tomkowicz <32700855+ilonatommy@users.noreply.github.com> Date: Wed, 17 Jan 2024 14:10:31 +0000 Subject: [PATCH 14/22] Missing change for clean CI commit. --- .../CompareInfo/CompareInfoTests.HashCode.cs | 39 +++++++------------ 1 file changed, 13 insertions(+), 26 deletions(-) diff --git a/src/libraries/System.Runtime/tests/System.Globalization.Tests/CompareInfo/CompareInfoTests.HashCode.cs b/src/libraries/System.Runtime/tests/System.Globalization.Tests/CompareInfo/CompareInfoTests.HashCode.cs index 05b535d09ba8b6..78c853400cc3fd 100644 --- a/src/libraries/System.Runtime/tests/System.Globalization.Tests/CompareInfo/CompareInfoTests.HashCode.cs +++ b/src/libraries/System.Runtime/tests/System.Globalization.Tests/CompareInfo/CompareInfoTests.HashCode.cs @@ -17,10 +17,10 @@ public class CustomComparer : StringComparer private readonly CompareInfo _compareInfo; private readonly CompareOptions _compareOptions; - public CustomComparer(CompareInfo cmpInfo) + public CustomComparer(CompareInfo cmpInfo, CompareOptions cmpOptions) { _compareInfo = cmpInfo; - _compareOptions = CompareOptions.IgnoreCase; + _compareOptions = cmpOptions; } public override int Compare(string x, string y) => @@ -29,11 +29,14 @@ public override int Compare(string x, string y) => public override bool Equals(string x, string y) => _compareInfo.Compare(x, y, _compareOptions) == 0; - public override int GetHashCode(string obj) => - _compareInfo.GetHashCode(obj, _compareOptions); + public override int GetHashCode(string obj) + { + return _compareInfo.GetHashCode(obj, _compareOptions); + + } } - public static IEnumerable HashCodeLocalized_TestData(bool testCollection) + public static IEnumerable HashCodeLocalized_TestData() { yield return new object[] { s_invariantCompare, "foo", "Foo", CompareOptions.IgnoreCase }; yield return new object[] { s_invariantCompare, "igloo", "İGLOO", CompareOptions.IgnoreCase }; @@ -44,25 +47,17 @@ public static IEnumerable HashCodeLocalized_TestData(bool testCollecti if (!PlatformDetection.IsHybridGlobalizationOnBrowser) { // ActiveIssue: https://github.com/dotnet/runtime/issues/96400 + yield return new object[] { new CultureInfo("en-GB").CompareInfo, "100", "100!", CompareOptions.IgnoreSymbols }; // HG: equal: True, hashCodesEqual: False + yield return new object[] { new CultureInfo("ja-JP").CompareInfo, "\u30A2", "\u3042", CompareOptions.IgnoreKanaType }; // HG: equal: True, hashCodesEqual: False yield return new object[] { new CultureInfo("en-GB").CompareInfo, "café", "cafe\u0301", CompareOptions.IgnoreNonSpace | CompareOptions.IgnoreKanaType }; // HG: equal: True, hashCodesEqual: False yield return new object[] { new CultureInfo("en-GB").CompareInfo, "café", "cafe\u0301", CompareOptions.IgnoreNonSpace | CompareOptions.IgnoreKanaType }; // HG: equal: True, hashCodesEqual: False yield return new object[] { new CultureInfo("tr-TR").CompareInfo, "igloo", "İGLOO", CompareOptions.IgnoreCase }; // HG: equal: True, hashCodesEqual: False yield return new object[] { new CultureInfo("tr-TR").CompareInfo, "igloo", "IGLOO", CompareOptions.IgnoreCase }; // HG: equal: False, hashCodesEqual: True } - - if (!testCollection) - // in ICU: IgnoreKanaType and IgnoreSymbols are not respected - // when using custom comparer. For equal hashes, ContainsKey returns false - if (!PlatformDetection.IsHybridGlobalizationOnBrowser) - { - // ActiveIssue: https://github.com/dotnet/runtime/issues/96400 - yield return new object[] { new CultureInfo("en-GB").CompareInfo, "100", "100!", CompareOptions.IgnoreSymbols }; // HG: equal: True, hashCodesEqual: False - yield return new object[] { new CultureInfo("ja-JP").CompareInfo, "\u30A2", "\u3042", CompareOptions.IgnoreKanaType }; // HG: equal: True, hashCodesEqual: False - } } [Theory] - [MemberData(nameof(HashCodeLocalized_TestData), parameters: false)] + [MemberData(nameof(HashCodeLocalized_TestData))] public void HashCodeLocalized(CompareInfo cmpInfo, string str1, string str2, CompareOptions options) { bool areEqual = cmpInfo.Compare(str1, str2, options) == 0; @@ -77,17 +72,9 @@ public void HashCodeLocalized(CompareInfo cmpInfo, string str1, string str2, Com { Assert.False(areHashCodesEqual); } - } - - [Theory] - [MemberData(nameof(HashCodeLocalized_TestData), parameters: true)] - public void CollectionWithCustomComparer(CompareInfo cmpInfo, string str1, string str2, CompareOptions options) - { - var hashCode1 = cmpInfo.GetHashCode(str1, options); - var hashCode2 = cmpInfo.GetHashCode(str2, options); - bool areHashCodesEqual = hashCode1 == hashCode2; - Dictionary customDictionary = new Dictionary(new CustomComparer(cmpInfo)); + // implication of the above behavior: + Dictionary customDictionary = new Dictionary(new CustomComparer(cmpInfo, options)); customDictionary.Add(str1, 0); if (customDictionary.ContainsKey(str2)) { From 9423bcc567d6c56a8934e7275043fbf90f2e87a1 Mon Sep 17 00:00:00 2001 From: Ilona Tomkowicz <32700855+ilonatommy@users.noreply.github.com> Date: Thu, 18 Jan 2024 10:03:17 +0000 Subject: [PATCH 15/22] `SortKey` not supported for non-invariant cultures, `HashCode` supported for non-invariant cultures only with `IgnoreCase` or `None` options. --- .../System/Globalization/CompareInfo.Icu.cs | 21 +++++++++++++++++-- .../Globalization/CompareInfo.WebAssembly.cs | 15 ++++++++++++- .../CompareInfo/CompareInfoTests.HashCode.cs | 4 ++-- 3 files changed, 35 insertions(+), 5 deletions(-) diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.Icu.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.Icu.cs index a25f22eaca341e..fe9e414c51c228 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.Icu.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.Icu.cs @@ -695,7 +695,11 @@ private unsafe SortKey IcuCreateSortKey(string source, CompareOptions options) #if TARGET_BROWSER // JS cannot create locale-sensitive sort key, use invaraint functions instead. if (GlobalizationMode.Hybrid) + { + if (!_isInvariantCulture) + throw new PlatformNotSupportedException(GetPNSEText("CreateSortKey")); return InvariantCreateSortKey(source, options); + } #endif if ((options & ValidCompareMaskOffFlags) != 0) @@ -751,7 +755,11 @@ private unsafe int IcuGetSortKey(ReadOnlySpan source, Span destinati #if TARGET_BROWSER if (GlobalizationMode.Hybrid) + { + if (!_isInvariantCulture) + throw new PlatformNotSupportedException(GetPNSEText("GetSortKey")); return InvariantGetSortKey(source, destination, options); + } #endif // It's ok to pass nullptr (for empty buffers) to ICU's sort key routines. @@ -798,7 +806,11 @@ private unsafe int IcuGetSortKeyLength(ReadOnlySpan source, CompareOptions #if TARGET_BROWSER if (GlobalizationMode.Hybrid) - return InvariantGetSortKeyLength(source, options); + { + if (!_isInvariantCulture) + throw new PlatformNotSupportedException(GetPNSEText("GetSortKeyLength")); + return InvariantGetSortKeyLength(source, options); + } #endif // It's ok to pass nullptr (for empty buffers) to ICU's sort key routines. @@ -852,10 +864,15 @@ private unsafe int IcuGetHashCodeOfString(ReadOnlySpan source, CompareOpti #if TARGET_BROWSER if (GlobalizationMode.Hybrid) { + if (!_isInvariantCulture && !LocalizedHashCodeSupportsCompareOptions(options)) + { + throw new PlatformNotSupportedException(GetPNSEText("GetHashCode")); + } + // JS cannot create locale-sensitive HashCode, use invaraint functions instead // empty chars influence invariant hashing algo but do not influence ICU hashing algo, // Hybrid wants to behave like ICU - ReadOnlySpan sanitizedSource = RemoveEmptyChars(source); + ReadOnlySpan sanitizedSource = RemoveEmptyChars(source, options); return InvariantGetHashCode(sanitizedSource, options); } #endif diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.WebAssembly.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.WebAssembly.cs index dc19cb4a7dfd99..d65cc2abf64363 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.WebAssembly.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.WebAssembly.cs @@ -8,6 +8,12 @@ namespace System.Globalization { public partial class CompareInfo { + // invariant culture has empty CultureInfo.ToString() and + // m_name == CultureInfo._name == CultureInfo.ToString() + private bool _isInvariantCulture => string.IsNullOrEmpty(m_name); + + private static bool LocalizedHashCodeSupportsCompareOptions(CompareOptions options) => + options == CompareOptions.IgnoreCase || options == CompareOptions.None; private static void AssertHybridOnWasm(CompareOptions options) { Debug.Assert(!GlobalizationMode.Invariant); @@ -126,7 +132,7 @@ private unsafe int JsIndexOfCore(ReadOnlySpan source, ReadOnlySpan t '\u2068', '\u2069', '\u202C' }; - private ReadOnlySpan RemoveEmptyChars(ReadOnlySpan source) + private ReadOnlySpan RemoveEmptyChars(ReadOnlySpan source, CompareOptions options) { char[] result = new char[source.Length]; int resultIndex = 0; @@ -137,6 +143,13 @@ private ReadOnlySpan RemoveEmptyChars(ReadOnlySpan source) result[resultIndex++] = c; } } + if ((options & CompareOptions.IgnoreCase) != 0) + { + string resultStr = new string(result, 0, resultIndex); + TextInfo textInfo = new CultureInfo(m_name).TextInfo; + resultStr = textInfo.ToLower(resultStr); + return resultStr.AsSpan(); + } return result.AsSpan(0, resultIndex); } diff --git a/src/libraries/System.Runtime/tests/System.Globalization.Tests/CompareInfo/CompareInfoTests.HashCode.cs b/src/libraries/System.Runtime/tests/System.Globalization.Tests/CompareInfo/CompareInfoTests.HashCode.cs index 78c853400cc3fd..2739bd71d42e11 100644 --- a/src/libraries/System.Runtime/tests/System.Globalization.Tests/CompareInfo/CompareInfoTests.HashCode.cs +++ b/src/libraries/System.Runtime/tests/System.Globalization.Tests/CompareInfo/CompareInfoTests.HashCode.cs @@ -43,6 +43,8 @@ public static IEnumerable HashCodeLocalized_TestData() yield return new object[] { s_invariantCompare, "igloo", "IGLOO", CompareOptions.IgnoreCase }; yield return new object[] { new CultureInfo("pl-PL").CompareInfo, "igloo", "İGLOO", CompareOptions.IgnoreCase }; yield return new object[] { new CultureInfo("pl-PL").CompareInfo, "igloo", "IGLOO", CompareOptions.IgnoreCase }; + yield return new object[] { new CultureInfo("tr-TR").CompareInfo, "igloo", "İGLOO", CompareOptions.IgnoreCase }; + yield return new object[] { new CultureInfo("tr-TR").CompareInfo, "igloo", "IGLOO", CompareOptions.IgnoreCase }; if (!PlatformDetection.IsHybridGlobalizationOnBrowser) { @@ -51,8 +53,6 @@ public static IEnumerable HashCodeLocalized_TestData() yield return new object[] { new CultureInfo("ja-JP").CompareInfo, "\u30A2", "\u3042", CompareOptions.IgnoreKanaType }; // HG: equal: True, hashCodesEqual: False yield return new object[] { new CultureInfo("en-GB").CompareInfo, "café", "cafe\u0301", CompareOptions.IgnoreNonSpace | CompareOptions.IgnoreKanaType }; // HG: equal: True, hashCodesEqual: False yield return new object[] { new CultureInfo("en-GB").CompareInfo, "café", "cafe\u0301", CompareOptions.IgnoreNonSpace | CompareOptions.IgnoreKanaType }; // HG: equal: True, hashCodesEqual: False - yield return new object[] { new CultureInfo("tr-TR").CompareInfo, "igloo", "İGLOO", CompareOptions.IgnoreCase }; // HG: equal: True, hashCodesEqual: False - yield return new object[] { new CultureInfo("tr-TR").CompareInfo, "igloo", "IGLOO", CompareOptions.IgnoreCase }; // HG: equal: False, hashCodesEqual: True } } From 28879147fe2aec36e18c0f7db2a43bd5895f971f Mon Sep 17 00:00:00 2001 From: Ilona Tomkowicz <32700855+ilonatommy@users.noreply.github.com> Date: Thu, 18 Jan 2024 11:34:16 +0000 Subject: [PATCH 16/22] Feedback. --- .../src/System/Globalization/CompareInfo.Icu.cs | 4 +--- .../System/Globalization/CompareInfo.WebAssembly.cs | 11 ++++++++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.Icu.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.Icu.cs index fe9e414c51c228..1cf4c53563890e 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.Icu.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.Icu.cs @@ -870,9 +870,7 @@ private unsafe int IcuGetHashCodeOfString(ReadOnlySpan source, CompareOpti } // JS cannot create locale-sensitive HashCode, use invaraint functions instead - // empty chars influence invariant hashing algo but do not influence ICU hashing algo, - // Hybrid wants to behave like ICU - ReadOnlySpan sanitizedSource = RemoveEmptyChars(source, options); + ReadOnlySpan sanitizedSource = SanitizeForInvariantHash(source, options); return InvariantGetHashCode(sanitizedSource, options); } #endif diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.WebAssembly.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.WebAssembly.cs index d65cc2abf64363..4d5c57c05e3d59 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.WebAssembly.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.WebAssembly.cs @@ -12,6 +12,10 @@ public partial class CompareInfo // m_name == CultureInfo._name == CultureInfo.ToString() private bool _isInvariantCulture => string.IsNullOrEmpty(m_name); + private TextInfo? _thisTextInfo; + + private TextInfo thisTextInfo => _thisTextInfo ??= new CultureInfo(m_name).TextInfo; + private static bool LocalizedHashCodeSupportsCompareOptions(CompareOptions options) => options == CompareOptions.IgnoreCase || options == CompareOptions.None; private static void AssertHybridOnWasm(CompareOptions options) @@ -125,6 +129,7 @@ private unsafe int JsIndexOfCore(ReadOnlySpan source, ReadOnlySpan t return idx; } + // chars that are ignored by ICU hashing algorithm but not ignored by invariant hashing private char[] emptyCharsToRemove = { '\u200d', '\u200b', '\u200c', '\uFEFF', '\u200E', '\u200F', '\u2060', '\u2063', '\u2061', '\u2062', '\u2064', '\u180E', @@ -132,7 +137,7 @@ private unsafe int JsIndexOfCore(ReadOnlySpan source, ReadOnlySpan t '\u2068', '\u2069', '\u202C' }; - private ReadOnlySpan RemoveEmptyChars(ReadOnlySpan source, CompareOptions options) + private ReadOnlySpan SanitizeForInvariantHash(ReadOnlySpan source, CompareOptions options) { char[] result = new char[source.Length]; int resultIndex = 0; @@ -146,8 +151,8 @@ private ReadOnlySpan RemoveEmptyChars(ReadOnlySpan source, CompareOp if ((options & CompareOptions.IgnoreCase) != 0) { string resultStr = new string(result, 0, resultIndex); - TextInfo textInfo = new CultureInfo(m_name).TextInfo; - resultStr = textInfo.ToLower(resultStr); + // JS-based ToLower, to keep cases like Turkish I working + resultStr = _thisTextInfo.ToLower(resultStr); return resultStr.AsSpan(); } return result.AsSpan(0, resultIndex); From a599f7778640285eb81977a2aa494bb03ff8ca85 Mon Sep 17 00:00:00 2001 From: Ilona Tomkowicz <32700855+ilonatommy@users.noreply.github.com> Date: Thu, 18 Jan 2024 12:00:12 +0000 Subject: [PATCH 17/22] Fix build, add docs. --- .../features/globalization-hybrid-mode.md | 21 ++++++++++++++++--- .../Globalization/CompareInfo.WebAssembly.cs | 4 ++-- .../CompareInfo/CompareInfoTests.HashCode.cs | 1 - 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/docs/design/features/globalization-hybrid-mode.md b/docs/design/features/globalization-hybrid-mode.md index 9435e04b1e01d8..1f2daad16868bd 100644 --- a/docs/design/features/globalization-hybrid-mode.md +++ b/docs/design/features/globalization-hybrid-mode.md @@ -17,14 +17,29 @@ For WebAssembly in Browser we are using Web API instead of some ICU data. Ideall Hybrid has higher priority than sharding or custom modes, described in globalization-icu-wasm.md. -**SortKey** +**HashCode** + +Affected public APIs: +- System.Globalization.CompareInfo.GetHashCode + +For invariant culture all `CompareOptions` are available. + +For non-invariant cultures following `CompareOptions` are available: +- `CompareOption.None` +- `CompareOption.IgnoreCase` -In HybridGlobalization mode Invariant way of SortKey calculation is used. Comparison functions are locale-sensitive while hasing function are not, one of the side effects are described in the issue: https://github.com/dotnet/runtime/issues/96400. The following APIs will work in the same way as they do when `Invariant=true`: +The remaining combinations for non-invariant cultures throw `PlatformNotSupportedException`. + +**SortKey** Affected public APIs: - System.Globalization.CompareInfo.GetSortKey - System.Globalization.CompareInfo.GetSortKeyLength -- System.Globalization.CompareInfo.GetHashCode + +For invariant culture all `CompareOptions` are available. + +For non-invariant cultures `PlatformNotSupportedException` is thrown. + Indirectly affected APIs (the list might not be complete): - Microsoft.VisualBasic.Collection.Add - System.Collections.Hashtable.Add diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.WebAssembly.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.WebAssembly.cs index 4d5c57c05e3d59..9edf7e97af3b06 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.WebAssembly.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.WebAssembly.cs @@ -150,9 +150,9 @@ private ReadOnlySpan SanitizeForInvariantHash(ReadOnlySpan source, C } if ((options & CompareOptions.IgnoreCase) != 0) { - string resultStr = new string(result, 0, resultIndex); + string? resultStr = new string(result, 0, resultIndex); // JS-based ToLower, to keep cases like Turkish I working - resultStr = _thisTextInfo.ToLower(resultStr); + resultStr = _thisTextInfo?.ToLower(resultStr); return resultStr.AsSpan(); } return result.AsSpan(0, resultIndex); diff --git a/src/libraries/System.Runtime/tests/System.Globalization.Tests/CompareInfo/CompareInfoTests.HashCode.cs b/src/libraries/System.Runtime/tests/System.Globalization.Tests/CompareInfo/CompareInfoTests.HashCode.cs index 2739bd71d42e11..d395d5b35abb2d 100644 --- a/src/libraries/System.Runtime/tests/System.Globalization.Tests/CompareInfo/CompareInfoTests.HashCode.cs +++ b/src/libraries/System.Runtime/tests/System.Globalization.Tests/CompareInfo/CompareInfoTests.HashCode.cs @@ -32,7 +32,6 @@ public override bool Equals(string x, string y) => public override int GetHashCode(string obj) { return _compareInfo.GetHashCode(obj, _compareOptions); - } } From c9dc9385ca2987848e58ac5b773ed8b093fb5b98 Mon Sep 17 00:00:00 2001 From: Ilona Tomkowicz <32700855+ilonatommy@users.noreply.github.com> Date: Fri, 19 Jan 2024 08:33:51 +0000 Subject: [PATCH 18/22] Feedback @matouskozak @pavelsavara --- .../Globalization/CompareInfo.WebAssembly.cs | 44 +++++++++++++++---- 1 file changed, 36 insertions(+), 8 deletions(-) diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.WebAssembly.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.WebAssembly.cs index 9edf7e97af3b06..3031e47ec4a91b 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.WebAssembly.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.WebAssembly.cs @@ -129,13 +129,40 @@ private unsafe int JsIndexOfCore(ReadOnlySpan source, ReadOnlySpan t return idx; } - // chars that are ignored by ICU hashing algorithm but not ignored by invariant hashing - private char[] emptyCharsToRemove = { - '\u200d', '\u200b', '\u200c', '\uFEFF', '\u200E', '\u200F', - '\u2060', '\u2063', '\u2061', '\u2062', '\u2064', '\u180E', - '\u202A', '\u202B', '\u202D', '\u202E', '\u2066', '\u2067', - '\u2068', '\u2069', '\u202C' - }; + // there are chars that are ignored by ICU hashing algorithm but not ignored by invariant hashing + // Control: 1105 (out of 1105) + // Format: 697 (out of 731) + // OtherPunctuation: 6919 (out of 7004) + // SpaceSeparator: 289 (out of 289) + // OpenPunctuation: 1275 (out of 1343) + // ClosePunctuation: 1241 (out of 1309) + // DashPunctuation: 408 (out of 425) + // ConnectorPunctuation: 170 (out of 170) + // InitialQuotePunctuation: 204 (out of 204) + // FinalQuotePunctuation: 170 (out of 170) + // LineSeparator: 17 (out of 17) + // ParagraphSeparator: 17 (out of 17) + // OtherLetter: 34 (out of 784142) + // SpacingCombiningMark: 68 (out of 4420) + // ModifierLetter: 51 (out of 4012) + // EnclosingMark: 85 (out of 221) + // NonSpacingMark: 3281 (out of 18105) + // we can skip them all (~1027k chars) by checking for the remining UnicodeCategories (~291k chars) + // overskipping resutls in less collisions which is not a problem + private static bool ShouldNotBeSkipped(UnicodeCategory category) => + category == UnicodeCategory.LowercaseLetter || + category == UnicodeCategory.UppercaseLetter || + category == UnicodeCategory.TitlecaseLetter || + category == UnicodeCategory.LetterNumber || + category == UnicodeCategory.OtherNumber || + category == UnicodeCategory.Control || + category == UnicodeCategory.Surrogate || + category == UnicodeCategory.PrivateUse || + category == UnicodeCategory.MathSymbol || + category == UnicodeCategory.CurrencySymbol || + category == UnicodeCategory.ModifierSymbol || + category == UnicodeCategory.OtherSymbol || + category == UnicodeCategory.OtherNotAssigned; private ReadOnlySpan SanitizeForInvariantHash(ReadOnlySpan source, CompareOptions options) { @@ -143,7 +170,8 @@ private ReadOnlySpan SanitizeForInvariantHash(ReadOnlySpan source, C int resultIndex = 0; foreach (char c in source) { - if (Array.IndexOf(emptyCharsToRemove, c) == -1) + UnicodeCategory category = CharUnicodeInfo.GetUnicodeCategory(c); + if (ShouldNotBeSkipped(category)) { result[resultIndex++] = c; } From 398d047bf7aa2eff90b191961456244aaf570bfc Mon Sep 17 00:00:00 2001 From: Ilona Tomkowicz <32700855+ilonatommy@users.noreply.github.com> Date: Fri, 19 Jan 2024 13:50:58 +0000 Subject: [PATCH 19/22] Added tests + fixed algo. --- .../Globalization/CompareInfo.WebAssembly.cs | 9 +-- .../CompareInfo/CompareInfoTests.HashCode.cs | 74 ++++++++++++++++--- 2 files changed, 66 insertions(+), 17 deletions(-) diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.WebAssembly.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.WebAssembly.cs index 3031e47ec4a91b..721cef6a8290c9 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.WebAssembly.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.WebAssembly.cs @@ -147,7 +147,7 @@ private unsafe int JsIndexOfCore(ReadOnlySpan source, ReadOnlySpan t // ModifierLetter: 51 (out of 4012) // EnclosingMark: 85 (out of 221) // NonSpacingMark: 3281 (out of 18105) - // we can skip them all (~1027k chars) by checking for the remining UnicodeCategories (~291k chars) + // we can skip them all (~1027k chars) by checking for the remaining UnicodeCategories (~291k chars) // overskipping resutls in less collisions which is not a problem private static bool ShouldNotBeSkipped(UnicodeCategory category) => category == UnicodeCategory.LowercaseLetter || @@ -155,7 +155,6 @@ private static bool ShouldNotBeSkipped(UnicodeCategory category) => category == UnicodeCategory.TitlecaseLetter || category == UnicodeCategory.LetterNumber || category == UnicodeCategory.OtherNumber || - category == UnicodeCategory.Control || category == UnicodeCategory.Surrogate || category == UnicodeCategory.PrivateUse || category == UnicodeCategory.MathSymbol || @@ -178,9 +177,9 @@ private ReadOnlySpan SanitizeForInvariantHash(ReadOnlySpan source, C } if ((options & CompareOptions.IgnoreCase) != 0) { - string? resultStr = new string(result, 0, resultIndex); - // JS-based ToLower, to keep cases like Turkish I working - resultStr = _thisTextInfo?.ToLower(resultStr); + string resultStr = new string(result, 0, resultIndex); + // JS-based ToUpper, to keep cases like Turkish I working + resultStr = thisTextInfo.ToUpper(resultStr); return resultStr.AsSpan(); } return result.AsSpan(0, resultIndex); diff --git a/src/libraries/System.Runtime/tests/System.Globalization.Tests/CompareInfo/CompareInfoTests.HashCode.cs b/src/libraries/System.Runtime/tests/System.Globalization.Tests/CompareInfo/CompareInfoTests.HashCode.cs index d395d5b35abb2d..a2247b39f636ec 100644 --- a/src/libraries/System.Runtime/tests/System.Globalization.Tests/CompareInfo/CompareInfoTests.HashCode.cs +++ b/src/libraries/System.Runtime/tests/System.Globalization.Tests/CompareInfo/CompareInfoTests.HashCode.cs @@ -38,20 +38,20 @@ public override int GetHashCode(string obj) public static IEnumerable HashCodeLocalized_TestData() { yield return new object[] { s_invariantCompare, "foo", "Foo", CompareOptions.IgnoreCase }; - yield return new object[] { s_invariantCompare, "igloo", "İGLOO", CompareOptions.IgnoreCase }; + yield return new object[] { s_invariantCompare, "igloo", "\u0130GLOO", CompareOptions.IgnoreCase }; // FAILS yield return new object[] { s_invariantCompare, "igloo", "IGLOO", CompareOptions.IgnoreCase }; - yield return new object[] { new CultureInfo("pl-PL").CompareInfo, "igloo", "İGLOO", CompareOptions.IgnoreCase }; + yield return new object[] { new CultureInfo("pl-PL").CompareInfo, "igloo", "\u0130GLOO", CompareOptions.IgnoreCase }; // FAILS yield return new object[] { new CultureInfo("pl-PL").CompareInfo, "igloo", "IGLOO", CompareOptions.IgnoreCase }; - yield return new object[] { new CultureInfo("tr-TR").CompareInfo, "igloo", "İGLOO", CompareOptions.IgnoreCase }; - yield return new object[] { new CultureInfo("tr-TR").CompareInfo, "igloo", "IGLOO", CompareOptions.IgnoreCase }; + yield return new object[] { new CultureInfo("tr-TR").CompareInfo, "igloo", "\u0130GLOO", CompareOptions.IgnoreCase }; + yield return new object[] { new CultureInfo("tr-TR").CompareInfo, "igloo", "IGLOO", CompareOptions.IgnoreCase }; // FAILS if (!PlatformDetection.IsHybridGlobalizationOnBrowser) { // ActiveIssue: https://github.com/dotnet/runtime/issues/96400 yield return new object[] { new CultureInfo("en-GB").CompareInfo, "100", "100!", CompareOptions.IgnoreSymbols }; // HG: equal: True, hashCodesEqual: False yield return new object[] { new CultureInfo("ja-JP").CompareInfo, "\u30A2", "\u3042", CompareOptions.IgnoreKanaType }; // HG: equal: True, hashCodesEqual: False - yield return new object[] { new CultureInfo("en-GB").CompareInfo, "café", "cafe\u0301", CompareOptions.IgnoreNonSpace | CompareOptions.IgnoreKanaType }; // HG: equal: True, hashCodesEqual: False - yield return new object[] { new CultureInfo("en-GB").CompareInfo, "café", "cafe\u0301", CompareOptions.IgnoreNonSpace | CompareOptions.IgnoreKanaType }; // HG: equal: True, hashCodesEqual: False + yield return new object[] { new CultureInfo("en-GB").CompareInfo, "caf\u00E9", "cafe\u0301", CompareOptions.IgnoreNonSpace | CompareOptions.IgnoreKanaType }; // HG: equal: True, hashCodesEqual: False + yield return new object[] { new CultureInfo("en-GB").CompareInfo, "caf\u00E9", "cafe\u0301", CompareOptions.IgnoreNonSpace | CompareOptions.IgnoreKanaType }; // HG: equal: True, hashCodesEqual: False } } @@ -63,6 +63,7 @@ public void HashCodeLocalized(CompareInfo cmpInfo, string str1, string str2, Com var hashCode1 = cmpInfo.GetHashCode(str1, options); var hashCode2 = cmpInfo.GetHashCode(str2, options); bool areHashCodesEqual = hashCode1 == hashCode2; + if (areEqual) { Assert.True(areHashCodesEqual); @@ -73,17 +74,66 @@ public void HashCodeLocalized(CompareInfo cmpInfo, string str1, string str2, Com } // implication of the above behavior: - Dictionary customDictionary = new Dictionary(new CustomComparer(cmpInfo, options)); + StringComparer stringComparer = new CustomComparer(cmpInfo, options); + TryAddToCustomDictionary(stringComparer, str1, str2, areHashCodesEqual); + } + + private void TryAddToCustomDictionary(StringComparer comparer, string str1, string str2, bool shouldFail) + { + Dictionary customDictionary = new Dictionary(comparer); customDictionary.Add(str1, 0); - if (customDictionary.ContainsKey(str2)) + try { - Assert.True(areHashCodesEqual); + customDictionary.Add(str2, 1); + Assert.False(shouldFail); } - else + catch (ArgumentException ex) { - customDictionary.Add(str2, 1); - Assert.False(areHashCodesEqual); + Assert.True(shouldFail); + Assert.Contains("An item with the same key has already been added.", ex.Message); + } + catch (Exception ex) + { + Assert.Fail($"Unexpected exception thrown: {ex}"); } } + + public static IEnumerable CheckHashingOfSkippedChars_TestData() + { + // one char from each ignored category that is skipped on ICU + yield return new object[] { '\u0008', s_invariantCompare }; // Control: BACKSPACE + yield return new object[] { '\u200B', s_invariantCompare }; // Format: ZERO WIDTH SPACE + yield return new object[] { '\u180A', s_invariantCompare }; // OtherPunctuation: MONGOLIAN NIRUGU + yield return new object[] { '\uFE73', s_invariantCompare }; // OtherLetter: THAI CHARACTER PAIYANNOI + yield return new object[] { '\u0F3E', s_invariantCompare }; // SpacingCombiningMark: "TIBETAN MARK GTER YIG MGO UM RTAGS GNYIS + yield return new object[] { '\u0640', s_invariantCompare }; // ModifierLetter: ARABIC TATWEEL + yield return new object[] { '\u0488', s_invariantCompare }; // EnclosingMark: COMBINING CYRILLIC HUNDRED THOUSANDS SIGN + yield return new object[] { '\u034F', s_invariantCompare }; // NonSpacingMark: DIAERESIS + CompareInfo thaiCmpInfo = new CultureInfo("th-TH").CompareInfo; + yield return new object[] { '\u0020', thaiCmpInfo }; // SpaceSeparator: SPACE + yield return new object[] { '\u0028', thaiCmpInfo }; // OpenPunctuation: LEFT PARENTHESIS + yield return new object[] { '\u007D', thaiCmpInfo }; // ClosePunctuation: RIGHT PARENTHESIS + yield return new object[] { '\u2013', thaiCmpInfo }; // DashPunctuation: EN DASH + yield return new object[] { '\u005F', thaiCmpInfo }; // ConnectorPunctuation: LOW LINE + yield return new object[] { '\u2018', thaiCmpInfo }; // InitialQuotePunctuation: LEFT SINGLE QUOTATION MARK + yield return new object[] { '\u2019', thaiCmpInfo }; // FinalQuotePunctuation: RIGHT SINGLE QUOTATION MARK + yield return new object[] { '\u2028', thaiCmpInfo }; // LineSeparator: LINE SEPARATOR + yield return new object[] { '\u2029', thaiCmpInfo }; // ParagraphSeparator: PARAGRAPH SEPARATOR + } + + [Theory] + [MemberData(nameof(CheckHashingOfSkippedChars_TestData))] + public void CheckHashingOfSkippedChars(char character, CompareInfo cmpInfo) + { + string str1 = $"a{character}b"; + string str2 = "ab"; + CompareOptions options = CompareOptions.None; + var hashCode1 = cmpInfo.GetHashCode(str1, options); + var hashCode2 = cmpInfo.GetHashCode(str2, options); + bool areHashCodesEqual = hashCode1 == hashCode2; + Assert.True(areHashCodesEqual); + StringComparer stringComparer = new CustomComparer(cmpInfo, options); + TryAddToCustomDictionary(stringComparer, str1, str2, areHashCodesEqual); + } } } From ee1f5428a6467c65470d51b92c012ad90e8515d0 Mon Sep 17 00:00:00 2001 From: Ilona Tomkowicz <32700855+ilonatommy@users.noreply.github.com> Date: Fri, 19 Jan 2024 16:16:46 +0000 Subject: [PATCH 20/22] Block failing tests for a follow-up PR. --- .../tests/Xslt/XslCompiledTransformApi/XsltArgumentList.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libraries/System.Private.Xml/tests/Xslt/XslCompiledTransformApi/XsltArgumentList.cs b/src/libraries/System.Private.Xml/tests/Xslt/XslCompiledTransformApi/XsltArgumentList.cs index 71de03fbcabc9e..21603113f5cec4 100644 --- a/src/libraries/System.Private.Xml/tests/Xslt/XslCompiledTransformApi/XsltArgumentList.cs +++ b/src/libraries/System.Private.Xml/tests/Xslt/XslCompiledTransformApi/XsltArgumentList.cs @@ -3252,7 +3252,7 @@ public void AddExtObject32(object param, XslInputType xslInputType, ReaderType r [InlineData("sort.xsl", "sort.txt", XslInputType.Navigator, ReaderType.XmlValidatingReader, OutputType.Writer, NavType.XPathDocument)] [InlineData("sort.xsl", "sort.txt", XslInputType.Navigator, ReaderType.XmlValidatingReader, OutputType.TextWriter, NavType.XPathDocument)] - [Theory] + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] public void AddExtObject33(object param0, object param1, XslInputType xslInputType, ReaderType readerType, OutputType outputType, NavType navType) { ExObj obj = new ExObj(0, _output); From 10e90605b0a1bd7c8fd78b4e13b9674fe0753fce Mon Sep 17 00:00:00 2001 From: Ilona Tomkowicz <32700855+ilonatommy@users.noreply.github.com> Date: Fri, 19 Jan 2024 16:17:42 +0000 Subject: [PATCH 21/22] Add more details to PNSE. --- .../System.Private.CoreLib/src/Resources/Strings.resx | 3 +++ .../src/System/Globalization/CompareInfo.Icu.cs | 8 ++++---- .../src/System/Globalization/CompareInfo.cs | 1 + 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/libraries/System.Private.CoreLib/src/Resources/Strings.resx b/src/libraries/System.Private.CoreLib/src/Resources/Strings.resx index 68969b6453939b..ac57b0760021b2 100644 --- a/src/libraries/System.Private.CoreLib/src/Resources/Strings.resx +++ b/src/libraries/System.Private.CoreLib/src/Resources/Strings.resx @@ -4100,6 +4100,9 @@ {0} is not supported when HybridGlobalization=true. Disable it to load larger ICU bundle, then use this option. + + {0} is not supported for {1}, when HybridGlobalization=true. Disable it to load larger ICU bundle, then use this option. + The body of this method was removed by the AOT compiler because it's not callable. diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.Icu.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.Icu.cs index 1cf4c53563890e..75440b2a23c458 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.Icu.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.Icu.cs @@ -697,7 +697,7 @@ private unsafe SortKey IcuCreateSortKey(string source, CompareOptions options) if (GlobalizationMode.Hybrid) { if (!_isInvariantCulture) - throw new PlatformNotSupportedException(GetPNSEText("CreateSortKey")); + throw new PlatformNotSupportedException(GetPNSEWithReason("CreateSortKey", "non-invariant culture")); return InvariantCreateSortKey(source, options); } #endif @@ -757,7 +757,7 @@ private unsafe int IcuGetSortKey(ReadOnlySpan source, Span destinati if (GlobalizationMode.Hybrid) { if (!_isInvariantCulture) - throw new PlatformNotSupportedException(GetPNSEText("GetSortKey")); + throw new PlatformNotSupportedException(GetPNSEWithReason("GetSortKey", "non-invariant culture")); return InvariantGetSortKey(source, destination, options); } #endif @@ -808,7 +808,7 @@ private unsafe int IcuGetSortKeyLength(ReadOnlySpan source, CompareOptions if (GlobalizationMode.Hybrid) { if (!_isInvariantCulture) - throw new PlatformNotSupportedException(GetPNSEText("GetSortKeyLength")); + throw new PlatformNotSupportedException(GetPNSEWithReason("GetSortKeyLength", "non-invariant culture")); return InvariantGetSortKeyLength(source, options); } #endif @@ -866,7 +866,7 @@ private unsafe int IcuGetHashCodeOfString(ReadOnlySpan source, CompareOpti { if (!_isInvariantCulture && !LocalizedHashCodeSupportsCompareOptions(options)) { - throw new PlatformNotSupportedException(GetPNSEText("GetHashCode")); + throw new PlatformNotSupportedException(GetPNSEWithReason("GetHashCode", "non-invariant culture with CompareOptions different than None or IgnoreCase")); } // JS cannot create locale-sensitive HashCode, use invaraint functions instead diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.cs index 3e2afe57b37e74..729fe7d4383b5e 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.cs @@ -1628,6 +1628,7 @@ public SortVersion Version #if TARGET_BROWSER || TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS private static string GetPNSEText(string funcName) => SR.Format(SR.PlatformNotSupported_HybridGlobalization, funcName); + private static string GetPNSEWithReason(string funcName, string reason) => SR.Format(SR.PlatformNotSupportedWithReason_HybridGlobalization, funcName, reason); #endif } } From 80d9d37d88ad3b934d762252ac9aab83b632017b Mon Sep 17 00:00:00 2001 From: Ilona Tomkowicz <32700855+ilonatommy@users.noreply.github.com> Date: Fri, 19 Jan 2024 16:20:18 +0000 Subject: [PATCH 22/22] Feedback - correct comment --- .../src/System/Globalization/CompareInfo.WebAssembly.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.WebAssembly.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.WebAssembly.cs index 721cef6a8290c9..1d265dc70450a8 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.WebAssembly.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.WebAssembly.cs @@ -148,7 +148,8 @@ private unsafe int JsIndexOfCore(ReadOnlySpan source, ReadOnlySpan t // EnclosingMark: 85 (out of 221) // NonSpacingMark: 3281 (out of 18105) // we can skip them all (~1027k chars) by checking for the remaining UnicodeCategories (~291k chars) - // overskipping resutls in less collisions which is not a problem + // skipping more characters than ICU would lead to hashes with smaller distribution and more collisions in hash tables + // but it makes the behavior correct and consistent with locale-aware equals, which is acceptable tradeoff private static bool ShouldNotBeSkipped(UnicodeCategory category) => category == UnicodeCategory.LowercaseLetter || category == UnicodeCategory.UppercaseLetter ||