Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CA2012 ValueTask Consumption Improvements #7461

Open
CoolCoderSuper opened this issue Oct 31, 2024 · 0 comments · May be fixed by #7459
Open

CA2012 ValueTask Consumption Improvements #7461

CoolCoderSuper opened this issue Oct 31, 2024 · 0 comments · May be fixed by #7459

Comments

@CoolCoderSuper
Copy link

CoolCoderSuper commented Oct 31, 2024

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant