Sunday, 15 February 2015

c# - "Redundant code detection" works differently on protected or higher scoped properties and fields -



c# - "Redundant code detection" works differently on protected or higher scoped properties and fields -

in next code example, r# tell me assignment redundant. makes perfect sense me.

private string _name = null; // redundant code warning

however, things different, field / property gets protected or higher

protected string name = null; // no redundant code warning

is bug in r# or there reason behind?

it's because without looking deriving classes, resharper can't tell if it's used or not, errs on side of caution , assumes used, somewhere. if enable solution wide analysis, resharper able see whole solution, , know if field used in derived class or not. show redundant code warning.

c# resharper

No comments:

Post a Comment