What's wrong with this C# CodeSnippet?
I've made snippets before but I must be overlooking something really simple; I cannot figure out where the error is in this snippet...
<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>
Basically, when I got to import the snippet, it says that it is "invalid开发者_如何学运维". The file name is "nie.snippet". Thanks!
The author tag is not allowed as it seems to me:
<?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>
See here: http://msdn.microsoft.com/en-us/library/ms379562%28VS.80%29.aspx
The <CodeSnippet>
tag isn't closed. Append </CodeSnippet>
to the file.
Thanks for the help everyone. The missing end tag was my fault from copying onto the Stack. I took out the author tag and added the xml... tag to the top. Also, I had "C#" where "CSharp" should have been. Here is a final working version of the snippet!
<?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>
It doesn't look like you have closed the
<CodeSnippet>
Tag.
精彩评论