Added documentation to Attribute builder. Added Inheritance methods. Added a base DNA attribute to GenerateTypeDeclarations method.

This commit is contained in:
Samuele Lorefice
2025-02-26 18:58:29 +01:00
parent 1a34d70f8d
commit 55f3d411b3
2 changed files with 115 additions and 2 deletions

View File

@@ -21,6 +21,7 @@ namespace CodeGenerator {
private const string OutPath = @"GeneratedOutput";
private const string Namespace = "BlendFile";
private static HashSet<string> _customTypes;
private static readonly string[] ListLenghtStr = {"count", "length", "size"};
private static void Log(string message) {
@@ -142,12 +143,18 @@ namespace CodeGenerator {
var attributeBuilder = new AttributeBuilder();
var typeDeclarations = new CodeTypeDeclaration[] {
attributeBuilder.New().SetName("DNAAttribute")
.SetAttributeUsage(new (new CodeSnippetExpression("AttributeTargets.All")))
.AddAutoProperty(typeof(int), "OriginalIndex")
.AddAutoProperty(typeof(string), "OriginalName")
.AddPropertiesConstructor()
.Build(),
attributeBuilder.New().SetName("DNAFieldAttribute")
.SetAttributeUsage(new (new CodeSnippetExpression("AttributeTargets.Field")))
.AddAutoProperty(typeof(int), "Size")
.AddAutoProperty(typeof(string), "OriginalType")
.AddAutoProperty(typeof(string), "OriginalName")
.AddAutoProperty(typeof(int), "OriginalIndex")
.AddAutoProperty(typeof(string), "OriginalName")
.AddAutoProperty(typeof(string), "UnderlyingType")
.AddAutoProperty(typeof(bool), "IsPointer")
.AddAutoProperty(typeof(int), "MemoryOffset")
@@ -155,9 +162,21 @@ namespace CodeGenerator {
.Build(),
attributeBuilder.New().SetName("DNAClassAttribute")
.SetAttributeUsage(new (new CodeSnippetExpression("AttributeTargets.Class | AttributeTargets.Struct")))
.AddAutoProperty(typeof(int), "Size")
.AddAutoProperty(typeof(int), "OriginalIndex")
.AddAutoProperty(typeof(string), "OriginalName")
.AddPropertiesConstructor()
.Build(),
attributeBuilder.New().SetName("DNAListAttribute")
.SetAttributeUsage(new (new CodeSnippetExpression("AttributeTargets.Property | AttributeTargets.Field")))
.AddAutoProperty(typeof(int), "Size")
.AddAutoProperty(typeof(string), "OriginalType")
.AddAutoProperty(typeof(string), "OriginalName")
.AddAutoProperty(typeof(int), "OriginalIndex")
.AddAutoProperty(typeof(string), "UnderlyingType")
.AddAutoProperty(typeof(string), "CountFieldName")
.AddAutoProperty(typeof(int), "CountFieldIndex")
.AddAutoProperty(typeof(int), "MemoryOffset")
.AddPropertiesConstructor()
.Build()
};