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

VSTHRD200 should not trigger on test methods #670

Closed
NN--- opened this issue Sep 10, 2020 · 3 comments
Closed

VSTHRD200 should not trigger on test methods #670

NN--- opened this issue Sep 10, 2020 · 3 comments

Comments

@NN---
Copy link

NN--- commented Sep 10, 2020

Is your feature request related to a problem? Please describe.

Asynchronous unit test methods don't need Async suffix.

public class ATests
{
  [Test]
  public async F() // VSTHRD200
  {
    A a = new A();
    Assert.True(await a.T);
  }
}

Describe the solution you'd like

Either detect this automatically or add some exclusion rule.
For instance class ends with Tests.

Describe alternatives you've considered

I do not want to disable it completely in the solution.
It is possible to suppress it in Unit Tests projects but this is not scalable.

Additional context

Add any other context or screenshots about the feature request here.

@AArnott
Copy link
Member

AArnott commented Sep 10, 2020

It is possible to suppress it in Unit Tests projects but this is not scalable.

It is indeed suppressible. This can be done via the msbuild NoWarn property, a .ruleset file, an .editorconfig file, or #pragma to name several. Why isn't this scalable?

@NN---
Copy link
Author

NN--- commented Sep 10, 2020

Found solution

[*Tests/*]
Suppress 

@jmevel
Copy link

jmevel commented Mar 15, 2024

Found solution

[*Tests/*]
Suppress 

Wait... Could you give a full example of this "Suppress"?
Where do you even configure this?

This looks interesting so I'd like to know more.
Thanks 🙏

EDIT: nevermind, I didn't realize the .editorconfig filtering feature can actually be used like this

[*{Controller,StepDefinition,Tests}.cs]
dotnet_diagnostic.VSTHRD200.severity = none
dotnet_analyzer_diagnostic.VSTHRD200.severity = none

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants