C# - 快速分配所有字段/属性的片段或模板?

Dan*_*ann 6 c# resharper visual-studio code-snippets

对于可能知道答案的人的快速点 - 是否有一个片段或工具可以快速生成模板代码以分配对象的所有公共字段和/或属性?

例:

public class SomeBloatedClass
{
    public string SomeField1 { get; set; }
    public int SomeField2 { get; set; }
    // etc...
    public string SomeField99 { get; set; }
}

public class TestHarness
{
    public SomeBloatedClass CreateTestObject()
    {
         // Is there a snippet/macro/template that can generate the code to assign
         // all public fields/properties so they can be manually assigned quickly?
         // Something like this...?

         // *Begin auto-generated code
         SomeBloatedClass s = new SomeBloatedClass();
         s.SomeField1 = ;
         s.SomeField2 = ;
         // etc..
         s.SomeField99 = ;
         // *End auto-generated code

         return s;
    }
}
Run Code Online (Sandbox Code Playgroud)

只要它们集成到Visual Studio中,第三方工具就可以了.

编辑:我只是想让工具创建空的赋值语句,我可以使用适当的值快速手动编辑.理想情况下,解决方案将使用内置代码段机制通过TAB键从语句导航到语句 - 我无法使用StackOverflow的编辑器清楚地表示,但如果您使用了片段,则应该知道我的意思.

Dot*_*ver 0

有小片段或工具可以快速生成模板代码来分配对象的所有公共字段和/或属性吗?

C# 属性分配器工具。

并代表它我们还可以生成 c# ex 的属性。( get set )

时间:2019-03-17 标签:c#propertygenerator