File Header Macros in ReSharper 6
Previous posts introducing ReSharper 6:
- CSS Support in ReSharper 6
- ReSharper 6 Bundles Decompiler, Free Standalone Tool to Follow
- ReSharper 6 Enhances Suggestions with Explanations
- 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!