Artur Keyan
Artur Keyan

Reputation: 7683

C# code snippet does not automatically import namespace

I have code snippet for Dbset<>

<CodeSnippet Format="1.1.0" xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
  <Header>
    <Title>DbSet</Title>
    <Author>Կյանքի Համար</Author>
    <Shortcut>dbset</Shortcut>
    <Description>Add entity into context </Description>
    <SnippetTypes>
      <SnippetType>Expansion</SnippetType>
    </SnippetTypes>
  </Header>
  <Snippet>
    <Imports>
      <Import>
        <Namespace>Domain</Namespace>
      </Import>
    </Imports>
    <Declarations>
      <Literal>
        <ID>entity</ID>
        <ToolTip>Entity</ToolTip>
        <Default>Entity</Default>
      </Literal>
    </Declarations>
    <Code Language="csharp">
      <![CDATA[public DbSet<$entity$> $entity$s { get; set; }$end$      
      ]]></Code>
  </Snippet>
</CodeSnippet>

it is generating this: public DbSet<Game> Games { get; set; }

in this part I adding namespace for this snippet.

<Imports>
    <Import>
       <Namespace>EDGE.Domain</Namespace>
    </Import>
 </Imports>

I believe that the namespace should be automatically added when I use this snippet, but it did not.

I can not find the descriptions for each attribute of .snippet file(is there any reference documentation of all supported attributes and their meaning?). Can anyone tell me what is tag for?

Upvotes: 5

Views: 2391

Answers (1)

Andrei
Andrei

Reputation: 56688

From MSDN:

Namespace Element - Specifies the namespace that must be imported for the code snippet to compile and run.

Check it out - all snippet schema tags and their attributes are described there.

Upvotes: 3

Related Questions