From fcbb26407b5b87a2d6cc47ff0c8b4cc9e834a47a Mon Sep 17 00:00:00 2001 From: Ahson Khan Date: Wed, 8 Nov 2017 14:29:51 -0800 Subject: [PATCH] Adding placeholder Span debugger proxy (dotnet/coreclr#14749) * Adding placeholder Span debugger proxy. * Remove unnecessary unsafe keyword. Signed-off-by: dotnet-bot-corefx-mirror --- .../System.Private.CoreLib.Shared.projitems | 1 + src/Common/src/CoreLib/System/ReadOnlySpan.cs | 1 + src/Common/src/CoreLib/System/Span.cs | 1 + .../src/CoreLib/System/SpanDebugView.cs | 28 +++++++++++++++++++ 4 files changed, 31 insertions(+) create mode 100644 src/Common/src/CoreLib/System/SpanDebugView.cs diff --git a/src/Common/src/CoreLib/System.Private.CoreLib.Shared.projitems b/src/Common/src/CoreLib/System.Private.CoreLib.Shared.projitems index 5b7629f24548..68234374044d 100644 --- a/src/Common/src/CoreLib/System.Private.CoreLib.Shared.projitems +++ b/src/Common/src/CoreLib/System.Private.CoreLib.Shared.projitems @@ -441,6 +441,7 @@ + diff --git a/src/Common/src/CoreLib/System/ReadOnlySpan.cs b/src/Common/src/CoreLib/System/ReadOnlySpan.cs index c5f301a6f27e..a0a0cf9c055f 100644 --- a/src/Common/src/CoreLib/System/ReadOnlySpan.cs +++ b/src/Common/src/CoreLib/System/ReadOnlySpan.cs @@ -15,6 +15,7 @@ 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. /// + [DebuggerTypeProxy(typeof(SpanDebugView<>))] [DebuggerDisplay("{DebuggerDisplay,nq}")] [NonVersionable] public readonly ref struct ReadOnlySpan diff --git a/src/Common/src/CoreLib/System/Span.cs b/src/Common/src/CoreLib/System/Span.cs index 261b15c07878..f885c63850f1 100644 --- a/src/Common/src/CoreLib/System/Span.cs +++ b/src/Common/src/CoreLib/System/Span.cs @@ -21,6 +21,7 @@ namespace System /// Span 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. /// + [DebuggerTypeProxy(typeof(SpanDebugView<>))] [DebuggerDisplay("{DebuggerDisplay,nq}")] [NonVersionable] public readonly ref struct Span diff --git a/src/Common/src/CoreLib/System/SpanDebugView.cs b/src/Common/src/CoreLib/System/SpanDebugView.cs new file mode 100644 index 000000000000..caa12ef9ed9d --- /dev/null +++ b/src/Common/src/CoreLib/System/SpanDebugView.cs @@ -0,0 +1,28 @@ +// 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.Diagnostics; +using System.Reflection; +using System.Runtime.CompilerServices; + +namespace System +{ + internal sealed class SpanDebugView + { + private readonly T[] _array; + + public SpanDebugView(Span span) + { + _array = span.ToArray(); + } + + public SpanDebugView(ReadOnlySpan span) + { + _array = span.ToArray(); + } + + [DebuggerBrowsable(DebuggerBrowsableState.RootHidden)] + public T[] Items => _array; + } +}