diff --git a/src/System.Runtime.Extensions/System.Runtime.Extensions.sln b/src/System.Runtime.Extensions/System.Runtime.Extensions.sln index a56140ab8633..4ef1d323a52e 100644 --- a/src/System.Runtime.Extensions/System.Runtime.Extensions.sln +++ b/src/System.Runtime.Extensions/System.Runtime.Extensions.sln @@ -40,14 +40,14 @@ Global EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {845D2B72-D8A4-42E5-9BE9-17639EC4FC1A}.Debug|Any CPU.ActiveCfg = Windows_Debug|Any CPU - {845D2B72-D8A4-42E5-9BE9-17639EC4FC1A}.net46_Debug|Any CPU.ActiveCfg = net462_Release|Any CPU - {845D2B72-D8A4-42E5-9BE9-17639EC4FC1A}.net46_Debug|Any CPU.Build.0 = net462_Release|Any CPU - {845D2B72-D8A4-42E5-9BE9-17639EC4FC1A}.net46_Release|Any CPU.ActiveCfg = net462_Release|Any CPU - {845D2B72-D8A4-42E5-9BE9-17639EC4FC1A}.net46_Release|Any CPU.Build.0 = net462_Release|Any CPU - {845D2B72-D8A4-42E5-9BE9-17639EC4FC1A}.netstandard1.7_Debug|Any CPU.ActiveCfg = net463_Release|Any CPU - {845D2B72-D8A4-42E5-9BE9-17639EC4FC1A}.netstandard1.7_Debug|Any CPU.Build.0 = net463_Release|Any CPU - {845D2B72-D8A4-42E5-9BE9-17639EC4FC1A}.netstandard1.7_Release|Any CPU.ActiveCfg = net463_Debug|Any CPU - {845D2B72-D8A4-42E5-9BE9-17639EC4FC1A}.netstandard1.7_Release|Any CPU.Build.0 = net463_Debug|Any CPU + {845D2B72-D8A4-42E5-9BE9-17639EC4FC1A}.net46_Debug|Any CPU.ActiveCfg = net461_Release|Any CPU + {845D2B72-D8A4-42E5-9BE9-17639EC4FC1A}.net46_Debug|Any CPU.Build.0 = net461_Release|Any CPU + {845D2B72-D8A4-42E5-9BE9-17639EC4FC1A}.net46_Release|Any CPU.ActiveCfg = net461_Release|Any CPU + {845D2B72-D8A4-42E5-9BE9-17639EC4FC1A}.net46_Release|Any CPU.Build.0 = net461_Release|Any CPU + {845D2B72-D8A4-42E5-9BE9-17639EC4FC1A}.netstandard1.7_Debug|Any CPU.ActiveCfg = net461_Release|Any CPU + {845D2B72-D8A4-42E5-9BE9-17639EC4FC1A}.netstandard1.7_Debug|Any CPU.Build.0 = net461_Release|Any CPU + {845D2B72-D8A4-42E5-9BE9-17639EC4FC1A}.netstandard1.7_Release|Any CPU.ActiveCfg = net461_Release|Any CPU + {845D2B72-D8A4-42E5-9BE9-17639EC4FC1A}.netstandard1.7_Release|Any CPU.Build.0 = net461_Release|Any CPU {845D2B72-D8A4-42E5-9BE9-17639EC4FC1A}.Release|Any CPU.ActiveCfg = Windows_Release|Any CPU {845D2B72-D8A4-42E5-9BE9-17639EC4FC1A}.Unix_Debug|Any CPU.ActiveCfg = Unix_Debug|Any CPU {845D2B72-D8A4-42E5-9BE9-17639EC4FC1A}.Unix_Debug|Any CPU.Build.0 = Unix_Debug|Any CPU diff --git a/src/System.Runtime.Extensions/ref/System.Runtime.Extensions.cs b/src/System.Runtime.Extensions/ref/System.Runtime.Extensions.cs index d5d8c1d14ec4..5d6bc798e03f 100644 --- a/src/System.Runtime.Extensions/ref/System.Runtime.Extensions.cs +++ b/src/System.Runtime.Extensions/ref/System.Runtime.Extensions.cs @@ -901,6 +901,9 @@ protected StringComparer() { } public static System.StringComparer InvariantCultureIgnoreCase { get { throw null; } } public static System.StringComparer Ordinal { get { throw null; } } public static System.StringComparer OrdinalIgnoreCase { get { throw null; } } +#if netcoreapp11 + public static System.StringComparer FromComparison(System.StringComparison comparisonType) { throw null; } +#endif public abstract int Compare(string x, string y); public static System.StringComparer Create(System.Globalization.CultureInfo culture, bool ignoreCase) { throw null; } public new bool Equals(object x, object y) { throw null; } diff --git a/src/System.Runtime.Extensions/tests/System.Runtime.Extensions.Tests.csproj b/src/System.Runtime.Extensions/tests/System.Runtime.Extensions.Tests.csproj index ffdffdc7a863..ffa081346231 100644 --- a/src/System.Runtime.Extensions/tests/System.Runtime.Extensions.Tests.csproj +++ b/src/System.Runtime.Extensions/tests/System.Runtime.Extensions.Tests.csproj @@ -55,6 +55,7 @@ + diff --git a/src/System.Runtime.Extensions/tests/System/StringComparer.netcoreapp1.1.cs b/src/System.Runtime.Extensions/tests/System/StringComparer.netcoreapp1.1.cs new file mode 100644 index 000000000000..ed8ced4f10a5 --- /dev/null +++ b/src/System.Runtime.Extensions/tests/System/StringComparer.netcoreapp1.1.cs @@ -0,0 +1,42 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using Xunit; + +namespace System.Tests +{ + public static partial class MiscStringComparerTests + { + public static readonly object[][] FromComparison_TestData = + { + // StringComparison StringComparer + new object[] { StringComparison.CurrentCulture, StringComparer.CurrentCulture }, + new object[] { StringComparison.CurrentCultureIgnoreCase, StringComparer.CurrentCultureIgnoreCase }, + new object[] { StringComparison.InvariantCulture, StringComparer.InvariantCulture }, + new object[] { StringComparison.InvariantCultureIgnoreCase, StringComparer.InvariantCultureIgnoreCase }, + new object[] { StringComparison.Ordinal, StringComparer.Ordinal }, + new object[] { StringComparison.OrdinalIgnoreCase, StringComparer.OrdinalIgnoreCase }, + }; + + [Theory] + [MemberData(nameof(FromComparison_TestData))] + public static void FromComparisonTest(StringComparison comparison, StringComparer comparer) + { + Assert.Equal(comparer, StringComparer.FromComparison(comparison)); + } + + [Fact] + public static void FromComparisonInvalidTest() + { + StringComparison minInvalid = Enum.GetValues(typeof(StringComparison)).Cast().Min() - 1; + StringComparison maxInvalid = Enum.GetValues(typeof(StringComparison)).Cast().Max() + 1; + + Assert.Throws(() => StringComparer.FromComparison(minInvalid)); + Assert.Throws(() => StringComparer.FromComparison(maxInvalid)); + } + } +} diff --git a/src/System.Runtime.Extensions/tests/System/StringComparer.netstandard1.7.cs b/src/System.Runtime.Extensions/tests/System/StringComparer.netstandard1.7.cs index ba9fece11d56..d01fd232765d 100644 --- a/src/System.Runtime.Extensions/tests/System/StringComparer.netstandard1.7.cs +++ b/src/System.Runtime.Extensions/tests/System/StringComparer.netstandard1.7.cs @@ -8,7 +8,7 @@ namespace System.Tests { - public static class MiscStringComparerTests + public static partial class MiscStringComparerTests { public static IEnumerable UpperLowerCasing_TestData() {