-
Notifications
You must be signed in to change notification settings - Fork 485
Closed
Labels
BugThe product is not behaving according to its current intended designThe product is not behaving according to its current intended designDataFlowFalse_PositiveA diagnostic is reported for non-problematic caseA diagnostic is reported for non-problematic case
Milestone
Description
static void Repro()
{
D d = null;
try
{
d = new D();
}
finally
{
d?.Dispose();
}
}
class D : IDisposable
{
public D() => throw new InvalidOperationException();
public void Dispose() { }
}
The constructor of D
can throw and leave d
to be null
, so the finally
block correctly checks for null
. However, CA1508 suggests to remove the null check.
csdahlberg
Metadata
Metadata
Assignees
Labels
BugThe product is not behaving according to its current intended designThe product is not behaving according to its current intended designDataFlowFalse_PositiveA diagnostic is reported for non-problematic caseA diagnostic is reported for non-problematic case