Skip to content

fix(debugging): stop debugger displays rendering as a bare null - #2315

Merged
glennawatson merged 1 commit into
mainfrom
fix/debugger-display-null-rendering
Aug 18, 2026
Merged

fix(debugging): stop debugger displays rendering as a bare null#2315
glennawatson merged 1 commit into
mainfrom
fix/debugger-display-null-rendering

Conversation

@glennawatson

Copy link
Copy Markdown
Contributor

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 reads ApiResponse: NotFound, Content = null instead of a bare null.
  • Ten other shipped types carried the same shape and are fixed with it - ValidationApiException, StubApiResponse<T>, RefitSettings, BodyAttribute, MultipartItem, PropertyAttribute, RestMethodParameterInfo, SettingsFor<T>, RouteMatcher and XmlContentSerializerSettings. Each keeps the member it showed and gains the literal text that makes a null value legible.
  • DebuggerDisplayTests keeps 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 null when that member is null.

  • ApiResponse<T> carried [DebuggerDisplay("{Content}")], so a response with no content - a request error, or a 204 - showed as null in the debugger. It reads as though the response object itself does not exist, and sends the reader looking for a NullReferenceException that was never thrown.

Closes #2313

What might this PR break?

None at runtime.

  • Debugger displays have no effect outside a debugging session.
  • The public API baselines record [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

  • I have read the Contribute guide
  • Tests have been added or updated (for bug fixes / features)
  • Docs have been added or updated (for bug fixes / features)
  • Changes target the main branch
  • PR title follows Conventional Commits

Additional 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 override ToString(), 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.

- 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
@sonarqubecloud

Copy link
Copy Markdown

@codecov

codecov Bot commented Aug 18, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.91%. Comparing base (1643323) to head (1bd3f50).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@glennawatson
glennawatson merged commit 96316a6 into main Aug 18, 2026
18 checks passed
@glennawatson
glennawatson deleted the fix/debugger-display-null-rendering branch August 18, 2026 14:39
@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown

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.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Sep 2, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: ApiResponse<T> shows null in the debugger if no content.

2 participants