Skip to content

Commit

Permalink
MSTest analyzers: document suppressing warning (#44277)
Browse files Browse the repository at this point in the history
* MSTest analyzers: document suppressing warning

* Suppressors cannot be suppressed
  • Loading branch information
Evangelink authored Jan 17, 2025
1 parent 58988ce commit 462d811
Show file tree
Hide file tree
Showing 37 changed files with 643 additions and 3 deletions.
13 changes: 13 additions & 0 deletions docs/core/testing/mstest-analyzers/mstest0001.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,16 @@ To fix a violation of this rule, add `[assembly: Parallelize]` or `[assembly: Do
## When to suppress warnings

Do not suppress a warning from this rule. Many libraries can benefit from a massive performance boost when enabling parallelization. When the test application is designed in a way that prevents parallelization, having the attribute explicitly set helps new developers to understand the limitations of the library.

## Suppress a warning

Violations to this rule cannot be suppressed inline.

To disable the rule for a file, folder, or project, set its severity to `none` in the [configuration file](../../../fundamentals/code-analysis/configuration-files.md).

```ini
[*.{cs,vb}]
dotnet_diagnostic.MSTEST0001.severity = none
```

For more information, see [How to suppress code analysis warnings](../../../fundamentals/code-analysis/suppress-warnings.md).
19 changes: 19 additions & 0 deletions docs/core/testing/mstest-analyzers/mstest0002.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,22 @@ Ensure that the class matches the required layout described above.
## When to suppress warnings

Do not suppress a warning from this rule. Ignoring this rule will result in tests being ignored, because MSTest will not consider this class to be a test class.

## Suppress a warning

If you just want to suppress a single violation, add preprocessor directives to your source file to disable and then re-enable the rule.

```csharp
#pragma warning disable MSTEST0002
// The code that's violating the rule is on this line.
#pragma warning restore MSTEST0002
```

To disable the rule for a file, folder, or project, set its severity to `none` in the [configuration file](../../../fundamentals/code-analysis/configuration-files.md).

```ini
[*.{cs,vb}]
dotnet_diagnostic.MSTEST0002.severity = none
```

For more information, see [How to suppress code analysis warnings](../../../fundamentals/code-analysis/suppress-warnings.md).
19 changes: 19 additions & 0 deletions docs/core/testing/mstest-analyzers/mstest0003.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,22 @@ Ensure that the test method matches the required layout described above.
## When to suppress warnings

Do not suppress a warning from this rule. Ignoring this rule will result in tests being ignored, because MSTest will not consider this method to be a test method.

## Suppress a warning

If you just want to suppress a single violation, add preprocessor directives to your source file to disable and then re-enable the rule.

```csharp
#pragma warning disable MSTEST0003
// The code that's violating the rule is on this line.
#pragma warning restore MSTEST0003
```

To disable the rule for a file, folder, or project, set its severity to `none` in the [configuration file](../../../fundamentals/code-analysis/configuration-files.md).

```ini
[*.{cs,vb}]
dotnet_diagnostic.MSTEST0003.severity = none
```

For more information, see [How to suppress code analysis warnings](../../../fundamentals/code-analysis/suppress-warnings.md).
19 changes: 19 additions & 0 deletions docs/core/testing/mstest-analyzers/mstest0004.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,22 @@ Change the accessibility of the type to not be `public`.
## When to suppress warnings

You can suppress instances of this diagnostic if the type should remain `public` for compatibility reason.

## Suppress a warning

If you just want to suppress a single violation, add preprocessor directives to your source file to disable and then re-enable the rule.

```csharp
#pragma warning disable MSTEST0004
// The code that's violating the rule is on this line.
#pragma warning restore MSTEST0004
```

To disable the rule for a file, folder, or project, set its severity to `none` in the [configuration file](../../../fundamentals/code-analysis/configuration-files.md).

```ini
[*.{cs,vb}]
dotnet_diagnostic.MSTEST0004.severity = none
```

For more information, see [How to suppress code analysis warnings](../../../fundamentals/code-analysis/suppress-warnings.md).
19 changes: 19 additions & 0 deletions docs/core/testing/mstest-analyzers/mstest0005.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,22 @@ Ensure that the `TestContext` property matches the required layout described abo
## When to suppress warnings

Do not suppress a warning from this rule. Ignoring this rule will result in the `TestContext` not being injected by MSTest, thus resulting in `NullReferenceException` or inconsistent state when using the property.

## Suppress a warning

If you just want to suppress a single violation, add preprocessor directives to your source file to disable and then re-enable the rule.

```csharp
#pragma warning disable MSTEST0005
// The code that's violating the rule is on this line.
#pragma warning restore MSTEST0005
```

To disable the rule for a file, folder, or project, set its severity to `none` in the [configuration file](../../../fundamentals/code-analysis/configuration-files.md).

```ini
[*.{cs,vb}]
dotnet_diagnostic.MSTEST0005.severity = none
```

For more information, see [How to suppress code analysis warnings](../../../fundamentals/code-analysis/suppress-warnings.md).
19 changes: 19 additions & 0 deletions docs/core/testing/mstest-analyzers/mstest0006.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,22 @@ public class TestClass
}
}
```

## Suppress a warning

If you just want to suppress a single violation, add preprocessor directives to your source file to disable and then re-enable the rule.

```csharp
#pragma warning disable MSTEST0006
// The code that's violating the rule is on this line.
#pragma warning restore MSTEST0006
```

To disable the rule for a file, folder, or project, set its severity to `none` in the [configuration file](../../../fundamentals/code-analysis/configuration-files.md).

```ini
[*.{cs,vb}]
dotnet_diagnostic.MSTEST0006.severity = none
```

For more information, see [How to suppress code analysis warnings](../../../fundamentals/code-analysis/suppress-warnings.md).
19 changes: 19 additions & 0 deletions docs/core/testing/mstest-analyzers/mstest0007.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,22 @@ To fix a violation of this rule, either convert the method on which you applied
## When to suppress warnings

Do not suppress a warning from this rule. If you ignore this rule, your attributes will be ignored since they are designed for use only in a test context.

## Suppress a warning

If you just want to suppress a single violation, add preprocessor directives to your source file to disable and then re-enable the rule.

```csharp
#pragma warning disable MSTEST0007
// The code that's violating the rule is on this line.
#pragma warning restore MSTEST0007
```

To disable the rule for a file, folder, or project, set its severity to `none` in the [configuration file](../../../fundamentals/code-analysis/configuration-files.md).

```ini
[*.{cs,vb}]
dotnet_diagnostic.MSTEST0007.severity = none
```

For more information, see [How to suppress code analysis warnings](../../../fundamentals/code-analysis/suppress-warnings.md).
19 changes: 19 additions & 0 deletions docs/core/testing/mstest-analyzers/mstest0008.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,22 @@ Ensure that the method matches the layout described above.
## When to suppress warnings

Do not suppress a warning from this rule. If you ignore this rule, flagged instances will be either skipped or result in runtime error.

## Suppress a warning

If you just want to suppress a single violation, add preprocessor directives to your source file to disable and then re-enable the rule.

```csharp
#pragma warning disable MSTEST0008
// The code that's violating the rule is on this line.
#pragma warning restore MSTEST0008
```

To disable the rule for a file, folder, or project, set its severity to `none` in the [configuration file](../../../fundamentals/code-analysis/configuration-files.md).

```ini
[*.{cs,vb}]
dotnet_diagnostic.MSTEST0008.severity = none
```

For more information, see [How to suppress code analysis warnings](../../../fundamentals/code-analysis/suppress-warnings.md).
19 changes: 19 additions & 0 deletions docs/core/testing/mstest-analyzers/mstest0009.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,22 @@ Ensure that the method matches the layout described above.
## When to suppress warnings

Do not suppress a warning from this rule. If you ignore this rule, flagged instances will be either skipped or result in runtime error.

## Suppress a warning

If you just want to suppress a single violation, add preprocessor directives to your source file to disable and then re-enable the rule.

```csharp
#pragma warning disable MSTEST0009
// The code that's violating the rule is on this line.
#pragma warning restore MSTEST0009
```

To disable the rule for a file, folder, or project, set its severity to `none` in the [configuration file](../../../fundamentals/code-analysis/configuration-files.md).

```ini
[*.{cs,vb}]
dotnet_diagnostic.MSTEST0009.severity = none
```

For more information, see [How to suppress code analysis warnings](../../../fundamentals/code-analysis/suppress-warnings.md).
19 changes: 19 additions & 0 deletions docs/core/testing/mstest-analyzers/mstest0010.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,22 @@ Ensure that the method matches the layout described above.
## When to suppress warnings

Do not suppress a warning from this rule. If you ignore this rule, flagged instances will be either skipped or result in runtime error.

## Suppress a warning

If you just want to suppress a single violation, add preprocessor directives to your source file to disable and then re-enable the rule.

```csharp
#pragma warning disable MSTEST0010
// The code that's violating the rule is on this line.
#pragma warning restore MSTEST0010
```

To disable the rule for a file, folder, or project, set its severity to `none` in the [configuration file](../../../fundamentals/code-analysis/configuration-files.md).

```ini
[*.{cs,vb}]
dotnet_diagnostic.MSTEST0010.severity = none
```

For more information, see [How to suppress code analysis warnings](../../../fundamentals/code-analysis/suppress-warnings.md).
19 changes: 19 additions & 0 deletions docs/core/testing/mstest-analyzers/mstest0011.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,22 @@ Ensure that the method matches the layout described above.
## When to suppress warnings

Do not suppress a warning from this rule. If you ignore this rule, flagged instances will be either skipped or result in runtime error.

## Suppress a warning

If you just want to suppress a single violation, add preprocessor directives to your source file to disable and then re-enable the rule.

```csharp
#pragma warning disable MSTEST0011
// The code that's violating the rule is on this line.
#pragma warning restore MSTEST0011
```

To disable the rule for a file, folder, or project, set its severity to `none` in the [configuration file](../../../fundamentals/code-analysis/configuration-files.md).

```ini
[*.{cs,vb}]
dotnet_diagnostic.MSTEST0011.severity = none
```

For more information, see [How to suppress code analysis warnings](../../../fundamentals/code-analysis/suppress-warnings.md).
19 changes: 19 additions & 0 deletions docs/core/testing/mstest-analyzers/mstest0012.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,22 @@ Ensure that the method matches the layout described above.
## When to suppress warnings

Do not suppress a warning from this rule. If you ignore this rule, flagged instances will be either skipped or result in runtime error.

## Suppress a warning

If you just want to suppress a single violation, add preprocessor directives to your source file to disable and then re-enable the rule.

```csharp
#pragma warning disable MSTEST0012
// The code that's violating the rule is on this line.
#pragma warning restore MSTEST0012
```

To disable the rule for a file, folder, or project, set its severity to `none` in the [configuration file](../../../fundamentals/code-analysis/configuration-files.md).

```ini
[*.{cs,vb}]
dotnet_diagnostic.MSTEST0012.severity = none
```

For more information, see [How to suppress code analysis warnings](../../../fundamentals/code-analysis/suppress-warnings.md).
19 changes: 19 additions & 0 deletions docs/core/testing/mstest-analyzers/mstest0013.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,22 @@ Ensure that the method matches the layout described above.
## When to suppress warnings

Do not suppress a warning from this rule. If you ignore this rule, flagged instances will be either skipped or result in runtime error.

## Suppress a warning

If you just want to suppress a single violation, add preprocessor directives to your source file to disable and then re-enable the rule.

```csharp
#pragma warning disable MSTEST0013
// The code that's violating the rule is on this line.
#pragma warning restore MSTEST0013
```

To disable the rule for a file, folder, or project, set its severity to `none` in the [configuration file](../../../fundamentals/code-analysis/configuration-files.md).

```ini
[*.{cs,vb}]
dotnet_diagnostic.MSTEST0013.severity = none
```

For more information, see [How to suppress code analysis warnings](../../../fundamentals/code-analysis/suppress-warnings.md).
19 changes: 19 additions & 0 deletions docs/core/testing/mstest-analyzers/mstest0014.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,22 @@ Ensure that the `DataRow` instance matches the required layout described above.
## When to suppress warnings

Do not suppress a warning from this rule. If you ignore this rule, flagged instances will be either skipped or result in runtime error.

## Suppress a warning

If you just want to suppress a single violation, add preprocessor directives to your source file to disable and then re-enable the rule.

```csharp
#pragma warning disable MSTEST0014
// The code that's violating the rule is on this line.
#pragma warning restore MSTEST0014
```

To disable the rule for a file, folder, or project, set its severity to `none` in the [configuration file](../../../fundamentals/code-analysis/configuration-files.md).

```ini
[*.{cs,vb}]
dotnet_diagnostic.MSTEST0014.severity = none
```

For more information, see [How to suppress code analysis warnings](../../../fundamentals/code-analysis/suppress-warnings.md).
19 changes: 19 additions & 0 deletions docs/core/testing/mstest-analyzers/mstest0015.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,22 @@ Ensure that the test method isn't ignored.
## When to suppress warnings

Do not suppress a warning from this rule. If you ignore this rule, test method will be ignored.

## Suppress a warning

If you just want to suppress a single violation, add preprocessor directives to your source file to disable and then re-enable the rule.

```csharp
#pragma warning disable MSTEST0015
// The code that's violating the rule is on this line.
#pragma warning restore MSTEST0015
```

To disable the rule for a file, folder, or project, set its severity to `none` in the [configuration file](../../../fundamentals/code-analysis/configuration-files.md).

```ini
[*.{cs,vb}]
dotnet_diagnostic.MSTEST0015.severity = none
```

For more information, see [How to suppress code analysis warnings](../../../fundamentals/code-analysis/suppress-warnings.md).
19 changes: 19 additions & 0 deletions docs/core/testing/mstest-analyzers/mstest0016.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,22 @@ Ensure that the test class has a test method or is `static` and has methods attr
## When to suppress warnings

Do not suppress a warning from this rule. If you ignore this rule, test class will be ignored.

## Suppress a warning

If you just want to suppress a single violation, add preprocessor directives to your source file to disable and then re-enable the rule.

```csharp
#pragma warning disable MSTEST0016
// The code that's violating the rule is on this line.
#pragma warning restore MSTEST0016
```

To disable the rule for a file, folder, or project, set its severity to `none` in the [configuration file](../../../fundamentals/code-analysis/configuration-files.md).

```ini
[*.{cs,vb}]
dotnet_diagnostic.MSTEST0016.severity = none
```

For more information, see [How to suppress code analysis warnings](../../../fundamentals/code-analysis/suppress-warnings.md).
19 changes: 19 additions & 0 deletions docs/core/testing/mstest-analyzers/mstest0017.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,22 @@ Ensure that that `actual` and `expected`/`notExpected` arguments are passed in t
## When to suppress warnings

Do not suppress a warning from this rule as it would result to misleading output.

## Suppress a warning

If you just want to suppress a single violation, add preprocessor directives to your source file to disable and then re-enable the rule.

```csharp
#pragma warning disable MSTEST0017
// The code that's violating the rule is on this line.
#pragma warning restore MSTEST0017
```

To disable the rule for a file, folder, or project, set its severity to `none` in the [configuration file](../../../fundamentals/code-analysis/configuration-files.md).

```ini
[*.{cs,vb}]
dotnet_diagnostic.MSTEST0017.severity = none
```

For more information, see [How to suppress code analysis warnings](../../../fundamentals/code-analysis/suppress-warnings.md).
Loading

0 comments on commit 462d811

Please sign in to comment.