我以前做过片段,但我必须忽略一些非常简单的事情;我无法弄清楚此代码段中的错误位置......
<CodeSnippet Format="1.0.0" xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<Header>
<Title>Throw NotImplementedException()</Title>
<Author>olaffuB</Author>
<Shortcut>nie</Shortcut>
<Description>Quickly add a new NotImplementedException() to code.</Description>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Declarations>
<Literal>
<ID>TODO</ID>
<Default></Default>
</Literal>
</Declarations>
<Code Language="C#">
<![CDATA[throw new NotImplementedException("$TODO$"); // TODO: $TODO$]]>
</Code>
</Snippet>
</CodeSnippet>
基本上,当我导入代码片段时,它说它“无效”。文件名是“nie.snippet”。谢谢!
答案 0 :(得分:2)
<CodeSnippet>
标记未关闭。将</CodeSnippet>
附加到文件中。
答案 1 :(得分:2)
我不允许使用作者标记:
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippet Format="1.0.0">
<Header>
<Title>class</Title>
<Shortcut>class</Shortcut>
<Description>Expansion snippet for class</Description>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
<SnippetType>SurroundsWith</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Declarations>
<Literal default="true">
<ID>name</ID>
<ToolTip>Class name</ToolTip>
<Default>MyClass</Default>
</Literal>
</Declarations>
<Code Language="csharp" Format="CData">
<![CDATA[class $name$
{
$selected$$end$
}]]>
</Code>
</Snippet>
</CodeSnippet>
见这里:http://msdn.microsoft.com/en-us/library/ms379562%28VS.80%29.aspx
答案 2 :(得分:1)
感谢大家的帮助。丢失的结束标记是我复制到堆栈的错。我拿出了作者标签并将xml ...标签添加到顶部。此外,我有“C#”,其中“CSharp”应该是。这是片段的最终工作版本!
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippet Format="1.0.0" xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<Header>
<Title>Lemme Throw NotImplementedException()</Title>
<Shortcut>nie</Shortcut>
<Description>Allows an extreme coder to quickly add a new NotImplementedException to their code.</Description>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Declarations>
<Literal>
<ID>TODO</ID>
<Default>###</Default>
</Literal>
</Declarations>
<Code Language="CSharp" >
<![CDATA[throw new NotImplementedException("$TODO$"); // TODO: $TODO$]]>
</Code>
</Snippet>
</CodeSnippet>
答案 3 :(得分:0)
看起来你没有关闭
<CodeSnippet>
标签