fix(debugging): stop debugger displays rendering as a bare null - #2315
Merged
Conversation
- Give every debugger display literal text alongside its placeholder. A display made of nothing but one member rendered as a bare `null` the moment that member was null, which reads as though the object itself does not exist. - ApiResponse<T> was the reported case: hovering a response that came back without content showed `null`, sending the reader looking for a NullReferenceException that was never thrown. It now leads with the type and the status code. - Ten other shipped types carried the same shape and are fixed with it. - Add DebuggerDisplayTests, which walks the shipped assemblies and fails any display whose sole placeholder can be null, plus any placeholder naming a member that does not exist. Closes #2313
ChrisPulman
approved these changes
Aug 18, 2026
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2315 +/- ##
=======================================
Coverage 99.91% 99.91%
=======================================
Files 194 194
Lines 10138 10138
Branches 1947 1947
=======================================
Hits 10129 10129
Partials 9 9 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



What kind of change does this PR introduce?
Bug fix.
What is the new behavior?
A debugger display always shows that an object is there, whatever its members hold.
ApiResponse<T>leads with the type and the status code. Hovering a response that came back without content now readsApiResponse: NotFound, Content = nullinstead of a barenull.ValidationApiException,StubApiResponse<T>,RefitSettings,BodyAttribute,MultipartItem,PropertyAttribute,RestMethodParameterInfo,SettingsFor<T>,RouteMatcherandXmlContentSerializerSettings. Each keeps the member it showed and gains the literal text that makes a null value legible.DebuggerDisplayTestskeeps it that way. It walks the shipped assemblies and fails any display whose sole placeholder can be null, and any placeholder naming a member that does not exist. The offender list in this PR is what that test reported, not a hand-picked set.What is the current behavior?
A display made of nothing but one member renders as a bare
nullwhen that member is null.ApiResponse<T>carried[DebuggerDisplay("{Content}")], so a response with no content - a request error, or a 204 - showed asnullin the debugger. It reads as though the response object itself does not exist, and sends the reader looking for aNullReferenceExceptionthat was never thrown.Closes #2313
What might this PR break?
None at runtime.
[DebuggerDisplay], so the format-string changes show up as baseline diffs across every target. That is the analyzer recording an attribute argument, not a change to any callable surface.Checklist
mainbranchAdditional information
The reporter suggested prefixing the display, for example
ApiResponse:{Content}. This goes slightly further for the response and exception types by also showing the status code, which is the state worth seeing precisely when the content is missing.{ToString(),nq}displays are left alone - those types overrideToString(), and that is the idiomatic form rather than the shape that caused the report.Hand-authored file worth reviewing:
DebuggerDisplayTests.cs. Everything else is a one-line attribute change or regenerated baseline output.