Warning CA2247: Argument to TaskCompletionSource constructor should be TaskCreationOptions value
.NET code analyzer rule CA2247 is enabled, by default, starting in .NET 5.0. It produces a build warning for calls to the TaskCompletionSource<TResult> constructor that pass an argument of type TaskContinuationOptions.
Starting in .NET 5, the .NET SDK includes .NET source code analyzers. Several of these rules are enabled, by default, including CA2247. If your project contains code that violates this rule and is configured to treat warnings as errors, this change could break your build.
Rule CA2247 finds calls to the TaskCompletionSource<TResult> constructor that pass an argument of type TaskContinuationOptions. The TaskCompletionSource<TResult> type has a constructor that accepts a TaskCreationOptions value, and another constructor that accepts an Object. If you accidentally pass a TaskContinuationOptions value instead of a TaskCreationOptions value, the constructor with the Object parameter is called at run time. Your code will compile and run but won't have the intended behavior.
Replace the TaskContinuationOptions argument with the corresponding TaskCreationOptions value. Do not suppress this warning, since it almost always highlights a bug in your code. For more information, see CA2247.
To disable code analysis completely, set
falsein your project file. For more information, see EnableNETAnalyzers.