C# ClassName()未返回任何代码段工具visual studio 2013

C# ClassName()未返回任何代码段工具visual studio 2013,c#,.net,visual-studio,visual-studio-2013,code-snippets,C#,.net,Visual Studio,Visual Studio 2013,Code Snippets,我试图在VisualStudio中使用snippet工具在每个文件中生成版权文本。我创建了一个代码段文件,如下所示: <?xml version="1.0" encoding="utf-8"?> <CodeSnippet Format="1.0.0" xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet"> <Header> <

我试图在VisualStudio中使用snippet工具在每个文件中生成版权文本。我创建了一个代码段文件,如下所示:

            <?xml version="1.0" encoding="utf-8"?>
<CodeSnippet Format="1.0.0"  xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
    <Header>
        <Title>Copyright (c) 2014, CompanyName</Title>
        <Description>License applies to this software </Description>
      <Author>CompanyName</Author>
      <Shortcut>Copyright</Shortcut>
    </Header>
    <Snippet>
        <Declarations>
            <Literal Editable="false">
                <ID>classname</ID> 
                <ToolTip>Class name</ToolTip> 
                <Function>ClassName()</Function> 
            </Literal>
        </Declarations>
        <Code Language="CSharp">
            <![CDATA[
             /*Copyright file $classname$

             *
             *Copyright (c) 2015, CompanyName
             *
             *Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
             *
             *1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
             *
             *2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other 
             *materials provided with the distribution.
             *
             *3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific 
             *prior written permission.

             *THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
             *PURPOSE ARE DISCLAIMED. *IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF *SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, *DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
             *ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED *OF THE POSSIBILITY OF SUCH DAMAGE.
             */]]>
        </Code>
    </Snippet>
</CodeSnippet>

版权所有(c)2014,公司名称
许可证适用于此软件
公司名称
版权
类名
类名
类名()



但是,当我插入此代码时,ClassName()函数没有返回任何类名。

我现在看到了您的问题。如果将代码段添加到类中,这将起作用。如果在类之外的顶部插入此项,则无法执行此操作,因为该类不是代码段的上下文。

然后将其替换为此ClassNamePlaceholder,但我需要类名。我看到:D,如果它们具有调用文件名的函数,则会更好。