Skip to content

RCS1140 throws an ArgumentNullException in try/catch when exception is not used #1553

@merlinschumacher

Description

@merlinschumacher

Rosylnator Analyzers 4.12.7:

Steps to Reproduce:
Create a custom exception, use the custom exception in a try/catch, where you don't use the exception.

Here is an example project:
https://github.com/merlinschumacher/Roslyn-RCS1140-Issue

With 4.12.6 the issue isn't present.

Actual Behavior:
This triggers an argument null exception. Independent of the presence of an XML comment for the exception:

            try
            {
                Method2();
            }
            catch
            {
                throw new MyCustomException("MyCustomException");
            }

This works (passing the caught exception is not necessary):

            try
            {
                Method2();
            }
            catch (Exception ex)
            {
                throw new MyCustomException("MyCustomException");
            }

Expected Behavior:
To create an analyzer message notifying me of the possibly missing XML comment.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions