如果我有以下课程:
public class Foo
{
public string Code { get; set; }
public string Description { get; set; }
public DateTime? EffectiveDate { get; set; }
}
我想快速将其转换为
record
类型:
public record Foo(string Code, string Description, DateTime? EffectiveDate);
有没有办法快速做到这一点? VS19 中内置的快速操作菜单似乎没有提供此功能。
dotnet 开发人员正在根据此问题进行研究 classtorecode
MappingGenerator 插件(适用于 VisualStudio 和 Rider)包含“将类型转换为记录”重构 https://docs.mappinggenerator.net/refactorings/convert-type-to-record/
免责声明:我是 MappingGenerator 的作者。上述重构属于付费功能。
您可以在 VS 2022 中单击类别,然后单击左侧的螺丝刀后尝试“转换为位置记录”。