IDISP013 "Await in using" is thrown for expression trees for async methods
ssg opened this issue · comments
Sedat Kapanoğlu commented
The code below will throw IDISP013 when mocking up a class using Moq library:
public class O : IDisposable
{
public async Task<int> SomeMethod()
{
...
}
}
private void mock()
{
using var o = new O();
var mock = createMock()
.Setup(o => o.SomeMethod())
.ReturnsAsync(5);
}
Setup()
method receives an Expression<T>
. So, the warning there feels superfluous. I don't think it has a feasible fix either. (Async lambda expressions can't be mapped to expression trees).