Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/corert.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarek Safar <marek.safar@gmail.com>2018-03-05 19:14:33 +0300
committerMarek Safar <marek.safar@gmail.com>2018-03-05 19:14:33 +0300
commit61a8cb699635edabaac72b93e087d32714c1bf70 (patch)
treed24d5e9c9915fd43af007375c9c03d3955df0a6f
parentb2264e18523274aa956c55c219729d3e43d3c93c (diff)
Mono tweaks for String class support
-rw-r--r--src/System.Private.CoreLib/shared/System/Collections/Generic/ValueListBuilder.cs2
-rw-r--r--src/System.Private.CoreLib/shared/System/String.Manipulation.cs22
-rw-r--r--src/System.Private.CoreLib/src/System/String.cs6
3 files changed, 24 insertions, 6 deletions
diff --git a/src/System.Private.CoreLib/shared/System/Collections/Generic/ValueListBuilder.cs b/src/System.Private.CoreLib/shared/System/Collections/Generic/ValueListBuilder.cs
index 72da4a9e1..5fbeeec9c 100644
--- a/src/System.Private.CoreLib/shared/System/Collections/Generic/ValueListBuilder.cs
+++ b/src/System.Private.CoreLib/shared/System/Collections/Generic/ValueListBuilder.cs
@@ -3,7 +3,7 @@
// See the LICENSE file in the project root for more information.
using System.Buffers;
-using System.Diagnostics;
+using System.Diagnostics.Private;
using System.Runtime.CompilerServices;
namespace System.Collections.Generic
diff --git a/src/System.Private.CoreLib/shared/System/String.Manipulation.cs b/src/System.Private.CoreLib/shared/System/String.Manipulation.cs
index 76cbfaa8d..94f34b582 100644
--- a/src/System.Private.CoreLib/shared/System/String.Manipulation.cs
+++ b/src/System.Private.CoreLib/shared/System/String.Manipulation.cs
@@ -4,7 +4,7 @@
using System.Buffers;
using System.Collections.Generic;
-using System.Diagnostics;
+using System.Diagnostics.Private;
using System.Globalization;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
@@ -1123,7 +1123,11 @@ namespace System
throw new OutOfMemoryException();
string dst = FastAllocateString((int)dstLength);
+#if FEATURE_PORTABLE_SPAN
+ Span<char> dstSpan = new Span<char>(Unsafe.As<Pinnable<char>>(dst), MemoryExtensions.StringAdjustment, dst.Length);
+#else
Span<char> dstSpan = new Span<char>(ref dst.GetRawStringData(), dst.Length);
+#endif
int thisIdx = 0;
int dstIdx = 0;
@@ -1155,12 +1159,24 @@ namespace System
public string[] Split(char separator, StringSplitOptions options = StringSplitOptions.None)
{
- return SplitInternal(new ReadOnlySpan<char>(ref separator, 1), int.MaxValue, options);
+#if FEATURE_PORTABLE_SPAN
+ var srcSpan = new ReadOnlySpan<char>(Unsafe.As<Pinnable<char>>(separator), IntPtr.Zero, 1);
+#else
+ var srcSpan = new ReadOnlySpan<char>(ref separator, 1)
+#endif
+
+ return SplitInternal(srcSpan, int.MaxValue, options);
}
public string[] Split(char separator, int count, StringSplitOptions options = StringSplitOptions.None)
{
- return SplitInternal(new ReadOnlySpan<char>(ref separator, 1), count, options);
+#if FEATURE_PORTABLE_SPAN
+ var srcSpan = new ReadOnlySpan<char>(Unsafe.As<Pinnable<char>>(separator), IntPtr.Zero, 1);
+#else
+ var srcSpan = new ReadOnlySpan<char>(ref separator, 1)
+#endif
+
+ return SplitInternal(srcSpan, count, options);
}
// Creates an array of strings by splitting this string at each
diff --git a/src/System.Private.CoreLib/src/System/String.cs b/src/System.Private.CoreLib/src/System/String.cs
index 6c0f7532b..4ef655fbb 100644
--- a/src/System.Private.CoreLib/src/System/String.cs
+++ b/src/System.Private.CoreLib/src/System/String.cs
@@ -12,7 +12,7 @@
using System.Buffers;
using System.Collections;
using System.Collections.Generic;
-using System.Diagnostics;
+using System.Diagnostics.Private;
using System.Globalization;
using System.Runtime;
using System.Runtime.CompilerServices;
@@ -264,7 +264,7 @@ namespace System
if (numBytes == 0)
return string.Empty;
-#if PLATFORM_UNIX
+#if PLATFORM_UNIX || MONO
return Encoding.UTF8.GetString(pb, numBytes);
#else
int numCharsRequired = Interop.Kernel32.MultiByteToWideChar(Interop.Kernel32.CP_ACP, Interop.Kernel32.MB_PRECOMPOSED, pb, numBytes, (char*)null, 0);
@@ -386,6 +386,7 @@ namespace System
return result;
}
+#if !MONO // TODO: Undo
public static string Create<TState>(int length, TState state, SpanAction<char, TState> action)
{
if (action == null)
@@ -410,6 +411,7 @@ namespace System
public static implicit operator ReadOnlySpan<char>(string value) =>
value != null ? new ReadOnlySpan<char>(ref value.GetRawStringData(), value.Length) : default;
+#endif
public object Clone()
{