Chris Pfohl
Chris Pfohl

Reputation: 19074

Is there a way to make the C# compiler issue a warning when instance variable is hidden(shadowed)?

I am refactoring a little bit of code and I think I have created some instance variables that are being hidden(shadowed) in older methods. I want to see a warning wherever the hiding(shadowing) happens so I can check to make sure that it's actually what I want (and it's hardly ever what I want). Is there any easy way to do that?

Upvotes: 6

Views: 328

Answers (3)

bdukes
bdukes

Reputation: 156005

If you run Code Analysis, that'll show up (as CA1500 from the Maintanability section).

Upvotes: 5

JaredPar
JaredPar

Reputation: 755179

No there is no way to make the C# compiler emit this warning.

Upvotes: 1

SRM
SRM

Reputation: 1377

Have you looked into any productivity tools such as Resharper? http://www.jetbrains.com/resharper/

It will find that (and probably proactively warn you) with very little effort on your part.

Upvotes: 2

Related Questions