dotnet / dotnet/roslynator

RCS1220 Use pattern matching instead of is+as?

Open
#372 0 comments 0 reactions 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

An is+cast operator gets flagged by RCS1220. Should is+as also be flagged to be replaced by pattern matching?

```csharp
void Method(Control control)
{
//is+cast operator
if (control is TextBox)
{
TextBox textbox = (TextBox)control;
}

//is+as
if (control is TextBox)
{
TextBox textbox = control as TextBox;
}
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.