diff --git a/external/corefx b/external/corefx index 5b7f7dac2681e..d0516130e913a 160000 --- a/external/corefx +++ b/external/corefx @@ -1 +1 @@ -Subproject commit 5b7f7dac2681eed16bfa79de13f87c691a721faa +Subproject commit d0516130e913a7cc37268f08884520a896780840 diff --git a/mcs/class/corlib/ReferenceSources/String.cs b/mcs/class/corlib/ReferenceSources/String.cs index 6d8866a058ab4..d60eb32c15b28 100644 --- a/mcs/class/corlib/ReferenceSources/String.cs +++ b/mcs/class/corlib/ReferenceSources/String.cs @@ -59,6 +59,8 @@ partial class String public static readonly String Empty; + public int Length => _stringLength; + internal unsafe int IndexOfUnchecked (string value, int startIndex, int count) { int valueLen = value.Length; diff --git a/mcs/class/corlib/Test/System/StringTest.cs b/mcs/class/corlib/Test/System/StringTest.cs index 0be02f7a0bafa..29cd9e998c436 100644 --- a/mcs/class/corlib/Test/System/StringTest.cs +++ b/mcs/class/corlib/Test/System/StringTest.cs @@ -348,15 +348,7 @@ public unsafe void Constructor7_Value_Invalid () [Test] // ctor (SByte*, Int32, Int32) public unsafe void Constructor7_Value_Null () { - try { - new String ((sbyte*) null, 0, 0); - Assert.Fail ("#A1"); - } catch (ArgumentNullException ex) { - Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#A2"); - Assert.IsNull (ex.InnerException, "#A3"); - Assert.IsNotNull (ex.Message, "#A4"); - Assert.AreEqual ("value", ex.ParamName, "#A5"); - } + Assert.AreEqual (string.Empty, new String ((sbyte*) null, 0, 0)); try { new String ((sbyte*) null, 0, 1); @@ -368,15 +360,7 @@ public unsafe void Constructor7_Value_Null () Assert.AreEqual ("value", ex.ParamName, "#B5"); } - try { - new String ((sbyte*) null, 1, 0); - Assert.Fail ("#C1"); - } catch (ArgumentNullException ex) { - Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#C2"); - Assert.IsNull (ex.InnerException, "#C3"); - Assert.IsNotNull (ex.Message, "#C4"); - Assert.AreEqual ("value", ex.ParamName, "#C5"); - } + Assert.AreEqual (string.Empty, new String ((sbyte*) null, 1, 0)); } [Test] // ctor (SByte*, Int32, Int32, Encoding) @@ -511,15 +495,7 @@ public unsafe void Constructor8_Value_Invalid2 () [Test] // ctor (SByte*, Int32, Int32, Encoding) public unsafe void Constructor8_Value_Null () { - try { - new String ((sbyte*) null, 0, 0, null); - Assert.Fail ("#A1"); - } catch (ArgumentNullException ex) { - Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#A2"); - Assert.IsNull (ex.InnerException, "#A3"); - Assert.IsNotNull (ex.Message, "#A4"); - Assert.AreEqual ("value", ex.ParamName, "#A5"); - } + Assert.AreEqual (string.Empty, new String ((sbyte*) null, 0, 0, null)); try { new String ((sbyte*) null, 0, 1, null); @@ -531,15 +507,7 @@ public unsafe void Constructor8_Value_Null () Assert.AreEqual ("value", ex.ParamName, "#B5"); } - try { - new String ((sbyte*) null, 1, 0, null); - Assert.Fail ("#C1"); - } catch (ArgumentNullException ex) { - Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#C2"); - Assert.IsNull (ex.InnerException, "#C3"); - Assert.IsNotNull (ex.Message, "#C4"); - Assert.AreEqual ("value", ex.ParamName, "#C5"); - } + Assert.AreEqual (string.Empty, new String ((sbyte*) null, 1, 0, null)); Assert.AreEqual (String.Empty, new String ((sbyte*) null, 0, 0, Encoding.Default), "#D"); diff --git a/mcs/class/corlib/corefx/SR.missing.cs b/mcs/class/corlib/corefx/SR.missing.cs new file mode 100644 index 0000000000000..48f135a61166d --- /dev/null +++ b/mcs/class/corlib/corefx/SR.missing.cs @@ -0,0 +1,4 @@ +partial class SR +{ + public const string Arg_MustBeNullTerminatedString = "The string must be null-terminated."; +} \ No newline at end of file diff --git a/mcs/class/corlib/corlib.dll.sources b/mcs/class/corlib/corlib.dll.sources index be074c8f2df1e..f5752ffc4207b 100644 --- a/mcs/class/corlib/corlib.dll.sources +++ b/mcs/class/corlib/corlib.dll.sources @@ -891,7 +891,6 @@ ReferenceSources/Type.cs ../referencesource/mscorlib/system/_localdatastore.cs ../referencesource/mscorlib/system/_localdatastoremgr.cs ../referencesource/mscorlib/system/accessviolationexception.cs -../referencesource/mscorlib/system/action.cs ../referencesource/mscorlib/system/activator.cs ../referencesource/mscorlib/system/AggregateException.cs ../referencesource/mscorlib/system/appdomainattributes.cs @@ -1540,6 +1539,7 @@ coreclr/SorterArray.cs corefx/AwaitTaskContinuation.cs corefx/SynchronizationContext.cs corefx/SR.cs +corefx/SR.missing.cs corefx/CompareInfo.cs corefx/GlobalizationMode.cs corefx/Interop.GetRandomBytes.Mono.cs @@ -1570,8 +1570,6 @@ corert/RuntimeAugments.cs ../../../external/corert/src/System.Private.CoreLib/src/System/Array.cs ../../../external/corert/src/System.Private.CoreLib/src/System/ByReference.cs # TODO: Should all come from shared -../../../external/corert/src/System.Private.CoreLib/src/System/String.cs - ../../../external/corert/src/System.Private.CoreLib/src/System/Collections/Generic/ArraySortHelper.cs ../../../external/corert/src/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.cs @@ -1608,6 +1606,7 @@ corert/RuntimeAugments.cs ../../../external/corefx/src/System.ObjectModel/src/System/Collections/ObjectModel/KeyedCollection.cs ../../../external/corefx/src/System.ObjectModel/src/System/Collections/ObjectModel/ReadOnlyDictionary.cs +../../../external/corefx/src/Common/src/CoreLib/System/Action.cs ../../../external/corefx/src/Common/src/CoreLib/System/ArraySegment.cs ../../../external/corefx/src/Common/src/CoreLib/System/Gen2GcCallback.cs ../../../external/corefx/src/Common/src/CoreLib/System/HashCode.cs @@ -1628,6 +1627,7 @@ corert/RuntimeAugments.cs ../../../external/corefx/src/Common/src/CoreLib/System/SpanHelpers.BinarySearch.cs ../../../external/corefx/src/Common/src/CoreLib/System/SpanHelpers.Byte.cs ../../../external/corefx/src/Common/src/CoreLib/System/SpanHelpers.T.cs +../../../external/corefx/src/Common/src/CoreLib/System/String.cs ../../../external/corefx/src/Common/src/CoreLib/System/String.Comparison.cs ../../../external/corefx/src/Common/src/CoreLib/System/String.Manipulation.cs ../../../external/corefx/src/Common/src/CoreLib/System/String.Searching.cs diff --git a/mcs/class/referencesource/mscorlib/system/text/encoding.cs b/mcs/class/referencesource/mscorlib/system/text/encoding.cs index 07966c5248c06..a25c75a88c3c3 100644 --- a/mcs/class/referencesource/mscorlib/system/text/encoding.cs +++ b/mcs/class/referencesource/mscorlib/system/text/encoding.cs @@ -1370,8 +1370,8 @@ public unsafe string GetString(byte* bytes, int byteCount) #if MONO public virtual unsafe int GetChars(ReadOnlySpan bytes, Span chars) { - fixed (byte* bytesPtr = &System.Runtime.InteropServices.MemoryMarshal.GetReference(bytes)) - fixed (char* charsPtr = &System.Runtime.InteropServices.MemoryMarshal.GetReference(chars)) + fixed (byte* bytesPtr = &System.Runtime.InteropServices.MemoryMarshal.GetNonNullPinnableReference(bytes)) + fixed (char* charsPtr = &System.Runtime.InteropServices.MemoryMarshal.GetNonNullPinnableReference(chars)) { return GetChars(bytesPtr, bytes.Length, charsPtr, chars.Length); } @@ -1379,7 +1379,7 @@ public virtual unsafe int GetChars(ReadOnlySpan bytes, Span chars) public unsafe string GetString(ReadOnlySpan bytes) { - fixed (byte* bytesPtr = &bytes.GetPinnableReference()) + fixed (byte* bytesPtr = &System.Runtime.InteropServices.MemoryMarshal.GetNonNullPinnableReference(bytes)) { return GetString(bytesPtr, bytes.Length); }