Skip to content

Fix MSTEST0082 follow-up gaps - #10637

Merged
Amaury Levé (Evangelink) merged 12 commits into
microsoft:mainfrom
Evangelink:dev/amauryleve/fix-mstest0082-followups
Aug 24, 2026
Merged

Amaury Levé (Evangelink) merged 12 commits into
microsoft:mainfrom
Evangelink:dev/amauryleve/fix-mstest0082-followups

Conversation

@Evangelink

Copy link
Copy Markdown
Member

Follow-up to #10508 addressing substantive review findings that remained after merge.

Changes

  • Resolve the active MSTest framework from each applied [TestClass], so aliased v3/v4 references no longer disable MSTEST0082.
  • Restrict canonical attribute detection to the known MSTest framework assemblies, avoiding false positives from namespace/name lookalikes.
  • Mirror adapter discovery for generic method definitions and invalid TestContext properties.
  • Share exact runtime TestContext property validation with DependsOnShouldBeValidAnalyzer.
  • Clarify remediation when a custom MSTest attribute is defined in a separate assembly.
  • Add regression coverage for aliased frameworks, legacy TestContext, lookalike attributes, uninferable generic tests, and separate custom-attribute libraries.

Validation

  • Targeted InheritedMemberFromDifferentMSTestVersionAnalyzerTests: 61 passed.
  • Full MSTest.Analyzers.UnitTests net8.0 suite: 1,788 passed.
  • Targeted project builds for net8.0 and net472 with 0 errors.

Resolve MSTest framework identity per test class, mirror adapter TestContext and generic discovery behavior, reject lookalike attributes, and clarify custom attribute remediation.

Co-authored-by: Copilot App <[email protected]>

Copilot-Session: 8aa70d5a-57df-47a6-b5dc-addbffedea90
Copilot AI balanced review requested due to automatic review settings August 18, 2026 11:13

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Improves MSTEST0082 accuracy across aliased frameworks, runtime discovery edge cases, and custom attributes.

Changes:

  • Resolve canonical MSTest attributes only from recognized framework assemblies.
  • Align generic-method and TestContext validation with adapter behavior.
  • Add regressions and clarify localized remediation guidance.
Show a summary per file
File Description
src/Analyzers/MSTest.Analyzers/InheritedMemberFromDifferentMSTestVersionAnalyzer.cs Refines framework and discovery detection.
src/Analyzers/MSTest.Analyzers/DependsOnShouldBeValidAnalyzer.cs Uses shared TestContext validation.
src/Analyzers/MSTest.Analyzers/Helpers/FixtureUtils.cs Adds shared runtime-compatible validation.
src/Analyzers/MSTest.Analyzers/Resources.resx Clarifies custom-attribute remediation.
src/Analyzers/MSTest.Analyzers/xlf/Resources.cs.xlf Synchronizes Czech localization source.
src/Analyzers/MSTest.Analyzers/xlf/Resources.de.xlf Synchronizes German localization source.
src/Analyzers/MSTest.Analyzers/xlf/Resources.es.xlf Synchronizes Spanish localization source.
src/Analyzers/MSTest.Analyzers/xlf/Resources.fr.xlf Synchronizes French localization source.
src/Analyzers/MSTest.Analyzers/xlf/Resources.it.xlf Synchronizes Italian localization source.
src/Analyzers/MSTest.Analyzers/xlf/Resources.ja.xlf Synchronizes Japanese localization source.
src/Analyzers/MSTest.Analyzers/xlf/Resources.ko.xlf Synchronizes Korean localization source.
src/Analyzers/MSTest.Analyzers/xlf/Resources.pl.xlf Synchronizes Polish localization source.
src/Analyzers/MSTest.Analyzers/xlf/Resources.pt-BR.xlf Synchronizes Portuguese localization source.
src/Analyzers/MSTest.Analyzers/xlf/Resources.ru.xlf Synchronizes Russian localization source.
src/Analyzers/MSTest.Analyzers/xlf/Resources.tr.xlf Synchronizes Turkish localization source.
src/Analyzers/MSTest.Analyzers/xlf/Resources.zh-Hans.xlf Synchronizes Simplified Chinese source.
src/Analyzers/MSTest.Analyzers/xlf/Resources.zh-Hant.xlf Synchronizes Traditional Chinese source.
test/UnitTests/MSTest.Analyzers.UnitTests/InheritedMemberFromDifferentMSTestVersionAnalyzerTests.cs Adds edge-case regression coverage.

