IDISP013 does not trigger for using declaration
Closed this issue · 2 comments
Bouke commented
A using statement does throw IDISP013 as expected:
using (var scope = CreateScope())
return wrapped.HandleAsync(command, token);
However rewriting this to a using declaration does not trigger it, but should:
using var scope = CreateScope();
return wrapped.HandleAsync(command, token);
Failing test:
[Test]
public static void UsingDeclaration()
{
var code = @"
namespace N
{
using System.Threading.Tasks;
public static class C
{
public static ValueTask<int> MAsync()
{
using var file = System.IO.File.OpenRead(string.Empty);
return ↓InnerAsync();
}
private static async ValueTask<int> InnerAsync()
{
await Task.Delay(10).ConfigureAwait(false);
return 1;
}
}
}";
RoslynAssert.Diagnostics(Analyzer, ExpectedDiagnostic, code);
}
JohanLarsson commented
Great issue, thanks!