BuildableExpressions and BuildableExpressions.Generator work via creation of
SourceCodeExpression
s, which can be compiled to CLR Types at runtime, or used to generate C# source
code files at build-time. A SourceCodeExpression
consists of one or more types.
Defining a Struct
To add a struct to your SourceCodeExpression
, use:
BuildableExpression.SourceCode(sc =>
{
sc.AddStruct("MyStruct", str =>
{
// Set struct options if desired:
// str.SetSummary("Struct description");
// str.AddAttribute(typeof(SomeAttribute));
// str.SetVisibility(TypeVisibility.Internal);
// str.SetPartial();
// Add struct members - see below
});
});
Members are added via the struct API, which supports: