How to get Resharper to show a Refactoring that it already has.
- by AngryHacker
Whenever Resharper encounters code like this:
(treeListNode.Tag as GridLine).AdvertiserSeparation = 5;
it presents you with a possible fix (since treeListNode.Tag as GridLine might be null). It says: 'Replace with Direct Cast', which turns the code into the following:
((GridLine) treeListNode.Tag).AdvertiserSeparation = 5;
This is great. However, when it encounters code like this:
GridLine line = treeListNode.Tag as GridLine;
line.AdvertiserSeparation = 5;
Resharper simply displays a warning 'Possible System.NullReferenceException', but does not offer me to 'Replace with Direct Cast'. Is there a way to make Resharper offer me this refactoring, since it already has it?