ncupper / protobuf-net

Automatically exported from code.google.com/p/protobuf-net
Other
0 stars 0 forks source link

Inheritance broken in .proto generated by GetProto #340

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create an object model in which:
- Animal (abstract base) has Reptile and Mammal specializations
- Reptile (abstract base) has Alligator specialization 
- Mammal (abstract base) has Giraffe specialization
2. Have Giraffe have a member of type Alligator
3. Generate .proto file calling GetSchema() for Giraffe

What is the expected output? 
I would expect the following .proto (more or less):

message Animal {
    optional Reptile Reptile = 1;
    optional Mammal Mammal = 2;
}
message Reptile {
    optional Alligator Alligator = 1;
}
message Mammal {
    optional Giraffe Giraffe = 1;
}
message Alligator {
    optional Whatever fooBar = 1;
}
message Giraffe {
   optional string name = 1;
   optional Animal bestDangerousFriend = 2; // the Alligator is an Animal
}

What do you see instead?
I see that the bestDangerousFriend field is declared as being of type Reptile:
message Giraffe {
   optional string name = 1;
   optional Reptile bestDangerousFriend = 2; 
}

I walked through the code and it appears that protobuf-net explicitly gets the 
_base_ class of the metatype of the bestDangerousFriend field, rather than its 
"root base" class.

What version of the product are you using? On what operating system?
This is rev 596 on Windows XP.

Original issue reported on code.google.com by Gabriele.Giuseppini on 4 Dec 2012 at 12:59

GoogleCodeExporter commented 9 years ago
k; will look

Original comment by marc.gravell on 4 Dec 2012 at 3:57