Resharper string.Format highlighting for Trace methods
ReSharper has fantastic string.Format highlighting such that you can see where format parameters are missing or redundant in the list of parameters. It only does this for certain functions though, such as Debug.Writeline. If you create your own functions you can annotate the code directly. However if you want to annotate a function that doesn't belong to you, you can still do this through the external annotations method.
A set of functions that ReSharper doesn't format in this way out of the box that I can't live without are the Trace.TraceInformation/Warning/Error methods.
To get these highlighted, add the following XML to "C:\Program Files (x86)\JetBrains\ReSharper\v7.1\Bin\ExternalAnnotations\.NETFramework\System\Attributes.xml". You'll see a section near the bottom for Debug.Writeline already.
A set of functions that ReSharper doesn't format in this way out of the box that I can't live without are the Trace.TraceInformation/Warning/Error methods.
To get these highlighted, add the following XML to "C:\Program Files (x86)\JetBrains\ReSharper\v7.1\Bin\ExternalAnnotations\.NETFramework\System\Attributes.xml". You'll see a section near the bottom for Debug.Writeline already.
format format format
After setting that up, in order to benefit from it, you will need to global search-and replace (ensuring that you have "Match case" and "Use: Regular expressions" enabled):
ReplyDeleteFind what:
Trace.Trace{.+}\([Ss]tring.Format\({.+}\)\);
Replace with:
Trace.Trace\1(\2);
Thanks David - Great idea!
Delete