dotnet / dotnet/roslynator

Improve analyzer "Use exception filter" (RCS1236)

Open
#582 0 comments 1 reaction 0 assignees View on GitHub
Area-Analyzers Feature Request
Dominant language
C#
Stars
3.5k
Forks
294
Avg merge
2h 30m
Merged PRs (30d)
4

Description

This
```csharp
try
{
return Load(path);
}
catch (IOException)
{
}
catch (UnauthorizedAccessException)
{
}
catch (XmlException)
{
}
```
can be replaced with this
```csharp
try
{
return Load(path);
}
catch (Exception ex) when (ex is IOException
|| ex is UnauthorizedAccessException
|| ex is XmlException)
{
}
```

Contributor guide

Open the contributing guide

Research direction

Start by locating the RCS1236 analyzer entry point and its existing tests. Use the try/catch example as the acceptance case: the analyzer should recognize consecutive catches for IOException, UnauthorizedAccessException, and XmlException and suggest the shown exception-filter form.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.