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

VSTHRD110 False Negative in local functions? #1363

Open
PaulKlein opened this issue Dec 24, 2024 · 0 comments
Open

VSTHRD110 False Negative in local functions? #1363

PaulKlein opened this issue Dec 24, 2024 · 0 comments

Comments

@PaulKlein
Copy link

Bug description

An async method containing a synchronous local function doesn't trigger VSTHRD110 if that local function calls unawaited task methods.

Repro steps

        async Task DoOperationAsync()
        {
            // Warning CS4014 as expected
            HelperAsync();

            DoOperationInner();

            return;

            void DoOperationInner()
            {
                // No warning, would expect VSTHRD110?
                HelperAsync();
            }
        }
        
        void DoOperation()
        {
            // Raises VSTHRD110 as expected
            HelperAsync();
        }

        Task HelperAsync()
        {
            // e.g. some helper method doing some async work
            return Task.CompletedTask;
        }

Expected behavior

A VSTHRD110 warning on the call to HelperAsync inside DoOperationInner

Actual behavior

No warning is raised

  • Version used:
    Microsoft.VisualStudio.Threading.Analyzers v17.12.19

Additional context

Thank you very much for the work you do on these analysers, they are super helpful at preventing issues in my code!
Cheers

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

No branches or pull requests

1 participant