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

Closed
PaulKlein opened this issue Dec 24, 2024 · 1 comment · Fixed by #1385
Closed

VSTHRD110 False Negative in local functions? #1363

PaulKlein opened this issue Dec 24, 2024 · 1 comment · Fixed by #1385
Assignees

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

@AArnott AArnott self-assigned this Feb 4, 2025
@AArnott AArnott added the bug label Feb 4, 2025
AArnott added a commit that referenced this issue Feb 4, 2025
It isn't clear how to fix this without slowing down the analyzer significantly. As this has not been a highly requested, I'm going to Won't Fix this.

Closes #1363
@AArnott AArnott closed this as completed in 50873c3 Feb 6, 2025
@PaulKlein
Copy link
Author

Thanks @AArnott for taking a look at this, and thanks again for the excellent set of analysers here.

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

Successfully merging a pull request may close this issue.

2 participants