/// <remarks>
/// <see cref="SearchValues{T}"/> are optimized for situations where the same set of values is frequently used for searching at runtime.
/// </remarks>
+ [DebuggerDisplay("{DebuggerDisplay,nq}")]
[DebuggerTypeProxy(typeof(SearchValuesDebugView<>))]
public class SearchValues<T> where T : IEquatable<T>?
{
// Only CoreLib can create derived types
private protected SearchValues() { }
- /// <summary>Used by <see cref="SearchValuesDebugView{T}"/>.</summary>
+ /// <summary>Used by <see cref="DebuggerDisplay"/>s and <see cref="DebuggerTypeProxyAttribute"/>s for <see cref="SearchValues{T}"/>.</summary>
internal virtual T[] GetValues() => throw new UnreachableException();
/// <summary>
return values.LastIndexOfAnyExcept(span);
}
+
+ private string DebuggerDisplay
+ {
+ get
+ {
+ T[] values = GetValues();
+
+ string display = $"{GetType().Name}, Count={values.Length}";
+ if (values.Length > 0)
+ {
+ display += ", Values=";
+ display += typeof(T) == typeof(char) ?
+ "\"" + new string(Unsafe.As<T[], char[]>(ref values)) + "\"" :
+ string.Join(",", values);
+ }
+
+ return display;
+ }
+ }
}
}
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
+using System.Diagnostics;
+
namespace System.Buffers
{
internal sealed class SearchValuesDebugView<T> where T : IEquatable<T>?
_values = values;
}
+ [DebuggerBrowsable(DebuggerBrowsableState.RootHidden)]
public T[] Values => _values.GetValues();
}
}