fix(codegen): Fixes various code gen issues. Adds better embedded serialization support (#688)

* Adds save flag support (see `ElvenGlasses` for an example)
* Updates AOSAttributes so they are code genned
* Fixes embedded object support by adding an `IRawSerializable`
* Fixes various inconsistencies in serializing with codegen
This commit is contained in:
Kamron Batman 2021-08-17 02:43:52 -07:00 committed by GitHub
parent 69af652a18
commit 2c8097f707
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
54 changed files with 787 additions and 507 deletions

View file

@ -21,9 +21,16 @@ namespace SerializationGenerator
{
public static partial class SourceGeneration
{
public static void GenerateClassStart(this StringBuilder source, string className, ImmutableArray<ITypeSymbol> interfaces)
public static void GenerateClassStart(
this StringBuilder source,
string className,
string indent,
ImmutableArray<ITypeSymbol> interfaces,
Accessibility accessor = Accessibility.Public,
bool isPartial = true
)
{
source.Append($" public partial class {className}");
source.Append($"{indent}{accessor.ToFriendlyString()} {(isPartial ? "partial " : "")}class {className}");
if (!interfaces.IsEmpty)
{
source.Append(" : ");
@ -37,13 +44,12 @@ namespace SerializationGenerator
}
}
source.AppendLine(@"
{");
source.AppendLine($"\n{indent}{{");
}
public static void GenerateClassEnd(this StringBuilder source)
public static void GenerateClassEnd(this StringBuilder source, string indent)
{
source.AppendLine(" }");
source.AppendLine($"{indent}}}");
}
// TODO: Generalize this to any field using dynamic indentation