Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's wrong with this code snippet?

I tried to import this into the Code Snippets Manager and got the error "The snippet files chosen were not valid." Since this is my first snippet, and the error message doesn't deign to point out why the snippet is not valid, I am at a loss.

<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
  <CodeSnippet Format="1.0.0">
    <Header>
      <Title>EDI Property</Title>
      <Shortcut>edi</Shortcut>
      <SnippetTypes>
        <SnippetType>Expansion</SnippetType>
      </SnippetTypes>
    </Header>
    <Snippet>
      <Declarations>
        <Literal>
          <ID>required</ID>
          <ToolTip>required</ToolTip>
          <Default>[Required]
          </Default>
        </Literal>
        <Literal>
          <ID>min</ID>
          <ToolTip>min</ToolTip>
          <Default>1</Default>
        </Literal>
        <Literal>
          <ID>max</ID>
          <ToolTip>max</ToolTip>
          <Default>10</Default>
        </Literal>
        <Literal>
          <ID>position</ID>
          <ToolTip>position</ToolTip>
          <Default>1</Default>
        </Literal>
        <Literal>
          <ID>type</ID>
          <ToolTip>type</ToolTip>
          <Default>string</Default>
        </Literal>
        <Literal>
          <ID>name</ID>
          <ToolTip>name</ToolTip>
          <Default>Property</Default>
        </Literal>
      </Declarations>
      <Code Language="C#">
        <![CDATA[
        $required$[MinLength($min$)]
        [MaxLength($max$)]
        [ElementPosition($position$)]
        public $type$ $name$ { get; set; }
        ]]>
      </Code>
    </Snippet>
  </CodeSnippet>
</CodeSnippets>
like image 694
Thom Smith Avatar asked Aug 07 '12 14:08

Thom Smith


1 Answers

Your first line is wrong

<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet"></CodeSnippets>

remove the ending </CodeSnippets>

I'm checking against an example created by SnippetDesigner (recommended)
Looks like some tags are missing

  <Title>MySnippet</Title>
  <Author>Steve</Author>
  <Description>
  </Description>
  <HelpUrl>
  </HelpUrl>

also, I haven't find an example where

<Code Language="C#">

but

<Code Language="CSharp">
like image 182
Steve Avatar answered Oct 14 '22 10:10

Steve