Quantcast
Channel: Visual Studio Integrate forum
Viewing all articles
Browse latest Browse all 4410

use $selected$ value in multiple places in custom snippet

$
0
0

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

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>Variable name</ToolTip><Default>myVar</Default></Literal></Declarations><Code Language="csharp" Delimiter="$" Kind="file"><![CDATA[ICollection<$selected$> $Name$ = new Collection<$selected$>(); $end$]]>      </Code></Snippet></CodeSnippet></CodeSnippets>

I apply the snippet to: int

Output:

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<>


Viewing all articles
Browse latest Browse all 4410

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>