modified handling of array types in dna field attributes generation

This commit is contained in:
mm00
2025-02-18 17:59:52 +01:00
parent 7403dd7776
commit 15fb695bcd

View File

@@ -221,7 +221,7 @@ namespace CodeGenerator {
cmp = new CodeMemberProperty() {
Name = "UnderlyingType",
Type = new CodeTypeReference(typeof(Type)),
Type = new CodeTypeReference(typeof(string)),
Attributes = MemberAttributes.Public,
HasGet = true,
GetStatements = {
@@ -240,7 +240,7 @@ namespace CodeGenerator {
new(typeof(int), "originalIndex"),
new(typeof(string), "originalType"),
new(typeof(string), "originalName"),
new(typeof(Type), "underlyingType"),
new(typeof(string), "underlyingType"),
new(typeof(int), "size")
});
@@ -324,12 +324,20 @@ namespace CodeGenerator {
private static CodeAttributeDeclaration GenerateDNAFieldAttribute(int index, BlendFile.DnaField field,
BlendFile.Dna1Body body) {
Type t;
string t;
if (field.Name.Contains('[')) {
CodeMemberField amf = CreateArrayMemberField(field);
t = Type.GetType($"Array<{amf.Type.ArrayElementType.BaseType}>");
} else {
t = Type.GetType(field.Type.ParseFType());
var sb = new StringBuilder();
sb.Append(amf.Type.BaseType);
sb.Append("[");
for(int i=1; i<amf.Type.ArrayRank; i++) {
sb.Append(",");
}
sb.Append("]");
t = sb.ToString();
} else
{
t = field.Type;
}
CodeAttributeDeclaration cad = new("DNAFieldAttribute");