简体   繁体   中英

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; } 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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM