diff --git a/docs/design/features/globalization-hybrid-mode.md b/docs/design/features/globalization-hybrid-mode.md index 9d993f7b31c82..001ae20002cc9 100644 --- a/docs/design/features/globalization-hybrid-mode.md +++ b/docs/design/features/globalization-hybrid-mode.md @@ -17,12 +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. +**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` + +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 @@ -43,8 +60,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/Microsoft.VisualBasic.Core/tests/CollectionsTests.cs b/src/libraries/Microsoft.VisualBasic.Core/tests/CollectionsTests.cs index 35195353a2ed6..d387d548b4115 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 3d66733224abe..a95f101731dfc 100644 --- a/src/libraries/Microsoft.VisualBasic.Core/tests/LateBindingTests.cs +++ b/src/libraries/Microsoft.VisualBasic.Core/tests/LateBindingTests.cs @@ -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) { @@ -74,7 +74,7 @@ public void LateIndexSet(object obj, object[] args, string[] paramNames, Func("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 9b46116d50ed2..e5735bdbbbb7e 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 c0fddb75701b6..e172e121feac8 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 e34009b7c97fb..9ede42f1d18d4 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 d8eb5ae5777d7..74b351ff4007c 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 b9a64ecc30aed..941b943be7ab0 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 3f7ec1338bf87..7d1c06f066a11 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 db56a194ad67a..f1edcf9aad34a 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 e05a2e78936c5..05af2efe64000 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 fe99de5af1b7d..4ec96a64fd9ea 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 398aab7fabf13..c1f1bd54acfcb 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 82578fb7de13a..538b9c924ce2a 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 28ba9d7ad71ad..dc148f198c358 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 acdf6b442eabb..b15395c354d11 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 409ccd25c8ab4..2daff0ba450f9 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 c7106153faf89..20cf0fe5af512 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 ba652ced4b86b..c8b4fdc6c996e 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 c6e723e1a52f5..82e63d654e47c 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 4e0b496448802..c283053d0c70c 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 d61cabe1900b3..47c6e1db59e8d 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 b179a4b6bfd2c..dc7bfaca4f64c 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 b7deb3badfc45..0371dc9e20ad8 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 65e582c346a64..34e48ae0ba55d 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 dc9e8bb14598b..de3e23ecd4086 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 79e8c037ed15b..6873b3e8a22d2 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 f24d0cd7892e3..ac1163d28c041 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 37297f382c0a3..d6809b65a0941 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); @@ -336,7 +336,6 @@ private static void ValidateBehaviorOfInternalComparerVsPublicComparer(IEquality { publicComparer = EqualityComparer.Default; } - foreach (var pair in new[] { ("Hello", "Hello"), // exactly equal ("Hello", "Goodbye"), // not equal at all 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 c3350234eacc7..0e8fb95a74e6d 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; 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 3cf12c4d4648d..a03fc946672eb 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 edda9c89df4f9..7f6d7bb12c0f2 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(); 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 7652cfe9dac9d..db2a3420cde13 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 e9acec3f8c446..340eb77e7d60a 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 0806c4a586eb8..2c7a483cd2b66 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 02d2b2153d3d0..ef8516dfc3e16 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 3c88b4a785bcc..9d73511e9b07a 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 70c30ee55a86a..019ceee0d41b2 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.CoreLib/src/Resources/Strings.resx b/src/libraries/System.Private.CoreLib/src/Resources/Strings.resx index 68969b6453939..ac57b0760021b 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 f2c7dd254ae2f..75440b2a23c45 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,16 @@ 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) + { + if (!_isInvariantCulture) + throw new PlatformNotSupportedException(GetPNSEWithReason("CreateSortKey", "non-invariant culture")); + return InvariantCreateSortKey(source, options); + } +#endif + if ((options & ValidCompareMaskOffFlags) != 0) { throw new ArgumentException(SR.Argument_InvalidFlag, nameof(options)); @@ -743,6 +753,15 @@ private unsafe int IcuGetSortKey(ReadOnlySpan source, Span destinati Debug.Assert(!GlobalizationMode.UseNls); Debug.Assert((options & ValidCompareMaskOffFlags) == 0); +#if TARGET_BROWSER + if (GlobalizationMode.Hybrid) + { + if (!_isInvariantCulture) + throw new PlatformNotSupportedException(GetPNSEWithReason("GetSortKey", "non-invariant culture")); + 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 +804,15 @@ private unsafe int IcuGetSortKeyLength(ReadOnlySpan source, CompareOptions Debug.Assert(!GlobalizationMode.UseNls); Debug.Assert((options & ValidCompareMaskOffFlags) == 0); +#if TARGET_BROWSER + if (GlobalizationMode.Hybrid) + { + if (!_isInvariantCulture) + throw new PlatformNotSupportedException(GetPNSEWithReason("GetSortKeyLength", "non-invariant culture")); + 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 +861,20 @@ private unsafe int IcuGetHashCodeOfString(ReadOnlySpan source, CompareOpti Debug.Assert(!GlobalizationMode.UseNls); Debug.Assert((options & (CompareOptions.Ordinal | CompareOptions.OrdinalIgnoreCase)) == 0); +#if TARGET_BROWSER + if (GlobalizationMode.Hybrid) + { + if (!_isInvariantCulture && !LocalizedHashCodeSupportsCompareOptions(options)) + { + 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 + ReadOnlySpan sanitizedSource = SanitizeForInvariantHash(source, options); + 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 // 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 739f461cc8628..a26ba62928bcd 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.WebAssembly.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.WebAssembly.cs index dab9c1aac0ba7..1d265dc70450a 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,16 @@ 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 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) { Debug.Assert(!GlobalizationMode.Invariant); @@ -119,6 +129,63 @@ private unsafe int JsIndexOfCore(ReadOnlySpan source, ReadOnlySpan t return idx; } + // 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 remaining UnicodeCategories (~291k chars) + // 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 || + category == UnicodeCategory.TitlecaseLetter || + category == UnicodeCategory.LetterNumber || + category == UnicodeCategory.OtherNumber || + 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) + { + char[] result = new char[source.Length]; + int resultIndex = 0; + foreach (char c in source) + { + UnicodeCategory category = CharUnicodeInfo.GetUnicodeCategory(c); + if (ShouldNotBeSkipped(category)) + { + result[resultIndex++] = c; + } + } + if ((options & CompareOptions.IgnoreCase) != 0) + { + 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); + } + private static bool IndexingOptionsNotSupported(CompareOptions options) => (options & CompareOptions.IgnoreSymbols) == CompareOptions.IgnoreSymbols; 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 7d46be4685e0d..729fe7d4383b5 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.cs @@ -1450,10 +1450,6 @@ public SortKey GetSortKey(string source) private SortKey CreateSortKeyCore(string source, CompareOptions options) => GlobalizationMode.UseNls ? NlsCreateSortKey(source, options) : -#if TARGET_BROWSER - GlobalizationMode.Hybrid ? - throw new PlatformNotSupportedException(GetPNSEText("SortKey")) : -#endif IcuCreateSortKey(source, options); /// @@ -1493,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 ? - throw new PlatformNotSupportedException(GetPNSEText("SortKey")) : -#endif IcuGetSortKey(source, destination, options); /// @@ -1530,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 ? - throw new PlatformNotSupportedException(GetPNSEText("SortKey")) : -#endif IcuGetSortKeyLength(source, options); public override bool Equals([NotNullWhen(true)] object? value) @@ -1576,12 +1564,7 @@ public int GetHashCode(ReadOnlySpan source, CompareOptions options) return GetHashCodeOfStringCore(source, options); } - if ((options & CompareOptions.IgnoreCase) == 0) - { - return string.GetHashCode(source); - } - - return string.GetHashCodeOrdinalIgnoreCase(source); + return InvariantGetHashCode(source, options); } else { @@ -1607,10 +1590,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; @@ -1649,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 } } 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 293d959a01674..5550b59c4d88e 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/tests/System.Globalization.Extensions.Tests/GetStringComparerTests.cs b/src/libraries/System.Runtime/tests/System.Globalization.Extensions.Tests/GetStringComparerTests.cs index bab4eaadd8b50..3046f50a98c3e 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))] + [Theory] [ActiveIssue("https://github.com/dotnet/runtime/issues/95338", typeof(PlatformDetection), nameof(PlatformDetection.IsHybridGlobalizationOnApplePlatform))] [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.Globalization.Tests/CompareInfo/CompareInfoTests.HashCode.cs b/src/libraries/System.Runtime/tests/System.Globalization.Tests/CompareInfo/CompareInfoTests.HashCode.cs new file mode 100644 index 0000000000000..a2247b39f636e --- /dev/null +++ b/src/libraries/System.Runtime/tests/System.Globalization.Tests/CompareInfo/CompareInfoTests.HashCode.cs @@ -0,0 +1,139 @@ +// 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, CompareOptions cmpOptions) + { + _compareInfo = cmpInfo; + _compareOptions = cmpOptions; + } + + 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) + { + return _compareInfo.GetHashCode(obj, _compareOptions); + } + } + + public static IEnumerable HashCodeLocalized_TestData() + { + yield return new object[] { s_invariantCompare, "foo", "Foo", 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", "\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", "\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\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 + } + } + + [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: + 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); + try + { + customDictionary.Add(str2, 1); + Assert.False(shouldFail); + } + catch (ArgumentException ex) + { + 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); + } + } +} 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 596b0f3435ad1..a0542ac5e13c7 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 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 e5ba39e62b7a7..6319571112d96 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 @@ + 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 2b8c983fc83cd..bb69f0df97a3e 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,14 +87,15 @@ 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) + // 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" }; yield return new object[] { "turky i", "TURKY \u0130", "tr-TR" }; } } - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [Theory] [MemberData(nameof(UpperLowerCasing_TestData))] public static void CreateWithCulturesTest(string lowerForm, string upperForm, string cultureName) { @@ -112,7 +113,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"); 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 b6160f82fcea4..3027c870855b5 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 b31f71b1e3b48..c339685105509 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) { @@ -89,7 +89,8 @@ 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.IsNotHybridGlobalizationOnApplePlatform) + // https://github.com/dotnet/runtime/issues/95503 + if (PlatformDetection.IsNotHybridGlobalizationOnApplePlatform && 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/StringTests.cs b/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/StringTests.cs index d732e1644bb29..dbd6bf7cbee5b 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 bb500cea493b6..f7e20fbfe8938 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), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [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')] 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 d7459be339a96..0947ccbdfc895 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)));