Added derive from class parts to the attribute building process. Added static Lists of substrings for attribute filtering.

This commit is contained in:
Samuele Lorefice
2025-02-26 19:24:14 +01:00
parent 80234eb599
commit bdc9624d13

View File

@@ -22,7 +22,10 @@ namespace CodeGenerator {
private const string Namespace = "BlendFile"; private const string Namespace = "BlendFile";
private static HashSet<string> _customTypes; private static HashSet<string> _customTypes;
private static readonly string[] ListLenghtStr = {"count", "length", "size"}; private static readonly string[] ListMarkerStr = {"list", "array"};
private static readonly string[] ListLenghtStr = {"num", "len", "size"};
private static void Log(string message) { private static void Log(string message) {
Sb.AppendLine(message); Sb.AppendLine(message);
@@ -145,12 +148,14 @@ namespace CodeGenerator {
var typeDeclarations = new CodeTypeDeclaration[] { var typeDeclarations = new CodeTypeDeclaration[] {
attributeBuilder.New().SetName("DNAAttribute") attributeBuilder.New().SetName("DNAAttribute")
.SetAttributeUsage(new (new CodeSnippetExpression("AttributeTargets.All"))) .SetAttributeUsage(new (new CodeSnippetExpression("AttributeTargets.All")))
.DeriveFromClass("System.Attribute")
.AddAutoProperty(typeof(int), "OriginalIndex") .AddAutoProperty(typeof(int), "OriginalIndex")
.AddAutoProperty(typeof(string), "OriginalName") .AddAutoProperty(typeof(string), "OriginalName")
.AddPropertiesConstructor() .AddPropertiesConstructor()
.Build(), .Build(),
attributeBuilder.New().SetName("DNAFieldAttribute") attributeBuilder.New().SetName("DNAFieldAttribute")
.SetAttributeUsage(new (new CodeSnippetExpression("AttributeTargets.Field"))) .SetAttributeUsage(new (new CodeSnippetExpression("AttributeTargets.Field")))
.DeriveFromClass($"{Namespace}.DNAAttribute")
.AddAutoProperty(typeof(int), "Size") .AddAutoProperty(typeof(int), "Size")
.AddAutoProperty(typeof(string), "OriginalType") .AddAutoProperty(typeof(string), "OriginalType")
.AddAutoProperty(typeof(int), "OriginalIndex") .AddAutoProperty(typeof(int), "OriginalIndex")
@@ -162,6 +167,7 @@ namespace CodeGenerator {
.Build(), .Build(),
attributeBuilder.New().SetName("DNAClassAttribute") attributeBuilder.New().SetName("DNAClassAttribute")
.SetAttributeUsage(new (new CodeSnippetExpression("AttributeTargets.Class | AttributeTargets.Struct"))) .SetAttributeUsage(new (new CodeSnippetExpression("AttributeTargets.Class | AttributeTargets.Struct")))
.DeriveFromClass($"{Namespace}.DNAAttribute")
.AddAutoProperty(typeof(int), "Size") .AddAutoProperty(typeof(int), "Size")
.AddAutoProperty(typeof(int), "OriginalIndex") .AddAutoProperty(typeof(int), "OriginalIndex")
.AddAutoProperty(typeof(string), "OriginalName") .AddAutoProperty(typeof(string), "OriginalName")
@@ -169,6 +175,7 @@ namespace CodeGenerator {
.Build(), .Build(),
attributeBuilder.New().SetName("DNAListAttribute") attributeBuilder.New().SetName("DNAListAttribute")
.SetAttributeUsage(new (new CodeSnippetExpression("AttributeTargets.Property | AttributeTargets.Field"))) .SetAttributeUsage(new (new CodeSnippetExpression("AttributeTargets.Property | AttributeTargets.Field")))
.DeriveFromClass($"{Namespace}.DNAAttribute")
.AddAutoProperty(typeof(int), "Size") .AddAutoProperty(typeof(int), "Size")
.AddAutoProperty(typeof(string), "OriginalType") .AddAutoProperty(typeof(string), "OriginalType")
.AddAutoProperty(typeof(string), "OriginalName") .AddAutoProperty(typeof(string), "OriginalName")