opened
MaxXor
username_0
Hello, I'm currently using classes like this:

```csharp
    public interface ICreature
    {
    }

    [ProtoContract]
    public class Human : ICreature
    {
        [ProtoMember(1)]
        public string Name{ get; set; }
    }

    [ProtoContract]
    public class Animal : ICreature
    {
        [ProtoMember(1)]
        public string Name{ get; set; }
    }
```

To correctly un/serialize this with `Serializer.Deserialize<ICreature>(input)` I have to add them manually via:

```csharp
RuntimeTypeModel.Default[typeof(ICreature)].AddSubType(0, typeof(Human));
RuntimeTypeModel.Default[typeof(ICreature)].AddSubType(1, typeof(Animal));
```

Is there any easier way to do this, without having to manually add all the sub types to the default model?
Inheritance question
issue
created
mgravell
username_1
This seems to work:

```c#
    static void Main()
    {
        Serializer.PrepareSerializer<ICreature>();
        var creatures = new ICreature[] { new Human(), new Animal() };

        var clone = Serializer.DeepClone(creatures);
        Console.WriteLine(clone[0]); // Human
        Console.WriteLine(clone[1]); // Animal
    }

    [ProtoContract]
    [ProtoInclude(1, typeof(Human))]
    [ProtoInclude(2, typeof(Animal))]
    public interface ICreature
    {
    }
```

Note: `AddSubType(0, ...)` **should not work** - if it does, that's a bug - `0` is not a valid tag in protobuf.
comment
created
MaxXor
username_0
Oh nevermind, you example is indeed working, thanks!
comment
closed
MaxXor
username_0
issue
created
MaxXor
username_0
When exactly is it required to call `PrepareSerializer`?
comment
created
mgravell
username_1
good question; I haven't dug into which cog exactly fell out here; but: it is a good "catch all" for any problems of this kind; the 3.0 branch includes a new "create a compiled type model for this entire assembly" which I would recommend as a replacement - it is faster, too, and you don't need to worry about calling it multiple times (it does all the right things for reuse, etc).
comment
created
mgravell
username_1
Confusingly, it is the `split-reader` branch. It made sense at the time, but it now encompasses all of the 3.0 changes (which are incomplete, in particular if you're using the new "pipelines" support).
comment
created
MaxXor
username_0
I'm now adding a plugin system to my software and will use this to add dynamically new types to the serializer. This will continue to work in the v3.0, right?
```csharp
RuntimeTypeModel.Default[typeof(IBaseType)].AddSubType(counter, typeof(DerivedClass));
```
comment