Visual Studio 2015编辑封装字段 [英] Visual Studio 2015 edit encapsulate field

查看:150
本文介绍了Visual Studio 2015编辑封装字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


i尝试编辑"封装字段"。片段来自:C:\Program Files(x86)\ Microsoft Visual Studio 14.0\ VC#\ Snippets \ 1033 \ Refactoring\EncapsulateField.snippet



我的字段是:

   int  测试 ;   



当我按ctrl + r + ei get:

  公开    int    测试  
{
得到
{
返回 测试 ;
}

设置
{
测试
= ;
}
}



而不是我希望得到:

    公开    int    测试  
{
得到
{
返回 测试 ;
}

设置
{
测试
= ;
OnChange ();
}
}



当我查看上面的文件时,有一个看起来像这样的片段:

  <![  CDATA   [  

$修饰符$ $类型$ $ name $
{
得到
{ 返回 $ field $ ; }
设置 { $ field $ = ; }
}]]>



看起来不像预期。



我认为它必须看起来像这样:

  <![  CDATA   [  


$修饰符$ $类型$ $ name $
{

得到
{
返回 $ field $ ;
}

设置
{
$ field $
= ;
}
}]]>



这不是改变它的正确点,有可能改变它吗?


< p style ="padding-right:0px;字体大小:15像素;明确:两者;颜色:#242729; font-family:Arial,'Helvetica Neue',Helvetica,sans-serif">
greets



5p1k3

解决方案

< blockquote>

您好5p1k3md,


感谢您在此发帖。


在VS2015中,它现在关注工具>选项>文本编辑器> C#>格式化。然后你可以改变你喜欢的代码的方式到Microsoft提供的


您可以更改以下格式。


如果你不喜欢这种格式,那么o 真正的选择是让微软知道你对这个改变不满意。你可以
建议改变  UserVoice 。你可以编写你想要的
格式。


我希望这会有所帮助。


最好的问候,


Wendy


i try to edit the "encapsulate field" snippet from: C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC#\Snippets\1033\Refactoring\EncapsulateField.snippet

My field is:

int test;

When i press ctrl+r+e i get:

public int Test
    {
        get
        {
            return test;
        }

        set
        {
            test = value;
        }
    }

Instead of this i want to get:

        public int Test
    {
        get
        {
            return test;
        }

        set
        {
            test = value;
            OnChange();
        }
    }

When i look at the file above there is a snippet looking like this:

<![CDATA[

$modifier$ $type$ $name$
{
  get { return $field$; }
  set { $field$ = value; }
}]]>

which doesn't look like expected.

I thought it has to look something like this:

<![CDATA[


$modifier$ $type$ $name$
{

  get
  { 
      return $field$; 
  }

  set
  { 
    $field$ = value; 
  }
}]]>

Isn't it the right point to change it and is possible to change it at all ?

greets

5p1k3

解决方案

Hi 5p1k3md,

Thank you for posting here.

In VS2015, it now pays attention to the Tools > Options > Text Editor > C# > Formatting. And then you could change the way of the code you like according to the Microsoft provided.

You could change the format like the following.

If you do not like the format, the only real option is to let Microsoft know that you are not happy with the change. You could proposes a change in UserVoice. You could write the format you want.

I hope this would be helpful.

Best Regards,

Wendy


这篇关于Visual Studio 2015编辑封装字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