Introduces a Source Generator for AOT creation of serializers.
The generator creates a type per-serialized type with methods that map to ColumnWriterDelegate instances. A new ITypeDescriber knows how to find these types and methods, and constructs SerializableMembers that will use them.
Visible changes
New Attributes
[DoesNotEmitDefaultValue] - attached to generated methods which elide default values
[GeneratedSourceVersion] - attached to generated classes for lookup purposes, as well as to ensure the version of Cesil that generated the type matches the running version of Cesil
[GenerateSerializable] - attached to classes or structs to indicate that a type should have a serializer generated at compile time
[GenerateSerializableMember] - attached to methods, fields, or properties to indicate that they should be included in the generated serializer
This attribute includes properties like Name, Order, EmitDefaultValue, and so on to allow customization akin to the SerializableMember type (and other wrappers) used at runtime
AheadOfTimeTypeDescriber - a new ITypeDescriber which can find generated serializers (and, presumably, deserializers in the future) rather than use runtime code generation
An instance of this type is also pre-allocated on TypeDescribers
Internal changes
A whole new project, Cesil.SourceGenerator
DefaultTypeFormatters updated for easier inclusion into the generated source in a piecemeal fashion
SerializableMember now supports being backed by a pre-generated method
Associated Formatters, ShouldSerializes, and Getters are backed by logically equivalent methods though they might not be what is actually used by the pre-generated method
Commentary
This is a first pass at any sort of Source Generator support in Cesil. I expect it will change substantially before shipping, especially in regards to naming and test coverage.
Introduces a Source Generator for AOT creation of serializers.
The generator creates a type per-serialized type with methods that map to
ColumnWriterDelegate
instances. A newITypeDescriber
knows how to find these types and methods, and constructsSerializableMembers
that will use them.Visible changes
[DoesNotEmitDefaultValue]
- attached to generated methods which elide default values[GeneratedSourceVersion]
- attached to generated classes for lookup purposes, as well as to ensure the version of Cesil that generated the type matches the running version of Cesil[GenerateSerializable]
- attached to classes or structs to indicate that a type should have a serializer generated at compile time[GenerateSerializableMember
] - attached to methods, fields, or properties to indicate that they should be included in the generated serializerSerializableMember
type (and other wrappers) used at runtimeAheadOfTimeTypeDescriber
- a newITypeDescriber
which can find generated serializers (and, presumably, deserializers in the future) rather than use runtime code generationTypeDescribers
Internal changes
DefaultTypeFormatters
updated for easier inclusion into the generated source in a piecemeal fashionSerializableMember
now supports being backed by a pre-generated methodCommentary
This is a first pass at any sort of Source Generator support in Cesil. I expect it will change substantially before shipping, especially in regards to naming and test coverage.