3

I'm working with protobuf-net v2 r480 (to the best of my understanding...).

Question:

How can I get protobuf-net to ignore list handling when the class with the list handling (FileTree) is a field of another class (MyRandomStuff)?

Background:

I have a FileTree class (which I previously described here on StackOverflow) which implements ICollection<MyFileInfo>, IEnumerable<MyFileInfo>, IEnumerable, and a few other interfaces. I have tagged the FileTree class with [ProtoContract(IgnoreListHandling = true)]. The FileTree class itself serializes beautifully.

The problem I am having is with MyRandomStuff class, which has a FileTree field. When I tag that field with "[ProtoIgnore]", the instance of MyRandomStuffserializes just fine. However, when I include the FileTree field via "[ProtoMember(2)]", serialization fails with a message that the MyFileInfo object needs to have a parameterless constructor. I have intentionally setup my code so that MyFileInfo is never serializable. (Instead, FileTree creates the relevant MyFileInfo objects during deserialization).

Unfortunately, I don't have a quick sample that I can send if it is a bug. I have a work-around already, but I thought maybe I'd ask here if I'm just doing something incorrectly (like tagging, or using an out-of-date version of protobuf).

Andrew Brēza
  • 7,705
  • 3
  • 34
  • 40
Amanduh
  • 1,233
  • 1
  • 13
  • 23
  • 1
    No, that isn't the expected behaviour. No, you are not doing anything wrong. Have repro - my first-try fix will take some tweaking as it impacts some tests, need to look why. Applies only to a point in time, though, so closing the question *here*. Will be fixed soon. – Marc Gravell Mar 06 '12 at 07:58
  • @MarcGravell This question sounds nearly identical to a problem I'm currently having, except that I'm being told it's "Unable to resolve a suitable Add method." Adding `IgnoreListHandling = true` allowed me to serialize struct `A`, but the error persists when trying to serialize struct `B`, which has two fields of struct `A`. Removing `IEnumerable` from struct `A` allows both `A` and `B` to serialize. – dlras2 May 05 '12 at 07:41
  • @Dan I'll have to investigate – Marc Gravell May 05 '12 at 10:42
  • @MarcGravell Just @ me if you need more info to reproduce. – dlras2 May 05 '12 at 16:43
  • @Dan if you happen to *have* a small self-contained repro, it would save me some time - but I'm not saying you should g out of your way to create one. – Marc Gravell May 05 '12 at 18:42
  • @MarcGravell I narrowed down the problem to struct `A`'s indexer property. I reproduced the error succinctly here: http://dl.dropbox.com/u/832464/Code/SO9575661.zip – dlras2 May 05 '12 at 20:03

0 Answers0