Back to Nunit

NUnit1008

docs/articles/nunit-analyzers/NUnit1008.md

latest2.3 KB
Original Source

NUnit1008

Specifying ParallelScope.Self on assembly level has no effect

TopicValue
IdNUnit1008
SeverityWarning
EnabledTrue
CategoryStructure
CodeParallelizableUsageAnalyzer

Description

Specifying ParallelScope.Self on assembly level has no effect.

Motivation

Bring developers' attention to a scenario in which they may believe they are parallelizing something when in fact they are not and their efforts will have no effect.

How to fix violations

Example Violation

In AssemblyInfo.cs:

csharp
[assembly: Parallelizable(ParallelScope.Self)]

Explanation

ParallelScope.Self only applies to classes and methods, not to assemblies.

Fix

Either remove it or change to a valid option, such as:

csharp
[assembly: Parallelizable(ParallelScope.Children)]

Or:

csharp
[assembly: Parallelizable(ParallelScope.Fixtures)]
<!-- start generated config severity -->

Configure severity

Via ruleset file

Configure the severity per project, for more info see MSDN.

Via .editorconfig file

ini
# NUnit1008: Specifying ParallelScope.Self on assembly level has no effect
dotnet_diagnostic.NUnit1008.severity = chosenSeverity

where chosenSeverity can be one of none, silent, suggestion, warning, or error.

Via #pragma directive

csharp
#pragma warning disable NUnit1008 // Specifying ParallelScope.Self on assembly level has no effect
Code violating the rule here
#pragma warning restore NUnit1008 // Specifying ParallelScope.Self on assembly level has no effect

Or put this at the top of the file to disable all instances.

csharp
#pragma warning disable NUnit1008 // Specifying ParallelScope.Self on assembly level has no effect

Via attribute [SuppressMessage]

csharp
[System.Diagnostics.CodeAnalysis.SuppressMessage("Structure",
    "NUnit1008:Specifying ParallelScope.Self on assembly level has no effect",
    Justification = "Reason...")]
<!-- end generated config severity -->