visual studio – VS2022: Watch Window defaulting to value not in DebuggerDisplayAttribute


Simple problem. I have a class, with multiple properties. I have overridden ToString() and created a protected method called “DebugDisplay” that returns a string.

I have applied the [DebuggerDisplay(“{DebugDisplay()}”)] attribute to the class.
I build, and in the Watch Window i get: “myVar | EntityImplementation = None”

EntityImplementation is a property returning a custom enum, that does exist on myVar, but it isn’t in the ToString() result, or the DebugDisplay() method result.

I have completely removed this property and all references, and suddenly VS uses the correct watch value that i’m returning in my DebugDisplay() method.

I re-added (by undoing the commented out code) the EntityImplmentation property, and suddenly my DebugDisplay is completely overwridden again.

What is going on here?

Leave a Reply

Your email address will not be published. Required fields are marked *