0
Completed

Conditionally Override DebuggerDisplay

Kenneth LeFebvre 8 months ago in Improvements and existing features updated by Lior Kerner 7 months ago 1

I use Visual Studio's DebuggerDisplay all the time, but have long wished they would let me specify different display strings for different conditions. For example, given the following class:

[DebuggerDisplay("{LastName}, {FirstName} {MiddleName} ({Age} years old)")]
public class Person {
    public string FirstName { get; set; }
    public string MiddleName { get; set; }
    public string LastName { get; set; }
    public int Age { get; set; }
}

If there is no age, I would much rather have the template be "{LastName}, {FirstName} {MiddleName}". Additionally, it would be very helpful to be able to change the color, or use a highlight color, to make the missing value stand out from a long list.

Answer

Answer
Completed

Hi Kenneth!

Have you tried using our Reveal feature? Once you star properties, it will override the VS DebuggerDisplay attribute. This will allow you to filter out properties that you do not wish to see, using our Search feature.

Additionally, you can always apply your DebuggerDisplay attribute as a Custom Expression (with minor syntax adjustments).

Answer
Completed

Hi Kenneth!

Have you tried using our Reveal feature? Once you star properties, it will override the VS DebuggerDisplay attribute. This will allow you to filter out properties that you do not wish to see, using our Search feature.

Additionally, you can always apply your DebuggerDisplay attribute as a Custom Expression (with minor syntax adjustments).