From 22f1bc00d018a49f9550ee3b564f5f7737960b0d Mon Sep 17 00:00:00 2001 From: Jan Kotas Date: Thu, 22 Feb 2018 18:49:03 -0800 Subject: [PATCH] AsReadOnlySpan -> AsSpan rename to fix build breaks --- src/mscorlib/shared/System/Boolean.cs | 10 +++++----- .../System/Collections/Generic/ValueListBuilder.cs | 2 +- src/mscorlib/shared/System/Convert.cs | 18 +++++++++--------- .../shared/System/Globalization/CompareInfo.cs | 16 ++++++++-------- .../shared/System/Globalization/DateTimeParse.cs | 4 ++-- .../System/Globalization/HijriCalendar.Win32.cs | 2 +- .../System/Globalization/JapaneseCalendar.Win32.cs | 2 +- src/mscorlib/shared/System/IO/Path.Unix.cs | 4 ++-- src/mscorlib/shared/System/IO/Path.Windows.cs | 10 +++++----- src/mscorlib/shared/System/IO/Path.cs | 22 +++++++++++----------- src/mscorlib/shared/System/IO/StreamWriter.cs | 4 ++-- src/mscorlib/shared/System/Number.Formatting.cs | 2 +- src/mscorlib/shared/System/Span.NonGeneric.cs | 11 ++++++++--- src/mscorlib/shared/System/String.Manipulation.cs | 16 ++++++++-------- src/mscorlib/shared/System/StringSpanHelpers.cs | 2 +- src/mscorlib/shared/System/Text/StringBuilder.cs | 2 +- src/mscorlib/shared/System/TimeZoneInfo.Unix.cs | 6 +++--- src/mscorlib/shared/System/Version.cs | 4 ++-- 18 files changed, 71 insertions(+), 66 deletions(-) diff --git a/src/mscorlib/shared/System/Boolean.cs b/src/mscorlib/shared/System/Boolean.cs index c1f4bc9..fd56082 100644 --- a/src/mscorlib/shared/System/Boolean.cs +++ b/src/mscorlib/shared/System/Boolean.cs @@ -100,7 +100,7 @@ namespace System { string s = m_value ? TrueLiteral : FalseLiteral; - if (s.AsReadOnlySpan().TryCopyTo(destination)) + if (s.AsSpan().TryCopyTo(destination)) { charsWritten = s.Length; return true; @@ -181,7 +181,7 @@ namespace System public static Boolean Parse(String value) { if (value == null) throw new ArgumentNullException(nameof(value)); - return Parse(value.AsReadOnlySpan()); + return Parse(value.AsSpan()); } public static bool Parse(ReadOnlySpan value) => @@ -197,19 +197,19 @@ namespace System return false; } - return TryParse(value.AsReadOnlySpan(), out result); + return TryParse(value.AsSpan(), out result); } public static bool TryParse(ReadOnlySpan value, out bool result) { - ReadOnlySpan trueSpan = TrueLiteral.AsReadOnlySpan(); + ReadOnlySpan trueSpan = TrueLiteral.AsSpan(); if (StringSpanHelpers.Equals(trueSpan, value, StringComparison.OrdinalIgnoreCase)) { result = true; return true; } - ReadOnlySpan falseSpan = FalseLiteral.AsReadOnlySpan(); + ReadOnlySpan falseSpan = FalseLiteral.AsSpan(); if (StringSpanHelpers.Equals(falseSpan, value, StringComparison.OrdinalIgnoreCase)) { result = false; diff --git a/src/mscorlib/shared/System/Collections/Generic/ValueListBuilder.cs b/src/mscorlib/shared/System/Collections/Generic/ValueListBuilder.cs index 26b3c9f..72da4a9 100644 --- a/src/mscorlib/shared/System/Collections/Generic/ValueListBuilder.cs +++ b/src/mscorlib/shared/System/Collections/Generic/ValueListBuilder.cs @@ -43,7 +43,7 @@ namespace System.Collections.Generic _pos = pos + 1; } - public ReadOnlySpan AsReadOnlySpan() + public ReadOnlySpan AsSpan() { return _span.Slice(0, _pos); } diff --git a/src/mscorlib/shared/System/Convert.cs b/src/mscorlib/shared/System/Convert.cs index 488ea77..756bf17 100644 --- a/src/mscorlib/shared/System/Convert.cs +++ b/src/mscorlib/shared/System/Convert.cs @@ -2198,7 +2198,7 @@ namespace System return 0; } - int r = ParseNumbers.StringToInt(value.AsReadOnlySpan(), fromBase, ParseNumbers.IsTight | ParseNumbers.TreatAsUnsigned); + int r = ParseNumbers.StringToInt(value.AsSpan(), fromBase, ParseNumbers.IsTight | ParseNumbers.TreatAsUnsigned); if (r < Byte.MinValue || r > Byte.MaxValue) ThrowByteOverflowException(); return (byte)r; @@ -2221,7 +2221,7 @@ namespace System return 0; } - int r = ParseNumbers.StringToInt(value.AsReadOnlySpan(), fromBase, ParseNumbers.IsTight | ParseNumbers.TreatAsI1); + int r = ParseNumbers.StringToInt(value.AsSpan(), fromBase, ParseNumbers.IsTight | ParseNumbers.TreatAsI1); if (fromBase != 10 && r <= Byte.MaxValue) return (sbyte)r; @@ -2246,7 +2246,7 @@ namespace System return 0; } - int r = ParseNumbers.StringToInt(value.AsReadOnlySpan(), fromBase, ParseNumbers.IsTight | ParseNumbers.TreatAsI2); + int r = ParseNumbers.StringToInt(value.AsSpan(), fromBase, ParseNumbers.IsTight | ParseNumbers.TreatAsI2); if (fromBase != 10 && r <= UInt16.MaxValue) return (short)r; @@ -2272,7 +2272,7 @@ namespace System return 0; } - int r = ParseNumbers.StringToInt(value.AsReadOnlySpan(), fromBase, ParseNumbers.IsTight | ParseNumbers.TreatAsUnsigned); + int r = ParseNumbers.StringToInt(value.AsSpan(), fromBase, ParseNumbers.IsTight | ParseNumbers.TreatAsUnsigned); if (r < UInt16.MinValue || r > UInt16.MaxValue) ThrowUInt16OverflowException(); return (ushort)r; @@ -2289,7 +2289,7 @@ namespace System throw new ArgumentException(SR.Arg_InvalidBase); } return value != null ? - ParseNumbers.StringToInt(value.AsReadOnlySpan(), fromBase, ParseNumbers.IsTight) : + ParseNumbers.StringToInt(value.AsSpan(), fromBase, ParseNumbers.IsTight) : 0; } @@ -2305,7 +2305,7 @@ namespace System throw new ArgumentException(SR.Arg_InvalidBase); } return value != null ? - (uint)ParseNumbers.StringToInt(value.AsReadOnlySpan(), fromBase, ParseNumbers.TreatAsUnsigned | ParseNumbers.IsTight) : + (uint)ParseNumbers.StringToInt(value.AsSpan(), fromBase, ParseNumbers.TreatAsUnsigned | ParseNumbers.IsTight) : 0; } @@ -2320,7 +2320,7 @@ namespace System throw new ArgumentException(SR.Arg_InvalidBase); } return value != null ? - ParseNumbers.StringToLong(value.AsReadOnlySpan(), fromBase, ParseNumbers.IsTight) : + ParseNumbers.StringToLong(value.AsSpan(), fromBase, ParseNumbers.IsTight) : 0; } @@ -2336,7 +2336,7 @@ namespace System throw new ArgumentException(SR.Arg_InvalidBase); } return value != null ? - (ulong)ParseNumbers.StringToLong(value.AsReadOnlySpan(), fromBase, ParseNumbers.TreatAsUnsigned | ParseNumbers.IsTight) : + (ulong)ParseNumbers.StringToLong(value.AsSpan(), fromBase, ParseNumbers.TreatAsUnsigned | ParseNumbers.IsTight) : 0; } @@ -2653,7 +2653,7 @@ namespace System throw new ArgumentNullException(nameof(s)); } - return TryFromBase64Chars(s.AsReadOnlySpan(), bytes, out bytesWritten); + return TryFromBase64Chars(s.AsSpan(), bytes, out bytesWritten); } public static unsafe bool TryFromBase64Chars(ReadOnlySpan chars, Span bytes, out int bytesWritten) diff --git a/src/mscorlib/shared/System/Globalization/CompareInfo.cs b/src/mscorlib/shared/System/Globalization/CompareInfo.cs index 8020fad..8dbfed1 100644 --- a/src/mscorlib/shared/System/Globalization/CompareInfo.cs +++ b/src/mscorlib/shared/System/Globalization/CompareInfo.cs @@ -344,7 +344,7 @@ namespace System.Globalization return String.CompareOrdinal(string1, string2); } - return CompareString(string1.AsReadOnlySpan(), string2.AsReadOnlySpan(), options); + return CompareString(string1.AsSpan(), string2.AsSpan(), options); } // TODO https://github.com/dotnet/coreclr/issues/13827: @@ -354,7 +354,7 @@ namespace System.Globalization { if (options == CompareOptions.OrdinalIgnoreCase) { - return CompareOrdinalIgnoreCase(string1, string2.AsReadOnlySpan()); + return CompareOrdinalIgnoreCase(string1, string2.AsSpan()); } // Verify the options before we do any real comparison. @@ -365,7 +365,7 @@ namespace System.Globalization throw new ArgumentException(SR.Argument_CompareOptionOrdinal, nameof(options)); } - return string.CompareOrdinal(string1, string2.AsReadOnlySpan()); + return string.CompareOrdinal(string1, string2.AsSpan()); } if ((options & ValidCompareMaskOffFlags) != 0) @@ -382,8 +382,8 @@ namespace System.Globalization if (_invariantMode) { return (options & CompareOptions.IgnoreCase) != 0 ? - CompareOrdinalIgnoreCase(string1, string2.AsReadOnlySpan()) : - string.CompareOrdinal(string1, string2.AsReadOnlySpan()); + CompareOrdinalIgnoreCase(string1, string2.AsSpan()) : + string.CompareOrdinal(string1, string2.AsSpan()); } return CompareString(string1, string2, options); @@ -526,8 +526,8 @@ namespace System.Globalization } return CompareString( - string1.AsReadOnlySpan().Slice(offset1, length1), - string2.AsReadOnlySpan().Slice(offset2, length2), + string1.AsSpan().Slice(offset1, length1), + string2.AsSpan().Slice(offset2, length2), options); } @@ -551,7 +551,7 @@ namespace System.Globalization { Debug.Assert(indexA + lengthA <= strA.Length); Debug.Assert(indexB + lengthB <= strB.Length); - return CompareOrdinalIgnoreCase(strA.AsReadOnlySpan().Slice(indexA, lengthA), strB.AsReadOnlySpan().Slice(indexB, lengthB)); + return CompareOrdinalIgnoreCase(strA.AsSpan().Slice(indexA, lengthA), strB.AsSpan().Slice(indexB, lengthB)); } internal static unsafe int CompareOrdinalIgnoreCase(ReadOnlySpan strA, ReadOnlySpan strB) diff --git a/src/mscorlib/shared/System/Globalization/DateTimeParse.cs b/src/mscorlib/shared/System/Globalization/DateTimeParse.cs index 049aae3..5b285eb 100644 --- a/src/mscorlib/shared/System/Globalization/DateTimeParse.cs +++ b/src/mscorlib/shared/System/Globalization/DateTimeParse.cs @@ -5045,7 +5045,7 @@ new DS[] { DS.ERROR, DS.TX_NNN, DS.TX_NNN, DS.TX_NNN, DS.ERROR, DS.ERROR, { return false; } - if (m_info.Compare(Value.Slice(thisPosition, segmentLength), target.AsReadOnlySpan().Slice(targetPosition, segmentLength), CompareOptions.IgnoreCase) != 0) + if (m_info.Compare(Value.Slice(thisPosition, segmentLength), target.AsSpan().Slice(targetPosition, segmentLength), CompareOptions.IgnoreCase) != 0) { return false; } @@ -5071,7 +5071,7 @@ new DS[] { DS.ERROR, DS.TX_NNN, DS.TX_NNN, DS.TX_NNN, DS.ERROR, DS.ERROR, { return false; } - if (m_info.Compare(Value.Slice(thisPosition, segmentLength), target.AsReadOnlySpan().Slice(targetPosition, segmentLength), CompareOptions.IgnoreCase) != 0) + if (m_info.Compare(Value.Slice(thisPosition, segmentLength), target.AsSpan().Slice(targetPosition, segmentLength), CompareOptions.IgnoreCase) != 0) { return false; } diff --git a/src/mscorlib/shared/System/Globalization/HijriCalendar.Win32.cs b/src/mscorlib/shared/System/Globalization/HijriCalendar.Win32.cs index 09b1f20..365942c 100644 --- a/src/mscorlib/shared/System/Globalization/HijriCalendar.Win32.cs +++ b/src/mscorlib/shared/System/Globalization/HijriCalendar.Win32.cs @@ -69,7 +69,7 @@ namespace System.Globalization { try { - int advance = Int32.Parse(str.AsReadOnlySpan().Slice(HijriAdvanceRegKeyEntry.Length), provider:CultureInfo.InvariantCulture); + int advance = Int32.Parse(str.AsSpan().Slice(HijriAdvanceRegKeyEntry.Length), provider:CultureInfo.InvariantCulture); if ((advance >= MinAdvancedHijri) && (advance <= MaxAdvancedHijri)) { hijriAdvance = advance; diff --git a/src/mscorlib/shared/System/Globalization/JapaneseCalendar.Win32.cs b/src/mscorlib/shared/System/Globalization/JapaneseCalendar.Win32.cs index 9ea6c21..1d0180b 100644 --- a/src/mscorlib/shared/System/Globalization/JapaneseCalendar.Win32.cs +++ b/src/mscorlib/shared/System/Globalization/JapaneseCalendar.Win32.cs @@ -159,7 +159,7 @@ namespace System.Globalization int month; int day; - ReadOnlySpan valueSpan = value.AsReadOnlySpan(); + ReadOnlySpan valueSpan = value.AsSpan(); if (!Int32.TryParse(valueSpan.Slice(0, 4), NumberStyles.None, NumberFormatInfo.InvariantInfo, out year) || !Int32.TryParse(valueSpan.Slice(5, 2), NumberStyles.None, NumberFormatInfo.InvariantInfo, out month) || !Int32.TryParse(valueSpan.Slice(8, 2), NumberStyles.None, NumberFormatInfo.InvariantInfo, out day)) diff --git a/src/mscorlib/shared/System/IO/Path.Unix.cs b/src/mscorlib/shared/System/IO/Path.Unix.cs index 5d07f72..1294930 100644 --- a/src/mscorlib/shared/System/IO/Path.Unix.cs +++ b/src/mscorlib/shared/System/IO/Path.Unix.cs @@ -108,7 +108,7 @@ namespace System.IO if (path == null) return false; - return IsPathRooted(path.AsReadOnlySpan()); + return IsPathRooted(path.AsSpan()); } public static bool IsPathRooted(ReadOnlySpan path) @@ -128,7 +128,7 @@ namespace System.IO public static ReadOnlySpan GetPathRoot(ReadOnlySpan path) { - return PathInternal.IsEffectivelyEmpty(path) && IsPathRooted(path) ? PathInternal.DirectorySeparatorCharAsString.AsReadOnlySpan() : ReadOnlySpan.Empty; + return PathInternal.IsEffectivelyEmpty(path) && IsPathRooted(path) ? PathInternal.DirectorySeparatorCharAsString.AsSpan() : ReadOnlySpan.Empty; } /// Gets whether the system is case-sensitive. diff --git a/src/mscorlib/shared/System/IO/Path.Windows.cs b/src/mscorlib/shared/System/IO/Path.Windows.cs index 846dd53..6a8745d 100644 --- a/src/mscorlib/shared/System/IO/Path.Windows.cs +++ b/src/mscorlib/shared/System/IO/Path.Windows.cs @@ -80,19 +80,19 @@ namespace System.IO // Path is current drive rooted i.e. starts with \: // "\Foo" and "C:\Bar" => "C:\Foo" // "\Foo" and "\\?\C:\Bar" => "\\?\C:\Foo" - combinedPath = CombineNoChecks(GetPathRoot(basePath), path.AsReadOnlySpan().Slice(1)); + combinedPath = CombineNoChecks(GetPathRoot(basePath), path.AsSpan().Slice(1)); } else if (length >= 2 && PathInternal.IsValidDriveChar(path[0]) && path[1] == PathInternal.VolumeSeparatorChar) { // Drive relative paths Debug.Assert(length == 2 || !PathInternal.IsDirectorySeparator(path[2])); - if (StringSpanHelpers.Equals(GetVolumeName(path.AsReadOnlySpan()), GetVolumeName(basePath.AsReadOnlySpan()))) + if (StringSpanHelpers.Equals(GetVolumeName(path.AsSpan()), GetVolumeName(basePath.AsSpan()))) { // Matching root // "C:Foo" and "C:\Bar" => "C:\Bar\Foo" // "C:Foo" and "\\?\C:\Bar" => "\\?\C:\Bar\Foo" - combinedPath = CombineNoChecks(basePath, path.AsReadOnlySpan().Slice(2)); + combinedPath = CombineNoChecks(basePath, path.AsSpan().Slice(2)); } else { @@ -144,7 +144,7 @@ namespace System.IO // if it starts with a backslash ("\") or a valid drive letter and a colon (":"). public static bool IsPathRooted(string path) { - return path != null && IsPathRooted(path.AsReadOnlySpan()); + return path != null && IsPathRooted(path.AsSpan()); } public static bool IsPathRooted(ReadOnlySpan path) @@ -168,7 +168,7 @@ namespace System.IO if (PathInternal.IsEffectivelyEmpty(path)) return null; - ReadOnlySpan result = GetPathRoot(path.AsReadOnlySpan()); + ReadOnlySpan result = GetPathRoot(path.AsSpan()); if (path.Length == result.Length) return PathInternal.NormalizeDirectorySeparators(path); diff --git a/src/mscorlib/shared/System/IO/Path.cs b/src/mscorlib/shared/System/IO/Path.cs index 3784b87..7685099 100644 --- a/src/mscorlib/shared/System/IO/Path.cs +++ b/src/mscorlib/shared/System/IO/Path.cs @@ -130,7 +130,7 @@ namespace System.IO if (path == null) return null; - return new string(GetExtension(path.AsReadOnlySpan())); + return new string(GetExtension(path.AsSpan())); } /// @@ -169,7 +169,7 @@ namespace System.IO if (path == null) return null; - ReadOnlySpan result = GetFileName(path.AsReadOnlySpan()); + ReadOnlySpan result = GetFileName(path.AsSpan()); if (path.Length == result.Length) return path; @@ -200,7 +200,7 @@ namespace System.IO if (path == null) return null; - ReadOnlySpan result = GetFileNameWithoutExtension(path.AsReadOnlySpan()); + ReadOnlySpan result = GetFileNameWithoutExtension(path.AsSpan()); if (path.Length == result.Length) return path; @@ -254,7 +254,7 @@ namespace System.IO if (path == null) throw new ArgumentNullException(nameof(path)); - return IsPathFullyQualified(path.AsReadOnlySpan()); + return IsPathFullyQualified(path.AsSpan()); } public static bool IsPathFullyQualified(ReadOnlySpan path) @@ -271,7 +271,7 @@ namespace System.IO { if (path != null) { - return HasExtension(path.AsReadOnlySpan()); + return HasExtension(path.AsSpan()); } return false; } @@ -411,7 +411,7 @@ namespace System.IO if (string.IsNullOrEmpty(second)) return first; - if (IsPathRooted(second.AsReadOnlySpan())) + if (IsPathRooted(second.AsSpan())) return second; return CombineNoChecksInternal(first, second); @@ -443,9 +443,9 @@ namespace System.IO if (string.IsNullOrEmpty(third)) return CombineNoChecks(first, second); - if (IsPathRooted(third.AsReadOnlySpan())) + if (IsPathRooted(third.AsSpan())) return third; - if (IsPathRooted(second.AsReadOnlySpan())) + if (IsPathRooted(second.AsSpan())) return CombineNoChecks(second, third); return CombineNoChecksInternal(first, second, third); @@ -483,11 +483,11 @@ namespace System.IO if (string.IsNullOrEmpty(fourth)) return CombineNoChecks(first, second, third); - if (IsPathRooted(fourth.AsReadOnlySpan())) + if (IsPathRooted(fourth.AsSpan())) return fourth; - if (IsPathRooted(third.AsReadOnlySpan())) + if (IsPathRooted(third.AsSpan())) return CombineNoChecks(third, fourth); - if (IsPathRooted(second.AsReadOnlySpan())) + if (IsPathRooted(second.AsSpan())) return CombineNoChecks(second, third, fourth); return CombineNoChecksInternal(first, second, third, fourth); diff --git a/src/mscorlib/shared/System/IO/StreamWriter.cs b/src/mscorlib/shared/System/IO/StreamWriter.cs index 5826f91..6cdcd69 100644 --- a/src/mscorlib/shared/System/IO/StreamWriter.cs +++ b/src/mscorlib/shared/System/IO/StreamWriter.cs @@ -432,7 +432,7 @@ namespace System.IO { if (value != null) { - WriteCore(value.AsReadOnlySpan(), _autoFlush); + WriteCore(value.AsSpan(), _autoFlush); } } @@ -445,7 +445,7 @@ namespace System.IO CheckAsyncTaskInProgress(); if (value != null) { - WriteCore(value.AsReadOnlySpan(), autoFlush: false); + WriteCore(value.AsSpan(), autoFlush: false); } WriteCore(new ReadOnlySpan(CoreNewLine), autoFlush: true); } diff --git a/src/mscorlib/shared/System/Number.Formatting.cs b/src/mscorlib/shared/System/Number.Formatting.cs index 58d501b..24d5db1 100644 --- a/src/mscorlib/shared/System/Number.Formatting.cs +++ b/src/mscorlib/shared/System/Number.Formatting.cs @@ -564,7 +564,7 @@ namespace System { Debug.Assert(source != null); - if (source.AsReadOnlySpan().TryCopyTo(destination)) + if (source.AsSpan().TryCopyTo(destination)) { charsWritten = source.Length; return true; diff --git a/src/mscorlib/shared/System/Span.NonGeneric.cs b/src/mscorlib/shared/System/Span.NonGeneric.cs index 2331664..ff2d773 100644 --- a/src/mscorlib/shared/System/Span.NonGeneric.cs +++ b/src/mscorlib/shared/System/Span.NonGeneric.cs @@ -632,7 +632,7 @@ namespace System /// Returns default when is null. /// reference (Nothing in Visual Basic). [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static ReadOnlySpan AsReadOnlySpan(this string text) + public static ReadOnlySpan AsSpan(this string text) { if (text == null) return default; @@ -649,7 +649,7 @@ namespace System /// Thrown when the specified index is not in range (<0 or >text.Length). /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static ReadOnlySpan AsReadOnlySpan(this string text, int start) + public static ReadOnlySpan AsSpan(this string text, int start) { if (text == null) { @@ -673,7 +673,7 @@ namespace System /// Thrown when the specified index or is not in range. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static ReadOnlySpan AsReadOnlySpan(this string text, int start, int length) + public static ReadOnlySpan AsSpan(this string text, int start, int length) { if (text == null) { @@ -688,6 +688,11 @@ namespace System return new ReadOnlySpan(ref Unsafe.Add(ref text.GetRawStringData(), start), length); } + // TODO: Delete once the AsReadOnlySpan -> AsSpan rename propages through the system + public static ReadOnlySpan AsReadOnlySpan(this string text) => AsSpan(text); + public static ReadOnlySpan AsReadOnlySpan(this string text, int start) => AsSpan(text, start); + public static ReadOnlySpan AsReadOnlySpan(this string text, int start, int length) => AsSpan(text, start, length); + internal static unsafe void ClearWithoutReferences(ref byte b, nuint byteLength) { if (byteLength == 0) diff --git a/src/mscorlib/shared/System/String.Manipulation.cs b/src/mscorlib/shared/System/String.Manipulation.cs index 1d500e8..76cbfaa 100644 --- a/src/mscorlib/shared/System/String.Manipulation.cs +++ b/src/mscorlib/shared/System/String.Manipulation.cs @@ -1107,7 +1107,7 @@ namespace System // String allocation and copying is in separate method to make this method faster for the case where // nothing needs replacing. - string dst = ReplaceHelper(oldValue.Length, newValue, replacementIndices.AsReadOnlySpan()); + string dst = ReplaceHelper(oldValue.Length, newValue, replacementIndices.AsSpan()); replacementIndices.Dispose(); @@ -1136,19 +1136,19 @@ namespace System int count = replacementIdx - thisIdx; if (count != 0) { - this.AsReadOnlySpan().Slice(thisIdx, count).CopyTo(dstSpan.Slice(dstIdx)); + this.AsSpan().Slice(thisIdx, count).CopyTo(dstSpan.Slice(dstIdx)); dstIdx += count; } thisIdx = replacementIdx + oldValueLength; // Copy over newValue to replace the oldValue. - newValue.AsReadOnlySpan().CopyTo(dstSpan.Slice(dstIdx)); + newValue.AsSpan().CopyTo(dstSpan.Slice(dstIdx)); dstIdx += newValue.Length; } // Copy over the final non-matching portion at the end of the string. Debug.Assert(this.Length - thisIdx == dstSpan.Length - dstIdx); - this.AsReadOnlySpan().Slice(thisIdx).CopyTo(dstSpan.Slice(dstIdx)); + this.AsSpan().Slice(thisIdx).CopyTo(dstSpan.Slice(dstIdx)); return dst; } @@ -1228,7 +1228,7 @@ namespace System var sepListBuilder = new ValueListBuilder(initialSpan); MakeSeparatorList(separators, ref sepListBuilder); - ReadOnlySpan sepList = sepListBuilder.AsReadOnlySpan(); + ReadOnlySpan sepList = sepListBuilder.AsSpan(); // Handle the special case of no replaces. if (sepList.Length == 0) @@ -1309,8 +1309,8 @@ namespace System var lengthListBuilder = new ValueListBuilder(lengthListInitialSpan); MakeSeparatorList(separators, ref sepListBuilder, ref lengthListBuilder); - ReadOnlySpan sepList = sepListBuilder.AsReadOnlySpan(); - ReadOnlySpan lengthList = lengthListBuilder.AsReadOnlySpan(); + ReadOnlySpan sepList = sepListBuilder.AsSpan(); + ReadOnlySpan lengthList = lengthListBuilder.AsSpan(); // Handle the special case of no replaces. if (sepList.Length == 0) @@ -1334,7 +1334,7 @@ namespace System var sepListBuilder = new ValueListBuilder(sepListInitialSpan); MakeSeparatorList(separator, ref sepListBuilder); - ReadOnlySpan sepList = sepListBuilder.AsReadOnlySpan(); + ReadOnlySpan sepList = sepListBuilder.AsSpan(); if (sepList.Length == 0) { // there are no separators so sepListBuilder did not rent an array from pool and there is no need to dispose it diff --git a/src/mscorlib/shared/System/StringSpanHelpers.cs b/src/mscorlib/shared/System/StringSpanHelpers.cs index 7419adb..58820a8 100644 --- a/src/mscorlib/shared/System/StringSpanHelpers.cs +++ b/src/mscorlib/shared/System/StringSpanHelpers.cs @@ -17,7 +17,7 @@ namespace System throw new ArgumentOutOfRangeException(nameof(comparisonType)); public static bool Equals(this ReadOnlySpan left, string right) => - Equals(left, right.AsReadOnlySpan()); + Equals(left, right.AsSpan()); public static bool Equals(this ReadOnlySpan left, ReadOnlySpan right) { diff --git a/src/mscorlib/shared/System/Text/StringBuilder.cs b/src/mscorlib/shared/System/Text/StringBuilder.cs index 19c1549..a7804c3 100644 --- a/src/mscorlib/shared/System/Text/StringBuilder.cs +++ b/src/mscorlib/shared/System/Text/StringBuilder.cs @@ -1552,7 +1552,7 @@ namespace System.Text if (startPos != pos) { // There was no brace escaping, extract the item format as a single string - itemFormatSpan = format.AsReadOnlySpan().Slice(startPos, pos - startPos); + itemFormatSpan = format.AsSpan().Slice(startPos, pos - startPos); } } else diff --git a/src/mscorlib/shared/System/TimeZoneInfo.Unix.cs b/src/mscorlib/shared/System/TimeZoneInfo.Unix.cs index a06545f..410eaf3 100644 --- a/src/mscorlib/shared/System/TimeZoneInfo.Unix.cs +++ b/src/mscorlib/shared/System/TimeZoneInfo.Unix.cs @@ -1198,9 +1198,9 @@ namespace System int secondDotIndex = dateRule.IndexOf('.', firstDotIndex + 1); if (secondDotIndex > 0) { - if (int.TryParse(dateRule.AsReadOnlySpan().Slice(1, firstDotIndex - 1), out month) && - int.TryParse(dateRule.AsReadOnlySpan().Slice(firstDotIndex + 1, secondDotIndex - firstDotIndex - 1), out week) && - int.TryParse(dateRule.AsReadOnlySpan().Slice(secondDotIndex + 1), out int day)) + if (int.TryParse(dateRule.AsSpan().Slice(1, firstDotIndex - 1), out month) && + int.TryParse(dateRule.AsSpan().Slice(firstDotIndex + 1, secondDotIndex - firstDotIndex - 1), out week) && + int.TryParse(dateRule.AsSpan().Slice(secondDotIndex + 1), out int day)) { dayOfWeek = (DayOfWeek)day; return true; diff --git a/src/mscorlib/shared/System/Version.cs b/src/mscorlib/shared/System/Version.cs index df16be2..9e4cefc 100644 --- a/src/mscorlib/shared/System/Version.cs +++ b/src/mscorlib/shared/System/Version.cs @@ -300,7 +300,7 @@ namespace System throw new ArgumentNullException(nameof(input)); } - return ParseVersion(input.AsReadOnlySpan(), throwOnFailure: true); + return ParseVersion(input.AsSpan(), throwOnFailure: true); } public static Version Parse(ReadOnlySpan input) => @@ -314,7 +314,7 @@ namespace System return false; } - return (result = ParseVersion(input.AsReadOnlySpan(), throwOnFailure: false)) != null; + return (result = ParseVersion(input.AsSpan(), throwOnFailure: false)) != null; } public static bool TryParse(ReadOnlySpan input, out Version result) => -- 2.7.4