Added TransferBuffer<T> debug info

このコミットが含まれているのは:
Sergio Pedri committed 2021-01-31 20:24:12 +01:00
1 親 9e728efca5
コミット 8b9c0bf53b
3ファイル変更
+59 -4

検索条件に一致するファイルはありません

+35
ファイルの表示
@@ -0,0 +1,35 @@
using System;
using System.Diagnostics;
namespace ComputeSharp.Resources.Views
{
/// <summary>
/// A debug proxy used to display items in a <see cref="TransferBuffer{T}"/> instance.
/// </summary>
/// <typeparam name="T">The type of items to display.</typeparam>
internal sealed class TransferBufferDebugView<T>
where T : unmanaged
{
/// <summary>
/// Initializes a new instance of the <see cref="TransferBufferDebugView{T}"/> class with the specified parameters.
/// </summary>
/// <param name="buffer">The input <see cref="TransferBuffer{T}"/> instance with the items to display.</param>
public TransferBufferDebugView(TransferBuffer<T>? buffer)
{
if (buffer is not null)
{
var items = GC.AllocateUninitializedArray<T>(buffer.Length);
buffer.Span.CopyTo(items);
Items = items;
}
}
/// <summary>
/// Gets the items to display for the current instance.
/// </summary>
[DebuggerBrowsable(DebuggerBrowsableState.Collapsed)]
public T[]? Items { get; }
}
}