Review details

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

  • Files reviewed: 18/18 changed files
  • Comments generated: 0
  • Review effort level: Balanced

@github-actions

Copy link
Copy Markdown
Contributor

🔴 Build failure analysis

Outcome: All 6 primary build legs (Linux Debug/Release, macOS Debug/Release, Windows Debug/Release) failed to compile with identical errors. Both Windows acceptance-test legs compiled cleanly (no errors), so the failure is isolated to the build/compile stage, not test execution.

Root cause

Two IDE code-style analyzer diagnostics are configured as build-breaking errors (EnforceCodeStyleInBuild/.editorconfig severity) and are triggered by this PR's new test-helper code in:

test/UnitTests/MSTest.Analyzers.UnitTests/InheritedMemberFromDifferentMSTestVersionAnalyzerTests.cs

Line Code Message
2896 IDE0022 Use expression body for method
2954 IDE0303 (×2) Collection initialization can be simplified

Both offending lines are new/modified in this PR (visible in the diff hunks @@ -2611,10 +2893,15 @@ and @@ -2658,6 +2945,41 @@), so this is not a pre-existing/flaky issue — it's introduced by the PR's added helper methods AddLegacyFrameworkBaseProject(SolutionState, string) and AddAliasedLegacyFrameworkBaseLibrary.

Suggested fixes

  1. Line 2896 — the method body is a single statement, so IDE0022 wants it expression-bodied:

    private static void AddLegacyFrameworkBaseProject(SolutionState testState, string libraryCode)
        => AddAdditionalProject(testState, LegacyFrameworkAssemblyName, libraryCode);
  2. Line 2954 — ImmutableArray.Create("legacy") can be simplified to a collection expression:

    legacyFramework.WithProperties(legacyFramework.Properties.WithAliases(["legacy"])));

See inline review comments for exact diff suggestions.

Build overview

  • All 6 build legs report the same 3 errors + a generic "Build failed." (Windows legs show each duplicated across two TFMs/configs in one binlog).
  • Both application-model acceptance-test legs (7_0, 7_1) show zero errors — confirming the compile failure, not a test/Helix issue, is the root cause.
  • Verified PR head SHA is unchanged (0af457a4aedefb6b66b2854bb46bc27fc44b980c) at time of posting.

🤖 Automated content by GitHub Copilot. Generated by the Build Failure Analysis workflow. · auto · 199.4 AIC · ⌖ 2.1 AIC · ⊞ 11.6K · [◷]( · ◷)

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Automated content by GitHub Copilot. Generated by the Build Failure Analysis workflow. · auto · 199.4 AIC · ⌖ 2.1 AIC · ⊞ 11.6K · ◷

Use repository-preferred expression bodies and collection expressions so the analyzer test project builds cleanly in CI.

Co-authored-by: Copilot App <[email protected]>

Copilot-Session: 8aa70d5a-57df-47a6-b5dc-addbffedea90
Copilot AI review requested due to automatic review settings August 24, 2026 08:46

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review details

Suppressed comments (1)

Previously missed (1) — in code that hasn't changed since the last review.

src/Analyzers/MSTest.Analyzers/InheritedMemberFromDifferentMSTestVersionAnalyzer.cs:83

  • This now relies exclusively on GetFrameworkAssembly, which returns only the first applied canonical [TestClass]. A class can legally apply both aliased v3 and v4 test-class attribute types; if the legacy one is listed first and the inherited member is legacy, no warning is emitted even though the v4 adapter recognizes the second v4 [TestClass] and silently skips that member. Analyze every distinct framework assembly represented by the applied test-class attributes (deduplicating diagnostics), and add a reversed-order dual-attribute regression test.
        IAssemblySymbol? referenceAssembly = GetFrameworkAssembly(classSymbol);
  • Files reviewed: 18/18 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

Prefer the current MSTest framework when both aliased v3 and v4 TestClass attributes are applied, independent of source attribute order.

Co-authored-by: Copilot App <[email protected]>

Copilot-Session: 8aa70d5a-57df-47a6-b5dc-addbffedea90
Copilot AI review requested due to automatic review settings August 24, 2026 09:28

Copilot AI commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

