Skip to content

Improve S3247: Rule should recommend pattern matching for new C# instead of as #2120

@Evangelink

Description

@Evangelink

Description

Currently, when the rule detects a is check in an if followed by a cast, it raises an issue recommending to Replace this type-check-and-cast sequence with an 'as' and a null check.. While this is still relevant it makes more sense for modern applications to suggest to use pattern matching instead.

Repro steps

https://sonarcloud.io/project/issues?id=sonarlint-visualstudio&issues=AWMB0jMemtQEh111EJCu&open=AWMB0jMemtQEh111EJCu

TODO

  • Rule should be updated
  • RSPEC should be updated
  • Tests should be updated

When implementing this rule consider also #223

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions