Skip to content

CA2012 ValueTask Consumption Improvements #7461

Open
@CoolCoderSuper

Description

Analyzer

Diagnostic ID: CA2012

Describe the improvement

Sometimes method other than the built in ones are valid consumptions.

Describe suggestions on how to achieve the rule

Add editor config option similar to other analyzers

Additional context

Public Async Function Test() As Task
    Await ValueTask.KeepContext()
End Function

Public Module AsyncExtensions
    <Extension>
    Public Function KeepContext(a As ValueTask) As ConfiguredValueTaskAwaitable
        Return a.ConfigureAwait(True)
    End Function

    <Extension>
    Public Function FreeContext(a As ValueTask) As ConfiguredValueTaskAwaitable
        Return a.ConfigureAwait(False)
    End Function
End Module
dotnet_code_quality.additional_valid_valuetask_consumption=KeepContext|FreeContext

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions