evgenekov / protobuf-csharp-port

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

Builder.Clear() does not clear enum fields #99

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.Create a proto message that has an enum field
2.Create a c# builder for that message outside a loop, and loop 10 times.
3.Within the loop call Clear() on the builder and then set fields values.
4.Only set the enum field on iteration number #5
5.Print the contents of the builder as the last step in the loop.

What is the expected output? 
- only the 5th printout should show a value for the enumerated value

What do you see instead?
- the 5th and all subsequent printouts show the enumerated value.

What version of the product are you using? On what operating system?
2.4.1.521 Windows7

Original issue reported on code.google.com by aaron.hu...@gmail.com on 13 Feb 2015 at 8:02

GoogleCodeExporter commented 9 years ago
Does there have to be a loop for this? It sounds like it should be easy 
demonstrate without any looping. (It does sound like a real problem though...)

Original comment by jonathan.skeet on 13 Feb 2015 at 8:45

GoogleCodeExporter commented 9 years ago
Looping isn't needed.  It's just how this issue bit me.  Thanks for the
reply

On Fri, Feb 13, 2015, 12:45 PM null <protobuf-csharp-port@googlecode.com>
wrote:

Original comment by aaron.hu...@gmail.com on 13 Feb 2015 at 8:57

GoogleCodeExporter commented 9 years ago
I can't reproduce this in a test, e.g.

    [TestMethod]
    public void ClearWithEnum()
    {
        var builder = new TestAllTypes.Builder {OptionalForeignEnum = ForeignEnum.FOREIGN_BAR};
        var message = builder.Build();
        Assert.IsTrue(message.HasOptionalForeignEnum);
        Assert.AreEqual(ForeignEnum.FOREIGN_BAR, message.OptionalForeignEnum);
        builder.Clear();
        message = builder.Build();
        Assert.IsFalse(message.HasOptionalForeignEnum);
    }

That passes. Could you give a similar test (or short but complete program) that 
fails?

Original comment by jonathan.skeet on 15 Feb 2015 at 10:52

GoogleCodeExporter commented 9 years ago
Sorry Jon, my bad.  Please disregard.  

Original comment by aaron.hu...@gmail.com on 15 Feb 2015 at 7:15

GoogleCodeExporter commented 9 years ago
So you made a mistake diagnosing it? Fantastic - will close the issue. Thanks!
(If it turns out there really is a problem after all, feel free to reopen, of 
course.)

Original comment by jonathan.skeet on 15 Feb 2015 at 7:25