From fe6e82bd975ac7d8c36b4667161de13ac97ede66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Amaury=20Lev=C3=A9?= Date: Sun, 28 Jun 2026 22:30:29 +0200 Subject: [PATCH 1/2] Refactor analyzer/report-engine duplication and MSBuild authoring (#9483, #9482, #9467, #9414) - #9483: extract RegisterInstanceFixtureAnalyzer helper shared by TestInitialize/TestCleanup analyzers - #9482: bundle report-engine dependencies into ReportEngineContext + CreateEngineContext factory - #9467: reclassify MSTEST0067 to Category.Performance, document Category taxonomy, add governance tests - #9414: declare Returns on GetMSTestV2CultureHierarchy; move _ValidateBundledSdkFeatureVersions target from Directory.Packages.props to Directory.Build.targets Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- Directory.Build.targets | 18 ++++++++++++ Directory.Packages.props | 18 ++---------- .../common/MSTest.TestAdapter.targets | 2 +- .../uwp/MSTest.TestAdapter.targets | 2 +- ...idThreadSleepAndTaskWaitInTestsAnalyzer.cs | 2 +- .../MSTest.Analyzers/Helpers/Category.cs | 12 ++++++-- .../Helpers/FixtureMethodAnalyzerHelper.cs | 15 ++++++++++ .../TestCleanupShouldBeValidAnalyzer.cs | 4 +-- .../TestInitializeShouldBeValidAnalyzer.cs | 4 +-- .../CtrfReportEngine.cs | 5 ++++ .../CtrfReportGenerator.cs | 12 +------- ...osoft.Testing.Extensions.CtrfReport.csproj | 1 + .../HtmlReportEngine.cs | 5 ++++ .../HtmlReportGenerator.cs | 12 +------- ...osoft.Testing.Extensions.HtmlReport.csproj | 1 + .../JUnitReportEngine.cs | 5 ++++ .../JUnitReportGenerator.cs | 12 +------- ...soft.Testing.Extensions.JUnitReport.csproj | 1 + ...rosoft.Testing.Extensions.TrxReport.csproj | 1 + .../ReportEngineBase.cs | 15 ++++++++++ .../ReportEngineContext.cs | 28 +++++++++++++++++++ .../ReportGeneratorBase.cs | 18 ++++++++++++ .../AnalyzerCategoryGovernanceTests.cs | 25 +++++++++++++++++ 23 files changed, 160 insertions(+), 58 deletions(-) create mode 100644 src/Platform/SharedExtensionHelpers/ReportEngineContext.cs create mode 100644 test/UnitTests/MSTest.Analyzers.UnitTests/AnalyzerCategoryGovernanceTests.cs diff --git a/Directory.Build.targets b/Directory.Build.targets index d079454d8d..c3a33c3ba3 100644 --- a/Directory.Build.targets +++ b/Directory.Build.targets @@ -64,4 +64,22 @@ + + + + + <_AspireHostingTestingPackageVersion>@(PackageVersion->WithMetadataValue('Identity', 'Aspire.Hosting.Testing')->'%(Version)') + <_MicrosoftPlaywrightPackageVersion>@(PackageVersion->WithMetadataValue('Identity', 'Microsoft.Playwright.MSTest.v4')->'%(Version)') + + + + diff --git a/Directory.Packages.props b/Directory.Packages.props index e211c40dc3..a7b98f913b 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -164,24 +164,12 @@ template (see MSTest.Sdk.csproj). The two cannot be unified because the consuming property must be a plain scalar (an item transform such as @(PackageVersion->...) stored in a property is not expanded and breaks string concatenation, e.g. MSB4012), while Dependabot needs the literal on - the PackageVersion. The _ValidateBundledSdkFeatureVersions target below fails the build if the - property and the PackageVersion ever drift apart (e.g. after Dependabot bumps only the - PackageVersion), so the duplication can never ship out of sync. + the PackageVersion. The _ValidateBundledSdkFeatureVersions target (in Directory.Build.targets) + fails the build if the property and the PackageVersion ever drift apart (e.g. after Dependabot + bumps only the PackageVersion), so the duplication can never ship out of sync. --> - - - <_AspireHostingTestingPackageVersion>@(PackageVersion->WithMetadataValue('Identity', 'Aspire.Hosting.Testing')->'%(Version)') - <_MicrosoftPlaywrightPackageVersion>@(PackageVersion->WithMetadataValue('Identity', 'Microsoft.Playwright.MSTest.v4')->'%(Version)') - - - - diff --git a/src/Adapter/MSTest.TestAdapter/buildTransitive/common/MSTest.TestAdapter.targets b/src/Adapter/MSTest.TestAdapter/buildTransitive/common/MSTest.TestAdapter.targets index e524698986..04cfa32158 100644 --- a/src/Adapter/MSTest.TestAdapter/buildTransitive/common/MSTest.TestAdapter.targets +++ b/src/Adapter/MSTest.TestAdapter/buildTransitive/common/MSTest.TestAdapter.targets @@ -46,7 +46,7 @@ Rooting - +