Closed windowslucker1121 closed 7 months ago
I think the problem is this:
"type": "object",
Keep in mind the codegen tool cannot "magically" determine the kind of data you're trying to store.
Also keep in mind that C# System.Object is not "magically" serializable to json.
So whenever you use "object" in the schema, the codeGen will translate it to System.Text.Json.JsonNode , which is c# API to create json object structures.
If you want to avoid this, you need to avoid using "object" and user other data types.
If there's no good match between the data type you place in the schema, and the data types used in c#, the CodeGen tool has some replacement helpers that can allow you to "tweak" the schema after loading it. You'll see plenty of examples in the other extensions already used by the schema.
But if you can't avoid using "object" because the data type is mutable, then you have to rely on JsonNode and learn the API to access the underlaying data.
Hey there, thanks to your help last time here -> https://github.com/vpenades/SharpGLTF/issues/225 i was able to generate code and use my custom extension.
Now that i was able to successfully compile my "very basic" test schema i want to extend it to its fully potentional but the last 3 days i am really out of luck and now seeking here help again. :-/
I have the problem, that with the following schema:
When generating Code with the CodeGen tool it generates the following output:
Now that is something new i wasnt able to determine how to handle the JsonNode, nor do i know if this is correct. I tried changing the schema a dozen times and i even cant remember what i changed everything in the past days.
But then searching for other generated files, where these JsonNodes where generated i stumbled across this:
https://github.com/vpenades/SharpGLTF/blob/5a33d5452528d827ac55727f302d8a91a75c4186/src/SharpGLTF.Ext.3DTiles/Schema2/Generated/Ext.CESIUM_ext_structural_metadata_root.g.cs#L118-L120
digging a bit further how it was handled in that extension i found this:
https://github.com/vpenades/SharpGLTF/blob/5a33d5452528d827ac55727f302d8a91a75c4186/src/SharpGLTF.Ext.3DTiles/Schema2/Ext.StructuralMetadataRoot.cs#L540-L545
So is the "JsonNode" Type currently not supported and i need to pause my work here or is there anything i could do to work around it (or possible fix this?)
Thanks again for the help!!