How to make Resharper show Refactoring that it is already

Whenever Resharper encounters this code:

(treeListNode.Tag as GridLine).AdvertiserSeparation = 5;

it presents you with a possible fix (since treeListNode.Tag as a GridLine may be null). It says: "Replace with Direct Cast", which turns the code into the following:

((GridLine) treeListNode.Tag).AdvertiserSeparation = 5;

It's great. However, when he encounters such code:

GridLine line = treeListNode.Tag as GridLine;
line.AdvertiserSeparation = 5;

Resharper simply displays the warning “Possible System.NullReferenceException”, but does not offer me “Replace with Direct Cast”. Is there a way to get Resharper to offer me this refactoring since it already has it?

+3
source share
1

, . . , , . Resharper .

Jetbrains , .

http://www.jetbrains.net/jira/browse/RSRP

+1

Source: https://habr.com/ru/post/1729502/


All Articles