7

答えを知っているかもしれない人のための簡単なポイント - オブジェクトのすべてのパブリック フィールドやプロパティを割り当てるためのテンプレート コードをすばやく生成できるスニペットまたはツールはありますか?

例:

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;
    }
}

サードパーティ ツールは、Visual Studio に統合されている限り問題ありません。

編集: ツールで空の代入文を作成し、適切な値ですばやく編集できるようにしたいと考えています。理想的には、ソリューションは組み込みのスニペット メカニズムを使用して、TAB キーを介してステートメントからステートメントへと移動します。StackOverflow のエディターを使用して明確に表現することはできませんでしたが、スニペットを使用したことがある場合は、私の意味を理解する必要があります)。

4

1 に答える 1