diff options
author | Jan Kotas <jkotas@microsoft.com> | 2018-03-20 03:53:06 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-20 03:53:06 -0700 |
commit | ff2abe597b602c5228bae66c9f3f581a632ff4fb (patch) | |
tree | 50b02420e8510ab41a7dcff230ca91c98e79bc4d /src | |
parent | 101df105c3b94860d76b100dea1308a3ff371b11 (diff) | |
download | coreclr-ff2abe597b602c5228bae66c9f3f581a632ff4fb.tar.gz coreclr-ff2abe597b602c5228bae66c9f3f581a632ff4fb.tar.bz2 coreclr-ff2abe597b602c5228bae66c9f3f581a632ff4fb.zip |
Move CompareInfo.* to shared CoreLib partition (#17062)
Diffstat (limited to 'src')
-rw-r--r-- | src/mscorlib/System.Private.CoreLib.csproj | 2 | ||||
-rw-r--r-- | src/mscorlib/shared/System.Private.CoreLib.Shared.projitems | 2 | ||||
-rw-r--r-- | src/mscorlib/shared/System/Globalization/CompareInfo.Unix.cs (renamed from src/mscorlib/src/System/Globalization/CompareInfo.Unix.cs) | 10 | ||||
-rw-r--r-- | src/mscorlib/shared/System/Globalization/CompareInfo.Windows.cs (renamed from src/mscorlib/src/System/Globalization/CompareInfo.Windows.cs) | 14 |
4 files changed, 16 insertions, 12 deletions
diff --git a/src/mscorlib/System.Private.CoreLib.csproj b/src/mscorlib/System.Private.CoreLib.csproj index 038f09fc68..27e5702d31 100644 --- a/src/mscorlib/System.Private.CoreLib.csproj +++ b/src/mscorlib/System.Private.CoreLib.csproj @@ -590,7 +590,6 @@ </ItemGroup> <ItemGroup Condition="'$(TargetsUnix)' == 'true'"> <Compile Include="$(BclSourcesRoot)\Interop\Unix\Interop.Libraries.cs" /> - <Compile Include="$(BclSourcesRoot)\System\Globalization\CompareInfo.Unix.cs" /> <Compile Include="$(BclSourcesRoot)\System\Globalization\CultureInfo.Unix.cs" /> <Compile Include="$(BclSourcesRoot)\System\Globalization\GlobalizationMode.Unix.cs" /> <Compile Include="$(BclSourcesRoot)\System\Runtime\Versioning\CompatibilitySwitch.cs" /> @@ -599,7 +598,6 @@ <ItemGroup Condition="'$(TargetsWindows)' == 'true'"> <Compile Include="$(BclSourcesRoot)\Interop\Windows\Kernel32\Interop.GetSystemDirectoryW.cs" /> <Compile Include="$(BclSourcesRoot)\System\Diagnostics\Debug.Windows.cs" /> - <Compile Include="$(BclSourcesRoot)\System\Globalization\CompareInfo.Windows.cs" /> <Compile Include="$(BclSourcesRoot)\System\Globalization\CultureInfo.Windows.cs" /> <Compile Include="$(BclSourcesRoot)\System\Globalization\GlobalizationMode.Windows.cs" /> <Compile Include="$(BclSourcesRoot)\System\Threading\ClrThreadPoolBoundHandle.Windows.cs" /> diff --git a/src/mscorlib/shared/System.Private.CoreLib.Shared.projitems b/src/mscorlib/shared/System.Private.CoreLib.Shared.projitems index c18c944d44..2bc6464e97 100644 --- a/src/mscorlib/shared/System.Private.CoreLib.Shared.projitems +++ b/src/mscorlib/shared/System.Private.CoreLib.Shared.projitems @@ -711,6 +711,7 @@ <Compile Include="$(MSBuildThisFileDirectory)Microsoft\Win32\SafeHandles\SafeFileHandle.Windows.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Microsoft\Win32\SafeHandles\SafeFindHandle.Windows.cs" /> <Compile Include="$(MSBuildThisFileDirectory)System\Globalization\CalendarData.Windows.cs" Condition="'$(EnableDummyGlobalizationImplementation)' != 'true'" /> + <Compile Include="$(MSBuildThisFileDirectory)System\Globalization\CompareInfo.Windows.cs" Condition="'$(EnableDummyGlobalizationImplementation)' != 'true'" /> <Compile Include="$(MSBuildThisFileDirectory)System\Globalization\CultureData.Windows.cs" Condition="'$(EnableDummyGlobalizationImplementation)' != 'true'" /> <Compile Include="$(MSBuildThisFileDirectory)System\Globalization\HijriCalendar.Win32.cs" Condition="'$(EnableWinRT)' != 'true' and '$(EnableDummyGlobalizationImplementation)' != 'true'" /> <Compile Include="$(MSBuildThisFileDirectory)System\Globalization\HijriCalendar.WinRT.cs" Condition="'$(EnableWinRT)' == 'true'" /> @@ -792,6 +793,7 @@ <Compile Include="$(MSBuildThisFileDirectory)Microsoft\Win32\SafeHandles\SafeFileHandle.Unix.cs" /> <Compile Include="$(MSBuildThisFileDirectory)System\Diagnostics\Debug.Unix.cs" /> <Compile Include="$(MSBuildThisFileDirectory)System\Globalization\CalendarData.Unix.cs" Condition="'$(EnableDummyGlobalizationImplementation)' != 'true'" /> + <Compile Include="$(MSBuildThisFileDirectory)System\Globalization\CompareInfo.Unix.cs" Condition="'$(EnableDummyGlobalizationImplementation)' != 'true'" /> <Compile Include="$(MSBuildThisFileDirectory)System\Globalization\CultureData.Unix.cs" Condition="'$(EnableDummyGlobalizationImplementation)' != 'true'" /> <Compile Include="$(MSBuildThisFileDirectory)System\Globalization\HijriCalendar.Unix.cs" Condition="'$(EnableDummyGlobalizationImplementation)' != 'true'" /> <Compile Include="$(MSBuildThisFileDirectory)System\Globalization\IdnMapping.Unix.cs" Condition="'$(EnableDummyGlobalizationImplementation)' != 'true'" /> diff --git a/src/mscorlib/src/System/Globalization/CompareInfo.Unix.cs b/src/mscorlib/shared/System/Globalization/CompareInfo.Unix.cs index fe4c55c6c8..bfe1f6918d 100644 --- a/src/mscorlib/src/System/Globalization/CompareInfo.Unix.cs +++ b/src/mscorlib/shared/System/Globalization/CompareInfo.Unix.cs @@ -241,6 +241,7 @@ namespace System.Globalization return index; } +#if CORECLR if (_isAsciiEqualityOrdinal && CanUseAsciiOrdinalForOptions(options) && source.IsFastSort() && target.IsFastSort()) { index = IndexOf(source, target, startIndex, count, GetOrdinalCompareOptions(options)); @@ -251,6 +252,7 @@ namespace System.Globalization } return index; } +#endif fixed (char* pSource = source) { @@ -431,10 +433,12 @@ namespace System.Globalization return LastIndexOfOrdinalCore(source, target, startIndex, count, ignoreCase: false); } +#if CORECLR if (_isAsciiEqualityOrdinal && CanUseAsciiOrdinalForOptions(options) && source.IsFastSort() && target.IsFastSort()) { return LastIndexOf(source, target, startIndex, count, GetOrdinalCompareOptions(options)); } +#endif // startIndex is the index into source where we start search backwards from. leftStartIndex is the index into source // of the start of the string that is count characters away from startIndex. @@ -456,10 +460,12 @@ namespace System.Globalization Debug.Assert(!string.IsNullOrEmpty(prefix)); Debug.Assert((options & (CompareOptions.Ordinal | CompareOptions.OrdinalIgnoreCase)) == 0); +#if CORECLR if (_isAsciiEqualityOrdinal && CanUseAsciiOrdinalForOptions(options) && source.IsFastSort() && prefix.IsFastSort()) { return IsPrefix(source, prefix, GetOrdinalCompareOptions(options)); } +#endif return Interop.Globalization.StartsWith(_sortHandle, prefix, prefix.Length, source, source.Length, options); } @@ -587,10 +593,12 @@ namespace System.Globalization Debug.Assert(!string.IsNullOrEmpty(suffix)); Debug.Assert((options & (CompareOptions.Ordinal | CompareOptions.OrdinalIgnoreCase)) == 0); +#if CORECLR if (_isAsciiEqualityOrdinal && CanUseAsciiOrdinalForOptions(options) && source.IsFastSort() && suffix.IsFastSort()) { return IsSuffix(source, suffix, GetOrdinalCompareOptions(options)); } +#endif return Interop.Globalization.EndsWith(_sortHandle, suffix, suffix.Length, source, source.Length, options); } @@ -602,7 +610,7 @@ namespace System.Globalization Debug.Assert(!source.IsEmpty); Debug.Assert(!suffix.IsEmpty); Debug.Assert((options & (CompareOptions.Ordinal | CompareOptions.OrdinalIgnoreCase)) == 0); - + if (_isAsciiEqualityOrdinal && CanUseAsciiOrdinalForOptions(options)) { if (source.Length < suffix.Length) diff --git a/src/mscorlib/src/System/Globalization/CompareInfo.Windows.cs b/src/mscorlib/shared/System/Globalization/CompareInfo.Windows.cs index df62d7b0b0..edc7b03bf2 100644 --- a/src/mscorlib/src/System/Globalization/CompareInfo.Windows.cs +++ b/src/mscorlib/shared/System/Globalization/CompareInfo.Windows.cs @@ -16,9 +16,6 @@ namespace System.Globalization { _sortName = culture.SortName; - m_name = culture._name; - _sortName = culture.SortName; - if (_invariantMode) { _sortHandle = IntPtr.Zero; @@ -26,6 +23,7 @@ namespace System.Globalization else { const uint LCMAP_SORTHANDLE = 0x20000000; + IntPtr handle; int ret = Interop.Kernel32.LCMapStringEx(_sortName, LCMAP_SORTHANDLE, null, 0, &handle, IntPtr.Size, null, null, IntPtr.Zero); _sortHandle = ret > 0 ? handle : IntPtr.Zero; @@ -200,7 +198,7 @@ namespace System.Globalization if (result == 0) { - Environment.FailFast("CompareStringEx failed"); + throw new ArgumentException(SR.Arg_ExternalException); } // Map CompareStringEx return value to -1, 0, 1. @@ -232,7 +230,7 @@ namespace System.Globalization if (result == 0) { - Environment.FailFast("CompareStringEx failed"); + throw new ArgumentException(SR.Arg_ExternalException); } // Map CompareStringEx return value to -1, 0, 1. @@ -366,10 +364,8 @@ namespace System.Globalization Debug.Assert(target != null); Debug.Assert((options & CompareOptions.OrdinalIgnoreCase) == 0); - // TODO: Consider moving this up to the relevent APIs we need to ensure this behavior for - // and add a precondition that target is not empty. if (target.Length == 0) - return startIndex; // keep Whidbey compatibility + return startIndex; if ((options & CompareOptions.Ordinal) != 0) { @@ -623,7 +619,7 @@ namespace System.Globalization Debug.Assert(!_invariantMode); Interop.Kernel32.NlsVersionInfoEx nlsVersion = new Interop.Kernel32.NlsVersionInfoEx(); - nlsVersion.dwNLSVersionInfoSize = Marshal.SizeOf(typeof(Interop.Kernel32.NlsVersionInfoEx)); + nlsVersion.dwNLSVersionInfoSize = sizeof(Interop.Kernel32.NlsVersionInfoEx); Interop.Kernel32.GetNLSVersionEx(Interop.Kernel32.COMPARE_STRING, _sortName, &nlsVersion); return new SortVersion( nlsVersion.dwNLSVersion, |