Skip to content

False positive in "Invoke single-threaded types on Main thread" #274

@davkean

Description

@davkean

Bug description

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

To Reproduce

            private JoinableTaskContext joinableTaskContext;
            public int Invoke(IVsInvokablePrivate pInvokable)
            {
                try
                {
                    return this.joinableTaskContext.Factory.Run(async delegate
                    {
                        await this.joinableTaskContext.Factory.SwitchToMainThreadAsync();
                        return pInvokable.Invoke(); // Fires
                    });
                }
                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

Should not fire

Screenshots

Analyzer outputs warning

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions