一段时间以来,我有一个自定义的Visual Studio代码段,以帮助在我的C#源文件中注入版权标头。看起来像这样:
<CodeSnippet Format="1.0.0" xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<Header>
<Title>File Header</Title>
<Author>Me</Author>
<Shortcut>header</Shortcut>
<Description>Inserts a standard copyright header.</Description>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Declarations>
<Literal>
<ID>FileName</ID>
<ToolTip>The name of the C# code file.</ToolTip>
<Default>FileName</Default>
</Literal>
</Declarations>
<Code Language="CSharp"><![CDATA[// -----------------------------------------------------------------------
// <copyright file="$FileName$.cs" company="Company Name">
// Copyright © 2011-2016 by Company Name. All rights reserved.
// </copyright>
// -----------------------------------------------------------------------
]]></Code>
</Snippet>
</CodeSnippet>
对于此问题要注意的重要事项是CDATA块末尾的两个尾端。在2015年之前的Visual Studio版本中,我可以将光标放在文件的开头,恰好在第一个using声明之前,type header+TAB
,并且我的标头会出现在最后一个注释和第一个using声明之间的多余的空行。 。
Visual Studio 2015似乎不支持尾随空格。当我键入时header+TAB
,第一个using声明与最后一条注释出现在同一行。
我是在查看错误,还是有办法配置我的代码段,以使Visual Studio 2015能够遵守尾随的空白?
在查看VS附带的片段时,我看到的常见现象是大多数代码以 $end$
开关示例:
<Code Language="csharp"><![CDATA[switch ($expression$) { $cases$ }*$end$*]]> </Code>
放置$end$
在结尾的空白,像这样的结尾:
<![CDATA[// -----------------------------------------------------------------------
// <copyright file="$FileName$.cs" company="Company Name">
// Copyright © 2011-2016 by Company Name. All rights reserved.
// </copyright>
// -----------------------------------------------------------------------
$end$]]>
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句