Skip to content

Commit

Permalink
chore: Bump NUnit.Analyzers documentation to version 4.4.0 (#989)
Browse files Browse the repository at this point in the history
Co-authored-by: Mikkel Bundgaard <Bundgaard@copopt.com>
  • Loading branch information
mikkelbu and Mikkel Bundgaard authored Nov 15, 2024
1 parent 26fd020 commit ddc2396
Show file tree
Hide file tree
Showing 94 changed files with 662 additions and 96 deletions.
13 changes: 13 additions & 0 deletions docs/articles/nunit-analyzers/NUnit-Analyzers.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ Rules which enforce structural requirements on the test code.
| [NUnit1030](NUnit1030.md) | The type of parameter provided by the TestCaseSource does not match the type of the parameter in the Test method | :white_check_mark: | :exclamation: | :x: |
| [NUnit1031](NUnit1031.md) | The individual arguments provided by a ValuesAttribute must match the type of the corresponding parameter of the method | :white_check_mark: | :exclamation: | :x: |
| [NUnit1032](NUnit1032.md) | An IDisposable field/property should be Disposed in a TearDown method | :white_check_mark: | :exclamation: | :x: |
| [NUnit1033](NUnit1033.md) | The Write methods on TestContext will be marked as Obsolete and eventually removed | :white_check_mark: | :warning: | :white_check_mark: |

## Assertion Rules (NUnit2001 - )

Expand Down Expand Up @@ -112,6 +113,10 @@ Rules which improve assertions in the test code.
| [NUnit2048](NUnit2048.md) | Consider using Assert.That(...) instead of StringAssert(...) | :white_check_mark: | :warning: | :white_check_mark: |
| [NUnit2049](NUnit2049.md) | Consider using Assert.That(...) instead of CollectionAssert(...) | :white_check_mark: | :warning: | :white_check_mark: |
| [NUnit2050](NUnit2050.md) | NUnit 4 no longer supports string.Format specification | :white_check_mark: | :exclamation: | :white_check_mark: |
| [NUnit2051](NUnit2051.md) | Consider using Assert.That(expr, Is.Positive) instead of ClassicAssert.Positive(expr) | :white_check_mark: | :information_source: | :white_check_mark: |
| [NUnit2052](NUnit2052.md) | Consider using Assert.That(expr, Is.Negative) instead of ClassicAssert.Negative(expr) | :white_check_mark: | :information_source: | :white_check_mark: |
| [NUnit2053](NUnit2053.md) | Consider using Assert.That(actual, Is.AssignableFrom(expected)) instead of ClassicAssert.IsAssignableFrom(expected, actual) | :white_check_mark: | :information_source: | :white_check_mark: |
| [NUnit2054](NUnit2054.md) | Consider using Assert.That(actual, Is.Not.AssignableFrom(expected)) instead of ClassicAssert.IsNotAssignableFrom(expected, actual) | :white_check_mark: | :information_source: | :white_check_mark: |

## Suppressor Rules (NUnit3001 - )

Expand All @@ -124,3 +129,11 @@ builds (version 3.0.0 and above) which require Visual Studio 2019 (version 16.3)
| [NUnit3002](NUnit3002.md) | Field/Property is initialized in SetUp or OneTimeSetUp method | :white_check_mark: | :information_source: | :x: |
| [NUnit3003](NUnit3003.md) | Class is an NUnit TestFixture and is instantiated using reflection | :white_check_mark: | :information_source: | :x: |
| [NUnit3004](NUnit3004.md) | Field should be Disposed in TearDown or OneTimeTearDown method | :white_check_mark: | :information_source: | :x: |

## Style Rules (NUnit4001 - )

Rules which help you write concise and readable NUnit test code.

| Id | Title | :mag: | :memo: | :bulb: |
| :-- | :-- | :--: | :--: | :--: |
| [NUnit4001](NUnit4001.md) | Simplify the Values attribute | :white_check_mark: | :information_source: | :x: |
8 changes: 7 additions & 1 deletion docs/articles/nunit-analyzers/NUnit1001.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
| Severity | Error
| Enabled | True
| Category | Structure
| Code | [TestCaseUsageAnalyzer](https://github.com/nunit/nunit.analyzers/blob/4.1.0/src/nunit.analyzers/TestCaseUsage/TestCaseUsageAnalyzer.cs)
| Code | [TestCaseUsageAnalyzer](https://github.com/nunit/nunit.analyzers/blob/4.4.0/src/nunit.analyzers/TestCaseUsage/TestCaseUsageAnalyzer.cs)

## Description

Expand All @@ -29,6 +29,12 @@ public void SampleTest(int numberValue)
{
Assert.That(numberValue, Is.EqualTo(1));
}

[TestCase<double>(42)]
public void SampleTest(int numberValue)
{
Assert.That(numberValue, Is.EqualTo(1));
}
```

### Problem
Expand Down
2 changes: 1 addition & 1 deletion docs/articles/nunit-analyzers/NUnit1002.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
| Severity | Warning
| Enabled | True
| Category | Structure
| Code | [TestCaseSourceUsesStringAnalyzer](https://github.com/nunit/nunit.analyzers/blob/4.1.0/src/nunit.analyzers/TestCaseSourceUsage/TestCaseSourceUsesStringAnalyzer.cs)
| Code | [TestCaseSourceUsesStringAnalyzer](https://github.com/nunit/nunit.analyzers/blob/4.4.0/src/nunit.analyzers/TestCaseSourceUsage/TestCaseSourceUsesStringAnalyzer.cs)

## Description

Expand Down
2 changes: 1 addition & 1 deletion docs/articles/nunit-analyzers/NUnit1003.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
| Severity | Error
| Enabled | True
| Category | Structure
| Code | [TestCaseUsageAnalyzer](https://github.com/nunit/nunit.analyzers/blob/4.1.0/src/nunit.analyzers/TestCaseUsage/TestCaseUsageAnalyzer.cs)
| Code | [TestCaseUsageAnalyzer](https://github.com/nunit/nunit.analyzers/blob/4.4.0/src/nunit.analyzers/TestCaseUsage/TestCaseUsageAnalyzer.cs)

## Description

Expand Down
2 changes: 1 addition & 1 deletion docs/articles/nunit-analyzers/NUnit1004.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
| Severity | Error
| Enabled | True
| Category | Structure
| Code | [TestCaseUsageAnalyzer](https://github.com/nunit/nunit.analyzers/blob/4.1.0/src/nunit.analyzers/TestCaseUsage/TestCaseUsageAnalyzer.cs)
| Code | [TestCaseUsageAnalyzer](https://github.com/nunit/nunit.analyzers/blob/4.4.0/src/nunit.analyzers/TestCaseUsage/TestCaseUsageAnalyzer.cs)

## Description

Expand Down
2 changes: 1 addition & 1 deletion docs/articles/nunit-analyzers/NUnit1005.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
| Severity | Error
| Enabled | True
| Category | Structure
| Code | [TestMethodUsageAnalyzer](https://github.com/nunit/nunit.analyzers/blob/4.1.0/src/nunit.analyzers/TestMethodUsage/TestMethodUsageAnalyzer.cs)
| Code | [TestMethodUsageAnalyzer](https://github.com/nunit/nunit.analyzers/blob/4.4.0/src/nunit.analyzers/TestMethodUsage/TestMethodUsageAnalyzer.cs)

## Description

Expand Down
2 changes: 1 addition & 1 deletion docs/articles/nunit-analyzers/NUnit1006.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
| Severity | Error
| Enabled | True
| Category | Structure
| Code | [TestMethodUsageAnalyzer](https://github.com/nunit/nunit.analyzers/blob/4.1.0/src/nunit.analyzers/TestMethodUsage/TestMethodUsageAnalyzer.cs)
| Code | [TestMethodUsageAnalyzer](https://github.com/nunit/nunit.analyzers/blob/4.4.0/src/nunit.analyzers/TestMethodUsage/TestMethodUsageAnalyzer.cs)

## Description

Expand Down
2 changes: 1 addition & 1 deletion docs/articles/nunit-analyzers/NUnit1007.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
| Severity | Error
| Enabled | True
| Category | Structure
| Code | [TestMethodUsageAnalyzer](https://github.com/nunit/nunit.analyzers/blob/4.1.0/src/nunit.analyzers/TestMethodUsage/TestMethodUsageAnalyzer.cs)
| Code | [TestMethodUsageAnalyzer](https://github.com/nunit/nunit.analyzers/blob/4.4.0/src/nunit.analyzers/TestMethodUsage/TestMethodUsageAnalyzer.cs)

## Description

Expand Down
2 changes: 1 addition & 1 deletion docs/articles/nunit-analyzers/NUnit1008.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
| Severity | Warning
| Enabled | True
| Category | Structure
| Code | [ParallelizableUsageAnalyzer](https://github.com/nunit/nunit.analyzers/blob/4.1.0/src/nunit.analyzers/ParallelizableUsage/ParallelizableUsageAnalyzer.cs)
| Code | [ParallelizableUsageAnalyzer](https://github.com/nunit/nunit.analyzers/blob/4.4.0/src/nunit.analyzers/ParallelizableUsage/ParallelizableUsageAnalyzer.cs)

## Description

Expand Down
2 changes: 1 addition & 1 deletion docs/articles/nunit-analyzers/NUnit1009.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
| Severity | Error
| Enabled | True
| Category | Structure
| Code | [ParallelizableUsageAnalyzer](https://github.com/nunit/nunit.analyzers/blob/4.1.0/src/nunit.analyzers/ParallelizableUsage/ParallelizableUsageAnalyzer.cs)
| Code | [ParallelizableUsageAnalyzer](https://github.com/nunit/nunit.analyzers/blob/4.4.0/src/nunit.analyzers/ParallelizableUsage/ParallelizableUsageAnalyzer.cs)

## Description

Expand Down
2 changes: 1 addition & 1 deletion docs/articles/nunit-analyzers/NUnit1010.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
| Severity | Error
| Enabled | True
| Category | Structure
| Code | [ParallelizableUsageAnalyzer](https://github.com/nunit/nunit.analyzers/blob/4.1.0/src/nunit.analyzers/ParallelizableUsage/ParallelizableUsageAnalyzer.cs)
| Code | [ParallelizableUsageAnalyzer](https://github.com/nunit/nunit.analyzers/blob/4.4.0/src/nunit.analyzers/ParallelizableUsage/ParallelizableUsageAnalyzer.cs)

## Description

Expand Down
2 changes: 1 addition & 1 deletion docs/articles/nunit-analyzers/NUnit1011.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
| Severity | Error
| Enabled | True
| Category | Structure
| Code | [TestCaseSourceUsesStringAnalyzer](https://github.com/nunit/nunit.analyzers/blob/4.1.0/src/nunit.analyzers/TestCaseSourceUsage/TestCaseSourceUsesStringAnalyzer.cs)
| Code | [TestCaseSourceUsesStringAnalyzer](https://github.com/nunit/nunit.analyzers/blob/4.4.0/src/nunit.analyzers/TestCaseSourceUsage/TestCaseSourceUsesStringAnalyzer.cs)

## Description

Expand Down
2 changes: 1 addition & 1 deletion docs/articles/nunit-analyzers/NUnit1012.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
| Severity | Error
| Enabled | True
| Category | Structure
| Code | [TestMethodUsageAnalyzer](https://github.com/nunit/nunit.analyzers/blob/4.1.0/src/nunit.analyzers/TestMethodUsage/TestMethodUsageAnalyzer.cs)
| Code | [TestMethodUsageAnalyzer](https://github.com/nunit/nunit.analyzers/blob/4.4.0/src/nunit.analyzers/TestMethodUsage/TestMethodUsageAnalyzer.cs)

## Description

Expand Down
2 changes: 1 addition & 1 deletion docs/articles/nunit-analyzers/NUnit1013.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
| Severity | Error
| Enabled | True
| Category | Structure
| Code | [TestMethodUsageAnalyzer](https://github.com/nunit/nunit.analyzers/blob/4.1.0/src/nunit.analyzers/TestMethodUsage/TestMethodUsageAnalyzer.cs)
| Code | [TestMethodUsageAnalyzer](https://github.com/nunit/nunit.analyzers/blob/4.4.0/src/nunit.analyzers/TestMethodUsage/TestMethodUsageAnalyzer.cs)

## Description

Expand Down
2 changes: 1 addition & 1 deletion docs/articles/nunit-analyzers/NUnit1014.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
| Severity | Error
| Enabled | True
| Category | Structure
| Code | [TestMethodUsageAnalyzer](https://github.com/nunit/nunit.analyzers/blob/4.1.0/src/nunit.analyzers/TestMethodUsage/TestMethodUsageAnalyzer.cs)
| Code | [TestMethodUsageAnalyzer](https://github.com/nunit/nunit.analyzers/blob/4.4.0/src/nunit.analyzers/TestMethodUsage/TestMethodUsageAnalyzer.cs)

## Description

Expand Down
2 changes: 1 addition & 1 deletion docs/articles/nunit-analyzers/NUnit1015.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
| Severity | Error
| Enabled | True
| Category | Structure
| Code | [TestCaseSourceUsesStringAnalyzer](https://github.com/nunit/nunit.analyzers/blob/4.1.0/src/nunit.analyzers/TestCaseSourceUsage/TestCaseSourceUsesStringAnalyzer.cs)
| Code | [TestCaseSourceUsesStringAnalyzer](https://github.com/nunit/nunit.analyzers/blob/4.4.0/src/nunit.analyzers/TestCaseSourceUsage/TestCaseSourceUsesStringAnalyzer.cs)

## Description

Expand Down
2 changes: 1 addition & 1 deletion docs/articles/nunit-analyzers/NUnit1016.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
| Severity | Error
| Enabled | True
| Category | Structure
| Code | [TestCaseSourceUsesStringAnalyzer](https://github.com/nunit/nunit.analyzers/blob/4.1.0/src/nunit.analyzers/TestCaseSourceUsage/TestCaseSourceUsesStringAnalyzer.cs)
| Code | [TestCaseSourceUsesStringAnalyzer](https://github.com/nunit/nunit.analyzers/blob/4.4.0/src/nunit.analyzers/TestCaseSourceUsage/TestCaseSourceUsesStringAnalyzer.cs)

## Description

Expand Down
2 changes: 1 addition & 1 deletion docs/articles/nunit-analyzers/NUnit1017.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
| Severity | Error
| Enabled | True
| Category | Structure
| Code | [TestCaseSourceUsesStringAnalyzer](https://github.com/nunit/nunit.analyzers/blob/4.1.0/src/nunit.analyzers/TestCaseSourceUsage/TestCaseSourceUsesStringAnalyzer.cs)
| Code | [TestCaseSourceUsesStringAnalyzer](https://github.com/nunit/nunit.analyzers/blob/4.4.0/src/nunit.analyzers/TestCaseSourceUsage/TestCaseSourceUsesStringAnalyzer.cs)

## Description

Expand Down
2 changes: 1 addition & 1 deletion docs/articles/nunit-analyzers/NUnit1018.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
| Severity | Error
| Enabled | True
| Category | Structure
| Code | [TestCaseSourceUsesStringAnalyzer](https://github.com/nunit/nunit.analyzers/blob/4.1.0/src/nunit.analyzers/TestCaseSourceUsage/TestCaseSourceUsesStringAnalyzer.cs)
| Code | [TestCaseSourceUsesStringAnalyzer](https://github.com/nunit/nunit.analyzers/blob/4.4.0/src/nunit.analyzers/TestCaseSourceUsage/TestCaseSourceUsesStringAnalyzer.cs)

## Description

Expand Down
2 changes: 1 addition & 1 deletion docs/articles/nunit-analyzers/NUnit1019.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
| Severity | Error
| Enabled | True
| Category | Structure
| Code | [TestCaseSourceUsesStringAnalyzer](https://github.com/nunit/nunit.analyzers/blob/4.1.0/src/nunit.analyzers/TestCaseSourceUsage/TestCaseSourceUsesStringAnalyzer.cs)
| Code | [TestCaseSourceUsesStringAnalyzer](https://github.com/nunit/nunit.analyzers/blob/4.4.0/src/nunit.analyzers/TestCaseSourceUsage/TestCaseSourceUsesStringAnalyzer.cs)

## Description

Expand Down
2 changes: 1 addition & 1 deletion docs/articles/nunit-analyzers/NUnit1020.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
| Severity | Error
| Enabled | True
| Category | Structure
| Code | [TestCaseSourceUsesStringAnalyzer](https://github.com/nunit/nunit.analyzers/blob/4.1.0/src/nunit.analyzers/TestCaseSourceUsage/TestCaseSourceUsesStringAnalyzer.cs)
| Code | [TestCaseSourceUsesStringAnalyzer](https://github.com/nunit/nunit.analyzers/blob/4.4.0/src/nunit.analyzers/TestCaseSourceUsage/TestCaseSourceUsesStringAnalyzer.cs)

## Description

Expand Down
2 changes: 1 addition & 1 deletion docs/articles/nunit-analyzers/NUnit1021.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
| Severity | Warning
| Enabled | True
| Category | Structure
| Code | [ValueSourceUsageAnalyzer](https://github.com/nunit/nunit.analyzers/blob/4.1.0/src/nunit.analyzers/ValueSourceUsage/ValueSourceUsageAnalyzer.cs)
| Code | [ValueSourceUsageAnalyzer](https://github.com/nunit/nunit.analyzers/blob/4.4.0/src/nunit.analyzers/ValueSourceUsage/ValueSourceUsageAnalyzer.cs)

## Description

Expand Down
2 changes: 1 addition & 1 deletion docs/articles/nunit-analyzers/NUnit1022.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
| Severity | Error
| Enabled | True
| Category | Structure
| Code | [ValueSourceUsageAnalyzer](https://github.com/nunit/nunit.analyzers/blob/4.1.0/src/nunit.analyzers/ValueSourceUsage/ValueSourceUsageAnalyzer.cs)
| Code | [ValueSourceUsageAnalyzer](https://github.com/nunit/nunit.analyzers/blob/4.4.0/src/nunit.analyzers/ValueSourceUsage/ValueSourceUsageAnalyzer.cs)

## Description

Expand Down
2 changes: 1 addition & 1 deletion docs/articles/nunit-analyzers/NUnit1023.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
| Severity | Error
| Enabled | True
| Category | Structure
| Code | [ValueSourceUsageAnalyzer](https://github.com/nunit/nunit.analyzers/blob/4.1.0/src/nunit.analyzers/ValueSourceUsage/ValueSourceUsageAnalyzer.cs)
| Code | [ValueSourceUsageAnalyzer](https://github.com/nunit/nunit.analyzers/blob/4.4.0/src/nunit.analyzers/ValueSourceUsage/ValueSourceUsageAnalyzer.cs)

## Description

Expand Down
2 changes: 1 addition & 1 deletion docs/articles/nunit-analyzers/NUnit1024.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
| Severity | Error
| Enabled | True
| Category | Structure
| Code | [ValueSourceUsageAnalyzer](https://github.com/nunit/nunit.analyzers/blob/4.1.0/src/nunit.analyzers/ValueSourceUsage/ValueSourceUsageAnalyzer.cs)
| Code | [ValueSourceUsageAnalyzer](https://github.com/nunit/nunit.analyzers/blob/4.4.0/src/nunit.analyzers/ValueSourceUsage/ValueSourceUsageAnalyzer.cs)

## Description

Expand Down
2 changes: 1 addition & 1 deletion docs/articles/nunit-analyzers/NUnit1025.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
| Severity | Error
| Enabled | True
| Category | Structure
| Code | [ValueSourceUsageAnalyzer](https://github.com/nunit/nunit.analyzers/blob/4.1.0/src/nunit.analyzers/ValueSourceUsage/ValueSourceUsageAnalyzer.cs)
| Code | [ValueSourceUsageAnalyzer](https://github.com/nunit/nunit.analyzers/blob/4.4.0/src/nunit.analyzers/ValueSourceUsage/ValueSourceUsageAnalyzer.cs)

## Description

Expand Down
2 changes: 1 addition & 1 deletion docs/articles/nunit-analyzers/NUnit1026.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
| Severity | Error
| Enabled | True
| Category | Structure
| Code | [TestMethodAccessibilityLevelAnalyzer](https://github.com/nunit/nunit.analyzers/blob/4.1.0/src/nunit.analyzers/TestMethodAccessibilityLevel/TestMethodAccessibilityLevelAnalyzer.cs)
| Code | [TestMethodAccessibilityLevelAnalyzer](https://github.com/nunit/nunit.analyzers/blob/4.4.0/src/nunit.analyzers/TestMethodAccessibilityLevel/TestMethodAccessibilityLevelAnalyzer.cs)

## Description

Expand Down
2 changes: 1 addition & 1 deletion docs/articles/nunit-analyzers/NUnit1027.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
| Severity | Error
| Enabled | True
| Category | Structure
| Code | [TestMethodUsageAnalyzer](https://github.com/nunit/nunit.analyzers/blob/4.1.0/src/nunit.analyzers/TestMethodUsage/TestMethodUsageAnalyzer.cs)
| Code | [TestMethodUsageAnalyzer](https://github.com/nunit/nunit.analyzers/blob/4.4.0/src/nunit.analyzers/TestMethodUsage/TestMethodUsageAnalyzer.cs)

## Description

Expand Down
2 changes: 1 addition & 1 deletion docs/articles/nunit-analyzers/NUnit1028.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
| Severity | Info
| Enabled | True
| Category | Structure
| Code | [NonTestMethodAccessibilityLevelAnalyzer](https://github.com/nunit/nunit.analyzers/blob/4.1.0/src/nunit.analyzers/NonTestMethodAccessibilityLevel/NonTestMethodAccessibilityLevelAnalyzer.cs)
| Code | [NonTestMethodAccessibilityLevelAnalyzer](https://github.com/nunit/nunit.analyzers/blob/4.4.0/src/nunit.analyzers/NonTestMethodAccessibilityLevel/NonTestMethodAccessibilityLevelAnalyzer.cs)

## Description

Expand Down
2 changes: 1 addition & 1 deletion docs/articles/nunit-analyzers/NUnit1029.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
| Severity | Error
| Enabled | True
| Category | Structure
| Code | [TestCaseSourceUsesStringAnalyzer](https://github.com/nunit/nunit.analyzers/blob/4.1.0/src/nunit.analyzers/TestCaseSourceUsage/TestCaseSourceUsesStringAnalyzer.cs)
| Code | [TestCaseSourceUsesStringAnalyzer](https://github.com/nunit/nunit.analyzers/blob/4.4.0/src/nunit.analyzers/TestCaseSourceUsage/TestCaseSourceUsesStringAnalyzer.cs)

## Description

Expand Down
2 changes: 1 addition & 1 deletion docs/articles/nunit-analyzers/NUnit1030.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
| Severity | Error
| Enabled | True
| Category | Structure
| Code | [TestCaseSourceUsesStringAnalyzer](https://github.com/nunit/nunit.analyzers/blob/4.1.0/src/nunit.analyzers/TestCaseSourceUsage/TestCaseSourceUsesStringAnalyzer.cs)
| Code | [TestCaseSourceUsesStringAnalyzer](https://github.com/nunit/nunit.analyzers/blob/4.4.0/src/nunit.analyzers/TestCaseSourceUsage/TestCaseSourceUsesStringAnalyzer.cs)

## Description

Expand Down
2 changes: 1 addition & 1 deletion docs/articles/nunit-analyzers/NUnit1031.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
| Severity | Error
| Enabled | True
| Category | Structure
| Code | [ValuesUsageAnalyzer](https://github.com/nunit/nunit.analyzers/blob/4.1.0/src/nunit.analyzers/ValuesUsage/ValuesUsageAnalyzer.cs)
| Code | [ValuesUsageAnalyzer](https://github.com/nunit/nunit.analyzers/blob/4.4.0/src/nunit.analyzers/ValuesUsage/ValuesUsageAnalyzer.cs)

## Description

Expand Down
38 changes: 37 additions & 1 deletion docs/articles/nunit-analyzers/NUnit1032.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,58 @@
| Severity | Error
| Enabled | True
| Category | Structure
| Code | [DisposeFieldsAndPropertiesInTearDownAnalyzer](https://github.com/nunit/nunit.analyzers/blob/4.1.0/src/nunit.analyzers/DisposeFieldsAndPropertiesInTearDown/DisposeFieldsAndPropertiesInTearDownAnalyzer.cs)
| Code | [DisposeFieldsAndPropertiesInTearDownAnalyzer](https://github.com/nunit/nunit.analyzers/blob/4.4.0/src/nunit.analyzers/DisposeFieldsAndPropertiesInTearDown/DisposeFieldsAndPropertiesInTearDownAnalyzer.cs)

## Description

An IDisposable field/property should be Disposed in a TearDown method.

This analyzer rule only applies to a `TestFixture` which is using the default
NUnit `SingleInstance` life cycle where the class is instantiated once for all tests.

If you are using `LifeCycle.InstancePerTestCase` you should dispose the fields/properties
in the `Dispose` method of the test class.

## Motivation

Not Disposing fields/properties can cause memory leaks or failing tests.

## How to fix violations

### LifeCycle.SingleInstance

Dispose any fields/properties that are initialized in `SetUp` or `Test` methods in a `TearDown` method.
Fields/Properties that are initialized in `OneTimeSetUp`, or with initializers or in constructors
must be disposed in `OneTimeTearDown`.

### LifeCycle.InstancePerTestCase

If you have `IDisposable` fields or properties, your class must implement the
[`IDisposable`](https://learn.microsoft.com/en-us/dotnet/api/system.idisposable?view=net-8.0) interface.

Dispose any fields/properties that are initialized at declaration or in the constructor in the
[`Dispose`](https://learn.microsoft.com/en-us/dotnet/api/system.idisposable.dispose?view=net-8.0) method.

The NUnit.Analyzer will not help you here as the functionality is available in
[Microsoft .NET Analyzers](https://www.nuget.org/packages/Microsoft.CodeAnalysis.NetAnalyzers).
These are the rules that will help you with this:

* [CA1001](https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1001)
Types that own disposable fields should be disposable
* [CA2213](https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca2213)
Disposable fields should be disposed

Unfortunately, those rules are not enabled by default, you can enable them in your project in a
[`.editorconfig`](https://learn.microsoft.com/en-us/visualstudio/code-quality/use-roslyn-analyzers?view=vs-2022#manually-configure-rule-severity-in-an-editorconfig-file)
file using the following content:

```xml
# CA1001: Types that own disposable fields should be disposable
dotnet_diagnostic.CA1001.severity = warning
# CA2213: Disposable fields should be disposed
dotnet_diagnostic.CA2213.severity = warning
```

<!-- start generated config severity -->
## Configure severity

Expand Down
Loading

0 comments on commit ddc2396

Please sign in to comment.