Skip to content

Commit 420dde4

Browse files
committed
Improve 'MaxDegreesOfParallelism' check
1 parent af01dae commit 420dde4

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/Tasks/Microsoft.NET.Build.Tasks/RunCsWinRTGenerator.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,10 @@ protected override bool ValidateParameters()
160160
return false;
161161
}
162162

163-
if (MaxDegreesOfParallelism is 0 or < -1)
163+
// The degrees of parallelism matches the semantics of the 'MaxDegreesOfParallelism' property of 'Parallel.For'. That is, it must either be exactly '-1', which is a special
164+
// value meaning "use as many parallel threads as the runtime deems appropriate", or it must be set to a positive integer, to explicitly control the number of threads.
165+
// See: https://learn.microsoft.com/dotnet/api/system.threading.tasks.paralleloptions.maxdegreeofparallelism#system-threading-tasks-paralleloptions-maxdegreeofparallelism.
166+
if (MaxDegreesOfParallelism is not (-1 or > 0))
164167
{
165168
Log.LogWarning("Invalid 'MaxDegreesOfParallelism' value. It must be '-1' or greater than '0' (but was '{0}').", MaxDegreesOfParallelism);
166169

0 commit comments

Comments
 (0)