-
Notifications
You must be signed in to change notification settings - Fork 147
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
Disable VSTHRD200 for test methods #1315
Comments
There's a less strict option to only disable it in specific files. For example, if a convention is that all files containing tests end with [*Test.cs]
dotnet_diagnostic.VSTHRD200.severity = none This still has the issue that some methods may not be subject to the rule since not all methods in test files are test methods, but at least is not as bad as disabling it for entire project. Maybe the recommended test project .editorconfig file could be updated with this? |
MSTest added a diagnostic suppressor for this rule in its last release, see microsoft/testfx#2926 While this is nice, it shouldn't be necessary for each test framework to add a diagnostic suppressor. So I still think this issue should be fixed here. |
Interesting. I've never seen a diagnostic suppressor before. As for fixing it here or there, it's a toss-up. Either vs-threading has to hard-code knowledge of every test framework's attribute names, or each test framework has to hard-code knowledge of our analyzer in order to suppress it in some way. I don't know of a generally agreed upon precedent for resolving who should make the change. At the moment though, sure I could go either way. And it would be less work for one location to account for all the (known) test frameworks than for each test framework to make their own changes to suppress the analyzer. It's just a matter of time and which teams have it, because at the moment, this issue has mostly been left active because it's a reasonable proposal but we don't have time to fund it yet. |
We now have 3 suppressors (CA1515, CA2007, and as of today in a pre-release build, VSTHRD200). I definitely agree that there is zero end-user benefit to adding I don't feel like it should be the responsibility for vs-threading to look for exceptional situations across the universe of code; even if they wanted to, they shouldn't be responsible for determining the nuance of the implementation. Just to pick on us, you could look explicitly for As such, if I had a vote, I'd say you should close this. If you do, @cremor may want to open up an issue against NUnit, assuming they don't have a suppressor for this. |
Also, if you're interested, the implementation of the suppressor is actually pretty straight forward, as is the test: |
Good point, I'll close this issue. |
Is your feature request related to a problem? Please describe.
Test methods should not trigger VSTHRD200. But I also don't want to disable the rule for the whole test project like suggested in the recommended .editorconfig files.
Describe the solution you'd like
VSTHRD200 should ignore methods that have any of the following attributes applied:
[TestMethod]
(MSTest)[Fact]
(xUnit)[Test]
(NUnit)[Theory]
(xUnit and NUnit)When this is implemented the recommended .editorconfig files should be updated too.
Describe alternatives you've considered
Disabling VSTHRD200 for the whole test project, which I don't want.
The text was updated successfully, but these errors were encountered: