Saeb Amini Saeb Amini - 4 months ago 28
C# Question

How to Put Empty Literal in Code Snippet

I've slightly modified VS's

snippet. The idea is that if I want parameters or a body, I type them in, otherwise I can hit Enter twice to skip and make it parameterless:

<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="">
<CodeSnippet Format="1.0.0">
<Description>Code snippet for constructor</Description>
<Author>Microsoft Corporation</Author>
<Literal Editable="false">
<ToolTip>Class name</ToolTip>
<Code Language="csharp"><![CDATA[public $classname$ ($parameters$)

It works great, except it has a small nuisance in case I want parameterless:

public ProjectTask( )
{ }

Notice the extra space character
between the parentheses? I know I'm taking laziness to a whole new level here but is it possible to make that go away?


I just tried my exact same snippet above in VS 2015 and noticed it no longer has that problem and the generated code ends up like this:

public ProjectTask()
{ }