superlogical
superlogical

Reputation: 14950

How do I get Visual Studio to add a open source license at the top of each file

How do I get Resharper to add a open source license at the top of each file?

Upvotes: 2

Views: 1365

Answers (3)

Chris
Chris

Reputation: 6325

This is the snippet I put together for the MIT license. You open up a C# code file, you type 'license' hit tab twice and you are defaulted to the year and copyright holder sections.

Here is a link that describes the process. Hope this helps.

    <?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
  <CodeSnippet Format="1.0.0">
    <Header>
      <Title>Simple MIT License</Title>
      <Shortcut>license</Shortcut>
      <Description>
       The standard MIT licnese.
      </Description>
      <Author>Example License</Author>
      <SnippetTypes>       
        <SnippetType>Expansion</SnippetType>
      </SnippetTypes>
    </Header>   
    <Snippet>
    <Declarations>
    <Literal>
      <ID>year</ID>
      <ToolTip>Copyright year</ToolTip>
      <Default>year</Default>
    </Literal>
    <Literal>
      <ID>copyrightholders</ID>
      <ToolTip>Replace This With the Copyright Holders name</ToolTip>
      <Default>copyrightholders</Default>
    </Literal>  
  </Declarations>
  <Code Language="CSharp">
    <![CDATA[
    /*
        The MIT License

        Copyright (c) $year$ $copyrightholders$

        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:

        The above copyright notice and this permission notice shall be included in
        all copies or substantial portions of the Software.

        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
        THE SOFTWARE.
    */
   ]]>
  </Code>
    </Snippet>
  </CodeSnippet>
</CodeSnippets>

Upvotes: 1

knight666
knight666

Reputation: 1619

You could make a small script with Visual Assist X though. It wouldn't do it automatically, but all you'd have to do is type lic at the top of the page to output the licensing information.

Upvotes: 2

Traveling Tech Guy
Traveling Tech Guy

Reputation: 27809

If I understand you correctly, you want a comment at the top of each source file, detailing your licensing model?
If so, try Visual Studio templates.

Upvotes: 4

Related Questions