配置 Visual Studio 2019 的输出 将 XML 粘贴为 类
Configure output of Visual Studio 2019 Paste XML as Classes
当使用 Edit->Paste Special-Paste Xml as 类 时,生成的输出是这样的:
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; }
}
无法配置该行为。
我的猜测是他们这样做是因为 autoimplemented properties“仅”在 c# 3.0 之前出现在 c# 中,因此他们想出了一个不依赖于 c# 版本(向后兼容)的解决方案。我不知道有什么办法可以强迫那种特殊的糊状物使用它们,但我很乐意这样做。
当使用 Edit->Paste Special-Paste Xml as 类 时,生成的输出是这样的:
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; }
}
无法配置该行为。
我的猜测是他们这样做是因为 autoimplemented properties“仅”在 c# 3.0 之前出现在 c# 中,因此他们想出了一个不依赖于 c# 版本(向后兼容)的解决方案。我不知道有什么办法可以强迫那种特殊的糊状物使用它们,但我很乐意这样做。