Skip to content

VSTHRD200 should not trigger on test methods #670

Closed

Description

@NN---

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.

Activity

  1. AArnott commented on Sep 10, 2020

    @AArnott
    Member

    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?

  2. NN--- commented on Sep 10, 2020

    @NN---
    Author

    Found solution

    [*Tests/*]
    Suppress 
    
  3. jmevel commented on Mar 15, 2024

    @jmevel

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions