Fix MSTEST0082 follow-up gaps - #10637
Conversation
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 <223556219+Copilot@users.noreply.github.com> Copilot-Session: 8aa70d5a-57df-47a6-b5dc-addbffedea90
There was a problem hiding this comment.
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
TestContextvalidation 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
🔴 Build failure analysisOutcome: 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 causeTwo IDE code-style analyzer diagnostics are configured as build-breaking errors (
Both offending lines are new/modified in this PR (visible in the diff hunks Suggested fixes
See inline review comments for exact diff suggestions. Build overview
|
There was a problem hiding this comment.
🤖 Automated content by GitHub Copilot. Generated by the Build Failure Analysis workflow. · auto · 199.4 AIC · ⌖ 2.1 AIC · ⊞ 11.6K · ◷
| libraryProject.Sources.Add(("LegacyBase.cs", libraryCode)); | ||
| testState.AdditionalProjects.Add(LegacyFrameworkAssemblyName, libraryProject); | ||
| testState.AdditionalProjectReferences.Add(LegacyFrameworkAssemblyName); | ||
| AddAdditionalProject(testState, LegacyFrameworkAssemblyName, libraryCode); |
There was a problem hiding this comment.
Build error (IDE0022 — Use expression body for method): this single-statement method body is flagged as a build-breaking code-style violation in CI (all 6 build legs failed on this).
| AddAdditionalProject(testState, LegacyFrameworkAssemblyName, libraryCode); | |
| private static void AddLegacyFrameworkBaseProject(SolutionState testState, string libraryCode) | |
| => AddAdditionalProject(testState, LegacyFrameworkAssemblyName, libraryCode); |
| MetadataReference baseLibrary = EmitAssembly("BaseLibrary", baseLibraryCode, legacyFramework); | ||
|
|
||
| test.TestState.AdditionalReferences.Add( | ||
| legacyFramework.WithProperties(legacyFramework.Properties.WithAliases(ImmutableArray.Create("legacy")))); |
There was a problem hiding this comment.
Build error (IDE0303 — Collection initialization can be simplified): ImmutableArray.Create("legacy") triggers a build-breaking code-style diagnostic. Simplify to a collection expression:
| legacyFramework.WithProperties(legacyFramework.Properties.WithAliases(ImmutableArray.Create("legacy")))); | |
| legacyFramework.WithProperties(legacyFramework.Properties.WithAliases(["legacy"]))); |
Follow-up to #10508 addressing substantive review findings that remained after merge.
Changes
[TestClass], so aliased v3/v4 references no longer disable MSTEST0082.TestContextproperties.TestContextproperty validation withDependsOnShouldBeValidAnalyzer.TestContext, lookalike attributes, uninferable generic tests, and separate custom-attribute libraries.Validation
InheritedMemberFromDifferentMSTestVersionAnalyzerTests: 61 passed.MSTest.Analyzers.UnitTestsnet8.0 suite: 1,788 passed.