c# - Is there a way to use IReadOnlyCollection<T>/IReadOnlyList<T> with protobuf-net -


i gather when working collections protobuf-net needs getenumerator serialization , type add deserialization.

for types don't have add can set inheriting type before deserialization. works example ienumerable , list:

[protocontract(implicitfields = implicitfields.allpublic)] public class sheep {     public ienumerable<string> children { get; set; }     public sheep()     {         children = new list<string>();     } } 

var dolly = runtimetypemodel.default.deepclone(new sheep {     children = new[]     {         "bonnie",         "sally",         "rosie",         "lucy",         "darcy",         "cotton"     } }); 

however, when same ireadonlycollection (or ireadonlylist):

[protocontract(implicitfields = implicitfields.allpublic)] public class sheep {     public ireadonlycollection<string> children { get; set; }     public sheep()     {         children = new list<string>();     } } 

i exception:

unable resolve suitable add method system.collections.generic.ireadonlycollection`1[[system.string, mscorlib, version=4.0.0.0, culture=neutral, publickeytoken=b77a5c561934e089]]

so, there way make protobuf-net handle members of ireadonlycollection/ireadonlylist?


edit: i've opened issue feature on project's repository: support ireadonlycollection/ireadonlylist members

the main problem here "merge". non-merge (or basically: list replacement enabled), hard-code concrete type , strategy, however, there no obvious thing merge otherwise.

there no magic scenario @ moment; solution require library changes.


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -