.editorconfig for Test projects/classes
Asked Answered
M

1

6

I'm using an .editorconfig file on a global level for the entire solution. This is working fine so far. The existing rules do work.

Now I want a rule for VSTHRD200 for my test projects and classes, I've added the following lines:

# Test projects
[{IntegrationTest.*,Test.*}.csproj]
dotnet_diagnostics.VSTHRD200.severity = none # VSTHRD200: Use "Async" suffix for async methods
dotnet_analyzer_diagnostic.VSTHRD200.severity = none # VSTHRD200: Use "Async" suffix for async methods

# Test classes
[Test*.cs]
dotnet_diagnostics.VSTHRD200.severity = none # VSTHRD200: Use "Async" suffix for async methods
dotnet_analyzer_diagnostic.VSTHRD200.severity = none # VSTHRD200: Use "Async" suffix for async methods

These rules do work in a way, that I do not see warnings in Output window. But these rules do not apply to the category-Style, means I do see curly lines for test methods, which do not have a Async suffix in editor.

I've added dotnet_analyzer_diagnostic.category-Style.severity = none like VS 2019 suggested and placed them under the section headers for test projects and classes, but I have the feeling, that it'll disable all styling rules.

Is there a way to only disable the styling for the VSTHRD200 error code?

Millet answered 12/5, 2021 at 6:24 Comment(0)
M
4

Late to the game, but for those like me who had this problem, this worked:

[*Test*.cs]
dotnet_diagnostic.VSTHRD200.severity = suggestion
dotnet_analyzer_diagnostic.VSTHRD200.severity = suggestion

The solution above was almost correct but there was an "s" to much: dotnet_diagnostics.VSTHRD200.severity = none # VSTHRD200: Use "Async" suffix for async methods

Madrepore answered 7/2, 2023 at 15:3 Comment(1)
Oh no, just the small typo made it fail? Thanks for your answer!Millet

© 2022 - 2024 — McMap. All rights reserved.