IDE0290 suggests the use of primary constructors, but if one of the parameters happens to a IDisposable injected and you use readonly backup fields to store them, a CA2213 warning is generated
public class MyController(EfContext context)
{
private readonly EfContext _context = context; <-- here
CA2213 A type that implements System.IDisposable declares fields that are of types that also implement IDisposable. The Dispose method of the field is not called by the Dispose method of the declaring type. To fix a violation of this rule, call Dispose on fields that are of types that implement IDisposable if you are responsible for allocating and releasing the unmanaged resources held by the field.
However, the controller should be responsible of disposing that object. Is it a false positive?
NB: using a in
parameter also gives that warning:
public class MyController(in EfContext context)
{
private readonly EfContext _context = context; <-- here again
1