Add regression test for #1191 (custom IProblemDetailsWriter preservation)#1192
Open
xavierjohn wants to merge 1 commit into
Open
Conversation
… 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>
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Adds a regression test guarding the behavior described in #1191.
Context
The
Rfc7231ProblemDetailsWriterwrapper /TryAddProblemDetailsRfc7231Complianceworkaround introduced in7b4cb60(shipped inAsp.Versioning.Http8.1.1) was removed for .NET 10 in9e5f4d34and is not in the releasedv10.0.0source or NuGet (verified by scanninglib/net10.0/Asp.Versioning.Http.dllfrom nuget.org for either symbol — neither is present). So the underlying bug from #1191 is already fixed onmain.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:AddProblemDetails()+ a custom singletonIProblemDetailsWriter.IProblemDetailsWriterServiceDescriptors.AddApiVersioning().Verified
dotnet test src/AspNetCore/WebApi/test/Asp.Versioning.Http.Tests→ 170/170 passing onmainwith the new test.9e5f4d34services.Replace-by-index workaround in a probe and confirmed the new assertion fails (SequenceEqualreturnsFalsebecause theDefaultProblemDetailsWriterdescriptor is replaced with a wrapper-factory descriptor), so the test does catch the original regression.Related