Skip to content
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

Document MSTestAnalysisMode property #44632

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Youssef1313
Copy link
Member

@Youssef1313 Youssef1313 commented Jan 31, 2025

@dotnetrepoman dotnetrepoman bot added this to the January 2025 milestone Jan 31, 2025
@dotnet-policy-service dotnet-policy-service bot added dotnet-fundamentals/svc community-contribution Indicates PR is created by someone from the .NET community. labels Jan 31, 2025
Comment on lines +45 to +52
> [!NOTE]
> The following rules are completely opt-in and are not enabled in `Default`, `Recommended`, or `All` modes:
>
> - [MSTEST0015: Test method should not be ignored](mstest0015.md)
> - [MSTEST0019: Prefer TestInitialize methods over constructors](mstest0019.md)
> - [MSTEST0020: Prefer constructors over TestInitialize methods](mstest0020.md)
> - [MSTEST0021: Prefer Dispose over TestCleanup methods](mstest0021.md)
> - [MSTEST0022: Prefer TestCleanup over Dispose methods](mstest0022.md)
Copy link
Member Author

Choose a reason for hiding this comment

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

Not sure where to best document this. Options:

  1. In this page only as I did in this PR
  2. In doc page of the specific analyzer, with only a note here mentioning "some rules" may have this behavior
  3. Both as I did here plus in the specific analyzer page.

Copy link
Member

Choose a reason for hiding this comment

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

Probably 3 but the specific analyzer page update can be done on a follow-up PR IMO.

@Youssef1313 Youssef1313 marked this pull request as ready for review January 31, 2025 10:21
@Youssef1313 Youssef1313 requested review from IEvangelist and a team as code owners January 31, 2025 10:21

### `Recommended`

This mode is more aggressive than `Default`. Rules that are enabled by default with Info (`suggestion`) severity are escalated to be warnings. Moreover, certain rules may decide that they are escalated to be errors in both `Recommended` and `All` modes. For example, [MSTEST0003: Test methods should have valid layout](mstest0003.md) is escalated to error in `Recommended` and `All` modes.
Copy link
Member

Choose a reason for hiding this comment

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

The first sentence could feel a little scary to users. I would instead say that in Default we are ensuring to not have rules that would cause warning or error and that don't result in runtime error. Recommended is what we think most dev should use but this means that a minor update of the package could cause new warnings.

Copy link
Member Author

Choose a reason for hiding this comment

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

Recommended is what we think most dev should use but this means that a minor update of the package could cause new warnings.

But a minor update can cause new warnings for "Default" as well?

Copy link
Member

Choose a reason for hiding this comment

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

Only for cases where there is an execution error. Otherwise we mark the new rules as info

- Rules that are enabled by default will use their default severity.
- Rules that are disabled by default will use `none` severity.

### `Recommended`
Copy link
Member

Choose a reason for hiding this comment

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

It might be a bit too boring to maintain the doc but it would probably be awesome if we could list here the rules enabled by this mode.

Copy link
Member Author

Choose a reason for hiding this comment

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

It's easy that it gets outdated, esp when changes happen between releases. I'm not sure how to best handle this. Maybe the generated globalconfigs we produce should be part of version control with CI check that ensures the file is up-to-date? In that case we can instruct users to go to the relevant release branch and look into the globalconfig exactly for the specific release. Alternatively, we can tell them that they can look into the NuGet package contents with NuGet Package Explorer and find the globalconfig there (it's less convenient though 😕)

I'm not really sure what's best.

Copy link
Member

Choose a reason for hiding this comment

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

Maybe we could generate a markdown per version and we would include it here.
@IEvangelist is this something that is common?

Comment on lines +45 to +52
> [!NOTE]
> The following rules are completely opt-in and are not enabled in `Default`, `Recommended`, or `All` modes:
>
> - [MSTEST0015: Test method should not be ignored](mstest0015.md)
> - [MSTEST0019: Prefer TestInitialize methods over constructors](mstest0019.md)
> - [MSTEST0020: Prefer constructors over TestInitialize methods](mstest0020.md)
> - [MSTEST0021: Prefer Dispose over TestCleanup methods](mstest0021.md)
> - [MSTEST0022: Prefer TestCleanup over Dispose methods](mstest0022.md)
Copy link
Member

Choose a reason for hiding this comment

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

Probably 3 but the specific analyzer page update can be done on a follow-up PR IMO.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community-contribution Indicates PR is created by someone from the .NET community. dotnet-fundamentals/svc
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Document MSTestAnalysisMode
2 participants