C # - fragment or template for quick assignment of all fields / properties?

Quick points for those who can know the answer - is there a fragment or tool that can quickly generate template code for assigning all open fields and / or properties of an object?

Example:

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

Third-party tools are great as long as they integrate into Visual Studio.

Edit: I just want the tool to create empty assignment statements, which I could quickly edit manually using the appropriate values. Ideally, the solution will use the built-in snippet mechanism to move from the statement to the statement via the TAB key - I could not clearly imagine this using the StackOverflow editor, but if you used fragments, you should know what I mean).

+6
source share
1 answer

Is there a small fragment or tool that can quickly generate template code to assign all open fields and / or properties of an object?

C # property assignment tool.

and on his behalf we can also generate C # ex properties. (get set)

c # property generator

0
source

Source: https://habr.com/ru/post/943752/


All Articles