iTwin / itwinjs-core

Monorepo for iTwin.js Library
https://www.itwinjs.org
MIT License
606 stars 210 forks source link

Investigate and Fix bug with dateTime CustomAttribute instance JSON property value #6686

Open christophermlawson opened 5 months ago

christophermlawson commented 5 months ago

From native side, a dateTime typed CustomAttribute instance property is set as a string ("2021-08-19T16:37:42.278") in the returned JSON. This is not validated or processed during deserialization, so the in-memory schema has this set as a string as well. If you then serialize the Schema to xml, the error below occurs, because we are assuming this property value is of type dateTime.

Retrieving Bentley_Civil_Entries.04.00.00 ITwinSlimClient.ts:86 Uncaught TypeError TypeError: propertyValue.getTime is not a function at writePrimitiveProperty (c:\Source\sandbox\schema-exporter\node_modules\@itwin\ecschema-metadata\lib\cjs\Deserialization\XmlSerializationUtils.js:138:61) at writeInstanceProperty (c:\Source\sandbox\schema-exporter\node_modules\@itwin\ecschema-metadata\lib\cjs\Deserialization\XmlSerializationUtils.js:57:19) at writeCustomAttribute (c:\Source\sandbox\schema-exporter\node_modules\@itwin\ecschema-metadata\lib\cjs\Deserialization\XmlSerializationUtils.js:35:19) at processTicksAndRejections (internal/process/task_queues:95:5) XmlSerializationUtils.js:138 Process exited with code 1e