views:

138

answers:

3

Okay, I have a problem with Resharper that is driving me nuts. Let's say I create a method such as

    private int returnAValue(string something)
    {
        int dmid;
    } 

As I'm typing the method Resharper take the variable dmid and declares that it is a 'Local Variable that is never used'. As a result it changes the coloring of the text. How can I suppress this?

+8  A: 

Simply ignore that sort of warning until you've actually written enough code to care. In my experience that's usually not long after the declaration, assuming you're declaring variables as late as you can (which I consider to be a good idea). While the code is still being typed, it's unlikely to even compile...

If you have finished the method and you've still got the warning, then it's absolutely right - you should get rid of the unused variable.

Jon Skeet
+1 for suggesting declaring variables as late as possible.
Chris Dwyer
A: 

Type faster (and/or have a bigger solution) - then you'll beat R# and use the variable before it's highlighted. ;)

FWIW, I don't use R# - but surely they have an option to disable that check? Let the compiler catch it as a warning if you like, but then it'd only flag it on build.

Mark Brackett
A: 

I use resharper 4.5; thou I don't recommend turning this littler warning helper off I believe you can change the setting by following this path in Visual Studio. ReSharper -> Options -> Code Inspection -> Inspection Severity then look in the Potential Errors and Bad Practices. Hope that helps.

Geovani Martinez