kenrivcn / protobuf-net

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

Protobuf.net 'IsDefined' logical bug? #453

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
In the following code snippet I'm trying to use the 'IsDefined' method of a 
purpose-created model to see if I've already added the given type to the model. 
However, it always returns true, and inspection of the types known to the model 
after calling IsDefined shows that the type has been added to the model during 
the call. This seems to make IsDefined redundant, or am I missing something?

    private static void FillSignatureModel(RuntimeTypeModel Model, Object SignedObject) {
        var lBinding = BindingFlags.Instance | BindingFlags.NonPublic |
            BindingFlags.Public;

        var lType = SignedObject.GetType();

        // Already sorted
        if (Model.IsDefined(lType)) return;

        var lProtoType = Model.Add(lType, false);
        ...

Expected output for IsDefined(lType) would be false if the type is not defined 
in the model, and true otherwise. The result is always true and the type is 
added to the model.

What version of the product are you using? On what operating system?
Version is 2.0.0.668 on Windows 7 using .Net 4.0.3, C#

Originally posted to 
http://stackoverflow.com/questions/27399527/protobuf-net-isdefined-logical-bug

Original issue reported on code.google.com by RichardP...@gmail.com on 10 Dec 2014 at 11:42