$ selected $ используется только один раз в пользовательской Visual Studio c# фрагмент - PullRequest
0 голосов
/ 29 мая 2020

Мой пользовательский фрагмент включает только $ selected $ один раз. Как я могу использовать $ selected $ несколько раз?

Snippet :

<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
  <CodeSnippet Format="1.0.0">
    <Header>
      <SnippetTypes>
        <SnippetType>SurroundsWith</SnippetType>
      </SnippetTypes>
      <Title>Creates a collection using ICollection from the selected entity</Title>
      <Author>Stein Lundbeck</Author>
      <Description>Select entity and the snippet implements ICollection with the selected entity</Description>
      <Shortcut>icoll</Shortcut>
      <Keywords>
        <Keyword>C#</Keyword>
        <Keyword>Collection</Keyword>
        <Keyword>Entity</Keyword>
      </Keywords>
    </Header>
    <Snippet>
    <Imports>
        <Import>
          <Namespace>System.Collections.Generic</Namespace>
        </Import>
        <Import>
          <Namespace>System.Collections.ObjectModel</Namespace>
        </Import>
    </Imports>
    <Declarations>
        <Literal Editable="true">
            <ID>Name</ID>
            <ToolTip>Name of variable</ToolTip>
            <Default>myVar</Default>
        </Literal>
    </Declarations>
        <Code Language="csharp" Delimiter="$" Kind="file">
            <![CDATA[ICollection<$selected$> $Name$ = new Collection<$selected$>();

            $end$]]>      
        </Code>
    </Snippet>
  </CodeSnippet>
</CodeSnippets>

Output :

using System.Collections.Generic;
using System.Collections.ObjectModel;
namespace Test
{
    class MyClass
    {
        ICollection<int> myVar = new Collection<>();
    }  
}

В коллекции <> отсутствует значение из $ selected $

1 Ответ

1 голос
/ 29 мая 2020

Проверьте эту ссылку MSDN для схемы фрагментов кода

«Вы не можете использовать $ end $ или $ selected $ более одного раза во фрагменте кода».

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...