gpt4 book ai didi

c# - ClassName() 没有返回任何,片段工具 visual studio 2013

转载 作者:行者123 更新时间:2023-11-30 16:09:03 24 4
gpt4 key购买 nike

我正在尝试使用 visual studio 中的代码片段工具在每个文件中生成版权文本。我创建了一个片段文件如下:

            <?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>

然而,当我插入这段代码时,ClassName() 函数没有返回任何类名。

最佳答案

我现在明白你的问题了。如果您在类(class)内添加您的代码片段,这将起作用。如果您将它插入类之外的顶部,这将无法工作,因为该类不是代码段的上下文。

关于c# - ClassName() 没有返回任何,片段工具 visual studio 2013,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28219097/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com