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

CA1849 triggers when using nameof of a Task property in an async method #6993

Closed
GiottoVerducci opened this issue Oct 19, 2023 · 0 comments · Fixed by #7010
Closed

CA1849 triggers when using nameof of a Task property in an async method #6993

GiottoVerducci opened this issue Oct 19, 2023 · 0 comments · Fixed by #7010
Labels
Area-Microsoft.CodeAnalysis.NetAnalyzers Bug The product is not behaving according to its current intended design False_Positive A diagnostic is reported for non-problematic case good first issue help wanted The issue is up-for-grabs, and can be claimed by commenting
Milestone

Comments

@GiottoVerducci
Copy link

Analyzer

Diagnostic ID: CA1849: Call async methods when in an async method

Analyzer source

NuGet Package: microsoft.entityframeworkcore.analyzers
Version: 7.0.12 (latest)

Describe the bug

The following expression triggers a warning when used in an async method

nameof(Task<object>.Result)

For instance:

        public async Task<string> Foo()
        {
            await Task.CompletedTask; // do async stuff
            return nameof(Task<object>.Result); // this should return "Result"
        }

Expected behavior

Since it's a nameof(), it shouldn't trigger the warning.

Actual behavior

It triggers a warning:
Warning CA1849 'Task.Result' synchronously blocks. Use await instead.

@GiottoVerducci GiottoVerducci changed the title CA1849 triggers when using nameof CA1849 triggers when using nameof of a Task property in an async method Oct 19, 2023
@mavasani mavasani added Bug The product is not behaving according to its current intended design Area-Microsoft.CodeAnalysis.NetAnalyzers False_Positive A diagnostic is reported for non-problematic case help wanted The issue is up-for-grabs, and can be claimed by commenting good first issue labels Oct 23, 2023
@mavasani mavasani added this to the Unknown milestone Oct 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Microsoft.CodeAnalysis.NetAnalyzers Bug The product is not behaving according to its current intended design False_Positive A diagnostic is reported for non-problematic case good first issue help wanted The issue is up-for-grabs, and can be claimed by commenting
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants