Commit e81a9d7c authored by Jon Skeet's avatar Jon Skeet

Added ToBuilder and WeakToBuilder

parent 25a28580
...@@ -179,6 +179,7 @@ namespace Google.ProtocolBuffers.Examples.AddressBook { ...@@ -179,6 +179,7 @@ namespace Google.ProtocolBuffers.Examples.AddressBook {
return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
} }
public static Builder CreateBuilder() { return new Builder(); } public static Builder CreateBuilder() { return new Builder(); }
public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); } public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(PhoneNumber prototype) { public static Builder CreateBuilder(PhoneNumber prototype) {
return (Builder) new Builder().MergeFrom(prototype); return (Builder) new Builder().MergeFrom(prototype);
...@@ -435,6 +436,7 @@ namespace Google.ProtocolBuffers.Examples.AddressBook { ...@@ -435,6 +436,7 @@ namespace Google.ProtocolBuffers.Examples.AddressBook {
return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
} }
public static Builder CreateBuilder() { return new Builder(); } public static Builder CreateBuilder() { return new Builder(); }
public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); } public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(Person prototype) { public static Builder CreateBuilder(Person prototype) {
return (Builder) new Builder().MergeFrom(prototype); return (Builder) new Builder().MergeFrom(prototype);
...@@ -732,6 +734,7 @@ namespace Google.ProtocolBuffers.Examples.AddressBook { ...@@ -732,6 +734,7 @@ namespace Google.ProtocolBuffers.Examples.AddressBook {
return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
} }
public static Builder CreateBuilder() { return new Builder(); } public static Builder CreateBuilder() { return new Builder(); }
public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); } public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(AddressBook prototype) { public static Builder CreateBuilder(AddressBook prototype) {
return (Builder) new Builder().MergeFrom(prototype); return (Builder) new Builder().MergeFrom(prototype);
......
...@@ -525,6 +525,7 @@ namespace Google.ProtocolBuffers.ProtoBench { ...@@ -525,6 +525,7 @@ namespace Google.ProtocolBuffers.ProtoBench {
return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
} }
public static Builder CreateBuilder() { return new Builder(); } public static Builder CreateBuilder() { return new Builder(); }
public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); } public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(Message1 prototype) { public static Builder CreateBuilder(Message1 prototype) {
return (Builder) new Builder().MergeFrom(prototype); return (Builder) new Builder().MergeFrom(prototype);
...@@ -1568,6 +1569,7 @@ namespace Google.ProtocolBuffers.ProtoBench { ...@@ -1568,6 +1569,7 @@ namespace Google.ProtocolBuffers.ProtoBench {
return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
} }
public static Builder CreateBuilder() { return new Builder(); } public static Builder CreateBuilder() { return new Builder(); }
public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); } public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(Message2 prototype) { public static Builder CreateBuilder(Message2 prototype) {
return (Builder) new Builder().MergeFrom(prototype); return (Builder) new Builder().MergeFrom(prototype);
...@@ -2194,6 +2196,7 @@ namespace Google.ProtocolBuffers.ProtoBench { ...@@ -2194,6 +2196,7 @@ namespace Google.ProtocolBuffers.ProtoBench {
return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
} }
public static Builder CreateBuilder() { return new Builder(); } public static Builder CreateBuilder() { return new Builder(); }
public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); } public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(Group1 prototype) { public static Builder CreateBuilder(Group1 prototype) {
return (Builder) new Builder().MergeFrom(prototype); return (Builder) new Builder().MergeFrom(prototype);
...@@ -2886,6 +2889,7 @@ namespace Google.ProtocolBuffers.ProtoBench { ...@@ -2886,6 +2889,7 @@ namespace Google.ProtocolBuffers.ProtoBench {
return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
} }
public static Builder CreateBuilder() { return new Builder(); } public static Builder CreateBuilder() { return new Builder(); }
public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); } public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(Message3 prototype) { public static Builder CreateBuilder(Message3 prototype) {
return (Builder) new Builder().MergeFrom(prototype); return (Builder) new Builder().MergeFrom(prototype);
...@@ -3670,6 +3674,7 @@ namespace Google.ProtocolBuffers.ProtoBench { ...@@ -3670,6 +3674,7 @@ namespace Google.ProtocolBuffers.ProtoBench {
return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
} }
public static Builder CreateBuilder() { return new Builder(); } public static Builder CreateBuilder() { return new Builder(); }
public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); } public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(Message4 prototype) { public static Builder CreateBuilder(Message4 prototype) {
return (Builder) new Builder().MergeFrom(prototype); return (Builder) new Builder().MergeFrom(prototype);
......
...@@ -803,6 +803,7 @@ namespace Google.ProtocolBuffers.ProtoBench { ...@@ -803,6 +803,7 @@ namespace Google.ProtocolBuffers.ProtoBench {
return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
} }
public static Builder CreateBuilder() { return new Builder(); } public static Builder CreateBuilder() { return new Builder(); }
public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); } public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(SpeedMessage1 prototype) { public static Builder CreateBuilder(SpeedMessage1 prototype) {
return (Builder) new Builder().MergeFrom(prototype); return (Builder) new Builder().MergeFrom(prototype);
...@@ -2320,6 +2321,7 @@ namespace Google.ProtocolBuffers.ProtoBench { ...@@ -2320,6 +2321,7 @@ namespace Google.ProtocolBuffers.ProtoBench {
return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
} }
public static Builder CreateBuilder() { return new Builder(); } public static Builder CreateBuilder() { return new Builder(); }
public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); } public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(SpeedMessage2 prototype) { public static Builder CreateBuilder(SpeedMessage2 prototype) {
return (Builder) new Builder().MergeFrom(prototype); return (Builder) new Builder().MergeFrom(prototype);
...@@ -3267,6 +3269,7 @@ namespace Google.ProtocolBuffers.ProtoBench { ...@@ -3267,6 +3269,7 @@ namespace Google.ProtocolBuffers.ProtoBench {
return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
} }
public static Builder CreateBuilder() { return new Builder(); } public static Builder CreateBuilder() { return new Builder(); }
public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); } public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(Group1 prototype) { public static Builder CreateBuilder(Group1 prototype) {
return (Builder) new Builder().MergeFrom(prototype); return (Builder) new Builder().MergeFrom(prototype);
...@@ -4339,6 +4342,7 @@ namespace Google.ProtocolBuffers.ProtoBench { ...@@ -4339,6 +4342,7 @@ namespace Google.ProtocolBuffers.ProtoBench {
return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
} }
public static Builder CreateBuilder() { return new Builder(); } public static Builder CreateBuilder() { return new Builder(); }
public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); } public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(SpeedMessage3 prototype) { public static Builder CreateBuilder(SpeedMessage3 prototype) {
return (Builder) new Builder().MergeFrom(prototype); return (Builder) new Builder().MergeFrom(prototype);
...@@ -5463,6 +5467,7 @@ namespace Google.ProtocolBuffers.ProtoBench { ...@@ -5463,6 +5467,7 @@ namespace Google.ProtocolBuffers.ProtoBench {
return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
} }
public static Builder CreateBuilder() { return new Builder(); } public static Builder CreateBuilder() { return new Builder(); }
public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); } public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(SpeedMessage4 prototype) { public static Builder CreateBuilder(SpeedMessage4 prototype) {
return (Builder) new Builder().MergeFrom(prototype); return (Builder) new Builder().MergeFrom(prototype);
......
...@@ -267,6 +267,7 @@ namespace Google.ProtocolBuffers.ProtoGen { ...@@ -267,6 +267,7 @@ namespace Google.ProtocolBuffers.ProtoGen {
private void GenerateBuilder(TextGenerator writer) { private void GenerateBuilder(TextGenerator writer) {
writer.WriteLine("public static Builder CreateBuilder() { return new Builder(); }"); writer.WriteLine("public static Builder CreateBuilder() { return new Builder(); }");
writer.WriteLine("public override Builder ToBuilder() { return CreateBuilder(this); }");
writer.WriteLine("public override Builder CreateBuilderForType() { return new Builder(); }"); writer.WriteLine("public override Builder CreateBuilderForType() { return new Builder(); }");
writer.WriteLine("public static Builder CreateBuilder({0} prototype) {{", ClassName); writer.WriteLine("public static Builder CreateBuilder({0} prototype) {{", ClassName);
writer.WriteLine(" return (Builder) new Builder().MergeFrom(prototype);"); writer.WriteLine(" return (Builder) new Builder().MergeFrom(prototype);");
......
...@@ -297,6 +297,10 @@ namespace Google.ProtocolBuffers { ...@@ -297,6 +297,10 @@ namespace Google.ProtocolBuffers {
return new Builder(wrappedMessage.WeakCreateBuilderForType()); return new Builder(wrappedMessage.WeakCreateBuilderForType());
} }
public override Builder ToBuilder() {
return new Builder(wrappedMessage.WeakToBuilder());
}
internal class Builder : AbstractBuilder<AbstractMessageWrapper, Builder> { internal class Builder : AbstractBuilder<AbstractMessageWrapper, Builder> {
private readonly IBuilder wrappedBuilder; private readonly IBuilder wrappedBuilder;
......
using System.Collections.Generic;
using Google.ProtocolBuffers.TestProtos; using Google.ProtocolBuffers.TestProtos;
// Protocol Buffers - Google's data interchange format // Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved. // Copyright 2008 Google Inc. All rights reserved.
...@@ -173,5 +174,26 @@ namespace Google.ProtocolBuffers { ...@@ -173,5 +174,26 @@ namespace Google.ProtocolBuffers {
DynamicMessage copy = DynamicMessage.CreateBuilder(message).Build(); DynamicMessage copy = DynamicMessage.CreateBuilder(message).Build();
reflectionTester.AssertAllFieldsSetViaReflection(copy); reflectionTester.AssertAllFieldsSetViaReflection(copy);
} }
[Test]
public void ToBuilder() {
DynamicMessage.Builder builder =
DynamicMessage.CreateBuilder(TestAllTypes.Descriptor);
reflectionTester.SetAllFieldsViaReflection(builder);
int unknownFieldNum = 9;
ulong unknownFieldVal = 90;
builder.SetUnknownFields(UnknownFieldSet.CreateBuilder()
.AddField(unknownFieldNum,
UnknownField.CreateBuilder().AddVarint(unknownFieldVal).Build())
.Build());
DynamicMessage message = builder.Build();
DynamicMessage derived = message.ToBuilder().Build();
reflectionTester.AssertAllFieldsSetViaReflection(derived);
IList<ulong> values = derived.UnknownFields.FieldDictionary[unknownFieldNum].VarintList;
Assert.AreEqual(1, values.Count);
Assert.AreEqual(unknownFieldVal, values[0]);
}
} }
} }
...@@ -385,5 +385,13 @@ namespace Google.ProtocolBuffers { ...@@ -385,5 +385,13 @@ namespace Google.ProtocolBuffers {
Assert.IsTrue(builder.IsInitialized); Assert.IsTrue(builder.IsInitialized);
Assert.IsTrue(builder.BuildPartial().IsInitialized); Assert.IsTrue(builder.BuildPartial().IsInitialized);
} }
[Test]
public void ToBuilder() {
TestAllTypes.Builder builder = TestAllTypes.CreateBuilder();
TestUtil.SetAllFields(builder);
TestAllTypes message = builder.Build();
TestUtil.AssertAllFieldsSet(message.ToBuilder().Build());
}
} }
} }
...@@ -344,6 +344,7 @@ namespace Google.ProtocolBuffers.TestProtos { ...@@ -344,6 +344,7 @@ namespace Google.ProtocolBuffers.TestProtos {
return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
} }
public static Builder CreateBuilder() { return new Builder(); } public static Builder CreateBuilder() { return new Builder(); }
public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); } public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(TestMessageWithCustomOptions prototype) { public static Builder CreateBuilder(TestMessageWithCustomOptions prototype) {
return (Builder) new Builder().MergeFrom(prototype); return (Builder) new Builder().MergeFrom(prototype);
...@@ -453,6 +454,7 @@ namespace Google.ProtocolBuffers.TestProtos { ...@@ -453,6 +454,7 @@ namespace Google.ProtocolBuffers.TestProtos {
return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
} }
public static Builder CreateBuilder() { return new Builder(); } public static Builder CreateBuilder() { return new Builder(); }
public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); } public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(CustomOptionFooRequest prototype) { public static Builder CreateBuilder(CustomOptionFooRequest prototype) {
return (Builder) new Builder().MergeFrom(prototype); return (Builder) new Builder().MergeFrom(prototype);
...@@ -543,6 +545,7 @@ namespace Google.ProtocolBuffers.TestProtos { ...@@ -543,6 +545,7 @@ namespace Google.ProtocolBuffers.TestProtos {
return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
} }
public static Builder CreateBuilder() { return new Builder(); } public static Builder CreateBuilder() { return new Builder(); }
public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); } public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(CustomOptionFooResponse prototype) { public static Builder CreateBuilder(CustomOptionFooResponse prototype) {
return (Builder) new Builder().MergeFrom(prototype); return (Builder) new Builder().MergeFrom(prototype);
...@@ -643,6 +646,7 @@ namespace Google.ProtocolBuffers.TestProtos { ...@@ -643,6 +646,7 @@ namespace Google.ProtocolBuffers.TestProtos {
return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
} }
public static Builder CreateBuilder() { return new Builder(); } public static Builder CreateBuilder() { return new Builder(); }
public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); } public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(DummyMessageContainingEnum prototype) { public static Builder CreateBuilder(DummyMessageContainingEnum prototype) {
return (Builder) new Builder().MergeFrom(prototype); return (Builder) new Builder().MergeFrom(prototype);
...@@ -733,6 +737,7 @@ namespace Google.ProtocolBuffers.TestProtos { ...@@ -733,6 +737,7 @@ namespace Google.ProtocolBuffers.TestProtos {
return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
} }
public static Builder CreateBuilder() { return new Builder(); } public static Builder CreateBuilder() { return new Builder(); }
public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); } public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(DummyMessageInvalidAsOptionType prototype) { public static Builder CreateBuilder(DummyMessageInvalidAsOptionType prototype) {
return (Builder) new Builder().MergeFrom(prototype); return (Builder) new Builder().MergeFrom(prototype);
...@@ -823,6 +828,7 @@ namespace Google.ProtocolBuffers.TestProtos { ...@@ -823,6 +828,7 @@ namespace Google.ProtocolBuffers.TestProtos {
return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
} }
public static Builder CreateBuilder() { return new Builder(); } public static Builder CreateBuilder() { return new Builder(); }
public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); } public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(CustomOptionMinIntegerValues prototype) { public static Builder CreateBuilder(CustomOptionMinIntegerValues prototype) {
return (Builder) new Builder().MergeFrom(prototype); return (Builder) new Builder().MergeFrom(prototype);
...@@ -913,6 +919,7 @@ namespace Google.ProtocolBuffers.TestProtos { ...@@ -913,6 +919,7 @@ namespace Google.ProtocolBuffers.TestProtos {
return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
} }
public static Builder CreateBuilder() { return new Builder(); } public static Builder CreateBuilder() { return new Builder(); }
public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); } public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(CustomOptionMaxIntegerValues prototype) { public static Builder CreateBuilder(CustomOptionMaxIntegerValues prototype) {
return (Builder) new Builder().MergeFrom(prototype); return (Builder) new Builder().MergeFrom(prototype);
...@@ -1003,6 +1010,7 @@ namespace Google.ProtocolBuffers.TestProtos { ...@@ -1003,6 +1010,7 @@ namespace Google.ProtocolBuffers.TestProtos {
return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
} }
public static Builder CreateBuilder() { return new Builder(); } public static Builder CreateBuilder() { return new Builder(); }
public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); } public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(CustomOptionOtherValues prototype) { public static Builder CreateBuilder(CustomOptionOtherValues prototype) {
return (Builder) new Builder().MergeFrom(prototype); return (Builder) new Builder().MergeFrom(prototype);
...@@ -1093,6 +1101,7 @@ namespace Google.ProtocolBuffers.TestProtos { ...@@ -1093,6 +1101,7 @@ namespace Google.ProtocolBuffers.TestProtos {
return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
} }
public static Builder CreateBuilder() { return new Builder(); } public static Builder CreateBuilder() { return new Builder(); }
public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); } public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(SettingRealsFromPositiveInts prototype) { public static Builder CreateBuilder(SettingRealsFromPositiveInts prototype) {
return (Builder) new Builder().MergeFrom(prototype); return (Builder) new Builder().MergeFrom(prototype);
...@@ -1183,6 +1192,7 @@ namespace Google.ProtocolBuffers.TestProtos { ...@@ -1183,6 +1192,7 @@ namespace Google.ProtocolBuffers.TestProtos {
return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
} }
public static Builder CreateBuilder() { return new Builder(); } public static Builder CreateBuilder() { return new Builder(); }
public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); } public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(SettingRealsFromNegativeInts prototype) { public static Builder CreateBuilder(SettingRealsFromNegativeInts prototype) {
return (Builder) new Builder().MergeFrom(prototype); return (Builder) new Builder().MergeFrom(prototype);
...@@ -1282,6 +1292,7 @@ namespace Google.ProtocolBuffers.TestProtos { ...@@ -1282,6 +1292,7 @@ namespace Google.ProtocolBuffers.TestProtos {
return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
} }
public static Builder CreateBuilder() { return new Builder(); } public static Builder CreateBuilder() { return new Builder(); }
public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); } public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(ComplexOptionType1 prototype) { public static Builder CreateBuilder(ComplexOptionType1 prototype) {
return (Builder) new Builder().MergeFrom(prototype); return (Builder) new Builder().MergeFrom(prototype);
...@@ -1425,6 +1436,7 @@ namespace Google.ProtocolBuffers.TestProtos { ...@@ -1425,6 +1436,7 @@ namespace Google.ProtocolBuffers.TestProtos {
return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
} }
public static Builder CreateBuilder() { return new Builder(); } public static Builder CreateBuilder() { return new Builder(); }
public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); } public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(ComplexOptionType4 prototype) { public static Builder CreateBuilder(ComplexOptionType4 prototype) {
return (Builder) new Builder().MergeFrom(prototype); return (Builder) new Builder().MergeFrom(prototype);
...@@ -1541,6 +1553,7 @@ namespace Google.ProtocolBuffers.TestProtos { ...@@ -1541,6 +1553,7 @@ namespace Google.ProtocolBuffers.TestProtos {
return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
} }
public static Builder CreateBuilder() { return new Builder(); } public static Builder CreateBuilder() { return new Builder(); }
public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); } public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(ComplexOptionType2 prototype) { public static Builder CreateBuilder(ComplexOptionType2 prototype) {
return (Builder) new Builder().MergeFrom(prototype); return (Builder) new Builder().MergeFrom(prototype);
...@@ -1754,6 +1767,7 @@ namespace Google.ProtocolBuffers.TestProtos { ...@@ -1754,6 +1767,7 @@ namespace Google.ProtocolBuffers.TestProtos {
return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
} }
public static Builder CreateBuilder() { return new Builder(); } public static Builder CreateBuilder() { return new Builder(); }
public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); } public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(ComplexOptionType5 prototype) { public static Builder CreateBuilder(ComplexOptionType5 prototype) {
return (Builder) new Builder().MergeFrom(prototype); return (Builder) new Builder().MergeFrom(prototype);
...@@ -1861,6 +1875,7 @@ namespace Google.ProtocolBuffers.TestProtos { ...@@ -1861,6 +1875,7 @@ namespace Google.ProtocolBuffers.TestProtos {
return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
} }
public static Builder CreateBuilder() { return new Builder(); } public static Builder CreateBuilder() { return new Builder(); }
public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); } public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(ComplexOptionType3 prototype) { public static Builder CreateBuilder(ComplexOptionType3 prototype) {
return (Builder) new Builder().MergeFrom(prototype); return (Builder) new Builder().MergeFrom(prototype);
...@@ -2014,6 +2029,7 @@ namespace Google.ProtocolBuffers.TestProtos { ...@@ -2014,6 +2029,7 @@ namespace Google.ProtocolBuffers.TestProtos {
return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
} }
public static Builder CreateBuilder() { return new Builder(); } public static Builder CreateBuilder() { return new Builder(); }
public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); } public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(ComplexOpt6 prototype) { public static Builder CreateBuilder(ComplexOpt6 prototype) {
return (Builder) new Builder().MergeFrom(prototype); return (Builder) new Builder().MergeFrom(prototype);
...@@ -2122,6 +2138,7 @@ namespace Google.ProtocolBuffers.TestProtos { ...@@ -2122,6 +2138,7 @@ namespace Google.ProtocolBuffers.TestProtos {
return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
} }
public static Builder CreateBuilder() { return new Builder(); } public static Builder CreateBuilder() { return new Builder(); }
public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); } public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(VariousComplexOptions prototype) { public static Builder CreateBuilder(VariousComplexOptions prototype) {
return (Builder) new Builder().MergeFrom(prototype); return (Builder) new Builder().MergeFrom(prototype);
......
...@@ -146,6 +146,7 @@ namespace Google.ProtocolBuffers.TestProtos { ...@@ -146,6 +146,7 @@ namespace Google.ProtocolBuffers.TestProtos {
return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
} }
public static Builder CreateBuilder() { return new Builder(); } public static Builder CreateBuilder() { return new Builder(); }
public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); } public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(TestEmbedOptimizedForSize prototype) { public static Builder CreateBuilder(TestEmbedOptimizedForSize prototype) {
return (Builder) new Builder().MergeFrom(prototype); return (Builder) new Builder().MergeFrom(prototype);
......
...@@ -129,6 +129,7 @@ namespace Google.ProtocolBuffers.TestProtos { ...@@ -129,6 +129,7 @@ namespace Google.ProtocolBuffers.TestProtos {
return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
} }
public static Builder CreateBuilder() { return new Builder(); } public static Builder CreateBuilder() { return new Builder(); }
public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); } public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(ImportMessage prototype) { public static Builder CreateBuilder(ImportMessage prototype) {
return (Builder) new Builder().MergeFrom(prototype); return (Builder) new Builder().MergeFrom(prototype);
......
...@@ -143,6 +143,7 @@ namespace Google.ProtocolBuffers.TestProtos { ...@@ -143,6 +143,7 @@ namespace Google.ProtocolBuffers.TestProtos {
return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
} }
public static Builder CreateBuilder() { return new Builder(); } public static Builder CreateBuilder() { return new Builder(); }
public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); } public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(TestMessageSet prototype) { public static Builder CreateBuilder(TestMessageSet prototype) {
return (Builder) new Builder().MergeFrom(prototype); return (Builder) new Builder().MergeFrom(prototype);
...@@ -311,6 +312,7 @@ namespace Google.ProtocolBuffers.TestProtos { ...@@ -311,6 +312,7 @@ namespace Google.ProtocolBuffers.TestProtos {
return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
} }
public static Builder CreateBuilder() { return new Builder(); } public static Builder CreateBuilder() { return new Builder(); }
public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); } public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(TestMessageSetContainer prototype) { public static Builder CreateBuilder(TestMessageSetContainer prototype) {
return (Builder) new Builder().MergeFrom(prototype); return (Builder) new Builder().MergeFrom(prototype);
...@@ -528,6 +530,7 @@ namespace Google.ProtocolBuffers.TestProtos { ...@@ -528,6 +530,7 @@ namespace Google.ProtocolBuffers.TestProtos {
return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
} }
public static Builder CreateBuilder() { return new Builder(); } public static Builder CreateBuilder() { return new Builder(); }
public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); } public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(TestMessageSetExtension1 prototype) { public static Builder CreateBuilder(TestMessageSetExtension1 prototype) {
return (Builder) new Builder().MergeFrom(prototype); return (Builder) new Builder().MergeFrom(prototype);
...@@ -722,6 +725,7 @@ namespace Google.ProtocolBuffers.TestProtos { ...@@ -722,6 +725,7 @@ namespace Google.ProtocolBuffers.TestProtos {
return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
} }
public static Builder CreateBuilder() { return new Builder(); } public static Builder CreateBuilder() { return new Builder(); }
public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); } public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(TestMessageSetExtension2 prototype) { public static Builder CreateBuilder(TestMessageSetExtension2 prototype) {
return (Builder) new Builder().MergeFrom(prototype); return (Builder) new Builder().MergeFrom(prototype);
...@@ -956,6 +960,7 @@ namespace Google.ProtocolBuffers.TestProtos { ...@@ -956,6 +960,7 @@ namespace Google.ProtocolBuffers.TestProtos {
return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
} }
public static Builder CreateBuilder() { return new Builder(); } public static Builder CreateBuilder() { return new Builder(); }
public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); } public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(Item prototype) { public static Builder CreateBuilder(Item prototype) {
return (Builder) new Builder().MergeFrom(prototype); return (Builder) new Builder().MergeFrom(prototype);
...@@ -1157,6 +1162,7 @@ namespace Google.ProtocolBuffers.TestProtos { ...@@ -1157,6 +1162,7 @@ namespace Google.ProtocolBuffers.TestProtos {
return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
} }
public static Builder CreateBuilder() { return new Builder(); } public static Builder CreateBuilder() { return new Builder(); }
public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); } public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(RawMessageSet prototype) { public static Builder CreateBuilder(RawMessageSet prototype) {
return (Builder) new Builder().MergeFrom(prototype); return (Builder) new Builder().MergeFrom(prototype);
......
...@@ -122,6 +122,7 @@ namespace Google.ProtocolBuffers.TestProtos { ...@@ -122,6 +122,7 @@ namespace Google.ProtocolBuffers.TestProtos {
return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
} }
public static Builder CreateBuilder() { return new Builder(); } public static Builder CreateBuilder() { return new Builder(); }
public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); } public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(TestOptimizedForSize prototype) { public static Builder CreateBuilder(TestOptimizedForSize prototype) {
return (Builder) new Builder().MergeFrom(prototype); return (Builder) new Builder().MergeFrom(prototype);
...@@ -275,6 +276,7 @@ namespace Google.ProtocolBuffers.TestProtos { ...@@ -275,6 +276,7 @@ namespace Google.ProtocolBuffers.TestProtos {
return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
} }
public static Builder CreateBuilder() { return new Builder(); } public static Builder CreateBuilder() { return new Builder(); }
public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); } public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(TestRequiredOptimizedForSize prototype) { public static Builder CreateBuilder(TestRequiredOptimizedForSize prototype) {
return (Builder) new Builder().MergeFrom(prototype); return (Builder) new Builder().MergeFrom(prototype);
...@@ -392,6 +394,7 @@ namespace Google.ProtocolBuffers.TestProtos { ...@@ -392,6 +394,7 @@ namespace Google.ProtocolBuffers.TestProtos {
return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
} }
public static Builder CreateBuilder() { return new Builder(); } public static Builder CreateBuilder() { return new Builder(); }
public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); } public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(TestOptionalOptimizedForSize prototype) { public static Builder CreateBuilder(TestOptionalOptimizedForSize prototype) {
return (Builder) new Builder().MergeFrom(prototype); return (Builder) new Builder().MergeFrom(prototype);
......
...@@ -58,12 +58,17 @@ namespace Google.ProtocolBuffers { ...@@ -58,12 +58,17 @@ namespace Google.ProtocolBuffers {
public abstract UnknownFieldSet UnknownFields { get; } public abstract UnknownFieldSet UnknownFields { get; }
public abstract TMessage DefaultInstanceForType { get; } public abstract TMessage DefaultInstanceForType { get; }
public abstract TBuilder CreateBuilderForType(); public abstract TBuilder CreateBuilderForType();
public abstract TBuilder ToBuilder();
#endregion #endregion
public IBuilder WeakCreateBuilderForType() { public IBuilder WeakCreateBuilderForType() {
return CreateBuilderForType(); return CreateBuilderForType();
} }
public IBuilder WeakToBuilder() {
return ToBuilder();
}
public IMessage WeakDefaultInstanceForType { public IMessage WeakDefaultInstanceForType {
get { return DefaultInstanceForType; } get { return DefaultInstanceForType; }
} }
......
...@@ -143,6 +143,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { ...@@ -143,6 +143,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
} }
public static Builder CreateBuilder() { return new Builder(); } public static Builder CreateBuilder() { return new Builder(); }
public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); } public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(CSharpFileOptions prototype) { public static Builder CreateBuilder(CSharpFileOptions prototype) {
return (Builder) new Builder().MergeFrom(prototype); return (Builder) new Builder().MergeFrom(prototype);
...@@ -334,6 +335,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { ...@@ -334,6 +335,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
} }
public static Builder CreateBuilder() { return new Builder(); } public static Builder CreateBuilder() { return new Builder(); }
public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); } public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(CSharpFieldOptions prototype) { public static Builder CreateBuilder(CSharpFieldOptions prototype) {
return (Builder) new Builder().MergeFrom(prototype); return (Builder) new Builder().MergeFrom(prototype);
......
...@@ -279,6 +279,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { ...@@ -279,6 +279,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
} }
public static Builder CreateBuilder() { return new Builder(); } public static Builder CreateBuilder() { return new Builder(); }
public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); } public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(FileDescriptorSet prototype) { public static Builder CreateBuilder(FileDescriptorSet prototype) {
return (Builder) new Builder().MergeFrom(prototype); return (Builder) new Builder().MergeFrom(prototype);
...@@ -631,6 +632,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { ...@@ -631,6 +632,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
} }
public static Builder CreateBuilder() { return new Builder(); } public static Builder CreateBuilder() { return new Builder(); }
public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); } public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(FileDescriptorProto prototype) { public static Builder CreateBuilder(FileDescriptorProto prototype) {
return (Builder) new Builder().MergeFrom(prototype); return (Builder) new Builder().MergeFrom(prototype);
...@@ -1165,6 +1167,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { ...@@ -1165,6 +1167,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
} }
public static Builder CreateBuilder() { return new Builder(); } public static Builder CreateBuilder() { return new Builder(); }
public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); } public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(ExtensionRange prototype) { public static Builder CreateBuilder(ExtensionRange prototype) {
return (Builder) new Builder().MergeFrom(prototype); return (Builder) new Builder().MergeFrom(prototype);
...@@ -1478,6 +1481,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { ...@@ -1478,6 +1481,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
} }
public static Builder CreateBuilder() { return new Builder(); } public static Builder CreateBuilder() { return new Builder(); }
public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); } public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(DescriptorProto prototype) { public static Builder CreateBuilder(DescriptorProto prototype) {
return (Builder) new Builder().MergeFrom(prototype); return (Builder) new Builder().MergeFrom(prototype);
...@@ -2099,6 +2103,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { ...@@ -2099,6 +2103,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
} }
public static Builder CreateBuilder() { return new Builder(); } public static Builder CreateBuilder() { return new Builder(); }
public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); } public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(FieldDescriptorProto prototype) { public static Builder CreateBuilder(FieldDescriptorProto prototype) {
return (Builder) new Builder().MergeFrom(prototype); return (Builder) new Builder().MergeFrom(prototype);
...@@ -2541,6 +2546,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { ...@@ -2541,6 +2546,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
} }
public static Builder CreateBuilder() { return new Builder(); } public static Builder CreateBuilder() { return new Builder(); }
public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); } public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(EnumDescriptorProto prototype) { public static Builder CreateBuilder(EnumDescriptorProto prototype) {
return (Builder) new Builder().MergeFrom(prototype); return (Builder) new Builder().MergeFrom(prototype);
...@@ -2863,6 +2869,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { ...@@ -2863,6 +2869,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
} }
public static Builder CreateBuilder() { return new Builder(); } public static Builder CreateBuilder() { return new Builder(); }
public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); } public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(EnumValueDescriptorProto prototype) { public static Builder CreateBuilder(EnumValueDescriptorProto prototype) {
return (Builder) new Builder().MergeFrom(prototype); return (Builder) new Builder().MergeFrom(prototype);
...@@ -3167,6 +3174,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { ...@@ -3167,6 +3174,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
} }
public static Builder CreateBuilder() { return new Builder(); } public static Builder CreateBuilder() { return new Builder(); }
public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); } public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(ServiceDescriptorProto prototype) { public static Builder CreateBuilder(ServiceDescriptorProto prototype) {
return (Builder) new Builder().MergeFrom(prototype); return (Builder) new Builder().MergeFrom(prototype);
...@@ -3504,6 +3512,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { ...@@ -3504,6 +3512,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
} }
public static Builder CreateBuilder() { return new Builder(); } public static Builder CreateBuilder() { return new Builder(); }
public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); } public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(MethodDescriptorProto prototype) { public static Builder CreateBuilder(MethodDescriptorProto prototype) {
return (Builder) new Builder().MergeFrom(prototype); return (Builder) new Builder().MergeFrom(prototype);
...@@ -3876,6 +3885,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { ...@@ -3876,6 +3885,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
} }
public static Builder CreateBuilder() { return new Builder(); } public static Builder CreateBuilder() { return new Builder(); }
public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); } public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(FileOptions prototype) { public static Builder CreateBuilder(FileOptions prototype) {
return (Builder) new Builder().MergeFrom(prototype); return (Builder) new Builder().MergeFrom(prototype);
...@@ -4223,6 +4233,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { ...@@ -4223,6 +4233,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
} }
public static Builder CreateBuilder() { return new Builder(); } public static Builder CreateBuilder() { return new Builder(); }
public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); } public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(MessageOptions prototype) { public static Builder CreateBuilder(MessageOptions prototype) {
return (Builder) new Builder().MergeFrom(prototype); return (Builder) new Builder().MergeFrom(prototype);
...@@ -4528,6 +4539,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { ...@@ -4528,6 +4539,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
} }
public static Builder CreateBuilder() { return new Builder(); } public static Builder CreateBuilder() { return new Builder(); }
public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); } public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(FieldOptions prototype) { public static Builder CreateBuilder(FieldOptions prototype) {
return (Builder) new Builder().MergeFrom(prototype); return (Builder) new Builder().MergeFrom(prototype);
...@@ -4834,6 +4846,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { ...@@ -4834,6 +4846,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
} }
public static Builder CreateBuilder() { return new Builder(); } public static Builder CreateBuilder() { return new Builder(); }
public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); } public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(EnumOptions prototype) { public static Builder CreateBuilder(EnumOptions prototype) {
return (Builder) new Builder().MergeFrom(prototype); return (Builder) new Builder().MergeFrom(prototype);
...@@ -5059,6 +5072,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { ...@@ -5059,6 +5072,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
} }
public static Builder CreateBuilder() { return new Builder(); } public static Builder CreateBuilder() { return new Builder(); }
public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); } public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(EnumValueOptions prototype) { public static Builder CreateBuilder(EnumValueOptions prototype) {
return (Builder) new Builder().MergeFrom(prototype); return (Builder) new Builder().MergeFrom(prototype);
...@@ -5284,6 +5298,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { ...@@ -5284,6 +5298,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
} }
public static Builder CreateBuilder() { return new Builder(); } public static Builder CreateBuilder() { return new Builder(); }
public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); } public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(ServiceOptions prototype) { public static Builder CreateBuilder(ServiceOptions prototype) {
return (Builder) new Builder().MergeFrom(prototype); return (Builder) new Builder().MergeFrom(prototype);
...@@ -5509,6 +5524,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { ...@@ -5509,6 +5524,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
} }
public static Builder CreateBuilder() { return new Builder(); } public static Builder CreateBuilder() { return new Builder(); }
public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); } public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(MethodOptions prototype) { public static Builder CreateBuilder(MethodOptions prototype) {
return (Builder) new Builder().MergeFrom(prototype); return (Builder) new Builder().MergeFrom(prototype);
...@@ -5766,6 +5782,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { ...@@ -5766,6 +5782,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
} }
public static Builder CreateBuilder() { return new Builder(); } public static Builder CreateBuilder() { return new Builder(); }
public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); } public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(NamePart prototype) { public static Builder CreateBuilder(NamePart prototype) {
return (Builder) new Builder().MergeFrom(prototype); return (Builder) new Builder().MergeFrom(prototype);
...@@ -6045,6 +6062,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { ...@@ -6045,6 +6062,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
} }
public static Builder CreateBuilder() { return new Builder(); } public static Builder CreateBuilder() { return new Builder(); }
public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); } public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(UninterpretedOption prototype) { public static Builder CreateBuilder(UninterpretedOption prototype) {
return (Builder) new Builder().MergeFrom(prototype); return (Builder) new Builder().MergeFrom(prototype);
......
...@@ -74,7 +74,6 @@ namespace Google.ProtocolBuffers { ...@@ -74,7 +74,6 @@ namespace Google.ProtocolBuffers {
Builder builder = CreateBuilder(type); Builder builder = CreateBuilder(type);
Builder dynamicBuilder = builder.MergeFrom(input); Builder dynamicBuilder = builder.MergeFrom(input);
return dynamicBuilder.BuildParsed(); return dynamicBuilder.BuildParsed();
} }
/// <summary> /// <summary>
...@@ -247,6 +246,10 @@ namespace Google.ProtocolBuffers { ...@@ -247,6 +246,10 @@ namespace Google.ProtocolBuffers {
return new Builder(type); return new Builder(type);
} }
public override Builder ToBuilder() {
return CreateBuilderForType().MergeFrom(this);
}
/// <summary> /// <summary>
/// Verifies that the field is a field of this message. /// Verifies that the field is a field of this message.
/// </summary> /// </summary>
......
...@@ -326,8 +326,7 @@ namespace Google.ProtocolBuffers { ...@@ -326,8 +326,7 @@ namespace Google.ProtocolBuffers {
} }
} else if (field.MappedType == MappedType.Message && existingValue != null) { } else if (field.MappedType == MappedType.Message && existingValue != null) {
IMessage existingMessage = (IMessage)existingValue; IMessage existingMessage = (IMessage)existingValue;
IMessage merged = existingMessage.WeakCreateBuilderForType() IMessage merged = existingMessage.WeakToBuilder()
.WeakMergeFrom(existingMessage)
.WeakMergeFrom((IMessage) entry.Value) .WeakMergeFrom((IMessage) entry.Value)
.WeakBuild(); .WeakBuild();
this[field] = merged; this[field] = merged;
......
...@@ -168,11 +168,18 @@ namespace Google.ProtocolBuffers { ...@@ -168,11 +168,18 @@ namespace Google.ProtocolBuffers {
/// <summary> /// <summary>
/// Creates a builder for the type, but in a weakly typed manner. This /// Creates a builder for the type, but in a weakly typed manner. This
/// is typically implemented by strongly typed builders by just returning /// is typically implemented by strongly typed messages by just returning
/// the result of CreateBuilderForType. /// the result of CreateBuilderForType.
/// </summary> /// </summary>
IBuilder WeakCreateBuilderForType(); IBuilder WeakCreateBuilderForType();
/// <summary>
/// Creates a builder with the same contents as this message. This
/// is typically implemented by strongly typed messages by just returning
/// the result of ToBuilder.
/// </summary>
IBuilder WeakToBuilder();
IMessage WeakDefaultInstanceForType { get; } IMessage WeakDefaultInstanceForType { get; }
} }
...@@ -198,6 +205,12 @@ namespace Google.ProtocolBuffers { ...@@ -198,6 +205,12 @@ namespace Google.ProtocolBuffers {
/// Constructs a new builder for a message of the same type as this message. /// Constructs a new builder for a message of the same type as this message.
/// </summary> /// </summary>
TBuilder CreateBuilderForType(); TBuilder CreateBuilderForType();
/// <summary>
/// Creates a builder with the same contents as this current instance.
/// This is typically implemented by strongly typed messages by just
/// returning the result of ToBuilder().
/// </summary>
TBuilder ToBuilder();
#endregion #endregion
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment