Repository navigation
Add diagnostic for TestClass on abstract classes - #11240
Merged
Amaury Levé (Evangelink) merged 1 commit intoSep 13, 2026
Merged
Amaury Levé (Evangelink) merged 1 commit into
Amaury Levé (Evangelink) merged 1 commit into
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
No unresolved issues were identified that would block approval.
Review tier: Lite (auto)
Findings: None
Note
Copilot is running an experiment and ran this review at Lite.
What changed in this PR
Adds MSTEST0085 to flag [TestClass] on non-static abstract classes, where it has no discovery effect.
Changes:
- Implements the enabled Info-level analyzer and release tracking.
- Adds C#, record, custom-attribute, VB, and non-diagnostic tests.
- Adds resource and localization entries.
| File | Description |
|---|---|
| test/UnitTests/MSTest.Analyzers.UnitTests/TestClassAttributeShouldNotBeAppliedToAbstractClassAnalyzerTests.cs | Updated as part of this pull request. |
| src/Analyzers/MSTest.Analyzers/xlf/Resources.zh-Hant.xlf | Updated as part of this pull request. |
| src/Analyzers/MSTest.Analyzers/xlf/Resources.zh-Hans.xlf | Updated as part of this pull request. |
| src/Analyzers/MSTest.Analyzers/xlf/Resources.tr.xlf | Updated as part of this pull request. |
| src/Analyzers/MSTest.Analyzers/xlf/Resources.ru.xlf | Updated as part of this pull request. |
| src/Analyzers/MSTest.Analyzers/xlf/Resources.pt-BR.xlf | Updated as part of this pull request. |
| src/Analyzers/MSTest.Analyzers/xlf/Resources.pl.xlf | Updated as part of this pull request. |
| src/Analyzers/MSTest.Analyzers/xlf/Resources.ko.xlf | Updated as part of this pull request. |
| src/Analyzers/MSTest.Analyzers/xlf/Resources.ja.xlf | Updated as part of this pull request. |
| src/Analyzers/MSTest.Analyzers/xlf/Resources.it.xlf | Updated as part of this pull request. |
| src/Analyzers/MSTest.Analyzers/xlf/Resources.fr.xlf | Updated as part of this pull request. |
| src/Analyzers/MSTest.Analyzers/xlf/Resources.es.xlf | Updated as part of this pull request. |
| src/Analyzers/MSTest.Analyzers/xlf/Resources.de.xlf | Updated as part of this pull request. |
| src/Analyzers/MSTest.Analyzers/xlf/Resources.cs.xlf | Updated as part of this pull request. |
| src/Analyzers/MSTest.Analyzers/TestClassAttributeShouldNotBeAppliedToAbstractClassAnalyzer.cs | Updated as part of this pull request. |
| src/Analyzers/MSTest.Analyzers/Resources.resx | Updated as part of this pull request. |
| src/Analyzers/MSTest.Analyzers/Helpers/DiagnosticIds.cs | Updated as part of this pull request. |
| src/Analyzers/MSTest.Analyzers/AnalyzerReleases.Unshipped.md | Updated as part of this pull request. |
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Amaury Levé (Evangelink)
enabled auto-merge (squash)
September 13, 2026 14:31
Petr Pokorny (0101)
approved these changes
Sep 13, 2026
Amaury Levé (Evangelink)
deleted the
dev/amauryleve/report-abstract-testclass-diagnostic
branch
September 13, 2026 14:50
This was referenced Sep 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Applying
[TestClass]to an abstract class is misleading because MSTest skips abstract types during discovery. Tests declared by the base are discovered through concrete derived test classes, which must declare their own[TestClass]attribute.Changes
[TestClass]and derived attributes applied to non-static abstract classes.MustInheritclasses, and non-diagnostic cases.Testing
build.cmd -projects test\UnitTests\MSTest.Analyzers.UnitTests\MSTest.Analyzers.UnitTests.csproj -binaryLogTestClassAttributeShouldNotBeAppliedToAbstractClassAnalyzerTestspassed onnet8.0.Fixes: #11236