views:

257

answers:

2
+2  Q: 

Resharper gotchas

i absolutely adore ReSharper and would not work without it, but there are a few gotchas that i have run into and learned to avoid:

  • Allowing ReSharper to rename string literals automatically can really bite you in such instances as when your object variables match column names in your DAL SQL or other string constants. i have learned that instead of impatiently hitting the enter key when the second rename dialog appears i really need to see what ReSharper is suggesting and often skip the string literals rename step.
  • This one is a little more insidious: When you have Solution-Wide analysis turned on ReSharper will tell you whether or not public methods are used. This includes getters and setters in properties. It's a great feature but what ReSharper doesn't know is that when you're designing a view which will be displayed in the designer (form, user ctrl) that the property getters and setters are called at design time and don't show up in compilation. So ReSharper will suggest that those property's getters or setters can be made private or just removed. But if you make the adjustment and then load the view in the designer, the designer will crash because the property is not available and the error message is not exactly obvious. In a nutshell, a programmer needs to carefully consider property usage suggestions when designing a view.

Whew! Those are my biggies. What else is out there that could bite me and fellow ReSharper aficionados?

+2  A: 

When I run across preprocessor directives that use #ifs to do conditional compilation, and the current configuration is set so that a block of code is hidden, it doesn't seem to see the #if'd code and will recommend yanking out a variable that block of code uses, thinking it's never called.

Chris
+2  A: 

You can mark such properties by UsedImplicitly attribute and ReSharper will not suggest to remove it.

derigel
Good one, though i like to avoid using attributes to direct a productivity tool as it ties the code to a third party package. Is there possibly a setting where R# can ignore attributes in Control-derived classes? Or perhaps that should be a feature suggestion for the JetBrains team for the next release.
Paul Sasik
lol. Team 23! i think that perhaps i did just put in a feature request!
Paul Sasik
It's not necessary to reference JetBrains assembly.You can copy these attributes to your project, to any place and namespace.Look at ReSharper→Options→Code Annotations→Copy default implementation to clipboard.
derigel