I came across a strange phenomenon - serialization and deserialization of a Base
to disk seems to lose its “real” type, even though .GetType()
is correct?
See attached .dib file, which can be run directly in VSCode.
TestTrasnportDeserialization.dib (3.4 KB)
Steps:
- Retrieve a Speckle
Object
(in this case, aBrep
) from a Speckle Server - call it “apiBrep” - Serialize and then, deserialize it to disk, using a
DiskTransport
- call it “diskBrep” - Verify result of
.GetType()
on each object. It should return “Objects.Geometry.Brep” for both. - Access properties of each type:
- Dictionary-style properties (e.g.
["Faces"]
) return correctly - Dot-notation-style properties return the following error:
Error: (1,10): error CS1061: 'Base' does not contain a definition for 'Faces' and no accessible extension method 'Faces' accepting a first argument of type 'Base' could be found (are you missing a using directive or an assembly reference?)
This is a problem when using the disk-deserialized object in methods, as the compiler complains that the object is actually just a Base
, (and not the “complete” Speckle Object .GetType()
thinks it is); and so we recieve the following error:
Error: (1,14): error CS1503: Argument 1: cannot convert from 'Speckle.Core.Models.Base' to 'Objects.Geometry.Brep'
Any ideas?