Runtime instance to creation code transformer.
Object2Code is used to generate the object creation C# code of the runtime objects with pre-existing data. The source object may be configured by user, deserialized or whatever. By using the code from this repository you can create the code to create such object and full it with current runtime data.
Use entry point BrokenEvent.Object2Code.CodeBuilder
and pass the source object to one of its methods.
CodeBuilder.BuildStaticReadOnly(obj, "Simple");
The string result of such operation will be something like:
public static readonly SimpleType Simple = new SimpleType
{
IntValue = 25,
StringValue = ""Hello World"",
CharValue = '!',
EnumValue = SimpleEnum.SomeValue
};
(the code from unit tests).
We use two spaces as indent which is set as the default. This may be changed using BuildSettings.Indent
as well as the other properties.