Skip to content

NUnit1008

Mikkel Nylander Bundgaard edited this page Apr 25, 2020 · 2 revisions

NUnit1008

Specifying ParallelScope.Self on assembly level has no effect.

Topic Value
Id NUnit1008
Severity Warning
Enabled True
Category Structure
Code ParallelizableUsageAnalyzer

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:

[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:

[assembly: Parallelizable(ParallelScope.Children)]

Or:

[assembly: Parallelizable(ParallelScope.Fixtures)]

Configure severity

Via ruleset file.

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

Via #pragma directive.

#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.

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

Via attribute [SuppressMessage].

[System.Diagnostics.CodeAnalysis.SuppressMessage("Structure", 
    "NUnit1008:Specifying ParallelScope.Self on assembly level has no effect.",
    Justification = "Reason...")]
Clone this wiki locally