Skip to content

VSTHRD110 false positive fires when parentheses are added #1168

@iouri-s

Description

@iouri-s

Bug description

Repro steps

Code to reproduce the behavior.

class Class1
{

    public Func<Task<Dictionary<string, int>>>? VCLoadMethod;


    public Dictionary<string, int>? VirtualCurrencyBalances
    {
        get
        {   // This has no issue:
            // return VCLoadMethod?.Invoke().GetAwaiter().GetResult();

            // This triggers the warning:
            return (VCLoadMethod?.Invoke()).GetAwaiter().GetResult();
        }
    }
}

While parentheses are pointless in this case, they may be needed in more complex constructs such as (VCLoadMethod?.Invoke() ?? Task.FromResult(default(Dictionary<string, int>))).GetAwaiter().GetResult();
image

Expected behavior

Expect no warning.

Actual behavior

VSTHRD110

  • Version used:
  • Application (if applicable):

Additional context

Add any other context about the problem here.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions