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?
source
share