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

Add config parameter for value task consumption #7459

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

CoolCoderSuper
Copy link

@CoolCoderSuper CoolCoderSuper commented Oct 28, 2024

This adds a config option to CA2012 (ValueTask consumption).
The analyzer allows consumption via ConfigureAwait and a few others however it maybe useful to allow other methods as well.
For example:

    <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

Using these methods would trigger the warning.

dotnet_code_quality.additional_valid_valuetask_consumption=KeepContext|FreeContext

Or can configured like so.

Sorry if I did something incorrectly.

Fixes #7461

@CoolCoderSuper CoolCoderSuper requested a review from a team as a code owner October 28, 2024 14:03
@CoolCoderSuper
Copy link
Author

@AArnott
Not sure if you are the right person but I would appreciate if someone could take a look at this.

@AArnott
Copy link
Contributor

AArnott commented Nov 7, 2024

@CoolCoderSuper I am not the right person. Don't know who is. Sorry.

@CoolCoderSuper
Copy link
Author

OK thanks for the response

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

Successfully merging this pull request may close these issues.

CA2012 ValueTask Consumption Improvements
2 participants