From c853b030a2701b39cb098ea1facfd8721bba1cf1 Mon Sep 17 00:00:00 2001 From: Jan Kotas Date: Fri, 5 May 2017 20:48:28 -0700 Subject: [PATCH] Delete moved files and fix build breaks Signed-off-by: dotnet-bot --- .../Interop.Collation.cs | 69 ++++++++++++++++++++++ .../shared/System.Private.CoreLib.Shared.projitems | 1 + .../shared/System/Globalization/IdnMapping.Unix.cs | 4 +- .../System/Globalization/NumberFormatInfo.cs | 24 ++++---- .../shared/System/Globalization/StringInfo.cs | 10 ++-- 5 files changed, 89 insertions(+), 19 deletions(-) create mode 100644 src/mscorlib/shared/Interop/Unix/System.Globalization.Native/Interop.Collation.cs diff --git a/src/mscorlib/shared/Interop/Unix/System.Globalization.Native/Interop.Collation.cs b/src/mscorlib/shared/Interop/Unix/System.Globalization.Native/Interop.Collation.cs new file mode 100644 index 0000000..79aedd7 --- /dev/null +++ b/src/mscorlib/shared/Interop/Unix/System.Globalization.Native/Interop.Collation.cs @@ -0,0 +1,69 @@ +// 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; +using System.Globalization; +using System.Runtime.InteropServices; +using System.Security; + +internal static partial class Interop +{ + internal static partial class GlobalizationInterop + { + [DllImport(Libraries.GlobalizationInterop, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_GetSortHandle")] + internal unsafe static extern ResultCode GetSortHandle(byte[] localeName, out SafeSortHandle sortHandle); + + [DllImport(Libraries.GlobalizationInterop, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_CloseSortHandle")] + internal unsafe static extern void CloseSortHandle(IntPtr handle); + + [DllImport(Libraries.GlobalizationInterop, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_CompareString")] + internal unsafe static extern int CompareString(SafeSortHandle sortHandle, char* lpStr1, int cwStr1Len, char* lpStr2, int cwStr2Len, CompareOptions options); + + [DllImport(Libraries.GlobalizationInterop, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_IndexOf")] + internal unsafe static extern int IndexOf(SafeSortHandle sortHandle, string target, int cwTargetLength, char* pSource, int cwSourceLength, CompareOptions options, int* matchLengthPtr); + + [DllImport(Libraries.GlobalizationInterop, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_LastIndexOf")] + internal unsafe static extern int LastIndexOf(SafeSortHandle sortHandle, string target, int cwTargetLength, char* pSource, int cwSourceLength, CompareOptions options); + + [DllImport(Libraries.GlobalizationInterop, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_IndexOfOrdinalIgnoreCase")] + internal unsafe static extern int IndexOfOrdinalIgnoreCase(string target, int cwTargetLength, char* pSource, int cwSourceLength, bool findLast); + + [DllImport(Libraries.GlobalizationInterop, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_StartsWith")] + [return: MarshalAs(UnmanagedType.Bool)] + internal unsafe static extern bool StartsWith(SafeSortHandle sortHandle, string target, int cwTargetLength, string source, int cwSourceLength, CompareOptions options); + + [DllImport(Libraries.GlobalizationInterop, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_EndsWith")] + [return: MarshalAs(UnmanagedType.Bool)] + internal unsafe static extern bool EndsWith(SafeSortHandle sortHandle, string target, int cwTargetLength, string source, int cwSourceLength, CompareOptions options); + + [DllImport(Libraries.GlobalizationInterop, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_GetSortKey")] + internal unsafe static extern int GetSortKey(SafeSortHandle sortHandle, string str, int strLength, byte* sortKey, int sortKeyLength, CompareOptions options); + + [DllImport(Libraries.GlobalizationInterop, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_CompareStringOrdinalIgnoreCase")] + internal unsafe static extern int CompareStringOrdinalIgnoreCase(char* lpStr1, int cwStr1Len, char* lpStr2, int cwStr2Len); + + [DllImport(Libraries.GlobalizationInterop, EntryPoint = "GlobalizationNative_GetSortVersion")] + internal static extern int GetSortVersion(); + + internal class SafeSortHandle : SafeHandle + { + private SafeSortHandle() : + base(IntPtr.Zero, true) + { + } + + public override bool IsInvalid + { + get { return handle == IntPtr.Zero; } + } + + protected override bool ReleaseHandle() + { + CloseSortHandle(handle); + SetHandle(IntPtr.Zero); + return true; + } + } + } +} diff --git a/src/mscorlib/shared/System.Private.CoreLib.Shared.projitems b/src/mscorlib/shared/System.Private.CoreLib.Shared.projitems index 9b78005..3e00140 100644 --- a/src/mscorlib/shared/System.Private.CoreLib.Shared.projitems +++ b/src/mscorlib/shared/System.Private.CoreLib.Shared.projitems @@ -520,6 +520,7 @@ + diff --git a/src/mscorlib/shared/System/Globalization/IdnMapping.Unix.cs b/src/mscorlib/shared/System/Globalization/IdnMapping.Unix.cs index f1ad6f1..2bbda0d 100644 --- a/src/mscorlib/shared/System/Globalization/IdnMapping.Unix.cs +++ b/src/mscorlib/shared/System/Globalization/IdnMapping.Unix.cs @@ -39,7 +39,7 @@ namespace System.Globalization } char[] outputHeap = new char[actualLength]; - fixed (char* pOutputHeap = outputHeap) + fixed (char* pOutputHeap = &outputHeap[0]) { actualLength = Interop.GlobalizationInterop.ToAscii(flags, unicode, count, pOutputHeap, actualLength); if (actualLength == 0 || actualLength > outputHeap.Length) @@ -66,7 +66,7 @@ namespace System.Globalization else { char[] output = new char[count]; - fixed (char* pOutput = output) + fixed (char* pOutput = &output[0]) { return GetUnicodeCore(ascii, count, flags, pOutput, count, reattempt: true); } diff --git a/src/mscorlib/shared/System/Globalization/NumberFormatInfo.cs b/src/mscorlib/shared/System/Globalization/NumberFormatInfo.cs index c44c085..179a7f6 100644 --- a/src/mscorlib/shared/System/Globalization/NumberFormatInfo.cs +++ b/src/mscorlib/shared/System/Globalization/NumberFormatInfo.cs @@ -84,7 +84,7 @@ namespace System.Globalization internal int percentDecimalDigits = 2; [OptionalField(VersionAdded = 2)] - internal int digitSubstitution = (int) DigitShapes.None; + internal int digitSubstitution = (int)DigitShapes.None; internal bool isReadOnly = false; @@ -131,7 +131,7 @@ namespace System.Globalization Contract.EndContractBlock(); } - private static void VerifyNativeDigits(string [] nativeDig, string propertyName) + private static void VerifyNativeDigits(string[] nativeDig, string propertyName) { if (nativeDig == null) { @@ -157,7 +157,7 @@ namespace System.Globalization { // Not 1 or 2 UTF-16 code points throw new ArgumentException(SR.Argument_InvalidNativeDigitValue, propertyName); - } + } else if (!char.IsSurrogatePair(nativeDig[i][0], nativeDig[i][1])) { // 2 UTF-6 code points, but not a surrogate pair @@ -175,8 +175,8 @@ namespace System.Globalization } } - private static void VerifyDigitSubstitution(DigitShapes digitSub, string propertyName) - { + private static void VerifyDigitSubstitution(DigitShapes digitSub, string propertyName) + { switch (digitSub) { case DigitShapes.Context: @@ -309,7 +309,7 @@ namespace System.Globalization set { VerifyWritable(); - VerifyDecimalSeparator(value, "CurrencyDecimalSeparator"); + VerifyDecimalSeparator(value, nameof(CurrencyDecimalSeparator)); currencyDecimalSeparator = value; } } @@ -404,13 +404,13 @@ namespace System.Globalization { if (value == null) { - throw new ArgumentNullException("PercentGroupSizes", + throw new ArgumentNullException(nameof(PercentGroupSizes), SR.ArgumentNull_Obj); } Contract.EndContractBlock(); VerifyWritable(); Int32[] inputSizes = (Int32[])value.Clone(); - CheckGroupSize("PercentGroupSizes", inputSizes); + CheckGroupSize(nameof(PercentGroupSizes), inputSizes); percentGroupSizes = inputSizes; } } @@ -807,9 +807,9 @@ namespace System.Globalization } } - public string [] NativeDigits + public string[] NativeDigits { - get { return (String[]) nativeDigits.Clone(); } + get { return (String[])nativeDigits.Clone(); } set { VerifyWritable(); @@ -820,12 +820,12 @@ namespace System.Globalization public DigitShapes DigitSubstitution { - get { return (DigitShapes) digitSubstitution; } + get { return (DigitShapes)digitSubstitution; } set { VerifyWritable(); VerifyDigitSubstitution(value, nameof(DigitSubstitution)); - digitSubstitution = (int) value; + digitSubstitution = (int)value; } } diff --git a/src/mscorlib/shared/System/Globalization/StringInfo.cs b/src/mscorlib/shared/System/Globalization/StringInfo.cs index f1dd305..ca57b67 100644 --- a/src/mscorlib/shared/System/Globalization/StringInfo.cs +++ b/src/mscorlib/shared/System/Globalization/StringInfo.cs @@ -93,7 +93,7 @@ namespace System.Globalization { if (null == value) { - throw new ArgumentNullException("String", + throw new ArgumentNullException(nameof(String), SR.ArgumentNull_String); } Contract.EndContractBlock(); @@ -117,13 +117,13 @@ namespace System.Globalization } } - public string SubstringByTextElements(int startingTextElement) + public string SubstringByTextElements(int startingTextElement) { // If the string is empty, no sense going further. - if (null == this.Indexes) + if (null == this.Indexes) { // Just decide which error to give depending on the param they gave us.... - if (startingTextElement < 0) + if (startingTextElement < 0) { throw new ArgumentOutOfRangeException(nameof(startingTextElement), SR.ArgumentOutOfRange_NeedPosNum); } @@ -135,7 +135,7 @@ namespace System.Globalization return (SubstringByTextElements(startingTextElement, Indexes.Length - startingTextElement)); } - public string SubstringByTextElements(int startingTextElement, int lengthInTextElements) + public string SubstringByTextElements(int startingTextElement, int lengthInTextElements) { if (startingTextElement < 0) { -- 2.7.4