Skip to content

Comments

Add xUnit V3 project variants for shared tests/tools other repos consume.#9876

Draft
MichaelSimons wants to merge 2 commits intodotnet:mainfrom
MichaelSimons:xunit-v3-packages
Draft

Add xUnit V3 project variants for shared tests/tools other repos consume.#9876
MichaelSimons wants to merge 2 commits intodotnet:mainfrom
MichaelSimons:xunit-v3-packages

Conversation

@MichaelSimons
Copy link
Member

Summary

Adds xUnit V3 versions of the TemplateVerifier, TemplateApiVerifier, and their test projects alongside the existing V2 versions. The V2 projects remain unchanged for external consumers. Introduces shared .props files across all V2/V3 project pairs (including the pre-existing Mocks and TestHelper) to minimize duplication.

New projects

Project Type Location
Microsoft.TemplateEngine.Authoring.TemplateVerifier.XunitV3 tools tools/
Microsoft.TemplateEngine.Authoring.TemplateApiVerifier.XunitV3 tools tools/
Microsoft.TemplateEngine.Authoring.TemplateVerifier.UnitTests.XunitV3 test test/
Microsoft.TemplateEngine.Authoring.TemplateVerifier.IntegrationTests.XunitV3 test test/

Approach

  • Shared .props files extract common PropertyGroup, PackageReference, and ProjectReference items so that V2 and V3 .csproj files only contain what differs (xunit package versions and XUNIT_V3 define).
  • V3 projects link source from V2 via <Compile Include> — no code duplication.
  • PublicAPI.*.txt files are shared via <AdditionalFiles> where the public API surface is identical (TemplateVerifier, TemplateApiVerifier). TestHelper keeps separate files due to xunit namespace differences.
  • #if !XUNIT_V3 conditionals added where xunit V2/V3 APIs differ:
    • Xunit.Abstractions → auto-imported in V3 (shared CommandUtils files, test files)
    • UseVerifyAttribute removed in Verify.XunitV3 (VerificationEngine.cs)

MichaelSimons and others added 2 commits February 23, 2026 17:48
Introduce new XunitV3 copies of the packable test infrastructure
assemblies (Microsoft.TemplateEngine.TestHelper.XunitV3 and
Microsoft.TemplateEngine.Mocks.XunitV3) to enable downstream repos
(sdk, aspnet, wpf) to incrementally adopt xUnit v3.

- Add xunit.v3 and Verify.XunitV3 package versions to Directory.Packages.props
- Add #if XUNIT_V3 preprocessor guards in shared source files where
  v2/v3 APIs differ (namespace changes, new ITestOutputHelper members,
  nullable GetValue returns)
- New .XunitV3 projects compile the same source with XUNIT_V3 defined
- Existing v2 projects remain unchanged

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…heir tests

Create XunitV3 duplicates of TemplateVerifier, TemplateApiVerifier,
and their UnitTests and IntegrationTests projects. Use shared .props
files to minimize duplication between V2 and V3 project definitions.

- Extract common properties, package refs, and project refs into
  Shared.props files for all 4 project pairs
- V3 projects link source from V2 via Compile Include and define
  XUNIT_V3 constant
- V3 TemplateVerifier uses Verify.XunitV3 + xunit.v3 packages
- V3 TemplateApiVerifier swaps project refs to V3 versions
  shared CommandUtils files and test source files
- V3 tools projects share PublicAPI.*.txt from V2 via AdditionalFiles

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