marinasundstrom / CheckedExceptionsAnalyzer

0 stars 0 forks source link

Detect and warn when code might not be reached #10

Open marinasundstrom opened 4 days ago

marinasundstrom commented 4 days ago

Detect and warn when code might not be reached because of being after call to method might be throwing, due to not being handled by try-catch.

This applies to all code blocks. Methods, properties, lambdas, local functions.

public string Data
{
    [Throws(typeof(InvalidOperationException))]
    public void Foo()
    {
        throw new InvalidOperationException();
    }

    [Throws(typeof(InvalidOperationException))]
    get
    {
        Foo(); // This call may throw exception.

        // The code after might not run.

        return null;
    }
}