Why does System.Formats.Nrbf.ArrayRecord.GetArray require the type of the object in the array? #108625
Replies: 3 comments 2 replies
-
This is safe because the code of the type has clearly no risk. It also guarantees that the payload doesn't contain other types. |
Beta Was this translation helpful? Give feedback.
-
Thank you for the response
In my example, if I have a single |
Beta Was this translation helpful? Give feedback.
-
I feel like I'm missing something here since I'm still confused... For fields
Compared to arrays
So in both cases I end up with a |
Beta Was this translation helpful? Give feedback.
-
I'm using the prerelease Nrbf library from Nuget. It's not clear to me why I need to pass in the type into
ArrayRecord.GetArray
given that all I get from that call is an array ofClassRecords
. In my use case I would like to load data that was serialized using the BinaryFormatter in an application that doesn't have any reference to the classes used during serialization. In moving to a new serializer we want to rearchitect the model so keeping the old models around isn't ideal. I've also determined that it's really just checking the type name - I was able to create an empty shell of the class with the same name/namespace without any members at all and was able to deserialize without any issues.Here's a simple example.
In the case that I was generating the serialization data somewhere else I could just define this
and would be able to still read the Name member so it's not clear what the type accomplishes.
Beta Was this translation helpful? Give feedback.
All reactions