use $selected$ value in multiple places in custom snippet RRS feed

  • Question

  • I need to use the $selected$ value in multiple places in my snippet, but it only works one and renders blank after that.


    <?xml version="1.0" encoding="utf-8"?>
    <CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
      <CodeSnippet Format="1.0.0">
          <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>
            <Literal Editable="true">
                <ToolTip>Variable name</ToolTip>
            <Code Language="csharp" Delimiter="$" Kind="file">
                <![CDATA[ICollection<$selected$> $Name$ = new Collection<$selected$>(); $end$]]>      

    I apply the snippet to: int


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

    The int type is only used once, even though it should be used in both ICollection<> and Collection<>

    Friday, May 29, 2020 6:24 AM

All replies