erezak / libphonenumber-csharp

Forking original c# port
Apache License 2.0
198 stars 79 forks source link

cannot directly serialize PhoneNumber #35

Open AartBluestoke opened 3 years ago

AartBluestoke commented 3 years ago

Because of the publicly visible member "defaultInstanceForType" which is self-referential. If you are using newtonsoft for searialization this requires serializing everything with "Newtonsoft.Json.ReferenceLoopHandling.Ignore," (which could be dangerous, the default is to throw an exception by default for a good reason),

if you use the new c# language serializer, it will just crash with recursion limit exceeded.

Could the defaultInstanceForType please be annotated with 'don't serialize this', as it isn't part of the object state.

https://dotnetfiddle.net/rJNvxd