-
Notifications
You must be signed in to change notification settings - Fork 291
Rework MSTEST0016 message and description #7258
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This pull request improves the clarity and helpfulness of the MSTEST0016 analyzer diagnostic message and description, addressing issue #5427. The analyzer detects test classes (marked with [TestClass]) that don't contain any test methods.
Changes:
- Rewrote the diagnostic message to be more explicit about the problem and provide actionable suggestions
- Expanded the description to include detailed explanation of what constitutes a test method, exceptions to the rule, and common scenarios where the rule triggers
- Updated all localization (.xlf) files with new source text and marked them for translation review
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/Analyzers/MSTest.Analyzers/Resources.resx | Updated the English diagnostic message and description for MSTEST0016 with clearer, more comprehensive text |
| src/Analyzers/MSTest.Analyzers/xlf/Resources.cs.xlf | Updated Czech localization file with new source text, marked for translation review |
| src/Analyzers/MSTest.Analyzers/xlf/Resources.de.xlf | Updated German localization file with new source text, marked for translation review |
| src/Analyzers/MSTest.Analyzers/xlf/Resources.es.xlf | Updated Spanish localization file with new source text, marked for translation review |
| src/Analyzers/MSTest.Analyzers/xlf/Resources.fr.xlf | Updated French localization file with new source text, marked for translation review |
| src/Analyzers/MSTest.Analyzers/xlf/Resources.it.xlf | Updated Italian localization file with new source text, marked for translation review |
| src/Analyzers/MSTest.Analyzers/xlf/Resources.ja.xlf | Updated Japanese localization file with new source text, marked for translation review |
| src/Analyzers/MSTest.Analyzers/xlf/Resources.ko.xlf | Updated Korean localization file with new source text, marked for translation review |
| src/Analyzers/MSTest.Analyzers/xlf/Resources.pl.xlf | Updated Polish localization file with new source text, marked for translation review |
| src/Analyzers/MSTest.Analyzers/xlf/Resources.pt-BR.xlf | Updated Brazilian Portuguese localization file with new source text, marked for translation review |
| src/Analyzers/MSTest.Analyzers/xlf/Resources.ru.xlf | Updated Russian localization file with new source text, marked for translation review |
| src/Analyzers/MSTest.Analyzers/xlf/Resources.tr.xlf | Updated Turkish localization file with new source text, marked for translation review |
| src/Analyzers/MSTest.Analyzers/xlf/Resources.zh-Hans.xlf | Updated Simplified Chinese localization file with new source text, marked for translation review |
| src/Analyzers/MSTest.Analyzers/xlf/Resources.zh-Hant.xlf | Updated Traditional Chinese localization file with new source text, marked for translation review |
| </data> | ||
| <data name="TestClassShouldHaveTestMethodMessageFormat" xml:space="preserve"> | ||
| <value>Test class '{0}' should have at least one test method or be 'static' with method(s) marked by '[AssemblyInitialize]' and/or '[AssemblyCleanup]'</value> | ||
| <value>Test class '{0}' does not contain any test method (method marked with '[TestMethod]'). Add a test method, or remove '[TestClass]' if this is a base class or not intended to be a test class.</value> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this message also suggest marking the class as static if it contains asm init/cleanup or global init/cleanup?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was wondering about it but thought it was better to keep the message short and have all cases in the description. Honestly I don't know if people use description or not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Description shows in IDE-only IIRC. So it's less observed by users.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shall I go for a long message with the static special case then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, what about having different messages based on the case we are reporting?
If we were able to detect a fixture, we produce a message that is more direct about marking the class as static. Otherwise, we produce a message about missing test methods.
That way, we can still have short messages, but be precise per the scenario we are reporting.
Attempts to fix #5427