DotNetAnalyzers/IDisposableAnalyzers

IDISP001 is being triggered in .net 6 style asp.net program/startup classes

xt0rted opened this issue · 1 comments

After migrating my application to the new top-level statement program/startup format in asp.net 6 IDISP001 is being triggered on the following line:

var app = builder.Build();

This can be seen by creating a new asp.net core web app, installing this analyzer & setting the rule to error, and building.

If I disable this rule then I get a second error of IDE0079 for the whole code block.

#pragma warning disable IDISP001 // Dispose created.
var app = builder.Build();
#pragma warning restore IDISP001 // Dispose created.

Why not:

using var app = builder.Build();