marinasundstrom / CheckedExceptions

Enforce better exception handling in C#/.NET by ensuring exceptions are explicitly handled.
MIT License
5 stars 1 forks source link

Duplicates not detected when declaring multiple exceptions in one `ThrowsAttribute` for lambdas #67

Closed marinasundstrom closed 1 hour ago

marinasundstrom commented 15 hours ago

Duplicates not detected when declaring multiple exceptions in one ThrowsAttribute for lambdas.

    public void Foo2()
    {
        var fetcher = [Throws(typeof(NullReferenceException), typeof(NullReferenceException))] () =>
        {
            throw new NullReferenceException();
        };

        fetcher();
    }
mnmnk43434 commented 15 hours ago

Hello, we tried to solve the issue.

This is what we did:

Modified the CheckForDuplicateThrowsAttributes method to handle cases where multiple exception types are declared in a single ThrowsAttribute. This change applies to both lambdas and local functions.

You can review changes in this commit: https://github.com/mnmnk43434/marinasundstrom-CheckedExceptions-67/commit/bf818087e53a0a4a44619daef9be669fe81158a3.

[!CAUTION] Disclaimer: The concept of solution was created by AI and you should never copy paste this code before you check the correctness of generated code. Solution might not be complete, you should use this code as an inspiration only.


If you no longer want Latta AI to attempt solving issues on your repository, you can block this account.