You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
usingMoq;varmock=newMock<ILogger>();mock.Verify(
x =>x.InfoAsync(It.IsAny<string>()),Times.Never,"No Log should have been written");publicinterfaceILogger{TaskInfoAsync(stringmessage);}
Expected behavior
No warning.
Actual behavior
VSTHRD110 warning.
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.
The text was updated successfully, but these errors were encountered:
As a simple workaround for this issue, use a Times object instead of a method group. For example, use Times.Never() instead of Times.Never:
mock.Verify(
x =>x.InfoAsync(It.IsAny<string>()),Times.Never(),"No Log should have been written");
This will not trigger VSTHRD110 warning, because another Verify method overload with Func<Task> will be used instead of an overload with Action<T> that doesn't not return a task to the caller.
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:
Expected behavior
No warning.
Actual behavior
VSTHRD110 warning.
![image](https://user-images.githubusercontent.com/7333278/226138690-a0cb90e3-be2b-401e-a01b-404844a8276e.png)
Microsoft Visual Studio Enterprise 2022 (64-bit) - Current
Version 17.4.5
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: