File Header Macros in ReSharper 6
July 25th, 2011 by Hadi HaririPrevious posts introducing ReSharper 6:
- ReSharper 6 EAP is Open; Details on JavaScript Support
- CSS Support in ReSharper 6
- ReSharper 6 Bundles Decompiler, Free Standalone Tool to Follow
- ReSharper 6 Enhances Suggestions with Explanations
- ReSharper 6 Introduces support for JavaScript Unit Testing with QUnit
- ReSharper 6 Enhances Razor Support
Sometime ago I wrote about Automating File Header Information, showing how to insert license information and other data in project files. One of the shortcomings ReSharper had however was the inability to support macros. Something as simple as inserting the current year or filename required the support of StyleCop for ReSharper. ReSharper 6 now support macros allowing file headers to contain varying information:
For instance, in the previous license header, the Copyright years are fixed to 2010 – 2011. It also has no information relevant to the actual project. We could of course hardcode the name of the project in there but since this setting is not solution-specific, it would be of little use. Other data such a filenames however would be impossible to do.
With ReSharper 6 we simply remove the hardcoded values and replace them with macros. We can either type them in or click on the corresponding macro, which will insert it at current cursor position:
With this change in place, next time we run a code-cleanup and have the Update File Header option activated, we will get up to date and project/file specific header information inserted. Next feature request: Custom Macros!
Tags: ReSharper, ReSharper 6

August 21st, 2011 at 6:17 pm
Unfortunately, enabling file header addition/update seems to cause R# to always modify the file during clean-up, even if it has not materially changed the contents, and this is a step backwards from pre-6 versions of R# which would leave the file alone if clean-up would not change anything. It is a relatively minor issue, but I do hope that this gets addressed in a patch, as it removes the previous ability to instantly know if a clean-up operation has changed the file or not.
August 22nd, 2011 at 11:18 am
@Jeremy
Could you please log it with a test case to reproduce in http://youtrack.jetbrains.net/issues/RSRP ?
Thanks