Here is the example:
class A
{
public int x { get; private set; }
public A(){}
public A(int x)
{
this.x = x;
}
}
class Program
{
static void Main(string[] args)
{
A a = new A(1);
A a1;
using (FileStream fs = new FileStream("data", FileMode.Create, FileAccess.Write))
{
Serializer.Serialize(fs, a);
}
using (FileStream fs = new FileStream("data", FileMode.Open, FileAccess.Read))
{
a1 = Serializer.Deserialize<A>(fs);
}
Console.ReadLine();
}
}
Class A doesn't have any attribute or contract, but protobuf-net doesn't throw any exception. Why? After deserialization a1.x contains 1.
Target framework is 4.5. Protobuf-net version is 2.0.0.668, installed with nuget.
It is a feature of v2, from the webpage
(Emphasis mine)