Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Suppression rules automatically suppress diagnostics from other analyzers (like Roslyn or Visual Studio threading analyzers) that don't apply in the context of MSTest tests.
Rules in this category
| Rule ID | Title | Suppresses |
|---|---|---|
| MSTEST0027 | Suppress async suffix for test methods. | VSTHRD200 |
| MSTEST0028 | Suppress async suffix for test fixture methods. | VSTHRD200 |
| MSTEST0033 | Suppress non-nullable reference not initialized. | CS8618 |
How suppression rules work
These rules don't produce their own diagnostics. Instead, they suppress warnings from other analyzers that would otherwise trigger incorrectly in test code.
VSTHRD200: Use Async suffix for async methods
Suppressed by: MSTEST0027, MSTEST0028
Why suppress: Visual Studio threading analyzer (VSTHRD200) recommends that async methods should have an "Async" suffix. However, test methods and test fixture methods are discovered by MSTest through attributes, not naming conventions. Adding "Async" suffixes to test method names (for example, TestLoginAsync) provides no value and can make test names less readable.
Example:
[TestMethod]
public async Task TestLogin() // VSTHRD200 would warn without suppression
{
await LoginAsync();
// ...
}
CS8618: Non-nullable reference not initialized
Suppressed by: MSTEST0033
Why suppress: When using nullable reference types, the compiler warns about non-nullable properties that aren't initialized in constructors. However, MSTest automatically initializes the TestContext property before any test methods run, so the warning doesn't apply.
Example:
[TestClass]
public class MyTests
{
public TestContext TestContext { get; set; } = null!; // CS8618 would warn without suppression
[TestMethod]
public void TestSomething()
{
// TestContext is guaranteed to be non-null here
TestContext.WriteLine("Test output");
}
}
Disable suppression rules
If you prefer to see these warnings, disable the suppression rules in your .editorconfig:
[*.cs]
dotnet_diagnostic.MSTEST0027.severity = none
dotnet_diagnostic.MSTEST0028.severity = none
dotnet_diagnostic.MSTEST0033.severity = none