vs-threading icon indicating copy to clipboard operation
vs-threading copied to clipboard

VSTHRD110 fires in Expression-valued scenarios

Open iouri-s opened this issue 2 years ago • 1 comments

Bug description

When a Task-valued lambda is passed into a method expecting an Expression<> argument, VSTRD110 shouldn't fire, because no invocation is likely being made.

Repro steps

Code to reproduce the behavior.

Write a test using Moq library in VisualStudio:

using Moq;

var mock = new Mock<ILogger>();
mock.Verify(
    x => x.InfoAsync(It.IsAny<string>()),
    Times.Never,
    "No Log should have been written");

public interface ILogger
{
    Task InfoAsync(string message);
}

Expected behavior

No warning.

Actual behavior

VSTHRD110 warning. image

  • Version used: 17.5.22
  • Application (if applicable): Microsoft Visual Studio Enterprise 2022 (64-bit) - Current Version 17.4.5

Additional context

Add any other context about the problem here.

iouri-s avatar Mar 18 '23 20:03 iouri-s

Thank you for this report. It makes sense and I agree with your suggestion.

AArnott avatar Mar 20 '23 14:03 AArnott