Skip to content

Commit

Permalink
chore: Update documentation to NUnit Analyzers version 4.1 (#921)
Browse files Browse the repository at this point in the history
* chore: Update documentation to NUnit Analyzers version 4.1

* chore: Add "Interpolatable" to spell checker

---------

Co-authored-by: Mikkel Bundgaard <[email protected]> b4ac06a
  • Loading branch information
OsirisTerje committed Mar 29, 2024
1 parent ffcb477 commit 88a03e9
Show file tree
Hide file tree
Showing 94 changed files with 2,106 additions and 1,204 deletions.
83 changes: 52 additions & 31 deletions articles/nunit-analyzers/NUnit-Analyzers.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion articles/nunit-analyzers/NUnit1001.html
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ <h2 id="the-individual-arguments-provided-by-a-testcaseattribute-must-match-the-
</tr>
<tr>
<td style="text-align: left;">Code</td>
<td style="text-align: left;"><a href="https://github.com/nunit/nunit.analyzers/blob/3.8.0/src/nunit.analyzers/TestCaseUsage/TestCaseUsageAnalyzer.cs">TestCaseUsageAnalyzer</a></td>
<td style="text-align: left;"><a href="https://github.com/nunit/nunit.analyzers/blob/4.1.0/src/nunit.analyzers/TestCaseUsage/TestCaseUsageAnalyzer.cs">TestCaseUsageAnalyzer</a></td>
</tr>
</tbody>
</table>
Expand Down
2 changes: 1 addition & 1 deletion articles/nunit-analyzers/NUnit1002.html
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ <h2 id="the-testcasesource-should-use-nameof-operator-to-specify-target">The Tes
</tr>
<tr>
<td style="text-align: left;">Code</td>
<td style="text-align: left;"><a href="https://github.com/nunit/nunit.analyzers/blob/3.8.0/src/nunit.analyzers/TestCaseSourceUsage/TestCaseSourceUsesStringAnalyzer.cs">TestCaseSourceUsesStringAnalyzer</a></td>
<td style="text-align: left;"><a href="https://github.com/nunit/nunit.analyzers/blob/4.1.0/src/nunit.analyzers/TestCaseSourceUsage/TestCaseSourceUsesStringAnalyzer.cs">TestCaseSourceUsesStringAnalyzer</a></td>
</tr>
</tbody>
</table>
Expand Down
2 changes: 1 addition & 1 deletion articles/nunit-analyzers/NUnit1003.html
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ <h2 id="the-testcaseattribute-provided-too-few-arguments">The TestCaseAttribute
</tr>
<tr>
<td style="text-align: left;">Code</td>
<td style="text-align: left;"><a href="https://github.com/nunit/nunit.analyzers/blob/3.8.0/src/nunit.analyzers/TestCaseUsage/TestCaseUsageAnalyzer.cs">TestCaseUsageAnalyzer</a></td>
<td style="text-align: left;"><a href="https://github.com/nunit/nunit.analyzers/blob/4.1.0/src/nunit.analyzers/TestCaseUsage/TestCaseUsageAnalyzer.cs">TestCaseUsageAnalyzer</a></td>
</tr>
</tbody>
</table>
Expand Down
2 changes: 1 addition & 1 deletion articles/nunit-analyzers/NUnit1004.html
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ <h2 id="the-testcaseattribute-provided-too-many-arguments">The TestCaseAttribute
</tr>
<tr>
<td style="text-align: left;">Code</td>
<td style="text-align: left;"><a href="https://github.com/nunit/nunit.analyzers/blob/3.8.0/src/nunit.analyzers/TestCaseUsage/TestCaseUsageAnalyzer.cs">TestCaseUsageAnalyzer</a></td>
<td style="text-align: left;"><a href="https://github.com/nunit/nunit.analyzers/blob/4.1.0/src/nunit.analyzers/TestCaseUsage/TestCaseUsageAnalyzer.cs">TestCaseUsageAnalyzer</a></td>
</tr>
</tbody>
</table>
Expand Down
2 changes: 1 addition & 1 deletion articles/nunit-analyzers/NUnit1005.html
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ <h2 id="the-type-of-the-value-specified-via-expectedresult-must-match-the-return
</tr>
<tr>
<td style="text-align: left;">Code</td>
<td style="text-align: left;"><a href="https://github.com/nunit/nunit.analyzers/blob/3.8.0/src/nunit.analyzers/TestMethodUsage/TestMethodUsageAnalyzer.cs">TestMethodUsageAnalyzer</a></td>
<td style="text-align: left;"><a href="https://github.com/nunit/nunit.analyzers/blob/4.1.0/src/nunit.analyzers/TestMethodUsage/TestMethodUsageAnalyzer.cs">TestMethodUsageAnalyzer</a></td>
</tr>
</tbody>
</table>
Expand Down
2 changes: 1 addition & 1 deletion articles/nunit-analyzers/NUnit1006.html
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ <h2 id="expectedresult-must-not-be-specified-when-the-method-returns-void">Expec
</tr>
<tr>
<td style="text-align: left;">Code</td>
<td style="text-align: left;"><a href="https://github.com/nunit/nunit.analyzers/blob/3.8.0/src/nunit.analyzers/TestMethodUsage/TestMethodUsageAnalyzer.cs">TestMethodUsageAnalyzer</a></td>
<td style="text-align: left;"><a href="https://github.com/nunit/nunit.analyzers/blob/4.1.0/src/nunit.analyzers/TestMethodUsage/TestMethodUsageAnalyzer.cs">TestMethodUsageAnalyzer</a></td>
</tr>
</tbody>
</table>
Expand Down
2 changes: 1 addition & 1 deletion articles/nunit-analyzers/NUnit1007.html
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ <h2 id="the-method-has-non-void-return-type-but-no-result-is-expected-in-expecte
</tr>
<tr>
<td style="text-align: left;">Code</td>
<td style="text-align: left;"><a href="https://github.com/nunit/nunit.analyzers/blob/3.8.0/src/nunit.analyzers/TestMethodUsage/TestMethodUsageAnalyzer.cs">TestMethodUsageAnalyzer</a></td>
<td style="text-align: left;"><a href="https://github.com/nunit/nunit.analyzers/blob/4.1.0/src/nunit.analyzers/TestMethodUsage/TestMethodUsageAnalyzer.cs">TestMethodUsageAnalyzer</a></td>
</tr>
</tbody>
</table>
Expand Down
5 changes: 3 additions & 2 deletions articles/nunit-analyzers/NUnit1008.html
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ <h2 id="specifying-parallelscopeself-on-assembly-level-has-no-effect">Specifying
</tr>
<tr>
<td style="text-align: left;">Code</td>
<td style="text-align: left;"><a href="https://github.com/nunit/nunit.analyzers/blob/3.8.0/src/nunit.analyzers/ParallelizableUsage/ParallelizableUsageAnalyzer.cs">ParallelizableUsageAnalyzer</a></td>
<td style="text-align: left;"><a href="https://github.com/nunit/nunit.analyzers/blob/4.1.0/src/nunit.analyzers/ParallelizableUsage/ParallelizableUsageAnalyzer.cs">ParallelizableUsageAnalyzer</a></td>
</tr>
</tbody>
</table>
Expand All @@ -128,7 +128,8 @@ <h3 id="example-violation">Example Violation</h3>
<pre><code class="lang-csharp">[assembly: Parallelizable(ParallelScope.Self)]
</code></pre>
<h3 id="explanation">Explanation</h3>
<p><code>ParallelScope.Self</code> <a class="xref" href="../nunit/writing-tests/attributes/parallelizable.html">only applies to classes and methods</a>, not to assemblies.</p>
<p><code>ParallelScope.Self</code> <a class="xref" href="../nunit/writing-tests/attributes/parallelizable.html">only applies to classes and methods</a>,
not to assemblies.</p>
<h3 id="fix">Fix</h3>
<p>Either remove it or change to a valid option, such as:</p>
<pre><code class="lang-csharp">[assembly: Parallelizable(ParallelScope.Children)]
Expand Down
2 changes: 1 addition & 1 deletion articles/nunit-analyzers/NUnit1009.html
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ <h2 id="one-may-not-specify-parallelscopechildren-on-a-non-parameterized-test-me
</tr>
<tr>
<td style="text-align: left;">Code</td>
<td style="text-align: left;"><a href="https://github.com/nunit/nunit.analyzers/blob/3.8.0/src/nunit.analyzers/ParallelizableUsage/ParallelizableUsageAnalyzer.cs">ParallelizableUsageAnalyzer</a></td>
<td style="text-align: left;"><a href="https://github.com/nunit/nunit.analyzers/blob/4.1.0/src/nunit.analyzers/ParallelizableUsage/ParallelizableUsageAnalyzer.cs">ParallelizableUsageAnalyzer</a></td>
</tr>
</tbody>
</table>
Expand Down
2 changes: 1 addition & 1 deletion articles/nunit-analyzers/NUnit1010.html
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ <h2 id="one-may-not-specify-parallelscopefixtures-on-a-test-method">One may not
</tr>
<tr>
<td style="text-align: left;">Code</td>
<td style="text-align: left;"><a href="https://github.com/nunit/nunit.analyzers/blob/3.8.0/src/nunit.analyzers/ParallelizableUsage/ParallelizableUsageAnalyzer.cs">ParallelizableUsageAnalyzer</a></td>
<td style="text-align: left;"><a href="https://github.com/nunit/nunit.analyzers/blob/4.1.0/src/nunit.analyzers/ParallelizableUsage/ParallelizableUsageAnalyzer.cs">ParallelizableUsageAnalyzer</a></td>
</tr>
</tbody>
</table>
Expand Down
2 changes: 1 addition & 1 deletion articles/nunit-analyzers/NUnit1011.html
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ <h2 id="the-testcasesource-argument-does-not-specify-an-existing-member">The Tes
</tr>
<tr>
<td style="text-align: left;">Code</td>
<td style="text-align: left;"><a href="https://github.com/nunit/nunit.analyzers/blob/3.8.0/src/nunit.analyzers/TestCaseSourceUsage/TestCaseSourceUsesStringAnalyzer.cs">TestCaseSourceUsesStringAnalyzer</a></td>
<td style="text-align: left;"><a href="https://github.com/nunit/nunit.analyzers/blob/4.1.0/src/nunit.analyzers/TestCaseSourceUsage/TestCaseSourceUsesStringAnalyzer.cs">TestCaseSourceUsesStringAnalyzer</a></td>
</tr>
</tbody>
</table>
Expand Down
2 changes: 1 addition & 1 deletion articles/nunit-analyzers/NUnit1012.html
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ <h2 id="the-async-test-method-must-have-a-non-void-return-type">The async test m
</tr>
<tr>
<td style="text-align: left;">Code</td>
<td style="text-align: left;"><a href="https://github.com/nunit/nunit.analyzers/blob/3.8.0/src/nunit.analyzers/TestMethodUsage/TestMethodUsageAnalyzer.cs">TestMethodUsageAnalyzer</a></td>
<td style="text-align: left;"><a href="https://github.com/nunit/nunit.analyzers/blob/4.1.0/src/nunit.analyzers/TestMethodUsage/TestMethodUsageAnalyzer.cs">TestMethodUsageAnalyzer</a></td>
</tr>
</tbody>
</table>
Expand Down
8 changes: 5 additions & 3 deletions articles/nunit-analyzers/NUnit1013.html
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ <h2 id="the-async-test-method-must-have-a-non-generic-task-return-type-when-no-r
</tr>
<tr>
<td style="text-align: left;">Code</td>
<td style="text-align: left;"><a href="https://github.com/nunit/nunit.analyzers/blob/3.8.0/src/nunit.analyzers/TestMethodUsage/TestMethodUsageAnalyzer.cs">TestMethodUsageAnalyzer</a></td>
<td style="text-align: left;"><a href="https://github.com/nunit/nunit.analyzers/blob/4.1.0/src/nunit.analyzers/TestMethodUsage/TestMethodUsageAnalyzer.cs">TestMethodUsageAnalyzer</a></td>
</tr>
</tbody>
</table>
Expand All @@ -136,7 +136,8 @@ <h3 id="example-violation">Example Violation</h3>
}
</code></pre>
<h3 id="explanation">Explanation</h3>
<p>The NUnit <code>ExpectedResult</code> syntax is not used, so it's an error for this method to return something that isn't being checked.</p>
<p>The NUnit <code>ExpectedResult</code> syntax is not used, so it's an error for this method to return something that isn't being
checked.</p>
<h3 id="fix">Fix</h3>
<p>Utilize the <code>ExpectedResult</code> syntax:</p>
<pre><code class="lang-csharp">[TestCase(1, ExpectedResult = &quot;1&quot;)]
Expand Down Expand Up @@ -166,7 +167,8 @@ <h3 id="fix">Fix</h3>
<!-- start generated config severity -->
<h2 id="configure-severity">Configure severity</h2>
<h3 id="via-ruleset-file">Via ruleset file</h3>
<p>Configure the severity per project, for more info see <a href="https://learn.microsoft.com/en-us/visualstudio/code-quality/using-rule-sets-to-group-code-analysis-rules?view=vs-2022">MSDN</a>.</p>
<p>Configure the severity per project, for more info see
<a href="https://learn.microsoft.com/en-us/visualstudio/code-quality/using-rule-sets-to-group-code-analysis-rules?view=vs-2022">MSDN</a>.</p>
<h3 id="via-editorconfig-file">Via .editorconfig file</h3>
<pre><code class="lang-ini"># NUnit1013: The async test method must have a non-generic Task return type when no result is expected
dotnet_diagnostic.NUnit1013.severity = chosenSeverity
Expand Down
2 changes: 1 addition & 1 deletion articles/nunit-analyzers/NUnit1014.html
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ <h2 id="the-async-test-method-must-have-a-taskt-return-type-when-a-result-is-exp
</tr>
<tr>
<td style="text-align: left;">Code</td>
<td style="text-align: left;"><a href="https://github.com/nunit/nunit.analyzers/blob/3.8.0/src/nunit.analyzers/TestMethodUsage/TestMethodUsageAnalyzer.cs">TestMethodUsageAnalyzer</a></td>
<td style="text-align: left;"><a href="https://github.com/nunit/nunit.analyzers/blob/4.1.0/src/nunit.analyzers/TestMethodUsage/TestMethodUsageAnalyzer.cs">TestMethodUsageAnalyzer</a></td>
</tr>
</tbody>
</table>
Expand Down
30 changes: 16 additions & 14 deletions articles/nunit-analyzers/NUnit1015.html
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
<article class="content wrap" id="_content" data-uid="">
<h1 id="nunit1015">NUnit1015</h1>

<h2 id="the-source-type-does-not-implement-ienumerable">The source type does not implement IEnumerable</h2>
<h2 id="the-source-type-does-not-implement-iasyncenumerable">The source type does not implement I(Async)Enumerable</h2>
<table>
<thead>
<tr>
Expand All @@ -113,12 +113,12 @@ <h2 id="the-source-type-does-not-implement-ienumerable">The source type does not
</tr>
<tr>
<td style="text-align: left;">Code</td>
<td style="text-align: left;"><a href="https://github.com/nunit/nunit.analyzers/blob/3.8.0/src/nunit.analyzers/TestCaseSourceUsage/TestCaseSourceUsesStringAnalyzer.cs">TestCaseSourceUsesStringAnalyzer</a></td>
<td style="text-align: left;"><a href="https://github.com/nunit/nunit.analyzers/blob/4.1.0/src/nunit.analyzers/TestCaseSourceUsage/TestCaseSourceUsesStringAnalyzer.cs">TestCaseSourceUsesStringAnalyzer</a></td>
</tr>
</tbody>
</table>
<h2 id="description">Description</h2>
<p>The source type must implement IEnumerable in order to provide test cases.</p>
<p>The source type must implement I(Async)Enumerable in order to provide test cases.</p>
<h2 id="motivation">Motivation</h2>
<p>To prevent tests that will fail at runtime due to improper construction.</p>
<h2 id="how-to-fix-violations">How to fix violations</h2>
Expand All @@ -128,7 +128,7 @@ <h3 id="example-violation">Example Violation</h3>
[TestCaseSource(typeof(DivideCases))]
public void DivideTest(int n, int d, int q)
{
Assert.AreEqual(q, n / d);
ClassicAssert.AreEqual(q, n / d);
}
}

Expand All @@ -143,16 +143,17 @@ <h3 id="example-violation">Example Violation</h3>
}
</code></pre>
<h3 id="explanation">Explanation</h3>
<p>In the sample above, the class <code>DivideCases</code> does not implement <code>IEnumerable</code>.</p>
<p>However, source types specified by <code>TestCaseSource</code> <a class="xref" href="../nunit/writing-tests/attributes/testcasesource.html">must implement <code>IEnumerable</code></a>.</p>
<p>In the sample above, the class <code>DivideCases</code> does not implement <code>IEnumerable</code> nor <code>IAsyncEnumerable</code></p>
<p>However, source types specified by <code>TestCaseSource</code>
<a class="xref" href="../nunit/writing-tests/attributes/testcasesource.html">must implement <code>IEnumerable</code> or <code>IAsyncEnumerable</code></a>.</p>
<h3 id="fix">Fix</h3>
<p>Make the source type implement <code>IEnumerable</code>:</p>
<p>Make the source type implement <code>IEnumerable</code> or <code>IAsyncEnumerable</code></p>
<pre><code class="lang-csharp">public class MyTestClass
{
[TestCaseSource(typeof(DivideCases))]
public void DivideTest(int n, int d, int q)
{
Assert.AreEqual(q, n / d);
ClassicAssert.AreEqual(q, n / d);
}
}

