Skip to content

Add regression test for #1191 (custom IProblemDetailsWriter preservation)#1192

Open
xavierjohn wants to merge 1 commit into
dotnet:mainfrom
xavierjohn:xavierjohn/test/1191-problem-details-writer-regression
Open

Add regression test for #1191 (custom IProblemDetailsWriter preservation)#1192
xavierjohn wants to merge 1 commit into
dotnet:mainfrom
xavierjohn:xavierjohn/test/1191-problem-details-writer-regression

Conversation

@xavierjohn

Copy link
Copy Markdown
Collaborator

Adds a regression test guarding the behavior described in #1191.

Context

The Rfc7231ProblemDetailsWriter wrapper / TryAddProblemDetailsRfc7231Compliance workaround introduced in 7b4cb60 (shipped in Asp.Versioning.Http 8.1.1) was removed for .NET 10 in 9e5f4d34 and is not in the released v10.0.0 source or NuGet (verified by scanning lib/net10.0/Asp.Versioning.Http.dll from nuget.org for either symbol — neither is present). So the underlying bug from #1191 is already fixed on main.

However, there was no test guarding against the workaround being reintroduced, so a future change could silently regress the behavior again.

Change

One new test in IServiceCollectionExtensionsTest:

  • Registers AddProblemDetails() + a custom singleton IProblemDetailsWriter.
  • Snapshots all IProblemDetailsWriter ServiceDescriptors.
  • Calls AddApiVersioning().
  • Asserts the snapshot is unchanged and that the exact custom writer instance is still resolved from DI.

Verified

  • dotnet test src/AspNetCore/WebApi/test/Asp.Versioning.Http.Tests → 170/170 passing on main with the new test.
  • Manually re-introduced the pre-9e5f4d34 services.Replace-by-index workaround in a probe and confirmed the new assertion fails (SequenceEqual returns False because the DefaultProblemDetailsWriter descriptor is replaced with a wrapper-factory descriptor), so the test does catch the original regression.

Related

… preserved by AddApiVersioning. Related to dotnet#1191

The Rfc7231ProblemDetailsWriter wrapper introduced in 7b4cb60 (released in
8.1.1) was removed for .NET 10 in 9e5f4d3 and is no longer in v10.0.0, but
the repo had no test guarding against reintroduction.

This test snapshots the IProblemDetailsWriter descriptors after registering
AddProblemDetails() and a custom singleton writer, then calls AddApiVersioning()
and asserts the sequence of writer descriptors is unchanged and the custom
instance is still resolvable from DI. Verified the assertion fails when the
old in-place replace workaround is reintroduced.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant