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

VSTHRD010 code fix fails inside a lambda #275

Open
davkean opened this issue May 13, 2024 · 0 comments
Open

VSTHRD010 code fix fails inside a lambda #275

davkean opened this issue May 13, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@davkean
Copy link
Member

davkean commented May 13, 2024

Bug description

  • Version of the vssdk-analyzers: 17.11.13-preview
  • Analyzer rule: VSTHRD010
  • Error (exception message, type, and callstack where applicable):

To Reproduce

  1. CTRL+. on the point marked by $
            private JoinableTaskContext joinableTaskContext;
            public int Invoke(IVsInvokablePrivate pInvokable)
            {
                try
                {
                    return this.joinableTaskContext.Factory.Run(async delegate
                    {
                        await this.joinableTaskContext.Factory.SwitchToMainThreadAsync();
                        return pInvokable.$Invoke(); // <--- here
                    });
                }
                catch (Exception ex)
                {
                    return Marshal.GetHRForException(ex);
                }
            }

See: https://github.com/microsoft/vssdktestfx/blob/main/src/Microsoft.VisualStudio.Sdk.TestFramework/GlobalServiceProvider.cs#L299-L313

Expected behavior

No crash

Actual behavior

Crash:

System.ArgumentException : A non-empty value is required.
Parameter name: methodAsString
at Microsoft.VisualStudio.Threading.Analyzers.Utils.FindMethodGroup(SemanticModel semanticModel,String methodAsString)
at async Microsoft.VisualStudio.Threading.Analyzers.VSTHRD010MainThreadUsageCodeFix.RegisterCodeFixesAsync()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at async Microsoft.CodeAnalysis.CodeFixes.CodeFixService.GetCodeFixesAsync()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at async Microsoft.CodeAnalysis.Extensions.IExtensionManagerExtensions.PerformFunctionAsyncT

@AArnott AArnott added the bug Something isn't working label May 17, 2024
AArnott pushed a commit to AArnott/VSSDK-Analyzers that referenced this issue Jul 3, 2024
Bumps [powershell](https://github.com/PowerShell/PowerShell) from 7.4.2 to 7.4.3.
- [Release notes](https://github.com/PowerShell/PowerShell/releases)
- [Commits](PowerShell/PowerShell@v7.4.2...v7.4.3)

---
updated-dependencies:
- dependency-name: powershell
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants