I'm currently trying to write rules to enforce some code formatting for our team using Resharper 9.
Some of the rules I'm trying to write don't work properly or don't work at all.
Example :
Enforcing simple getter and setter properties in a single line :

which will convert this :

to this :
public string Description { get; set;
}
As you can see, the ending curly brace is gone to a new line which I didn't ask for.
Anyone has encountered this problem ?
Another random issue is to rewrite methods with an empty space between the method name and the leading parenthesis :

but I can't get this one to work. Any help would be great
Structural Search and Replace isn't designed to enforce formatting - almost the opposite! It's designed to match code regardless of formatting, and to match code constructs that are similar (e.g. x > 1 and 1 < x are equivalent matched statements).
To enforce this kind of formatting requires something like StyleCop. There is currently a plugin for 9.1, but not 9.2. The plugin for 9.1 is available in ReSharper's Extension Manager (ReSharper → Extension Manager), however, it's only visible if you enable pre-release extensions (ReSharper → Options → Extension Manager → Enable pre-release). Hopefully, the 9.2 compatible version will be available soon.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With