Expand All @@ -169,23 +170,24 @@ <h3 id="fix">Fix</h3>
<!-- start generated config severity -->
<h2 id="configure-severity">Configure severity</h2>
<h3 id="via-ruleset-file">Via ruleset file</h3>
<p>Configure the severity per project, for more info see <a href="https://learn.microsoft.com/en-us/visualstudio/code-quality/using-rule-sets-to-group-code-analysis-rules?view=vs-2022">MSDN</a>.</p>
<p>Configure the severity per project, for more info see
<a href="https://learn.microsoft.com/en-us/visualstudio/code-quality/using-rule-sets-to-group-code-analysis-rules?view=vs-2022">MSDN</a>.</p>
<h3 id="via-editorconfig-file">Via .editorconfig file</h3>
<pre><code class="lang-ini"># NUnit1015: The source type does not implement IEnumerable
<pre><code class="lang-ini"># NUnit1015: The source type does not implement I(Async)Enumerable
dotnet_diagnostic.NUnit1015.severity = chosenSeverity
</code></pre>
<p>where <code>chosenSeverity</code> can be one of <code>none</code>, <code>silent</code>, <code>suggestion</code>, <code>warning</code>, or <code>error</code>.</p>
<h3 id="via-pragma-directive">Via #pragma directive</h3>
<pre><code class="lang-csharp">#pragma warning disable NUnit1015 // The source type does not implement IEnumerable
<pre><code class="lang-csharp">#pragma warning disable NUnit1015 // The source type does not implement I(Async)Enumerable
Code violating the rule here
#pragma warning restore NUnit1015 // The source type does not implement IEnumerable
#pragma warning restore NUnit1015 // The source type does not implement I(Async)Enumerable
</code></pre>
<p>Or put this at the top of the file to disable all instances.</p>
<pre><code class="lang-csharp">#pragma warning disable NUnit1015 // The source type does not implement IEnumerable
<pre><code class="lang-csharp">#pragma warning disable NUnit1015 // The source type does not implement I(Async)Enumerable
</code></pre>
<h3 id="via-attribute-suppressmessage">Via attribute <code>[SuppressMessage]</code></h3>
<pre><code class="lang-csharp">[System.Diagnostics.CodeAnalysis.SuppressMessage(&quot;Structure&quot;,
&quot;NUnit1015:The source type does not implement IEnumerable&quot;,
&quot;NUnit1015:The source type does not implement I(Async)Enumerable&quot;,
Justification = &quot;Reason...&quot;)]
</code></pre>
<!-- end generated config severity -->
Expand Down
12 changes: 7 additions & 5 deletions articles/nunit-analyzers/NUnit1016.html
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ <h2 id="the-source-type-does-not-have-a-default-constructor">The source type doe
</tr>
<tr>
<td style="text-align: left;">Code</td>
<td style="text-align: left;"><a href="https://github.com/nunit/nunit.analyzers/blob/3.8.0/src/nunit.analyzers/TestCaseSourceUsage/TestCaseSourceUsesStringAnalyzer.cs">TestCaseSourceUsesStringAnalyzer</a></td>
<td style="text-align: left;"><a href="https://github.com/nunit/nunit.analyzers/blob/4.1.0/src/nunit.analyzers/TestCaseSourceUsage/TestCaseSourceUsesStringAnalyzer.cs">TestCaseSourceUsesStringAnalyzer</a></td>
</tr>
</tbody>
</table>
Expand All @@ -128,7 +128,7 @@ <h3 id="example-violation">Example Violation</h3>
[TestCaseSource(typeof(DivideCases))]
public void DivideTest(int n, int d, int q)
{
Assert.AreEqual(q, n / d);
ClassicAssert.AreEqual(q, n / d);
}
}

