在Visual Studio 2015中编辑C#的重构代码片段,不';你不能改变重构行为吗?

在Visual Studio 2015中编辑C#的重构代码片段,不';你不能改变重构行为吗?,c#,visual-studio,visual-studio-2015,code-snippets,C#,Visual Studio,Visual Studio 2015,Code Snippets,我想将典型的属性生成从输出更改为: set { amountOfDogesValue = value; } 要输出如下内容: set { if (value > 0) amountOfDogesValue = value; else throw new System.ArgumentException("Parameter cannot be smaller than 0", "DogesAmount"); } (但是)在if子句

我想将典型的属性生成从输出更改为:

set
{
    amountOfDogesValue = value;
}
要输出如下内容:

set
{
    if (value > 0)
        amountOfDogesValue = value;
    else
        throw new System.ArgumentException("Parameter cannot be smaller than 0", "DogesAmount");
}
但是)在if子句和throw行中包含一些无法编译的元素,因此我永远不会忘记编辑它们

我使用Visual Studio 2015并编辑了C:\Program Files(x86)\Microsoft Visual Studio 14.0\VC\Snippets\1033\Refactoring\EncapseField.snippet

<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets  xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
    <CodeSnippet Format="1.0.0">
        <Header>
            <Title>Encapsulate Field</Title>
            <Description>Refactoring snippet for Encapsulate field</Description>
            <Author>Microsoft Corporation</Author>
            <SnippetTypes>
                <SnippetType>Refactoring</SnippetType>
            </SnippetTypes>
        </Header>
        <Snippet>
            <Declarations>
                <Literal Editable="true">
                    <ID>modifier</ID>
                    <Default>public</Default>
                </Literal>
                <Literal Editable="false">
                    <ID>type</ID>
                    <Default>type</Default>
                </Literal>
                <Literal Editable="false">
                    <ID>name</ID>
                    <Default>name</Default>
                </Literal>
                <Literal Editable="false">
                    <ID>field</ID>
                    <Default>field</Default>
                </Literal>
            </Declarations>
            <Code Language="csharp">
                <![CDATA[

$modifier$ $type$ $name$
{
  get { return $field$; }
  set 
  { 
    if (value x= xm)
      $field$ = value;
    else
      throw new System.ArgumentException("Parameter cannot be "+, "$field$");
  }
}]]>
            </Code>
        </Snippet>
    </CodeSnippet>
</CodeSnippets>
重新启动MVS,重新启动电脑

但不知何故,它仍然以与以前完全相同的方式重构

以下是我的enclosureField.snippet代码

<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets  xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
    <CodeSnippet Format="1.0.0">
        <Header>
            <Title>Encapsulate Field</Title>
            <Description>Refactoring snippet for Encapsulate field</Description>
            <Author>Microsoft Corporation</Author>
            <SnippetTypes>
                <SnippetType>Refactoring</SnippetType>
            </SnippetTypes>
        </Header>
        <Snippet>
            <Declarations>
                <Literal Editable="true">
                    <ID>modifier</ID>
                    <Default>public</Default>
                </Literal>
                <Literal Editable="false">
                    <ID>type</ID>
                    <Default>type</Default>
                </Literal>
                <Literal Editable="false">
                    <ID>name</ID>
                    <Default>name</Default>
                </Literal>
                <Literal Editable="false">
                    <ID>field</ID>
                    <Default>field</Default>
                </Literal>
            </Declarations>
            <Code Language="csharp">
                <![CDATA[

$modifier$ $type$ $name$
{
  get { return $field$; }
  set 
  { 
    if (value x= xm)
      $field$ = value;
    else
      throw new System.ArgumentException("Parameter cannot be "+, "$field$");
  }
}]]>
            </Code>
        </Snippet>
    </CodeSnippet>
</CodeSnippets>

封装字段
重构封装字段的代码段
微软公司
重构
修饰语
公众的
类型
类型
名称
名称
领域
领域


(x=xm提醒我更改为上下文正确的操作数,+,提醒我编辑前面的字符串。)