Repository navigation
Fix MSTEST0082 follow-up gaps - #10637
Amaury Levé (Evangelink) merged 12 commits into
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 <[email protected]> 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 · ◷
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
There was a problem hiding this comment.
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
…test0082-followups
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
|
One or more custom setup steps configured for this repository failed during this Copilot code review run: 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 |
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
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
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
There was a problem hiding this comment.
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.
InheritedMemberFromDifferentMSTestVersionDescriptionimmediately 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
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
df20227
into
microsoft:main
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.