One or more custom setup steps configured for this repository failed during this Copilot code review run:

Build the repository

Setup steps run before each review. If the review above is missing context, or no review was posted at all, the failing step above may be the cause. See the workflow run for failure details, fix your setup steps configuration, and re-request a review.

Note

You can configure setup steps for Copilot code review separately from Copilot cloud agent with a copilot-code-review.yml file. Read the docs for details.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review details

  • Files reviewed: 18/18 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

Copilot AI review requested due to automatic review settings August 24, 2026 09:48
@Evangelink Amaury Levé (Evangelink) added the state/needs-review Awaiting review from the team. label Aug 24, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review details

  • Files reviewed: 18/18 changed files
  • Comments generated: 14
  • Review effort level: Balanced

Select the active MSTest framework through the global reference alias, cover both v3 and v4 alias arrangements, and repair duplicated localized MSTEST0082 units after the base merge.

Co-authored-by: Copilot App <[email protected]>

Copilot-Session: 8aa70d5a-57df-47a6-b5dc-addbffedea90
…-followups' into dev/amauryleve/fix-mstest0082-followups
Keep one current source and target for the updated MSTEST0082 message after integrating OneLoc translations.

Co-authored-by: Copilot App <[email protected]>

Copilot-Session: 8aa70d5a-57df-47a6-b5dc-addbffedea90
Copilot AI review requested due to automatic review settings August 24, 2026 10:07

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review details

  • Files reviewed: 18/18 changed files
  • Comments generated: 1
  • Review effort level: Balanced

Use an applied globally visible MSTest framework for discovery, and avoid diagnostics when only an aliased framework marks the class.

Co-authored-by: Copilot App <[email protected]>

Copilot-Session: 8aa70d5a-57df-47a6-b5dc-addbffedea90
Copilot AI review requested due to automatic review settings August 24, 2026 10:20

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review details

  • Files reviewed: 18/18 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

Use PortableExecutableReference.FilePath instead of descriptive MetadataReference.Display when locating the current framework reference.

Co-authored-by: Copilot App <[email protected]>

Copilot-Session: 8aa70d5a-57df-47a6-b5dc-addbffedea90
Copilot AI review requested due to automatic review settings August 24, 2026 11:35

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review details

Suppressed comments (1)

Previously missed (1) — in code that hasn't changed since the last review.

src/Analyzers/MSTest.Analyzers/Resources.resx:1257

  • The corrected remediation is only applied to the diagnostic message. InheritedMemberFromDifferentMSTestVersionDescription immediately below still says to recompile only the base assembly, which does not fix the new separate custom-attribute-library scenario because that attribute remains derived from the old framework type. Update the descriptor description with the same requirement and regenerate its XLIFF units so all user-facing forms give actionable guidance.
    <value>The inherited member '{1}.{0}' is annotated with a '[{2}]' attribute that resolves to a canonical MSTest attribute in '{3}', a different MSTest framework assembly than this test project uses; MSTest matches these attributes by exact type identity, so the inherited '[{2}]' is silently ignored at run time. Recompile the assembly that declares '{1}' and, for custom attributes, the assembly that defines '[{2}]', against the same MSTest version as the test project.</value>
  • Files reviewed: 18/18 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

Keep the descriptor description consistent with the diagnostic message when custom attributes are defined in a separate assembly.

Co-authored-by: Copilot App <[email protected]>

Copilot-Session: 8aa70d5a-57df-47a6-b5dc-addbffedea90
Copilot AI review requested due to automatic review settings August 24, 2026 11:48

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review details

  • Files reviewed: 18/18 changed files
  • Comments generated: 2
  • Review effort level: Balanced

Recognize TestContext from framework extensions and avoid scanning compilation references for source types without an applicable TestClass attribute.

Co-authored-by: Copilot App <[email protected]>

Copilot-Session: 8aa70d5a-57df-47a6-b5dc-addbffedea90
Copilot AI review requested due to automatic review settings August 24, 2026 12:02

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review details

  • Files reviewed: 18/18 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

@Evangelink
Amaury Levé (Evangelink) merged commit df20227 into microsoft:main Aug 24, 2026
47 of 50 checks passed
@Evangelink
Amaury Levé (Evangelink) deleted the dev/amauryleve/fix-mstest0082-followups branch August 24, 2026 13:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

state/needs-review Awaiting review from the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants