Skip to main content
A newer version of this page is available. .

How To Add a License to Code Files

CodeRush enables you to add a comment with context-dependent elements to the beginning of the file. You can use this feature to add an author and a license to all source code files in your solution:

  1. Open the CodeRush | Code Templates... window.
  2. Focus the 1-key | h template.

    HowTo_Header1

  3. Customize the template. You can use Text Commands and String Providers to add variable strings into it (for example, the file path). For example, add an MIT license to your code:

    HowTo_Header_2

  4. Test the new template: open a source file and add a copyright header to it. You can execute the Add Copyright Header code provider or expand the h template on the first line:

    HowTo_Header_GIF

Add a License to All Project Files

Enable the Add copyright header cleanup provider and run Code Cleanup:

  1. Open the Editor | C# | Code Cleanup options page.
  2. Check the Add copyright header item in the cleanup refactorings/providers list.
  3. Uncheck the items you do not need.
  4. Clean up your project:

    HowTo_CleanupProj