Fix Verify snapshot naming for xunit v3 compatibility#10052
Merged
MichaelSimons merged 2 commits intodotnet:mainfrom Mar 25, 2026
Merged
Fix Verify snapshot naming for xunit v3 compatibility#10052MichaelSimons merged 2 commits intodotnet:mainfrom
MichaelSimons merged 2 commits intodotnet:mainfrom
Conversation
With MTP, Verify.XunitV3 auto-detects [Theory] parameters from the xUnit test context and appends them to snapshot file paths. This breaks snapshot matching because TemplateVerifier already manages naming uniqueness via ScenarioName. Switch from UseTypeName+UseMethodName to UseFileName which replaces the entire type+method+parameters naming, preventing Verify from appending auto-detected parameters regardless of test runner mode. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
baronfel
approved these changes
Mar 25, 2026
00522e6 to
721c2fe
Compare
721c2fe to
d49b839
Compare
MiYanni
approved these changes
Mar 25, 2026
mmitche
pushed a commit
to dotnet/sdk
that referenced
this pull request
Apr 2, 2026
…ing#10052) ## Summary `Verify.XunitV3` auto-detects `[Theory]` parameters from the xunit v3 test context and appends them to snapshot file paths. This breaks snapshot matching because TemplateVerifier already manages naming uniqueness via `ScenarioName`. It can also cause path-too-long errors, particularly in Helix where the directory structure is deeper. This is a behavioral difference between `Verify.Xunit` (xunit v2) and `Verify.XunitV3` (xunit v3) — the v2 package does not auto-append parameters, while the v3 package does regardless of test runner mode. ## Fix Switch from `UseTypeName` + `UseMethodName` to `UseFileName`, which replaces the entire type+method+parameters naming in a single call. This prevents Verify from appending auto-detected parameters. `UseFileName` is the only Verify API that fully controls the output path — there is no more targeted API to disable parameter auto-appending. Snapshot file names remain functionally identical; the parameters previously managed via `UseMethodName` are now pre-baked into the file name string. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Commit migrated from dotnet/templating@80848b3
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.
Summary
Verify.XunitV3auto-detects[Theory]parameters from the xunit v3 test context and appends them to snapshot file paths. This breaks snapshot matching because TemplateVerifier already manages naming uniqueness viaScenarioName. It can also cause path-too-long errors, particularly in Helix where the directory structure is deeper.This is a behavioral difference between
Verify.Xunit(xunit v2) andVerify.XunitV3(xunit v3) — the v2 package does not auto-append parameters, while the v3 package does regardless of test runner mode.Fix
Switch from
UseTypeName+UseMethodNametoUseFileName, which replaces the entire type+method+parameters naming in a single call. This prevents Verify from appending auto-detected parameters.UseFileNameis the only Verify API that fully controls the output path — there is no more targeted API to disable parameter auto-appending. Snapshot file names remain functionally identical; the parameters previously managed viaUseMethodNameare now pre-baked into the file name string.