Expand All @@ -146,15 +146,16 @@ <h3 id="example-violation">Example Violation</h3>
</code></pre>
<h3 id="explanation">Explanation</h3>
<p>In the sample above, the class <code>DivideCases</code> does not have a default constructor - i.e. a constructor with no parameters.</p>
<p>However, source types specified by <code>TestCaseSource</code> <a class="xref" href="../nunit/writing-tests/attributes/testcasesource.html">must have a default constructor</a>.</p>
<p>However, source types specified by <code>TestCaseSource</code>
<a class="xref" href="../nunit/writing-tests/attributes/testcasesource.html">must have a default constructor</a>.</p>
<h3 id="fix">Fix</h3>
<p>Add a default constructor to the source type (or remove the parameters from an existing constructor):</p>
<pre><code class="lang-csharp">public class MyTestClass
{
[TestCaseSource(typeof(DivideCases))]
public void DivideTest(int n, int d, int q)
{
Assert.AreEqual(q, n / d);
ClassicAssert.AreEqual(q, n / d);
}
}

Expand All @@ -175,7 +176,8 @@ <h3 id="fix">Fix</h3>
<!-- start generated config severity -->
<h2 id="configure-severity">Configure severity</h2>
<h3 id="via-ruleset-file">Via ruleset file</h3>
<p>Configure the severity per project, for more info see <a href="https://learn.microsoft.com/en-us/visualstudio/code-quality/using-rule-sets-to-group-code-analysis-rules?view=vs-2022">MSDN</a>.</p>
<p>Configure the severity per project, for more info see
<a href="https://learn.microsoft.com/en-us/visualstudio/code-quality/using-rule-sets-to-group-code-analysis-rules?view=vs-2022">MSDN</a>.</p>
<h3 id="via-editorconfig-file">Via .editorconfig file</h3>
<pre><code class="lang-ini"># NUnit1016: The source type does not have a default constructor
dotnet_diagnostic.NUnit1016.severity = chosenSeverity
Expand Down
Loading

0 comments on commit 88a03e9

Please sign in to comment.