Skip to content

Conversation

@Qluxzz
Copy link
Contributor

@Qluxzz Qluxzz commented Sep 15, 2024

There was no tests for RCS1140 so I added one based on the documentation for the rule.

When I was testing this rule I was not expecting it to require me to document exception types thrown but caught in the same method.

An example from a unit test I created

public void Foo(object parameter)
{
    try 
    {
        if (parameter == null)
            throw new ArgumentNullException(nameof(parameter));
    }
    catch (ArgumentNullException) {}
}

Here the exception is caught in the method but the analyzer for RCS1140 still require it to be documented on the method.

This PR checks if the exception type thrown in the method is also caught in the same method, and then removes the requirement to document it for the method.

@Qluxzz
Copy link
Contributor Author

Qluxzz commented Sep 15, 2024

@dotnet-policy-service agree

Copy link
Collaborator

@josefpihrt josefpihrt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update changelog.

@Qluxzz Qluxzz requested a review from josefpihrt September 22, 2024 12:02
@Qluxzz Qluxzz requested a review from josefpihrt September 27, 2024 10:31
josefpihrt
josefpihrt previously approved these changes Sep 27, 2024
Copy link
Collaborator

@josefpihrt josefpihrt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great PR! Thanks for the contribution.

@josefpihrt josefpihrt merged commit bde6487 into dotnet:main Sep 27, 2024
17 checks passed
@Qluxzz Qluxzz deleted the fix-required-to-document-caught-exceptions branch September 30, 2024 14:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants