-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add DebuggerDisplay for SearchValues #86559
Add DebuggerDisplay for SearchValues #86559
Conversation
Tagging subscribers to this area: @dotnet/area-system-runtime |
Just a general question: why this can't be just |
{ | ||
T[] values = GetValues(); | ||
|
||
string display = $"{GetType().Name}, Count={values.Length}"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm using this in my testing, helps a ton when there are multiple generic variants.
Type implType = searchValuesInstance.GetType();
string impl = $"{implType.Name} [{string.Join(", ", implType.GenericTypeArguments.Select(t => t.Name))}]";
E.g.
SingleStringSearchValuesThreeChars`2 [ValueLength8OrLonger, CaseSensitive]
src/libraries/System.Private.CoreLib/src/System/SearchValues/SearchValuesDebugView.cs
Show resolved
Hide resolved
Overriding |
This is effectively a collection. We don't override ToString on collections, and if we did, this wouldn't be the format chosen. The purpose of DebuggerDisplay is to raise for quick consumption the most relevant information for debugging purposes, not for runtime formatting. We should also feel free to frequently change a DebuggerDisplay rendering whereas doing so with ToString would not be desirable as code can take a dependency on it, it can be persisted in logs, test output, etc. This also needn't increase app size and can be trimmed as a debugger display. |
Before:
After: