配置Visual Studio 2019的输出将XML粘贴为类



使用Edit->Paste Special-Paste Xml作为类时,生成的输出如下:

public class RootElement
{
private string prop1Field;
private string  prop2Field;
public string Prop1
{
get
{
return this.prop1Field;
}
set
{
this.prop1Field = value;
}
}
/// <remarks/>
public string Prop2
{
get
{
return this.prop2Field;
}
set
{
this.prop2Field = value;
}
}
}

是否有一种方法来配置这种行为,这样它就会创建更简洁的东西?

public class RootElement
{
public string Prop1 { get; set; }
public string Prop2 { get; set; }
}

没有办法配置这个行为。

我猜他们这样做是因为自动实现的属性"only"在c# 3.0中出现,所以他们想出了一个不依赖于c#版本的解决方案(向后兼容)。我知道没有办法强迫那个特殊的粘贴使用它们,但我希望它能。

最新更新