// 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; namespace CommunityToolkit.HighPerformance.Buffers.Views; /// /// A debug proxy used to display items in a 1D layout. /// /// The type of items to display. internal sealed class MemoryDebugView { /// /// Initializes a new instance of the class with the specified parameters. /// /// The input instance with the items to display. public MemoryDebugView(ArrayPoolBufferWriter? arrayPoolBufferWriter) { this.Items = arrayPoolBufferWriter?.WrittenSpan.ToArray(); } /// /// Initializes a new instance of the class with the specified parameters. /// /// The input instance with the items to display. public MemoryDebugView(MemoryBufferWriter? memoryBufferWriter) { this.Items = memoryBufferWriter?.WrittenSpan.ToArray(); } /// /// Initializes a new instance of the class with the specified parameters. /// /// The input instance with the items to display. public MemoryDebugView(MemoryOwner? memoryOwner) { this.Items = memoryOwner?.Span.ToArray(); } /// /// Initializes a new instance of the class with the specified parameters. /// /// The input instance with the items to display. public MemoryDebugView(SpanOwner spanOwner) { this.Items = spanOwner.Span.ToArray(); } /// /// Gets the items to display for the current instance /// [DebuggerBrowsable(DebuggerBrowsableState.Collapsed)] public T[]? Items { get; } }