diff options
Diffstat (limited to 'src/System.Private.CoreLib/shared/System/ReadOnlySpan.Fast.cs')
-rw-r--r-- | src/System.Private.CoreLib/shared/System/ReadOnlySpan.Fast.cs | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/System.Private.CoreLib/shared/System/ReadOnlySpan.Fast.cs b/src/System.Private.CoreLib/shared/System/ReadOnlySpan.Fast.cs index 9bf3f211a..4fb039a0f 100644 --- a/src/System.Private.CoreLib/shared/System/ReadOnlySpan.Fast.cs +++ b/src/System.Private.CoreLib/shared/System/ReadOnlySpan.Fast.cs @@ -2,10 +2,11 @@ // 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.ComponentModel; using System.Diagnostics; using System.Runtime.CompilerServices; using System.Runtime.Versioning; +using EditorBrowsableAttribute = System.ComponentModel.EditorBrowsableAttribute; +using EditorBrowsableState = System.ComponentModel.EditorBrowsableState; using Internal.Runtime.CompilerServices; #pragma warning disable 0809 //warning CS0809: Obsolete member 'Span<T>.Equals(object)' overrides non-obsolete member 'object.Equals(object)' @@ -22,8 +23,6 @@ namespace System /// ReadOnlySpan represents a contiguous region of arbitrary memory. Unlike arrays, it can point to either managed /// or native memory, or to memory allocated on the stack. It is type- and memory-safe. /// </summary> - [DebuggerTypeProxy(typeof(SpanDebugView<>))] - [DebuggerDisplay("{ToString(),raw}")] [NonVersionable] public readonly ref partial struct ReadOnlySpan<T> { @@ -150,6 +149,13 @@ namespace System } /// <summary> + /// Returns a reference to the 0th element of the Span. If the Span is empty, returns null reference. + /// It can be used for pinning and is required to support the use of span within a fixed statement. + /// </summary> + [EditorBrowsable(EditorBrowsableState.Never)] + public unsafe ref readonly T GetPinnableReference() => ref (_length != 0) ? ref _pointer.Value : ref Unsafe.AsRef<T>(null); + + /// <summary> /// Copies the contents of this read-only span into destination span. If the source /// and destinations overlap, this method behaves as if the original values in /// a temporary location before the destination is overwritten. @@ -159,6 +165,7 @@ namespace System /// Thrown when the destination Span is shorter than the source Span. /// </exception> /// </summary> + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void CopyTo(Span<T> destination) { // Using "if (!TryCopyTo(...))" results in two branches: one for the length @@ -204,7 +211,7 @@ namespace System /// <summary> /// For <see cref="ReadOnlySpan{Char}"/>, returns a new instance of string that represents the characters pointed to by the span. - /// Otherwise, returns a <see cref="String"/> with the name of the type and the number of elements. + /// Otherwise, returns a <see cref="string"/> with the name of the type and the number of elements. /// </summary> public override string ToString() { |