Highlight unused classes, methods, variables

After using ReSharper with C# for many years, I figure I'd replace Visual Assist X with ReSharper C++ for a try. One of my favorite features of ReSharper for C# is the color highlighting (grey) when a class, method, or variable is not used. Is it possible to get this functionality in ReSharper C++?

As additional feedback, I was confused seeing grey variables initially and eventually discovered these were method parameters. I turned this off because I find it distracting and misleading (based on my previous experience where grey meant unused).

Thanks

3 comments

Jeffrey,

Thanks for giving R++ a try. We haven't yet come up with a way to implement the "unused class/method/field/global variable" analysis in C++ precisely. In C# it relies on solution-wide analysis, which is too prohibitive for C++ given the specifics of the language.

For local variables and function parameters the analysis should work though, and they are indeed marked as grey by default. Do I understand correctly that you've found an example where R++ marks a parameter as unused when it is actually being used? Could you please share a code snippet where this happens?

0

This isn't the best example, but it should suffice.

What I notice is that parameters are highlighted grey (line 74). I dislike this because when I see the variable used on line 78 it makes me feel like that variable is not referenced anywhere (which I believe was the intention of the grey highlighting in ReSharper for C#).

resharper.png

I notice in another method where I assign an HRESULT variable but never reference it it does in fact show "Assigned value is never used" in the same (or very similar?) grey color. I like the "is never used" highlighting but I don't like the parameter highlighting. The colors are the same or look close enough to me and lead to confusion.

It would be AWESOME to have the "unused class/method/field/global variable" analysis in C++ but I understand the difficulty. If you guys figure that one out I'm sure I wouldn't be the only one who's excited. :)

Thanks

0

Thanks for the example! This grey color is the color Visual Studio uses by default to highlight function parameters. It can be modified by changing the "ReSharper C++ Parameter Variable Identifier" color from "Default" to e.g. "Black", and differs slightly from the R++ unused variable highlighting - the latter one is lighter. We do not set it ourselves since some VS users might have gotten used to the default color scheme, but we'll consider doing that.

0

Please sign in to leave a comment.