Skip to content

add AdvancedDebuggerDisplayExtensions#2

Draft
InsanityCode wants to merge 2 commits into
chaosfrom
recursive-debugger-display
Draft

add AdvancedDebuggerDisplayExtensions#2
InsanityCode wants to merge 2 commits into
chaosfrom
recursive-debugger-display

Conversation

@InsanityCode

Copy link
Copy Markdown
Member

Problem

The DebuggerDisplayAttribute does not recursively evaluate the DebuggerDisplayAttribute of types used in the provided debugger display expression.

Sadly the DebuggerDisplayAttribute class is sealed, so inheriting this class and defining a custom attribute for that sake is not an option.

Solution

Provide an extension method for all types that evaluates the debugger display of an object.

@InsanityCode InsanityCode added the draft This is a draft pull request. Do not merge (yet). label Mar 28, 2024
@InsanityCode InsanityCode self-assigned this Mar 28, 2024
@InsanityCode

Copy link
Copy Markdown
Member Author

As it is now this is far from complete as it is lacking support for several kinds of expressions supported by
DebuggerDisplayAttributes, such as

  • passing arguments to called methods
  • accessing static members
  • indexers
  • escaping braces by using double braces:
    e.g. {{ this is not an expression to be evaluated, but a terminal }}
  • calling extension methods on an object
    (other than .DebugDisplay())
  • arithmetic or logical operators
  • expressions in parantheses

... and likely many more

The status quo is simply meant to present the concept in order to decide whether we actually want that.

@FramePerfection

Copy link
Copy Markdown
Member

Unfortunately I could not get this to work at all in Visual Studio 2017, it would always fail to find the DebugDisplay extension method, no matter how I tried to qualify it.

On top of this, the amount of Todos is already considerable, and it's unlikely that many of the features required to fully support all sorts of C# expressions would find much use anyways.

I believe the solution here is to just take the hit and explicitly parameterize the DebuggerDisplay attribute as necessary where it really is necessary. It won't do to attempt changing the fundamental behavior of a piece of software that we have essentially no control over, and given that dotnet/roslyn#24670 is probably not going to be resolved any time soon, there's nothing we can really do.

@InsanityCode InsanityCode marked this pull request as draft October 18, 2025 13:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

draft This is a draft pull request. Do not merge (yet).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants