Roslyn-analyzers: CA2007 Should respect ValueTask as well

Created on 26 Jul 2019  路  3Comments  路  Source: dotnet/roslyn-analyzers

The current DoNotDirectlyAWaitATaskAnalyzer code only pays attention to Task and Task{TResult}:
https://github.com/dotnet/roslyn-analyzers/blob/c9d6579f31fd4ad45f3d23187189657343b395a4/src/Microsoft.CodeQuality.Analyzers/Core/ApiDesignGuidelines/DoNotDirectlyAwaitATask.cs#L93-L96

It should also be augmented to pay attention to ValueTask and ValueTask{TResult} if they're available in the compilation unit.

Area-Microsoft.CodeQuality.Analyzers Feature Request

Most helpful comment

Tagging @AArnott - we are actually planning on adding VS Threading analyzer package as a dependency of FxCop analyzers package, and deprecate CA2007 in favor of a similar rule in the threading package that handles both Task and ValueTask.

All 3 comments

Tagging @AArnott - we are actually planning on adding VS Threading analyzer package as a dependency of FxCop analyzers package, and deprecate CA2007 in favor of a similar rule in the threading package that handles both Task and ValueTask.

Yes, our VSTHRD111 rule already supports ValueTask for this scenario.

What's the suggested approach to solve the issue?
I'm using
# CA2007: Consider calling ConfigureAwait on the awaited task dotnet_diagnostic.CA2007.severity = error and I'd like to have errors on ValueTask too, is it possible to have that with something to install on top of fxCopAnalyzers?

-- update --
nevermind, solved by myself
nuget => Microsoft.VisualStudio.Threading.Analyzers
editorconfig rule => dotnet_diagnostic.VSTHRD111.severity = error

Was this page helpful?
0 / 5 - 0 ratings

Related issues

fschlaef picture fschlaef  路  4Comments

paulomorgado picture paulomorgado  路  3Comments

paulomorgado picture paulomorgado  路  3Comments

x3ntrix picture x3ntrix  路  3Comments

KrisVandermotten picture KrisVandermotten  路  3Comments