我最近已升级到R#7.1,我遇到了这个问题,其中To Property With Backing Field
行动取代我的支持字段并将其移动到类的顶部。ReSharper 7.1“与财产与支持领域”移动领域不合适
实施例:
步骤1:定义一个自动特性:
public class MyClass
{
//... Lots of members here
public int MyNewProperty {get;set;} // <- Create auto Property
}
步骤2:ReSharper的 “财产随着支持字段”
预期成果:
public class MyClass
{
//... Lots of members here
private int _myNewProperty; // <- Backing field immediately above property
public int MyNewProperty
{
get
{
return _myNewProperty;
}
set
{
_myNewProperty = value;
}
}
}
得到的结果:
public class MyClass
{
private int _myNewProperty; // <- Backing field on top of the class
//... Lots of members here
public int MyNewProperty
{
get
{
return _myNewProperty;
}
set
{
_myNewProperty = value;
}
}
}
我已经在玩Type Members Layout
配置通过注释 “实例字段” 的一部分,是这样的:
<!--instance fields-->
<!--<Entry>
<Match>
<And>
<Kind Is="field"/>
<Not>
<Static/>
</Not>
</And>
</Match>
<Sort>
<Readonly/>
<Name/>
</Sort>
</Entry>-->
但我仍然得到相同的行为。
问:如何防止这种行为并将其恢复到V6.X?
我没有ReSharper,所以我无法测试,但如果从''标签中删除' ',会发生什么情况? –
@newStackExchangeInstance整个事情都被注释掉了。我认为这样可以解决问题,但它没有 –
尝试取消注释并做到这一点,看看会发生什么。 –