diff options
Diffstat (limited to 'src/ProtocolBuffers.Test')
17 files changed, 5203 insertions, 1167 deletions
diff --git a/src/ProtocolBuffers.Test/GeneratedMessageTest.cs b/src/ProtocolBuffers.Test/GeneratedMessageTest.cs index 410452d3..12224e9b 100644 --- a/src/ProtocolBuffers.Test/GeneratedMessageTest.cs +++ b/src/ProtocolBuffers.Test/GeneratedMessageTest.cs @@ -112,22 +112,6 @@ namespace Google.ProtocolBuffers }
[Test]
- public void DoubleBuildError()
- {
- TestAllTypes.Builder builder = new TestAllTypes.Builder();
- builder.Build();
- try
- {
- builder.Build();
- Assert.Fail("Should have thrown exception.");
- }
- catch (InvalidOperationException)
- {
- // Success.
- }
- }
-
- [Test]
public void DefaultInstance()
{
Assert.AreSame(TestAllTypes.DefaultInstance, TestAllTypes.DefaultInstance.DefaultInstanceForType);
diff --git a/src/ProtocolBuffers.Test/ProtocolBuffers.Test.csproj b/src/ProtocolBuffers.Test/ProtocolBuffers.Test.csproj index 95ab0b9c..b1a7e559 100644 --- a/src/ProtocolBuffers.Test/ProtocolBuffers.Test.csproj +++ b/src/ProtocolBuffers.Test/ProtocolBuffers.Test.csproj @@ -105,6 +105,7 @@ <Compile Include="NameHelpersTest.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ReflectionTester.cs" />
+ <Compile Include="ReusableBuilderTest.cs" />
<Compile Include="ServiceTest.cs" />
<Compile Include="TestProtos\UnitTestCSharpOptionsProtoFile.cs" />
<Compile Include="TestProtos\UnitTestCustomOptionsProtoFile.cs" />
diff --git a/src/ProtocolBuffers.Test/ReusableBuilderTest.cs b/src/ProtocolBuffers.Test/ReusableBuilderTest.cs new file mode 100644 index 00000000..4184971f --- /dev/null +++ b/src/ProtocolBuffers.Test/ReusableBuilderTest.cs @@ -0,0 +1,117 @@ +using System;
+using System.Collections.Generic;
+using System.Text;
+using NUnit.Framework;
+using Google.ProtocolBuffers.TestProtos;
+
+namespace Google.ProtocolBuffers
+{
+ [TestFixture]
+ public class ReusableBuilderTest
+ {
+ [Test]
+ public void TestUnmodifiedDefaultInstance()
+ {
+ //Simply calling ToBuilder().Build() no longer creates a copy of the message
+ TestAllTypes.Builder builder = TestAllTypes.DefaultInstance.ToBuilder();
+ Assert.IsTrue(ReferenceEquals(TestAllTypes.DefaultInstance, builder.Build()));
+ }
+
+ [Test]
+ public void BuildMultipleWithoutChange()
+ {
+ //Calling Build() or BuildPartial() does not require a copy of the message
+ TestAllTypes.Builder builder = TestAllTypes.DefaultInstance.ToBuilder();
+ builder.SetDefaultBool(true);
+
+ TestAllTypes first = builder.BuildPartial();
+ //Still the same instance?
+ Assert.IsTrue(ReferenceEquals(first, builder.Build()));
+ //Still the same instance?
+ Assert.IsTrue(ReferenceEquals(first, builder.BuildPartial().ToBuilder().Build()));
+ }
+
+ [Test]
+ public void MergeFromDefaultInstance()
+ {
+ TestAllTypes.Builder builder = TestAllTypes.DefaultInstance.ToBuilder();
+ Assert.IsTrue(ReferenceEquals(TestAllTypes.DefaultInstance, builder.Build()));
+ builder.MergeFrom(TestAllTypes.DefaultInstance);
+ Assert.IsTrue(ReferenceEquals(TestAllTypes.DefaultInstance, builder.Build()));
+ }
+
+ [Test]
+ public void BuildNewBuilderIsDefaultInstance()
+ {
+ Assert.IsTrue(ReferenceEquals(TestAllTypes.DefaultInstance, new TestAllTypes.Builder().Build()));
+ Assert.IsTrue(ReferenceEquals(TestAllTypes.DefaultInstance, TestAllTypes.CreateBuilder().Build()));
+ //last test, if you clear a builder it reverts to default instance
+ Assert.IsTrue(ReferenceEquals(TestAllTypes.DefaultInstance,
+ TestAllTypes.CreateBuilder().SetOptionalBool(true).Build().ToBuilder().Clear().Build()));
+ }
+
+ [Test]
+ public void CloneOnChangePrimitive()
+ {
+ TestAllTypes.Builder builder = TestAllTypes.DefaultInstance.ToBuilder();
+ Assert.IsTrue(ReferenceEquals(TestAllTypes.DefaultInstance, builder.Build()));
+ builder.SetDefaultBool(true);
+ Assert.IsFalse(ReferenceEquals(TestAllTypes.DefaultInstance, builder.Build()));
+ }
+
+ [Test]
+ public void CloneOnAddRepeatedBool()
+ {
+ TestAllTypes.Builder builder = TestAllTypes.DefaultInstance.ToBuilder();
+ Assert.IsTrue(ReferenceEquals(TestAllTypes.DefaultInstance, builder.Build()));
+ builder.AddRepeatedBool(true);
+ Assert.IsFalse(ReferenceEquals(TestAllTypes.DefaultInstance, builder.Build()));
+ }
+
+ [Test]
+ public void CloneOnChangeMessage()
+ {
+ TestAllTypes.Builder builder = TestAllTypes.DefaultInstance.ToBuilder();
+ Assert.IsTrue(ReferenceEquals(TestAllTypes.DefaultInstance, builder.Build()));
+ builder.SetOptionalForeignMessage(new ForeignMessage.Builder());
+ Assert.IsFalse(ReferenceEquals(TestAllTypes.DefaultInstance, builder.Build()));
+ }
+
+ [Test]
+ public void CloneOnClearMessage()
+ {
+ TestAllTypes.Builder builder = TestAllTypes.DefaultInstance.ToBuilder();
+ Assert.IsTrue(ReferenceEquals(TestAllTypes.DefaultInstance, builder.Build()));
+ builder.ClearOptionalForeignMessage();
+ Assert.IsFalse(ReferenceEquals(TestAllTypes.DefaultInstance, builder.Build()));
+ }
+
+ [Test]
+ public void CloneOnAddRepeatedForeignMessage()
+ {
+ TestAllTypes.Builder builder = TestAllTypes.DefaultInstance.ToBuilder();
+ Assert.IsTrue(ReferenceEquals(TestAllTypes.DefaultInstance, builder.Build()));
+ builder.AddRepeatedForeignMessage(ForeignMessage.DefaultInstance);
+ Assert.IsFalse(ReferenceEquals(TestAllTypes.DefaultInstance, builder.Build()));
+ }
+
+ [Test]
+ public void CloneOnChangeEnumValue()
+ {
+ TestAllTypes.Builder builder = TestAllTypes.DefaultInstance.ToBuilder();
+ Assert.IsTrue(ReferenceEquals(TestAllTypes.DefaultInstance, builder.Build()));
+ builder.SetOptionalForeignEnum(ForeignEnum.FOREIGN_BAR);
+ Assert.IsFalse(ReferenceEquals(TestAllTypes.DefaultInstance, builder.Build()));
+ }
+
+ [Test]
+ public void CloneOnAddRepeatedForeignEnum()
+ {
+ TestAllTypes.Builder builder = TestAllTypes.DefaultInstance.ToBuilder();
+ Assert.IsTrue(ReferenceEquals(TestAllTypes.DefaultInstance, builder.Build()));
+ builder.AddRepeatedForeignEnum(ForeignEnum.FOREIGN_BAR);
+ Assert.IsFalse(ReferenceEquals(TestAllTypes.DefaultInstance, builder.Build()));
+ }
+
+ }
+}
diff --git a/src/ProtocolBuffers.Test/TestProtos/UnitTestCSharpOptionsProtoFile.cs b/src/ProtocolBuffers.Test/TestProtos/UnitTestCSharpOptionsProtoFile.cs index ff726d65..215b9b4f 100644 --- a/src/ProtocolBuffers.Test/TestProtos/UnitTestCSharpOptionsProtoFile.cs +++ b/src/ProtocolBuffers.Test/TestProtos/UnitTestCSharpOptionsProtoFile.cs @@ -190,7 +190,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(OptionsMessage prototype) {
- return (Builder) new Builder().MergeFrom(prototype);
+ return new Builder(prototype);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -200,21 +200,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder {
get { return this; }
}
- public Builder() {}
+ public Builder() {
+ result = DefaultInstance ?? new OptionsMessage();
+ builderIsReadOnly = result == DefaultInstance;
+ }
+ internal Builder(OptionsMessage cloneFrom) {
+ result = cloneFrom;
+ builderIsReadOnly = true;
+ }
+
+ bool builderIsReadOnly;
+ OptionsMessage result;
- OptionsMessage result = new OptionsMessage();
+ private OptionsMessage PrepareBuilder() {
+ if (builderIsReadOnly) {
+ OptionsMessage original = result;
+ result = new OptionsMessage();
+ builderIsReadOnly = false;
+ MergeFrom(original);
+ }
+ return result;
+ }
+
+ public override bool IsInitialized {
+ get { return result.IsInitialized; }
+ }
protected override OptionsMessage MessageBeingBuilt {
- get { return result; }
+ get { return PrepareBuilder(); }
}
public override Builder Clear() {
- result = new OptionsMessage();
+ result = DefaultInstance ?? new OptionsMessage();
+ builderIsReadOnly = true;
return this;
}
public override Builder Clone() {
- return new Builder().MergeFrom(result);
+ if (builderIsReadOnly) {
+ return new Builder(result);
+ } else {
+ return new Builder().MergeFrom(result);
+ }
}
public override pbd::MessageDescriptor DescriptorForType {
@@ -226,12 +253,11 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override OptionsMessage BuildPartial() {
- if (result == null) {
- throw new global::System.InvalidOperationException("build() has already been called on this Builder");
+ if (builderIsReadOnly) {
+ return result;
}
- OptionsMessage returnMe = result;
- result = null;
- return returnMe;
+ builderIsReadOnly = true;
+ return result;
}
public override Builder MergeFrom(pb::IMessage other) {
@@ -245,6 +271,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder MergeFrom(OptionsMessage other) {
if (other == global::Google.ProtocolBuffers.TestProtos.OptionsMessage.DefaultInstance) return this;
+ PrepareBuilder();
if (other.HasNormal) {
Normal = other.Normal;
}
@@ -263,6 +290,7 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
+ PrepareBuilder();
pb::UnknownFieldSet.Builder unknownFields = null;
uint tag;
string field_name;
@@ -327,11 +355,13 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetNormal(string value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.hasNormal = true;
result.normal_ = value;
return this;
}
public Builder ClearNormal() {
+ PrepareBuilder();
result.hasNormal = false;
result.normal_ = "";
return this;
@@ -346,11 +376,13 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetOptionsMessage_(string value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.hasOptionsMessage_ = true;
result.optionsMessage_ = value;
return this;
}
public Builder ClearOptionsMessage_() {
+ PrepareBuilder();
result.hasOptionsMessage_ = false;
result.optionsMessage_ = "";
return this;
@@ -365,11 +397,13 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetCustomName(string value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.hasCustomName = true;
result.customized_ = value;
return this;
}
public Builder ClearCustomName() {
+ PrepareBuilder();
result.hasCustomName = false;
result.customized_ = "";
return this;
diff --git a/src/ProtocolBuffers.Test/TestProtos/UnitTestCustomOptionsProtoFile.cs b/src/ProtocolBuffers.Test/TestProtos/UnitTestCustomOptionsProtoFile.cs index 0b1be422..bc29da26 100644 --- a/src/ProtocolBuffers.Test/TestProtos/UnitTestCustomOptionsProtoFile.cs +++ b/src/ProtocolBuffers.Test/TestProtos/UnitTestCustomOptionsProtoFile.cs @@ -513,7 +513,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(TestMessageWithCustomOptions prototype) {
- return (Builder) new Builder().MergeFrom(prototype);
+ return new Builder(prototype);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -523,21 +523,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder {
get { return this; }
}
- public Builder() {}
+ public Builder() {
+ result = DefaultInstance ?? new TestMessageWithCustomOptions();
+ builderIsReadOnly = result == DefaultInstance;
+ }
+ internal Builder(TestMessageWithCustomOptions cloneFrom) {
+ result = cloneFrom;
+ builderIsReadOnly = true;
+ }
+
+ bool builderIsReadOnly;
+ TestMessageWithCustomOptions result;
+
+ private TestMessageWithCustomOptions PrepareBuilder() {
+ if (builderIsReadOnly) {
+ TestMessageWithCustomOptions original = result;
+ result = new TestMessageWithCustomOptions();
+ builderIsReadOnly = false;
+ MergeFrom(original);
+ }
+ return result;
+ }
- TestMessageWithCustomOptions result = new TestMessageWithCustomOptions();
+ public override bool IsInitialized {
+ get { return result.IsInitialized; }
+ }
protected override TestMessageWithCustomOptions MessageBeingBuilt {
- get { return result; }
+ get { return PrepareBuilder(); }
}
public override Builder Clear() {
- result = new TestMessageWithCustomOptions();
+ result = DefaultInstance ?? new TestMessageWithCustomOptions();
+ builderIsReadOnly = true;
return this;
}
public override Builder Clone() {
- return new Builder().MergeFrom(result);
+ if (builderIsReadOnly) {
+ return new Builder(result);
+ } else {
+ return new Builder().MergeFrom(result);
+ }
}
public override pbd::MessageDescriptor DescriptorForType {
@@ -549,12 +576,11 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override TestMessageWithCustomOptions BuildPartial() {
- if (result == null) {
- throw new global::System.InvalidOperationException("build() has already been called on this Builder");
+ if (builderIsReadOnly) {
+ return result;
}
- TestMessageWithCustomOptions returnMe = result;
- result = null;
- return returnMe;
+ builderIsReadOnly = true;
+ return result;
}
public override Builder MergeFrom(pb::IMessage other) {
@@ -568,6 +594,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder MergeFrom(TestMessageWithCustomOptions other) {
if (other == global::Google.ProtocolBuffers.TestProtos.TestMessageWithCustomOptions.DefaultInstance) return this;
+ PrepareBuilder();
if (other.HasField1) {
Field1 = other.Field1;
}
@@ -580,6 +607,7 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
+ PrepareBuilder();
pb::UnknownFieldSet.Builder unknownFields = null;
uint tag;
string field_name;
@@ -636,11 +664,13 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetField1(string value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.hasField1 = true;
result.field1_ = value;
return this;
}
public Builder ClearField1() {
+ PrepareBuilder();
result.hasField1 = false;
result.field1_ = "";
return this;
@@ -737,7 +767,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(CustomOptionFooRequest prototype) {
- return (Builder) new Builder().MergeFrom(prototype);
+ return new Builder(prototype);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -747,21 +777,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder {
get { return this; }
}
- public Builder() {}
+ public Builder() {
+ result = DefaultInstance ?? new CustomOptionFooRequest();
+ builderIsReadOnly = result == DefaultInstance;
+ }
+ internal Builder(CustomOptionFooRequest cloneFrom) {
+ result = cloneFrom;
+ builderIsReadOnly = true;
+ }
+
+ bool builderIsReadOnly;
+ CustomOptionFooRequest result;
+
+ private CustomOptionFooRequest PrepareBuilder() {
+ if (builderIsReadOnly) {
+ CustomOptionFooRequest original = result;
+ result = new CustomOptionFooRequest();
+ builderIsReadOnly = false;
+ MergeFrom(original);
+ }
+ return result;
+ }
- CustomOptionFooRequest result = new CustomOptionFooRequest();
+ public override bool IsInitialized {
+ get { return result.IsInitialized; }
+ }
protected override CustomOptionFooRequest MessageBeingBuilt {
- get { return result; }
+ get { return PrepareBuilder(); }
}
public override Builder Clear() {
- result = new CustomOptionFooRequest();
+ result = DefaultInstance ?? new CustomOptionFooRequest();
+ builderIsReadOnly = true;
return this;
}
public override Builder Clone() {
- return new Builder().MergeFrom(result);
+ if (builderIsReadOnly) {
+ return new Builder(result);
+ } else {
+ return new Builder().MergeFrom(result);
+ }
}
public override pbd::MessageDescriptor DescriptorForType {
@@ -773,12 +830,11 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override CustomOptionFooRequest BuildPartial() {
- if (result == null) {
- throw new global::System.InvalidOperationException("build() has already been called on this Builder");
+ if (builderIsReadOnly) {
+ return result;
}
- CustomOptionFooRequest returnMe = result;
- result = null;
- return returnMe;
+ builderIsReadOnly = true;
+ return result;
}
public override Builder MergeFrom(pb::IMessage other) {
@@ -792,6 +848,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder MergeFrom(CustomOptionFooRequest other) {
if (other == global::Google.ProtocolBuffers.TestProtos.CustomOptionFooRequest.DefaultInstance) return this;
+ PrepareBuilder();
this.MergeUnknownFields(other.UnknownFields);
return this;
}
@@ -801,6 +858,7 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
+ PrepareBuilder();
pb::UnknownFieldSet.Builder unknownFields = null;
uint tag;
string field_name;
@@ -935,7 +993,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(CustomOptionFooResponse prototype) {
- return (Builder) new Builder().MergeFrom(prototype);
+ return new Builder(prototype);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -945,21 +1003,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder {
get { return this; }
}
- public Builder() {}
+ public Builder() {
+ result = DefaultInstance ?? new CustomOptionFooResponse();
+ builderIsReadOnly = result == DefaultInstance;
+ }
+ internal Builder(CustomOptionFooResponse cloneFrom) {
+ result = cloneFrom;
+ builderIsReadOnly = true;
+ }
- CustomOptionFooResponse result = new CustomOptionFooResponse();
+ bool builderIsReadOnly;
+ CustomOptionFooResponse result;
+
+ private CustomOptionFooResponse PrepareBuilder() {
+ if (builderIsReadOnly) {
+ CustomOptionFooResponse original = result;
+ result = new CustomOptionFooResponse();
+ builderIsReadOnly = false;
+ MergeFrom(original);
+ }
+ return result;
+ }
+
+ public override bool IsInitialized {
+ get { return result.IsInitialized; }
+ }
protected override CustomOptionFooResponse MessageBeingBuilt {
- get { return result; }
+ get { return PrepareBuilder(); }
}
public override Builder Clear() {
- result = new CustomOptionFooResponse();
+ result = DefaultInstance ?? new CustomOptionFooResponse();
+ builderIsReadOnly = true;
return this;
}
public override Builder Clone() {
- return new Builder().MergeFrom(result);
+ if (builderIsReadOnly) {
+ return new Builder(result);
+ } else {
+ return new Builder().MergeFrom(result);
+ }
}
public override pbd::MessageDescriptor DescriptorForType {
@@ -971,12 +1056,11 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override CustomOptionFooResponse BuildPartial() {
- if (result == null) {
- throw new global::System.InvalidOperationException("build() has already been called on this Builder");
+ if (builderIsReadOnly) {
+ return result;
}
- CustomOptionFooResponse returnMe = result;
- result = null;
- return returnMe;
+ builderIsReadOnly = true;
+ return result;
}
public override Builder MergeFrom(pb::IMessage other) {
@@ -990,6 +1074,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder MergeFrom(CustomOptionFooResponse other) {
if (other == global::Google.ProtocolBuffers.TestProtos.CustomOptionFooResponse.DefaultInstance) return this;
+ PrepareBuilder();
this.MergeUnknownFields(other.UnknownFields);
return this;
}
@@ -999,6 +1084,7 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
+ PrepareBuilder();
pb::UnknownFieldSet.Builder unknownFields = null;
uint tag;
string field_name;
@@ -1148,7 +1234,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(DummyMessageContainingEnum prototype) {
- return (Builder) new Builder().MergeFrom(prototype);
+ return new Builder(prototype);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -1158,21 +1244,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder {
get { return this; }
}
- public Builder() {}
+ public Builder() {
+ result = DefaultInstance ?? new DummyMessageContainingEnum();
+ builderIsReadOnly = result == DefaultInstance;
+ }
+ internal Builder(DummyMessageContainingEnum cloneFrom) {
+ result = cloneFrom;
+ builderIsReadOnly = true;
+ }
- DummyMessageContainingEnum result = new DummyMessageContainingEnum();
+ bool builderIsReadOnly;
+ DummyMessageContainingEnum result;
+
+ private DummyMessageContainingEnum PrepareBuilder() {
+ if (builderIsReadOnly) {
+ DummyMessageContainingEnum original = result;
+ result = new DummyMessageContainingEnum();
+ builderIsReadOnly = false;
+ MergeFrom(original);
+ }
+ return result;
+ }
+
+ public override bool IsInitialized {
+ get { return result.IsInitialized; }
+ }
protected override DummyMessageContainingEnum MessageBeingBuilt {
- get { return result; }
+ get { return PrepareBuilder(); }
}
public override Builder Clear() {
- result = new DummyMessageContainingEnum();
+ result = DefaultInstance ?? new DummyMessageContainingEnum();
+ builderIsReadOnly = true;
return this;
}
public override Builder Clone() {
- return new Builder().MergeFrom(result);
+ if (builderIsReadOnly) {
+ return new Builder(result);
+ } else {
+ return new Builder().MergeFrom(result);
+ }
}
public override pbd::MessageDescriptor DescriptorForType {
@@ -1184,12 +1297,11 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override DummyMessageContainingEnum BuildPartial() {
- if (result == null) {
- throw new global::System.InvalidOperationException("build() has already been called on this Builder");
+ if (builderIsReadOnly) {
+ return result;
}
- DummyMessageContainingEnum returnMe = result;
- result = null;
- return returnMe;
+ builderIsReadOnly = true;
+ return result;
}
public override Builder MergeFrom(pb::IMessage other) {
@@ -1203,6 +1315,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder MergeFrom(DummyMessageContainingEnum other) {
if (other == global::Google.ProtocolBuffers.TestProtos.DummyMessageContainingEnum.DefaultInstance) return this;
+ PrepareBuilder();
this.MergeUnknownFields(other.UnknownFields);
return this;
}
@@ -1212,6 +1325,7 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
+ PrepareBuilder();
pb::UnknownFieldSet.Builder unknownFields = null;
uint tag;
string field_name;
@@ -1346,7 +1460,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(DummyMessageInvalidAsOptionType prototype) {
- return (Builder) new Builder().MergeFrom(prototype);
+ return new Builder(prototype);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -1356,21 +1470,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder {
get { return this; }
}
- public Builder() {}
+ public Builder() {
+ result = DefaultInstance ?? new DummyMessageInvalidAsOptionType();
+ builderIsReadOnly = result == DefaultInstance;
+ }
+ internal Builder(DummyMessageInvalidAsOptionType cloneFrom) {
+ result = cloneFrom;
+ builderIsReadOnly = true;
+ }
- DummyMessageInvalidAsOptionType result = new DummyMessageInvalidAsOptionType();
+ bool builderIsReadOnly;
+ DummyMessageInvalidAsOptionType result;
+
+ private DummyMessageInvalidAsOptionType PrepareBuilder() {
+ if (builderIsReadOnly) {
+ DummyMessageInvalidAsOptionType original = result;
+ result = new DummyMessageInvalidAsOptionType();
+ builderIsReadOnly = false;
+ MergeFrom(original);
+ }
+ return result;
+ }
+
+ public override bool IsInitialized {
+ get { return result.IsInitialized; }
+ }
protected override DummyMessageInvalidAsOptionType MessageBeingBuilt {
- get { return result; }
+ get { return PrepareBuilder(); }
}
public override Builder Clear() {
- result = new DummyMessageInvalidAsOptionType();
+ result = DefaultInstance ?? new DummyMessageInvalidAsOptionType();
+ builderIsReadOnly = true;
return this;
}
public override Builder Clone() {
- return new Builder().MergeFrom(result);
+ if (builderIsReadOnly) {
+ return new Builder(result);
+ } else {
+ return new Builder().MergeFrom(result);
+ }
}
public override pbd::MessageDescriptor DescriptorForType {
@@ -1382,12 +1523,11 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override DummyMessageInvalidAsOptionType BuildPartial() {
- if (result == null) {
- throw new global::System.InvalidOperationException("build() has already been called on this Builder");
+ if (builderIsReadOnly) {
+ return result;
}
- DummyMessageInvalidAsOptionType returnMe = result;
- result = null;
- return returnMe;
+ builderIsReadOnly = true;
+ return result;
}
public override Builder MergeFrom(pb::IMessage other) {
@@ -1401,6 +1541,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder MergeFrom(DummyMessageInvalidAsOptionType other) {
if (other == global::Google.ProtocolBuffers.TestProtos.DummyMessageInvalidAsOptionType.DefaultInstance) return this;
+ PrepareBuilder();
this.MergeUnknownFields(other.UnknownFields);
return this;
}
@@ -1410,6 +1551,7 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
+ PrepareBuilder();
pb::UnknownFieldSet.Builder unknownFields = null;
uint tag;
string field_name;
@@ -1544,7 +1686,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(CustomOptionMinIntegerValues prototype) {
- return (Builder) new Builder().MergeFrom(prototype);
+ return new Builder(prototype);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -1554,21 +1696,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder {
get { return this; }
}
- public Builder() {}
+ public Builder() {
+ result = DefaultInstance ?? new CustomOptionMinIntegerValues();
+ builderIsReadOnly = result == DefaultInstance;
+ }
+ internal Builder(CustomOptionMinIntegerValues cloneFrom) {
+ result = cloneFrom;
+ builderIsReadOnly = true;
+ }
- CustomOptionMinIntegerValues result = new CustomOptionMinIntegerValues();
+ bool builderIsReadOnly;
+ CustomOptionMinIntegerValues result;
+
+ private CustomOptionMinIntegerValues PrepareBuilder() {
+ if (builderIsReadOnly) {
+ CustomOptionMinIntegerValues original = result;
+ result = new CustomOptionMinIntegerValues();
+ builderIsReadOnly = false;
+ MergeFrom(original);
+ }
+ return result;
+ }
+
+ public override bool IsInitialized {
+ get { return result.IsInitialized; }
+ }
protected override CustomOptionMinIntegerValues MessageBeingBuilt {
- get { return result; }
+ get { return PrepareBuilder(); }
}
public override Builder Clear() {
- result = new CustomOptionMinIntegerValues();
+ result = DefaultInstance ?? new CustomOptionMinIntegerValues();
+ builderIsReadOnly = true;
return this;
}
public override Builder Clone() {
- return new Builder().MergeFrom(result);
+ if (builderIsReadOnly) {
+ return new Builder(result);
+ } else {
+ return new Builder().MergeFrom(result);
+ }
}
public override pbd::MessageDescriptor DescriptorForType {
@@ -1580,12 +1749,11 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override CustomOptionMinIntegerValues BuildPartial() {
- if (result == null) {
- throw new global::System.InvalidOperationException("build() has already been called on this Builder");
+ if (builderIsReadOnly) {
+ return result;
}
- CustomOptionMinIntegerValues returnMe = result;
- result = null;
- return returnMe;
+ builderIsReadOnly = true;
+ return result;
}
public override Builder MergeFrom(pb::IMessage other) {
@@ -1599,6 +1767,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder MergeFrom(CustomOptionMinIntegerValues other) {
if (other == global::Google.ProtocolBuffers.TestProtos.CustomOptionMinIntegerValues.DefaultInstance) return this;
+ PrepareBuilder();
this.MergeUnknownFields(other.UnknownFields);
return this;
}
@@ -1608,6 +1777,7 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
+ PrepareBuilder();
pb::UnknownFieldSet.Builder unknownFields = null;
uint tag;
string field_name;
@@ -1742,7 +1912,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(CustomOptionMaxIntegerValues prototype) {
- return (Builder) new Builder().MergeFrom(prototype);
+ return new Builder(prototype);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -1752,21 +1922,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder {
get { return this; }
}
- public Builder() {}
+ public Builder() {
+ result = DefaultInstance ?? new CustomOptionMaxIntegerValues();
+ builderIsReadOnly = result == DefaultInstance;
+ }
+ internal Builder(CustomOptionMaxIntegerValues cloneFrom) {
+ result = cloneFrom;
+ builderIsReadOnly = true;
+ }
+
+ bool builderIsReadOnly;
+ CustomOptionMaxIntegerValues result;
+
+ private CustomOptionMaxIntegerValues PrepareBuilder() {
+ if (builderIsReadOnly) {
+ CustomOptionMaxIntegerValues original = result;
+ result = new CustomOptionMaxIntegerValues();
+ builderIsReadOnly = false;
+ MergeFrom(original);
+ }
+ return result;
+ }
- CustomOptionMaxIntegerValues result = new CustomOptionMaxIntegerValues();
+ public override bool IsInitialized {
+ get { return result.IsInitialized; }
+ }
protected override CustomOptionMaxIntegerValues MessageBeingBuilt {
- get { return result; }
+ get { return PrepareBuilder(); }
}
public override Builder Clear() {
- result = new CustomOptionMaxIntegerValues();
+ result = DefaultInstance ?? new CustomOptionMaxIntegerValues();
+ builderIsReadOnly = true;
return this;
}
public override Builder Clone() {
- return new Builder().MergeFrom(result);
+ if (builderIsReadOnly) {
+ return new Builder(result);
+ } else {
+ return new Builder().MergeFrom(result);
+ }
}
public override pbd::MessageDescriptor DescriptorForType {
@@ -1778,12 +1975,11 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override CustomOptionMaxIntegerValues BuildPartial() {
- if (result == null) {
- throw new global::System.InvalidOperationException("build() has already been called on this Builder");
+ if (builderIsReadOnly) {
+ return result;
}
- CustomOptionMaxIntegerValues returnMe = result;
- result = null;
- return returnMe;
+ builderIsReadOnly = true;
+ return result;
}
public override Builder MergeFrom(pb::IMessage other) {
@@ -1797,6 +1993,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder MergeFrom(CustomOptionMaxIntegerValues other) {
if (other == global::Google.ProtocolBuffers.TestProtos.CustomOptionMaxIntegerValues.DefaultInstance) return this;
+ PrepareBuilder();
this.MergeUnknownFields(other.UnknownFields);
return this;
}
@@ -1806,6 +2003,7 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
+ PrepareBuilder();
pb::UnknownFieldSet.Builder unknownFields = null;
uint tag;
string field_name;
@@ -1940,7 +2138,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(CustomOptionOtherValues prototype) {
- return (Builder) new Builder().MergeFrom(prototype);
+ return new Builder(prototype);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -1950,21 +2148,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder {
get { return this; }
}
- public Builder() {}
+ public Builder() {
+ result = DefaultInstance ?? new CustomOptionOtherValues();
+ builderIsReadOnly = result == DefaultInstance;
+ }
+ internal Builder(CustomOptionOtherValues cloneFrom) {
+ result = cloneFrom;
+ builderIsReadOnly = true;
+ }
+
+ bool builderIsReadOnly;
+ CustomOptionOtherValues result;
- CustomOptionOtherValues result = new CustomOptionOtherValues();
+ private CustomOptionOtherValues PrepareBuilder() {
+ if (builderIsReadOnly) {
+ CustomOptionOtherValues original = result;
+ result = new CustomOptionOtherValues();
+ builderIsReadOnly = false;
+ MergeFrom(original);
+ }
+ return result;
+ }
+
+ public override bool IsInitialized {
+ get { return result.IsInitialized; }
+ }
protected override CustomOptionOtherValues MessageBeingBuilt {
- get { return result; }
+ get { return PrepareBuilder(); }
}
public override Builder Clear() {
- result = new CustomOptionOtherValues();
+ result = DefaultInstance ?? new CustomOptionOtherValues();
+ builderIsReadOnly = true;
return this;
}
public override Builder Clone() {
- return new Builder().MergeFrom(result);
+ if (builderIsReadOnly) {
+ return new Builder(result);
+ } else {
+ return new Builder().MergeFrom(result);
+ }
}
public override pbd::MessageDescriptor DescriptorForType {
@@ -1976,12 +2201,11 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override CustomOptionOtherValues BuildPartial() {
- if (result == null) {
- throw new global::System.InvalidOperationException("build() has already been called on this Builder");
+ if (builderIsReadOnly) {
+ return result;
}
- CustomOptionOtherValues returnMe = result;
- result = null;
- return returnMe;
+ builderIsReadOnly = true;
+ return result;
}
public override Builder MergeFrom(pb::IMessage other) {
@@ -1995,6 +2219,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder MergeFrom(CustomOptionOtherValues other) {
if (other == global::Google.ProtocolBuffers.TestProtos.CustomOptionOtherValues.DefaultInstance) return this;
+ PrepareBuilder();
this.MergeUnknownFields(other.UnknownFields);
return this;
}
@@ -2004,6 +2229,7 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
+ PrepareBuilder();
pb::UnknownFieldSet.Builder unknownFields = null;
uint tag;
string field_name;
@@ -2138,7 +2364,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(SettingRealsFromPositiveInts prototype) {
- return (Builder) new Builder().MergeFrom(prototype);
+ return new Builder(prototype);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -2148,21 +2374,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder {
get { return this; }
}
- public Builder() {}
+ public Builder() {
+ result = DefaultInstance ?? new SettingRealsFromPositiveInts();
+ builderIsReadOnly = result == DefaultInstance;
+ }
+ internal Builder(SettingRealsFromPositiveInts cloneFrom) {
+ result = cloneFrom;
+ builderIsReadOnly = true;
+ }
+
+ bool builderIsReadOnly;
+ SettingRealsFromPositiveInts result;
- SettingRealsFromPositiveInts result = new SettingRealsFromPositiveInts();
+ private SettingRealsFromPositiveInts PrepareBuilder() {
+ if (builderIsReadOnly) {
+ SettingRealsFromPositiveInts original = result;
+ result = new SettingRealsFromPositiveInts();
+ builderIsReadOnly = false;
+ MergeFrom(original);
+ }
+ return result;
+ }
+
+ public override bool IsInitialized {
+ get { return result.IsInitialized; }
+ }
protected override SettingRealsFromPositiveInts MessageBeingBuilt {
- get { return result; }
+ get { return PrepareBuilder(); }
}
public override Builder Clear() {
- result = new SettingRealsFromPositiveInts();
+ result = DefaultInstance ?? new SettingRealsFromPositiveInts();
+ builderIsReadOnly = true;
return this;
}
public override Builder Clone() {
- return new Builder().MergeFrom(result);
+ if (builderIsReadOnly) {
+ return new Builder(result);
+ } else {
+ return new Builder().MergeFrom(result);
+ }
}
public override pbd::MessageDescriptor DescriptorForType {
@@ -2174,12 +2427,11 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override SettingRealsFromPositiveInts BuildPartial() {
- if (result == null) {
- throw new global::System.InvalidOperationException("build() has already been called on this Builder");
+ if (builderIsReadOnly) {
+ return result;
}
- SettingRealsFromPositiveInts returnMe = result;
- result = null;
- return returnMe;
+ builderIsReadOnly = true;
+ return result;
}
public override Builder MergeFrom(pb::IMessage other) {
@@ -2193,6 +2445,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder MergeFrom(SettingRealsFromPositiveInts other) {
if (other == global::Google.ProtocolBuffers.TestProtos.SettingRealsFromPositiveInts.DefaultInstance) return this;
+ PrepareBuilder();
this.MergeUnknownFields(other.UnknownFields);
return this;
}
@@ -2202,6 +2455,7 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
+ PrepareBuilder();
pb::UnknownFieldSet.Builder unknownFields = null;
uint tag;
string field_name;
@@ -2336,7 +2590,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(SettingRealsFromNegativeInts prototype) {
- return (Builder) new Builder().MergeFrom(prototype);
+ return new Builder(prototype);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -2346,21 +2600,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder {
get { return this; }
}
- public Builder() {}
+ public Builder() {
+ result = DefaultInstance ?? new SettingRealsFromNegativeInts();
+ builderIsReadOnly = result == DefaultInstance;
+ }
+ internal Builder(SettingRealsFromNegativeInts cloneFrom) {
+ result = cloneFrom;
+ builderIsReadOnly = true;
+ }
- SettingRealsFromNegativeInts result = new SettingRealsFromNegativeInts();
+ bool builderIsReadOnly;
+ SettingRealsFromNegativeInts result;
+
+ private SettingRealsFromNegativeInts PrepareBuilder() {
+ if (builderIsReadOnly) {
+ SettingRealsFromNegativeInts original = result;
+ result = new SettingRealsFromNegativeInts();
+ builderIsReadOnly = false;
+ MergeFrom(original);
+ }
+ return result;
+ }
+
+ public override bool IsInitialized {
+ get { return result.IsInitialized; }
+ }
protected override SettingRealsFromNegativeInts MessageBeingBuilt {
- get { return result; }
+ get { return PrepareBuilder(); }
}
public override Builder Clear() {
- result = new SettingRealsFromNegativeInts();
+ result = DefaultInstance ?? new SettingRealsFromNegativeInts();
+ builderIsReadOnly = true;
return this;
}
public override Builder Clone() {
- return new Builder().MergeFrom(result);
+ if (builderIsReadOnly) {
+ return new Builder(result);
+ } else {
+ return new Builder().MergeFrom(result);
+ }
}
public override pbd::MessageDescriptor DescriptorForType {
@@ -2372,12 +2653,11 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override SettingRealsFromNegativeInts BuildPartial() {
- if (result == null) {
- throw new global::System.InvalidOperationException("build() has already been called on this Builder");
+ if (builderIsReadOnly) {
+ return result;
}
- SettingRealsFromNegativeInts returnMe = result;
- result = null;
- return returnMe;
+ builderIsReadOnly = true;
+ return result;
}
public override Builder MergeFrom(pb::IMessage other) {
@@ -2391,6 +2671,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder MergeFrom(SettingRealsFromNegativeInts other) {
if (other == global::Google.ProtocolBuffers.TestProtos.SettingRealsFromNegativeInts.DefaultInstance) return this;
+ PrepareBuilder();
this.MergeUnknownFields(other.UnknownFields);
return this;
}
@@ -2400,6 +2681,7 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
+ PrepareBuilder();
pb::UnknownFieldSet.Builder unknownFields = null;
uint tag;
string field_name;
@@ -2586,7 +2868,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(ComplexOptionType1 prototype) {
- return (Builder) new Builder().MergeFrom(prototype);
+ return new Builder(prototype);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -2596,21 +2878,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder {
get { return this; }
}
- public Builder() {}
+ public Builder() {
+ result = DefaultInstance ?? new ComplexOptionType1();
+ builderIsReadOnly = result == DefaultInstance;
+ }
+ internal Builder(ComplexOptionType1 cloneFrom) {
+ result = cloneFrom;
+ builderIsReadOnly = true;
+ }
+
+ bool builderIsReadOnly;
+ ComplexOptionType1 result;
+
+ private ComplexOptionType1 PrepareBuilder() {
+ if (builderIsReadOnly) {
+ ComplexOptionType1 original = result;
+ result = new ComplexOptionType1();
+ builderIsReadOnly = false;
+ MergeFrom(original);
+ }
+ return result;
+ }
- ComplexOptionType1 result = new ComplexOptionType1();
+ public override bool IsInitialized {
+ get { return result.IsInitialized; }
+ }
protected override ComplexOptionType1 MessageBeingBuilt {
- get { return result; }
+ get { return PrepareBuilder(); }
}
public override Builder Clear() {
- result = new ComplexOptionType1();
+ result = DefaultInstance ?? new ComplexOptionType1();
+ builderIsReadOnly = true;
return this;
}
public override Builder Clone() {
- return new Builder().MergeFrom(result);
+ if (builderIsReadOnly) {
+ return new Builder(result);
+ } else {
+ return new Builder().MergeFrom(result);
+ }
}
public override pbd::MessageDescriptor DescriptorForType {
@@ -2622,12 +2931,11 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override ComplexOptionType1 BuildPartial() {
- if (result == null) {
- throw new global::System.InvalidOperationException("build() has already been called on this Builder");
+ if (builderIsReadOnly) {
+ return result;
}
- ComplexOptionType1 returnMe = result;
- result = null;
- return returnMe;
+ builderIsReadOnly = true;
+ return result;
}
public override Builder MergeFrom(pb::IMessage other) {
@@ -2641,6 +2949,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder MergeFrom(ComplexOptionType1 other) {
if (other == global::Google.ProtocolBuffers.TestProtos.ComplexOptionType1.DefaultInstance) return this;
+ PrepareBuilder();
if (other.HasFoo) {
Foo = other.Foo;
}
@@ -2660,6 +2969,7 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
+ PrepareBuilder();
pb::UnknownFieldSet.Builder unknownFields = null;
uint tag;
string field_name;
@@ -2723,11 +3033,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetFoo(value); }
}
public Builder SetFoo(int value) {
+ PrepareBuilder();
result.hasFoo = true;
result.foo_ = value;
return this;
}
public Builder ClearFoo() {
+ PrepareBuilder();
result.hasFoo = false;
result.foo_ = 0;
return this;
@@ -2741,11 +3053,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetFoo2(value); }
}
public Builder SetFoo2(int value) {
+ PrepareBuilder();
result.hasFoo2 = true;
result.foo2_ = value;
return this;
}
public Builder ClearFoo2() {
+ PrepareBuilder();
result.hasFoo2 = false;
result.foo2_ = 0;
return this;
@@ -2759,11 +3073,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetFoo3(value); }
}
public Builder SetFoo3(int value) {
+ PrepareBuilder();
result.hasFoo3 = true;
result.foo3_ = value;
return this;
}
public Builder ClearFoo3() {
+ PrepareBuilder();
result.hasFoo3 = false;
result.foo3_ = 0;
return this;
@@ -2910,7 +3226,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(ComplexOptionType4 prototype) {
- return (Builder) new Builder().MergeFrom(prototype);
+ return new Builder(prototype);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -2920,21 +3236,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder {
get { return this; }
}
- public Builder() {}
+ public Builder() {
+ result = DefaultInstance ?? new ComplexOptionType4();
+ builderIsReadOnly = result == DefaultInstance;
+ }
+ internal Builder(ComplexOptionType4 cloneFrom) {
+ result = cloneFrom;
+ builderIsReadOnly = true;
+ }
- ComplexOptionType4 result = new ComplexOptionType4();
+ bool builderIsReadOnly;
+ ComplexOptionType4 result;
+
+ private ComplexOptionType4 PrepareBuilder() {
+ if (builderIsReadOnly) {
+ ComplexOptionType4 original = result;
+ result = new ComplexOptionType4();
+ builderIsReadOnly = false;
+ MergeFrom(original);
+ }
+ return result;
+ }
+
+ public override bool IsInitialized {
+ get { return result.IsInitialized; }
+ }
protected override ComplexOptionType4 MessageBeingBuilt {
- get { return result; }
+ get { return PrepareBuilder(); }
}
public override Builder Clear() {
- result = new ComplexOptionType4();
+ result = DefaultInstance ?? new ComplexOptionType4();
+ builderIsReadOnly = true;
return this;
}
public override Builder Clone() {
- return new Builder().MergeFrom(result);
+ if (builderIsReadOnly) {
+ return new Builder(result);
+ } else {
+ return new Builder().MergeFrom(result);
+ }
}
public override pbd::MessageDescriptor DescriptorForType {
@@ -2946,12 +3289,11 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override ComplexOptionType4 BuildPartial() {
- if (result == null) {
- throw new global::System.InvalidOperationException("build() has already been called on this Builder");
+ if (builderIsReadOnly) {
+ return result;
}
- ComplexOptionType4 returnMe = result;
- result = null;
- return returnMe;
+ builderIsReadOnly = true;
+ return result;
}
public override Builder MergeFrom(pb::IMessage other) {
@@ -2965,6 +3307,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder MergeFrom(ComplexOptionType4 other) {
if (other == global::Google.ProtocolBuffers.TestProtos.ComplexOptionType2.Types.ComplexOptionType4.DefaultInstance) return this;
+ PrepareBuilder();
if (other.HasWaldo) {
Waldo = other.Waldo;
}
@@ -2977,6 +3320,7 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
+ PrepareBuilder();
pb::UnknownFieldSet.Builder unknownFields = null;
uint tag;
string field_name;
@@ -3032,11 +3376,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetWaldo(value); }
}
public Builder SetWaldo(int value) {
+ PrepareBuilder();
result.hasWaldo = true;
result.waldo_ = value;
return this;
}
public Builder ClearWaldo() {
+ PrepareBuilder();
result.hasWaldo = false;
result.waldo_ = 0;
return this;
@@ -3164,7 +3510,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(ComplexOptionType2 prototype) {
- return (Builder) new Builder().MergeFrom(prototype);
+ return new Builder(prototype);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -3174,21 +3520,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder {
get { return this; }
}
- public Builder() {}
+ public Builder() {
+ result = DefaultInstance ?? new ComplexOptionType2();
+ builderIsReadOnly = result == DefaultInstance;
+ }
+ internal Builder(ComplexOptionType2 cloneFrom) {
+ result = cloneFrom;
+ builderIsReadOnly = true;
+ }
+
+ bool builderIsReadOnly;
+ ComplexOptionType2 result;
- ComplexOptionType2 result = new ComplexOptionType2();
+ private ComplexOptionType2 PrepareBuilder() {
+ if (builderIsReadOnly) {
+ ComplexOptionType2 original = result;
+ result = new ComplexOptionType2();
+ builderIsReadOnly = false;
+ MergeFrom(original);
+ }
+ return result;
+ }
+
+ public override bool IsInitialized {
+ get { return result.IsInitialized; }
+ }
protected override ComplexOptionType2 MessageBeingBuilt {
- get { return result; }
+ get { return PrepareBuilder(); }
}
public override Builder Clear() {
- result = new ComplexOptionType2();
+ result = DefaultInstance ?? new ComplexOptionType2();
+ builderIsReadOnly = true;
return this;
}
public override Builder Clone() {
- return new Builder().MergeFrom(result);
+ if (builderIsReadOnly) {
+ return new Builder(result);
+ } else {
+ return new Builder().MergeFrom(result);
+ }
}
public override pbd::MessageDescriptor DescriptorForType {
@@ -3200,12 +3573,11 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override ComplexOptionType2 BuildPartial() {
- if (result == null) {
- throw new global::System.InvalidOperationException("build() has already been called on this Builder");
+ if (builderIsReadOnly) {
+ return result;
}
- ComplexOptionType2 returnMe = result;
- result = null;
- return returnMe;
+ builderIsReadOnly = true;
+ return result;
}
public override Builder MergeFrom(pb::IMessage other) {
@@ -3219,6 +3591,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder MergeFrom(ComplexOptionType2 other) {
if (other == global::Google.ProtocolBuffers.TestProtos.ComplexOptionType2.DefaultInstance) return this;
+ PrepareBuilder();
if (other.HasBar) {
MergeBar(other.Bar);
}
@@ -3238,6 +3611,7 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
+ PrepareBuilder();
pb::UnknownFieldSet.Builder unknownFields = null;
uint tag;
string field_name;
@@ -3312,18 +3686,21 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetBar(global::Google.ProtocolBuffers.TestProtos.ComplexOptionType1 value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.hasBar = true;
result.bar_ = value;
return this;
}
public Builder SetBar(global::Google.ProtocolBuffers.TestProtos.ComplexOptionType1.Builder builderForValue) {
pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue");
+ PrepareBuilder();
result.hasBar = true;
result.bar_ = builderForValue.Build();
return this;
}
public Builder MergeBar(global::Google.ProtocolBuffers.TestProtos.ComplexOptionType1 value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
if (result.hasBar &&
result.bar_ != global::Google.ProtocolBuffers.TestProtos.ComplexOptionType1.DefaultInstance) {
result.bar_ = global::Google.ProtocolBuffers.TestProtos.ComplexOptionType1.CreateBuilder(result.bar_).MergeFrom(value).BuildPartial();
@@ -3334,6 +3711,7 @@ namespace Google.ProtocolBuffers.TestProtos { return this;
}
public Builder ClearBar() {
+ PrepareBuilder();
result.hasBar = false;
result.bar_ = global::Google.ProtocolBuffers.TestProtos.ComplexOptionType1.DefaultInstance;
return this;
@@ -3347,11 +3725,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetBaz(value); }
}
public Builder SetBaz(int value) {
+ PrepareBuilder();
result.hasBaz = true;
result.baz_ = value;
return this;
}
public Builder ClearBaz() {
+ PrepareBuilder();
result.hasBaz = false;
result.baz_ = 0;
return this;
@@ -3366,18 +3746,21 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetFred(global::Google.ProtocolBuffers.TestProtos.ComplexOptionType2.Types.ComplexOptionType4 value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.hasFred = true;
result.fred_ = value;
return this;
}
public Builder SetFred(global::Google.ProtocolBuffers.TestProtos.ComplexOptionType2.Types.ComplexOptionType4.Builder builderForValue) {
pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue");
+ PrepareBuilder();
result.hasFred = true;
result.fred_ = builderForValue.Build();
return this;
}
public Builder MergeFred(global::Google.ProtocolBuffers.TestProtos.ComplexOptionType2.Types.ComplexOptionType4 value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
if (result.hasFred &&
result.fred_ != global::Google.ProtocolBuffers.TestProtos.ComplexOptionType2.Types.ComplexOptionType4.DefaultInstance) {
result.fred_ = global::Google.ProtocolBuffers.TestProtos.ComplexOptionType2.Types.ComplexOptionType4.CreateBuilder(result.fred_).MergeFrom(value).BuildPartial();
@@ -3388,6 +3771,7 @@ namespace Google.ProtocolBuffers.TestProtos { return this;
}
public Builder ClearFred() {
+ PrepareBuilder();
result.hasFred = false;
result.fred_ = global::Google.ProtocolBuffers.TestProtos.ComplexOptionType2.Types.ComplexOptionType4.DefaultInstance;
return this;
@@ -3532,7 +3916,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(ComplexOptionType5 prototype) {
- return (Builder) new Builder().MergeFrom(prototype);
+ return new Builder(prototype);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -3542,21 +3926,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder {
get { return this; }
}
- public Builder() {}
+ public Builder() {
+ result = DefaultInstance ?? new ComplexOptionType5();
+ builderIsReadOnly = result == DefaultInstance;
+ }
+ internal Builder(ComplexOptionType5 cloneFrom) {
+ result = cloneFrom;
+ builderIsReadOnly = true;
+ }
+
+ bool builderIsReadOnly;
+ ComplexOptionType5 result;
+
+ private ComplexOptionType5 PrepareBuilder() {
+ if (builderIsReadOnly) {
+ ComplexOptionType5 original = result;
+ result = new ComplexOptionType5();
+ builderIsReadOnly = false;
+ MergeFrom(original);
+ }
+ return result;
+ }
- ComplexOptionType5 result = new ComplexOptionType5();
+ public override bool IsInitialized {
+ get { return result.IsInitialized; }
+ }
protected override ComplexOptionType5 MessageBeingBuilt {
- get { return result; }
+ get { return PrepareBuilder(); }
}
public override Builder Clear() {
- result = new ComplexOptionType5();
+ result = DefaultInstance ?? new ComplexOptionType5();
+ builderIsReadOnly = true;
return this;
}
public override Builder Clone() {
- return new Builder().MergeFrom(result);
+ if (builderIsReadOnly) {
+ return new Builder(result);
+ } else {
+ return new Builder().MergeFrom(result);
+ }
}
public override pbd::MessageDescriptor DescriptorForType {
@@ -3568,12 +3979,11 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override ComplexOptionType5 BuildPartial() {
- if (result == null) {
- throw new global::System.InvalidOperationException("build() has already been called on this Builder");
+ if (builderIsReadOnly) {
+ return result;
}
- ComplexOptionType5 returnMe = result;
- result = null;
- return returnMe;
+ builderIsReadOnly = true;
+ return result;
}
public override Builder MergeFrom(pb::IMessage other) {
@@ -3587,6 +3997,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder MergeFrom(ComplexOptionType5 other) {
if (other == global::Google.ProtocolBuffers.TestProtos.ComplexOptionType3.Types.ComplexOptionType5.DefaultInstance) return this;
+ PrepareBuilder();
if (other.HasPlugh) {
Plugh = other.Plugh;
}
@@ -3599,6 +4010,7 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
+ PrepareBuilder();
pb::UnknownFieldSet.Builder unknownFields = null;
uint tag;
string field_name;
@@ -3654,11 +4066,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetPlugh(value); }
}
public Builder SetPlugh(int value) {
+ PrepareBuilder();
result.hasPlugh = true;
result.plugh_ = value;
return this;
}
public Builder ClearPlugh() {
+ PrepareBuilder();
result.hasPlugh = false;
result.plugh_ = 0;
return this;
@@ -3763,7 +4177,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(ComplexOptionType3 prototype) {
- return (Builder) new Builder().MergeFrom(prototype);
+ return new Builder(prototype);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -3773,21 +4187,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder {
get { return this; }
}
- public Builder() {}
+ public Builder() {
+ result = DefaultInstance ?? new ComplexOptionType3();
+ builderIsReadOnly = result == DefaultInstance;
+ }
+ internal Builder(ComplexOptionType3 cloneFrom) {
+ result = cloneFrom;
+ builderIsReadOnly = true;
+ }
- ComplexOptionType3 result = new ComplexOptionType3();
+ bool builderIsReadOnly;
+ ComplexOptionType3 result;
+
+ private ComplexOptionType3 PrepareBuilder() {
+ if (builderIsReadOnly) {
+ ComplexOptionType3 original = result;
+ result = new ComplexOptionType3();
+ builderIsReadOnly = false;
+ MergeFrom(original);
+ }
+ return result;
+ }
+
+ public override bool IsInitialized {
+ get { return result.IsInitialized; }
+ }
protected override ComplexOptionType3 MessageBeingBuilt {
- get { return result; }
+ get { return PrepareBuilder(); }
}
public override Builder Clear() {
- result = new ComplexOptionType3();
+ result = DefaultInstance ?? new ComplexOptionType3();
+ builderIsReadOnly = true;
return this;
}
public override Builder Clone() {
- return new Builder().MergeFrom(result);
+ if (builderIsReadOnly) {
+ return new Builder(result);
+ } else {
+ return new Builder().MergeFrom(result);
+ }
}
public override pbd::MessageDescriptor DescriptorForType {
@@ -3799,12 +4240,11 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override ComplexOptionType3 BuildPartial() {
- if (result == null) {
- throw new global::System.InvalidOperationException("build() has already been called on this Builder");
+ if (builderIsReadOnly) {
+ return result;
}
- ComplexOptionType3 returnMe = result;
- result = null;
- return returnMe;
+ builderIsReadOnly = true;
+ return result;
}
public override Builder MergeFrom(pb::IMessage other) {
@@ -3818,6 +4258,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder MergeFrom(ComplexOptionType3 other) {
if (other == global::Google.ProtocolBuffers.TestProtos.ComplexOptionType3.DefaultInstance) return this;
+ PrepareBuilder();
if (other.HasQux) {
Qux = other.Qux;
}
@@ -3833,6 +4274,7 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
+ PrepareBuilder();
pb::UnknownFieldSet.Builder unknownFields = null;
uint tag;
string field_name;
@@ -3897,11 +4339,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetQux(value); }
}
public Builder SetQux(int value) {
+ PrepareBuilder();
result.hasQux = true;
result.qux_ = value;
return this;
}
public Builder ClearQux() {
+ PrepareBuilder();
result.hasQux = false;
result.qux_ = 0;
return this;
@@ -3916,18 +4360,21 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetComplexOptionType5(global::Google.ProtocolBuffers.TestProtos.ComplexOptionType3.Types.ComplexOptionType5 value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.hasComplexOptionType5 = true;
result.complexOptionType5_ = value;
return this;
}
public Builder SetComplexOptionType5(global::Google.ProtocolBuffers.TestProtos.ComplexOptionType3.Types.ComplexOptionType5.Builder builderForValue) {
pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue");
+ PrepareBuilder();
result.hasComplexOptionType5 = true;
result.complexOptionType5_ = builderForValue.Build();
return this;
}
public Builder MergeComplexOptionType5(global::Google.ProtocolBuffers.TestProtos.ComplexOptionType3.Types.ComplexOptionType5 value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
if (result.hasComplexOptionType5 &&
result.complexOptionType5_ != global::Google.ProtocolBuffers.TestProtos.ComplexOptionType3.Types.ComplexOptionType5.DefaultInstance) {
result.complexOptionType5_ = global::Google.ProtocolBuffers.TestProtos.ComplexOptionType3.Types.ComplexOptionType5.CreateBuilder(result.complexOptionType5_).MergeFrom(value).BuildPartial();
@@ -3938,6 +4385,7 @@ namespace Google.ProtocolBuffers.TestProtos { return this;
}
public Builder ClearComplexOptionType5() {
+ PrepareBuilder();
result.hasComplexOptionType5 = false;
result.complexOptionType5_ = global::Google.ProtocolBuffers.TestProtos.ComplexOptionType3.Types.ComplexOptionType5.DefaultInstance;
return this;
@@ -4050,7 +4498,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(ComplexOpt6 prototype) {
- return (Builder) new Builder().MergeFrom(prototype);
+ return new Builder(prototype);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -4060,21 +4508,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder {
get { return this; }
}
- public Builder() {}
+ public Builder() {
+ result = DefaultInstance ?? new ComplexOpt6();
+ builderIsReadOnly = result == DefaultInstance;
+ }
+ internal Builder(ComplexOpt6 cloneFrom) {
+ result = cloneFrom;
+ builderIsReadOnly = true;
+ }
+
+ bool builderIsReadOnly;
+ ComplexOpt6 result;
+
+ private ComplexOpt6 PrepareBuilder() {
+ if (builderIsReadOnly) {
+ ComplexOpt6 original = result;
+ result = new ComplexOpt6();
+ builderIsReadOnly = false;
+ MergeFrom(original);
+ }
+ return result;
+ }
- ComplexOpt6 result = new ComplexOpt6();
+ public override bool IsInitialized {
+ get { return result.IsInitialized; }
+ }
protected override ComplexOpt6 MessageBeingBuilt {
- get { return result; }
+ get { return PrepareBuilder(); }
}
public override Builder Clear() {
- result = new ComplexOpt6();
+ result = DefaultInstance ?? new ComplexOpt6();
+ builderIsReadOnly = true;
return this;
}
public override Builder Clone() {
- return new Builder().MergeFrom(result);
+ if (builderIsReadOnly) {
+ return new Builder(result);
+ } else {
+ return new Builder().MergeFrom(result);
+ }
}
public override pbd::MessageDescriptor DescriptorForType {
@@ -4086,12 +4561,11 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override ComplexOpt6 BuildPartial() {
- if (result == null) {
- throw new global::System.InvalidOperationException("build() has already been called on this Builder");
+ if (builderIsReadOnly) {
+ return result;
}
- ComplexOpt6 returnMe = result;
- result = null;
- return returnMe;
+ builderIsReadOnly = true;
+ return result;
}
public override Builder MergeFrom(pb::IMessage other) {
@@ -4105,6 +4579,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder MergeFrom(ComplexOpt6 other) {
if (other == global::Google.ProtocolBuffers.TestProtos.ComplexOpt6.DefaultInstance) return this;
+ PrepareBuilder();
if (other.HasXyzzy) {
Xyzzy = other.Xyzzy;
}
@@ -4117,6 +4592,7 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
+ PrepareBuilder();
pb::UnknownFieldSet.Builder unknownFields = null;
uint tag;
string field_name;
@@ -4172,11 +4648,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetXyzzy(value); }
}
public Builder SetXyzzy(int value) {
+ PrepareBuilder();
result.hasXyzzy = true;
result.xyzzy_ = value;
return this;
}
public Builder ClearXyzzy() {
+ PrepareBuilder();
result.hasXyzzy = false;
result.xyzzy_ = 0;
return this;
@@ -4273,7 +4751,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(VariousComplexOptions prototype) {
- return (Builder) new Builder().MergeFrom(prototype);
+ return new Builder(prototype);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -4283,21 +4761,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder {
get { return this; }
}
- public Builder() {}
+ public Builder() {
+ result = DefaultInstance ?? new VariousComplexOptions();
+ builderIsReadOnly = result == DefaultInstance;
+ }
+ internal Builder(VariousComplexOptions cloneFrom) {
+ result = cloneFrom;
+ builderIsReadOnly = true;
+ }
+
+ bool builderIsReadOnly;
+ VariousComplexOptions result;
- VariousComplexOptions result = new VariousComplexOptions();
+ private VariousComplexOptions PrepareBuilder() {
+ if (builderIsReadOnly) {
+ VariousComplexOptions original = result;
+ result = new VariousComplexOptions();
+ builderIsReadOnly = false;
+ MergeFrom(original);
+ }
+ return result;
+ }
+
+ public override bool IsInitialized {
+ get { return result.IsInitialized; }
+ }
protected override VariousComplexOptions MessageBeingBuilt {
- get { return result; }
+ get { return PrepareBuilder(); }
}
public override Builder Clear() {
- result = new VariousComplexOptions();
+ result = DefaultInstance ?? new VariousComplexOptions();
+ builderIsReadOnly = true;
return this;
}
public override Builder Clone() {
- return new Builder().MergeFrom(result);
+ if (builderIsReadOnly) {
+ return new Builder(result);
+ } else {
+ return new Builder().MergeFrom(result);
+ }
}
public override pbd::MessageDescriptor DescriptorForType {
@@ -4309,12 +4814,11 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override VariousComplexOptions BuildPartial() {
- if (result == null) {
- throw new global::System.InvalidOperationException("build() has already been called on this Builder");
+ if (builderIsReadOnly) {
+ return result;
}
- VariousComplexOptions returnMe = result;
- result = null;
- return returnMe;
+ builderIsReadOnly = true;
+ return result;
}
public override Builder MergeFrom(pb::IMessage other) {
@@ -4328,6 +4832,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder MergeFrom(VariousComplexOptions other) {
if (other == global::Google.ProtocolBuffers.TestProtos.VariousComplexOptions.DefaultInstance) return this;
+ PrepareBuilder();
this.MergeUnknownFields(other.UnknownFields);
return this;
}
@@ -4337,6 +4842,7 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
+ PrepareBuilder();
pb::UnknownFieldSet.Builder unknownFields = null;
uint tag;
string field_name;
diff --git a/src/ProtocolBuffers.Test/TestProtos/UnitTestEmbedOptimizeForProtoFile.cs b/src/ProtocolBuffers.Test/TestProtos/UnitTestEmbedOptimizeForProtoFile.cs index 09ecdd63..466cce73 100644 --- a/src/ProtocolBuffers.Test/TestProtos/UnitTestEmbedOptimizeForProtoFile.cs +++ b/src/ProtocolBuffers.Test/TestProtos/UnitTestEmbedOptimizeForProtoFile.cs @@ -186,7 +186,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(TestEmbedOptimizedForSize prototype) {
- return (Builder) new Builder().MergeFrom(prototype);
+ return new Builder(prototype);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -196,21 +196,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder {
get { return this; }
}
- public Builder() {}
+ public Builder() {
+ result = DefaultInstance ?? new TestEmbedOptimizedForSize();
+ builderIsReadOnly = result == DefaultInstance;
+ }
+ internal Builder(TestEmbedOptimizedForSize cloneFrom) {
+ result = cloneFrom;
+ builderIsReadOnly = true;
+ }
+
+ bool builderIsReadOnly;
+ TestEmbedOptimizedForSize result;
- TestEmbedOptimizedForSize result = new TestEmbedOptimizedForSize();
+ private TestEmbedOptimizedForSize PrepareBuilder() {
+ if (builderIsReadOnly) {
+ TestEmbedOptimizedForSize original = result;
+ result = new TestEmbedOptimizedForSize();
+ builderIsReadOnly = false;
+ MergeFrom(original);
+ }
+ return result;
+ }
+
+ public override bool IsInitialized {
+ get { return result.IsInitialized; }
+ }
protected override TestEmbedOptimizedForSize MessageBeingBuilt {
- get { return result; }
+ get { return PrepareBuilder(); }
}
public override Builder Clear() {
- result = new TestEmbedOptimizedForSize();
+ result = DefaultInstance ?? new TestEmbedOptimizedForSize();
+ builderIsReadOnly = true;
return this;
}
public override Builder Clone() {
- return new Builder().MergeFrom(result);
+ if (builderIsReadOnly) {
+ return new Builder(result);
+ } else {
+ return new Builder().MergeFrom(result);
+ }
}
public override pbd::MessageDescriptor DescriptorForType {
@@ -222,13 +249,12 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override TestEmbedOptimizedForSize BuildPartial() {
- if (result == null) {
- throw new global::System.InvalidOperationException("build() has already been called on this Builder");
+ if (builderIsReadOnly) {
+ return result;
}
result.repeatedMessage_.MakeReadOnly();
- TestEmbedOptimizedForSize returnMe = result;
- result = null;
- return returnMe;
+ builderIsReadOnly = true;
+ return result;
}
public override Builder MergeFrom(pb::IMessage other) {
@@ -242,6 +268,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder MergeFrom(TestEmbedOptimizedForSize other) {
if (other == global::Google.ProtocolBuffers.TestProtos.TestEmbedOptimizedForSize.DefaultInstance) return this;
+ PrepareBuilder();
if (other.HasOptionalMessage) {
MergeOptionalMessage(other.OptionalMessage);
}
@@ -257,6 +284,7 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
+ PrepareBuilder();
pb::UnknownFieldSet.Builder unknownFields = null;
uint tag;
string field_name;
@@ -322,18 +350,21 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetOptionalMessage(global::Google.ProtocolBuffers.TestProtos.TestOptimizedForSize value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.hasOptionalMessage = true;
result.optionalMessage_ = value;
return this;
}
public Builder SetOptionalMessage(global::Google.ProtocolBuffers.TestProtos.TestOptimizedForSize.Builder builderForValue) {
pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue");
+ PrepareBuilder();
result.hasOptionalMessage = true;
result.optionalMessage_ = builderForValue.Build();
return this;
}
public Builder MergeOptionalMessage(global::Google.ProtocolBuffers.TestProtos.TestOptimizedForSize value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
if (result.hasOptionalMessage &&
result.optionalMessage_ != global::Google.ProtocolBuffers.TestProtos.TestOptimizedForSize.DefaultInstance) {
result.optionalMessage_ = global::Google.ProtocolBuffers.TestProtos.TestOptimizedForSize.CreateBuilder(result.optionalMessage_).MergeFrom(value).BuildPartial();
@@ -344,13 +375,14 @@ namespace Google.ProtocolBuffers.TestProtos { return this;
}
public Builder ClearOptionalMessage() {
+ PrepareBuilder();
result.hasOptionalMessage = false;
result.optionalMessage_ = global::Google.ProtocolBuffers.TestProtos.TestOptimizedForSize.DefaultInstance;
return this;
}
public pbc::IPopsicleList<global::Google.ProtocolBuffers.TestProtos.TestOptimizedForSize> RepeatedMessageList {
- get { return result.repeatedMessage_; }
+ get { return PrepareBuilder().repeatedMessage_; }
}
public int RepeatedMessageCount {
get { return result.RepeatedMessageCount; }
@@ -360,29 +392,35 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetRepeatedMessage(int index, global::Google.ProtocolBuffers.TestProtos.TestOptimizedForSize value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.repeatedMessage_[index] = value;
return this;
}
public Builder SetRepeatedMessage(int index, global::Google.ProtocolBuffers.TestProtos.TestOptimizedForSize.Builder builderForValue) {
pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue");
+ PrepareBuilder();
result.repeatedMessage_[index] = builderForValue.Build();
return this;
}
public Builder AddRepeatedMessage(global::Google.ProtocolBuffers.TestProtos.TestOptimizedForSize value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.repeatedMessage_.Add(value);
return this;
}
public Builder AddRepeatedMessage(global::Google.ProtocolBuffers.TestProtos.TestOptimizedForSize.Builder builderForValue) {
pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue");
+ PrepareBuilder();
result.repeatedMessage_.Add(builderForValue.Build());
return this;
}
public Builder AddRangeRepeatedMessage(scg::IEnumerable<global::Google.ProtocolBuffers.TestProtos.TestOptimizedForSize> values) {
+ PrepareBuilder();
base.AddRange(values, result.repeatedMessage_);
return this;
}
public Builder ClearRepeatedMessage() {
+ PrepareBuilder();
result.repeatedMessage_.Clear();
return this;
}
diff --git a/src/ProtocolBuffers.Test/TestProtos/UnitTestExtrasIssuesProtoFile.cs b/src/ProtocolBuffers.Test/TestProtos/UnitTestExtrasIssuesProtoFile.cs index db56e8b9..7791759a 100644 --- a/src/ProtocolBuffers.Test/TestProtos/UnitTestExtrasIssuesProtoFile.cs +++ b/src/ProtocolBuffers.Test/TestProtos/UnitTestExtrasIssuesProtoFile.cs @@ -175,7 +175,7 @@ namespace UnitTest.Issues.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(A prototype) {
- return (Builder) new Builder().MergeFrom(prototype);
+ return new Builder(prototype);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -185,21 +185,48 @@ namespace UnitTest.Issues.TestProtos { protected override Builder ThisBuilder {
get { return this; }
}
- public Builder() {}
+ public Builder() {
+ result = DefaultInstance ?? new A();
+ builderIsReadOnly = result == DefaultInstance;
+ }
+ internal Builder(A cloneFrom) {
+ result = cloneFrom;
+ builderIsReadOnly = true;
+ }
+
+ bool builderIsReadOnly;
+ A result;
- A result = new A();
+ private A PrepareBuilder() {
+ if (builderIsReadOnly) {
+ A original = result;
+ result = new A();
+ builderIsReadOnly = false;
+ MergeFrom(original);
+ }
+ return result;
+ }
+
+ public override bool IsInitialized {
+ get { return result.IsInitialized; }
+ }
protected override A MessageBeingBuilt {
- get { return result; }
+ get { return PrepareBuilder(); }
}
public override Builder Clear() {
- result = new A();
+ result = DefaultInstance ?? new A();
+ builderIsReadOnly = true;
return this;
}
public override Builder Clone() {
- return new Builder().MergeFrom(result);
+ if (builderIsReadOnly) {
+ return new Builder(result);
+ } else {
+ return new Builder().MergeFrom(result);
+ }
}
public override pbd::MessageDescriptor DescriptorForType {
@@ -211,12 +238,11 @@ namespace UnitTest.Issues.TestProtos { }
public override A BuildPartial() {
- if (result == null) {
- throw new global::System.InvalidOperationException("build() has already been called on this Builder");
+ if (builderIsReadOnly) {
+ return result;
}
- A returnMe = result;
- result = null;
- return returnMe;
+ builderIsReadOnly = true;
+ return result;
}
public override Builder MergeFrom(pb::IMessage other) {
@@ -230,6 +256,7 @@ namespace UnitTest.Issues.TestProtos { public override Builder MergeFrom(A other) {
if (other == global::UnitTest.Issues.TestProtos.A.DefaultInstance) return this;
+ PrepareBuilder();
if (other.HasA_) {
A_ = other.A_;
}
@@ -242,6 +269,7 @@ namespace UnitTest.Issues.TestProtos { }
public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
+ PrepareBuilder();
pb::UnknownFieldSet.Builder unknownFields = null;
uint tag;
string field_name;
@@ -297,11 +325,13 @@ namespace UnitTest.Issues.TestProtos { set { SetA_(value); }
}
public Builder SetA_(int value) {
+ PrepareBuilder();
result.hasA_ = true;
result.a_ = value;
return this;
}
public Builder ClearA_() {
+ PrepareBuilder();
result.hasA_ = false;
result.a_ = 0;
return this;
@@ -414,7 +444,7 @@ namespace UnitTest.Issues.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(B prototype) {
- return (Builder) new Builder().MergeFrom(prototype);
+ return new Builder(prototype);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -424,21 +454,48 @@ namespace UnitTest.Issues.TestProtos { protected override Builder ThisBuilder {
get { return this; }
}
- public Builder() {}
+ public Builder() {
+ result = DefaultInstance ?? new B();
+ builderIsReadOnly = result == DefaultInstance;
+ }
+ internal Builder(B cloneFrom) {
+ result = cloneFrom;
+ builderIsReadOnly = true;
+ }
+
+ bool builderIsReadOnly;
+ B result;
- B result = new B();
+ private B PrepareBuilder() {
+ if (builderIsReadOnly) {
+ B original = result;
+ result = new B();
+ builderIsReadOnly = false;
+ MergeFrom(original);
+ }
+ return result;
+ }
+
+ public override bool IsInitialized {
+ get { return result.IsInitialized; }
+ }
protected override B MessageBeingBuilt {
- get { return result; }
+ get { return PrepareBuilder(); }
}
public override Builder Clear() {
- result = new B();
+ result = DefaultInstance ?? new B();
+ builderIsReadOnly = true;
return this;
}
public override Builder Clone() {
- return new Builder().MergeFrom(result);
+ if (builderIsReadOnly) {
+ return new Builder(result);
+ } else {
+ return new Builder().MergeFrom(result);
+ }
}
public override pbd::MessageDescriptor DescriptorForType {
@@ -450,12 +507,11 @@ namespace UnitTest.Issues.TestProtos { }
public override B BuildPartial() {
- if (result == null) {
- throw new global::System.InvalidOperationException("build() has already been called on this Builder");
+ if (builderIsReadOnly) {
+ return result;
}
- B returnMe = result;
- result = null;
- return returnMe;
+ builderIsReadOnly = true;
+ return result;
}
public override Builder MergeFrom(pb::IMessage other) {
@@ -469,6 +525,7 @@ namespace UnitTest.Issues.TestProtos { public override Builder MergeFrom(B other) {
if (other == global::UnitTest.Issues.TestProtos.B.DefaultInstance) return this;
+ PrepareBuilder();
if (other.HasB_) {
B_ = other.B_;
}
@@ -481,6 +538,7 @@ namespace UnitTest.Issues.TestProtos { }
public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
+ PrepareBuilder();
pb::UnknownFieldSet.Builder unknownFields = null;
uint tag;
string field_name;
@@ -536,11 +594,13 @@ namespace UnitTest.Issues.TestProtos { set { SetB_(value); }
}
public Builder SetB_(int value) {
+ PrepareBuilder();
result.hasB_ = true;
result.b_ = value;
return this;
}
public Builder ClearB_() {
+ PrepareBuilder();
result.hasB_ = false;
result.b_ = 0;
return this;
@@ -653,7 +713,7 @@ namespace UnitTest.Issues.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(AB prototype) {
- return (Builder) new Builder().MergeFrom(prototype);
+ return new Builder(prototype);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -663,21 +723,48 @@ namespace UnitTest.Issues.TestProtos { protected override Builder ThisBuilder {
get { return this; }
}
- public Builder() {}
+ public Builder() {
+ result = DefaultInstance ?? new AB();
+ builderIsReadOnly = result == DefaultInstance;
+ }
+ internal Builder(AB cloneFrom) {
+ result = cloneFrom;
+ builderIsReadOnly = true;
+ }
+
+ bool builderIsReadOnly;
+ AB result;
- AB result = new AB();
+ private AB PrepareBuilder() {
+ if (builderIsReadOnly) {
+ AB original = result;
+ result = new AB();
+ builderIsReadOnly = false;
+ MergeFrom(original);
+ }
+ return result;
+ }
+
+ public override bool IsInitialized {
+ get { return result.IsInitialized; }
+ }
protected override AB MessageBeingBuilt {
- get { return result; }
+ get { return PrepareBuilder(); }
}
public override Builder Clear() {
- result = new AB();
+ result = DefaultInstance ?? new AB();
+ builderIsReadOnly = true;
return this;
}
public override Builder Clone() {
- return new Builder().MergeFrom(result);
+ if (builderIsReadOnly) {
+ return new Builder(result);
+ } else {
+ return new Builder().MergeFrom(result);
+ }
}
public override pbd::MessageDescriptor DescriptorForType {
@@ -689,12 +776,11 @@ namespace UnitTest.Issues.TestProtos { }
public override AB BuildPartial() {
- if (result == null) {
- throw new global::System.InvalidOperationException("build() has already been called on this Builder");
+ if (builderIsReadOnly) {
+ return result;
}
- AB returnMe = result;
- result = null;
- return returnMe;
+ builderIsReadOnly = true;
+ return result;
}
public override Builder MergeFrom(pb::IMessage other) {
@@ -708,6 +794,7 @@ namespace UnitTest.Issues.TestProtos { public override Builder MergeFrom(AB other) {
if (other == global::UnitTest.Issues.TestProtos.AB.DefaultInstance) return this;
+ PrepareBuilder();
if (other.HasAB_) {
AB_ = other.AB_;
}
@@ -720,6 +807,7 @@ namespace UnitTest.Issues.TestProtos { }
public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
+ PrepareBuilder();
pb::UnknownFieldSet.Builder unknownFields = null;
uint tag;
string field_name;
@@ -775,11 +863,13 @@ namespace UnitTest.Issues.TestProtos { set { SetAB_(value); }
}
public Builder SetAB_(int value) {
+ PrepareBuilder();
result.hasAB_ = true;
result.aB_ = value;
return this;
}
public Builder ClearAB_() {
+ PrepareBuilder();
result.hasAB_ = false;
result.aB_ = 0;
return this;
@@ -894,7 +984,7 @@ namespace UnitTest.Issues.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(NumberField prototype) {
- return (Builder) new Builder().MergeFrom(prototype);
+ return new Builder(prototype);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -904,21 +994,48 @@ namespace UnitTest.Issues.TestProtos { protected override Builder ThisBuilder {
get { return this; }
}
- public Builder() {}
+ public Builder() {
+ result = DefaultInstance ?? new NumberField();
+ builderIsReadOnly = result == DefaultInstance;
+ }
+ internal Builder(NumberField cloneFrom) {
+ result = cloneFrom;
+ builderIsReadOnly = true;
+ }
+
+ bool builderIsReadOnly;
+ NumberField result;
- NumberField result = new NumberField();
+ private NumberField PrepareBuilder() {
+ if (builderIsReadOnly) {
+ NumberField original = result;
+ result = new NumberField();
+ builderIsReadOnly = false;
+ MergeFrom(original);
+ }
+ return result;
+ }
+
+ public override bool IsInitialized {
+ get { return result.IsInitialized; }
+ }
protected override NumberField MessageBeingBuilt {
- get { return result; }
+ get { return PrepareBuilder(); }
}
public override Builder Clear() {
- result = new NumberField();
+ result = DefaultInstance ?? new NumberField();
+ builderIsReadOnly = true;
return this;
}
public override Builder Clone() {
- return new Builder().MergeFrom(result);
+ if (builderIsReadOnly) {
+ return new Builder(result);
+ } else {
+ return new Builder().MergeFrom(result);
+ }
}
public override pbd::MessageDescriptor DescriptorForType {
@@ -930,12 +1047,11 @@ namespace UnitTest.Issues.TestProtos { }
public override NumberField BuildPartial() {
- if (result == null) {
- throw new global::System.InvalidOperationException("build() has already been called on this Builder");
+ if (builderIsReadOnly) {
+ return result;
}
- NumberField returnMe = result;
- result = null;
- return returnMe;
+ builderIsReadOnly = true;
+ return result;
}
public override Builder MergeFrom(pb::IMessage other) {
@@ -949,6 +1065,7 @@ namespace UnitTest.Issues.TestProtos { public override Builder MergeFrom(NumberField other) {
if (other == global::UnitTest.Issues.TestProtos.NumberField.DefaultInstance) return this;
+ PrepareBuilder();
if (other.Has_01) {
_01 = other._01;
}
@@ -961,6 +1078,7 @@ namespace UnitTest.Issues.TestProtos { }
public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
+ PrepareBuilder();
pb::UnknownFieldSet.Builder unknownFields = null;
uint tag;
string field_name;
@@ -1018,11 +1136,13 @@ namespace UnitTest.Issues.TestProtos { }
[global::System.CLSCompliant(false)]
public Builder Set_01(int value) {
+ PrepareBuilder();
result.has_01 = true;
result._01_ = value;
return this;
}
public Builder Clear_01() {
+ PrepareBuilder();
result.has_01 = false;
result._01_ = 0;
return this;
diff --git a/src/ProtocolBuffers.Test/TestProtos/UnitTestGoogleSizeProtoFile.cs b/src/ProtocolBuffers.Test/TestProtos/UnitTestGoogleSizeProtoFile.cs index 77635f21..64046eeb 100644 --- a/src/ProtocolBuffers.Test/TestProtos/UnitTestGoogleSizeProtoFile.cs +++ b/src/ProtocolBuffers.Test/TestProtos/UnitTestGoogleSizeProtoFile.cs @@ -606,7 +606,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(SizeMessage1 prototype) {
- return (Builder) new Builder().MergeFrom(prototype);
+ return new Builder(prototype);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -616,21 +616,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder {
get { return this; }
}
- public Builder() {}
+ public Builder() {
+ result = DefaultInstance ?? new SizeMessage1();
+ builderIsReadOnly = result == DefaultInstance;
+ }
+ internal Builder(SizeMessage1 cloneFrom) {
+ result = cloneFrom;
+ builderIsReadOnly = true;
+ }
+
+ bool builderIsReadOnly;
+ SizeMessage1 result;
+
+ private SizeMessage1 PrepareBuilder() {
+ if (builderIsReadOnly) {
+ SizeMessage1 original = result;
+ result = new SizeMessage1();
+ builderIsReadOnly = false;
+ MergeFrom(original);
+ }
+ return result;
+ }
- SizeMessage1 result = new SizeMessage1();
+ public override bool IsInitialized {
+ get { return result.IsInitialized; }
+ }
protected override SizeMessage1 MessageBeingBuilt {
- get { return result; }
+ get { return PrepareBuilder(); }
}
public override Builder Clear() {
- result = new SizeMessage1();
+ result = DefaultInstance ?? new SizeMessage1();
+ builderIsReadOnly = true;
return this;
}
public override Builder Clone() {
- return new Builder().MergeFrom(result);
+ if (builderIsReadOnly) {
+ return new Builder(result);
+ } else {
+ return new Builder().MergeFrom(result);
+ }
}
public override pbd::MessageDescriptor DescriptorForType {
@@ -642,13 +669,12 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override SizeMessage1 BuildPartial() {
- if (result == null) {
- throw new global::System.InvalidOperationException("build() has already been called on this Builder");
+ if (builderIsReadOnly) {
+ return result;
}
result.field5_.MakeReadOnly();
- SizeMessage1 returnMe = result;
- result = null;
- return returnMe;
+ builderIsReadOnly = true;
+ return result;
}
@@ -661,11 +687,13 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetField1(string value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.hasField1 = true;
result.field1_ = value;
return this;
}
public Builder ClearField1() {
+ PrepareBuilder();
result.hasField1 = false;
result.field1_ = "";
return this;
@@ -680,11 +708,13 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetField9(string value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.hasField9 = true;
result.field9_ = value;
return this;
}
public Builder ClearField9() {
+ PrepareBuilder();
result.hasField9 = false;
result.field9_ = "";
return this;
@@ -699,11 +729,13 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetField18(string value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.hasField18 = true;
result.field18_ = value;
return this;
}
public Builder ClearField18() {
+ PrepareBuilder();
result.hasField18 = false;
result.field18_ = "";
return this;
@@ -717,11 +749,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField80(value); }
}
public Builder SetField80(bool value) {
+ PrepareBuilder();
result.hasField80 = true;
result.field80_ = value;
return this;
}
public Builder ClearField80() {
+ PrepareBuilder();
result.hasField80 = false;
result.field80_ = false;
return this;
@@ -735,11 +769,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField81(value); }
}
public Builder SetField81(bool value) {
+ PrepareBuilder();
result.hasField81 = true;
result.field81_ = value;
return this;
}
public Builder ClearField81() {
+ PrepareBuilder();
result.hasField81 = false;
result.field81_ = true;
return this;
@@ -753,11 +789,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField2(value); }
}
public Builder SetField2(int value) {
+ PrepareBuilder();
result.hasField2 = true;
result.field2_ = value;
return this;
}
public Builder ClearField2() {
+ PrepareBuilder();
result.hasField2 = false;
result.field2_ = 0;
return this;
@@ -771,11 +809,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField3(value); }
}
public Builder SetField3(int value) {
+ PrepareBuilder();
result.hasField3 = true;
result.field3_ = value;
return this;
}
public Builder ClearField3() {
+ PrepareBuilder();
result.hasField3 = false;
result.field3_ = 0;
return this;
@@ -789,11 +829,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField280(value); }
}
public Builder SetField280(int value) {
+ PrepareBuilder();
result.hasField280 = true;
result.field280_ = value;
return this;
}
public Builder ClearField280() {
+ PrepareBuilder();
result.hasField280 = false;
result.field280_ = 0;
return this;
@@ -807,11 +849,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField6(value); }
}
public Builder SetField6(int value) {
+ PrepareBuilder();
result.hasField6 = true;
result.field6_ = value;
return this;
}
public Builder ClearField6() {
+ PrepareBuilder();
result.hasField6 = false;
result.field6_ = 0;
return this;
@@ -825,11 +869,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField22(value); }
}
public Builder SetField22(long value) {
+ PrepareBuilder();
result.hasField22 = true;
result.field22_ = value;
return this;
}
public Builder ClearField22() {
+ PrepareBuilder();
result.hasField22 = false;
result.field22_ = 0L;
return this;
@@ -844,11 +890,13 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetField4(string value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.hasField4 = true;
result.field4_ = value;
return this;
}
public Builder ClearField4() {
+ PrepareBuilder();
result.hasField4 = false;
result.field4_ = "";
return this;
@@ -856,7 +904,7 @@ namespace Google.ProtocolBuffers.TestProtos { [global::System.CLSCompliant(false)]
public pbc::IPopsicleList<ulong> Field5List {
- get { return result.field5_; }
+ get { return PrepareBuilder().field5_; }
}
public int Field5Count {
get { return result.Field5Count; }
@@ -867,20 +915,24 @@ namespace Google.ProtocolBuffers.TestProtos { }
[global::System.CLSCompliant(false)]
public Builder SetField5(int index, ulong value) {
+ PrepareBuilder();
result.field5_[index] = value;
return this;
}
[global::System.CLSCompliant(false)]
public Builder AddField5(ulong value) {
+ PrepareBuilder();
result.field5_.Add(value);
return this;
}
[global::System.CLSCompliant(false)]
public Builder AddRangeField5(scg::IEnumerable<ulong> values) {
+ PrepareBuilder();
base.AddRange(values, result.field5_);
return this;
}
public Builder ClearField5() {
+ PrepareBuilder();
result.field5_.Clear();
return this;
}
@@ -893,11 +945,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField59(value); }
}
public Builder SetField59(bool value) {
+ PrepareBuilder();
result.hasField59 = true;
result.field59_ = value;
return this;
}
public Builder ClearField59() {
+ PrepareBuilder();
result.hasField59 = false;
result.field59_ = false;
return this;
@@ -912,11 +966,13 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetField7(string value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.hasField7 = true;
result.field7_ = value;
return this;
}
public Builder ClearField7() {
+ PrepareBuilder();
result.hasField7 = false;
result.field7_ = "";
return this;
@@ -930,11 +986,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField16(value); }
}
public Builder SetField16(int value) {
+ PrepareBuilder();
result.hasField16 = true;
result.field16_ = value;
return this;
}
public Builder ClearField16() {
+ PrepareBuilder();
result.hasField16 = false;
result.field16_ = 0;
return this;
@@ -948,11 +1006,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField130(value); }
}
public Builder SetField130(int value) {
+ PrepareBuilder();
result.hasField130 = true;
result.field130_ = value;
return this;
}
public Builder ClearField130() {
+ PrepareBuilder();
result.hasField130 = false;
result.field130_ = 0;
return this;
@@ -966,11 +1026,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField12(value); }
}
public Builder SetField12(bool value) {
+ PrepareBuilder();
result.hasField12 = true;
result.field12_ = value;
return this;
}
public Builder ClearField12() {
+ PrepareBuilder();
result.hasField12 = false;
result.field12_ = true;
return this;
@@ -984,11 +1046,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField17(value); }
}
public Builder SetField17(bool value) {
+ PrepareBuilder();
result.hasField17 = true;
result.field17_ = value;
return this;
}
public Builder ClearField17() {
+ PrepareBuilder();
result.hasField17 = false;
result.field17_ = true;
return this;
@@ -1002,11 +1066,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField13(value); }
}
public Builder SetField13(bool value) {
+ PrepareBuilder();
result.hasField13 = true;
result.field13_ = value;
return this;
}
public Builder ClearField13() {
+ PrepareBuilder();
result.hasField13 = false;
result.field13_ = true;
return this;
@@ -1020,11 +1086,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField14(value); }
}
public Builder SetField14(bool value) {
+ PrepareBuilder();
result.hasField14 = true;
result.field14_ = value;
return this;
}
public Builder ClearField14() {
+ PrepareBuilder();
result.hasField14 = false;
result.field14_ = true;
return this;
@@ -1038,11 +1106,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField104(value); }
}
public Builder SetField104(int value) {
+ PrepareBuilder();
result.hasField104 = true;
result.field104_ = value;
return this;
}
public Builder ClearField104() {
+ PrepareBuilder();
result.hasField104 = false;
result.field104_ = 0;
return this;
@@ -1056,11 +1126,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField100(value); }
}
public Builder SetField100(int value) {
+ PrepareBuilder();
result.hasField100 = true;
result.field100_ = value;
return this;
}
public Builder ClearField100() {
+ PrepareBuilder();
result.hasField100 = false;
result.field100_ = 0;
return this;
@@ -1074,11 +1146,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField101(value); }
}
public Builder SetField101(int value) {
+ PrepareBuilder();
result.hasField101 = true;
result.field101_ = value;
return this;
}
public Builder ClearField101() {
+ PrepareBuilder();
result.hasField101 = false;
result.field101_ = 0;
return this;
@@ -1093,11 +1167,13 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetField102(string value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.hasField102 = true;
result.field102_ = value;
return this;
}
public Builder ClearField102() {
+ PrepareBuilder();
result.hasField102 = false;
result.field102_ = "";
return this;
@@ -1112,11 +1188,13 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetField103(string value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.hasField103 = true;
result.field103_ = value;
return this;
}
public Builder ClearField103() {
+ PrepareBuilder();
result.hasField103 = false;
result.field103_ = "";
return this;
@@ -1130,11 +1208,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField29(value); }
}
public Builder SetField29(int value) {
+ PrepareBuilder();
result.hasField29 = true;
result.field29_ = value;
return this;
}
public Builder ClearField29() {
+ PrepareBuilder();
result.hasField29 = false;
result.field29_ = 0;
return this;
@@ -1148,11 +1228,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField30(value); }
}
public Builder SetField30(bool value) {
+ PrepareBuilder();
result.hasField30 = true;
result.field30_ = value;
return this;
}
public Builder ClearField30() {
+ PrepareBuilder();
result.hasField30 = false;
result.field30_ = false;
return this;
@@ -1166,11 +1248,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField60(value); }
}
public Builder SetField60(int value) {
+ PrepareBuilder();
result.hasField60 = true;
result.field60_ = value;
return this;
}
public Builder ClearField60() {
+ PrepareBuilder();
result.hasField60 = false;
result.field60_ = -1;
return this;
@@ -1184,11 +1268,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField271(value); }
}
public Builder SetField271(int value) {
+ PrepareBuilder();
result.hasField271 = true;
result.field271_ = value;
return this;
}
public Builder ClearField271() {
+ PrepareBuilder();
result.hasField271 = false;
result.field271_ = -1;
return this;
@@ -1202,11 +1288,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField272(value); }
}
public Builder SetField272(int value) {
+ PrepareBuilder();
result.hasField272 = true;
result.field272_ = value;
return this;
}
public Builder ClearField272() {
+ PrepareBuilder();
result.hasField272 = false;
result.field272_ = -1;
return this;
@@ -1220,11 +1308,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField150(value); }
}
public Builder SetField150(int value) {
+ PrepareBuilder();
result.hasField150 = true;
result.field150_ = value;
return this;
}
public Builder ClearField150() {
+ PrepareBuilder();
result.hasField150 = false;
result.field150_ = 0;
return this;
@@ -1238,11 +1328,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField23(value); }
}
public Builder SetField23(int value) {
+ PrepareBuilder();
result.hasField23 = true;
result.field23_ = value;
return this;
}
public Builder ClearField23() {
+ PrepareBuilder();
result.hasField23 = false;
result.field23_ = 0;
return this;
@@ -1256,11 +1348,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField24(value); }
}
public Builder SetField24(bool value) {
+ PrepareBuilder();
result.hasField24 = true;
result.field24_ = value;
return this;
}
public Builder ClearField24() {
+ PrepareBuilder();
result.hasField24 = false;
result.field24_ = false;
return this;
@@ -1274,11 +1368,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField25(value); }
}
public Builder SetField25(int value) {
+ PrepareBuilder();
result.hasField25 = true;
result.field25_ = value;
return this;
}
public Builder ClearField25() {
+ PrepareBuilder();
result.hasField25 = false;
result.field25_ = 0;
return this;
@@ -1293,18 +1389,21 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetField15(global::Google.ProtocolBuffers.TestProtos.SizeMessage1SubMessage value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.hasField15 = true;
result.field15_ = value;
return this;
}
public Builder SetField15(global::Google.ProtocolBuffers.TestProtos.SizeMessage1SubMessage.Builder builderForValue) {
pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue");
+ PrepareBuilder();
result.hasField15 = true;
result.field15_ = builderForValue.Build();
return this;
}
public Builder MergeField15(global::Google.ProtocolBuffers.TestProtos.SizeMessage1SubMessage value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
if (result.hasField15 &&
result.field15_ != global::Google.ProtocolBuffers.TestProtos.SizeMessage1SubMessage.DefaultInstance) {
result.field15_ = global::Google.ProtocolBuffers.TestProtos.SizeMessage1SubMessage.CreateBuilder(result.field15_).MergeFrom(value).BuildPartial();
@@ -1315,6 +1414,7 @@ namespace Google.ProtocolBuffers.TestProtos { return this;
}
public Builder ClearField15() {
+ PrepareBuilder();
result.hasField15 = false;
result.field15_ = global::Google.ProtocolBuffers.TestProtos.SizeMessage1SubMessage.DefaultInstance;
return this;
@@ -1328,11 +1428,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField78(value); }
}
public Builder SetField78(bool value) {
+ PrepareBuilder();
result.hasField78 = true;
result.field78_ = value;
return this;
}
public Builder ClearField78() {
+ PrepareBuilder();
result.hasField78 = false;
result.field78_ = false;
return this;
@@ -1346,11 +1448,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField67(value); }
}
public Builder SetField67(int value) {
+ PrepareBuilder();
result.hasField67 = true;
result.field67_ = value;
return this;
}
public Builder ClearField67() {
+ PrepareBuilder();
result.hasField67 = false;
result.field67_ = 0;
return this;
@@ -1364,11 +1468,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField68(value); }
}
public Builder SetField68(int value) {
+ PrepareBuilder();
result.hasField68 = true;
result.field68_ = value;
return this;
}
public Builder ClearField68() {
+ PrepareBuilder();
result.hasField68 = false;
result.field68_ = 0;
return this;
@@ -1382,11 +1488,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField128(value); }
}
public Builder SetField128(int value) {
+ PrepareBuilder();
result.hasField128 = true;
result.field128_ = value;
return this;
}
public Builder ClearField128() {
+ PrepareBuilder();
result.hasField128 = false;
result.field128_ = 0;
return this;
@@ -1401,11 +1509,13 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetField129(string value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.hasField129 = true;
result.field129_ = value;
return this;
}
public Builder ClearField129() {
+ PrepareBuilder();
result.hasField129 = false;
result.field129_ = "xxxxxxxxxxxxxxxxxxxxx";
return this;
@@ -1419,11 +1529,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField131(value); }
}
public Builder SetField131(int value) {
+ PrepareBuilder();
result.hasField131 = true;
result.field131_ = value;
return this;
}
public Builder ClearField131() {
+ PrepareBuilder();
result.hasField131 = false;
result.field131_ = 0;
return this;
@@ -1697,7 +1809,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(SizeMessage1SubMessage prototype) {
- return (Builder) new Builder().MergeFrom(prototype);
+ return new Builder(prototype);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -1707,21 +1819,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder {
get { return this; }
}
- public Builder() {}
+ public Builder() {
+ result = DefaultInstance ?? new SizeMessage1SubMessage();
+ builderIsReadOnly = result == DefaultInstance;
+ }
+ internal Builder(SizeMessage1SubMessage cloneFrom) {
+ result = cloneFrom;
+ builderIsReadOnly = true;
+ }
- SizeMessage1SubMessage result = new SizeMessage1SubMessage();
+ bool builderIsReadOnly;
+ SizeMessage1SubMessage result;
+
+ private SizeMessage1SubMessage PrepareBuilder() {
+ if (builderIsReadOnly) {
+ SizeMessage1SubMessage original = result;
+ result = new SizeMessage1SubMessage();
+ builderIsReadOnly = false;
+ MergeFrom(original);
+ }
+ return result;
+ }
+
+ public override bool IsInitialized {
+ get { return result.IsInitialized; }
+ }
protected override SizeMessage1SubMessage MessageBeingBuilt {
- get { return result; }
+ get { return PrepareBuilder(); }
}
public override Builder Clear() {
- result = new SizeMessage1SubMessage();
+ result = DefaultInstance ?? new SizeMessage1SubMessage();
+ builderIsReadOnly = true;
return this;
}
public override Builder Clone() {
- return new Builder().MergeFrom(result);
+ if (builderIsReadOnly) {
+ return new Builder(result);
+ } else {
+ return new Builder().MergeFrom(result);
+ }
}
public override pbd::MessageDescriptor DescriptorForType {
@@ -1733,12 +1872,11 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override SizeMessage1SubMessage BuildPartial() {
- if (result == null) {
- throw new global::System.InvalidOperationException("build() has already been called on this Builder");
+ if (builderIsReadOnly) {
+ return result;
}
- SizeMessage1SubMessage returnMe = result;
- result = null;
- return returnMe;
+ builderIsReadOnly = true;
+ return result;
}
@@ -1750,11 +1888,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField1(value); }
}
public Builder SetField1(int value) {
+ PrepareBuilder();
result.hasField1 = true;
result.field1_ = value;
return this;
}
public Builder ClearField1() {
+ PrepareBuilder();
result.hasField1 = false;
result.field1_ = 0;
return this;
@@ -1768,11 +1908,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField2(value); }
}
public Builder SetField2(int value) {
+ PrepareBuilder();
result.hasField2 = true;
result.field2_ = value;
return this;
}
public Builder ClearField2() {
+ PrepareBuilder();
result.hasField2 = false;
result.field2_ = 0;
return this;
@@ -1786,11 +1928,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField3(value); }
}
public Builder SetField3(int value) {
+ PrepareBuilder();
result.hasField3 = true;
result.field3_ = value;
return this;
}
public Builder ClearField3() {
+ PrepareBuilder();
result.hasField3 = false;
result.field3_ = 0;
return this;
@@ -1805,11 +1949,13 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetField15(string value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.hasField15 = true;
result.field15_ = value;
return this;
}
public Builder ClearField15() {
+ PrepareBuilder();
result.hasField15 = false;
result.field15_ = "";
return this;
@@ -1823,11 +1969,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField12(value); }
}
public Builder SetField12(bool value) {
+ PrepareBuilder();
result.hasField12 = true;
result.field12_ = value;
return this;
}
public Builder ClearField12() {
+ PrepareBuilder();
result.hasField12 = false;
result.field12_ = true;
return this;
@@ -1841,11 +1989,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField13(value); }
}
public Builder SetField13(long value) {
+ PrepareBuilder();
result.hasField13 = true;
result.field13_ = value;
return this;
}
public Builder ClearField13() {
+ PrepareBuilder();
result.hasField13 = false;
result.field13_ = 0L;
return this;
@@ -1859,11 +2009,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField14(value); }
}
public Builder SetField14(long value) {
+ PrepareBuilder();
result.hasField14 = true;
result.field14_ = value;
return this;
}
public Builder ClearField14() {
+ PrepareBuilder();
result.hasField14 = false;
result.field14_ = 0L;
return this;
@@ -1877,11 +2029,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField16(value); }
}
public Builder SetField16(int value) {
+ PrepareBuilder();
result.hasField16 = true;
result.field16_ = value;
return this;
}
public Builder ClearField16() {
+ PrepareBuilder();
result.hasField16 = false;
result.field16_ = 0;
return this;
@@ -1895,11 +2049,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField19(value); }
}
public Builder SetField19(int value) {
+ PrepareBuilder();
result.hasField19 = true;
result.field19_ = value;
return this;
}
public Builder ClearField19() {
+ PrepareBuilder();
result.hasField19 = false;
result.field19_ = 2;
return this;
@@ -1913,11 +2069,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField20(value); }
}
public Builder SetField20(bool value) {
+ PrepareBuilder();
result.hasField20 = true;
result.field20_ = value;
return this;
}
public Builder ClearField20() {
+ PrepareBuilder();
result.hasField20 = false;
result.field20_ = true;
return this;
@@ -1931,11 +2089,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField28(value); }
}
public Builder SetField28(bool value) {
+ PrepareBuilder();
result.hasField28 = true;
result.field28_ = value;
return this;
}
public Builder ClearField28() {
+ PrepareBuilder();
result.hasField28 = false;
result.field28_ = true;
return this;
@@ -1951,11 +2111,13 @@ namespace Google.ProtocolBuffers.TestProtos { }
[global::System.CLSCompliant(false)]
public Builder SetField21(ulong value) {
+ PrepareBuilder();
result.hasField21 = true;
result.field21_ = value;
return this;
}
public Builder ClearField21() {
+ PrepareBuilder();
result.hasField21 = false;
result.field21_ = 0;
return this;
@@ -1969,11 +2131,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField22(value); }
}
public Builder SetField22(int value) {
+ PrepareBuilder();
result.hasField22 = true;
result.field22_ = value;
return this;
}
public Builder ClearField22() {
+ PrepareBuilder();
result.hasField22 = false;
result.field22_ = 0;
return this;
@@ -1987,11 +2151,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField23(value); }
}
public Builder SetField23(bool value) {
+ PrepareBuilder();
result.hasField23 = true;
result.field23_ = value;
return this;
}
public Builder ClearField23() {
+ PrepareBuilder();
result.hasField23 = false;
result.field23_ = false;
return this;
@@ -2005,11 +2171,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField206(value); }
}
public Builder SetField206(bool value) {
+ PrepareBuilder();
result.hasField206 = true;
result.field206_ = value;
return this;
}
public Builder ClearField206() {
+ PrepareBuilder();
result.hasField206 = false;
result.field206_ = false;
return this;
@@ -2025,11 +2193,13 @@ namespace Google.ProtocolBuffers.TestProtos { }
[global::System.CLSCompliant(false)]
public Builder SetField203(uint value) {
+ PrepareBuilder();
result.hasField203 = true;
result.field203_ = value;
return this;
}
public Builder ClearField203() {
+ PrepareBuilder();
result.hasField203 = false;
result.field203_ = 0;
return this;
@@ -2043,11 +2213,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField204(value); }
}
public Builder SetField204(int value) {
+ PrepareBuilder();
result.hasField204 = true;
result.field204_ = value;
return this;
}
public Builder ClearField204() {
+ PrepareBuilder();
result.hasField204 = false;
result.field204_ = 0;
return this;
@@ -2062,11 +2234,13 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetField205(string value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.hasField205 = true;
result.field205_ = value;
return this;
}
public Builder ClearField205() {
+ PrepareBuilder();
result.hasField205 = false;
result.field205_ = "";
return this;
@@ -2082,11 +2256,13 @@ namespace Google.ProtocolBuffers.TestProtos { }
[global::System.CLSCompliant(false)]
public Builder SetField207(ulong value) {
+ PrepareBuilder();
result.hasField207 = true;
result.field207_ = value;
return this;
}
public Builder ClearField207() {
+ PrepareBuilder();
result.hasField207 = false;
result.field207_ = 0UL;
return this;
@@ -2102,11 +2278,13 @@ namespace Google.ProtocolBuffers.TestProtos { }
[global::System.CLSCompliant(false)]
public Builder SetField300(ulong value) {
+ PrepareBuilder();
result.hasField300 = true;
result.field300_ = value;
return this;
}
public Builder ClearField300() {
+ PrepareBuilder();
result.hasField300 = false;
result.field300_ = 0UL;
return this;
@@ -2373,7 +2551,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(Group1 prototype) {
- return (Builder) new Builder().MergeFrom(prototype);
+ return new Builder(prototype);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -2383,21 +2561,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder {
get { return this; }
}
- public Builder() {}
+ public Builder() {
+ result = DefaultInstance ?? new Group1();
+ builderIsReadOnly = result == DefaultInstance;
+ }
+ internal Builder(Group1 cloneFrom) {
+ result = cloneFrom;
+ builderIsReadOnly = true;
+ }
+
+ bool builderIsReadOnly;
+ Group1 result;
- Group1 result = new Group1();
+ private Group1 PrepareBuilder() {
+ if (builderIsReadOnly) {
+ Group1 original = result;
+ result = new Group1();
+ builderIsReadOnly = false;
+ MergeFrom(original);
+ }
+ return result;
+ }
+
+ public override bool IsInitialized {
+ get { return result.IsInitialized; }
+ }
protected override Group1 MessageBeingBuilt {
- get { return result; }
+ get { return PrepareBuilder(); }
}
public override Builder Clear() {
- result = new Group1();
+ result = DefaultInstance ?? new Group1();
+ builderIsReadOnly = true;
return this;
}
public override Builder Clone() {
- return new Builder().MergeFrom(result);
+ if (builderIsReadOnly) {
+ return new Builder(result);
+ } else {
+ return new Builder().MergeFrom(result);
+ }
}
public override pbd::MessageDescriptor DescriptorForType {
@@ -2409,15 +2614,14 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override Group1 BuildPartial() {
- if (result == null) {
- throw new global::System.InvalidOperationException("build() has already been called on this Builder");
+ if (builderIsReadOnly) {
+ return result;
}
result.field14_.MakeReadOnly();
result.field22_.MakeReadOnly();
result.field73_.MakeReadOnly();
- Group1 returnMe = result;
- result = null;
- return returnMe;
+ builderIsReadOnly = true;
+ return result;
}
@@ -2429,11 +2633,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField11(value); }
}
public Builder SetField11(float value) {
+ PrepareBuilder();
result.hasField11 = true;
result.field11_ = value;
return this;
}
public Builder ClearField11() {
+ PrepareBuilder();
result.hasField11 = false;
result.field11_ = 0F;
return this;
@@ -2447,11 +2653,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField26(value); }
}
public Builder SetField26(float value) {
+ PrepareBuilder();
result.hasField26 = true;
result.field26_ = value;
return this;
}
public Builder ClearField26() {
+ PrepareBuilder();
result.hasField26 = false;
result.field26_ = 0F;
return this;
@@ -2466,11 +2674,13 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetField12(string value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.hasField12 = true;
result.field12_ = value;
return this;
}
public Builder ClearField12() {
+ PrepareBuilder();
result.hasField12 = false;
result.field12_ = "";
return this;
@@ -2485,18 +2695,20 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetField13(string value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.hasField13 = true;
result.field13_ = value;
return this;
}
public Builder ClearField13() {
+ PrepareBuilder();
result.hasField13 = false;
result.field13_ = "";
return this;
}
public pbc::IPopsicleList<string> Field14List {
- get { return result.field14_; }
+ get { return PrepareBuilder().field14_; }
}
public int Field14Count {
get { return result.Field14Count; }
@@ -2506,19 +2718,23 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetField14(int index, string value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.field14_[index] = value;
return this;
}
public Builder AddField14(string value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.field14_.Add(value);
return this;
}
public Builder AddRangeField14(scg::IEnumerable<string> values) {
+ PrepareBuilder();
base.AddRange(values, result.field14_);
return this;
}
public Builder ClearField14() {
+ PrepareBuilder();
result.field14_.Clear();
return this;
}
@@ -2533,11 +2749,13 @@ namespace Google.ProtocolBuffers.TestProtos { }
[global::System.CLSCompliant(false)]
public Builder SetField15(ulong value) {
+ PrepareBuilder();
result.hasField15 = true;
result.field15_ = value;
return this;
}
public Builder ClearField15() {
+ PrepareBuilder();
result.hasField15 = false;
result.field15_ = 0UL;
return this;
@@ -2551,11 +2769,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField5(value); }
}
public Builder SetField5(int value) {
+ PrepareBuilder();
result.hasField5 = true;
result.field5_ = value;
return this;
}
public Builder ClearField5() {
+ PrepareBuilder();
result.hasField5 = false;
result.field5_ = 0;
return this;
@@ -2570,11 +2790,13 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetField27(string value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.hasField27 = true;
result.field27_ = value;
return this;
}
public Builder ClearField27() {
+ PrepareBuilder();
result.hasField27 = false;
result.field27_ = "";
return this;
@@ -2588,11 +2810,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField28(value); }
}
public Builder SetField28(int value) {
+ PrepareBuilder();
result.hasField28 = true;
result.field28_ = value;
return this;
}
public Builder ClearField28() {
+ PrepareBuilder();
result.hasField28 = false;
result.field28_ = 0;
return this;
@@ -2607,11 +2831,13 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetField29(string value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.hasField29 = true;
result.field29_ = value;
return this;
}
public Builder ClearField29() {
+ PrepareBuilder();
result.hasField29 = false;
result.field29_ = "";
return this;
@@ -2626,18 +2852,20 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetField16(string value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.hasField16 = true;
result.field16_ = value;
return this;
}
public Builder ClearField16() {
+ PrepareBuilder();
result.hasField16 = false;
result.field16_ = "";
return this;
}
public pbc::IPopsicleList<string> Field22List {
- get { return result.field22_; }
+ get { return PrepareBuilder().field22_; }
}
public int Field22Count {
get { return result.Field22Count; }
@@ -2647,25 +2875,29 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetField22(int index, string value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.field22_[index] = value;
return this;
}
public Builder AddField22(string value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.field22_.Add(value);
return this;
}
public Builder AddRangeField22(scg::IEnumerable<string> values) {
+ PrepareBuilder();
base.AddRange(values, result.field22_);
return this;
}
public Builder ClearField22() {
+ PrepareBuilder();
result.field22_.Clear();
return this;
}
public pbc::IPopsicleList<int> Field73List {
- get { return result.field73_; }
+ get { return PrepareBuilder().field73_; }
}
public int Field73Count {
get { return result.Field73Count; }
@@ -2674,18 +2906,22 @@ namespace Google.ProtocolBuffers.TestProtos { return result.GetField73(index);
}
public Builder SetField73(int index, int value) {
+ PrepareBuilder();
result.field73_[index] = value;
return this;
}
public Builder AddField73(int value) {
+ PrepareBuilder();
result.field73_.Add(value);
return this;
}
public Builder AddRangeField73(scg::IEnumerable<int> values) {
+ PrepareBuilder();
base.AddRange(values, result.field73_);
return this;
}
public Builder ClearField73() {
+ PrepareBuilder();
result.field73_.Clear();
return this;
}
@@ -2698,11 +2934,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField20(value); }
}
public Builder SetField20(int value) {
+ PrepareBuilder();
result.hasField20 = true;
result.field20_ = value;
return this;
}
public Builder ClearField20() {
+ PrepareBuilder();
result.hasField20 = false;
result.field20_ = 0;
return this;
@@ -2717,11 +2955,13 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetField24(string value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.hasField24 = true;
result.field24_ = value;
return this;
}
public Builder ClearField24() {
+ PrepareBuilder();
result.hasField24 = false;
result.field24_ = "";
return this;
@@ -2736,18 +2976,21 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetField31(global::Google.ProtocolBuffers.TestProtos.SizeMessage2GroupedMessage value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.hasField31 = true;
result.field31_ = value;
return this;
}
public Builder SetField31(global::Google.ProtocolBuffers.TestProtos.SizeMessage2GroupedMessage.Builder builderForValue) {
pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue");
+ PrepareBuilder();
result.hasField31 = true;
result.field31_ = builderForValue.Build();
return this;
}
public Builder MergeField31(global::Google.ProtocolBuffers.TestProtos.SizeMessage2GroupedMessage value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
if (result.hasField31 &&
result.field31_ != global::Google.ProtocolBuffers.TestProtos.SizeMessage2GroupedMessage.DefaultInstance) {
result.field31_ = global::Google.ProtocolBuffers.TestProtos.SizeMessage2GroupedMessage.CreateBuilder(result.field31_).MergeFrom(value).BuildPartial();
@@ -2758,6 +3001,7 @@ namespace Google.ProtocolBuffers.TestProtos { return this;
}
public Builder ClearField31() {
+ PrepareBuilder();
result.hasField31 = false;
result.field31_ = global::Google.ProtocolBuffers.TestProtos.SizeMessage2GroupedMessage.DefaultInstance;
return this;
@@ -3113,7 +3357,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(SizeMessage2 prototype) {
- return (Builder) new Builder().MergeFrom(prototype);
+ return new Builder(prototype);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -3123,21 +3367,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder {
get { return this; }
}
- public Builder() {}
+ public Builder() {
+ result = DefaultInstance ?? new SizeMessage2();
+ builderIsReadOnly = result == DefaultInstance;
+ }
+ internal Builder(SizeMessage2 cloneFrom) {
+ result = cloneFrom;
+ builderIsReadOnly = true;
+ }
- SizeMessage2 result = new SizeMessage2();
+ bool builderIsReadOnly;
+ SizeMessage2 result;
+
+ private SizeMessage2 PrepareBuilder() {
+ if (builderIsReadOnly) {
+ SizeMessage2 original = result;
+ result = new SizeMessage2();
+ builderIsReadOnly = false;
+ MergeFrom(original);
+ }
+ return result;
+ }
+
+ public override bool IsInitialized {
+ get { return result.IsInitialized; }
+ }
protected override SizeMessage2 MessageBeingBuilt {
- get { return result; }
+ get { return PrepareBuilder(); }
}
public override Builder Clear() {
- result = new SizeMessage2();
+ result = DefaultInstance ?? new SizeMessage2();
+ builderIsReadOnly = true;
return this;
}
public override Builder Clone() {
- return new Builder().MergeFrom(result);
+ if (builderIsReadOnly) {
+ return new Builder(result);
+ } else {
+ return new Builder().MergeFrom(result);
+ }
}
public override pbd::MessageDescriptor DescriptorForType {
@@ -3149,16 +3420,15 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override SizeMessage2 BuildPartial() {
- if (result == null) {
- throw new global::System.InvalidOperationException("build() has already been called on this Builder");
+ if (builderIsReadOnly) {
+ return result;
}
result.group1_.MakeReadOnly();
result.field128_.MakeReadOnly();
result.field127_.MakeReadOnly();
result.field130_.MakeReadOnly();
- SizeMessage2 returnMe = result;
- result = null;
- return returnMe;
+ builderIsReadOnly = true;
+ return result;
}
@@ -3171,11 +3441,13 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetField1(string value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.hasField1 = true;
result.field1_ = value;
return this;
}
public Builder ClearField1() {
+ PrepareBuilder();
result.hasField1 = false;
result.field1_ = "";
return this;
@@ -3189,11 +3461,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField3(value); }
}
public Builder SetField3(long value) {
+ PrepareBuilder();
result.hasField3 = true;
result.field3_ = value;
return this;
}
public Builder ClearField3() {
+ PrepareBuilder();
result.hasField3 = false;
result.field3_ = 0L;
return this;
@@ -3207,11 +3481,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField4(value); }
}
public Builder SetField4(long value) {
+ PrepareBuilder();
result.hasField4 = true;
result.field4_ = value;
return this;
}
public Builder ClearField4() {
+ PrepareBuilder();
result.hasField4 = false;
result.field4_ = 0L;
return this;
@@ -3225,11 +3501,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField30(value); }
}
public Builder SetField30(long value) {
+ PrepareBuilder();
result.hasField30 = true;
result.field30_ = value;
return this;
}
public Builder ClearField30() {
+ PrepareBuilder();
result.hasField30 = false;
result.field30_ = 0L;
return this;
@@ -3243,11 +3521,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField75(value); }
}
public Builder SetField75(bool value) {
+ PrepareBuilder();
result.hasField75 = true;
result.field75_ = value;
return this;
}
public Builder ClearField75() {
+ PrepareBuilder();
result.hasField75 = false;
result.field75_ = false;
return this;
@@ -3262,11 +3542,13 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetField6(string value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.hasField6 = true;
result.field6_ = value;
return this;
}
public Builder ClearField6() {
+ PrepareBuilder();
result.hasField6 = false;
result.field6_ = "";
return this;
@@ -3281,11 +3563,13 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetField2(pb::ByteString value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.hasField2 = true;
result.field2_ = value;
return this;
}
public Builder ClearField2() {
+ PrepareBuilder();
result.hasField2 = false;
result.field2_ = pb::ByteString.Empty;
return this;
@@ -3299,11 +3583,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField21(value); }
}
public Builder SetField21(int value) {
+ PrepareBuilder();
result.hasField21 = true;
result.field21_ = value;
return this;
}
public Builder ClearField21() {
+ PrepareBuilder();
result.hasField21 = false;
result.field21_ = 0;
return this;
@@ -3317,11 +3603,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField71(value); }
}
public Builder SetField71(int value) {
+ PrepareBuilder();
result.hasField71 = true;
result.field71_ = value;
return this;
}
public Builder ClearField71() {
+ PrepareBuilder();
result.hasField71 = false;
result.field71_ = 0;
return this;
@@ -3335,11 +3623,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField25(value); }
}
public Builder SetField25(float value) {
+ PrepareBuilder();
result.hasField25 = true;
result.field25_ = value;
return this;
}
public Builder ClearField25() {
+ PrepareBuilder();
result.hasField25 = false;
result.field25_ = 0F;
return this;
@@ -3353,11 +3643,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField109(value); }
}
public Builder SetField109(int value) {
+ PrepareBuilder();
result.hasField109 = true;
result.field109_ = value;
return this;
}
public Builder ClearField109() {
+ PrepareBuilder();
result.hasField109 = false;
result.field109_ = 0;
return this;
@@ -3371,11 +3663,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField210(value); }
}
public Builder SetField210(int value) {
+ PrepareBuilder();
result.hasField210 = true;
result.field210_ = value;
return this;
}
public Builder ClearField210() {
+ PrepareBuilder();
result.hasField210 = false;
result.field210_ = 0;
return this;
@@ -3389,11 +3683,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField211(value); }
}
public Builder SetField211(int value) {
+ PrepareBuilder();
result.hasField211 = true;
result.field211_ = value;
return this;
}
public Builder ClearField211() {
+ PrepareBuilder();
result.hasField211 = false;
result.field211_ = 0;
return this;
@@ -3407,11 +3703,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField212(value); }
}
public Builder SetField212(int value) {
+ PrepareBuilder();
result.hasField212 = true;
result.field212_ = value;
return this;
}
public Builder ClearField212() {
+ PrepareBuilder();
result.hasField212 = false;
result.field212_ = 0;
return this;
@@ -3425,11 +3723,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField213(value); }
}
public Builder SetField213(int value) {
+ PrepareBuilder();
result.hasField213 = true;
result.field213_ = value;
return this;
}
public Builder ClearField213() {
+ PrepareBuilder();
result.hasField213 = false;
result.field213_ = 0;
return this;
@@ -3443,11 +3743,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField216(value); }
}
public Builder SetField216(int value) {
+ PrepareBuilder();
result.hasField216 = true;
result.field216_ = value;
return this;
}
public Builder ClearField216() {
+ PrepareBuilder();
result.hasField216 = false;
result.field216_ = 0;
return this;
@@ -3461,11 +3763,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField217(value); }
}
public Builder SetField217(int value) {
+ PrepareBuilder();
result.hasField217 = true;
result.field217_ = value;
return this;
}
public Builder ClearField217() {
+ PrepareBuilder();
result.hasField217 = false;
result.field217_ = 0;
return this;
@@ -3479,11 +3783,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField218(value); }
}
public Builder SetField218(int value) {
+ PrepareBuilder();
result.hasField218 = true;
result.field218_ = value;
return this;
}
public Builder ClearField218() {
+ PrepareBuilder();
result.hasField218 = false;
result.field218_ = 0;
return this;
@@ -3497,11 +3803,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField220(value); }
}
public Builder SetField220(int value) {
+ PrepareBuilder();
result.hasField220 = true;
result.field220_ = value;
return this;
}
public Builder ClearField220() {
+ PrepareBuilder();
result.hasField220 = false;
result.field220_ = 0;
return this;
@@ -3515,11 +3823,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField221(value); }
}
public Builder SetField221(int value) {
+ PrepareBuilder();
result.hasField221 = true;
result.field221_ = value;
return this;
}
public Builder ClearField221() {
+ PrepareBuilder();
result.hasField221 = false;
result.field221_ = 0;
return this;
@@ -3533,11 +3843,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField222(value); }
}
public Builder SetField222(float value) {
+ PrepareBuilder();
result.hasField222 = true;
result.field222_ = value;
return this;
}
public Builder ClearField222() {
+ PrepareBuilder();
result.hasField222 = false;
result.field222_ = 0F;
return this;
@@ -3551,18 +3863,20 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField63(value); }
}
public Builder SetField63(int value) {
+ PrepareBuilder();
result.hasField63 = true;
result.field63_ = value;
return this;
}
public Builder ClearField63() {
+ PrepareBuilder();
result.hasField63 = false;
result.field63_ = 0;
return this;
}
public pbc::IPopsicleList<global::Google.ProtocolBuffers.TestProtos.SizeMessage2.Types.Group1> Group1List {
- get { return result.group1_; }
+ get { return PrepareBuilder().group1_; }
}
public int Group1Count {
get { return result.Group1Count; }
@@ -3572,35 +3886,41 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetGroup1(int index, global::Google.ProtocolBuffers.TestProtos.SizeMessage2.Types.Group1 value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.group1_[index] = value;
return this;
}
public Builder SetGroup1(int index, global::Google.ProtocolBuffers.TestProtos.SizeMessage2.Types.Group1.Builder builderForValue) {
pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue");
+ PrepareBuilder();
result.group1_[index] = builderForValue.Build();
return this;
}
public Builder AddGroup1(global::Google.ProtocolBuffers.TestProtos.SizeMessage2.Types.Group1 value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.group1_.Add(value);
return this;
}
public Builder AddGroup1(global::Google.ProtocolBuffers.TestProtos.SizeMessage2.Types.Group1.Builder builderForValue) {
pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue");
+ PrepareBuilder();
result.group1_.Add(builderForValue.Build());
return this;
}
public Builder AddRangeGroup1(scg::IEnumerable<global::Google.ProtocolBuffers.TestProtos.SizeMessage2.Types.Group1> values) {
+ PrepareBuilder();
base.AddRange(values, result.group1_);
return this;
}
public Builder ClearGroup1() {
+ PrepareBuilder();
result.group1_.Clear();
return this;
}
public pbc::IPopsicleList<string> Field128List {
- get { return result.field128_; }
+ get { return PrepareBuilder().field128_; }
}
public int Field128Count {
get { return result.Field128Count; }
@@ -3610,19 +3930,23 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetField128(int index, string value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.field128_[index] = value;
return this;
}
public Builder AddField128(string value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.field128_.Add(value);
return this;
}
public Builder AddRangeField128(scg::IEnumerable<string> values) {
+ PrepareBuilder();
base.AddRange(values, result.field128_);
return this;
}
public Builder ClearField128() {
+ PrepareBuilder();
result.field128_.Clear();
return this;
}
@@ -3635,18 +3959,20 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField131(value); }
}
public Builder SetField131(long value) {
+ PrepareBuilder();
result.hasField131 = true;
result.field131_ = value;
return this;
}
public Builder ClearField131() {
+ PrepareBuilder();
result.hasField131 = false;
result.field131_ = 0L;
return this;
}
public pbc::IPopsicleList<string> Field127List {
- get { return result.field127_; }
+ get { return PrepareBuilder().field127_; }
}
public int Field127Count {
get { return result.Field127Count; }
@@ -3656,19 +3982,23 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetField127(int index, string value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.field127_[index] = value;
return this;
}
public Builder AddField127(string value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.field127_.Add(value);
return this;
}
public Builder AddRangeField127(scg::IEnumerable<string> values) {
+ PrepareBuilder();
base.AddRange(values, result.field127_);
return this;
}
public Builder ClearField127() {
+ PrepareBuilder();
result.field127_.Clear();
return this;
}
@@ -3681,18 +4011,20 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField129(value); }
}
public Builder SetField129(int value) {
+ PrepareBuilder();
result.hasField129 = true;
result.field129_ = value;
return this;
}
public Builder ClearField129() {
+ PrepareBuilder();
result.hasField129 = false;
result.field129_ = 0;
return this;
}
public pbc::IPopsicleList<long> Field130List {
- get { return result.field130_; }
+ get { return PrepareBuilder().field130_; }
}
public int Field130Count {
get { return result.Field130Count; }
@@ -3701,18 +4033,22 @@ namespace Google.ProtocolBuffers.TestProtos { return result.GetField130(index);
}
public Builder SetField130(int index, long value) {
+ PrepareBuilder();
result.field130_[index] = value;
return this;
}
public Builder AddField130(long value) {
+ PrepareBuilder();
result.field130_.Add(value);
return this;
}
public Builder AddRangeField130(scg::IEnumerable<long> values) {
+ PrepareBuilder();
base.AddRange(values, result.field130_);
return this;
}
public Builder ClearField130() {
+ PrepareBuilder();
result.field130_.Clear();
return this;
}
@@ -3725,11 +4061,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField205(value); }
}
public Builder SetField205(bool value) {
+ PrepareBuilder();
result.hasField205 = true;
result.field205_ = value;
return this;
}
public Builder ClearField205() {
+ PrepareBuilder();
result.hasField205 = false;
result.field205_ = false;
return this;
@@ -3743,11 +4081,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField206(value); }
}
public Builder SetField206(bool value) {
+ PrepareBuilder();
result.hasField206 = true;
result.field206_ = value;
return this;
}
public Builder ClearField206() {
+ PrepareBuilder();
result.hasField206 = false;
result.field206_ = false;
return this;
@@ -3927,7 +4267,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(SizeMessage2GroupedMessage prototype) {
- return (Builder) new Builder().MergeFrom(prototype);
+ return new Builder(prototype);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -3937,21 +4277,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder {
get { return this; }
}
- public Builder() {}
+ public Builder() {
+ result = DefaultInstance ?? new SizeMessage2GroupedMessage();
+ builderIsReadOnly = result == DefaultInstance;
+ }
+ internal Builder(SizeMessage2GroupedMessage cloneFrom) {
+ result = cloneFrom;
+ builderIsReadOnly = true;
+ }
- SizeMessage2GroupedMessage result = new SizeMessage2GroupedMessage();
+ bool builderIsReadOnly;
+ SizeMessage2GroupedMessage result;
+
+ private SizeMessage2GroupedMessage PrepareBuilder() {
+ if (builderIsReadOnly) {
+ SizeMessage2GroupedMessage original = result;
+ result = new SizeMessage2GroupedMessage();
+ builderIsReadOnly = false;
+ MergeFrom(original);
+ }
+ return result;
+ }
+
+ public override bool IsInitialized {
+ get { return result.IsInitialized; }
+ }
protected override SizeMessage2GroupedMessage MessageBeingBuilt {
- get { return result; }
+ get { return PrepareBuilder(); }
}
public override Builder Clear() {
- result = new SizeMessage2GroupedMessage();
+ result = DefaultInstance ?? new SizeMessage2GroupedMessage();
+ builderIsReadOnly = true;
return this;
}
public override Builder Clone() {
- return new Builder().MergeFrom(result);
+ if (builderIsReadOnly) {
+ return new Builder(result);
+ } else {
+ return new Builder().MergeFrom(result);
+ }
}
public override pbd::MessageDescriptor DescriptorForType {
@@ -3963,12 +4330,11 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override SizeMessage2GroupedMessage BuildPartial() {
- if (result == null) {
- throw new global::System.InvalidOperationException("build() has already been called on this Builder");
+ if (builderIsReadOnly) {
+ return result;
}
- SizeMessage2GroupedMessage returnMe = result;
- result = null;
- return returnMe;
+ builderIsReadOnly = true;
+ return result;
}
@@ -3980,11 +4346,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField1(value); }
}
public Builder SetField1(float value) {
+ PrepareBuilder();
result.hasField1 = true;
result.field1_ = value;
return this;
}
public Builder ClearField1() {
+ PrepareBuilder();
result.hasField1 = false;
result.field1_ = 0F;
return this;
@@ -3998,11 +4366,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField2(value); }
}
public Builder SetField2(float value) {
+ PrepareBuilder();
result.hasField2 = true;
result.field2_ = value;
return this;
}
public Builder ClearField2() {
+ PrepareBuilder();
result.hasField2 = false;
result.field2_ = 0F;
return this;
@@ -4016,11 +4386,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField3(value); }
}
public Builder SetField3(float value) {
+ PrepareBuilder();
result.hasField3 = true;
result.field3_ = value;
return this;
}
public Builder ClearField3() {
+ PrepareBuilder();
result.hasField3 = false;
result.field3_ = 0F;
return this;
@@ -4034,11 +4406,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField4(value); }
}
public Builder SetField4(bool value) {
+ PrepareBuilder();
result.hasField4 = true;
result.field4_ = value;
return this;
}
public Builder ClearField4() {
+ PrepareBuilder();
result.hasField4 = false;
result.field4_ = false;
return this;
@@ -4052,11 +4426,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField5(value); }
}
public Builder SetField5(bool value) {
+ PrepareBuilder();
result.hasField5 = true;
result.field5_ = value;
return this;
}
public Builder ClearField5() {
+ PrepareBuilder();
result.hasField5 = false;
result.field5_ = false;
return this;
@@ -4070,11 +4446,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField6(value); }
}
public Builder SetField6(bool value) {
+ PrepareBuilder();
result.hasField6 = true;
result.field6_ = value;
return this;
}
public Builder ClearField6() {
+ PrepareBuilder();
result.hasField6 = false;
result.field6_ = true;
return this;
@@ -4088,11 +4466,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField7(value); }
}
public Builder SetField7(bool value) {
+ PrepareBuilder();
result.hasField7 = true;
result.field7_ = value;
return this;
}
public Builder ClearField7() {
+ PrepareBuilder();
result.hasField7 = false;
result.field7_ = false;
return this;
@@ -4106,11 +4486,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField8(value); }
}
public Builder SetField8(float value) {
+ PrepareBuilder();
result.hasField8 = true;
result.field8_ = value;
return this;
}
public Builder ClearField8() {
+ PrepareBuilder();
result.hasField8 = false;
result.field8_ = 0F;
return this;
@@ -4124,11 +4506,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField9(value); }
}
public Builder SetField9(bool value) {
+ PrepareBuilder();
result.hasField9 = true;
result.field9_ = value;
return this;
}
public Builder ClearField9() {
+ PrepareBuilder();
result.hasField9 = false;
result.field9_ = false;
return this;
@@ -4142,11 +4526,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField10(value); }
}
public Builder SetField10(float value) {
+ PrepareBuilder();
result.hasField10 = true;
result.field10_ = value;
return this;
}
public Builder ClearField10() {
+ PrepareBuilder();
result.hasField10 = false;
result.field10_ = 0F;
return this;
@@ -4160,11 +4546,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField11(value); }
}
public Builder SetField11(long value) {
+ PrepareBuilder();
result.hasField11 = true;
result.field11_ = value;
return this;
}
public Builder ClearField11() {
+ PrepareBuilder();
result.hasField11 = false;
result.field11_ = 0L;
return this;
diff --git a/src/ProtocolBuffers.Test/TestProtos/UnitTestGoogleSpeedProtoFile.cs b/src/ProtocolBuffers.Test/TestProtos/UnitTestGoogleSpeedProtoFile.cs index 918be643..379a86f9 100644 --- a/src/ProtocolBuffers.Test/TestProtos/UnitTestGoogleSpeedProtoFile.cs +++ b/src/ProtocolBuffers.Test/TestProtos/UnitTestGoogleSpeedProtoFile.cs @@ -885,7 +885,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(SpeedMessage1 prototype) {
- return (Builder) new Builder().MergeFrom(prototype);
+ return new Builder(prototype);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -895,21 +895,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder {
get { return this; }
}
- public Builder() {}
+ public Builder() {
+ result = DefaultInstance ?? new SpeedMessage1();
+ builderIsReadOnly = result == DefaultInstance;
+ }
+ internal Builder(SpeedMessage1 cloneFrom) {
+ result = cloneFrom;
+ builderIsReadOnly = true;
+ }
+
+ bool builderIsReadOnly;
+ SpeedMessage1 result;
- SpeedMessage1 result = new SpeedMessage1();
+ private SpeedMessage1 PrepareBuilder() {
+ if (builderIsReadOnly) {
+ SpeedMessage1 original = result;
+ result = new SpeedMessage1();
+ builderIsReadOnly = false;
+ MergeFrom(original);
+ }
+ return result;
+ }
+
+ public override bool IsInitialized {
+ get { return result.IsInitialized; }
+ }
protected override SpeedMessage1 MessageBeingBuilt {
- get { return result; }
+ get { return PrepareBuilder(); }
}
public override Builder Clear() {
- result = new SpeedMessage1();
+ result = DefaultInstance ?? new SpeedMessage1();
+ builderIsReadOnly = true;
return this;
}
public override Builder Clone() {
- return new Builder().MergeFrom(result);
+ if (builderIsReadOnly) {
+ return new Builder(result);
+ } else {
+ return new Builder().MergeFrom(result);
+ }
}
public override pbd::MessageDescriptor DescriptorForType {
@@ -921,13 +948,12 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override SpeedMessage1 BuildPartial() {
- if (result == null) {
- throw new global::System.InvalidOperationException("build() has already been called on this Builder");
+ if (builderIsReadOnly) {
+ return result;
}
result.field5_.MakeReadOnly();
- SpeedMessage1 returnMe = result;
- result = null;
- return returnMe;
+ builderIsReadOnly = true;
+ return result;
}
public override Builder MergeFrom(pb::IMessage other) {
@@ -941,6 +967,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder MergeFrom(SpeedMessage1 other) {
if (other == global::Google.ProtocolBuffers.TestProtos.SpeedMessage1.DefaultInstance) return this;
+ PrepareBuilder();
if (other.HasField1) {
Field1 = other.Field1;
}
@@ -1073,6 +1100,7 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
+ PrepareBuilder();
pb::UnknownFieldSet.Builder unknownFields = null;
uint tag;
string field_name;
@@ -1295,11 +1323,13 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetField1(string value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.hasField1 = true;
result.field1_ = value;
return this;
}
public Builder ClearField1() {
+ PrepareBuilder();
result.hasField1 = false;
result.field1_ = "";
return this;
@@ -1314,11 +1344,13 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetField9(string value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.hasField9 = true;
result.field9_ = value;
return this;
}
public Builder ClearField9() {
+ PrepareBuilder();
result.hasField9 = false;
result.field9_ = "";
return this;
@@ -1333,11 +1365,13 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetField18(string value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.hasField18 = true;
result.field18_ = value;
return this;
}
public Builder ClearField18() {
+ PrepareBuilder();
result.hasField18 = false;
result.field18_ = "";
return this;
@@ -1351,11 +1385,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField80(value); }
}
public Builder SetField80(bool value) {
+ PrepareBuilder();
result.hasField80 = true;
result.field80_ = value;
return this;
}
public Builder ClearField80() {
+ PrepareBuilder();
result.hasField80 = false;
result.field80_ = false;
return this;
@@ -1369,11 +1405,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField81(value); }
}
public Builder SetField81(bool value) {
+ PrepareBuilder();
result.hasField81 = true;
result.field81_ = value;
return this;
}
public Builder ClearField81() {
+ PrepareBuilder();
result.hasField81 = false;
result.field81_ = true;
return this;
@@ -1387,11 +1425,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField2(value); }
}
public Builder SetField2(int value) {
+ PrepareBuilder();
result.hasField2 = true;
result.field2_ = value;
return this;
}
public Builder ClearField2() {
+ PrepareBuilder();
result.hasField2 = false;
result.field2_ = 0;
return this;
@@ -1405,11 +1445,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField3(value); }
}
public Builder SetField3(int value) {
+ PrepareBuilder();
result.hasField3 = true;
result.field3_ = value;
return this;
}
public Builder ClearField3() {
+ PrepareBuilder();
result.hasField3 = false;
result.field3_ = 0;
return this;
@@ -1423,11 +1465,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField280(value); }
}
public Builder SetField280(int value) {
+ PrepareBuilder();
result.hasField280 = true;
result.field280_ = value;
return this;
}
public Builder ClearField280() {
+ PrepareBuilder();
result.hasField280 = false;
result.field280_ = 0;
return this;
@@ -1441,11 +1485,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField6(value); }
}
public Builder SetField6(int value) {
+ PrepareBuilder();
result.hasField6 = true;
result.field6_ = value;
return this;
}
public Builder ClearField6() {
+ PrepareBuilder();
result.hasField6 = false;
result.field6_ = 0;
return this;
@@ -1459,11 +1505,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField22(value); }
}
public Builder SetField22(long value) {
+ PrepareBuilder();
result.hasField22 = true;
result.field22_ = value;
return this;
}
public Builder ClearField22() {
+ PrepareBuilder();
result.hasField22 = false;
result.field22_ = 0L;
return this;
@@ -1478,11 +1526,13 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetField4(string value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.hasField4 = true;
result.field4_ = value;
return this;
}
public Builder ClearField4() {
+ PrepareBuilder();
result.hasField4 = false;
result.field4_ = "";
return this;
@@ -1490,7 +1540,7 @@ namespace Google.ProtocolBuffers.TestProtos { [global::System.CLSCompliant(false)]
public pbc::IPopsicleList<ulong> Field5List {
- get { return result.field5_; }
+ get { return PrepareBuilder().field5_; }
}
public int Field5Count {
get { return result.Field5Count; }
@@ -1501,20 +1551,24 @@ namespace Google.ProtocolBuffers.TestProtos { }
[global::System.CLSCompliant(false)]
public Builder SetField5(int index, ulong value) {
+ PrepareBuilder();
result.field5_[index] = value;
return this;
}
[global::System.CLSCompliant(false)]
public Builder AddField5(ulong value) {
+ PrepareBuilder();
result.field5_.Add(value);
return this;
}
[global::System.CLSCompliant(false)]
public Builder AddRangeField5(scg::IEnumerable<ulong> values) {
+ PrepareBuilder();
base.AddRange(values, result.field5_);
return this;
}
public Builder ClearField5() {
+ PrepareBuilder();
result.field5_.Clear();
return this;
}
@@ -1527,11 +1581,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField59(value); }
}
public Builder SetField59(bool value) {
+ PrepareBuilder();
result.hasField59 = true;
result.field59_ = value;
return this;
}
public Builder ClearField59() {
+ PrepareBuilder();
result.hasField59 = false;
result.field59_ = false;
return this;
@@ -1546,11 +1602,13 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetField7(string value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.hasField7 = true;
result.field7_ = value;
return this;
}
public Builder ClearField7() {
+ PrepareBuilder();
result.hasField7 = false;
result.field7_ = "";
return this;
@@ -1564,11 +1622,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField16(value); }
}
public Builder SetField16(int value) {
+ PrepareBuilder();
result.hasField16 = true;
result.field16_ = value;
return this;
}
public Builder ClearField16() {
+ PrepareBuilder();
result.hasField16 = false;
result.field16_ = 0;
return this;
@@ -1582,11 +1642,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField130(value); }
}
public Builder SetField130(int value) {
+ PrepareBuilder();
result.hasField130 = true;
result.field130_ = value;
return this;
}
public Builder ClearField130() {
+ PrepareBuilder();
result.hasField130 = false;
result.field130_ = 0;
return this;
@@ -1600,11 +1662,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField12(value); }
}
public Builder SetField12(bool value) {
+ PrepareBuilder();
result.hasField12 = true;
result.field12_ = value;
return this;
}
public Builder ClearField12() {
+ PrepareBuilder();
result.hasField12 = false;
result.field12_ = true;
return this;
@@ -1618,11 +1682,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField17(value); }
}
public Builder SetField17(bool value) {
+ PrepareBuilder();
result.hasField17 = true;
result.field17_ = value;
return this;
}
public Builder ClearField17() {
+ PrepareBuilder();
result.hasField17 = false;
result.field17_ = true;
return this;
@@ -1636,11 +1702,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField13(value); }
}
public Builder SetField13(bool value) {
+ PrepareBuilder();
result.hasField13 = true;
result.field13_ = value;
return this;
}
public Builder ClearField13() {
+ PrepareBuilder();
result.hasField13 = false;
result.field13_ = true;
return this;
@@ -1654,11 +1722,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField14(value); }
}
public Builder SetField14(bool value) {
+ PrepareBuilder();
result.hasField14 = true;
result.field14_ = value;
return this;
}
public Builder ClearField14() {
+ PrepareBuilder();
result.hasField14 = false;
result.field14_ = true;
return this;
@@ -1672,11 +1742,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField104(value); }
}
public Builder SetField104(int value) {
+ PrepareBuilder();
result.hasField104 = true;
result.field104_ = value;
return this;
}
public Builder ClearField104() {
+ PrepareBuilder();
result.hasField104 = false;
result.field104_ = 0;
return this;
@@ -1690,11 +1762,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField100(value); }
}
public Builder SetField100(int value) {
+ PrepareBuilder();
result.hasField100 = true;
result.field100_ = value;
return this;
}
public Builder ClearField100() {
+ PrepareBuilder();
result.hasField100 = false;
result.field100_ = 0;
return this;
@@ -1708,11 +1782,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField101(value); }
}
public Builder SetField101(int value) {
+ PrepareBuilder();
result.hasField101 = true;
result.field101_ = value;
return this;
}
public Builder ClearField101() {
+ PrepareBuilder();
result.hasField101 = false;
result.field101_ = 0;
return this;
@@ -1727,11 +1803,13 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetField102(string value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.hasField102 = true;
result.field102_ = value;
return this;
}
public Builder ClearField102() {
+ PrepareBuilder();
result.hasField102 = false;
result.field102_ = "";
return this;
@@ -1746,11 +1824,13 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetField103(string value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.hasField103 = true;
result.field103_ = value;
return this;
}
public Builder ClearField103() {
+ PrepareBuilder();
result.hasField103 = false;
result.field103_ = "";
return this;
@@ -1764,11 +1844,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField29(value); }
}
public Builder SetField29(int value) {
+ PrepareBuilder();
result.hasField29 = true;
result.field29_ = value;
return this;
}
public Builder ClearField29() {
+ PrepareBuilder();
result.hasField29 = false;
result.field29_ = 0;
return this;
@@ -1782,11 +1864,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField30(value); }
}
public Builder SetField30(bool value) {
+ PrepareBuilder();
result.hasField30 = true;
result.field30_ = value;
return this;
}
public Builder ClearField30() {
+ PrepareBuilder();
result.hasField30 = false;
result.field30_ = false;
return this;
@@ -1800,11 +1884,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField60(value); }
}
public Builder SetField60(int value) {
+ PrepareBuilder();
result.hasField60 = true;
result.field60_ = value;
return this;
}
public Builder ClearField60() {
+ PrepareBuilder();
result.hasField60 = false;
result.field60_ = -1;
return this;
@@ -1818,11 +1904,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField271(value); }
}
public Builder SetField271(int value) {
+ PrepareBuilder();
result.hasField271 = true;
result.field271_ = value;
return this;
}
public Builder ClearField271() {
+ PrepareBuilder();
result.hasField271 = false;
result.field271_ = -1;
return this;
@@ -1836,11 +1924,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField272(value); }
}
public Builder SetField272(int value) {
+ PrepareBuilder();
result.hasField272 = true;
result.field272_ = value;
return this;
}
public Builder ClearField272() {
+ PrepareBuilder();
result.hasField272 = false;
result.field272_ = -1;
return this;
@@ -1854,11 +1944,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField150(value); }
}
public Builder SetField150(int value) {
+ PrepareBuilder();
result.hasField150 = true;
result.field150_ = value;
return this;
}
public Builder ClearField150() {
+ PrepareBuilder();
result.hasField150 = false;
result.field150_ = 0;
return this;
@@ -1872,11 +1964,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField23(value); }
}
public Builder SetField23(int value) {
+ PrepareBuilder();
result.hasField23 = true;
result.field23_ = value;
return this;
}
public Builder ClearField23() {
+ PrepareBuilder();
result.hasField23 = false;
result.field23_ = 0;
return this;
@@ -1890,11 +1984,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField24(value); }
}
public Builder SetField24(bool value) {
+ PrepareBuilder();
result.hasField24 = true;
result.field24_ = value;
return this;
}
public Builder ClearField24() {
+ PrepareBuilder();
result.hasField24 = false;
result.field24_ = false;
return this;
@@ -1908,11 +2004,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField25(value); }
}
public Builder SetField25(int value) {
+ PrepareBuilder();
result.hasField25 = true;
result.field25_ = value;
return this;
}
public Builder ClearField25() {
+ PrepareBuilder();
result.hasField25 = false;
result.field25_ = 0;
return this;
@@ -1927,18 +2025,21 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetField15(global::Google.ProtocolBuffers.TestProtos.SpeedMessage1SubMessage value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.hasField15 = true;
result.field15_ = value;
return this;
}
public Builder SetField15(global::Google.ProtocolBuffers.TestProtos.SpeedMessage1SubMessage.Builder builderForValue) {
pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue");
+ PrepareBuilder();
result.hasField15 = true;
result.field15_ = builderForValue.Build();
return this;
}
public Builder MergeField15(global::Google.ProtocolBuffers.TestProtos.SpeedMessage1SubMessage value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
if (result.hasField15 &&
result.field15_ != global::Google.ProtocolBuffers.TestProtos.SpeedMessage1SubMessage.DefaultInstance) {
result.field15_ = global::Google.ProtocolBuffers.TestProtos.SpeedMessage1SubMessage.CreateBuilder(result.field15_).MergeFrom(value).BuildPartial();
@@ -1949,6 +2050,7 @@ namespace Google.ProtocolBuffers.TestProtos { return this;
}
public Builder ClearField15() {
+ PrepareBuilder();
result.hasField15 = false;
result.field15_ = global::Google.ProtocolBuffers.TestProtos.SpeedMessage1SubMessage.DefaultInstance;
return this;
@@ -1962,11 +2064,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField78(value); }
}
public Builder SetField78(bool value) {
+ PrepareBuilder();
result.hasField78 = true;
result.field78_ = value;
return this;
}
public Builder ClearField78() {
+ PrepareBuilder();
result.hasField78 = false;
result.field78_ = false;
return this;
@@ -1980,11 +2084,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField67(value); }
}
public Builder SetField67(int value) {
+ PrepareBuilder();
result.hasField67 = true;
result.field67_ = value;
return this;
}
public Builder ClearField67() {
+ PrepareBuilder();
result.hasField67 = false;
result.field67_ = 0;
return this;
@@ -1998,11 +2104,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField68(value); }
}
public Builder SetField68(int value) {
+ PrepareBuilder();
result.hasField68 = true;
result.field68_ = value;
return this;
}
public Builder ClearField68() {
+ PrepareBuilder();
result.hasField68 = false;
result.field68_ = 0;
return this;
@@ -2016,11 +2124,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField128(value); }
}
public Builder SetField128(int value) {
+ PrepareBuilder();
result.hasField128 = true;
result.field128_ = value;
return this;
}
public Builder ClearField128() {
+ PrepareBuilder();
result.hasField128 = false;
result.field128_ = 0;
return this;
@@ -2035,11 +2145,13 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetField129(string value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.hasField129 = true;
result.field129_ = value;
return this;
}
public Builder ClearField129() {
+ PrepareBuilder();
result.hasField129 = false;
result.field129_ = "xxxxxxxxxxxxxxxxxxxxx";
return this;
@@ -2053,11 +2165,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField131(value); }
}
public Builder SetField131(int value) {
+ PrepareBuilder();
result.hasField131 = true;
result.field131_ = value;
return this;
}
public Builder ClearField131() {
+ PrepareBuilder();
result.hasField131 = false;
result.field131_ = 0;
return this;
@@ -2478,7 +2592,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(SpeedMessage1SubMessage prototype) {
- return (Builder) new Builder().MergeFrom(prototype);
+ return new Builder(prototype);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -2488,21 +2602,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder {
get { return this; }
}
- public Builder() {}
+ public Builder() {
+ result = DefaultInstance ?? new SpeedMessage1SubMessage();
+ builderIsReadOnly = result == DefaultInstance;
+ }
+ internal Builder(SpeedMessage1SubMessage cloneFrom) {
+ result = cloneFrom;
+ builderIsReadOnly = true;
+ }
- SpeedMessage1SubMessage result = new SpeedMessage1SubMessage();
+ bool builderIsReadOnly;
+ SpeedMessage1SubMessage result;
+
+ private SpeedMessage1SubMessage PrepareBuilder() {
+ if (builderIsReadOnly) {
+ SpeedMessage1SubMessage original = result;
+ result = new SpeedMessage1SubMessage();
+ builderIsReadOnly = false;
+ MergeFrom(original);
+ }
+ return result;
+ }
+
+ public override bool IsInitialized {
+ get { return result.IsInitialized; }
+ }
protected override SpeedMessage1SubMessage MessageBeingBuilt {
- get { return result; }
+ get { return PrepareBuilder(); }
}
public override Builder Clear() {
- result = new SpeedMessage1SubMessage();
+ result = DefaultInstance ?? new SpeedMessage1SubMessage();
+ builderIsReadOnly = true;
return this;
}
public override Builder Clone() {
- return new Builder().MergeFrom(result);
+ if (builderIsReadOnly) {
+ return new Builder(result);
+ } else {
+ return new Builder().MergeFrom(result);
+ }
}
public override pbd::MessageDescriptor DescriptorForType {
@@ -2514,12 +2655,11 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override SpeedMessage1SubMessage BuildPartial() {
- if (result == null) {
- throw new global::System.InvalidOperationException("build() has already been called on this Builder");
+ if (builderIsReadOnly) {
+ return result;
}
- SpeedMessage1SubMessage returnMe = result;
- result = null;
- return returnMe;
+ builderIsReadOnly = true;
+ return result;
}
public override Builder MergeFrom(pb::IMessage other) {
@@ -2533,6 +2673,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder MergeFrom(SpeedMessage1SubMessage other) {
if (other == global::Google.ProtocolBuffers.TestProtos.SpeedMessage1SubMessage.DefaultInstance) return this;
+ PrepareBuilder();
if (other.HasField1) {
Field1 = other.Field1;
}
@@ -2602,6 +2743,7 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
+ PrepareBuilder();
pb::UnknownFieldSet.Builder unknownFields = null;
uint tag;
string field_name;
@@ -2733,11 +2875,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField1(value); }
}
public Builder SetField1(int value) {
+ PrepareBuilder();
result.hasField1 = true;
result.field1_ = value;
return this;
}
public Builder ClearField1() {
+ PrepareBuilder();
result.hasField1 = false;
result.field1_ = 0;
return this;
@@ -2751,11 +2895,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField2(value); }
}
public Builder SetField2(int value) {
+ PrepareBuilder();
result.hasField2 = true;
result.field2_ = value;
return this;
}
public Builder ClearField2() {
+ PrepareBuilder();
result.hasField2 = false;
result.field2_ = 0;
return this;
@@ -2769,11 +2915,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField3(value); }
}
public Builder SetField3(int value) {
+ PrepareBuilder();
result.hasField3 = true;
result.field3_ = value;
return this;
}
public Builder ClearField3() {
+ PrepareBuilder();
result.hasField3 = false;
result.field3_ = 0;
return this;
@@ -2788,11 +2936,13 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetField15(string value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.hasField15 = true;
result.field15_ = value;
return this;
}
public Builder ClearField15() {
+ PrepareBuilder();
result.hasField15 = false;
result.field15_ = "";
return this;
@@ -2806,11 +2956,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField12(value); }
}
public Builder SetField12(bool value) {
+ PrepareBuilder();
result.hasField12 = true;
result.field12_ = value;
return this;
}
public Builder ClearField12() {
+ PrepareBuilder();
result.hasField12 = false;
result.field12_ = true;
return this;
@@ -2824,11 +2976,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField13(value); }
}
public Builder SetField13(long value) {
+ PrepareBuilder();
result.hasField13 = true;
result.field13_ = value;
return this;
}
public Builder ClearField13() {
+ PrepareBuilder();
result.hasField13 = false;
result.field13_ = 0L;
return this;
@@ -2842,11 +2996,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField14(value); }
}
public Builder SetField14(long value) {
+ PrepareBuilder();
result.hasField14 = true;
result.field14_ = value;
return this;
}
public Builder ClearField14() {
+ PrepareBuilder();
result.hasField14 = false;
result.field14_ = 0L;
return this;
@@ -2860,11 +3016,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField16(value); }
}
public Builder SetField16(int value) {
+ PrepareBuilder();
result.hasField16 = true;
result.field16_ = value;
return this;
}
public Builder ClearField16() {
+ PrepareBuilder();
result.hasField16 = false;
result.field16_ = 0;
return this;
@@ -2878,11 +3036,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField19(value); }
}
public Builder SetField19(int value) {
+ PrepareBuilder();
result.hasField19 = true;
result.field19_ = value;
return this;
}
public Builder ClearField19() {
+ PrepareBuilder();
result.hasField19 = false;
result.field19_ = 2;
return this;
@@ -2896,11 +3056,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField20(value); }
}
public Builder SetField20(bool value) {
+ PrepareBuilder();
result.hasField20 = true;
result.field20_ = value;
return this;
}
public Builder ClearField20() {
+ PrepareBuilder();
result.hasField20 = false;
result.field20_ = true;
return this;
@@ -2914,11 +3076,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField28(value); }
}
public Builder SetField28(bool value) {
+ PrepareBuilder();
result.hasField28 = true;
result.field28_ = value;
return this;
}
public Builder ClearField28() {
+ PrepareBuilder();
result.hasField28 = false;
result.field28_ = true;
return this;
@@ -2934,11 +3098,13 @@ namespace Google.ProtocolBuffers.TestProtos { }
[global::System.CLSCompliant(false)]
public Builder SetField21(ulong value) {
+ PrepareBuilder();
result.hasField21 = true;
result.field21_ = value;
return this;
}
public Builder ClearField21() {
+ PrepareBuilder();
result.hasField21 = false;
result.field21_ = 0;
return this;
@@ -2952,11 +3118,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField22(value); }
}
public Builder SetField22(int value) {
+ PrepareBuilder();
result.hasField22 = true;
result.field22_ = value;
return this;
}
public Builder ClearField22() {
+ PrepareBuilder();
result.hasField22 = false;
result.field22_ = 0;
return this;
@@ -2970,11 +3138,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField23(value); }
}
public Builder SetField23(bool value) {
+ PrepareBuilder();
result.hasField23 = true;
result.field23_ = value;
return this;
}
public Builder ClearField23() {
+ PrepareBuilder();
result.hasField23 = false;
result.field23_ = false;
return this;
@@ -2988,11 +3158,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField206(value); }
}
public Builder SetField206(bool value) {
+ PrepareBuilder();
result.hasField206 = true;
result.field206_ = value;
return this;
}
public Builder ClearField206() {
+ PrepareBuilder();
result.hasField206 = false;
result.field206_ = false;
return this;
@@ -3008,11 +3180,13 @@ namespace Google.ProtocolBuffers.TestProtos { }
[global::System.CLSCompliant(false)]
public Builder SetField203(uint value) {
+ PrepareBuilder();
result.hasField203 = true;
result.field203_ = value;
return this;
}
public Builder ClearField203() {
+ PrepareBuilder();
result.hasField203 = false;
result.field203_ = 0;
return this;
@@ -3026,11 +3200,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField204(value); }
}
public Builder SetField204(int value) {
+ PrepareBuilder();
result.hasField204 = true;
result.field204_ = value;
return this;
}
public Builder ClearField204() {
+ PrepareBuilder();
result.hasField204 = false;
result.field204_ = 0;
return this;
@@ -3045,11 +3221,13 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetField205(string value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.hasField205 = true;
result.field205_ = value;
return this;
}
public Builder ClearField205() {
+ PrepareBuilder();
result.hasField205 = false;
result.field205_ = "";
return this;
@@ -3065,11 +3243,13 @@ namespace Google.ProtocolBuffers.TestProtos { }
[global::System.CLSCompliant(false)]
public Builder SetField207(ulong value) {
+ PrepareBuilder();
result.hasField207 = true;
result.field207_ = value;
return this;
}
public Builder ClearField207() {
+ PrepareBuilder();
result.hasField207 = false;
result.field207_ = 0UL;
return this;
@@ -3085,11 +3265,13 @@ namespace Google.ProtocolBuffers.TestProtos { }
[global::System.CLSCompliant(false)]
public Builder SetField300(ulong value) {
+ PrepareBuilder();
result.hasField300 = true;
result.field300_ = value;
return this;
}
public Builder ClearField300() {
+ PrepareBuilder();
result.hasField300 = false;
result.field300_ = 0UL;
return this;
@@ -3498,7 +3680,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(Group1 prototype) {
- return (Builder) new Builder().MergeFrom(prototype);
+ return new Builder(prototype);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -3508,21 +3690,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder {
get { return this; }
}
- public Builder() {}
+ public Builder() {
+ result = DefaultInstance ?? new Group1();
+ builderIsReadOnly = result == DefaultInstance;
+ }
+ internal Builder(Group1 cloneFrom) {
+ result = cloneFrom;
+ builderIsReadOnly = true;
+ }
+
+ bool builderIsReadOnly;
+ Group1 result;
+
+ private Group1 PrepareBuilder() {
+ if (builderIsReadOnly) {
+ Group1 original = result;
+ result = new Group1();
+ builderIsReadOnly = false;
+ MergeFrom(original);
+ }
+ return result;
+ }
- Group1 result = new Group1();
+ public override bool IsInitialized {
+ get { return result.IsInitialized; }
+ }
protected override Group1 MessageBeingBuilt {
- get { return result; }
+ get { return PrepareBuilder(); }
}
public override Builder Clear() {
- result = new Group1();
+ result = DefaultInstance ?? new Group1();
+ builderIsReadOnly = true;
return this;
}
public override Builder Clone() {
- return new Builder().MergeFrom(result);
+ if (builderIsReadOnly) {
+ return new Builder(result);
+ } else {
+ return new Builder().MergeFrom(result);
+ }
}
public override pbd::MessageDescriptor DescriptorForType {
@@ -3534,15 +3743,14 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override Group1 BuildPartial() {
- if (result == null) {
- throw new global::System.InvalidOperationException("build() has already been called on this Builder");
+ if (builderIsReadOnly) {
+ return result;
}
result.field14_.MakeReadOnly();
result.field22_.MakeReadOnly();
result.field73_.MakeReadOnly();
- Group1 returnMe = result;
- result = null;
- return returnMe;
+ builderIsReadOnly = true;
+ return result;
}
public override Builder MergeFrom(pb::IMessage other) {
@@ -3556,6 +3764,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder MergeFrom(Group1 other) {
if (other == global::Google.ProtocolBuffers.TestProtos.SpeedMessage2.Types.Group1.DefaultInstance) return this;
+ PrepareBuilder();
if (other.HasField11) {
Field11 = other.Field11;
}
@@ -3613,6 +3822,7 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
+ PrepareBuilder();
pb::UnknownFieldSet.Builder unknownFields = null;
uint tag;
string field_name;
@@ -3734,11 +3944,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField11(value); }
}
public Builder SetField11(float value) {
+ PrepareBuilder();
result.hasField11 = true;
result.field11_ = value;
return this;
}
public Builder ClearField11() {
+ PrepareBuilder();
result.hasField11 = false;
result.field11_ = 0F;
return this;
@@ -3752,11 +3964,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField26(value); }
}
public Builder SetField26(float value) {
+ PrepareBuilder();
result.hasField26 = true;
result.field26_ = value;
return this;
}
public Builder ClearField26() {
+ PrepareBuilder();
result.hasField26 = false;
result.field26_ = 0F;
return this;
@@ -3771,11 +3985,13 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetField12(string value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.hasField12 = true;
result.field12_ = value;
return this;
}
public Builder ClearField12() {
+ PrepareBuilder();
result.hasField12 = false;
result.field12_ = "";
return this;
@@ -3790,18 +4006,20 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetField13(string value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.hasField13 = true;
result.field13_ = value;
return this;
}
public Builder ClearField13() {
+ PrepareBuilder();
result.hasField13 = false;
result.field13_ = "";
return this;
}
public pbc::IPopsicleList<string> Field14List {
- get { return result.field14_; }
+ get { return PrepareBuilder().field14_; }
}
public int Field14Count {
get { return result.Field14Count; }
@@ -3811,19 +4029,23 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetField14(int index, string value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.field14_[index] = value;
return this;
}
public Builder AddField14(string value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.field14_.Add(value);
return this;
}
public Builder AddRangeField14(scg::IEnumerable<string> values) {
+ PrepareBuilder();
base.AddRange(values, result.field14_);
return this;
}
public Builder ClearField14() {
+ PrepareBuilder();
result.field14_.Clear();
return this;
}
@@ -3838,11 +4060,13 @@ namespace Google.ProtocolBuffers.TestProtos { }
[global::System.CLSCompliant(false)]
public Builder SetField15(ulong value) {
+ PrepareBuilder();
result.hasField15 = true;
result.field15_ = value;
return this;
}
public Builder ClearField15() {
+ PrepareBuilder();
result.hasField15 = false;
result.field15_ = 0UL;
return this;
@@ -3856,11 +4080,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField5(value); }
}
public Builder SetField5(int value) {
+ PrepareBuilder();
result.hasField5 = true;
result.field5_ = value;
return this;
}
public Builder ClearField5() {
+ PrepareBuilder();
result.hasField5 = false;
result.field5_ = 0;
return this;
@@ -3875,11 +4101,13 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetField27(string value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.hasField27 = true;
result.field27_ = value;
return this;
}
public Builder ClearField27() {
+ PrepareBuilder();
result.hasField27 = false;
result.field27_ = "";
return this;
@@ -3893,11 +4121,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField28(value); }
}
public Builder SetField28(int value) {
+ PrepareBuilder();
result.hasField28 = true;
result.field28_ = value;
return this;
}
public Builder ClearField28() {
+ PrepareBuilder();
result.hasField28 = false;
result.field28_ = 0;
return this;
@@ -3912,11 +4142,13 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetField29(string value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.hasField29 = true;
result.field29_ = value;
return this;
}
public Builder ClearField29() {
+ PrepareBuilder();
result.hasField29 = false;
result.field29_ = "";
return this;
@@ -3931,18 +4163,20 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetField16(string value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.hasField16 = true;
result.field16_ = value;
return this;
}
public Builder ClearField16() {
+ PrepareBuilder();
result.hasField16 = false;
result.field16_ = "";
return this;
}
public pbc::IPopsicleList<string> Field22List {
- get { return result.field22_; }
+ get { return PrepareBuilder().field22_; }
}
public int Field22Count {
get { return result.Field22Count; }
@@ -3952,25 +4186,29 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetField22(int index, string value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.field22_[index] = value;
return this;
}
public Builder AddField22(string value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.field22_.Add(value);
return this;
}
public Builder AddRangeField22(scg::IEnumerable<string> values) {
+ PrepareBuilder();
base.AddRange(values, result.field22_);
return this;
}
public Builder ClearField22() {
+ PrepareBuilder();
result.field22_.Clear();
return this;
}
public pbc::IPopsicleList<int> Field73List {
- get { return result.field73_; }
+ get { return PrepareBuilder().field73_; }
}
public int Field73Count {
get { return result.Field73Count; }
@@ -3979,18 +4217,22 @@ namespace Google.ProtocolBuffers.TestProtos { return result.GetField73(index);
}
public Builder SetField73(int index, int value) {
+ PrepareBuilder();
result.field73_[index] = value;
return this;
}
public Builder AddField73(int value) {
+ PrepareBuilder();
result.field73_.Add(value);
return this;
}
public Builder AddRangeField73(scg::IEnumerable<int> values) {
+ PrepareBuilder();
base.AddRange(values, result.field73_);
return this;
}
public Builder ClearField73() {
+ PrepareBuilder();
result.field73_.Clear();
return this;
}
@@ -4003,11 +4245,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField20(value); }
}
public Builder SetField20(int value) {
+ PrepareBuilder();
result.hasField20 = true;
result.field20_ = value;
return this;
}
public Builder ClearField20() {
+ PrepareBuilder();
result.hasField20 = false;
result.field20_ = 0;
return this;
@@ -4022,11 +4266,13 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetField24(string value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.hasField24 = true;
result.field24_ = value;
return this;
}
public Builder ClearField24() {
+ PrepareBuilder();
result.hasField24 = false;
result.field24_ = "";
return this;
@@ -4041,18 +4287,21 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetField31(global::Google.ProtocolBuffers.TestProtos.SpeedMessage2GroupedMessage value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.hasField31 = true;
result.field31_ = value;
return this;
}
public Builder SetField31(global::Google.ProtocolBuffers.TestProtos.SpeedMessage2GroupedMessage.Builder builderForValue) {
pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue");
+ PrepareBuilder();
result.hasField31 = true;
result.field31_ = builderForValue.Build();
return this;
}
public Builder MergeField31(global::Google.ProtocolBuffers.TestProtos.SpeedMessage2GroupedMessage value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
if (result.hasField31 &&
result.field31_ != global::Google.ProtocolBuffers.TestProtos.SpeedMessage2GroupedMessage.DefaultInstance) {
result.field31_ = global::Google.ProtocolBuffers.TestProtos.SpeedMessage2GroupedMessage.CreateBuilder(result.field31_).MergeFrom(value).BuildPartial();
@@ -4063,6 +4312,7 @@ namespace Google.ProtocolBuffers.TestProtos { return this;
}
public Builder ClearField31() {
+ PrepareBuilder();
result.hasField31 = false;
result.field31_ = global::Google.ProtocolBuffers.TestProtos.SpeedMessage2GroupedMessage.DefaultInstance;
return this;
@@ -4638,7 +4888,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(SpeedMessage2 prototype) {
- return (Builder) new Builder().MergeFrom(prototype);
+ return new Builder(prototype);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -4648,21 +4898,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder {
get { return this; }
}
- public Builder() {}
+ public Builder() {
+ result = DefaultInstance ?? new SpeedMessage2();
+ builderIsReadOnly = result == DefaultInstance;
+ }
+ internal Builder(SpeedMessage2 cloneFrom) {
+ result = cloneFrom;
+ builderIsReadOnly = true;
+ }
- SpeedMessage2 result = new SpeedMessage2();
+ bool builderIsReadOnly;
+ SpeedMessage2 result;
+
+ private SpeedMessage2 PrepareBuilder() {
+ if (builderIsReadOnly) {
+ SpeedMessage2 original = result;
+ result = new SpeedMessage2();
+ builderIsReadOnly = false;
+ MergeFrom(original);
+ }
+ return result;
+ }
+
+ public override bool IsInitialized {
+ get { return result.IsInitialized; }
+ }
protected override SpeedMessage2 MessageBeingBuilt {
- get { return result; }
+ get { return PrepareBuilder(); }
}
public override Builder Clear() {
- result = new SpeedMessage2();
+ result = DefaultInstance ?? new SpeedMessage2();
+ builderIsReadOnly = true;
return this;
}
public override Builder Clone() {
- return new Builder().MergeFrom(result);
+ if (builderIsReadOnly) {
+ return new Builder(result);
+ } else {
+ return new Builder().MergeFrom(result);
+ }
}
public override pbd::MessageDescriptor DescriptorForType {
@@ -4674,16 +4951,15 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override SpeedMessage2 BuildPartial() {
- if (result == null) {
- throw new global::System.InvalidOperationException("build() has already been called on this Builder");
+ if (builderIsReadOnly) {
+ return result;
}
result.group1_.MakeReadOnly();
result.field128_.MakeReadOnly();
result.field127_.MakeReadOnly();
result.field130_.MakeReadOnly();
- SpeedMessage2 returnMe = result;
- result = null;
- return returnMe;
+ builderIsReadOnly = true;
+ return result;
}
public override Builder MergeFrom(pb::IMessage other) {
@@ -4697,6 +4973,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder MergeFrom(SpeedMessage2 other) {
if (other == global::Google.ProtocolBuffers.TestProtos.SpeedMessage2.DefaultInstance) return this;
+ PrepareBuilder();
if (other.HasField1) {
Field1 = other.Field1;
}
@@ -4796,6 +5073,7 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
+ PrepareBuilder();
pb::UnknownFieldSet.Builder unknownFields = null;
uint tag;
string field_name;
@@ -4969,11 +5247,13 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetField1(string value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.hasField1 = true;
result.field1_ = value;
return this;
}
public Builder ClearField1() {
+ PrepareBuilder();
result.hasField1 = false;
result.field1_ = "";
return this;
@@ -4987,11 +5267,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField3(value); }
}
public Builder SetField3(long value) {
+ PrepareBuilder();
result.hasField3 = true;
result.field3_ = value;
return this;
}
public Builder ClearField3() {
+ PrepareBuilder();
result.hasField3 = false;
result.field3_ = 0L;
return this;
@@ -5005,11 +5287,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField4(value); }
}
public Builder SetField4(long value) {
+ PrepareBuilder();
result.hasField4 = true;
result.field4_ = value;
return this;
}
public Builder ClearField4() {
+ PrepareBuilder();
result.hasField4 = false;
result.field4_ = 0L;
return this;
@@ -5023,11 +5307,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField30(value); }
}
public Builder SetField30(long value) {
+ PrepareBuilder();
result.hasField30 = true;
result.field30_ = value;
return this;
}
public Builder ClearField30() {
+ PrepareBuilder();
result.hasField30 = false;
result.field30_ = 0L;
return this;
@@ -5041,11 +5327,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField75(value); }
}
public Builder SetField75(bool value) {
+ PrepareBuilder();
result.hasField75 = true;
result.field75_ = value;
return this;
}
public Builder ClearField75() {
+ PrepareBuilder();
result.hasField75 = false;
result.field75_ = false;
return this;
@@ -5060,11 +5348,13 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetField6(string value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.hasField6 = true;
result.field6_ = value;
return this;
}
public Builder ClearField6() {
+ PrepareBuilder();
result.hasField6 = false;
result.field6_ = "";
return this;
@@ -5079,11 +5369,13 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetField2(pb::ByteString value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.hasField2 = true;
result.field2_ = value;
return this;
}
public Builder ClearField2() {
+ PrepareBuilder();
result.hasField2 = false;
result.field2_ = pb::ByteString.Empty;
return this;
@@ -5097,11 +5389,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField21(value); }
}
public Builder SetField21(int value) {
+ PrepareBuilder();
result.hasField21 = true;
result.field21_ = value;
return this;
}
public Builder ClearField21() {
+ PrepareBuilder();
result.hasField21 = false;
result.field21_ = 0;
return this;
@@ -5115,11 +5409,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField71(value); }
}
public Builder SetField71(int value) {
+ PrepareBuilder();
result.hasField71 = true;
result.field71_ = value;
return this;
}
public Builder ClearField71() {
+ PrepareBuilder();
result.hasField71 = false;
result.field71_ = 0;
return this;
@@ -5133,11 +5429,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField25(value); }
}
public Builder SetField25(float value) {
+ PrepareBuilder();
result.hasField25 = true;
result.field25_ = value;
return this;
}
public Builder ClearField25() {
+ PrepareBuilder();
result.hasField25 = false;
result.field25_ = 0F;
return this;
@@ -5151,11 +5449,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField109(value); }
}
public Builder SetField109(int value) {
+ PrepareBuilder();
result.hasField109 = true;
result.field109_ = value;
return this;
}
public Builder ClearField109() {
+ PrepareBuilder();
result.hasField109 = false;
result.field109_ = 0;
return this;
@@ -5169,11 +5469,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField210(value); }
}
public Builder SetField210(int value) {
+ PrepareBuilder();
result.hasField210 = true;
result.field210_ = value;
return this;
}
public Builder ClearField210() {
+ PrepareBuilder();
result.hasField210 = false;
result.field210_ = 0;
return this;
@@ -5187,11 +5489,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField211(value); }
}
public Builder SetField211(int value) {
+ PrepareBuilder();
result.hasField211 = true;
result.field211_ = value;
return this;
}
public Builder ClearField211() {
+ PrepareBuilder();
result.hasField211 = false;
result.field211_ = 0;
return this;
@@ -5205,11 +5509,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField212(value); }
}
public Builder SetField212(int value) {
+ PrepareBuilder();
result.hasField212 = true;
result.field212_ = value;
return this;
}
public Builder ClearField212() {
+ PrepareBuilder();
result.hasField212 = false;
result.field212_ = 0;
return this;
@@ -5223,11 +5529,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField213(value); }
}
public Builder SetField213(int value) {
+ PrepareBuilder();
result.hasField213 = true;
result.field213_ = value;
return this;
}
public Builder ClearField213() {
+ PrepareBuilder();
result.hasField213 = false;
result.field213_ = 0;
return this;
@@ -5241,11 +5549,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField216(value); }
}
public Builder SetField216(int value) {
+ PrepareBuilder();
result.hasField216 = true;
result.field216_ = value;
return this;
}
public Builder ClearField216() {
+ PrepareBuilder();
result.hasField216 = false;
result.field216_ = 0;
return this;
@@ -5259,11 +5569,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField217(value); }
}
public Builder SetField217(int value) {
+ PrepareBuilder();
result.hasField217 = true;
result.field217_ = value;
return this;
}
public Builder ClearField217() {
+ PrepareBuilder();
result.hasField217 = false;
result.field217_ = 0;
return this;
@@ -5277,11 +5589,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField218(value); }
}
public Builder SetField218(int value) {
+ PrepareBuilder();
result.hasField218 = true;
result.field218_ = value;
return this;
}
public Builder ClearField218() {
+ PrepareBuilder();
result.hasField218 = false;
result.field218_ = 0;
return this;
@@ -5295,11 +5609,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField220(value); }
}
public Builder SetField220(int value) {
+ PrepareBuilder();
result.hasField220 = true;
result.field220_ = value;
return this;
}
public Builder ClearField220() {
+ PrepareBuilder();
result.hasField220 = false;
result.field220_ = 0;
return this;
@@ -5313,11 +5629,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField221(value); }
}
public Builder SetField221(int value) {
+ PrepareBuilder();
result.hasField221 = true;
result.field221_ = value;
return this;
}
public Builder ClearField221() {
+ PrepareBuilder();
result.hasField221 = false;
result.field221_ = 0;
return this;
@@ -5331,11 +5649,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField222(value); }
}
public Builder SetField222(float value) {
+ PrepareBuilder();
result.hasField222 = true;
result.field222_ = value;
return this;
}
public Builder ClearField222() {
+ PrepareBuilder();
result.hasField222 = false;
result.field222_ = 0F;
return this;
@@ -5349,18 +5669,20 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField63(value); }
}
public Builder SetField63(int value) {
+ PrepareBuilder();
result.hasField63 = true;
result.field63_ = value;
return this;
}
public Builder ClearField63() {
+ PrepareBuilder();
result.hasField63 = false;
result.field63_ = 0;
return this;
}
public pbc::IPopsicleList<global::Google.ProtocolBuffers.TestProtos.SpeedMessage2.Types.Group1> Group1List {
- get { return result.group1_; }
+ get { return PrepareBuilder().group1_; }
}
public int Group1Count {
get { return result.Group1Count; }
@@ -5370,35 +5692,41 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetGroup1(int index, global::Google.ProtocolBuffers.TestProtos.SpeedMessage2.Types.Group1 value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.group1_[index] = value;
return this;
}
public Builder SetGroup1(int index, global::Google.ProtocolBuffers.TestProtos.SpeedMessage2.Types.Group1.Builder builderForValue) {
pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue");
+ PrepareBuilder();
result.group1_[index] = builderForValue.Build();
return this;
}
public Builder AddGroup1(global::Google.ProtocolBuffers.TestProtos.SpeedMessage2.Types.Group1 value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.group1_.Add(value);
return this;
}
public Builder AddGroup1(global::Google.ProtocolBuffers.TestProtos.SpeedMessage2.Types.Group1.Builder builderForValue) {
pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue");
+ PrepareBuilder();
result.group1_.Add(builderForValue.Build());
return this;
}
public Builder AddRangeGroup1(scg::IEnumerable<global::Google.ProtocolBuffers.TestProtos.SpeedMessage2.Types.Group1> values) {
+ PrepareBuilder();
base.AddRange(values, result.group1_);
return this;
}
public Builder ClearGroup1() {
+ PrepareBuilder();
result.group1_.Clear();
return this;
}
public pbc::IPopsicleList<string> Field128List {
- get { return result.field128_; }
+ get { return PrepareBuilder().field128_; }
}
public int Field128Count {
get { return result.Field128Count; }
@@ -5408,19 +5736,23 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetField128(int index, string value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.field128_[index] = value;
return this;
}
public Builder AddField128(string value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.field128_.Add(value);
return this;
}
public Builder AddRangeField128(scg::IEnumerable<string> values) {
+ PrepareBuilder();
base.AddRange(values, result.field128_);
return this;
}
public Builder ClearField128() {
+ PrepareBuilder();
result.field128_.Clear();
return this;
}
@@ -5433,18 +5765,20 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField131(value); }
}
public Builder SetField131(long value) {
+ PrepareBuilder();
result.hasField131 = true;
result.field131_ = value;
return this;
}
public Builder ClearField131() {
+ PrepareBuilder();
result.hasField131 = false;
result.field131_ = 0L;
return this;
}
public pbc::IPopsicleList<string> Field127List {
- get { return result.field127_; }
+ get { return PrepareBuilder().field127_; }
}
public int Field127Count {
get { return result.Field127Count; }
@@ -5454,19 +5788,23 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetField127(int index, string value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.field127_[index] = value;
return this;
}
public Builder AddField127(string value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.field127_.Add(value);
return this;
}
public Builder AddRangeField127(scg::IEnumerable<string> values) {
+ PrepareBuilder();
base.AddRange(values, result.field127_);
return this;
}
public Builder ClearField127() {
+ PrepareBuilder();
result.field127_.Clear();
return this;
}
@@ -5479,18 +5817,20 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField129(value); }
}
public Builder SetField129(int value) {
+ PrepareBuilder();
result.hasField129 = true;
result.field129_ = value;
return this;
}
public Builder ClearField129() {
+ PrepareBuilder();
result.hasField129 = false;
result.field129_ = 0;
return this;
}
public pbc::IPopsicleList<long> Field130List {
- get { return result.field130_; }
+ get { return PrepareBuilder().field130_; }
}
public int Field130Count {
get { return result.Field130Count; }
@@ -5499,18 +5839,22 @@ namespace Google.ProtocolBuffers.TestProtos { return result.GetField130(index);
}
public Builder SetField130(int index, long value) {
+ PrepareBuilder();
result.field130_[index] = value;
return this;
}
public Builder AddField130(long value) {
+ PrepareBuilder();
result.field130_.Add(value);
return this;
}
public Builder AddRangeField130(scg::IEnumerable<long> values) {
+ PrepareBuilder();
base.AddRange(values, result.field130_);
return this;
}
public Builder ClearField130() {
+ PrepareBuilder();
result.field130_.Clear();
return this;
}
@@ -5523,11 +5867,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField205(value); }
}
public Builder SetField205(bool value) {
+ PrepareBuilder();
result.hasField205 = true;
result.field205_ = value;
return this;
}
public Builder ClearField205() {
+ PrepareBuilder();
result.hasField205 = false;
result.field205_ = false;
return this;
@@ -5541,11 +5887,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField206(value); }
}
public Builder SetField206(bool value) {
+ PrepareBuilder();
result.hasField206 = true;
result.field206_ = value;
return this;
}
public Builder ClearField206() {
+ PrepareBuilder();
result.hasField206 = false;
result.field206_ = false;
return this;
@@ -5818,7 +6166,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(SpeedMessage2GroupedMessage prototype) {
- return (Builder) new Builder().MergeFrom(prototype);
+ return new Builder(prototype);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -5828,21 +6176,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder {
get { return this; }
}
- public Builder() {}
+ public Builder() {
+ result = DefaultInstance ?? new SpeedMessage2GroupedMessage();
+ builderIsReadOnly = result == DefaultInstance;
+ }
+ internal Builder(SpeedMessage2GroupedMessage cloneFrom) {
+ result = cloneFrom;
+ builderIsReadOnly = true;
+ }
- SpeedMessage2GroupedMessage result = new SpeedMessage2GroupedMessage();
+ bool builderIsReadOnly;
+ SpeedMessage2GroupedMessage result;
+
+ private SpeedMessage2GroupedMessage PrepareBuilder() {
+ if (builderIsReadOnly) {
+ SpeedMessage2GroupedMessage original = result;
+ result = new SpeedMessage2GroupedMessage();
+ builderIsReadOnly = false;
+ MergeFrom(original);
+ }
+ return result;
+ }
+
+ public override bool IsInitialized {
+ get { return result.IsInitialized; }
+ }
protected override SpeedMessage2GroupedMessage MessageBeingBuilt {
- get { return result; }
+ get { return PrepareBuilder(); }
}
public override Builder Clear() {
- result = new SpeedMessage2GroupedMessage();
+ result = DefaultInstance ?? new SpeedMessage2GroupedMessage();
+ builderIsReadOnly = true;
return this;
}
public override Builder Clone() {
- return new Builder().MergeFrom(result);
+ if (builderIsReadOnly) {
+ return new Builder(result);
+ } else {
+ return new Builder().MergeFrom(result);
+ }
}
public override pbd::MessageDescriptor DescriptorForType {
@@ -5854,12 +6229,11 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override SpeedMessage2GroupedMessage BuildPartial() {
- if (result == null) {
- throw new global::System.InvalidOperationException("build() has already been called on this Builder");
+ if (builderIsReadOnly) {
+ return result;
}
- SpeedMessage2GroupedMessage returnMe = result;
- result = null;
- return returnMe;
+ builderIsReadOnly = true;
+ return result;
}
public override Builder MergeFrom(pb::IMessage other) {
@@ -5873,6 +6247,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder MergeFrom(SpeedMessage2GroupedMessage other) {
if (other == global::Google.ProtocolBuffers.TestProtos.SpeedMessage2GroupedMessage.DefaultInstance) return this;
+ PrepareBuilder();
if (other.HasField1) {
Field1 = other.Field1;
}
@@ -5915,6 +6290,7 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
+ PrepareBuilder();
pb::UnknownFieldSet.Builder unknownFields = null;
uint tag;
string field_name;
@@ -6010,11 +6386,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField1(value); }
}
public Builder SetField1(float value) {
+ PrepareBuilder();
result.hasField1 = true;
result.field1_ = value;
return this;
}
public Builder ClearField1() {
+ PrepareBuilder();
result.hasField1 = false;
result.field1_ = 0F;
return this;
@@ -6028,11 +6406,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField2(value); }
}
public Builder SetField2(float value) {
+ PrepareBuilder();
result.hasField2 = true;
result.field2_ = value;
return this;
}
public Builder ClearField2() {
+ PrepareBuilder();
result.hasField2 = false;
result.field2_ = 0F;
return this;
@@ -6046,11 +6426,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField3(value); }
}
public Builder SetField3(float value) {
+ PrepareBuilder();
result.hasField3 = true;
result.field3_ = value;
return this;
}
public Builder ClearField3() {
+ PrepareBuilder();
result.hasField3 = false;
result.field3_ = 0F;
return this;
@@ -6064,11 +6446,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField4(value); }
}
public Builder SetField4(bool value) {
+ PrepareBuilder();
result.hasField4 = true;
result.field4_ = value;
return this;
}
public Builder ClearField4() {
+ PrepareBuilder();
result.hasField4 = false;
result.field4_ = false;
return this;
@@ -6082,11 +6466,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField5(value); }
}
public Builder SetField5(bool value) {
+ PrepareBuilder();
result.hasField5 = true;
result.field5_ = value;
return this;
}
public Builder ClearField5() {
+ PrepareBuilder();
result.hasField5 = false;
result.field5_ = false;
return this;
@@ -6100,11 +6486,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField6(value); }
}
public Builder SetField6(bool value) {
+ PrepareBuilder();
result.hasField6 = true;
result.field6_ = value;
return this;
}
public Builder ClearField6() {
+ PrepareBuilder();
result.hasField6 = false;
result.field6_ = true;
return this;
@@ -6118,11 +6506,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField7(value); }
}
public Builder SetField7(bool value) {
+ PrepareBuilder();
result.hasField7 = true;
result.field7_ = value;
return this;
}
public Builder ClearField7() {
+ PrepareBuilder();
result.hasField7 = false;
result.field7_ = false;
return this;
@@ -6136,11 +6526,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField8(value); }
}
public Builder SetField8(float value) {
+ PrepareBuilder();
result.hasField8 = true;
result.field8_ = value;
return this;
}
public Builder ClearField8() {
+ PrepareBuilder();
result.hasField8 = false;
result.field8_ = 0F;
return this;
@@ -6154,11 +6546,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField9(value); }
}
public Builder SetField9(bool value) {
+ PrepareBuilder();
result.hasField9 = true;
result.field9_ = value;
return this;
}
public Builder ClearField9() {
+ PrepareBuilder();
result.hasField9 = false;
result.field9_ = false;
return this;
@@ -6172,11 +6566,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField10(value); }
}
public Builder SetField10(float value) {
+ PrepareBuilder();
result.hasField10 = true;
result.field10_ = value;
return this;
}
public Builder ClearField10() {
+ PrepareBuilder();
result.hasField10 = false;
result.field10_ = 0F;
return this;
@@ -6190,11 +6586,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetField11(value); }
}
public Builder SetField11(long value) {
+ PrepareBuilder();
result.hasField11 = true;
result.field11_ = value;
return this;
}
public Builder ClearField11() {
+ PrepareBuilder();
result.hasField11 = false;
result.field11_ = 0L;
return this;
diff --git a/src/ProtocolBuffers.Test/TestProtos/UnitTestImportLiteProtoFile.cs b/src/ProtocolBuffers.Test/TestProtos/UnitTestImportLiteProtoFile.cs index a96833be..0df40f42 100644 --- a/src/ProtocolBuffers.Test/TestProtos/UnitTestImportLiteProtoFile.cs +++ b/src/ProtocolBuffers.Test/TestProtos/UnitTestImportLiteProtoFile.cs @@ -150,7 +150,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(ImportMessageLite prototype) {
- return (Builder) new Builder().MergeFrom(prototype);
+ return new Builder(prototype);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -160,21 +160,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder {
get { return this; }
}
- public Builder() {}
+ public Builder() {
+ result = DefaultInstance ?? new ImportMessageLite();
+ builderIsReadOnly = result == DefaultInstance;
+ }
+ internal Builder(ImportMessageLite cloneFrom) {
+ result = cloneFrom;
+ builderIsReadOnly = true;
+ }
+
+ bool builderIsReadOnly;
+ ImportMessageLite result;
- ImportMessageLite result = new ImportMessageLite();
+ private ImportMessageLite PrepareBuilder() {
+ if (builderIsReadOnly) {
+ ImportMessageLite original = result;
+ result = new ImportMessageLite();
+ builderIsReadOnly = false;
+ MergeFrom(original);
+ }
+ return result;
+ }
+
+ public override bool IsInitialized {
+ get { return result.IsInitialized; }
+ }
protected override ImportMessageLite MessageBeingBuilt {
- get { return result; }
+ get { return PrepareBuilder(); }
}
public override Builder Clear() {
- result = new ImportMessageLite();
+ result = DefaultInstance ?? new ImportMessageLite();
+ builderIsReadOnly = true;
return this;
}
public override Builder Clone() {
- return new Builder().MergeFrom(result);
+ if (builderIsReadOnly) {
+ return new Builder(result);
+ } else {
+ return new Builder().MergeFrom(result);
+ }
}
public override ImportMessageLite DefaultInstanceForType {
@@ -182,12 +209,11 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override ImportMessageLite BuildPartial() {
- if (result == null) {
- throw new global::System.InvalidOperationException("build() has already been called on this Builder");
+ if (builderIsReadOnly) {
+ return result;
}
- ImportMessageLite returnMe = result;
- result = null;
- return returnMe;
+ builderIsReadOnly = true;
+ return result;
}
public override Builder MergeFrom(pb::IMessageLite other) {
@@ -201,6 +227,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder MergeFrom(ImportMessageLite other) {
if (other == global::Google.ProtocolBuffers.TestProtos.ImportMessageLite.DefaultInstance) return this;
+ PrepareBuilder();
if (other.HasD) {
D = other.D;
}
@@ -212,6 +239,7 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
+ PrepareBuilder();
uint tag;
string field_name;
while (input.ReadTag(out tag, out field_name)) {
@@ -254,11 +282,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetD(value); }
}
public Builder SetD(int value) {
+ PrepareBuilder();
result.hasD = true;
result.d_ = value;
return this;
}
public Builder ClearD() {
+ PrepareBuilder();
result.hasD = false;
result.d_ = 0;
return this;
diff --git a/src/ProtocolBuffers.Test/TestProtos/UnitTestImportProtoFile.cs b/src/ProtocolBuffers.Test/TestProtos/UnitTestImportProtoFile.cs index 5749c97f..75e746a8 100644 --- a/src/ProtocolBuffers.Test/TestProtos/UnitTestImportProtoFile.cs +++ b/src/ProtocolBuffers.Test/TestProtos/UnitTestImportProtoFile.cs @@ -169,7 +169,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(ImportMessage prototype) {
- return (Builder) new Builder().MergeFrom(prototype);
+ return new Builder(prototype);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -179,21 +179,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder {
get { return this; }
}
- public Builder() {}
+ public Builder() {
+ result = DefaultInstance ?? new ImportMessage();
+ builderIsReadOnly = result == DefaultInstance;
+ }
+ internal Builder(ImportMessage cloneFrom) {
+ result = cloneFrom;
+ builderIsReadOnly = true;
+ }
+
+ bool builderIsReadOnly;
+ ImportMessage result;
- ImportMessage result = new ImportMessage();
+ private ImportMessage PrepareBuilder() {
+ if (builderIsReadOnly) {
+ ImportMessage original = result;
+ result = new ImportMessage();
+ builderIsReadOnly = false;
+ MergeFrom(original);
+ }
+ return result;
+ }
+
+ public override bool IsInitialized {
+ get { return result.IsInitialized; }
+ }
protected override ImportMessage MessageBeingBuilt {
- get { return result; }
+ get { return PrepareBuilder(); }
}
public override Builder Clear() {
- result = new ImportMessage();
+ result = DefaultInstance ?? new ImportMessage();
+ builderIsReadOnly = true;
return this;
}
public override Builder Clone() {
- return new Builder().MergeFrom(result);
+ if (builderIsReadOnly) {
+ return new Builder(result);
+ } else {
+ return new Builder().MergeFrom(result);
+ }
}
public override pbd::MessageDescriptor DescriptorForType {
@@ -205,12 +232,11 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override ImportMessage BuildPartial() {
- if (result == null) {
- throw new global::System.InvalidOperationException("build() has already been called on this Builder");
+ if (builderIsReadOnly) {
+ return result;
}
- ImportMessage returnMe = result;
- result = null;
- return returnMe;
+ builderIsReadOnly = true;
+ return result;
}
public override Builder MergeFrom(pb::IMessage other) {
@@ -224,6 +250,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder MergeFrom(ImportMessage other) {
if (other == global::Google.ProtocolBuffers.TestProtos.ImportMessage.DefaultInstance) return this;
+ PrepareBuilder();
if (other.HasD) {
D = other.D;
}
@@ -236,6 +263,7 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
+ PrepareBuilder();
pb::UnknownFieldSet.Builder unknownFields = null;
uint tag;
string field_name;
@@ -291,11 +319,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetD(value); }
}
public Builder SetD(int value) {
+ PrepareBuilder();
result.hasD = true;
result.d_ = value;
return this;
}
public Builder ClearD() {
+ PrepareBuilder();
result.hasD = false;
result.d_ = 0;
return this;
diff --git a/src/ProtocolBuffers.Test/TestProtos/UnitTestMessageSetProtoFile.cs b/src/ProtocolBuffers.Test/TestProtos/UnitTestMessageSetProtoFile.cs index 8a6bb589..f51b2f42 100644 --- a/src/ProtocolBuffers.Test/TestProtos/UnitTestMessageSetProtoFile.cs +++ b/src/ProtocolBuffers.Test/TestProtos/UnitTestMessageSetProtoFile.cs @@ -189,7 +189,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(TestMessageSet prototype) {
- return (Builder) new Builder().MergeFrom(prototype);
+ return new Builder(prototype);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -199,21 +199,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder {
get { return this; }
}
- public Builder() {}
+ public Builder() {
+ result = DefaultInstance ?? new TestMessageSet();
+ builderIsReadOnly = result == DefaultInstance;
+ }
+ internal Builder(TestMessageSet cloneFrom) {
+ result = cloneFrom;
+ builderIsReadOnly = true;
+ }
- TestMessageSet result = new TestMessageSet();
+ bool builderIsReadOnly;
+ TestMessageSet result;
+
+ private TestMessageSet PrepareBuilder() {
+ if (builderIsReadOnly) {
+ TestMessageSet original = result;
+ result = new TestMessageSet();
+ builderIsReadOnly = false;
+ MergeFrom(original);
+ }
+ return result;
+ }
+
+ public override bool IsInitialized {
+ get { return result.IsInitialized; }
+ }
protected override TestMessageSet MessageBeingBuilt {
- get { return result; }
+ get { return PrepareBuilder(); }
}
public override Builder Clear() {
- result = new TestMessageSet();
+ result = DefaultInstance ?? new TestMessageSet();
+ builderIsReadOnly = true;
return this;
}
public override Builder Clone() {
- return new Builder().MergeFrom(result);
+ if (builderIsReadOnly) {
+ return new Builder(result);
+ } else {
+ return new Builder().MergeFrom(result);
+ }
}
public override pbd::MessageDescriptor DescriptorForType {
@@ -225,12 +252,11 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override TestMessageSet BuildPartial() {
- if (result == null) {
- throw new global::System.InvalidOperationException("build() has already been called on this Builder");
+ if (builderIsReadOnly) {
+ return result;
}
- TestMessageSet returnMe = result;
- result = null;
- return returnMe;
+ builderIsReadOnly = true;
+ return result;
}
public override Builder MergeFrom(pb::IMessage other) {
@@ -244,6 +270,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder MergeFrom(TestMessageSet other) {
if (other == global::Google.ProtocolBuffers.TestProtos.TestMessageSet.DefaultInstance) return this;
+ PrepareBuilder();
this.MergeExtensionFields(other);
this.MergeUnknownFields(other.UnknownFields);
return this;
@@ -254,6 +281,7 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
+ PrepareBuilder();
pb::UnknownFieldSet.Builder unknownFields = null;
uint tag;
string field_name;
@@ -404,7 +432,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(TestMessageSetContainer prototype) {
- return (Builder) new Builder().MergeFrom(prototype);
+ return new Builder(prototype);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -414,21 +442,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder {
get { return this; }
}
- public Builder() {}
+ public Builder() {
+ result = DefaultInstance ?? new TestMessageSetContainer();
+ builderIsReadOnly = result == DefaultInstance;
+ }
+ internal Builder(TestMessageSetContainer cloneFrom) {
+ result = cloneFrom;
+ builderIsReadOnly = true;
+ }
- TestMessageSetContainer result = new TestMessageSetContainer();
+ bool builderIsReadOnly;
+ TestMessageSetContainer result;
+
+ private TestMessageSetContainer PrepareBuilder() {
+ if (builderIsReadOnly) {
+ TestMessageSetContainer original = result;
+ result = new TestMessageSetContainer();
+ builderIsReadOnly = false;
+ MergeFrom(original);
+ }
+ return result;
+ }
+
+ public override bool IsInitialized {
+ get { return result.IsInitialized; }
+ }
protected override TestMessageSetContainer MessageBeingBuilt {
- get { return result; }
+ get { return PrepareBuilder(); }
}
public override Builder Clear() {
- result = new TestMessageSetContainer();
+ result = DefaultInstance ?? new TestMessageSetContainer();
+ builderIsReadOnly = true;
return this;
}
public override Builder Clone() {
- return new Builder().MergeFrom(result);
+ if (builderIsReadOnly) {
+ return new Builder(result);
+ } else {
+ return new Builder().MergeFrom(result);
+ }
}
public override pbd::MessageDescriptor DescriptorForType {
@@ -440,12 +495,11 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override TestMessageSetContainer BuildPartial() {
- if (result == null) {
- throw new global::System.InvalidOperationException("build() has already been called on this Builder");
+ if (builderIsReadOnly) {
+ return result;
}
- TestMessageSetContainer returnMe = result;
- result = null;
- return returnMe;
+ builderIsReadOnly = true;
+ return result;
}
public override Builder MergeFrom(pb::IMessage other) {
@@ -459,6 +513,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder MergeFrom(TestMessageSetContainer other) {
if (other == global::Google.ProtocolBuffers.TestProtos.TestMessageSetContainer.DefaultInstance) return this;
+ PrepareBuilder();
if (other.HasMessageSet) {
MergeMessageSet(other.MessageSet);
}
@@ -471,6 +526,7 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
+ PrepareBuilder();
pb::UnknownFieldSet.Builder unknownFields = null;
uint tag;
string field_name;
@@ -532,18 +588,21 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetMessageSet(global::Google.ProtocolBuffers.TestProtos.TestMessageSet value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.hasMessageSet = true;
result.messageSet_ = value;
return this;
}
public Builder SetMessageSet(global::Google.ProtocolBuffers.TestProtos.TestMessageSet.Builder builderForValue) {
pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue");
+ PrepareBuilder();
result.hasMessageSet = true;
result.messageSet_ = builderForValue.Build();
return this;
}
public Builder MergeMessageSet(global::Google.ProtocolBuffers.TestProtos.TestMessageSet value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
if (result.hasMessageSet &&
result.messageSet_ != global::Google.ProtocolBuffers.TestProtos.TestMessageSet.DefaultInstance) {
result.messageSet_ = global::Google.ProtocolBuffers.TestProtos.TestMessageSet.CreateBuilder(result.messageSet_).MergeFrom(value).BuildPartial();
@@ -554,6 +613,7 @@ namespace Google.ProtocolBuffers.TestProtos { return this;
}
public Builder ClearMessageSet() {
+ PrepareBuilder();
result.hasMessageSet = false;
result.messageSet_ = global::Google.ProtocolBuffers.TestProtos.TestMessageSet.DefaultInstance;
return this;
@@ -668,7 +728,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(TestMessageSetExtension1 prototype) {
- return (Builder) new Builder().MergeFrom(prototype);
+ return new Builder(prototype);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -678,21 +738,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder {
get { return this; }
}
- public Builder() {}
+ public Builder() {
+ result = DefaultInstance ?? new TestMessageSetExtension1();
+ builderIsReadOnly = result == DefaultInstance;
+ }
+ internal Builder(TestMessageSetExtension1 cloneFrom) {
+ result = cloneFrom;
+ builderIsReadOnly = true;
+ }
- TestMessageSetExtension1 result = new TestMessageSetExtension1();
+ bool builderIsReadOnly;
+ TestMessageSetExtension1 result;
+
+ private TestMessageSetExtension1 PrepareBuilder() {
+ if (builderIsReadOnly) {
+ TestMessageSetExtension1 original = result;
+ result = new TestMessageSetExtension1();
+ builderIsReadOnly = false;
+ MergeFrom(original);
+ }
+ return result;
+ }
+
+ public override bool IsInitialized {
+ get { return result.IsInitialized; }
+ }
protected override TestMessageSetExtension1 MessageBeingBuilt {
- get { return result; }
+ get { return PrepareBuilder(); }
}
public override Builder Clear() {
- result = new TestMessageSetExtension1();
+ result = DefaultInstance ?? new TestMessageSetExtension1();
+ builderIsReadOnly = true;
return this;
}
public override Builder Clone() {
- return new Builder().MergeFrom(result);
+ if (builderIsReadOnly) {
+ return new Builder(result);
+ } else {
+ return new Builder().MergeFrom(result);
+ }
}
public override pbd::MessageDescriptor DescriptorForType {
@@ -704,12 +791,11 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override TestMessageSetExtension1 BuildPartial() {
- if (result == null) {
- throw new global::System.InvalidOperationException("build() has already been called on this Builder");
+ if (builderIsReadOnly) {
+ return result;
}
- TestMessageSetExtension1 returnMe = result;
- result = null;
- return returnMe;
+ builderIsReadOnly = true;
+ return result;
}
public override Builder MergeFrom(pb::IMessage other) {
@@ -723,6 +809,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder MergeFrom(TestMessageSetExtension1 other) {
if (other == global::Google.ProtocolBuffers.TestProtos.TestMessageSetExtension1.DefaultInstance) return this;
+ PrepareBuilder();
if (other.HasI) {
I = other.I;
}
@@ -735,6 +822,7 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
+ PrepareBuilder();
pb::UnknownFieldSet.Builder unknownFields = null;
uint tag;
string field_name;
@@ -790,11 +878,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetI(value); }
}
public Builder SetI(int value) {
+ PrepareBuilder();
result.hasI = true;
result.i_ = value;
return this;
}
public Builder ClearI() {
+ PrepareBuilder();
result.hasI = false;
result.i_ = 0;
return this;
@@ -909,7 +999,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(TestMessageSetExtension2 prototype) {
- return (Builder) new Builder().MergeFrom(prototype);
+ return new Builder(prototype);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -919,21 +1009,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder {
get { return this; }
}
- public Builder() {}
+ public Builder() {
+ result = DefaultInstance ?? new TestMessageSetExtension2();
+ builderIsReadOnly = result == DefaultInstance;
+ }
+ internal Builder(TestMessageSetExtension2 cloneFrom) {
+ result = cloneFrom;
+ builderIsReadOnly = true;
+ }
- TestMessageSetExtension2 result = new TestMessageSetExtension2();
+ bool builderIsReadOnly;
+ TestMessageSetExtension2 result;
+
+ private TestMessageSetExtension2 PrepareBuilder() {
+ if (builderIsReadOnly) {
+ TestMessageSetExtension2 original = result;
+ result = new TestMessageSetExtension2();
+ builderIsReadOnly = false;
+ MergeFrom(original);
+ }
+ return result;
+ }
+
+ public override bool IsInitialized {
+ get { return result.IsInitialized; }
+ }
protected override TestMessageSetExtension2 MessageBeingBuilt {
- get { return result; }
+ get { return PrepareBuilder(); }
}
public override Builder Clear() {
- result = new TestMessageSetExtension2();
+ result = DefaultInstance ?? new TestMessageSetExtension2();
+ builderIsReadOnly = true;
return this;
}
public override Builder Clone() {
- return new Builder().MergeFrom(result);
+ if (builderIsReadOnly) {
+ return new Builder(result);
+ } else {
+ return new Builder().MergeFrom(result);
+ }
}
public override pbd::MessageDescriptor DescriptorForType {
@@ -945,12 +1062,11 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override TestMessageSetExtension2 BuildPartial() {
- if (result == null) {
- throw new global::System.InvalidOperationException("build() has already been called on this Builder");
+ if (builderIsReadOnly) {
+ return result;
}
- TestMessageSetExtension2 returnMe = result;
- result = null;
- return returnMe;
+ builderIsReadOnly = true;
+ return result;
}
public override Builder MergeFrom(pb::IMessage other) {
@@ -964,6 +1080,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder MergeFrom(TestMessageSetExtension2 other) {
if (other == global::Google.ProtocolBuffers.TestProtos.TestMessageSetExtension2.DefaultInstance) return this;
+ PrepareBuilder();
if (other.HasStr) {
Str = other.Str;
}
@@ -976,6 +1093,7 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
+ PrepareBuilder();
pb::UnknownFieldSet.Builder unknownFields = null;
uint tag;
string field_name;
@@ -1032,11 +1150,13 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetStr(string value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.hasStr = true;
result.str_ = value;
return this;
}
public Builder ClearStr() {
+ PrepareBuilder();
result.hasStr = false;
result.str_ = "";
return this;
@@ -1199,7 +1319,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(Item prototype) {
- return (Builder) new Builder().MergeFrom(prototype);
+ return new Builder(prototype);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -1209,21 +1329,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder {
get { return this; }
}
- public Builder() {}
+ public Builder() {
+ result = DefaultInstance ?? new Item();
+ builderIsReadOnly = result == DefaultInstance;
+ }
+ internal Builder(Item cloneFrom) {
+ result = cloneFrom;
+ builderIsReadOnly = true;
+ }
- Item result = new Item();
+ bool builderIsReadOnly;
+ Item result;
+
+ private Item PrepareBuilder() {
+ if (builderIsReadOnly) {
+ Item original = result;
+ result = new Item();
+ builderIsReadOnly = false;
+ MergeFrom(original);
+ }
+ return result;
+ }
+
+ public override bool IsInitialized {
+ get { return result.IsInitialized; }
+ }
protected override Item MessageBeingBuilt {
- get { return result; }
+ get { return PrepareBuilder(); }
}
public override Builder Clear() {
- result = new Item();
+ result = DefaultInstance ?? new Item();
+ builderIsReadOnly = true;
return this;
}
public override Builder Clone() {
- return new Builder().MergeFrom(result);
+ if (builderIsReadOnly) {
+ return new Builder(result);
+ } else {
+ return new Builder().MergeFrom(result);
+ }
}
public override pbd::MessageDescriptor DescriptorForType {
@@ -1235,12 +1382,11 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override Item BuildPartial() {
- if (result == null) {
- throw new global::System.InvalidOperationException("build() has already been called on this Builder");
+ if (builderIsReadOnly) {
+ return result;
}
- Item returnMe = result;
- result = null;
- return returnMe;
+ builderIsReadOnly = true;
+ return result;
}
public override Builder MergeFrom(pb::IMessage other) {
@@ -1254,6 +1400,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder MergeFrom(Item other) {
if (other == global::Google.ProtocolBuffers.TestProtos.RawMessageSet.Types.Item.DefaultInstance) return this;
+ PrepareBuilder();
if (other.HasTypeId) {
TypeId = other.TypeId;
}
@@ -1269,6 +1416,7 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
+ PrepareBuilder();
pb::UnknownFieldSet.Builder unknownFields = null;
uint tag;
string field_name;
@@ -1328,11 +1476,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetTypeId(value); }
}
public Builder SetTypeId(int value) {
+ PrepareBuilder();
result.hasTypeId = true;
result.typeId_ = value;
return this;
}
public Builder ClearTypeId() {
+ PrepareBuilder();
result.hasTypeId = false;
result.typeId_ = 0;
return this;
@@ -1347,11 +1497,13 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetMessage(pb::ByteString value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.hasMessage = true;
result.message_ = value;
return this;
}
public Builder ClearMessage() {
+ PrepareBuilder();
result.hasMessage = false;
result.message_ = pb::ByteString.Empty;
return this;
@@ -1442,7 +1594,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(RawMessageSet prototype) {
- return (Builder) new Builder().MergeFrom(prototype);
+ return new Builder(prototype);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -1452,21 +1604,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder {
get { return this; }
}
- public Builder() {}
+ public Builder() {
+ result = DefaultInstance ?? new RawMessageSet();
+ builderIsReadOnly = result == DefaultInstance;
+ }
+ internal Builder(RawMessageSet cloneFrom) {
+ result = cloneFrom;
+ builderIsReadOnly = true;
+ }
- RawMessageSet result = new RawMessageSet();
+ bool builderIsReadOnly;
+ RawMessageSet result;
+
+ private RawMessageSet PrepareBuilder() {
+ if (builderIsReadOnly) {
+ RawMessageSet original = result;
+ result = new RawMessageSet();
+ builderIsReadOnly = false;
+ MergeFrom(original);
+ }
+ return result;
+ }
+
+ public override bool IsInitialized {
+ get { return result.IsInitialized; }
+ }
protected override RawMessageSet MessageBeingBuilt {
- get { return result; }
+ get { return PrepareBuilder(); }
}
public override Builder Clear() {
- result = new RawMessageSet();
+ result = DefaultInstance ?? new RawMessageSet();
+ builderIsReadOnly = true;
return this;
}
public override Builder Clone() {
- return new Builder().MergeFrom(result);
+ if (builderIsReadOnly) {
+ return new Builder(result);
+ } else {
+ return new Builder().MergeFrom(result);
+ }
}
public override pbd::MessageDescriptor DescriptorForType {
@@ -1478,13 +1657,12 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override RawMessageSet BuildPartial() {
- if (result == null) {
- throw new global::System.InvalidOperationException("build() has already been called on this Builder");
+ if (builderIsReadOnly) {
+ return result;
}
result.item_.MakeReadOnly();
- RawMessageSet returnMe = result;
- result = null;
- return returnMe;
+ builderIsReadOnly = true;
+ return result;
}
public override Builder MergeFrom(pb::IMessage other) {
@@ -1498,6 +1676,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder MergeFrom(RawMessageSet other) {
if (other == global::Google.ProtocolBuffers.TestProtos.RawMessageSet.DefaultInstance) return this;
+ PrepareBuilder();
if (other.item_.Count != 0) {
base.AddRange(other.item_, result.item_);
}
@@ -1510,6 +1689,7 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
+ PrepareBuilder();
pb::UnknownFieldSet.Builder unknownFields = null;
uint tag;
string field_name;
@@ -1558,7 +1738,7 @@ namespace Google.ProtocolBuffers.TestProtos { public pbc::IPopsicleList<global::Google.ProtocolBuffers.TestProtos.RawMessageSet.Types.Item> ItemList {
- get { return result.item_; }
+ get { return PrepareBuilder().item_; }
}
public int ItemCount {
get { return result.ItemCount; }
@@ -1568,29 +1748,35 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetItem(int index, global::Google.ProtocolBuffers.TestProtos.RawMessageSet.Types.Item value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.item_[index] = value;
return this;
}
public Builder SetItem(int index, global::Google.ProtocolBuffers.TestProtos.RawMessageSet.Types.Item.Builder builderForValue) {
pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue");
+ PrepareBuilder();
result.item_[index] = builderForValue.Build();
return this;
}
public Builder AddItem(global::Google.ProtocolBuffers.TestProtos.RawMessageSet.Types.Item value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.item_.Add(value);
return this;
}
public Builder AddItem(global::Google.ProtocolBuffers.TestProtos.RawMessageSet.Types.Item.Builder builderForValue) {
pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue");
+ PrepareBuilder();
result.item_.Add(builderForValue.Build());
return this;
}
public Builder AddRangeItem(scg::IEnumerable<global::Google.ProtocolBuffers.TestProtos.RawMessageSet.Types.Item> values) {
+ PrepareBuilder();
base.AddRange(values, result.item_);
return this;
}
public Builder ClearItem() {
+ PrepareBuilder();
result.item_.Clear();
return this;
}
diff --git a/src/ProtocolBuffers.Test/TestProtos/UnitTestNoGenericServicesProtoFile.cs b/src/ProtocolBuffers.Test/TestProtos/UnitTestNoGenericServicesProtoFile.cs index 74d6af60..ca401926 100644 --- a/src/ProtocolBuffers.Test/TestProtos/UnitTestNoGenericServicesProtoFile.cs +++ b/src/ProtocolBuffers.Test/TestProtos/UnitTestNoGenericServicesProtoFile.cs @@ -183,7 +183,7 @@ namespace Google.ProtocolBuffers.TestProtos.NoGenericService { public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(TestMessage prototype) {
- return (Builder) new Builder().MergeFrom(prototype);
+ return new Builder(prototype);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -193,21 +193,48 @@ namespace Google.ProtocolBuffers.TestProtos.NoGenericService { protected override Builder ThisBuilder {
get { return this; }
}
- public Builder() {}
+ public Builder() {
+ result = DefaultInstance ?? new TestMessage();
+ builderIsReadOnly = result == DefaultInstance;
+ }
+ internal Builder(TestMessage cloneFrom) {
+ result = cloneFrom;
+ builderIsReadOnly = true;
+ }
+
+ bool builderIsReadOnly;
+ TestMessage result;
- TestMessage result = new TestMessage();
+ private TestMessage PrepareBuilder() {
+ if (builderIsReadOnly) {
+ TestMessage original = result;
+ result = new TestMessage();
+ builderIsReadOnly = false;
+ MergeFrom(original);
+ }
+ return result;
+ }
+
+ public override bool IsInitialized {
+ get { return result.IsInitialized; }
+ }
protected override TestMessage MessageBeingBuilt {
- get { return result; }
+ get { return PrepareBuilder(); }
}
public override Builder Clear() {
- result = new TestMessage();
+ result = DefaultInstance ?? new TestMessage();
+ builderIsReadOnly = true;
return this;
}
public override Builder Clone() {
- return new Builder().MergeFrom(result);
+ if (builderIsReadOnly) {
+ return new Builder(result);
+ } else {
+ return new Builder().MergeFrom(result);
+ }
}
public override pbd::MessageDescriptor DescriptorForType {
@@ -219,12 +246,11 @@ namespace Google.ProtocolBuffers.TestProtos.NoGenericService { }
public override TestMessage BuildPartial() {
- if (result == null) {
- throw new global::System.InvalidOperationException("build() has already been called on this Builder");
+ if (builderIsReadOnly) {
+ return result;
}
- TestMessage returnMe = result;
- result = null;
- return returnMe;
+ builderIsReadOnly = true;
+ return result;
}
public override Builder MergeFrom(pb::IMessage other) {
@@ -238,6 +264,7 @@ namespace Google.ProtocolBuffers.TestProtos.NoGenericService { public override Builder MergeFrom(TestMessage other) {
if (other == global::Google.ProtocolBuffers.TestProtos.NoGenericService.TestMessage.DefaultInstance) return this;
+ PrepareBuilder();
if (other.HasA) {
A = other.A;
}
@@ -251,6 +278,7 @@ namespace Google.ProtocolBuffers.TestProtos.NoGenericService { }
public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
+ PrepareBuilder();
pb::UnknownFieldSet.Builder unknownFields = null;
uint tag;
string field_name;
@@ -306,11 +334,13 @@ namespace Google.ProtocolBuffers.TestProtos.NoGenericService { set { SetA(value); }
}
public Builder SetA(int value) {
+ PrepareBuilder();
result.hasA = true;
result.a_ = value;
return this;
}
public Builder ClearA() {
+ PrepareBuilder();
result.hasA = false;
result.a_ = 0;
return this;
diff --git a/src/ProtocolBuffers.Test/TestProtos/UnitTestOptimizeForProtoFile.cs b/src/ProtocolBuffers.Test/TestProtos/UnitTestOptimizeForProtoFile.cs index c7153abc..967d549a 100644 --- a/src/ProtocolBuffers.Test/TestProtos/UnitTestOptimizeForProtoFile.cs +++ b/src/ProtocolBuffers.Test/TestProtos/UnitTestOptimizeForProtoFile.cs @@ -164,7 +164,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(TestOptimizedForSize prototype) {
- return (Builder) new Builder().MergeFrom(prototype);
+ return new Builder(prototype);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -174,21 +174,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder {
get { return this; }
}
- public Builder() {}
+ public Builder() {
+ result = DefaultInstance ?? new TestOptimizedForSize();
+ builderIsReadOnly = result == DefaultInstance;
+ }
+ internal Builder(TestOptimizedForSize cloneFrom) {
+ result = cloneFrom;
+ builderIsReadOnly = true;
+ }
- TestOptimizedForSize result = new TestOptimizedForSize();
+ bool builderIsReadOnly;
+ TestOptimizedForSize result;
+
+ private TestOptimizedForSize PrepareBuilder() {
+ if (builderIsReadOnly) {
+ TestOptimizedForSize original = result;
+ result = new TestOptimizedForSize();
+ builderIsReadOnly = false;
+ MergeFrom(original);
+ }
+ return result;
+ }
+
+ public override bool IsInitialized {
+ get { return result.IsInitialized; }
+ }
protected override TestOptimizedForSize MessageBeingBuilt {
- get { return result; }
+ get { return PrepareBuilder(); }
}
public override Builder Clear() {
- result = new TestOptimizedForSize();
+ result = DefaultInstance ?? new TestOptimizedForSize();
+ builderIsReadOnly = true;
return this;
}
public override Builder Clone() {
- return new Builder().MergeFrom(result);
+ if (builderIsReadOnly) {
+ return new Builder(result);
+ } else {
+ return new Builder().MergeFrom(result);
+ }
}
public override pbd::MessageDescriptor DescriptorForType {
@@ -200,12 +227,11 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override TestOptimizedForSize BuildPartial() {
- if (result == null) {
- throw new global::System.InvalidOperationException("build() has already been called on this Builder");
+ if (builderIsReadOnly) {
+ return result;
}
- TestOptimizedForSize returnMe = result;
- result = null;
- return returnMe;
+ builderIsReadOnly = true;
+ return result;
}
@@ -217,11 +243,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetI(value); }
}
public Builder SetI(int value) {
+ PrepareBuilder();
result.hasI = true;
result.i_ = value;
return this;
}
public Builder ClearI() {
+ PrepareBuilder();
result.hasI = false;
result.i_ = 0;
return this;
@@ -236,18 +264,21 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetMsg(global::Google.ProtocolBuffers.TestProtos.ForeignMessage value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.hasMsg = true;
result.msg_ = value;
return this;
}
public Builder SetMsg(global::Google.ProtocolBuffers.TestProtos.ForeignMessage.Builder builderForValue) {
pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue");
+ PrepareBuilder();
result.hasMsg = true;
result.msg_ = builderForValue.Build();
return this;
}
public Builder MergeMsg(global::Google.ProtocolBuffers.TestProtos.ForeignMessage value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
if (result.hasMsg &&
result.msg_ != global::Google.ProtocolBuffers.TestProtos.ForeignMessage.DefaultInstance) {
result.msg_ = global::Google.ProtocolBuffers.TestProtos.ForeignMessage.CreateBuilder(result.msg_).MergeFrom(value).BuildPartial();
@@ -258,6 +289,7 @@ namespace Google.ProtocolBuffers.TestProtos { return this;
}
public Builder ClearMsg() {
+ PrepareBuilder();
result.hasMsg = false;
result.msg_ = global::Google.ProtocolBuffers.TestProtos.ForeignMessage.DefaultInstance;
return this;
@@ -337,7 +369,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(TestRequiredOptimizedForSize prototype) {
- return (Builder) new Builder().MergeFrom(prototype);
+ return new Builder(prototype);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -347,21 +379,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder {
get { return this; }
}
- public Builder() {}
+ public Builder() {
+ result = DefaultInstance ?? new TestRequiredOptimizedForSize();
+ builderIsReadOnly = result == DefaultInstance;
+ }
+ internal Builder(TestRequiredOptimizedForSize cloneFrom) {
+ result = cloneFrom;
+ builderIsReadOnly = true;
+ }
- TestRequiredOptimizedForSize result = new TestRequiredOptimizedForSize();
+ bool builderIsReadOnly;
+ TestRequiredOptimizedForSize result;
+
+ private TestRequiredOptimizedForSize PrepareBuilder() {
+ if (builderIsReadOnly) {
+ TestRequiredOptimizedForSize original = result;
+ result = new TestRequiredOptimizedForSize();
+ builderIsReadOnly = false;
+ MergeFrom(original);
+ }
+ return result;
+ }
+
+ public override bool IsInitialized {
+ get { return result.IsInitialized; }
+ }
protected override TestRequiredOptimizedForSize MessageBeingBuilt {
- get { return result; }
+ get { return PrepareBuilder(); }
}
public override Builder Clear() {
- result = new TestRequiredOptimizedForSize();
+ result = DefaultInstance ?? new TestRequiredOptimizedForSize();
+ builderIsReadOnly = true;
return this;
}
public override Builder Clone() {
- return new Builder().MergeFrom(result);
+ if (builderIsReadOnly) {
+ return new Builder(result);
+ } else {
+ return new Builder().MergeFrom(result);
+ }
}
public override pbd::MessageDescriptor DescriptorForType {
@@ -373,12 +432,11 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override TestRequiredOptimizedForSize BuildPartial() {
- if (result == null) {
- throw new global::System.InvalidOperationException("build() has already been called on this Builder");
+ if (builderIsReadOnly) {
+ return result;
}
- TestRequiredOptimizedForSize returnMe = result;
- result = null;
- return returnMe;
+ builderIsReadOnly = true;
+ return result;
}
@@ -390,11 +448,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetX(value); }
}
public Builder SetX(int value) {
+ PrepareBuilder();
result.hasX = true;
result.x_ = value;
return this;
}
public Builder ClearX() {
+ PrepareBuilder();
result.hasX = false;
result.x_ = 0;
return this;
@@ -474,7 +534,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(TestOptionalOptimizedForSize prototype) {
- return (Builder) new Builder().MergeFrom(prototype);
+ return new Builder(prototype);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -484,21 +544,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder {
get { return this; }
}
- public Builder() {}
+ public Builder() {
+ result = DefaultInstance ?? new TestOptionalOptimizedForSize();
+ builderIsReadOnly = result == DefaultInstance;
+ }
+ internal Builder(TestOptionalOptimizedForSize cloneFrom) {
+ result = cloneFrom;
+ builderIsReadOnly = true;
+ }
- TestOptionalOptimizedForSize result = new TestOptionalOptimizedForSize();
+ bool builderIsReadOnly;
+ TestOptionalOptimizedForSize result;
+
+ private TestOptionalOptimizedForSize PrepareBuilder() {
+ if (builderIsReadOnly) {
+ TestOptionalOptimizedForSize original = result;
+ result = new TestOptionalOptimizedForSize();
+ builderIsReadOnly = false;
+ MergeFrom(original);
+ }
+ return result;
+ }
+
+ public override bool IsInitialized {
+ get { return result.IsInitialized; }
+ }
protected override TestOptionalOptimizedForSize MessageBeingBuilt {
- get { return result; }
+ get { return PrepareBuilder(); }
}
public override Builder Clear() {
- result = new TestOptionalOptimizedForSize();
+ result = DefaultInstance ?? new TestOptionalOptimizedForSize();
+ builderIsReadOnly = true;
return this;
}
public override Builder Clone() {
- return new Builder().MergeFrom(result);
+ if (builderIsReadOnly) {
+ return new Builder(result);
+ } else {
+ return new Builder().MergeFrom(result);
+ }
}
public override pbd::MessageDescriptor DescriptorForType {
@@ -510,12 +597,11 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override TestOptionalOptimizedForSize BuildPartial() {
- if (result == null) {
- throw new global::System.InvalidOperationException("build() has already been called on this Builder");
+ if (builderIsReadOnly) {
+ return result;
}
- TestOptionalOptimizedForSize returnMe = result;
- result = null;
- return returnMe;
+ builderIsReadOnly = true;
+ return result;
}
@@ -528,18 +614,21 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetO(global::Google.ProtocolBuffers.TestProtos.TestRequiredOptimizedForSize value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.hasO = true;
result.o_ = value;
return this;
}
public Builder SetO(global::Google.ProtocolBuffers.TestProtos.TestRequiredOptimizedForSize.Builder builderForValue) {
pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue");
+ PrepareBuilder();
result.hasO = true;
result.o_ = builderForValue.Build();
return this;
}
public Builder MergeO(global::Google.ProtocolBuffers.TestProtos.TestRequiredOptimizedForSize value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
if (result.hasO &&
result.o_ != global::Google.ProtocolBuffers.TestProtos.TestRequiredOptimizedForSize.DefaultInstance) {
result.o_ = global::Google.ProtocolBuffers.TestProtos.TestRequiredOptimizedForSize.CreateBuilder(result.o_).MergeFrom(value).BuildPartial();
@@ -550,6 +639,7 @@ namespace Google.ProtocolBuffers.TestProtos { return this;
}
public Builder ClearO() {
+ PrepareBuilder();
result.hasO = false;
result.o_ = global::Google.ProtocolBuffers.TestProtos.TestRequiredOptimizedForSize.DefaultInstance;
return this;
diff --git a/src/ProtocolBuffers.Test/TestProtos/UnitTestProtoFile.cs b/src/ProtocolBuffers.Test/TestProtos/UnitTestProtoFile.cs index d8824d49..aeea673d 100644 --- a/src/ProtocolBuffers.Test/TestProtos/UnitTestProtoFile.cs +++ b/src/ProtocolBuffers.Test/TestProtos/UnitTestProtoFile.cs @@ -1260,7 +1260,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(NestedMessage prototype) {
- return (Builder) new Builder().MergeFrom(prototype);
+ return new Builder(prototype);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -1270,21 +1270,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder {
get { return this; }
}
- public Builder() {}
+ public Builder() {
+ result = DefaultInstance ?? new NestedMessage();
+ builderIsReadOnly = result == DefaultInstance;
+ }
+ internal Builder(NestedMessage cloneFrom) {
+ result = cloneFrom;
+ builderIsReadOnly = true;
+ }
+
+ bool builderIsReadOnly;
+ NestedMessage result;
+
+ private NestedMessage PrepareBuilder() {
+ if (builderIsReadOnly) {
+ NestedMessage original = result;
+ result = new NestedMessage();
+ builderIsReadOnly = false;
+ MergeFrom(original);
+ }
+ return result;
+ }
- NestedMessage result = new NestedMessage();
+ public override bool IsInitialized {
+ get { return result.IsInitialized; }
+ }
protected override NestedMessage MessageBeingBuilt {
- get { return result; }
+ get { return PrepareBuilder(); }
}
public override Builder Clear() {
- result = new NestedMessage();
+ result = DefaultInstance ?? new NestedMessage();
+ builderIsReadOnly = true;
return this;
}
public override Builder Clone() {
- return new Builder().MergeFrom(result);
+ if (builderIsReadOnly) {
+ return new Builder(result);
+ } else {
+ return new Builder().MergeFrom(result);
+ }
}
public override pbd::MessageDescriptor DescriptorForType {
@@ -1296,12 +1323,11 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override NestedMessage BuildPartial() {
- if (result == null) {
- throw new global::System.InvalidOperationException("build() has already been called on this Builder");
+ if (builderIsReadOnly) {
+ return result;
}
- NestedMessage returnMe = result;
- result = null;
- return returnMe;
+ builderIsReadOnly = true;
+ return result;
}
public override Builder MergeFrom(pb::IMessage other) {
@@ -1315,6 +1341,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder MergeFrom(NestedMessage other) {
if (other == global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage.DefaultInstance) return this;
+ PrepareBuilder();
if (other.HasBb) {
Bb = other.Bb;
}
@@ -1327,6 +1354,7 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
+ PrepareBuilder();
pb::UnknownFieldSet.Builder unknownFields = null;
uint tag;
string field_name;
@@ -1382,11 +1410,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetBb(value); }
}
public Builder SetBb(int value) {
+ PrepareBuilder();
result.hasBb = true;
result.bb_ = value;
return this;
}
public Builder ClearBb() {
+ PrepareBuilder();
result.hasBb = false;
result.bb_ = 0;
return this;
@@ -1499,7 +1529,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(OptionalGroup prototype) {
- return (Builder) new Builder().MergeFrom(prototype);
+ return new Builder(prototype);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -1509,21 +1539,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder {
get { return this; }
}
- public Builder() {}
+ public Builder() {
+ result = DefaultInstance ?? new OptionalGroup();
+ builderIsReadOnly = result == DefaultInstance;
+ }
+ internal Builder(OptionalGroup cloneFrom) {
+ result = cloneFrom;
+ builderIsReadOnly = true;
+ }
+
+ bool builderIsReadOnly;
+ OptionalGroup result;
+
+ private OptionalGroup PrepareBuilder() {
+ if (builderIsReadOnly) {
+ OptionalGroup original = result;
+ result = new OptionalGroup();
+ builderIsReadOnly = false;
+ MergeFrom(original);
+ }
+ return result;
+ }
- OptionalGroup result = new OptionalGroup();
+ public override bool IsInitialized {
+ get { return result.IsInitialized; }
+ }
protected override OptionalGroup MessageBeingBuilt {
- get { return result; }
+ get { return PrepareBuilder(); }
}
public override Builder Clear() {
- result = new OptionalGroup();
+ result = DefaultInstance ?? new OptionalGroup();
+ builderIsReadOnly = true;
return this;
}
public override Builder Clone() {
- return new Builder().MergeFrom(result);
+ if (builderIsReadOnly) {
+ return new Builder(result);
+ } else {
+ return new Builder().MergeFrom(result);
+ }
}
public override pbd::MessageDescriptor DescriptorForType {
@@ -1535,12 +1592,11 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override OptionalGroup BuildPartial() {
- if (result == null) {
- throw new global::System.InvalidOperationException("build() has already been called on this Builder");
+ if (builderIsReadOnly) {
+ return result;
}
- OptionalGroup returnMe = result;
- result = null;
- return returnMe;
+ builderIsReadOnly = true;
+ return result;
}
public override Builder MergeFrom(pb::IMessage other) {
@@ -1554,6 +1610,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder MergeFrom(OptionalGroup other) {
if (other == global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.OptionalGroup.DefaultInstance) return this;
+ PrepareBuilder();
if (other.HasA) {
A = other.A;
}
@@ -1566,6 +1623,7 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
+ PrepareBuilder();
pb::UnknownFieldSet.Builder unknownFields = null;
uint tag;
string field_name;
@@ -1621,11 +1679,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetA(value); }
}
public Builder SetA(int value) {
+ PrepareBuilder();
result.hasA = true;
result.a_ = value;
return this;
}
public Builder ClearA() {
+ PrepareBuilder();
result.hasA = false;
result.a_ = 0;
return this;
@@ -1738,7 +1798,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(RepeatedGroup prototype) {
- return (Builder) new Builder().MergeFrom(prototype);
+ return new Builder(prototype);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -1748,21 +1808,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder {
get { return this; }
}
- public Builder() {}
+ public Builder() {
+ result = DefaultInstance ?? new RepeatedGroup();
+ builderIsReadOnly = result == DefaultInstance;
+ }
+ internal Builder(RepeatedGroup cloneFrom) {
+ result = cloneFrom;
+ builderIsReadOnly = true;
+ }
+
+ bool builderIsReadOnly;
+ RepeatedGroup result;
- RepeatedGroup result = new RepeatedGroup();
+ private RepeatedGroup PrepareBuilder() {
+ if (builderIsReadOnly) {
+ RepeatedGroup original = result;
+ result = new RepeatedGroup();
+ builderIsReadOnly = false;
+ MergeFrom(original);
+ }
+ return result;
+ }
+
+ public override bool IsInitialized {
+ get { return result.IsInitialized; }
+ }
protected override RepeatedGroup MessageBeingBuilt {
- get { return result; }
+ get { return PrepareBuilder(); }
}
public override Builder Clear() {
- result = new RepeatedGroup();
+ result = DefaultInstance ?? new RepeatedGroup();
+ builderIsReadOnly = true;
return this;
}
public override Builder Clone() {
- return new Builder().MergeFrom(result);
+ if (builderIsReadOnly) {
+ return new Builder(result);
+ } else {
+ return new Builder().MergeFrom(result);
+ }
}
public override pbd::MessageDescriptor DescriptorForType {
@@ -1774,12 +1861,11 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override RepeatedGroup BuildPartial() {
- if (result == null) {
- throw new global::System.InvalidOperationException("build() has already been called on this Builder");
+ if (builderIsReadOnly) {
+ return result;
}
- RepeatedGroup returnMe = result;
- result = null;
- return returnMe;
+ builderIsReadOnly = true;
+ return result;
}
public override Builder MergeFrom(pb::IMessage other) {
@@ -1793,6 +1879,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder MergeFrom(RepeatedGroup other) {
if (other == global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.RepeatedGroup.DefaultInstance) return this;
+ PrepareBuilder();
if (other.HasA) {
A = other.A;
}
@@ -1805,6 +1892,7 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
+ PrepareBuilder();
pb::UnknownFieldSet.Builder unknownFields = null;
uint tag;
string field_name;
@@ -1860,11 +1948,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetA(value); }
}
public Builder SetA(int value) {
+ PrepareBuilder();
result.hasA = true;
result.a_ = value;
return this;
}
public Builder ClearA() {
+ PrepareBuilder();
result.hasA = false;
result.a_ = 0;
return this;
@@ -3181,7 +3271,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(TestAllTypes prototype) {
- return (Builder) new Builder().MergeFrom(prototype);
+ return new Builder(prototype);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -3191,21 +3281,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder {
get { return this; }
}
- public Builder() {}
+ public Builder() {
+ result = DefaultInstance ?? new TestAllTypes();
+ builderIsReadOnly = result == DefaultInstance;
+ }
+ internal Builder(TestAllTypes cloneFrom) {
+ result = cloneFrom;
+ builderIsReadOnly = true;
+ }
+
+ bool builderIsReadOnly;
+ TestAllTypes result;
+
+ private TestAllTypes PrepareBuilder() {
+ if (builderIsReadOnly) {
+ TestAllTypes original = result;
+ result = new TestAllTypes();
+ builderIsReadOnly = false;
+ MergeFrom(original);
+ }
+ return result;
+ }
- TestAllTypes result = new TestAllTypes();
+ public override bool IsInitialized {
+ get { return result.IsInitialized; }
+ }
protected override TestAllTypes MessageBeingBuilt {
- get { return result; }
+ get { return PrepareBuilder(); }
}
public override Builder Clear() {
- result = new TestAllTypes();
+ result = DefaultInstance ?? new TestAllTypes();
+ builderIsReadOnly = true;
return this;
}
public override Builder Clone() {
- return new Builder().MergeFrom(result);
+ if (builderIsReadOnly) {
+ return new Builder(result);
+ } else {
+ return new Builder().MergeFrom(result);
+ }
}
public override pbd::MessageDescriptor DescriptorForType {
@@ -3217,8 +3334,8 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override TestAllTypes BuildPartial() {
- if (result == null) {
- throw new global::System.InvalidOperationException("build() has already been called on this Builder");
+ if (builderIsReadOnly) {
+ return result;
}
result.repeatedInt32_.MakeReadOnly();
result.repeatedInt64_.MakeReadOnly();
@@ -3244,9 +3361,8 @@ namespace Google.ProtocolBuffers.TestProtos { result.repeatedImportEnum_.MakeReadOnly();
result.repeatedStringPiece_.MakeReadOnly();
result.repeatedCord_.MakeReadOnly();
- TestAllTypes returnMe = result;
- result = null;
- return returnMe;
+ builderIsReadOnly = true;
+ return result;
}
public override Builder MergeFrom(pb::IMessage other) {
@@ -3260,6 +3376,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder MergeFrom(TestAllTypes other) {
if (other == global::Google.ProtocolBuffers.TestProtos.TestAllTypes.DefaultInstance) return this;
+ PrepareBuilder();
if (other.HasOptionalInt32) {
OptionalInt32 = other.OptionalInt32;
}
@@ -3473,6 +3590,7 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
+ PrepareBuilder();
pb::UnknownFieldSet.Builder unknownFields = null;
uint tag;
string field_name;
@@ -3907,11 +4025,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetOptionalInt32(value); }
}
public Builder SetOptionalInt32(int value) {
+ PrepareBuilder();
result.hasOptionalInt32 = true;
result.optionalInt32_ = value;
return this;
}
public Builder ClearOptionalInt32() {
+ PrepareBuilder();
result.hasOptionalInt32 = false;
result.optionalInt32_ = 0;
return this;
@@ -3925,11 +4045,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetOptionalInt64(value); }
}
public Builder SetOptionalInt64(long value) {
+ PrepareBuilder();
result.hasOptionalInt64 = true;
result.optionalInt64_ = value;
return this;
}
public Builder ClearOptionalInt64() {
+ PrepareBuilder();
result.hasOptionalInt64 = false;
result.optionalInt64_ = 0L;
return this;
@@ -3945,11 +4067,13 @@ namespace Google.ProtocolBuffers.TestProtos { }
[global::System.CLSCompliant(false)]
public Builder SetOptionalUint32(uint value) {
+ PrepareBuilder();
result.hasOptionalUint32 = true;
result.optionalUint32_ = value;
return this;
}
public Builder ClearOptionalUint32() {
+ PrepareBuilder();
result.hasOptionalUint32 = false;
result.optionalUint32_ = 0;
return this;
@@ -3965,11 +4089,13 @@ namespace Google.ProtocolBuffers.TestProtos { }
[global::System.CLSCompliant(false)]
public Builder SetOptionalUint64(ulong value) {
+ PrepareBuilder();
result.hasOptionalUint64 = true;
result.optionalUint64_ = value;
return this;
}
public Builder ClearOptionalUint64() {
+ PrepareBuilder();
result.hasOptionalUint64 = false;
result.optionalUint64_ = 0UL;
return this;
@@ -3983,11 +4109,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetOptionalSint32(value); }
}
public Builder SetOptionalSint32(int value) {
+ PrepareBuilder();
result.hasOptionalSint32 = true;
result.optionalSint32_ = value;
return this;
}
public Builder ClearOptionalSint32() {
+ PrepareBuilder();
result.hasOptionalSint32 = false;
result.optionalSint32_ = 0;
return this;
@@ -4001,11 +4129,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetOptionalSint64(value); }
}
public Builder SetOptionalSint64(long value) {
+ PrepareBuilder();
result.hasOptionalSint64 = true;
result.optionalSint64_ = value;
return this;
}
public Builder ClearOptionalSint64() {
+ PrepareBuilder();
result.hasOptionalSint64 = false;
result.optionalSint64_ = 0;
return this;
@@ -4021,11 +4151,13 @@ namespace Google.ProtocolBuffers.TestProtos { }
[global::System.CLSCompliant(false)]
public Builder SetOptionalFixed32(uint value) {
+ PrepareBuilder();
result.hasOptionalFixed32 = true;
result.optionalFixed32_ = value;
return this;
}
public Builder ClearOptionalFixed32() {
+ PrepareBuilder();
result.hasOptionalFixed32 = false;
result.optionalFixed32_ = 0;
return this;
@@ -4041,11 +4173,13 @@ namespace Google.ProtocolBuffers.TestProtos { }
[global::System.CLSCompliant(false)]
public Builder SetOptionalFixed64(ulong value) {
+ PrepareBuilder();
result.hasOptionalFixed64 = true;
result.optionalFixed64_ = value;
return this;
}
public Builder ClearOptionalFixed64() {
+ PrepareBuilder();
result.hasOptionalFixed64 = false;
result.optionalFixed64_ = 0;
return this;
@@ -4059,11 +4193,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetOptionalSfixed32(value); }
}
public Builder SetOptionalSfixed32(int value) {
+ PrepareBuilder();
result.hasOptionalSfixed32 = true;
result.optionalSfixed32_ = value;
return this;
}
public Builder ClearOptionalSfixed32() {
+ PrepareBuilder();
result.hasOptionalSfixed32 = false;
result.optionalSfixed32_ = 0;
return this;
@@ -4077,11 +4213,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetOptionalSfixed64(value); }
}
public Builder SetOptionalSfixed64(long value) {
+ PrepareBuilder();
result.hasOptionalSfixed64 = true;
result.optionalSfixed64_ = value;
return this;
}
public Builder ClearOptionalSfixed64() {
+ PrepareBuilder();
result.hasOptionalSfixed64 = false;
result.optionalSfixed64_ = 0;
return this;
@@ -4095,11 +4233,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetOptionalFloat(value); }
}
public Builder SetOptionalFloat(float value) {
+ PrepareBuilder();
result.hasOptionalFloat = true;
result.optionalFloat_ = value;
return this;
}
public Builder ClearOptionalFloat() {
+ PrepareBuilder();
result.hasOptionalFloat = false;
result.optionalFloat_ = 0F;
return this;
@@ -4113,11 +4253,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetOptionalDouble(value); }
}
public Builder SetOptionalDouble(double value) {
+ PrepareBuilder();
result.hasOptionalDouble = true;
result.optionalDouble_ = value;
return this;
}
public Builder ClearOptionalDouble() {
+ PrepareBuilder();
result.hasOptionalDouble = false;
result.optionalDouble_ = 0D;
return this;
@@ -4131,11 +4273,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetOptionalBool(value); }
}
public Builder SetOptionalBool(bool value) {
+ PrepareBuilder();
result.hasOptionalBool = true;
result.optionalBool_ = value;
return this;
}
public Builder ClearOptionalBool() {
+ PrepareBuilder();
result.hasOptionalBool = false;
result.optionalBool_ = false;
return this;
@@ -4150,11 +4294,13 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetOptionalString(string value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.hasOptionalString = true;
result.optionalString_ = value;
return this;
}
public Builder ClearOptionalString() {
+ PrepareBuilder();
result.hasOptionalString = false;
result.optionalString_ = "";
return this;
@@ -4169,11 +4315,13 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetOptionalBytes(pb::ByteString value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.hasOptionalBytes = true;
result.optionalBytes_ = value;
return this;
}
public Builder ClearOptionalBytes() {
+ PrepareBuilder();
result.hasOptionalBytes = false;
result.optionalBytes_ = pb::ByteString.Empty;
return this;
@@ -4188,18 +4336,21 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetOptionalGroup(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.OptionalGroup value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.hasOptionalGroup = true;
result.optionalGroup_ = value;
return this;
}
public Builder SetOptionalGroup(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.OptionalGroup.Builder builderForValue) {
pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue");
+ PrepareBuilder();
result.hasOptionalGroup = true;
result.optionalGroup_ = builderForValue.Build();
return this;
}
public Builder MergeOptionalGroup(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.OptionalGroup value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
if (result.hasOptionalGroup &&
result.optionalGroup_ != global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.OptionalGroup.DefaultInstance) {
result.optionalGroup_ = global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.OptionalGroup.CreateBuilder(result.optionalGroup_).MergeFrom(value).BuildPartial();
@@ -4210,6 +4361,7 @@ namespace Google.ProtocolBuffers.TestProtos { return this;
}
public Builder ClearOptionalGroup() {
+ PrepareBuilder();
result.hasOptionalGroup = false;
result.optionalGroup_ = global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.OptionalGroup.DefaultInstance;
return this;
@@ -4224,18 +4376,21 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetOptionalNestedMessage(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.hasOptionalNestedMessage = true;
result.optionalNestedMessage_ = value;
return this;
}
public Builder SetOptionalNestedMessage(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage.Builder builderForValue) {
pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue");
+ PrepareBuilder();
result.hasOptionalNestedMessage = true;
result.optionalNestedMessage_ = builderForValue.Build();
return this;
}
public Builder MergeOptionalNestedMessage(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
if (result.hasOptionalNestedMessage &&
result.optionalNestedMessage_ != global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage.DefaultInstance) {
result.optionalNestedMessage_ = global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage.CreateBuilder(result.optionalNestedMessage_).MergeFrom(value).BuildPartial();
@@ -4246,6 +4401,7 @@ namespace Google.ProtocolBuffers.TestProtos { return this;
}
public Builder ClearOptionalNestedMessage() {
+ PrepareBuilder();
result.hasOptionalNestedMessage = false;
result.optionalNestedMessage_ = global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage.DefaultInstance;
return this;
@@ -4260,18 +4416,21 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetOptionalForeignMessage(global::Google.ProtocolBuffers.TestProtos.ForeignMessage value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.hasOptionalForeignMessage = true;
result.optionalForeignMessage_ = value;
return this;
}
public Builder SetOptionalForeignMessage(global::Google.ProtocolBuffers.TestProtos.ForeignMessage.Builder builderForValue) {
pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue");
+ PrepareBuilder();
result.hasOptionalForeignMessage = true;
result.optionalForeignMessage_ = builderForValue.Build();
return this;
}
public Builder MergeOptionalForeignMessage(global::Google.ProtocolBuffers.TestProtos.ForeignMessage value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
if (result.hasOptionalForeignMessage &&
result.optionalForeignMessage_ != global::Google.ProtocolBuffers.TestProtos.ForeignMessage.DefaultInstance) {
result.optionalForeignMessage_ = global::Google.ProtocolBuffers.TestProtos.ForeignMessage.CreateBuilder(result.optionalForeignMessage_).MergeFrom(value).BuildPartial();
@@ -4282,6 +4441,7 @@ namespace Google.ProtocolBuffers.TestProtos { return this;
}
public Builder ClearOptionalForeignMessage() {
+ PrepareBuilder();
result.hasOptionalForeignMessage = false;
result.optionalForeignMessage_ = global::Google.ProtocolBuffers.TestProtos.ForeignMessage.DefaultInstance;
return this;
@@ -4296,18 +4456,21 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetOptionalImportMessage(global::Google.ProtocolBuffers.TestProtos.ImportMessage value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.hasOptionalImportMessage = true;
result.optionalImportMessage_ = value;
return this;
}
public Builder SetOptionalImportMessage(global::Google.ProtocolBuffers.TestProtos.ImportMessage.Builder builderForValue) {
pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue");
+ PrepareBuilder();
result.hasOptionalImportMessage = true;
result.optionalImportMessage_ = builderForValue.Build();
return this;
}
public Builder MergeOptionalImportMessage(global::Google.ProtocolBuffers.TestProtos.ImportMessage value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
if (result.hasOptionalImportMessage &&
result.optionalImportMessage_ != global::Google.ProtocolBuffers.TestProtos.ImportMessage.DefaultInstance) {
result.optionalImportMessage_ = global::Google.ProtocolBuffers.TestProtos.ImportMessage.CreateBuilder(result.optionalImportMessage_).MergeFrom(value).BuildPartial();
@@ -4318,6 +4481,7 @@ namespace Google.ProtocolBuffers.TestProtos { return this;
}
public Builder ClearOptionalImportMessage() {
+ PrepareBuilder();
result.hasOptionalImportMessage = false;
result.optionalImportMessage_ = global::Google.ProtocolBuffers.TestProtos.ImportMessage.DefaultInstance;
return this;
@@ -4331,11 +4495,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetOptionalNestedEnum(value); }
}
public Builder SetOptionalNestedEnum(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedEnum value) {
+ PrepareBuilder();
result.hasOptionalNestedEnum = true;
result.optionalNestedEnum_ = value;
return this;
}
public Builder ClearOptionalNestedEnum() {
+ PrepareBuilder();
result.hasOptionalNestedEnum = false;
result.optionalNestedEnum_ = global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedEnum.FOO;
return this;
@@ -4349,11 +4515,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetOptionalForeignEnum(value); }
}
public Builder SetOptionalForeignEnum(global::Google.ProtocolBuffers.TestProtos.ForeignEnum value) {
+ PrepareBuilder();
result.hasOptionalForeignEnum = true;
result.optionalForeignEnum_ = value;
return this;
}
public Builder ClearOptionalForeignEnum() {
+ PrepareBuilder();
result.hasOptionalForeignEnum = false;
result.optionalForeignEnum_ = global::Google.ProtocolBuffers.TestProtos.ForeignEnum.FOREIGN_FOO;
return this;
@@ -4367,11 +4535,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetOptionalImportEnum(value); }
}
public Builder SetOptionalImportEnum(global::Google.ProtocolBuffers.TestProtos.ImportEnum value) {
+ PrepareBuilder();
result.hasOptionalImportEnum = true;
result.optionalImportEnum_ = value;
return this;
}
public Builder ClearOptionalImportEnum() {
+ PrepareBuilder();
result.hasOptionalImportEnum = false;
result.optionalImportEnum_ = global::Google.ProtocolBuffers.TestProtos.ImportEnum.IMPORT_FOO;
return this;
@@ -4386,11 +4556,13 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetOptionalStringPiece(string value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.hasOptionalStringPiece = true;
result.optionalStringPiece_ = value;
return this;
}
public Builder ClearOptionalStringPiece() {
+ PrepareBuilder();
result.hasOptionalStringPiece = false;
result.optionalStringPiece_ = "";
return this;
@@ -4405,18 +4577,20 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetOptionalCord(string value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.hasOptionalCord = true;
result.optionalCord_ = value;
return this;
}
public Builder ClearOptionalCord() {
+ PrepareBuilder();
result.hasOptionalCord = false;
result.optionalCord_ = "";
return this;
}
public pbc::IPopsicleList<int> RepeatedInt32List {
- get { return result.repeatedInt32_; }
+ get { return PrepareBuilder().repeatedInt32_; }
}
public int RepeatedInt32Count {
get { return result.RepeatedInt32Count; }
@@ -4425,24 +4599,28 @@ namespace Google.ProtocolBuffers.TestProtos { return result.GetRepeatedInt32(index);
}
public Builder SetRepeatedInt32(int index, int value) {
+ PrepareBuilder();
result.repeatedInt32_[index] = value;
return this;
}
public Builder AddRepeatedInt32(int value) {
+ PrepareBuilder();
result.repeatedInt32_.Add(value);
return this;
}
public Builder AddRangeRepeatedInt32(scg::IEnumerable<int> values) {
+ PrepareBuilder();
base.AddRange(values, result.repeatedInt32_);
return this;
}
public Builder ClearRepeatedInt32() {
+ PrepareBuilder();
result.repeatedInt32_.Clear();
return this;
}
public pbc::IPopsicleList<long> RepeatedInt64List {
- get { return result.repeatedInt64_; }
+ get { return PrepareBuilder().repeatedInt64_; }
}
public int RepeatedInt64Count {
get { return result.RepeatedInt64Count; }
@@ -4451,25 +4629,29 @@ namespace Google.ProtocolBuffers.TestProtos { return result.GetRepeatedInt64(index);
}
public Builder SetRepeatedInt64(int index, long value) {
+ PrepareBuilder();
result.repeatedInt64_[index] = value;
return this;
}
public Builder AddRepeatedInt64(long value) {
+ PrepareBuilder();
result.repeatedInt64_.Add(value);
return this;
}
public Builder AddRangeRepeatedInt64(scg::IEnumerable<long> values) {
+ PrepareBuilder();
base.AddRange(values, result.repeatedInt64_);
return this;
}
public Builder ClearRepeatedInt64() {
+ PrepareBuilder();
result.repeatedInt64_.Clear();
return this;
}
[global::System.CLSCompliant(false)]
public pbc::IPopsicleList<uint> RepeatedUint32List {
- get { return result.repeatedUint32_; }
+ get { return PrepareBuilder().repeatedUint32_; }
}
public int RepeatedUint32Count {
get { return result.RepeatedUint32Count; }
@@ -4480,27 +4662,31 @@ namespace Google.ProtocolBuffers.TestProtos { }
[global::System.CLSCompliant(false)]
public Builder SetRepeatedUint32(int index, uint value) {
+ PrepareBuilder();
result.repeatedUint32_[index] = value;
return this;
}
[global::System.CLSCompliant(false)]
public Builder AddRepeatedUint32(uint value) {
+ PrepareBuilder();
result.repeatedUint32_.Add(value);
return this;
}
[global::System.CLSCompliant(false)]
public Builder AddRangeRepeatedUint32(scg::IEnumerable<uint> values) {
+ PrepareBuilder();
base.AddRange(values, result.repeatedUint32_);
return this;
}
public Builder ClearRepeatedUint32() {
+ PrepareBuilder();
result.repeatedUint32_.Clear();
return this;
}
[global::System.CLSCompliant(false)]
public pbc::IPopsicleList<ulong> RepeatedUint64List {
- get { return result.repeatedUint64_; }
+ get { return PrepareBuilder().repeatedUint64_; }
}
public int RepeatedUint64Count {
get { return result.RepeatedUint64Count; }
@@ -4511,26 +4697,30 @@ namespace Google.ProtocolBuffers.TestProtos { }
[global::System.CLSCompliant(false)]
public Builder SetRepeatedUint64(int index, ulong value) {
+ PrepareBuilder();
result.repeatedUint64_[index] = value;
return this;
}
[global::System.CLSCompliant(false)]
public Builder AddRepeatedUint64(ulong value) {
+ PrepareBuilder();
result.repeatedUint64_.Add(value);
return this;
}
[global::System.CLSCompliant(false)]
public Builder AddRangeRepeatedUint64(scg::IEnumerable<ulong> values) {
+ PrepareBuilder();
base.AddRange(values, result.repeatedUint64_);
return this;
}
public Builder ClearRepeatedUint64() {
+ PrepareBuilder();
result.repeatedUint64_.Clear();
return this;
}
public pbc::IPopsicleList<int> RepeatedSint32List {
- get { return result.repeatedSint32_; }
+ get { return PrepareBuilder().repeatedSint32_; }
}
public int RepeatedSint32Count {
get { return result.RepeatedSint32Count; }
@@ -4539,24 +4729,28 @@ namespace Google.ProtocolBuffers.TestProtos { return result.GetRepeatedSint32(index);
}
public Builder SetRepeatedSint32(int index, int value) {
+ PrepareBuilder();
result.repeatedSint32_[index] = value;
return this;
}
public Builder AddRepeatedSint32(int value) {
+ PrepareBuilder();
result.repeatedSint32_.Add(value);
return this;
}
public Builder AddRangeRepeatedSint32(scg::IEnumerable<int> values) {
+ PrepareBuilder();
base.AddRange(values, result.repeatedSint32_);
return this;
}
public Builder ClearRepeatedSint32() {
+ PrepareBuilder();
result.repeatedSint32_.Clear();
return this;
}
public pbc::IPopsicleList<long> RepeatedSint64List {
- get { return result.repeatedSint64_; }
+ get { return PrepareBuilder().repeatedSint64_; }
}
public int RepeatedSint64Count {
get { return result.RepeatedSint64Count; }
@@ -4565,25 +4759,29 @@ namespace Google.ProtocolBuffers.TestProtos { return result.GetRepeatedSint64(index);
}
public Builder SetRepeatedSint64(int index, long value) {
+ PrepareBuilder();
result.repeatedSint64_[index] = value;
return this;
}
public Builder AddRepeatedSint64(long value) {
+ PrepareBuilder();
result.repeatedSint64_.Add(value);
return this;
}
public Builder AddRangeRepeatedSint64(scg::IEnumerable<long> values) {
+ PrepareBuilder();
base.AddRange(values, result.repeatedSint64_);
return this;
}
public Builder ClearRepeatedSint64() {
+ PrepareBuilder();
result.repeatedSint64_.Clear();
return this;
}
[global::System.CLSCompliant(false)]
public pbc::IPopsicleList<uint> RepeatedFixed32List {
- get { return result.repeatedFixed32_; }
+ get { return PrepareBuilder().repeatedFixed32_; }
}
public int RepeatedFixed32Count {
get { return result.RepeatedFixed32Count; }
@@ -4594,27 +4792,31 @@ namespace Google.ProtocolBuffers.TestProtos { }
[global::System.CLSCompliant(false)]
public Builder SetRepeatedFixed32(int index, uint value) {
+ PrepareBuilder();
result.repeatedFixed32_[index] = value;
return this;
}
[global::System.CLSCompliant(false)]
public Builder AddRepeatedFixed32(uint value) {
+ PrepareBuilder();
result.repeatedFixed32_.Add(value);
return this;
}
[global::System.CLSCompliant(false)]
public Builder AddRangeRepeatedFixed32(scg::IEnumerable<uint> values) {
+ PrepareBuilder();
base.AddRange(values, result.repeatedFixed32_);
return this;
}
public Builder ClearRepeatedFixed32() {
+ PrepareBuilder();
result.repeatedFixed32_.Clear();
return this;
}
[global::System.CLSCompliant(false)]
public pbc::IPopsicleList<ulong> RepeatedFixed64List {
- get { return result.repeatedFixed64_; }
+ get { return PrepareBuilder().repeatedFixed64_; }
}
public int RepeatedFixed64Count {
get { return result.RepeatedFixed64Count; }
@@ -4625,26 +4827,30 @@ namespace Google.ProtocolBuffers.TestProtos { }
[global::System.CLSCompliant(false)]
public Builder SetRepeatedFixed64(int index, ulong value) {
+ PrepareBuilder();
result.repeatedFixed64_[index] = value;
return this;
}
[global::System.CLSCompliant(false)]
public Builder AddRepeatedFixed64(ulong value) {
+ PrepareBuilder();
result.repeatedFixed64_.Add(value);
return this;
}
[global::System.CLSCompliant(false)]
public Builder AddRangeRepeatedFixed64(scg::IEnumerable<ulong> values) {
+ PrepareBuilder();
base.AddRange(values, result.repeatedFixed64_);
return this;
}
public Builder ClearRepeatedFixed64() {
+ PrepareBuilder();
result.repeatedFixed64_.Clear();
return this;
}
public pbc::IPopsicleList<int> RepeatedSfixed32List {
- get { return result.repeatedSfixed32_; }
+ get { return PrepareBuilder().repeatedSfixed32_; }
}
public int RepeatedSfixed32Count {
get { return result.RepeatedSfixed32Count; }
@@ -4653,24 +4859,28 @@ namespace Google.ProtocolBuffers.TestProtos { return result.GetRepeatedSfixed32(index);
}
public Builder SetRepeatedSfixed32(int index, int value) {
+ PrepareBuilder();
result.repeatedSfixed32_[index] = value;
return this;
}
public Builder AddRepeatedSfixed32(int value) {
+ PrepareBuilder();
result.repeatedSfixed32_.Add(value);
return this;
}
public Builder AddRangeRepeatedSfixed32(scg::IEnumerable<int> values) {
+ PrepareBuilder();
base.AddRange(values, result.repeatedSfixed32_);
return this;
}
public Builder ClearRepeatedSfixed32() {
+ PrepareBuilder();
result.repeatedSfixed32_.Clear();
return this;
}
public pbc::IPopsicleList<long> RepeatedSfixed64List {
- get { return result.repeatedSfixed64_; }
+ get { return PrepareBuilder().repeatedSfixed64_; }
}
public int RepeatedSfixed64Count {
get { return result.RepeatedSfixed64Count; }
@@ -4679,24 +4889,28 @@ namespace Google.ProtocolBuffers.TestProtos { return result.GetRepeatedSfixed64(index);
}
public Builder SetRepeatedSfixed64(int index, long value) {
+ PrepareBuilder();
result.repeatedSfixed64_[index] = value;
return this;
}
public Builder AddRepeatedSfixed64(long value) {
+ PrepareBuilder();
result.repeatedSfixed64_.Add(value);
return this;
}
public Builder AddRangeRepeatedSfixed64(scg::IEnumerable<long> values) {
+ PrepareBuilder();
base.AddRange(values, result.repeatedSfixed64_);
return this;
}
public Builder ClearRepeatedSfixed64() {
+ PrepareBuilder();
result.repeatedSfixed64_.Clear();
return this;
}
public pbc::IPopsicleList<float> RepeatedFloatList {
- get { return result.repeatedFloat_; }
+ get { return PrepareBuilder().repeatedFloat_; }
}
public int RepeatedFloatCount {
get { return result.RepeatedFloatCount; }
@@ -4705,24 +4919,28 @@ namespace Google.ProtocolBuffers.TestProtos { return result.GetRepeatedFloat(index);
}
public Builder SetRepeatedFloat(int index, float value) {
+ PrepareBuilder();
result.repeatedFloat_[index] = value;
return this;
}
public Builder AddRepeatedFloat(float value) {
+ PrepareBuilder();
result.repeatedFloat_.Add(value);
return this;
}
public Builder AddRangeRepeatedFloat(scg::IEnumerable<float> values) {
+ PrepareBuilder();
base.AddRange(values, result.repeatedFloat_);
return this;
}
public Builder ClearRepeatedFloat() {
+ PrepareBuilder();
result.repeatedFloat_.Clear();
return this;
}
public pbc::IPopsicleList<double> RepeatedDoubleList {
- get { return result.repeatedDouble_; }
+ get { return PrepareBuilder().repeatedDouble_; }
}
public int RepeatedDoubleCount {
get { return result.RepeatedDoubleCount; }
@@ -4731,24 +4949,28 @@ namespace Google.ProtocolBuffers.TestProtos { return result.GetRepeatedDouble(index);
}
public Builder SetRepeatedDouble(int index, double value) {
+ PrepareBuilder();
result.repeatedDouble_[index] = value;
return this;
}
public Builder AddRepeatedDouble(double value) {
+ PrepareBuilder();
result.repeatedDouble_.Add(value);
return this;
}
public Builder AddRangeRepeatedDouble(scg::IEnumerable<double> values) {
+ PrepareBuilder();
base.AddRange(values, result.repeatedDouble_);
return this;
}
public Builder ClearRepeatedDouble() {
+ PrepareBuilder();
result.repeatedDouble_.Clear();
return this;
}
public pbc::IPopsicleList<bool> RepeatedBoolList {
- get { return result.repeatedBool_; }
+ get { return PrepareBuilder().repeatedBool_; }
}
public int RepeatedBoolCount {
get { return result.RepeatedBoolCount; }
@@ -4757,24 +4979,28 @@ namespace Google.ProtocolBuffers.TestProtos { return result.GetRepeatedBool(index);
}
public Builder SetRepeatedBool(int index, bool value) {
+ PrepareBuilder();
result.repeatedBool_[index] = value;
return this;
}
public Builder AddRepeatedBool(bool value) {
+ PrepareBuilder();
result.repeatedBool_.Add(value);
return this;
}
public Builder AddRangeRepeatedBool(scg::IEnumerable<bool> values) {
+ PrepareBuilder();
base.AddRange(values, result.repeatedBool_);
return this;
}
public Builder ClearRepeatedBool() {
+ PrepareBuilder();
result.repeatedBool_.Clear();
return this;
}
public pbc::IPopsicleList<string> RepeatedStringList {
- get { return result.repeatedString_; }
+ get { return PrepareBuilder().repeatedString_; }
}
public int RepeatedStringCount {
get { return result.RepeatedStringCount; }
@@ -4784,25 +5010,29 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetRepeatedString(int index, string value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.repeatedString_[index] = value;
return this;
}
public Builder AddRepeatedString(string value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.repeatedString_.Add(value);
return this;
}
public Builder AddRangeRepeatedString(scg::IEnumerable<string> values) {
+ PrepareBuilder();
base.AddRange(values, result.repeatedString_);
return this;
}
public Builder ClearRepeatedString() {
+ PrepareBuilder();
result.repeatedString_.Clear();
return this;
}
public pbc::IPopsicleList<pb::ByteString> RepeatedBytesList {
- get { return result.repeatedBytes_; }
+ get { return PrepareBuilder().repeatedBytes_; }
}
public int RepeatedBytesCount {
get { return result.RepeatedBytesCount; }
@@ -4812,25 +5042,29 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetRepeatedBytes(int index, pb::ByteString value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.repeatedBytes_[index] = value;
return this;
}
public Builder AddRepeatedBytes(pb::ByteString value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.repeatedBytes_.Add(value);
return this;
}
public Builder AddRangeRepeatedBytes(scg::IEnumerable<pb::ByteString> values) {
+ PrepareBuilder();
base.AddRange(values, result.repeatedBytes_);
return this;
}
public Builder ClearRepeatedBytes() {
+ PrepareBuilder();
result.repeatedBytes_.Clear();
return this;
}
public pbc::IPopsicleList<global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.RepeatedGroup> RepeatedGroupList {
- get { return result.repeatedGroup_; }
+ get { return PrepareBuilder().repeatedGroup_; }
}
public int RepeatedGroupCount {
get { return result.RepeatedGroupCount; }
@@ -4840,35 +5074,41 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetRepeatedGroup(int index, global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.RepeatedGroup value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.repeatedGroup_[index] = value;
return this;
}
public Builder SetRepeatedGroup(int index, global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.RepeatedGroup.Builder builderForValue) {
pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue");
+ PrepareBuilder();
result.repeatedGroup_[index] = builderForValue.Build();
return this;
}
public Builder AddRepeatedGroup(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.RepeatedGroup value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.repeatedGroup_.Add(value);
return this;
}
public Builder AddRepeatedGroup(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.RepeatedGroup.Builder builderForValue) {
pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue");
+ PrepareBuilder();
result.repeatedGroup_.Add(builderForValue.Build());
return this;
}
public Builder AddRangeRepeatedGroup(scg::IEnumerable<global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.RepeatedGroup> values) {
+ PrepareBuilder();
base.AddRange(values, result.repeatedGroup_);
return this;
}
public Builder ClearRepeatedGroup() {
+ PrepareBuilder();
result.repeatedGroup_.Clear();
return this;
}
public pbc::IPopsicleList<global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage> RepeatedNestedMessageList {
- get { return result.repeatedNestedMessage_; }
+ get { return PrepareBuilder().repeatedNestedMessage_; }
}
public int RepeatedNestedMessageCount {
get { return result.RepeatedNestedMessageCount; }
@@ -4878,35 +5118,41 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetRepeatedNestedMessage(int index, global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.repeatedNestedMessage_[index] = value;
return this;
}
public Builder SetRepeatedNestedMessage(int index, global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage.Builder builderForValue) {
pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue");
+ PrepareBuilder();
result.repeatedNestedMessage_[index] = builderForValue.Build();
return this;
}
public Builder AddRepeatedNestedMessage(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.repeatedNestedMessage_.Add(value);
return this;
}
public Builder AddRepeatedNestedMessage(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage.Builder builderForValue) {
pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue");
+ PrepareBuilder();
result.repeatedNestedMessage_.Add(builderForValue.Build());
return this;
}
public Builder AddRangeRepeatedNestedMessage(scg::IEnumerable<global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage> values) {
+ PrepareBuilder();
base.AddRange(values, result.repeatedNestedMessage_);
return this;
}
public Builder ClearRepeatedNestedMessage() {
+ PrepareBuilder();
result.repeatedNestedMessage_.Clear();
return this;
}
public pbc::IPopsicleList<global::Google.ProtocolBuffers.TestProtos.ForeignMessage> RepeatedForeignMessageList {
- get { return result.repeatedForeignMessage_; }
+ get { return PrepareBuilder().repeatedForeignMessage_; }
}
public int RepeatedForeignMessageCount {
get { return result.RepeatedForeignMessageCount; }
@@ -4916,35 +5162,41 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetRepeatedForeignMessage(int index, global::Google.ProtocolBuffers.TestProtos.ForeignMessage value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.repeatedForeignMessage_[index] = value;
return this;
}
public Builder SetRepeatedForeignMessage(int index, global::Google.ProtocolBuffers.TestProtos.ForeignMessage.Builder builderForValue) {
pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue");
+ PrepareBuilder();
result.repeatedForeignMessage_[index] = builderForValue.Build();
return this;
}
public Builder AddRepeatedForeignMessage(global::Google.ProtocolBuffers.TestProtos.ForeignMessage value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.repeatedForeignMessage_.Add(value);
return this;
}
public Builder AddRepeatedForeignMessage(global::Google.ProtocolBuffers.TestProtos.ForeignMessage.Builder builderForValue) {
pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue");
+ PrepareBuilder();
result.repeatedForeignMessage_.Add(builderForValue.Build());
return this;
}
public Builder AddRangeRepeatedForeignMessage(scg::IEnumerable<global::Google.ProtocolBuffers.TestProtos.ForeignMessage> values) {
+ PrepareBuilder();
base.AddRange(values, result.repeatedForeignMessage_);
return this;
}
public Builder ClearRepeatedForeignMessage() {
+ PrepareBuilder();
result.repeatedForeignMessage_.Clear();
return this;
}
public pbc::IPopsicleList<global::Google.ProtocolBuffers.TestProtos.ImportMessage> RepeatedImportMessageList {
- get { return result.repeatedImportMessage_; }
+ get { return PrepareBuilder().repeatedImportMessage_; }
}
public int RepeatedImportMessageCount {
get { return result.RepeatedImportMessageCount; }
@@ -4954,35 +5206,41 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetRepeatedImportMessage(int index, global::Google.ProtocolBuffers.TestProtos.ImportMessage value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.repeatedImportMessage_[index] = value;
return this;
}
public Builder SetRepeatedImportMessage(int index, global::Google.ProtocolBuffers.TestProtos.ImportMessage.Builder builderForValue) {
pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue");
+ PrepareBuilder();
result.repeatedImportMessage_[index] = builderForValue.Build();
return this;
}
public Builder AddRepeatedImportMessage(global::Google.ProtocolBuffers.TestProtos.ImportMessage value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.repeatedImportMessage_.Add(value);
return this;
}
public Builder AddRepeatedImportMessage(global::Google.ProtocolBuffers.TestProtos.ImportMessage.Builder builderForValue) {
pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue");
+ PrepareBuilder();
result.repeatedImportMessage_.Add(builderForValue.Build());
return this;
}
public Builder AddRangeRepeatedImportMessage(scg::IEnumerable<global::Google.ProtocolBuffers.TestProtos.ImportMessage> values) {
+ PrepareBuilder();
base.AddRange(values, result.repeatedImportMessage_);
return this;
}
public Builder ClearRepeatedImportMessage() {
+ PrepareBuilder();
result.repeatedImportMessage_.Clear();
return this;
}
public pbc::IPopsicleList<global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedEnum> RepeatedNestedEnumList {
- get { return result.repeatedNestedEnum_; }
+ get { return PrepareBuilder().repeatedNestedEnum_; }
}
public int RepeatedNestedEnumCount {
get { return result.RepeatedNestedEnumCount; }
@@ -4991,24 +5249,28 @@ namespace Google.ProtocolBuffers.TestProtos { return result.GetRepeatedNestedEnum(index);
}
public Builder SetRepeatedNestedEnum(int index, global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedEnum value) {
+ PrepareBuilder();
result.repeatedNestedEnum_[index] = value;
return this;
}
public Builder AddRepeatedNestedEnum(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedEnum value) {
+ PrepareBuilder();
result.repeatedNestedEnum_.Add(value);
return this;
}
public Builder AddRangeRepeatedNestedEnum(scg::IEnumerable<global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedEnum> values) {
+ PrepareBuilder();
base.AddRange(values, result.repeatedNestedEnum_);
return this;
}
public Builder ClearRepeatedNestedEnum() {
+ PrepareBuilder();
result.repeatedNestedEnum_.Clear();
return this;
}
public pbc::IPopsicleList<global::Google.ProtocolBuffers.TestProtos.ForeignEnum> RepeatedForeignEnumList {
- get { return result.repeatedForeignEnum_; }
+ get { return PrepareBuilder().repeatedForeignEnum_; }
}
public int RepeatedForeignEnumCount {
get { return result.RepeatedForeignEnumCount; }
@@ -5017,24 +5279,28 @@ namespace Google.ProtocolBuffers.TestProtos { return result.GetRepeatedForeignEnum(index);
}
public Builder SetRepeatedForeignEnum(int index, global::Google.ProtocolBuffers.TestProtos.ForeignEnum value) {
+ PrepareBuilder();
result.repeatedForeignEnum_[index] = value;
return this;
}
public Builder AddRepeatedForeignEnum(global::Google.ProtocolBuffers.TestProtos.ForeignEnum value) {
+ PrepareBuilder();
result.repeatedForeignEnum_.Add(value);
return this;
}
public Builder AddRangeRepeatedForeignEnum(scg::IEnumerable<global::Google.ProtocolBuffers.TestProtos.ForeignEnum> values) {
+ PrepareBuilder();
base.AddRange(values, result.repeatedForeignEnum_);
return this;
}
public Builder ClearRepeatedForeignEnum() {
+ PrepareBuilder();
result.repeatedForeignEnum_.Clear();
return this;
}
public pbc::IPopsicleList<global::Google.ProtocolBuffers.TestProtos.ImportEnum> RepeatedImportEnumList {
- get { return result.repeatedImportEnum_; }
+ get { return PrepareBuilder().repeatedImportEnum_; }
}
public int RepeatedImportEnumCount {
get { return result.RepeatedImportEnumCount; }
@@ -5043,24 +5309,28 @@ namespace Google.ProtocolBuffers.TestProtos { return result.GetRepeatedImportEnum(index);
}
public Builder SetRepeatedImportEnum(int index, global::Google.ProtocolBuffers.TestProtos.ImportEnum value) {
+ PrepareBuilder();
result.repeatedImportEnum_[index] = value;
return this;
}
public Builder AddRepeatedImportEnum(global::Google.ProtocolBuffers.TestProtos.ImportEnum value) {
+ PrepareBuilder();
result.repeatedImportEnum_.Add(value);
return this;
}
public Builder AddRangeRepeatedImportEnum(scg::IEnumerable<global::Google.ProtocolBuffers.TestProtos.ImportEnum> values) {
+ PrepareBuilder();
base.AddRange(values, result.repeatedImportEnum_);
return this;
}
public Builder ClearRepeatedImportEnum() {
+ PrepareBuilder();
result.repeatedImportEnum_.Clear();
return this;
}
public pbc::IPopsicleList<string> RepeatedStringPieceList {
- get { return result.repeatedStringPiece_; }
+ get { return PrepareBuilder().repeatedStringPiece_; }
}
public int RepeatedStringPieceCount {
get { return result.RepeatedStringPieceCount; }
@@ -5070,25 +5340,29 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetRepeatedStringPiece(int index, string value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.repeatedStringPiece_[index] = value;
return this;
}
public Builder AddRepeatedStringPiece(string value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.repeatedStringPiece_.Add(value);
return this;
}
public Builder AddRangeRepeatedStringPiece(scg::IEnumerable<string> values) {
+ PrepareBuilder();
base.AddRange(values, result.repeatedStringPiece_);
return this;
}
public Builder ClearRepeatedStringPiece() {
+ PrepareBuilder();
result.repeatedStringPiece_.Clear();
return this;
}
public pbc::IPopsicleList<string> RepeatedCordList {
- get { return result.repeatedCord_; }
+ get { return PrepareBuilder().repeatedCord_; }
}
public int RepeatedCordCount {
get { return result.RepeatedCordCount; }
@@ -5098,19 +5372,23 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetRepeatedCord(int index, string value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.repeatedCord_[index] = value;
return this;
}
public Builder AddRepeatedCord(string value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.repeatedCord_.Add(value);
return this;
}
public Builder AddRangeRepeatedCord(scg::IEnumerable<string> values) {
+ PrepareBuilder();
base.AddRange(values, result.repeatedCord_);
return this;
}
public Builder ClearRepeatedCord() {
+ PrepareBuilder();
result.repeatedCord_.Clear();
return this;
}
@@ -5123,11 +5401,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetDefaultInt32(value); }
}
public Builder SetDefaultInt32(int value) {
+ PrepareBuilder();
result.hasDefaultInt32 = true;
result.defaultInt32_ = value;
return this;
}
public Builder ClearDefaultInt32() {
+ PrepareBuilder();
result.hasDefaultInt32 = false;
result.defaultInt32_ = 41;
return this;
@@ -5141,11 +5421,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetDefaultInt64(value); }
}
public Builder SetDefaultInt64(long value) {
+ PrepareBuilder();
result.hasDefaultInt64 = true;
result.defaultInt64_ = value;
return this;
}
public Builder ClearDefaultInt64() {
+ PrepareBuilder();
result.hasDefaultInt64 = false;
result.defaultInt64_ = 42L;
return this;
@@ -5161,11 +5443,13 @@ namespace Google.ProtocolBuffers.TestProtos { }
[global::System.CLSCompliant(false)]
public Builder SetDefaultUint32(uint value) {
+ PrepareBuilder();
result.hasDefaultUint32 = true;
result.defaultUint32_ = value;
return this;
}
public Builder ClearDefaultUint32() {
+ PrepareBuilder();
result.hasDefaultUint32 = false;
result.defaultUint32_ = 43;
return this;
@@ -5181,11 +5465,13 @@ namespace Google.ProtocolBuffers.TestProtos { }
[global::System.CLSCompliant(false)]
public Builder SetDefaultUint64(ulong value) {
+ PrepareBuilder();
result.hasDefaultUint64 = true;
result.defaultUint64_ = value;
return this;
}
public Builder ClearDefaultUint64() {
+ PrepareBuilder();
result.hasDefaultUint64 = false;
result.defaultUint64_ = 44UL;
return this;
@@ -5199,11 +5485,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetDefaultSint32(value); }
}
public Builder SetDefaultSint32(int value) {
+ PrepareBuilder();
result.hasDefaultSint32 = true;
result.defaultSint32_ = value;
return this;
}
public Builder ClearDefaultSint32() {
+ PrepareBuilder();
result.hasDefaultSint32 = false;
result.defaultSint32_ = -45;
return this;
@@ -5217,11 +5505,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetDefaultSint64(value); }
}
public Builder SetDefaultSint64(long value) {
+ PrepareBuilder();
result.hasDefaultSint64 = true;
result.defaultSint64_ = value;
return this;
}
public Builder ClearDefaultSint64() {
+ PrepareBuilder();
result.hasDefaultSint64 = false;
result.defaultSint64_ = 46;
return this;
@@ -5237,11 +5527,13 @@ namespace Google.ProtocolBuffers.TestProtos { }
[global::System.CLSCompliant(false)]
public Builder SetDefaultFixed32(uint value) {
+ PrepareBuilder();
result.hasDefaultFixed32 = true;
result.defaultFixed32_ = value;
return this;
}
public Builder ClearDefaultFixed32() {
+ PrepareBuilder();
result.hasDefaultFixed32 = false;
result.defaultFixed32_ = 47;
return this;
@@ -5257,11 +5549,13 @@ namespace Google.ProtocolBuffers.TestProtos { }
[global::System.CLSCompliant(false)]
public Builder SetDefaultFixed64(ulong value) {
+ PrepareBuilder();
result.hasDefaultFixed64 = true;
result.defaultFixed64_ = value;
return this;
}
public Builder ClearDefaultFixed64() {
+ PrepareBuilder();
result.hasDefaultFixed64 = false;
result.defaultFixed64_ = 48;
return this;
@@ -5275,11 +5569,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetDefaultSfixed32(value); }
}
public Builder SetDefaultSfixed32(int value) {
+ PrepareBuilder();
result.hasDefaultSfixed32 = true;
result.defaultSfixed32_ = value;
return this;
}
public Builder ClearDefaultSfixed32() {
+ PrepareBuilder();
result.hasDefaultSfixed32 = false;
result.defaultSfixed32_ = 49;
return this;
@@ -5293,11 +5589,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetDefaultSfixed64(value); }
}
public Builder SetDefaultSfixed64(long value) {
+ PrepareBuilder();
result.hasDefaultSfixed64 = true;
result.defaultSfixed64_ = value;
return this;
}
public Builder ClearDefaultSfixed64() {
+ PrepareBuilder();
result.hasDefaultSfixed64 = false;
result.defaultSfixed64_ = -50;
return this;
@@ -5311,11 +5609,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetDefaultFloat(value); }
}
public Builder SetDefaultFloat(float value) {
+ PrepareBuilder();
result.hasDefaultFloat = true;
result.defaultFloat_ = value;
return this;
}
public Builder ClearDefaultFloat() {
+ PrepareBuilder();
result.hasDefaultFloat = false;
result.defaultFloat_ = 51.5F;
return this;
@@ -5329,11 +5629,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetDefaultDouble(value); }
}
public Builder SetDefaultDouble(double value) {
+ PrepareBuilder();
result.hasDefaultDouble = true;
result.defaultDouble_ = value;
return this;
}
public Builder ClearDefaultDouble() {
+ PrepareBuilder();
result.hasDefaultDouble = false;
result.defaultDouble_ = 52000D;
return this;
@@ -5347,11 +5649,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetDefaultBool(value); }
}
public Builder SetDefaultBool(bool value) {
+ PrepareBuilder();
result.hasDefaultBool = true;
result.defaultBool_ = value;
return this;
}
public Builder ClearDefaultBool() {
+ PrepareBuilder();
result.hasDefaultBool = false;
result.defaultBool_ = true;
return this;
@@ -5366,11 +5670,13 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetDefaultString(string value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.hasDefaultString = true;
result.defaultString_ = value;
return this;
}
public Builder ClearDefaultString() {
+ PrepareBuilder();
result.hasDefaultString = false;
result.defaultString_ = "hello";
return this;
@@ -5385,11 +5691,13 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetDefaultBytes(pb::ByteString value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.hasDefaultBytes = true;
result.defaultBytes_ = value;
return this;
}
public Builder ClearDefaultBytes() {
+ PrepareBuilder();
result.hasDefaultBytes = false;
result.defaultBytes_ = (pb::ByteString) global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Descriptor.Fields[62].DefaultValue;
return this;
@@ -5403,11 +5711,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetDefaultNestedEnum(value); }
}
public Builder SetDefaultNestedEnum(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedEnum value) {
+ PrepareBuilder();
result.hasDefaultNestedEnum = true;
result.defaultNestedEnum_ = value;
return this;
}
public Builder ClearDefaultNestedEnum() {
+ PrepareBuilder();
result.hasDefaultNestedEnum = false;
result.defaultNestedEnum_ = global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedEnum.BAR;
return this;
@@ -5421,11 +5731,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetDefaultForeignEnum(value); }
}
public Builder SetDefaultForeignEnum(global::Google.ProtocolBuffers.TestProtos.ForeignEnum value) {
+ PrepareBuilder();
result.hasDefaultForeignEnum = true;
result.defaultForeignEnum_ = value;
return this;
}
public Builder ClearDefaultForeignEnum() {
+ PrepareBuilder();
result.hasDefaultForeignEnum = false;
result.defaultForeignEnum_ = global::Google.ProtocolBuffers.TestProtos.ForeignEnum.FOREIGN_BAR;
return this;
@@ -5439,11 +5751,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetDefaultImportEnum(value); }
}
public Builder SetDefaultImportEnum(global::Google.ProtocolBuffers.TestProtos.ImportEnum value) {
+ PrepareBuilder();
result.hasDefaultImportEnum = true;
result.defaultImportEnum_ = value;
return this;
}
public Builder ClearDefaultImportEnum() {
+ PrepareBuilder();
result.hasDefaultImportEnum = false;
result.defaultImportEnum_ = global::Google.ProtocolBuffers.TestProtos.ImportEnum.IMPORT_BAR;
return this;
@@ -5458,11 +5772,13 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetDefaultStringPiece(string value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.hasDefaultStringPiece = true;
result.defaultStringPiece_ = value;
return this;
}
public Builder ClearDefaultStringPiece() {
+ PrepareBuilder();
result.hasDefaultStringPiece = false;
result.defaultStringPiece_ = "abc";
return this;
@@ -5477,11 +5793,13 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetDefaultCord(string value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.hasDefaultCord = true;
result.defaultCord_ = value;
return this;
}
public Builder ClearDefaultCord() {
+ PrepareBuilder();
result.hasDefaultCord = false;
result.defaultCord_ = "123";
return this;
@@ -5594,7 +5912,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(TestDeprecatedFields prototype) {
- return (Builder) new Builder().MergeFrom(prototype);
+ return new Builder(prototype);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -5604,21 +5922,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder {
get { return this; }
}
- public Builder() {}
+ public Builder() {
+ result = DefaultInstance ?? new TestDeprecatedFields();
+ builderIsReadOnly = result == DefaultInstance;
+ }
+ internal Builder(TestDeprecatedFields cloneFrom) {
+ result = cloneFrom;
+ builderIsReadOnly = true;
+ }
+
+ bool builderIsReadOnly;
+ TestDeprecatedFields result;
- TestDeprecatedFields result = new TestDeprecatedFields();
+ private TestDeprecatedFields PrepareBuilder() {
+ if (builderIsReadOnly) {
+ TestDeprecatedFields original = result;
+ result = new TestDeprecatedFields();
+ builderIsReadOnly = false;
+ MergeFrom(original);
+ }
+ return result;
+ }
+
+ public override bool IsInitialized {
+ get { return result.IsInitialized; }
+ }
protected override TestDeprecatedFields MessageBeingBuilt {
- get { return result; }
+ get { return PrepareBuilder(); }
}
public override Builder Clear() {
- result = new TestDeprecatedFields();
+ result = DefaultInstance ?? new TestDeprecatedFields();
+ builderIsReadOnly = true;
return this;
}
public override Builder Clone() {
- return new Builder().MergeFrom(result);
+ if (builderIsReadOnly) {
+ return new Builder(result);
+ } else {
+ return new Builder().MergeFrom(result);
+ }
}
public override pbd::MessageDescriptor DescriptorForType {
@@ -5630,12 +5975,11 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override TestDeprecatedFields BuildPartial() {
- if (result == null) {
- throw new global::System.InvalidOperationException("build() has already been called on this Builder");
+ if (builderIsReadOnly) {
+ return result;
}
- TestDeprecatedFields returnMe = result;
- result = null;
- return returnMe;
+ builderIsReadOnly = true;
+ return result;
}
public override Builder MergeFrom(pb::IMessage other) {
@@ -5649,6 +5993,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder MergeFrom(TestDeprecatedFields other) {
if (other == global::Google.ProtocolBuffers.TestProtos.TestDeprecatedFields.DefaultInstance) return this;
+ PrepareBuilder();
if (other.HasDeprecatedInt32) {
DeprecatedInt32 = other.DeprecatedInt32;
}
@@ -5661,6 +6006,7 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
+ PrepareBuilder();
pb::UnknownFieldSet.Builder unknownFields = null;
uint tag;
string field_name;
@@ -5716,11 +6062,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetDeprecatedInt32(value); }
}
public Builder SetDeprecatedInt32(int value) {
+ PrepareBuilder();
result.hasDeprecatedInt32 = true;
result.deprecatedInt32_ = value;
return this;
}
public Builder ClearDeprecatedInt32() {
+ PrepareBuilder();
result.hasDeprecatedInt32 = false;
result.deprecatedInt32_ = 0;
return this;
@@ -5833,7 +6181,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(ForeignMessage prototype) {
- return (Builder) new Builder().MergeFrom(prototype);
+ return new Builder(prototype);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -5843,21 +6191,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder {
get { return this; }
}
- public Builder() {}
+ public Builder() {
+ result = DefaultInstance ?? new ForeignMessage();
+ builderIsReadOnly = result == DefaultInstance;
+ }
+ internal Builder(ForeignMessage cloneFrom) {
+ result = cloneFrom;
+ builderIsReadOnly = true;
+ }
- ForeignMessage result = new ForeignMessage();
+ bool builderIsReadOnly;
+ ForeignMessage result;
+
+ private ForeignMessage PrepareBuilder() {
+ if (builderIsReadOnly) {
+ ForeignMessage original = result;
+ result = new ForeignMessage();
+ builderIsReadOnly = false;
+ MergeFrom(original);
+ }
+ return result;
+ }
+
+ public override bool IsInitialized {
+ get { return result.IsInitialized; }
+ }
protected override ForeignMessage MessageBeingBuilt {
- get { return result; }
+ get { return PrepareBuilder(); }
}
public override Builder Clear() {
- result = new ForeignMessage();
+ result = DefaultInstance ?? new ForeignMessage();
+ builderIsReadOnly = true;
return this;
}
public override Builder Clone() {
- return new Builder().MergeFrom(result);
+ if (builderIsReadOnly) {
+ return new Builder(result);
+ } else {
+ return new Builder().MergeFrom(result);
+ }
}
public override pbd::MessageDescriptor DescriptorForType {
@@ -5869,12 +6244,11 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override ForeignMessage BuildPartial() {
- if (result == null) {
- throw new global::System.InvalidOperationException("build() has already been called on this Builder");
+ if (builderIsReadOnly) {
+ return result;
}
- ForeignMessage returnMe = result;
- result = null;
- return returnMe;
+ builderIsReadOnly = true;
+ return result;
}
public override Builder MergeFrom(pb::IMessage other) {
@@ -5888,6 +6262,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder MergeFrom(ForeignMessage other) {
if (other == global::Google.ProtocolBuffers.TestProtos.ForeignMessage.DefaultInstance) return this;
+ PrepareBuilder();
if (other.HasC) {
C = other.C;
}
@@ -5900,6 +6275,7 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
+ PrepareBuilder();
pb::UnknownFieldSet.Builder unknownFields = null;
uint tag;
string field_name;
@@ -5955,11 +6331,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetC(value); }
}
public Builder SetC(int value) {
+ PrepareBuilder();
result.hasC = true;
result.c_ = value;
return this;
}
public Builder ClearC() {
+ PrepareBuilder();
result.hasC = false;
result.c_ = 0;
return this;
@@ -6060,7 +6438,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(TestAllExtensions prototype) {
- return (Builder) new Builder().MergeFrom(prototype);
+ return new Builder(prototype);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -6070,21 +6448,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder {
get { return this; }
}
- public Builder() {}
+ public Builder() {
+ result = DefaultInstance ?? new TestAllExtensions();
+ builderIsReadOnly = result == DefaultInstance;
+ }
+ internal Builder(TestAllExtensions cloneFrom) {
+ result = cloneFrom;
+ builderIsReadOnly = true;
+ }
- TestAllExtensions result = new TestAllExtensions();
+ bool builderIsReadOnly;
+ TestAllExtensions result;
+
+ private TestAllExtensions PrepareBuilder() {
+ if (builderIsReadOnly) {
+ TestAllExtensions original = result;
+ result = new TestAllExtensions();
+ builderIsReadOnly = false;
+ MergeFrom(original);
+ }
+ return result;
+ }
+
+ public override bool IsInitialized {
+ get { return result.IsInitialized; }
+ }
protected override TestAllExtensions MessageBeingBuilt {
- get { return result; }
+ get { return PrepareBuilder(); }
}
public override Builder Clear() {
- result = new TestAllExtensions();
+ result = DefaultInstance ?? new TestAllExtensions();
+ builderIsReadOnly = true;
return this;
}
public override Builder Clone() {
- return new Builder().MergeFrom(result);
+ if (builderIsReadOnly) {
+ return new Builder(result);
+ } else {
+ return new Builder().MergeFrom(result);
+ }
}
public override pbd::MessageDescriptor DescriptorForType {
@@ -6096,12 +6501,11 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override TestAllExtensions BuildPartial() {
- if (result == null) {
- throw new global::System.InvalidOperationException("build() has already been called on this Builder");
+ if (builderIsReadOnly) {
+ return result;
}
- TestAllExtensions returnMe = result;
- result = null;
- return returnMe;
+ builderIsReadOnly = true;
+ return result;
}
public override Builder MergeFrom(pb::IMessage other) {
@@ -6115,6 +6519,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder MergeFrom(TestAllExtensions other) {
if (other == global::Google.ProtocolBuffers.TestProtos.TestAllExtensions.DefaultInstance) return this;
+ PrepareBuilder();
this.MergeExtensionFields(other);
this.MergeUnknownFields(other.UnknownFields);
return this;
@@ -6125,6 +6530,7 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
+ PrepareBuilder();
pb::UnknownFieldSet.Builder unknownFields = null;
uint tag;
string field_name;
@@ -6275,7 +6681,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(OptionalGroup_extension prototype) {
- return (Builder) new Builder().MergeFrom(prototype);
+ return new Builder(prototype);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -6285,21 +6691,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder {
get { return this; }
}
- public Builder() {}
+ public Builder() {
+ result = DefaultInstance ?? new OptionalGroup_extension();
+ builderIsReadOnly = result == DefaultInstance;
+ }
+ internal Builder(OptionalGroup_extension cloneFrom) {
+ result = cloneFrom;
+ builderIsReadOnly = true;
+ }
- OptionalGroup_extension result = new OptionalGroup_extension();
+ bool builderIsReadOnly;
+ OptionalGroup_extension result;
+
+ private OptionalGroup_extension PrepareBuilder() {
+ if (builderIsReadOnly) {
+ OptionalGroup_extension original = result;
+ result = new OptionalGroup_extension();
+ builderIsReadOnly = false;
+ MergeFrom(original);
+ }
+ return result;
+ }
+
+ public override bool IsInitialized {
+ get { return result.IsInitialized; }
+ }
protected override OptionalGroup_extension MessageBeingBuilt {
- get { return result; }
+ get { return PrepareBuilder(); }
}
public override Builder Clear() {
- result = new OptionalGroup_extension();
+ result = DefaultInstance ?? new OptionalGroup_extension();
+ builderIsReadOnly = true;
return this;
}
public override Builder Clone() {
- return new Builder().MergeFrom(result);
+ if (builderIsReadOnly) {
+ return new Builder(result);
+ } else {
+ return new Builder().MergeFrom(result);
+ }
}
public override pbd::MessageDescriptor DescriptorForType {
@@ -6311,12 +6744,11 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override OptionalGroup_extension BuildPartial() {
- if (result == null) {
- throw new global::System.InvalidOperationException("build() has already been called on this Builder");
+ if (builderIsReadOnly) {
+ return result;
}
- OptionalGroup_extension returnMe = result;
- result = null;
- return returnMe;
+ builderIsReadOnly = true;
+ return result;
}
public override Builder MergeFrom(pb::IMessage other) {
@@ -6330,6 +6762,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder MergeFrom(OptionalGroup_extension other) {
if (other == global::Google.ProtocolBuffers.TestProtos.OptionalGroup_extension.DefaultInstance) return this;
+ PrepareBuilder();
if (other.HasA) {
A = other.A;
}
@@ -6342,6 +6775,7 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
+ PrepareBuilder();
pb::UnknownFieldSet.Builder unknownFields = null;
uint tag;
string field_name;
@@ -6397,11 +6831,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetA(value); }
}
public Builder SetA(int value) {
+ PrepareBuilder();
result.hasA = true;
result.a_ = value;
return this;
}
public Builder ClearA() {
+ PrepareBuilder();
result.hasA = false;
result.a_ = 0;
return this;
@@ -6514,7 +6950,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(RepeatedGroup_extension prototype) {
- return (Builder) new Builder().MergeFrom(prototype);
+ return new Builder(prototype);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -6524,21 +6960,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder {
get { return this; }
}
- public Builder() {}
+ public Builder() {
+ result = DefaultInstance ?? new RepeatedGroup_extension();
+ builderIsReadOnly = result == DefaultInstance;
+ }
+ internal Builder(RepeatedGroup_extension cloneFrom) {
+ result = cloneFrom;
+ builderIsReadOnly = true;
+ }
+
+ bool builderIsReadOnly;
+ RepeatedGroup_extension result;
+
+ private RepeatedGroup_extension PrepareBuilder() {
+ if (builderIsReadOnly) {
+ RepeatedGroup_extension original = result;
+ result = new RepeatedGroup_extension();
+ builderIsReadOnly = false;
+ MergeFrom(original);
+ }
+ return result;
+ }
- RepeatedGroup_extension result = new RepeatedGroup_extension();
+ public override bool IsInitialized {
+ get { return result.IsInitialized; }
+ }
protected override RepeatedGroup_extension MessageBeingBuilt {
- get { return result; }
+ get { return PrepareBuilder(); }
}
public override Builder Clear() {
- result = new RepeatedGroup_extension();
+ result = DefaultInstance ?? new RepeatedGroup_extension();
+ builderIsReadOnly = true;
return this;
}
public override Builder Clone() {
- return new Builder().MergeFrom(result);
+ if (builderIsReadOnly) {
+ return new Builder(result);
+ } else {
+ return new Builder().MergeFrom(result);
+ }
}
public override pbd::MessageDescriptor DescriptorForType {
@@ -6550,12 +7013,11 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override RepeatedGroup_extension BuildPartial() {
- if (result == null) {
- throw new global::System.InvalidOperationException("build() has already been called on this Builder");
+ if (builderIsReadOnly) {
+ return result;
}
- RepeatedGroup_extension returnMe = result;
- result = null;
- return returnMe;
+ builderIsReadOnly = true;
+ return result;
}
public override Builder MergeFrom(pb::IMessage other) {
@@ -6569,6 +7031,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder MergeFrom(RepeatedGroup_extension other) {
if (other == global::Google.ProtocolBuffers.TestProtos.RepeatedGroup_extension.DefaultInstance) return this;
+ PrepareBuilder();
if (other.HasA) {
A = other.A;
}
@@ -6581,6 +7044,7 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
+ PrepareBuilder();
pb::UnknownFieldSet.Builder unknownFields = null;
uint tag;
string field_name;
@@ -6636,11 +7100,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetA(value); }
}
public Builder SetA(int value) {
+ PrepareBuilder();
result.hasA = true;
result.a_ = value;
return this;
}
public Builder ClearA() {
+ PrepareBuilder();
result.hasA = false;
result.a_ = 0;
return this;
@@ -6739,7 +7205,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(TestNestedExtension prototype) {
- return (Builder) new Builder().MergeFrom(prototype);
+ return new Builder(prototype);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -6749,21 +7215,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder {
get { return this; }
}
- public Builder() {}
+ public Builder() {
+ result = DefaultInstance ?? new TestNestedExtension();
+ builderIsReadOnly = result == DefaultInstance;
+ }
+ internal Builder(TestNestedExtension cloneFrom) {
+ result = cloneFrom;
+ builderIsReadOnly = true;
+ }
+
+ bool builderIsReadOnly;
+ TestNestedExtension result;
+
+ private TestNestedExtension PrepareBuilder() {
+ if (builderIsReadOnly) {
+ TestNestedExtension original = result;
+ result = new TestNestedExtension();
+ builderIsReadOnly = false;
+ MergeFrom(original);
+ }
+ return result;
+ }
- TestNestedExtension result = new TestNestedExtension();
+ public override bool IsInitialized {
+ get { return result.IsInitialized; }
+ }
protected override TestNestedExtension MessageBeingBuilt {
- get { return result; }
+ get { return PrepareBuilder(); }
}
public override Builder Clear() {
- result = new TestNestedExtension();
+ result = DefaultInstance ?? new TestNestedExtension();
+ builderIsReadOnly = true;
return this;
}
public override Builder Clone() {
- return new Builder().MergeFrom(result);
+ if (builderIsReadOnly) {
+ return new Builder(result);
+ } else {
+ return new Builder().MergeFrom(result);
+ }
}
public override pbd::MessageDescriptor DescriptorForType {
@@ -6775,12 +7268,11 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override TestNestedExtension BuildPartial() {
- if (result == null) {
- throw new global::System.InvalidOperationException("build() has already been called on this Builder");
+ if (builderIsReadOnly) {
+ return result;
}
- TestNestedExtension returnMe = result;
- result = null;
- return returnMe;
+ builderIsReadOnly = true;
+ return result;
}
public override Builder MergeFrom(pb::IMessage other) {
@@ -6794,6 +7286,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder MergeFrom(TestNestedExtension other) {
if (other == global::Google.ProtocolBuffers.TestProtos.TestNestedExtension.DefaultInstance) return this;
+ PrepareBuilder();
this.MergeUnknownFields(other.UnknownFields);
return this;
}
@@ -6803,6 +7296,7 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
+ PrepareBuilder();
pb::UnknownFieldSet.Builder unknownFields = null;
uint tag;
string field_name;
@@ -7472,7 +7966,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(TestRequired prototype) {
- return (Builder) new Builder().MergeFrom(prototype);
+ return new Builder(prototype);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -7482,21 +7976,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder {
get { return this; }
}
- public Builder() {}
+ public Builder() {
+ result = DefaultInstance ?? new TestRequired();
+ builderIsReadOnly = result == DefaultInstance;
+ }
+ internal Builder(TestRequired cloneFrom) {
+ result = cloneFrom;
+ builderIsReadOnly = true;
+ }
- TestRequired result = new TestRequired();
+ bool builderIsReadOnly;
+ TestRequired result;
+
+ private TestRequired PrepareBuilder() {
+ if (builderIsReadOnly) {
+ TestRequired original = result;
+ result = new TestRequired();
+ builderIsReadOnly = false;
+ MergeFrom(original);
+ }
+ return result;
+ }
+
+ public override bool IsInitialized {
+ get { return result.IsInitialized; }
+ }
protected override TestRequired MessageBeingBuilt {
- get { return result; }
+ get { return PrepareBuilder(); }
}
public override Builder Clear() {
- result = new TestRequired();
+ result = DefaultInstance ?? new TestRequired();
+ builderIsReadOnly = true;
return this;
}
public override Builder Clone() {
- return new Builder().MergeFrom(result);
+ if (builderIsReadOnly) {
+ return new Builder(result);
+ } else {
+ return new Builder().MergeFrom(result);
+ }
}
public override pbd::MessageDescriptor DescriptorForType {
@@ -7508,12 +8029,11 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override TestRequired BuildPartial() {
- if (result == null) {
- throw new global::System.InvalidOperationException("build() has already been called on this Builder");
+ if (builderIsReadOnly) {
+ return result;
}
- TestRequired returnMe = result;
- result = null;
- return returnMe;
+ builderIsReadOnly = true;
+ return result;
}
public override Builder MergeFrom(pb::IMessage other) {
@@ -7527,6 +8047,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder MergeFrom(TestRequired other) {
if (other == global::Google.ProtocolBuffers.TestProtos.TestRequired.DefaultInstance) return this;
+ PrepareBuilder();
if (other.HasA) {
A = other.A;
}
@@ -7635,6 +8156,7 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
+ PrepareBuilder();
pb::UnknownFieldSet.Builder unknownFields = null;
uint tag;
string field_name;
@@ -7818,11 +8340,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetA(value); }
}
public Builder SetA(int value) {
+ PrepareBuilder();
result.hasA = true;
result.a_ = value;
return this;
}
public Builder ClearA() {
+ PrepareBuilder();
result.hasA = false;
result.a_ = 0;
return this;
@@ -7836,11 +8360,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetDummy2(value); }
}
public Builder SetDummy2(int value) {
+ PrepareBuilder();
result.hasDummy2 = true;
result.dummy2_ = value;
return this;
}
public Builder ClearDummy2() {
+ PrepareBuilder();
result.hasDummy2 = false;
result.dummy2_ = 0;
return this;
@@ -7854,11 +8380,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetB(value); }
}
public Builder SetB(int value) {
+ PrepareBuilder();
result.hasB = true;
result.b_ = value;
return this;
}
public Builder ClearB() {
+ PrepareBuilder();
result.hasB = false;
result.b_ = 0;
return this;
@@ -7872,11 +8400,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetDummy4(value); }
}
public Builder SetDummy4(int value) {
+ PrepareBuilder();
result.hasDummy4 = true;
result.dummy4_ = value;
return this;
}
public Builder ClearDummy4() {
+ PrepareBuilder();
result.hasDummy4 = false;
result.dummy4_ = 0;
return this;
@@ -7890,11 +8420,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetDummy5(value); }
}
public Builder SetDummy5(int value) {
+ PrepareBuilder();
result.hasDummy5 = true;
result.dummy5_ = value;
return this;
}
public Builder ClearDummy5() {
+ PrepareBuilder();
result.hasDummy5 = false;
result.dummy5_ = 0;
return this;
@@ -7908,11 +8440,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetDummy6(value); }
}
public Builder SetDummy6(int value) {
+ PrepareBuilder();
result.hasDummy6 = true;
result.dummy6_ = value;
return this;
}
public Builder ClearDummy6() {
+ PrepareBuilder();
result.hasDummy6 = false;
result.dummy6_ = 0;
return this;
@@ -7926,11 +8460,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetDummy7(value); }
}
public Builder SetDummy7(int value) {
+ PrepareBuilder();
result.hasDummy7 = true;
result.dummy7_ = value;
return this;
}
public Builder ClearDummy7() {
+ PrepareBuilder();
result.hasDummy7 = false;
result.dummy7_ = 0;
return this;
@@ -7944,11 +8480,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetDummy8(value); }
}
public Builder SetDummy8(int value) {
+ PrepareBuilder();
result.hasDummy8 = true;
result.dummy8_ = value;
return this;
}
public Builder ClearDummy8() {
+ PrepareBuilder();
result.hasDummy8 = false;
result.dummy8_ = 0;
return this;
@@ -7962,11 +8500,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetDummy9(value); }
}
public Builder SetDummy9(int value) {
+ PrepareBuilder();
result.hasDummy9 = true;
result.dummy9_ = value;
return this;
}
public Builder ClearDummy9() {
+ PrepareBuilder();
result.hasDummy9 = false;
result.dummy9_ = 0;
return this;
@@ -7980,11 +8520,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetDummy10(value); }
}
public Builder SetDummy10(int value) {
+ PrepareBuilder();
result.hasDummy10 = true;
result.dummy10_ = value;
return this;
}
public Builder ClearDummy10() {
+ PrepareBuilder();
result.hasDummy10 = false;
result.dummy10_ = 0;
return this;
@@ -7998,11 +8540,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetDummy11(value); }
}
public Builder SetDummy11(int value) {
+ PrepareBuilder();
result.hasDummy11 = true;
result.dummy11_ = value;
return this;
}
public Builder ClearDummy11() {
+ PrepareBuilder();
result.hasDummy11 = false;
result.dummy11_ = 0;
return this;
@@ -8016,11 +8560,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetDummy12(value); }
}
public Builder SetDummy12(int value) {
+ PrepareBuilder();
result.hasDummy12 = true;
result.dummy12_ = value;
return this;
}
public Builder ClearDummy12() {
+ PrepareBuilder();
result.hasDummy12 = false;
result.dummy12_ = 0;
return this;
@@ -8034,11 +8580,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetDummy13(value); }
}
public Builder SetDummy13(int value) {
+ PrepareBuilder();
result.hasDummy13 = true;
result.dummy13_ = value;
return this;
}
public Builder ClearDummy13() {
+ PrepareBuilder();
result.hasDummy13 = false;
result.dummy13_ = 0;
return this;
@@ -8052,11 +8600,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetDummy14(value); }
}
public Builder SetDummy14(int value) {
+ PrepareBuilder();
result.hasDummy14 = true;
result.dummy14_ = value;
return this;
}
public Builder ClearDummy14() {
+ PrepareBuilder();
result.hasDummy14 = false;
result.dummy14_ = 0;
return this;
@@ -8070,11 +8620,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetDummy15(value); }
}
public Builder SetDummy15(int value) {
+ PrepareBuilder();
result.hasDummy15 = true;
result.dummy15_ = value;
return this;
}
public Builder ClearDummy15() {
+ PrepareBuilder();
result.hasDummy15 = false;
result.dummy15_ = 0;
return this;
@@ -8088,11 +8640,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetDummy16(value); }
}
public Builder SetDummy16(int value) {
+ PrepareBuilder();
result.hasDummy16 = true;
result.dummy16_ = value;
return this;
}
public Builder ClearDummy16() {
+ PrepareBuilder();
result.hasDummy16 = false;
result.dummy16_ = 0;
return this;
@@ -8106,11 +8660,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetDummy17(value); }
}
public Builder SetDummy17(int value) {
+ PrepareBuilder();
result.hasDummy17 = true;
result.dummy17_ = value;
return this;
}
public Builder ClearDummy17() {
+ PrepareBuilder();
result.hasDummy17 = false;
result.dummy17_ = 0;
return this;
@@ -8124,11 +8680,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetDummy18(value); }
}
public Builder SetDummy18(int value) {
+ PrepareBuilder();
result.hasDummy18 = true;
result.dummy18_ = value;
return this;
}
public Builder ClearDummy18() {
+ PrepareBuilder();
result.hasDummy18 = false;
result.dummy18_ = 0;
return this;
@@ -8142,11 +8700,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetDummy19(value); }
}
public Builder SetDummy19(int value) {
+ PrepareBuilder();
result.hasDummy19 = true;
result.dummy19_ = value;
return this;
}
public Builder ClearDummy19() {
+ PrepareBuilder();
result.hasDummy19 = false;
result.dummy19_ = 0;
return this;
@@ -8160,11 +8720,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetDummy20(value); }
}
public Builder SetDummy20(int value) {
+ PrepareBuilder();
result.hasDummy20 = true;
result.dummy20_ = value;
return this;
}
public Builder ClearDummy20() {
+ PrepareBuilder();
result.hasDummy20 = false;
result.dummy20_ = 0;
return this;
@@ -8178,11 +8740,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetDummy21(value); }
}
public Builder SetDummy21(int value) {
+ PrepareBuilder();
result.hasDummy21 = true;
result.dummy21_ = value;
return this;
}
public Builder ClearDummy21() {
+ PrepareBuilder();
result.hasDummy21 = false;
result.dummy21_ = 0;
return this;
@@ -8196,11 +8760,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetDummy22(value); }
}
public Builder SetDummy22(int value) {
+ PrepareBuilder();
result.hasDummy22 = true;
result.dummy22_ = value;
return this;
}
public Builder ClearDummy22() {
+ PrepareBuilder();
result.hasDummy22 = false;
result.dummy22_ = 0;
return this;
@@ -8214,11 +8780,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetDummy23(value); }
}
public Builder SetDummy23(int value) {
+ PrepareBuilder();
result.hasDummy23 = true;
result.dummy23_ = value;
return this;
}
public Builder ClearDummy23() {
+ PrepareBuilder();
result.hasDummy23 = false;
result.dummy23_ = 0;
return this;
@@ -8232,11 +8800,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetDummy24(value); }
}
public Builder SetDummy24(int value) {
+ PrepareBuilder();
result.hasDummy24 = true;
result.dummy24_ = value;
return this;
}
public Builder ClearDummy24() {
+ PrepareBuilder();
result.hasDummy24 = false;
result.dummy24_ = 0;
return this;
@@ -8250,11 +8820,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetDummy25(value); }
}
public Builder SetDummy25(int value) {
+ PrepareBuilder();
result.hasDummy25 = true;
result.dummy25_ = value;
return this;
}
public Builder ClearDummy25() {
+ PrepareBuilder();
result.hasDummy25 = false;
result.dummy25_ = 0;
return this;
@@ -8268,11 +8840,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetDummy26(value); }
}
public Builder SetDummy26(int value) {
+ PrepareBuilder();
result.hasDummy26 = true;
result.dummy26_ = value;
return this;
}
public Builder ClearDummy26() {
+ PrepareBuilder();
result.hasDummy26 = false;
result.dummy26_ = 0;
return this;
@@ -8286,11 +8860,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetDummy27(value); }
}
public Builder SetDummy27(int value) {
+ PrepareBuilder();
result.hasDummy27 = true;
result.dummy27_ = value;
return this;
}
public Builder ClearDummy27() {
+ PrepareBuilder();
result.hasDummy27 = false;
result.dummy27_ = 0;
return this;
@@ -8304,11 +8880,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetDummy28(value); }
}
public Builder SetDummy28(int value) {
+ PrepareBuilder();
result.hasDummy28 = true;
result.dummy28_ = value;
return this;
}
public Builder ClearDummy28() {
+ PrepareBuilder();
result.hasDummy28 = false;
result.dummy28_ = 0;
return this;
@@ -8322,11 +8900,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetDummy29(value); }
}
public Builder SetDummy29(int value) {
+ PrepareBuilder();
result.hasDummy29 = true;
result.dummy29_ = value;
return this;
}
public Builder ClearDummy29() {
+ PrepareBuilder();
result.hasDummy29 = false;
result.dummy29_ = 0;
return this;
@@ -8340,11 +8920,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetDummy30(value); }
}
public Builder SetDummy30(int value) {
+ PrepareBuilder();
result.hasDummy30 = true;
result.dummy30_ = value;
return this;
}
public Builder ClearDummy30() {
+ PrepareBuilder();
result.hasDummy30 = false;
result.dummy30_ = 0;
return this;
@@ -8358,11 +8940,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetDummy31(value); }
}
public Builder SetDummy31(int value) {
+ PrepareBuilder();
result.hasDummy31 = true;
result.dummy31_ = value;
return this;
}
public Builder ClearDummy31() {
+ PrepareBuilder();
result.hasDummy31 = false;
result.dummy31_ = 0;
return this;
@@ -8376,11 +8960,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetDummy32(value); }
}
public Builder SetDummy32(int value) {
+ PrepareBuilder();
result.hasDummy32 = true;
result.dummy32_ = value;
return this;
}
public Builder ClearDummy32() {
+ PrepareBuilder();
result.hasDummy32 = false;
result.dummy32_ = 0;
return this;
@@ -8394,11 +8980,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetC(value); }
}
public Builder SetC(int value) {
+ PrepareBuilder();
result.hasC = true;
result.c_ = value;
return this;
}
public Builder ClearC() {
+ PrepareBuilder();
result.hasC = false;
result.c_ = 0;
return this;
@@ -8551,7 +9139,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(TestRequiredForeign prototype) {
- return (Builder) new Builder().MergeFrom(prototype);
+ return new Builder(prototype);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -8561,21 +9149,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder {
get { return this; }
}
- public Builder() {}
+ public Builder() {
+ result = DefaultInstance ?? new TestRequiredForeign();
+ builderIsReadOnly = result == DefaultInstance;
+ }
+ internal Builder(TestRequiredForeign cloneFrom) {
+ result = cloneFrom;
+ builderIsReadOnly = true;
+ }
+
+ bool builderIsReadOnly;
+ TestRequiredForeign result;
- TestRequiredForeign result = new TestRequiredForeign();
+ private TestRequiredForeign PrepareBuilder() {
+ if (builderIsReadOnly) {
+ TestRequiredForeign original = result;
+ result = new TestRequiredForeign();
+ builderIsReadOnly = false;
+ MergeFrom(original);
+ }
+ return result;
+ }
+
+ public override bool IsInitialized {
+ get { return result.IsInitialized; }
+ }
protected override TestRequiredForeign MessageBeingBuilt {
- get { return result; }
+ get { return PrepareBuilder(); }
}
public override Builder Clear() {
- result = new TestRequiredForeign();
+ result = DefaultInstance ?? new TestRequiredForeign();
+ builderIsReadOnly = true;
return this;
}
public override Builder Clone() {
- return new Builder().MergeFrom(result);
+ if (builderIsReadOnly) {
+ return new Builder(result);
+ } else {
+ return new Builder().MergeFrom(result);
+ }
}
public override pbd::MessageDescriptor DescriptorForType {
@@ -8587,13 +9202,12 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override TestRequiredForeign BuildPartial() {
- if (result == null) {
- throw new global::System.InvalidOperationException("build() has already been called on this Builder");
+ if (builderIsReadOnly) {
+ return result;
}
result.repeatedMessage_.MakeReadOnly();
- TestRequiredForeign returnMe = result;
- result = null;
- return returnMe;
+ builderIsReadOnly = true;
+ return result;
}
public override Builder MergeFrom(pb::IMessage other) {
@@ -8607,6 +9221,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder MergeFrom(TestRequiredForeign other) {
if (other == global::Google.ProtocolBuffers.TestProtos.TestRequiredForeign.DefaultInstance) return this;
+ PrepareBuilder();
if (other.HasOptionalMessage) {
MergeOptionalMessage(other.OptionalMessage);
}
@@ -8625,6 +9240,7 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
+ PrepareBuilder();
pb::UnknownFieldSet.Builder unknownFields = null;
uint tag;
string field_name;
@@ -8694,18 +9310,21 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetOptionalMessage(global::Google.ProtocolBuffers.TestProtos.TestRequired value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.hasOptionalMessage = true;
result.optionalMessage_ = value;
return this;
}
public Builder SetOptionalMessage(global::Google.ProtocolBuffers.TestProtos.TestRequired.Builder builderForValue) {
pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue");
+ PrepareBuilder();
result.hasOptionalMessage = true;
result.optionalMessage_ = builderForValue.Build();
return this;
}
public Builder MergeOptionalMessage(global::Google.ProtocolBuffers.TestProtos.TestRequired value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
if (result.hasOptionalMessage &&
result.optionalMessage_ != global::Google.ProtocolBuffers.TestProtos.TestRequired.DefaultInstance) {
result.optionalMessage_ = global::Google.ProtocolBuffers.TestProtos.TestRequired.CreateBuilder(result.optionalMessage_).MergeFrom(value).BuildPartial();
@@ -8716,13 +9335,14 @@ namespace Google.ProtocolBuffers.TestProtos { return this;
}
public Builder ClearOptionalMessage() {
+ PrepareBuilder();
result.hasOptionalMessage = false;
result.optionalMessage_ = global::Google.ProtocolBuffers.TestProtos.TestRequired.DefaultInstance;
return this;
}
public pbc::IPopsicleList<global::Google.ProtocolBuffers.TestProtos.TestRequired> RepeatedMessageList {
- get { return result.repeatedMessage_; }
+ get { return PrepareBuilder().repeatedMessage_; }
}
public int RepeatedMessageCount {
get { return result.RepeatedMessageCount; }
@@ -8732,29 +9352,35 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetRepeatedMessage(int index, global::Google.ProtocolBuffers.TestProtos.TestRequired value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.repeatedMessage_[index] = value;
return this;
}
public Builder SetRepeatedMessage(int index, global::Google.ProtocolBuffers.TestProtos.TestRequired.Builder builderForValue) {
pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue");
+ PrepareBuilder();
result.repeatedMessage_[index] = builderForValue.Build();
return this;
}
public Builder AddRepeatedMessage(global::Google.ProtocolBuffers.TestProtos.TestRequired value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.repeatedMessage_.Add(value);
return this;
}
public Builder AddRepeatedMessage(global::Google.ProtocolBuffers.TestProtos.TestRequired.Builder builderForValue) {
pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue");
+ PrepareBuilder();
result.repeatedMessage_.Add(builderForValue.Build());
return this;
}
public Builder AddRangeRepeatedMessage(scg::IEnumerable<global::Google.ProtocolBuffers.TestProtos.TestRequired> values) {
+ PrepareBuilder();
base.AddRange(values, result.repeatedMessage_);
return this;
}
public Builder ClearRepeatedMessage() {
+ PrepareBuilder();
result.repeatedMessage_.Clear();
return this;
}
@@ -8767,11 +9393,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetDummy(value); }
}
public Builder SetDummy(int value) {
+ PrepareBuilder();
result.hasDummy = true;
result.dummy_ = value;
return this;
}
public Builder ClearDummy() {
+ PrepareBuilder();
result.hasDummy = false;
result.dummy_ = 0;
return this;
@@ -8884,7 +9512,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(TestForeignNested prototype) {
- return (Builder) new Builder().MergeFrom(prototype);
+ return new Builder(prototype);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -8894,21 +9522,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder {
get { return this; }
}
- public Builder() {}
+ public Builder() {
+ result = DefaultInstance ?? new TestForeignNested();
+ builderIsReadOnly = result == DefaultInstance;
+ }
+ internal Builder(TestForeignNested cloneFrom) {
+ result = cloneFrom;
+ builderIsReadOnly = true;
+ }
- TestForeignNested result = new TestForeignNested();
+ bool builderIsReadOnly;
+ TestForeignNested result;
+
+ private TestForeignNested PrepareBuilder() {
+ if (builderIsReadOnly) {
+ TestForeignNested original = result;
+ result = new TestForeignNested();
+ builderIsReadOnly = false;
+ MergeFrom(original);
+ }
+ return result;
+ }
+
+ public override bool IsInitialized {
+ get { return result.IsInitialized; }
+ }
protected override TestForeignNested MessageBeingBuilt {
- get { return result; }
+ get { return PrepareBuilder(); }
}
public override Builder Clear() {
- result = new TestForeignNested();
+ result = DefaultInstance ?? new TestForeignNested();
+ builderIsReadOnly = true;
return this;
}
public override Builder Clone() {
- return new Builder().MergeFrom(result);
+ if (builderIsReadOnly) {
+ return new Builder(result);
+ } else {
+ return new Builder().MergeFrom(result);
+ }
}
public override pbd::MessageDescriptor DescriptorForType {
@@ -8920,12 +9575,11 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override TestForeignNested BuildPartial() {
- if (result == null) {
- throw new global::System.InvalidOperationException("build() has already been called on this Builder");
+ if (builderIsReadOnly) {
+ return result;
}
- TestForeignNested returnMe = result;
- result = null;
- return returnMe;
+ builderIsReadOnly = true;
+ return result;
}
public override Builder MergeFrom(pb::IMessage other) {
@@ -8939,6 +9593,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder MergeFrom(TestForeignNested other) {
if (other == global::Google.ProtocolBuffers.TestProtos.TestForeignNested.DefaultInstance) return this;
+ PrepareBuilder();
if (other.HasForeignNested) {
MergeForeignNested(other.ForeignNested);
}
@@ -8951,6 +9606,7 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
+ PrepareBuilder();
pb::UnknownFieldSet.Builder unknownFields = null;
uint tag;
string field_name;
@@ -9012,18 +9668,21 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetForeignNested(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.hasForeignNested = true;
result.foreignNested_ = value;
return this;
}
public Builder SetForeignNested(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage.Builder builderForValue) {
pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue");
+ PrepareBuilder();
result.hasForeignNested = true;
result.foreignNested_ = builderForValue.Build();
return this;
}
public Builder MergeForeignNested(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
if (result.hasForeignNested &&
result.foreignNested_ != global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage.DefaultInstance) {
result.foreignNested_ = global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage.CreateBuilder(result.foreignNested_).MergeFrom(value).BuildPartial();
@@ -9034,6 +9693,7 @@ namespace Google.ProtocolBuffers.TestProtos { return this;
}
public Builder ClearForeignNested() {
+ PrepareBuilder();
result.hasForeignNested = false;
result.foreignNested_ = global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage.DefaultInstance;
return this;
@@ -9130,7 +9790,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(TestEmptyMessage prototype) {
- return (Builder) new Builder().MergeFrom(prototype);
+ return new Builder(prototype);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -9140,21 +9800,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder {
get { return this; }
}
- public Builder() {}
+ public Builder() {
+ result = DefaultInstance ?? new TestEmptyMessage();
+ builderIsReadOnly = result == DefaultInstance;
+ }
+ internal Builder(TestEmptyMessage cloneFrom) {
+ result = cloneFrom;
+ builderIsReadOnly = true;
+ }
+
+ bool builderIsReadOnly;
+ TestEmptyMessage result;
+
+ private TestEmptyMessage PrepareBuilder() {
+ if (builderIsReadOnly) {
+ TestEmptyMessage original = result;
+ result = new TestEmptyMessage();
+ builderIsReadOnly = false;
+ MergeFrom(original);
+ }
+ return result;
+ }
- TestEmptyMessage result = new TestEmptyMessage();
+ public override bool IsInitialized {
+ get { return result.IsInitialized; }
+ }
protected override TestEmptyMessage MessageBeingBuilt {
- get { return result; }
+ get { return PrepareBuilder(); }
}
public override Builder Clear() {
- result = new TestEmptyMessage();
+ result = DefaultInstance ?? new TestEmptyMessage();
+ builderIsReadOnly = true;
return this;
}
public override Builder Clone() {
- return new Builder().MergeFrom(result);
+ if (builderIsReadOnly) {
+ return new Builder(result);
+ } else {
+ return new Builder().MergeFrom(result);
+ }
}
public override pbd::MessageDescriptor DescriptorForType {
@@ -9166,12 +9853,11 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override TestEmptyMessage BuildPartial() {
- if (result == null) {
- throw new global::System.InvalidOperationException("build() has already been called on this Builder");
+ if (builderIsReadOnly) {
+ return result;
}
- TestEmptyMessage returnMe = result;
- result = null;
- return returnMe;
+ builderIsReadOnly = true;
+ return result;
}
public override Builder MergeFrom(pb::IMessage other) {
@@ -9185,6 +9871,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder MergeFrom(TestEmptyMessage other) {
if (other == global::Google.ProtocolBuffers.TestProtos.TestEmptyMessage.DefaultInstance) return this;
+ PrepareBuilder();
this.MergeUnknownFields(other.UnknownFields);
return this;
}
@@ -9194,6 +9881,7 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
+ PrepareBuilder();
pb::UnknownFieldSet.Builder unknownFields = null;
uint tag;
string field_name;
@@ -9332,7 +10020,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(TestEmptyMessageWithExtensions prototype) {
- return (Builder) new Builder().MergeFrom(prototype);
+ return new Builder(prototype);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -9342,21 +10030,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder {
get { return this; }
}
- public Builder() {}
+ public Builder() {
+ result = DefaultInstance ?? new TestEmptyMessageWithExtensions();
+ builderIsReadOnly = result == DefaultInstance;
+ }
+ internal Builder(TestEmptyMessageWithExtensions cloneFrom) {
+ result = cloneFrom;
+ builderIsReadOnly = true;
+ }
- TestEmptyMessageWithExtensions result = new TestEmptyMessageWithExtensions();
+ bool builderIsReadOnly;
+ TestEmptyMessageWithExtensions result;
+
+ private TestEmptyMessageWithExtensions PrepareBuilder() {
+ if (builderIsReadOnly) {
+ TestEmptyMessageWithExtensions original = result;
+ result = new TestEmptyMessageWithExtensions();
+ builderIsReadOnly = false;
+ MergeFrom(original);
+ }
+ return result;
+ }
+
+ public override bool IsInitialized {
+ get { return result.IsInitialized; }
+ }
protected override TestEmptyMessageWithExtensions MessageBeingBuilt {
- get { return result; }
+ get { return PrepareBuilder(); }
}
public override Builder Clear() {
- result = new TestEmptyMessageWithExtensions();
+ result = DefaultInstance ?? new TestEmptyMessageWithExtensions();
+ builderIsReadOnly = true;
return this;
}
public override Builder Clone() {
- return new Builder().MergeFrom(result);
+ if (builderIsReadOnly) {
+ return new Builder(result);
+ } else {
+ return new Builder().MergeFrom(result);
+ }
}
public override pbd::MessageDescriptor DescriptorForType {
@@ -9368,12 +10083,11 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override TestEmptyMessageWithExtensions BuildPartial() {
- if (result == null) {
- throw new global::System.InvalidOperationException("build() has already been called on this Builder");
+ if (builderIsReadOnly) {
+ return result;
}
- TestEmptyMessageWithExtensions returnMe = result;
- result = null;
- return returnMe;
+ builderIsReadOnly = true;
+ return result;
}
public override Builder MergeFrom(pb::IMessage other) {
@@ -9387,6 +10101,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder MergeFrom(TestEmptyMessageWithExtensions other) {
if (other == global::Google.ProtocolBuffers.TestProtos.TestEmptyMessageWithExtensions.DefaultInstance) return this;
+ PrepareBuilder();
this.MergeExtensionFields(other);
this.MergeUnknownFields(other.UnknownFields);
return this;
@@ -9397,6 +10112,7 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
+ PrepareBuilder();
pb::UnknownFieldSet.Builder unknownFields = null;
uint tag;
string field_name;
@@ -9537,7 +10253,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(TestMultipleExtensionRanges prototype) {
- return (Builder) new Builder().MergeFrom(prototype);
+ return new Builder(prototype);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -9547,21 +10263,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder {
get { return this; }
}
- public Builder() {}
+ public Builder() {
+ result = DefaultInstance ?? new TestMultipleExtensionRanges();
+ builderIsReadOnly = result == DefaultInstance;
+ }
+ internal Builder(TestMultipleExtensionRanges cloneFrom) {
+ result = cloneFrom;
+ builderIsReadOnly = true;
+ }
+
+ bool builderIsReadOnly;
+ TestMultipleExtensionRanges result;
+
+ private TestMultipleExtensionRanges PrepareBuilder() {
+ if (builderIsReadOnly) {
+ TestMultipleExtensionRanges original = result;
+ result = new TestMultipleExtensionRanges();
+ builderIsReadOnly = false;
+ MergeFrom(original);
+ }
+ return result;
+ }
- TestMultipleExtensionRanges result = new TestMultipleExtensionRanges();
+ public override bool IsInitialized {
+ get { return result.IsInitialized; }
+ }
protected override TestMultipleExtensionRanges MessageBeingBuilt {
- get { return result; }
+ get { return PrepareBuilder(); }
}
public override Builder Clear() {
- result = new TestMultipleExtensionRanges();
+ result = DefaultInstance ?? new TestMultipleExtensionRanges();
+ builderIsReadOnly = true;
return this;
}
public override Builder Clone() {
- return new Builder().MergeFrom(result);
+ if (builderIsReadOnly) {
+ return new Builder(result);
+ } else {
+ return new Builder().MergeFrom(result);
+ }
}
public override pbd::MessageDescriptor DescriptorForType {
@@ -9573,12 +10316,11 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override TestMultipleExtensionRanges BuildPartial() {
- if (result == null) {
- throw new global::System.InvalidOperationException("build() has already been called on this Builder");
+ if (builderIsReadOnly) {
+ return result;
}
- TestMultipleExtensionRanges returnMe = result;
- result = null;
- return returnMe;
+ builderIsReadOnly = true;
+ return result;
}
public override Builder MergeFrom(pb::IMessage other) {
@@ -9592,6 +10334,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder MergeFrom(TestMultipleExtensionRanges other) {
if (other == global::Google.ProtocolBuffers.TestProtos.TestMultipleExtensionRanges.DefaultInstance) return this;
+ PrepareBuilder();
this.MergeExtensionFields(other);
this.MergeUnknownFields(other.UnknownFields);
return this;
@@ -9602,6 +10345,7 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
+ PrepareBuilder();
pb::UnknownFieldSet.Builder unknownFields = null;
uint tag;
string field_name;
@@ -9768,7 +10512,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(TestReallyLargeTagNumber prototype) {
- return (Builder) new Builder().MergeFrom(prototype);
+ return new Builder(prototype);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -9778,21 +10522,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder {
get { return this; }
}
- public Builder() {}
+ public Builder() {
+ result = DefaultInstance ?? new TestReallyLargeTagNumber();
+ builderIsReadOnly = result == DefaultInstance;
+ }
+ internal Builder(TestReallyLargeTagNumber cloneFrom) {
+ result = cloneFrom;
+ builderIsReadOnly = true;
+ }
+
+ bool builderIsReadOnly;
+ TestReallyLargeTagNumber result;
+
+ private TestReallyLargeTagNumber PrepareBuilder() {
+ if (builderIsReadOnly) {
+ TestReallyLargeTagNumber original = result;
+ result = new TestReallyLargeTagNumber();
+ builderIsReadOnly = false;
+ MergeFrom(original);
+ }
+ return result;
+ }
- TestReallyLargeTagNumber result = new TestReallyLargeTagNumber();
+ public override bool IsInitialized {
+ get { return result.IsInitialized; }
+ }
protected override TestReallyLargeTagNumber MessageBeingBuilt {
- get { return result; }
+ get { return PrepareBuilder(); }
}
public override Builder Clear() {
- result = new TestReallyLargeTagNumber();
+ result = DefaultInstance ?? new TestReallyLargeTagNumber();
+ builderIsReadOnly = true;
return this;
}
public override Builder Clone() {
- return new Builder().MergeFrom(result);
+ if (builderIsReadOnly) {
+ return new Builder(result);
+ } else {
+ return new Builder().MergeFrom(result);
+ }
}
public override pbd::MessageDescriptor DescriptorForType {
@@ -9804,12 +10575,11 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override TestReallyLargeTagNumber BuildPartial() {
- if (result == null) {
- throw new global::System.InvalidOperationException("build() has already been called on this Builder");
+ if (builderIsReadOnly) {
+ return result;
}
- TestReallyLargeTagNumber returnMe = result;
- result = null;
- return returnMe;
+ builderIsReadOnly = true;
+ return result;
}
public override Builder MergeFrom(pb::IMessage other) {
@@ -9823,6 +10593,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder MergeFrom(TestReallyLargeTagNumber other) {
if (other == global::Google.ProtocolBuffers.TestProtos.TestReallyLargeTagNumber.DefaultInstance) return this;
+ PrepareBuilder();
if (other.HasA) {
A = other.A;
}
@@ -9838,6 +10609,7 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
+ PrepareBuilder();
pb::UnknownFieldSet.Builder unknownFields = null;
uint tag;
string field_name;
@@ -9897,11 +10669,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetA(value); }
}
public Builder SetA(int value) {
+ PrepareBuilder();
result.hasA = true;
result.a_ = value;
return this;
}
public Builder ClearA() {
+ PrepareBuilder();
result.hasA = false;
result.a_ = 0;
return this;
@@ -9915,11 +10689,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetBb(value); }
}
public Builder SetBb(int value) {
+ PrepareBuilder();
result.hasBb = true;
result.bb_ = value;
return this;
}
public Builder ClearBb() {
+ PrepareBuilder();
result.hasBb = false;
result.bb_ = 0;
return this;
@@ -10048,7 +10824,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(TestRecursiveMessage prototype) {
- return (Builder) new Builder().MergeFrom(prototype);
+ return new Builder(prototype);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -10058,21 +10834,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder {
get { return this; }
}
- public Builder() {}
+ public Builder() {
+ result = DefaultInstance ?? new TestRecursiveMessage();
+ builderIsReadOnly = result == DefaultInstance;
+ }
+ internal Builder(TestRecursiveMessage cloneFrom) {
+ result = cloneFrom;
+ builderIsReadOnly = true;
+ }
- TestRecursiveMessage result = new TestRecursiveMessage();
+ bool builderIsReadOnly;
+ TestRecursiveMessage result;
+
+ private TestRecursiveMessage PrepareBuilder() {
+ if (builderIsReadOnly) {
+ TestRecursiveMessage original = result;
+ result = new TestRecursiveMessage();
+ builderIsReadOnly = false;
+ MergeFrom(original);
+ }
+ return result;
+ }
+
+ public override bool IsInitialized {
+ get { return result.IsInitialized; }
+ }
protected override TestRecursiveMessage MessageBeingBuilt {
- get { return result; }
+ get { return PrepareBuilder(); }
}
public override Builder Clear() {
- result = new TestRecursiveMessage();
+ result = DefaultInstance ?? new TestRecursiveMessage();
+ builderIsReadOnly = true;
return this;
}
public override Builder Clone() {
- return new Builder().MergeFrom(result);
+ if (builderIsReadOnly) {
+ return new Builder(result);
+ } else {
+ return new Builder().MergeFrom(result);
+ }
}
public override pbd::MessageDescriptor DescriptorForType {
@@ -10084,12 +10887,11 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override TestRecursiveMessage BuildPartial() {
- if (result == null) {
- throw new global::System.InvalidOperationException("build() has already been called on this Builder");
+ if (builderIsReadOnly) {
+ return result;
}
- TestRecursiveMessage returnMe = result;
- result = null;
- return returnMe;
+ builderIsReadOnly = true;
+ return result;
}
public override Builder MergeFrom(pb::IMessage other) {
@@ -10103,6 +10905,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder MergeFrom(TestRecursiveMessage other) {
if (other == global::Google.ProtocolBuffers.TestProtos.TestRecursiveMessage.DefaultInstance) return this;
+ PrepareBuilder();
if (other.HasA) {
MergeA(other.A);
}
@@ -10118,6 +10921,7 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
+ PrepareBuilder();
pb::UnknownFieldSet.Builder unknownFields = null;
uint tag;
string field_name;
@@ -10183,18 +10987,21 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetA(global::Google.ProtocolBuffers.TestProtos.TestRecursiveMessage value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.hasA = true;
result.a_ = value;
return this;
}
public Builder SetA(global::Google.ProtocolBuffers.TestProtos.TestRecursiveMessage.Builder builderForValue) {
pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue");
+ PrepareBuilder();
result.hasA = true;
result.a_ = builderForValue.Build();
return this;
}
public Builder MergeA(global::Google.ProtocolBuffers.TestProtos.TestRecursiveMessage value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
if (result.hasA &&
result.a_ != global::Google.ProtocolBuffers.TestProtos.TestRecursiveMessage.DefaultInstance) {
result.a_ = global::Google.ProtocolBuffers.TestProtos.TestRecursiveMessage.CreateBuilder(result.a_).MergeFrom(value).BuildPartial();
@@ -10205,6 +11012,7 @@ namespace Google.ProtocolBuffers.TestProtos { return this;
}
public Builder ClearA() {
+ PrepareBuilder();
result.hasA = false;
result.a_ = global::Google.ProtocolBuffers.TestProtos.TestRecursiveMessage.DefaultInstance;
return this;
@@ -10218,11 +11026,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetI(value); }
}
public Builder SetI(int value) {
+ PrepareBuilder();
result.hasI = true;
result.i_ = value;
return this;
}
public Builder ClearI() {
+ PrepareBuilder();
result.hasI = false;
result.i_ = 0;
return this;
@@ -10335,7 +11145,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(TestMutualRecursionA prototype) {
- return (Builder) new Builder().MergeFrom(prototype);
+ return new Builder(prototype);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -10345,21 +11155,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder {
get { return this; }
}
- public Builder() {}
+ public Builder() {
+ result = DefaultInstance ?? new TestMutualRecursionA();
+ builderIsReadOnly = result == DefaultInstance;
+ }
+ internal Builder(TestMutualRecursionA cloneFrom) {
+ result = cloneFrom;
+ builderIsReadOnly = true;
+ }
+
+ bool builderIsReadOnly;
+ TestMutualRecursionA result;
+
+ private TestMutualRecursionA PrepareBuilder() {
+ if (builderIsReadOnly) {
+ TestMutualRecursionA original = result;
+ result = new TestMutualRecursionA();
+ builderIsReadOnly = false;
+ MergeFrom(original);
+ }
+ return result;
+ }
- TestMutualRecursionA result = new TestMutualRecursionA();
+ public override bool IsInitialized {
+ get { return result.IsInitialized; }
+ }
protected override TestMutualRecursionA MessageBeingBuilt {
- get { return result; }
+ get { return PrepareBuilder(); }
}
public override Builder Clear() {
- result = new TestMutualRecursionA();
+ result = DefaultInstance ?? new TestMutualRecursionA();
+ builderIsReadOnly = true;
return this;
}
public override Builder Clone() {
- return new Builder().MergeFrom(result);
+ if (builderIsReadOnly) {
+ return new Builder(result);
+ } else {
+ return new Builder().MergeFrom(result);
+ }
}
public override pbd::MessageDescriptor DescriptorForType {
@@ -10371,12 +11208,11 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override TestMutualRecursionA BuildPartial() {
- if (result == null) {
- throw new global::System.InvalidOperationException("build() has already been called on this Builder");
+ if (builderIsReadOnly) {
+ return result;
}
- TestMutualRecursionA returnMe = result;
- result = null;
- return returnMe;
+ builderIsReadOnly = true;
+ return result;
}
public override Builder MergeFrom(pb::IMessage other) {
@@ -10390,6 +11226,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder MergeFrom(TestMutualRecursionA other) {
if (other == global::Google.ProtocolBuffers.TestProtos.TestMutualRecursionA.DefaultInstance) return this;
+ PrepareBuilder();
if (other.HasBb) {
MergeBb(other.Bb);
}
@@ -10402,6 +11239,7 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
+ PrepareBuilder();
pb::UnknownFieldSet.Builder unknownFields = null;
uint tag;
string field_name;
@@ -10463,18 +11301,21 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetBb(global::Google.ProtocolBuffers.TestProtos.TestMutualRecursionB value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.hasBb = true;
result.bb_ = value;
return this;
}
public Builder SetBb(global::Google.ProtocolBuffers.TestProtos.TestMutualRecursionB.Builder builderForValue) {
pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue");
+ PrepareBuilder();
result.hasBb = true;
result.bb_ = builderForValue.Build();
return this;
}
public Builder MergeBb(global::Google.ProtocolBuffers.TestProtos.TestMutualRecursionB value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
if (result.hasBb &&
result.bb_ != global::Google.ProtocolBuffers.TestProtos.TestMutualRecursionB.DefaultInstance) {
result.bb_ = global::Google.ProtocolBuffers.TestProtos.TestMutualRecursionB.CreateBuilder(result.bb_).MergeFrom(value).BuildPartial();
@@ -10485,6 +11326,7 @@ namespace Google.ProtocolBuffers.TestProtos { return this;
}
public Builder ClearBb() {
+ PrepareBuilder();
result.hasBb = false;
result.bb_ = global::Google.ProtocolBuffers.TestProtos.TestMutualRecursionB.DefaultInstance;
return this;
@@ -10613,7 +11455,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(TestMutualRecursionB prototype) {
- return (Builder) new Builder().MergeFrom(prototype);
+ return new Builder(prototype);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -10623,21 +11465,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder {
get { return this; }
}
- public Builder() {}
+ public Builder() {
+ result = DefaultInstance ?? new TestMutualRecursionB();
+ builderIsReadOnly = result == DefaultInstance;
+ }
+ internal Builder(TestMutualRecursionB cloneFrom) {
+ result = cloneFrom;
+ builderIsReadOnly = true;
+ }
- TestMutualRecursionB result = new TestMutualRecursionB();
+ bool builderIsReadOnly;
+ TestMutualRecursionB result;
+
+ private TestMutualRecursionB PrepareBuilder() {
+ if (builderIsReadOnly) {
+ TestMutualRecursionB original = result;
+ result = new TestMutualRecursionB();
+ builderIsReadOnly = false;
+ MergeFrom(original);
+ }
+ return result;
+ }
+
+ public override bool IsInitialized {
+ get { return result.IsInitialized; }
+ }
protected override TestMutualRecursionB MessageBeingBuilt {
- get { return result; }
+ get { return PrepareBuilder(); }
}
public override Builder Clear() {
- result = new TestMutualRecursionB();
+ result = DefaultInstance ?? new TestMutualRecursionB();
+ builderIsReadOnly = true;
return this;
}
public override Builder Clone() {
- return new Builder().MergeFrom(result);
+ if (builderIsReadOnly) {
+ return new Builder(result);
+ } else {
+ return new Builder().MergeFrom(result);
+ }
}
public override pbd::MessageDescriptor DescriptorForType {
@@ -10649,12 +11518,11 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override TestMutualRecursionB BuildPartial() {
- if (result == null) {
- throw new global::System.InvalidOperationException("build() has already been called on this Builder");
+ if (builderIsReadOnly) {
+ return result;
}
- TestMutualRecursionB returnMe = result;
- result = null;
- return returnMe;
+ builderIsReadOnly = true;
+ return result;
}
public override Builder MergeFrom(pb::IMessage other) {
@@ -10668,6 +11536,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder MergeFrom(TestMutualRecursionB other) {
if (other == global::Google.ProtocolBuffers.TestProtos.TestMutualRecursionB.DefaultInstance) return this;
+ PrepareBuilder();
if (other.HasA) {
MergeA(other.A);
}
@@ -10683,6 +11552,7 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
+ PrepareBuilder();
pb::UnknownFieldSet.Builder unknownFields = null;
uint tag;
string field_name;
@@ -10748,18 +11618,21 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetA(global::Google.ProtocolBuffers.TestProtos.TestMutualRecursionA value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.hasA = true;
result.a_ = value;
return this;
}
public Builder SetA(global::Google.ProtocolBuffers.TestProtos.TestMutualRecursionA.Builder builderForValue) {
pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue");
+ PrepareBuilder();
result.hasA = true;
result.a_ = builderForValue.Build();
return this;
}
public Builder MergeA(global::Google.ProtocolBuffers.TestProtos.TestMutualRecursionA value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
if (result.hasA &&
result.a_ != global::Google.ProtocolBuffers.TestProtos.TestMutualRecursionA.DefaultInstance) {
result.a_ = global::Google.ProtocolBuffers.TestProtos.TestMutualRecursionA.CreateBuilder(result.a_).MergeFrom(value).BuildPartial();
@@ -10770,6 +11643,7 @@ namespace Google.ProtocolBuffers.TestProtos { return this;
}
public Builder ClearA() {
+ PrepareBuilder();
result.hasA = false;
result.a_ = global::Google.ProtocolBuffers.TestProtos.TestMutualRecursionA.DefaultInstance;
return this;
@@ -10783,11 +11657,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetOptionalInt32(value); }
}
public Builder SetOptionalInt32(int value) {
+ PrepareBuilder();
result.hasOptionalInt32 = true;
result.optionalInt32_ = value;
return this;
}
public Builder ClearOptionalInt32() {
+ PrepareBuilder();
result.hasOptionalInt32 = false;
result.optionalInt32_ = 0;
return this;
@@ -10932,7 +11808,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(Foo prototype) {
- return (Builder) new Builder().MergeFrom(prototype);
+ return new Builder(prototype);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -10942,21 +11818,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder {
get { return this; }
}
- public Builder() {}
+ public Builder() {
+ result = DefaultInstance ?? new Foo();
+ builderIsReadOnly = result == DefaultInstance;
+ }
+ internal Builder(Foo cloneFrom) {
+ result = cloneFrom;
+ builderIsReadOnly = true;
+ }
+
+ bool builderIsReadOnly;
+ Foo result;
- Foo result = new Foo();
+ private Foo PrepareBuilder() {
+ if (builderIsReadOnly) {
+ Foo original = result;
+ result = new Foo();
+ builderIsReadOnly = false;
+ MergeFrom(original);
+ }
+ return result;
+ }
+
+ public override bool IsInitialized {
+ get { return result.IsInitialized; }
+ }
protected override Foo MessageBeingBuilt {
- get { return result; }
+ get { return PrepareBuilder(); }
}
public override Builder Clear() {
- result = new Foo();
+ result = DefaultInstance ?? new Foo();
+ builderIsReadOnly = true;
return this;
}
public override Builder Clone() {
- return new Builder().MergeFrom(result);
+ if (builderIsReadOnly) {
+ return new Builder(result);
+ } else {
+ return new Builder().MergeFrom(result);
+ }
}
public override pbd::MessageDescriptor DescriptorForType {
@@ -10968,12 +11871,11 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override Foo BuildPartial() {
- if (result == null) {
- throw new global::System.InvalidOperationException("build() has already been called on this Builder");
+ if (builderIsReadOnly) {
+ return result;
}
- Foo returnMe = result;
- result = null;
- return returnMe;
+ builderIsReadOnly = true;
+ return result;
}
public override Builder MergeFrom(pb::IMessage other) {
@@ -10987,6 +11889,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder MergeFrom(Foo other) {
if (other == global::Google.ProtocolBuffers.TestProtos.TestDupFieldNumber.Types.Foo.DefaultInstance) return this;
+ PrepareBuilder();
if (other.HasA) {
A = other.A;
}
@@ -10999,6 +11902,7 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
+ PrepareBuilder();
pb::UnknownFieldSet.Builder unknownFields = null;
uint tag;
string field_name;
@@ -11054,11 +11958,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetA(value); }
}
public Builder SetA(int value) {
+ PrepareBuilder();
result.hasA = true;
result.a_ = value;
return this;
}
public Builder ClearA() {
+ PrepareBuilder();
result.hasA = false;
result.a_ = 0;
return this;
@@ -11171,7 +12077,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(Bar prototype) {
- return (Builder) new Builder().MergeFrom(prototype);
+ return new Builder(prototype);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -11181,21 +12087,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder {
get { return this; }
}
- public Builder() {}
+ public Builder() {
+ result = DefaultInstance ?? new Bar();
+ builderIsReadOnly = result == DefaultInstance;
+ }
+ internal Builder(Bar cloneFrom) {
+ result = cloneFrom;
+ builderIsReadOnly = true;
+ }
- Bar result = new Bar();
+ bool builderIsReadOnly;
+ Bar result;
+
+ private Bar PrepareBuilder() {
+ if (builderIsReadOnly) {
+ Bar original = result;
+ result = new Bar();
+ builderIsReadOnly = false;
+ MergeFrom(original);
+ }
+ return result;
+ }
+
+ public override bool IsInitialized {
+ get { return result.IsInitialized; }
+ }
protected override Bar MessageBeingBuilt {
- get { return result; }
+ get { return PrepareBuilder(); }
}
public override Builder Clear() {
- result = new Bar();
+ result = DefaultInstance ?? new Bar();
+ builderIsReadOnly = true;
return this;
}
public override Builder Clone() {
- return new Builder().MergeFrom(result);
+ if (builderIsReadOnly) {
+ return new Builder(result);
+ } else {
+ return new Builder().MergeFrom(result);
+ }
}
public override pbd::MessageDescriptor DescriptorForType {
@@ -11207,12 +12140,11 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override Bar BuildPartial() {
- if (result == null) {
- throw new global::System.InvalidOperationException("build() has already been called on this Builder");
+ if (builderIsReadOnly) {
+ return result;
}
- Bar returnMe = result;
- result = null;
- return returnMe;
+ builderIsReadOnly = true;
+ return result;
}
public override Builder MergeFrom(pb::IMessage other) {
@@ -11226,6 +12158,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder MergeFrom(Bar other) {
if (other == global::Google.ProtocolBuffers.TestProtos.TestDupFieldNumber.Types.Bar.DefaultInstance) return this;
+ PrepareBuilder();
if (other.HasA) {
A = other.A;
}
@@ -11238,6 +12171,7 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
+ PrepareBuilder();
pb::UnknownFieldSet.Builder unknownFields = null;
uint tag;
string field_name;
@@ -11293,11 +12227,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetA(value); }
}
public Builder SetA(int value) {
+ PrepareBuilder();
result.hasA = true;
result.a_ = value;
return this;
}
public Builder ClearA() {
+ PrepareBuilder();
result.hasA = false;
result.a_ = 0;
return this;
@@ -11418,7 +12354,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(TestDupFieldNumber prototype) {
- return (Builder) new Builder().MergeFrom(prototype);
+ return new Builder(prototype);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -11428,21 +12364,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder {
get { return this; }
}
- public Builder() {}
+ public Builder() {
+ result = DefaultInstance ?? new TestDupFieldNumber();
+ builderIsReadOnly = result == DefaultInstance;
+ }
+ internal Builder(TestDupFieldNumber cloneFrom) {
+ result = cloneFrom;
+ builderIsReadOnly = true;
+ }
- TestDupFieldNumber result = new TestDupFieldNumber();
+ bool builderIsReadOnly;
+ TestDupFieldNumber result;
+
+ private TestDupFieldNumber PrepareBuilder() {
+ if (builderIsReadOnly) {
+ TestDupFieldNumber original = result;
+ result = new TestDupFieldNumber();
+ builderIsReadOnly = false;
+ MergeFrom(original);
+ }
+ return result;
+ }
+
+ public override bool IsInitialized {
+ get { return result.IsInitialized; }
+ }
protected override TestDupFieldNumber MessageBeingBuilt {
- get { return result; }
+ get { return PrepareBuilder(); }
}
public override Builder Clear() {
- result = new TestDupFieldNumber();
+ result = DefaultInstance ?? new TestDupFieldNumber();
+ builderIsReadOnly = true;
return this;
}
public override Builder Clone() {
- return new Builder().MergeFrom(result);
+ if (builderIsReadOnly) {
+ return new Builder(result);
+ } else {
+ return new Builder().MergeFrom(result);
+ }
}
public override pbd::MessageDescriptor DescriptorForType {
@@ -11454,12 +12417,11 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override TestDupFieldNumber BuildPartial() {
- if (result == null) {
- throw new global::System.InvalidOperationException("build() has already been called on this Builder");
+ if (builderIsReadOnly) {
+ return result;
}
- TestDupFieldNumber returnMe = result;
- result = null;
- return returnMe;
+ builderIsReadOnly = true;
+ return result;
}
public override Builder MergeFrom(pb::IMessage other) {
@@ -11473,6 +12435,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder MergeFrom(TestDupFieldNumber other) {
if (other == global::Google.ProtocolBuffers.TestProtos.TestDupFieldNumber.DefaultInstance) return this;
+ PrepareBuilder();
if (other.HasA) {
A = other.A;
}
@@ -11491,6 +12454,7 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
+ PrepareBuilder();
pb::UnknownFieldSet.Builder unknownFields = null;
uint tag;
string field_name;
@@ -11564,11 +12528,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetA(value); }
}
public Builder SetA(int value) {
+ PrepareBuilder();
result.hasA = true;
result.a_ = value;
return this;
}
public Builder ClearA() {
+ PrepareBuilder();
result.hasA = false;
result.a_ = 0;
return this;
@@ -11583,18 +12549,21 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetFoo(global::Google.ProtocolBuffers.TestProtos.TestDupFieldNumber.Types.Foo value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.hasFoo = true;
result.foo_ = value;
return this;
}
public Builder SetFoo(global::Google.ProtocolBuffers.TestProtos.TestDupFieldNumber.Types.Foo.Builder builderForValue) {
pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue");
+ PrepareBuilder();
result.hasFoo = true;
result.foo_ = builderForValue.Build();
return this;
}
public Builder MergeFoo(global::Google.ProtocolBuffers.TestProtos.TestDupFieldNumber.Types.Foo value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
if (result.hasFoo &&
result.foo_ != global::Google.ProtocolBuffers.TestProtos.TestDupFieldNumber.Types.Foo.DefaultInstance) {
result.foo_ = global::Google.ProtocolBuffers.TestProtos.TestDupFieldNumber.Types.Foo.CreateBuilder(result.foo_).MergeFrom(value).BuildPartial();
@@ -11605,6 +12574,7 @@ namespace Google.ProtocolBuffers.TestProtos { return this;
}
public Builder ClearFoo() {
+ PrepareBuilder();
result.hasFoo = false;
result.foo_ = global::Google.ProtocolBuffers.TestProtos.TestDupFieldNumber.Types.Foo.DefaultInstance;
return this;
@@ -11619,18 +12589,21 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetBar(global::Google.ProtocolBuffers.TestProtos.TestDupFieldNumber.Types.Bar value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.hasBar = true;
result.bar_ = value;
return this;
}
public Builder SetBar(global::Google.ProtocolBuffers.TestProtos.TestDupFieldNumber.Types.Bar.Builder builderForValue) {
pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue");
+ PrepareBuilder();
result.hasBar = true;
result.bar_ = builderForValue.Build();
return this;
}
public Builder MergeBar(global::Google.ProtocolBuffers.TestProtos.TestDupFieldNumber.Types.Bar value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
if (result.hasBar &&
result.bar_ != global::Google.ProtocolBuffers.TestProtos.TestDupFieldNumber.Types.Bar.DefaultInstance) {
result.bar_ = global::Google.ProtocolBuffers.TestProtos.TestDupFieldNumber.Types.Bar.CreateBuilder(result.bar_).MergeFrom(value).BuildPartial();
@@ -11641,6 +12614,7 @@ namespace Google.ProtocolBuffers.TestProtos { return this;
}
public Builder ClearBar() {
+ PrepareBuilder();
result.hasBar = false;
result.bar_ = global::Google.ProtocolBuffers.TestProtos.TestDupFieldNumber.Types.Bar.DefaultInstance;
return this;
@@ -11810,7 +12784,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(NestedMessage prototype) {
- return (Builder) new Builder().MergeFrom(prototype);
+ return new Builder(prototype);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -11820,21 +12794,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder {
get { return this; }
}
- public Builder() {}
+ public Builder() {
+ result = DefaultInstance ?? new NestedMessage();
+ builderIsReadOnly = result == DefaultInstance;
+ }
+ internal Builder(NestedMessage cloneFrom) {
+ result = cloneFrom;
+ builderIsReadOnly = true;
+ }
+
+ bool builderIsReadOnly;
+ NestedMessage result;
+
+ private NestedMessage PrepareBuilder() {
+ if (builderIsReadOnly) {
+ NestedMessage original = result;
+ result = new NestedMessage();
+ builderIsReadOnly = false;
+ MergeFrom(original);
+ }
+ return result;
+ }
- NestedMessage result = new NestedMessage();
+ public override bool IsInitialized {
+ get { return result.IsInitialized; }
+ }
protected override NestedMessage MessageBeingBuilt {
- get { return result; }
+ get { return PrepareBuilder(); }
}
public override Builder Clear() {
- result = new NestedMessage();
+ result = DefaultInstance ?? new NestedMessage();
+ builderIsReadOnly = true;
return this;
}
public override Builder Clone() {
- return new Builder().MergeFrom(result);
+ if (builderIsReadOnly) {
+ return new Builder(result);
+ } else {
+ return new Builder().MergeFrom(result);
+ }
}
public override pbd::MessageDescriptor DescriptorForType {
@@ -11846,14 +12847,13 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override NestedMessage BuildPartial() {
- if (result == null) {
- throw new global::System.InvalidOperationException("build() has already been called on this Builder");
+ if (builderIsReadOnly) {
+ return result;
}
result.nestedmessageRepeatedInt32_.MakeReadOnly();
result.nestedmessageRepeatedForeignmessage_.MakeReadOnly();
- NestedMessage returnMe = result;
- result = null;
- return returnMe;
+ builderIsReadOnly = true;
+ return result;
}
public override Builder MergeFrom(pb::IMessage other) {
@@ -11867,6 +12867,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder MergeFrom(NestedMessage other) {
if (other == global::Google.ProtocolBuffers.TestProtos.TestNestedMessageHasBits.Types.NestedMessage.DefaultInstance) return this;
+ PrepareBuilder();
if (other.nestedmessageRepeatedInt32_.Count != 0) {
base.AddRange(other.nestedmessageRepeatedInt32_, result.nestedmessageRepeatedInt32_);
}
@@ -11882,6 +12883,7 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
+ PrepareBuilder();
pb::UnknownFieldSet.Builder unknownFields = null;
uint tag;
string field_name;
@@ -11935,7 +12937,7 @@ namespace Google.ProtocolBuffers.TestProtos { public pbc::IPopsicleList<int> NestedmessageRepeatedInt32List {
- get { return result.nestedmessageRepeatedInt32_; }
+ get { return PrepareBuilder().nestedmessageRepeatedInt32_; }
}
public int NestedmessageRepeatedInt32Count {
get { return result.NestedmessageRepeatedInt32Count; }
@@ -11944,24 +12946,28 @@ namespace Google.ProtocolBuffers.TestProtos { return result.GetNestedmessageRepeatedInt32(index);
}
public Builder SetNestedmessageRepeatedInt32(int index, int value) {
+ PrepareBuilder();
result.nestedmessageRepeatedInt32_[index] = value;
return this;
}
public Builder AddNestedmessageRepeatedInt32(int value) {
+ PrepareBuilder();
result.nestedmessageRepeatedInt32_.Add(value);
return this;
}
public Builder AddRangeNestedmessageRepeatedInt32(scg::IEnumerable<int> values) {
+ PrepareBuilder();
base.AddRange(values, result.nestedmessageRepeatedInt32_);
return this;
}
public Builder ClearNestedmessageRepeatedInt32() {
+ PrepareBuilder();
result.nestedmessageRepeatedInt32_.Clear();
return this;
}
public pbc::IPopsicleList<global::Google.ProtocolBuffers.TestProtos.ForeignMessage> NestedmessageRepeatedForeignmessageList {
- get { return result.nestedmessageRepeatedForeignmessage_; }
+ get { return PrepareBuilder().nestedmessageRepeatedForeignmessage_; }
}
public int NestedmessageRepeatedForeignmessageCount {
get { return result.NestedmessageRepeatedForeignmessageCount; }
@@ -11971,29 +12977,35 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetNestedmessageRepeatedForeignmessage(int index, global::Google.ProtocolBuffers.TestProtos.ForeignMessage value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.nestedmessageRepeatedForeignmessage_[index] = value;
return this;
}
public Builder SetNestedmessageRepeatedForeignmessage(int index, global::Google.ProtocolBuffers.TestProtos.ForeignMessage.Builder builderForValue) {
pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue");
+ PrepareBuilder();
result.nestedmessageRepeatedForeignmessage_[index] = builderForValue.Build();
return this;
}
public Builder AddNestedmessageRepeatedForeignmessage(global::Google.ProtocolBuffers.TestProtos.ForeignMessage value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.nestedmessageRepeatedForeignmessage_.Add(value);
return this;
}
public Builder AddNestedmessageRepeatedForeignmessage(global::Google.ProtocolBuffers.TestProtos.ForeignMessage.Builder builderForValue) {
pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue");
+ PrepareBuilder();
result.nestedmessageRepeatedForeignmessage_.Add(builderForValue.Build());
return this;
}
public Builder AddRangeNestedmessageRepeatedForeignmessage(scg::IEnumerable<global::Google.ProtocolBuffers.TestProtos.ForeignMessage> values) {
+ PrepareBuilder();
base.AddRange(values, result.nestedmessageRepeatedForeignmessage_);
return this;
}
public Builder ClearNestedmessageRepeatedForeignmessage() {
+ PrepareBuilder();
result.nestedmessageRepeatedForeignmessage_.Clear();
return this;
}
@@ -12081,7 +13093,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(TestNestedMessageHasBits prototype) {
- return (Builder) new Builder().MergeFrom(prototype);
+ return new Builder(prototype);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -12091,21 +13103,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder {
get { return this; }
}
- public Builder() {}
+ public Builder() {
+ result = DefaultInstance ?? new TestNestedMessageHasBits();
+ builderIsReadOnly = result == DefaultInstance;
+ }
+ internal Builder(TestNestedMessageHasBits cloneFrom) {
+ result = cloneFrom;
+ builderIsReadOnly = true;
+ }
- TestNestedMessageHasBits result = new TestNestedMessageHasBits();
+ bool builderIsReadOnly;
+ TestNestedMessageHasBits result;
+
+ private TestNestedMessageHasBits PrepareBuilder() {
+ if (builderIsReadOnly) {
+ TestNestedMessageHasBits original = result;
+ result = new TestNestedMessageHasBits();
+ builderIsReadOnly = false;
+ MergeFrom(original);
+ }
+ return result;
+ }
+
+ public override bool IsInitialized {
+ get { return result.IsInitialized; }
+ }
protected override TestNestedMessageHasBits MessageBeingBuilt {
- get { return result; }
+ get { return PrepareBuilder(); }
}
public override Builder Clear() {
- result = new TestNestedMessageHasBits();
+ result = DefaultInstance ?? new TestNestedMessageHasBits();
+ builderIsReadOnly = true;
return this;
}
public override Builder Clone() {
- return new Builder().MergeFrom(result);
+ if (builderIsReadOnly) {
+ return new Builder(result);
+ } else {
+ return new Builder().MergeFrom(result);
+ }
}
public override pbd::MessageDescriptor DescriptorForType {
@@ -12117,12 +13156,11 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override TestNestedMessageHasBits BuildPartial() {
- if (result == null) {
- throw new global::System.InvalidOperationException("build() has already been called on this Builder");
+ if (builderIsReadOnly) {
+ return result;
}
- TestNestedMessageHasBits returnMe = result;
- result = null;
- return returnMe;
+ builderIsReadOnly = true;
+ return result;
}
public override Builder MergeFrom(pb::IMessage other) {
@@ -12136,6 +13174,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder MergeFrom(TestNestedMessageHasBits other) {
if (other == global::Google.ProtocolBuffers.TestProtos.TestNestedMessageHasBits.DefaultInstance) return this;
+ PrepareBuilder();
if (other.HasOptionalNestedMessage) {
MergeOptionalNestedMessage(other.OptionalNestedMessage);
}
@@ -12148,6 +13187,7 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
+ PrepareBuilder();
pb::UnknownFieldSet.Builder unknownFields = null;
uint tag;
string field_name;
@@ -12209,18 +13249,21 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetOptionalNestedMessage(global::Google.ProtocolBuffers.TestProtos.TestNestedMessageHasBits.Types.NestedMessage value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.hasOptionalNestedMessage = true;
result.optionalNestedMessage_ = value;
return this;
}
public Builder SetOptionalNestedMessage(global::Google.ProtocolBuffers.TestProtos.TestNestedMessageHasBits.Types.NestedMessage.Builder builderForValue) {
pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue");
+ PrepareBuilder();
result.hasOptionalNestedMessage = true;
result.optionalNestedMessage_ = builderForValue.Build();
return this;
}
public Builder MergeOptionalNestedMessage(global::Google.ProtocolBuffers.TestProtos.TestNestedMessageHasBits.Types.NestedMessage value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
if (result.hasOptionalNestedMessage &&
result.optionalNestedMessage_ != global::Google.ProtocolBuffers.TestProtos.TestNestedMessageHasBits.Types.NestedMessage.DefaultInstance) {
result.optionalNestedMessage_ = global::Google.ProtocolBuffers.TestProtos.TestNestedMessageHasBits.Types.NestedMessage.CreateBuilder(result.optionalNestedMessage_).MergeFrom(value).BuildPartial();
@@ -12231,6 +13274,7 @@ namespace Google.ProtocolBuffers.TestProtos { return this;
}
public Builder ClearOptionalNestedMessage() {
+ PrepareBuilder();
result.hasOptionalNestedMessage = false;
result.optionalNestedMessage_ = global::Google.ProtocolBuffers.TestProtos.TestNestedMessageHasBits.Types.NestedMessage.DefaultInstance;
return this;
@@ -12558,7 +13602,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(TestCamelCaseFieldNames prototype) {
- return (Builder) new Builder().MergeFrom(prototype);
+ return new Builder(prototype);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -12568,21 +13612,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder {
get { return this; }
}
- public Builder() {}
+ public Builder() {
+ result = DefaultInstance ?? new TestCamelCaseFieldNames();
+ builderIsReadOnly = result == DefaultInstance;
+ }
+ internal Builder(TestCamelCaseFieldNames cloneFrom) {
+ result = cloneFrom;
+ builderIsReadOnly = true;
+ }
+
+ bool builderIsReadOnly;
+ TestCamelCaseFieldNames result;
+
+ private TestCamelCaseFieldNames PrepareBuilder() {
+ if (builderIsReadOnly) {
+ TestCamelCaseFieldNames original = result;
+ result = new TestCamelCaseFieldNames();
+ builderIsReadOnly = false;
+ MergeFrom(original);
+ }
+ return result;
+ }
- TestCamelCaseFieldNames result = new TestCamelCaseFieldNames();
+ public override bool IsInitialized {
+ get { return result.IsInitialized; }
+ }
protected override TestCamelCaseFieldNames MessageBeingBuilt {
- get { return result; }
+ get { return PrepareBuilder(); }
}
public override Builder Clear() {
- result = new TestCamelCaseFieldNames();
+ result = DefaultInstance ?? new TestCamelCaseFieldNames();
+ builderIsReadOnly = true;
return this;
}
public override Builder Clone() {
- return new Builder().MergeFrom(result);
+ if (builderIsReadOnly) {
+ return new Builder(result);
+ } else {
+ return new Builder().MergeFrom(result);
+ }
}
public override pbd::MessageDescriptor DescriptorForType {
@@ -12594,8 +13665,8 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override TestCamelCaseFieldNames BuildPartial() {
- if (result == null) {
- throw new global::System.InvalidOperationException("build() has already been called on this Builder");
+ if (builderIsReadOnly) {
+ return result;
}
result.repeatedPrimitiveField_.MakeReadOnly();
result.repeatedStringField_.MakeReadOnly();
@@ -12603,9 +13674,8 @@ namespace Google.ProtocolBuffers.TestProtos { result.repeatedMessageField_.MakeReadOnly();
result.repeatedStringPieceField_.MakeReadOnly();
result.repeatedCordField_.MakeReadOnly();
- TestCamelCaseFieldNames returnMe = result;
- result = null;
- return returnMe;
+ builderIsReadOnly = true;
+ return result;
}
public override Builder MergeFrom(pb::IMessage other) {
@@ -12619,6 +13689,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder MergeFrom(TestCamelCaseFieldNames other) {
if (other == global::Google.ProtocolBuffers.TestProtos.TestCamelCaseFieldNames.DefaultInstance) return this;
+ PrepareBuilder();
if (other.HasPrimitiveField) {
PrimitiveField = other.PrimitiveField;
}
@@ -12664,6 +13735,7 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
+ PrepareBuilder();
pb::UnknownFieldSet.Builder unknownFields = null;
uint tag;
string field_name;
@@ -12787,11 +13859,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetPrimitiveField(value); }
}
public Builder SetPrimitiveField(int value) {
+ PrepareBuilder();
result.hasPrimitiveField = true;
result.primitiveField_ = value;
return this;
}
public Builder ClearPrimitiveField() {
+ PrepareBuilder();
result.hasPrimitiveField = false;
result.primitiveField_ = 0;
return this;
@@ -12806,11 +13880,13 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetStringField(string value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.hasStringField = true;
result.stringField_ = value;
return this;
}
public Builder ClearStringField() {
+ PrepareBuilder();
result.hasStringField = false;
result.stringField_ = "";
return this;
@@ -12824,11 +13900,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetEnumField(value); }
}
public Builder SetEnumField(global::Google.ProtocolBuffers.TestProtos.ForeignEnum value) {
+ PrepareBuilder();
result.hasEnumField = true;
result.enumField_ = value;
return this;
}
public Builder ClearEnumField() {
+ PrepareBuilder();
result.hasEnumField = false;
result.enumField_ = global::Google.ProtocolBuffers.TestProtos.ForeignEnum.FOREIGN_FOO;
return this;
@@ -12843,18 +13921,21 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetMessageField(global::Google.ProtocolBuffers.TestProtos.ForeignMessage value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.hasMessageField = true;
result.messageField_ = value;
return this;
}
public Builder SetMessageField(global::Google.ProtocolBuffers.TestProtos.ForeignMessage.Builder builderForValue) {
pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue");
+ PrepareBuilder();
result.hasMessageField = true;
result.messageField_ = builderForValue.Build();
return this;
}
public Builder MergeMessageField(global::Google.ProtocolBuffers.TestProtos.ForeignMessage value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
if (result.hasMessageField &&
result.messageField_ != global::Google.ProtocolBuffers.TestProtos.ForeignMessage.DefaultInstance) {
result.messageField_ = global::Google.ProtocolBuffers.TestProtos.ForeignMessage.CreateBuilder(result.messageField_).MergeFrom(value).BuildPartial();
@@ -12865,6 +13946,7 @@ namespace Google.ProtocolBuffers.TestProtos { return this;
}
public Builder ClearMessageField() {
+ PrepareBuilder();
result.hasMessageField = false;
result.messageField_ = global::Google.ProtocolBuffers.TestProtos.ForeignMessage.DefaultInstance;
return this;
@@ -12879,11 +13961,13 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetStringPieceField(string value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.hasStringPieceField = true;
result.stringPieceField_ = value;
return this;
}
public Builder ClearStringPieceField() {
+ PrepareBuilder();
result.hasStringPieceField = false;
result.stringPieceField_ = "";
return this;
@@ -12898,18 +13982,20 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetCordField(string value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.hasCordField = true;
result.cordField_ = value;
return this;
}
public Builder ClearCordField() {
+ PrepareBuilder();
result.hasCordField = false;
result.cordField_ = "";
return this;
}
public pbc::IPopsicleList<int> RepeatedPrimitiveFieldList {
- get { return result.repeatedPrimitiveField_; }
+ get { return PrepareBuilder().repeatedPrimitiveField_; }
}
public int RepeatedPrimitiveFieldCount {
get { return result.RepeatedPrimitiveFieldCount; }
@@ -12918,24 +14004,28 @@ namespace Google.ProtocolBuffers.TestProtos { return result.GetRepeatedPrimitiveField(index);
}
public Builder SetRepeatedPrimitiveField(int index, int value) {
+ PrepareBuilder();
result.repeatedPrimitiveField_[index] = value;
return this;
}
public Builder AddRepeatedPrimitiveField(int value) {
+ PrepareBuilder();
result.repeatedPrimitiveField_.Add(value);
return this;
}
public Builder AddRangeRepeatedPrimitiveField(scg::IEnumerable<int> values) {
+ PrepareBuilder();
base.AddRange(values, result.repeatedPrimitiveField_);
return this;
}
public Builder ClearRepeatedPrimitiveField() {
+ PrepareBuilder();
result.repeatedPrimitiveField_.Clear();
return this;
}
public pbc::IPopsicleList<string> RepeatedStringFieldList {
- get { return result.repeatedStringField_; }
+ get { return PrepareBuilder().repeatedStringField_; }
}
public int RepeatedStringFieldCount {
get { return result.RepeatedStringFieldCount; }
@@ -12945,25 +14035,29 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetRepeatedStringField(int index, string value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.repeatedStringField_[index] = value;
return this;
}
public Builder AddRepeatedStringField(string value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.repeatedStringField_.Add(value);
return this;
}
public Builder AddRangeRepeatedStringField(scg::IEnumerable<string> values) {
+ PrepareBuilder();
base.AddRange(values, result.repeatedStringField_);
return this;
}
public Builder ClearRepeatedStringField() {
+ PrepareBuilder();
result.repeatedStringField_.Clear();
return this;
}
public pbc::IPopsicleList<global::Google.ProtocolBuffers.TestProtos.ForeignEnum> RepeatedEnumFieldList {
- get { return result.repeatedEnumField_; }
+ get { return PrepareBuilder().repeatedEnumField_; }
}
public int RepeatedEnumFieldCount {
get { return result.RepeatedEnumFieldCount; }
@@ -12972,24 +14066,28 @@ namespace Google.ProtocolBuffers.TestProtos { return result.GetRepeatedEnumField(index);
}
public Builder SetRepeatedEnumField(int index, global::Google.ProtocolBuffers.TestProtos.ForeignEnum value) {
+ PrepareBuilder();
result.repeatedEnumField_[index] = value;
return this;
}
public Builder AddRepeatedEnumField(global::Google.ProtocolBuffers.TestProtos.ForeignEnum value) {
+ PrepareBuilder();
result.repeatedEnumField_.Add(value);
return this;
}
public Builder AddRangeRepeatedEnumField(scg::IEnumerable<global::Google.ProtocolBuffers.TestProtos.ForeignEnum> values) {
+ PrepareBuilder();
base.AddRange(values, result.repeatedEnumField_);
return this;
}
public Builder ClearRepeatedEnumField() {
+ PrepareBuilder();
result.repeatedEnumField_.Clear();
return this;
}
public pbc::IPopsicleList<global::Google.ProtocolBuffers.TestProtos.ForeignMessage> RepeatedMessageFieldList {
- get { return result.repeatedMessageField_; }
+ get { return PrepareBuilder().repeatedMessageField_; }
}
public int RepeatedMessageFieldCount {
get { return result.RepeatedMessageFieldCount; }
@@ -12999,35 +14097,41 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetRepeatedMessageField(int index, global::Google.ProtocolBuffers.TestProtos.ForeignMessage value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.repeatedMessageField_[index] = value;
return this;
}
public Builder SetRepeatedMessageField(int index, global::Google.ProtocolBuffers.TestProtos.ForeignMessage.Builder builderForValue) {
pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue");
+ PrepareBuilder();
result.repeatedMessageField_[index] = builderForValue.Build();
return this;
}
public Builder AddRepeatedMessageField(global::Google.ProtocolBuffers.TestProtos.ForeignMessage value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.repeatedMessageField_.Add(value);
return this;
}
public Builder AddRepeatedMessageField(global::Google.ProtocolBuffers.TestProtos.ForeignMessage.Builder builderForValue) {
pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue");
+ PrepareBuilder();
result.repeatedMessageField_.Add(builderForValue.Build());
return this;
}
public Builder AddRangeRepeatedMessageField(scg::IEnumerable<global::Google.ProtocolBuffers.TestProtos.ForeignMessage> values) {
+ PrepareBuilder();
base.AddRange(values, result.repeatedMessageField_);
return this;
}
public Builder ClearRepeatedMessageField() {
+ PrepareBuilder();
result.repeatedMessageField_.Clear();
return this;
}
public pbc::IPopsicleList<string> RepeatedStringPieceFieldList {
- get { return result.repeatedStringPieceField_; }
+ get { return PrepareBuilder().repeatedStringPieceField_; }
}
public int RepeatedStringPieceFieldCount {
get { return result.RepeatedStringPieceFieldCount; }
@@ -13037,25 +14141,29 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetRepeatedStringPieceField(int index, string value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.repeatedStringPieceField_[index] = value;
return this;
}
public Builder AddRepeatedStringPieceField(string value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.repeatedStringPieceField_.Add(value);
return this;
}
public Builder AddRangeRepeatedStringPieceField(scg::IEnumerable<string> values) {
+ PrepareBuilder();
base.AddRange(values, result.repeatedStringPieceField_);
return this;
}
public Builder ClearRepeatedStringPieceField() {
+ PrepareBuilder();
result.repeatedStringPieceField_.Clear();
return this;
}
public pbc::IPopsicleList<string> RepeatedCordFieldList {
- get { return result.repeatedCordField_; }
+ get { return PrepareBuilder().repeatedCordField_; }
}
public int RepeatedCordFieldCount {
get { return result.RepeatedCordFieldCount; }
@@ -13065,19 +14173,23 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetRepeatedCordField(int index, string value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.repeatedCordField_[index] = value;
return this;
}
public Builder AddRepeatedCordField(string value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.repeatedCordField_.Add(value);
return this;
}
public Builder AddRangeRepeatedCordField(scg::IEnumerable<string> values) {
+ PrepareBuilder();
base.AddRange(values, result.repeatedCordField_);
return this;
}
public Builder ClearRepeatedCordField() {
+ PrepareBuilder();
result.repeatedCordField_.Clear();
return this;
}
@@ -13226,7 +14338,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(TestFieldOrderings prototype) {
- return (Builder) new Builder().MergeFrom(prototype);
+ return new Builder(prototype);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -13236,21 +14348,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder {
get { return this; }
}
- public Builder() {}
+ public Builder() {
+ result = DefaultInstance ?? new TestFieldOrderings();
+ builderIsReadOnly = result == DefaultInstance;
+ }
+ internal Builder(TestFieldOrderings cloneFrom) {
+ result = cloneFrom;
+ builderIsReadOnly = true;
+ }
+
+ bool builderIsReadOnly;
+ TestFieldOrderings result;
+
+ private TestFieldOrderings PrepareBuilder() {
+ if (builderIsReadOnly) {
+ TestFieldOrderings original = result;
+ result = new TestFieldOrderings();
+ builderIsReadOnly = false;
+ MergeFrom(original);
+ }
+ return result;
+ }
- TestFieldOrderings result = new TestFieldOrderings();
+ public override bool IsInitialized {
+ get { return result.IsInitialized; }
+ }
protected override TestFieldOrderings MessageBeingBuilt {
- get { return result; }
+ get { return PrepareBuilder(); }
}
public override Builder Clear() {
- result = new TestFieldOrderings();
+ result = DefaultInstance ?? new TestFieldOrderings();
+ builderIsReadOnly = true;
return this;
}
public override Builder Clone() {
- return new Builder().MergeFrom(result);
+ if (builderIsReadOnly) {
+ return new Builder(result);
+ } else {
+ return new Builder().MergeFrom(result);
+ }
}
public override pbd::MessageDescriptor DescriptorForType {
@@ -13262,12 +14401,11 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override TestFieldOrderings BuildPartial() {
- if (result == null) {
- throw new global::System.InvalidOperationException("build() has already been called on this Builder");
+ if (builderIsReadOnly) {
+ return result;
}
- TestFieldOrderings returnMe = result;
- result = null;
- return returnMe;
+ builderIsReadOnly = true;
+ return result;
}
public override Builder MergeFrom(pb::IMessage other) {
@@ -13281,6 +14419,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder MergeFrom(TestFieldOrderings other) {
if (other == global::Google.ProtocolBuffers.TestProtos.TestFieldOrderings.DefaultInstance) return this;
+ PrepareBuilder();
if (other.HasMyString) {
MyString = other.MyString;
}
@@ -13300,6 +14439,7 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
+ PrepareBuilder();
pb::UnknownFieldSet.Builder unknownFields = null;
uint tag;
string field_name;
@@ -13364,11 +14504,13 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetMyString(string value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.hasMyString = true;
result.myString_ = value;
return this;
}
public Builder ClearMyString() {
+ PrepareBuilder();
result.hasMyString = false;
result.myString_ = "";
return this;
@@ -13382,11 +14524,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetMyInt(value); }
}
public Builder SetMyInt(long value) {
+ PrepareBuilder();
result.hasMyInt = true;
result.myInt_ = value;
return this;
}
public Builder ClearMyInt() {
+ PrepareBuilder();
result.hasMyInt = false;
result.myInt_ = 0L;
return this;
@@ -13400,11 +14544,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetMyFloat(value); }
}
public Builder SetMyFloat(float value) {
+ PrepareBuilder();
result.hasMyFloat = true;
result.myFloat_ = value;
return this;
}
public Builder ClearMyFloat() {
+ PrepareBuilder();
result.hasMyFloat = false;
result.myFloat_ = 0F;
return this;
@@ -13807,7 +14953,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(TestExtremeDefaultValues prototype) {
- return (Builder) new Builder().MergeFrom(prototype);
+ return new Builder(prototype);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -13817,21 +14963,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder {
get { return this; }
}
- public Builder() {}
+ public Builder() {
+ result = DefaultInstance ?? new TestExtremeDefaultValues();
+ builderIsReadOnly = result == DefaultInstance;
+ }
+ internal Builder(TestExtremeDefaultValues cloneFrom) {
+ result = cloneFrom;
+ builderIsReadOnly = true;
+ }
+
+ bool builderIsReadOnly;
+ TestExtremeDefaultValues result;
- TestExtremeDefaultValues result = new TestExtremeDefaultValues();
+ private TestExtremeDefaultValues PrepareBuilder() {
+ if (builderIsReadOnly) {
+ TestExtremeDefaultValues original = result;
+ result = new TestExtremeDefaultValues();
+ builderIsReadOnly = false;
+ MergeFrom(original);
+ }
+ return result;
+ }
+
+ public override bool IsInitialized {
+ get { return result.IsInitialized; }
+ }
protected override TestExtremeDefaultValues MessageBeingBuilt {
- get { return result; }
+ get { return PrepareBuilder(); }
}
public override Builder Clear() {
- result = new TestExtremeDefaultValues();
+ result = DefaultInstance ?? new TestExtremeDefaultValues();
+ builderIsReadOnly = true;
return this;
}
public override Builder Clone() {
- return new Builder().MergeFrom(result);
+ if (builderIsReadOnly) {
+ return new Builder(result);
+ } else {
+ return new Builder().MergeFrom(result);
+ }
}
public override pbd::MessageDescriptor DescriptorForType {
@@ -13843,12 +15016,11 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override TestExtremeDefaultValues BuildPartial() {
- if (result == null) {
- throw new global::System.InvalidOperationException("build() has already been called on this Builder");
+ if (builderIsReadOnly) {
+ return result;
}
- TestExtremeDefaultValues returnMe = result;
- result = null;
- return returnMe;
+ builderIsReadOnly = true;
+ return result;
}
public override Builder MergeFrom(pb::IMessage other) {
@@ -13862,6 +15034,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder MergeFrom(TestExtremeDefaultValues other) {
if (other == global::Google.ProtocolBuffers.TestProtos.TestExtremeDefaultValues.DefaultInstance) return this;
+ PrepareBuilder();
if (other.HasEscapedBytes) {
EscapedBytes = other.EscapedBytes;
}
@@ -13928,6 +15101,7 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
+ PrepareBuilder();
pb::UnknownFieldSet.Builder unknownFields = null;
uint tag;
string field_name;
@@ -14056,11 +15230,13 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetEscapedBytes(pb::ByteString value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.hasEscapedBytes = true;
result.escapedBytes_ = value;
return this;
}
public Builder ClearEscapedBytes() {
+ PrepareBuilder();
result.hasEscapedBytes = false;
result.escapedBytes_ = (pb::ByteString) global::Google.ProtocolBuffers.TestProtos.TestExtremeDefaultValues.Descriptor.Fields[0].DefaultValue;
return this;
@@ -14076,11 +15252,13 @@ namespace Google.ProtocolBuffers.TestProtos { }
[global::System.CLSCompliant(false)]
public Builder SetLargeUint32(uint value) {
+ PrepareBuilder();
result.hasLargeUint32 = true;
result.largeUint32_ = value;
return this;
}
public Builder ClearLargeUint32() {
+ PrepareBuilder();
result.hasLargeUint32 = false;
result.largeUint32_ = 4294967295;
return this;
@@ -14096,11 +15274,13 @@ namespace Google.ProtocolBuffers.TestProtos { }
[global::System.CLSCompliant(false)]
public Builder SetLargeUint64(ulong value) {
+ PrepareBuilder();
result.hasLargeUint64 = true;
result.largeUint64_ = value;
return this;
}
public Builder ClearLargeUint64() {
+ PrepareBuilder();
result.hasLargeUint64 = false;
result.largeUint64_ = 18446744073709551615UL;
return this;
@@ -14114,11 +15294,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetSmallInt32(value); }
}
public Builder SetSmallInt32(int value) {
+ PrepareBuilder();
result.hasSmallInt32 = true;
result.smallInt32_ = value;
return this;
}
public Builder ClearSmallInt32() {
+ PrepareBuilder();
result.hasSmallInt32 = false;
result.smallInt32_ = -2147483647;
return this;
@@ -14132,11 +15314,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetSmallInt64(value); }
}
public Builder SetSmallInt64(long value) {
+ PrepareBuilder();
result.hasSmallInt64 = true;
result.smallInt64_ = value;
return this;
}
public Builder ClearSmallInt64() {
+ PrepareBuilder();
result.hasSmallInt64 = false;
result.smallInt64_ = -9223372036854775807L;
return this;
@@ -14151,11 +15335,13 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetUtf8String(string value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.hasUtf8String = true;
result.utf8String_ = value;
return this;
}
public Builder ClearUtf8String() {
+ PrepareBuilder();
result.hasUtf8String = false;
result.utf8String_ = (string) global::Google.ProtocolBuffers.TestProtos.TestExtremeDefaultValues.Descriptor.Fields[5].DefaultValue;
return this;
@@ -14169,11 +15355,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetZeroFloat(value); }
}
public Builder SetZeroFloat(float value) {
+ PrepareBuilder();
result.hasZeroFloat = true;
result.zeroFloat_ = value;
return this;
}
public Builder ClearZeroFloat() {
+ PrepareBuilder();
result.hasZeroFloat = false;
result.zeroFloat_ = 0F;
return this;
@@ -14187,11 +15375,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetOneFloat(value); }
}
public Builder SetOneFloat(float value) {
+ PrepareBuilder();
result.hasOneFloat = true;
result.oneFloat_ = value;
return this;
}
public Builder ClearOneFloat() {
+ PrepareBuilder();
result.hasOneFloat = false;
result.oneFloat_ = 1F;
return this;
@@ -14205,11 +15395,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetSmallFloat(value); }
}
public Builder SetSmallFloat(float value) {
+ PrepareBuilder();
result.hasSmallFloat = true;
result.smallFloat_ = value;
return this;
}
public Builder ClearSmallFloat() {
+ PrepareBuilder();
result.hasSmallFloat = false;
result.smallFloat_ = 1.5F;
return this;
@@ -14223,11 +15415,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetNegativeOneFloat(value); }
}
public Builder SetNegativeOneFloat(float value) {
+ PrepareBuilder();
result.hasNegativeOneFloat = true;
result.negativeOneFloat_ = value;
return this;
}
public Builder ClearNegativeOneFloat() {
+ PrepareBuilder();
result.hasNegativeOneFloat = false;
result.negativeOneFloat_ = -1F;
return this;
@@ -14241,11 +15435,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetNegativeFloat(value); }
}
public Builder SetNegativeFloat(float value) {
+ PrepareBuilder();
result.hasNegativeFloat = true;
result.negativeFloat_ = value;
return this;
}
public Builder ClearNegativeFloat() {
+ PrepareBuilder();
result.hasNegativeFloat = false;
result.negativeFloat_ = -1.5F;
return this;
@@ -14259,11 +15455,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetLargeFloat(value); }
}
public Builder SetLargeFloat(float value) {
+ PrepareBuilder();
result.hasLargeFloat = true;
result.largeFloat_ = value;
return this;
}
public Builder ClearLargeFloat() {
+ PrepareBuilder();
result.hasLargeFloat = false;
result.largeFloat_ = 2E+08F;
return this;
@@ -14277,11 +15475,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetSmallNegativeFloat(value); }
}
public Builder SetSmallNegativeFloat(float value) {
+ PrepareBuilder();
result.hasSmallNegativeFloat = true;
result.smallNegativeFloat_ = value;
return this;
}
public Builder ClearSmallNegativeFloat() {
+ PrepareBuilder();
result.hasSmallNegativeFloat = false;
result.smallNegativeFloat_ = -8E-28F;
return this;
@@ -14295,11 +15495,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetInfDouble(value); }
}
public Builder SetInfDouble(double value) {
+ PrepareBuilder();
result.hasInfDouble = true;
result.infDouble_ = value;
return this;
}
public Builder ClearInfDouble() {
+ PrepareBuilder();
result.hasInfDouble = false;
result.infDouble_ = double.PositiveInfinity;
return this;
@@ -14313,11 +15515,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetNegInfDouble(value); }
}
public Builder SetNegInfDouble(double value) {
+ PrepareBuilder();
result.hasNegInfDouble = true;
result.negInfDouble_ = value;
return this;
}
public Builder ClearNegInfDouble() {
+ PrepareBuilder();
result.hasNegInfDouble = false;
result.negInfDouble_ = double.NegativeInfinity;
return this;
@@ -14331,11 +15535,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetNanDouble(value); }
}
public Builder SetNanDouble(double value) {
+ PrepareBuilder();
result.hasNanDouble = true;
result.nanDouble_ = value;
return this;
}
public Builder ClearNanDouble() {
+ PrepareBuilder();
result.hasNanDouble = false;
result.nanDouble_ = double.NaN;
return this;
@@ -14349,11 +15555,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetInfFloat(value); }
}
public Builder SetInfFloat(float value) {
+ PrepareBuilder();
result.hasInfFloat = true;
result.infFloat_ = value;
return this;
}
public Builder ClearInfFloat() {
+ PrepareBuilder();
result.hasInfFloat = false;
result.infFloat_ = float.PositiveInfinity;
return this;
@@ -14367,11 +15575,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetNegInfFloat(value); }
}
public Builder SetNegInfFloat(float value) {
+ PrepareBuilder();
result.hasNegInfFloat = true;
result.negInfFloat_ = value;
return this;
}
public Builder ClearNegInfFloat() {
+ PrepareBuilder();
result.hasNegInfFloat = false;
result.negInfFloat_ = float.NegativeInfinity;
return this;
@@ -14385,11 +15595,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetNanFloat(value); }
}
public Builder SetNanFloat(float value) {
+ PrepareBuilder();
result.hasNanFloat = true;
result.nanFloat_ = value;
return this;
}
public Builder ClearNanFloat() {
+ PrepareBuilder();
result.hasNanFloat = false;
result.nanFloat_ = float.NaN;
return this;
@@ -14502,7 +15714,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(OneString prototype) {
- return (Builder) new Builder().MergeFrom(prototype);
+ return new Builder(prototype);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -14512,21 +15724,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder {
get { return this; }
}
- public Builder() {}
+ public Builder() {
+ result = DefaultInstance ?? new OneString();
+ builderIsReadOnly = result == DefaultInstance;
+ }
+ internal Builder(OneString cloneFrom) {
+ result = cloneFrom;
+ builderIsReadOnly = true;
+ }
- OneString result = new OneString();
+ bool builderIsReadOnly;
+ OneString result;
+
+ private OneString PrepareBuilder() {
+ if (builderIsReadOnly) {
+ OneString original = result;
+ result = new OneString();
+ builderIsReadOnly = false;
+ MergeFrom(original);
+ }
+ return result;
+ }
+
+ public override bool IsInitialized {
+ get { return result.IsInitialized; }
+ }
protected override OneString MessageBeingBuilt {
- get { return result; }
+ get { return PrepareBuilder(); }
}
public override Builder Clear() {
- result = new OneString();
+ result = DefaultInstance ?? new OneString();
+ builderIsReadOnly = true;
return this;
}
public override Builder Clone() {
- return new Builder().MergeFrom(result);
+ if (builderIsReadOnly) {
+ return new Builder(result);
+ } else {
+ return new Builder().MergeFrom(result);
+ }
}
public override pbd::MessageDescriptor DescriptorForType {
@@ -14538,12 +15777,11 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override OneString BuildPartial() {
- if (result == null) {
- throw new global::System.InvalidOperationException("build() has already been called on this Builder");
+ if (builderIsReadOnly) {
+ return result;
}
- OneString returnMe = result;
- result = null;
- return returnMe;
+ builderIsReadOnly = true;
+ return result;
}
public override Builder MergeFrom(pb::IMessage other) {
@@ -14557,6 +15795,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder MergeFrom(OneString other) {
if (other == global::Google.ProtocolBuffers.TestProtos.OneString.DefaultInstance) return this;
+ PrepareBuilder();
if (other.HasData) {
Data = other.Data;
}
@@ -14569,6 +15808,7 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
+ PrepareBuilder();
pb::UnknownFieldSet.Builder unknownFields = null;
uint tag;
string field_name;
@@ -14625,11 +15865,13 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetData(string value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.hasData = true;
result.data_ = value;
return this;
}
public Builder ClearData() {
+ PrepareBuilder();
result.hasData = false;
result.data_ = "";
return this;
@@ -14742,7 +15984,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(OneBytes prototype) {
- return (Builder) new Builder().MergeFrom(prototype);
+ return new Builder(prototype);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -14752,21 +15994,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder {
get { return this; }
}
- public Builder() {}
+ public Builder() {
+ result = DefaultInstance ?? new OneBytes();
+ builderIsReadOnly = result == DefaultInstance;
+ }
+ internal Builder(OneBytes cloneFrom) {
+ result = cloneFrom;
+ builderIsReadOnly = true;
+ }
- OneBytes result = new OneBytes();
+ bool builderIsReadOnly;
+ OneBytes result;
+
+ private OneBytes PrepareBuilder() {
+ if (builderIsReadOnly) {
+ OneBytes original = result;
+ result = new OneBytes();
+ builderIsReadOnly = false;
+ MergeFrom(original);
+ }
+ return result;
+ }
+
+ public override bool IsInitialized {
+ get { return result.IsInitialized; }
+ }
protected override OneBytes MessageBeingBuilt {
- get { return result; }
+ get { return PrepareBuilder(); }
}
public override Builder Clear() {
- result = new OneBytes();
+ result = DefaultInstance ?? new OneBytes();
+ builderIsReadOnly = true;
return this;
}
public override Builder Clone() {
- return new Builder().MergeFrom(result);
+ if (builderIsReadOnly) {
+ return new Builder(result);
+ } else {
+ return new Builder().MergeFrom(result);
+ }
}
public override pbd::MessageDescriptor DescriptorForType {
@@ -14778,12 +16047,11 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override OneBytes BuildPartial() {
- if (result == null) {
- throw new global::System.InvalidOperationException("build() has already been called on this Builder");
+ if (builderIsReadOnly) {
+ return result;
}
- OneBytes returnMe = result;
- result = null;
- return returnMe;
+ builderIsReadOnly = true;
+ return result;
}
public override Builder MergeFrom(pb::IMessage other) {
@@ -14797,6 +16065,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder MergeFrom(OneBytes other) {
if (other == global::Google.ProtocolBuffers.TestProtos.OneBytes.DefaultInstance) return this;
+ PrepareBuilder();
if (other.HasData) {
Data = other.Data;
}
@@ -14809,6 +16078,7 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
+ PrepareBuilder();
pb::UnknownFieldSet.Builder unknownFields = null;
uint tag;
string field_name;
@@ -14865,11 +16135,13 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetData(pb::ByteString value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.hasData = true;
result.data_ = value;
return this;
}
public Builder ClearData() {
+ PrepareBuilder();
result.hasData = false;
result.data_ = pb::ByteString.Empty;
return this;
@@ -15339,7 +16611,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(TestPackedTypes prototype) {
- return (Builder) new Builder().MergeFrom(prototype);
+ return new Builder(prototype);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -15349,21 +16621,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder {
get { return this; }
}
- public Builder() {}
+ public Builder() {
+ result = DefaultInstance ?? new TestPackedTypes();
+ builderIsReadOnly = result == DefaultInstance;
+ }
+ internal Builder(TestPackedTypes cloneFrom) {
+ result = cloneFrom;
+ builderIsReadOnly = true;
+ }
- TestPackedTypes result = new TestPackedTypes();
+ bool builderIsReadOnly;
+ TestPackedTypes result;
+
+ private TestPackedTypes PrepareBuilder() {
+ if (builderIsReadOnly) {
+ TestPackedTypes original = result;
+ result = new TestPackedTypes();
+ builderIsReadOnly = false;
+ MergeFrom(original);
+ }
+ return result;
+ }
+
+ public override bool IsInitialized {
+ get { return result.IsInitialized; }
+ }
protected override TestPackedTypes MessageBeingBuilt {
- get { return result; }
+ get { return PrepareBuilder(); }
}
public override Builder Clear() {
- result = new TestPackedTypes();
+ result = DefaultInstance ?? new TestPackedTypes();
+ builderIsReadOnly = true;
return this;
}
public override Builder Clone() {
- return new Builder().MergeFrom(result);
+ if (builderIsReadOnly) {
+ return new Builder(result);
+ } else {
+ return new Builder().MergeFrom(result);
+ }
}
public override pbd::MessageDescriptor DescriptorForType {
@@ -15375,8 +16674,8 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override TestPackedTypes BuildPartial() {
- if (result == null) {
- throw new global::System.InvalidOperationException("build() has already been called on this Builder");
+ if (builderIsReadOnly) {
+ return result;
}
result.packedInt32_.MakeReadOnly();
result.packedInt64_.MakeReadOnly();
@@ -15392,9 +16691,8 @@ namespace Google.ProtocolBuffers.TestProtos { result.packedDouble_.MakeReadOnly();
result.packedBool_.MakeReadOnly();
result.packedEnum_.MakeReadOnly();
- TestPackedTypes returnMe = result;
- result = null;
- return returnMe;
+ builderIsReadOnly = true;
+ return result;
}
public override Builder MergeFrom(pb::IMessage other) {
@@ -15408,6 +16706,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder MergeFrom(TestPackedTypes other) {
if (other == global::Google.ProtocolBuffers.TestProtos.TestPackedTypes.DefaultInstance) return this;
+ PrepareBuilder();
if (other.packedInt32_.Count != 0) {
base.AddRange(other.packedInt32_, result.packedInt32_);
}
@@ -15459,6 +16758,7 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
+ PrepareBuilder();
pb::UnknownFieldSet.Builder unknownFields = null;
uint tag;
string field_name;
@@ -15582,7 +16882,7 @@ namespace Google.ProtocolBuffers.TestProtos { public pbc::IPopsicleList<int> PackedInt32List {
- get { return result.packedInt32_; }
+ get { return PrepareBuilder().packedInt32_; }
}
public int PackedInt32Count {
get { return result.PackedInt32Count; }
@@ -15591,24 +16891,28 @@ namespace Google.ProtocolBuffers.TestProtos { return result.GetPackedInt32(index);
}
public Builder SetPackedInt32(int index, int value) {
+ PrepareBuilder();
result.packedInt32_[index] = value;
return this;
}
public Builder AddPackedInt32(int value) {
+ PrepareBuilder();
result.packedInt32_.Add(value);
return this;
}
public Builder AddRangePackedInt32(scg::IEnumerable<int> values) {
+ PrepareBuilder();
base.AddRange(values, result.packedInt32_);
return this;
}
public Builder ClearPackedInt32() {
+ PrepareBuilder();
result.packedInt32_.Clear();
return this;
}
public pbc::IPopsicleList<long> PackedInt64List {
- get { return result.packedInt64_; }
+ get { return PrepareBuilder().packedInt64_; }
}
public int PackedInt64Count {
get { return result.PackedInt64Count; }
@@ -15617,25 +16921,29 @@ namespace Google.ProtocolBuffers.TestProtos { return result.GetPackedInt64(index);
}
public Builder SetPackedInt64(int index, long value) {
+ PrepareBuilder();
result.packedInt64_[index] = value;
return this;
}
public Builder AddPackedInt64(long value) {
+ PrepareBuilder();
result.packedInt64_.Add(value);
return this;
}
public Builder AddRangePackedInt64(scg::IEnumerable<long> values) {
+ PrepareBuilder();
base.AddRange(values, result.packedInt64_);
return this;
}
public Builder ClearPackedInt64() {
+ PrepareBuilder();
result.packedInt64_.Clear();
return this;
}
[global::System.CLSCompliant(false)]
public pbc::IPopsicleList<uint> PackedUint32List {
- get { return result.packedUint32_; }
+ get { return PrepareBuilder().packedUint32_; }
}
public int PackedUint32Count {
get { return result.PackedUint32Count; }
@@ -15646,27 +16954,31 @@ namespace Google.ProtocolBuffers.TestProtos { }
[global::System.CLSCompliant(false)]
public Builder SetPackedUint32(int index, uint value) {
+ PrepareBuilder();
result.packedUint32_[index] = value;
return this;
}
[global::System.CLSCompliant(false)]
public Builder AddPackedUint32(uint value) {
+ PrepareBuilder();
result.packedUint32_.Add(value);
return this;
}
[global::System.CLSCompliant(false)]
public Builder AddRangePackedUint32(scg::IEnumerable<uint> values) {
+ PrepareBuilder();
base.AddRange(values, result.packedUint32_);
return this;
}
public Builder ClearPackedUint32() {
+ PrepareBuilder();
result.packedUint32_.Clear();
return this;
}
[global::System.CLSCompliant(false)]
public pbc::IPopsicleList<ulong> PackedUint64List {
- get { return result.packedUint64_; }
+ get { return PrepareBuilder().packedUint64_; }
}
public int PackedUint64Count {
get { return result.PackedUint64Count; }
@@ -15677,26 +16989,30 @@ namespace Google.ProtocolBuffers.TestProtos { }
[global::System.CLSCompliant(false)]
public Builder SetPackedUint64(int index, ulong value) {
+ PrepareBuilder();
result.packedUint64_[index] = value;
return this;
}
[global::System.CLSCompliant(false)]
public Builder AddPackedUint64(ulong value) {
+ PrepareBuilder();
result.packedUint64_.Add(value);
return this;
}
[global::System.CLSCompliant(false)]
public Builder AddRangePackedUint64(scg::IEnumerable<ulong> values) {
+ PrepareBuilder();
base.AddRange(values, result.packedUint64_);
return this;
}
public Builder ClearPackedUint64() {
+ PrepareBuilder();
result.packedUint64_.Clear();
return this;
}
public pbc::IPopsicleList<int> PackedSint32List {
- get { return result.packedSint32_; }
+ get { return PrepareBuilder().packedSint32_; }
}
public int PackedSint32Count {
get { return result.PackedSint32Count; }
@@ -15705,24 +17021,28 @@ namespace Google.ProtocolBuffers.TestProtos { return result.GetPackedSint32(index);
}
public Builder SetPackedSint32(int index, int value) {
+ PrepareBuilder();
result.packedSint32_[index] = value;
return this;
}
public Builder AddPackedSint32(int value) {
+ PrepareBuilder();
result.packedSint32_.Add(value);
return this;
}
public Builder AddRangePackedSint32(scg::IEnumerable<int> values) {
+ PrepareBuilder();
base.AddRange(values, result.packedSint32_);
return this;
}
public Builder ClearPackedSint32() {
+ PrepareBuilder();
result.packedSint32_.Clear();
return this;
}
public pbc::IPopsicleList<long> PackedSint64List {
- get { return result.packedSint64_; }
+ get { return PrepareBuilder().packedSint64_; }
}
public int PackedSint64Count {
get { return result.PackedSint64Count; }
@@ -15731,25 +17051,29 @@ namespace Google.ProtocolBuffers.TestProtos { return result.GetPackedSint64(index);
}
public Builder SetPackedSint64(int index, long value) {
+ PrepareBuilder();
result.packedSint64_[index] = value;
return this;
}
public Builder AddPackedSint64(long value) {
+ PrepareBuilder();
result.packedSint64_.Add(value);
return this;
}
public Builder AddRangePackedSint64(scg::IEnumerable<long> values) {
+ PrepareBuilder();
base.AddRange(values, result.packedSint64_);
return this;
}
public Builder ClearPackedSint64() {
+ PrepareBuilder();
result.packedSint64_.Clear();
return this;
}
[global::System.CLSCompliant(false)]
public pbc::IPopsicleList<uint> PackedFixed32List {
- get { return result.packedFixed32_; }
+ get { return PrepareBuilder().packedFixed32_; }
}
public int PackedFixed32Count {
get { return result.PackedFixed32Count; }
@@ -15760,27 +17084,31 @@ namespace Google.ProtocolBuffers.TestProtos { }
[global::System.CLSCompliant(false)]
public Builder SetPackedFixed32(int index, uint value) {
+ PrepareBuilder();
result.packedFixed32_[index] = value;
return this;
}
[global::System.CLSCompliant(false)]
public Builder AddPackedFixed32(uint value) {
+ PrepareBuilder();
result.packedFixed32_.Add(value);
return this;
}
[global::System.CLSCompliant(false)]
public Builder AddRangePackedFixed32(scg::IEnumerable<uint> values) {
+ PrepareBuilder();
base.AddRange(values, result.packedFixed32_);
return this;
}
public Builder ClearPackedFixed32() {
+ PrepareBuilder();
result.packedFixed32_.Clear();
return this;
}
[global::System.CLSCompliant(false)]
public pbc::IPopsicleList<ulong> PackedFixed64List {
- get { return result.packedFixed64_; }
+ get { return PrepareBuilder().packedFixed64_; }
}
public int PackedFixed64Count {
get { return result.PackedFixed64Count; }
@@ -15791,26 +17119,30 @@ namespace Google.ProtocolBuffers.TestProtos { }
[global::System.CLSCompliant(false)]
public Builder SetPackedFixed64(int index, ulong value) {
+ PrepareBuilder();
result.packedFixed64_[index] = value;
return this;
}
[global::System.CLSCompliant(false)]
public Builder AddPackedFixed64(ulong value) {
+ PrepareBuilder();
result.packedFixed64_.Add(value);
return this;
}
[global::System.CLSCompliant(false)]
public Builder AddRangePackedFixed64(scg::IEnumerable<ulong> values) {
+ PrepareBuilder();
base.AddRange(values, result.packedFixed64_);
return this;
}
public Builder ClearPackedFixed64() {
+ PrepareBuilder();
result.packedFixed64_.Clear();
return this;
}
public pbc::IPopsicleList<int> PackedSfixed32List {
- get { return result.packedSfixed32_; }
+ get { return PrepareBuilder().packedSfixed32_; }
}
public int PackedSfixed32Count {
get { return result.PackedSfixed32Count; }
@@ -15819,24 +17151,28 @@ namespace Google.ProtocolBuffers.TestProtos { return result.GetPackedSfixed32(index);
}
public Builder SetPackedSfixed32(int index, int value) {
+ PrepareBuilder();
result.packedSfixed32_[index] = value;
return this;
}
public Builder AddPackedSfixed32(int value) {
+ PrepareBuilder();
result.packedSfixed32_.Add(value);
return this;
}
public Builder AddRangePackedSfixed32(scg::IEnumerable<int> values) {
+ PrepareBuilder();
base.AddRange(values, result.packedSfixed32_);
return this;
}
public Builder ClearPackedSfixed32() {
+ PrepareBuilder();
result.packedSfixed32_.Clear();
return this;
}
public pbc::IPopsicleList<long> PackedSfixed64List {
- get { return result.packedSfixed64_; }
+ get { return PrepareBuilder().packedSfixed64_; }
}
public int PackedSfixed64Count {
get { return result.PackedSfixed64Count; }
@@ -15845,24 +17181,28 @@ namespace Google.ProtocolBuffers.TestProtos { return result.GetPackedSfixed64(index);
}
public Builder SetPackedSfixed64(int index, long value) {
+ PrepareBuilder();
result.packedSfixed64_[index] = value;
return this;
}
public Builder AddPackedSfixed64(long value) {
+ PrepareBuilder();
result.packedSfixed64_.Add(value);
return this;
}
public Builder AddRangePackedSfixed64(scg::IEnumerable<long> values) {
+ PrepareBuilder();
base.AddRange(values, result.packedSfixed64_);
return this;
}
public Builder ClearPackedSfixed64() {
+ PrepareBuilder();
result.packedSfixed64_.Clear();
return this;
}
public pbc::IPopsicleList<float> PackedFloatList {
- get { return result.packedFloat_; }
+ get { return PrepareBuilder().packedFloat_; }
}
public int PackedFloatCount {
get { return result.PackedFloatCount; }
@@ -15871,24 +17211,28 @@ namespace Google.ProtocolBuffers.TestProtos { return result.GetPackedFloat(index);
}
public Builder SetPackedFloat(int index, float value) {
+ PrepareBuilder();
result.packedFloat_[index] = value;
return this;
}
public Builder AddPackedFloat(float value) {
+ PrepareBuilder();
result.packedFloat_.Add(value);
return this;
}
public Builder AddRangePackedFloat(scg::IEnumerable<float> values) {
+ PrepareBuilder();
base.AddRange(values, result.packedFloat_);
return this;
}
public Builder ClearPackedFloat() {
+ PrepareBuilder();
result.packedFloat_.Clear();
return this;
}
public pbc::IPopsicleList<double> PackedDoubleList {
- get { return result.packedDouble_; }
+ get { return PrepareBuilder().packedDouble_; }
}
public int PackedDoubleCount {
get { return result.PackedDoubleCount; }
@@ -15897,24 +17241,28 @@ namespace Google.ProtocolBuffers.TestProtos { return result.GetPackedDouble(index);
}
public Builder SetPackedDouble(int index, double value) {
+ PrepareBuilder();
result.packedDouble_[index] = value;
return this;
}
public Builder AddPackedDouble(double value) {
+ PrepareBuilder();
result.packedDouble_.Add(value);
return this;
}
public Builder AddRangePackedDouble(scg::IEnumerable<double> values) {
+ PrepareBuilder();
base.AddRange(values, result.packedDouble_);
return this;
}
public Builder ClearPackedDouble() {
+ PrepareBuilder();
result.packedDouble_.Clear();
return this;
}
public pbc::IPopsicleList<bool> PackedBoolList {
- get { return result.packedBool_; }
+ get { return PrepareBuilder().packedBool_; }
}
public int PackedBoolCount {
get { return result.PackedBoolCount; }
@@ -15923,24 +17271,28 @@ namespace Google.ProtocolBuffers.TestProtos { return result.GetPackedBool(index);
}
public Builder SetPackedBool(int index, bool value) {
+ PrepareBuilder();
result.packedBool_[index] = value;
return this;
}
public Builder AddPackedBool(bool value) {
+ PrepareBuilder();
result.packedBool_.Add(value);
return this;
}
public Builder AddRangePackedBool(scg::IEnumerable<bool> values) {
+ PrepareBuilder();
base.AddRange(values, result.packedBool_);
return this;
}
public Builder ClearPackedBool() {
+ PrepareBuilder();
result.packedBool_.Clear();
return this;
}
public pbc::IPopsicleList<global::Google.ProtocolBuffers.TestProtos.ForeignEnum> PackedEnumList {
- get { return result.packedEnum_; }
+ get { return PrepareBuilder().packedEnum_; }
}
public int PackedEnumCount {
get { return result.PackedEnumCount; }
@@ -15949,18 +17301,22 @@ namespace Google.ProtocolBuffers.TestProtos { return result.GetPackedEnum(index);
}
public Builder SetPackedEnum(int index, global::Google.ProtocolBuffers.TestProtos.ForeignEnum value) {
+ PrepareBuilder();
result.packedEnum_[index] = value;
return this;
}
public Builder AddPackedEnum(global::Google.ProtocolBuffers.TestProtos.ForeignEnum value) {
+ PrepareBuilder();
result.packedEnum_.Add(value);
return this;
}
public Builder AddRangePackedEnum(scg::IEnumerable<global::Google.ProtocolBuffers.TestProtos.ForeignEnum> values) {
+ PrepareBuilder();
base.AddRange(values, result.packedEnum_);
return this;
}
public Builder ClearPackedEnum() {
+ PrepareBuilder();
result.packedEnum_.Clear();
return this;
}
@@ -16374,7 +17730,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(TestUnpackedTypes prototype) {
- return (Builder) new Builder().MergeFrom(prototype);
+ return new Builder(prototype);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -16384,21 +17740,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder {
get { return this; }
}
- public Builder() {}
+ public Builder() {
+ result = DefaultInstance ?? new TestUnpackedTypes();
+ builderIsReadOnly = result == DefaultInstance;
+ }
+ internal Builder(TestUnpackedTypes cloneFrom) {
+ result = cloneFrom;
+ builderIsReadOnly = true;
+ }
+
+ bool builderIsReadOnly;
+ TestUnpackedTypes result;
+
+ private TestUnpackedTypes PrepareBuilder() {
+ if (builderIsReadOnly) {
+ TestUnpackedTypes original = result;
+ result = new TestUnpackedTypes();
+ builderIsReadOnly = false;
+ MergeFrom(original);
+ }
+ return result;
+ }
- TestUnpackedTypes result = new TestUnpackedTypes();
+ public override bool IsInitialized {
+ get { return result.IsInitialized; }
+ }
protected override TestUnpackedTypes MessageBeingBuilt {
- get { return result; }
+ get { return PrepareBuilder(); }
}
public override Builder Clear() {
- result = new TestUnpackedTypes();
+ result = DefaultInstance ?? new TestUnpackedTypes();
+ builderIsReadOnly = true;
return this;
}
public override Builder Clone() {
- return new Builder().MergeFrom(result);
+ if (builderIsReadOnly) {
+ return new Builder(result);
+ } else {
+ return new Builder().MergeFrom(result);
+ }
}
public override pbd::MessageDescriptor DescriptorForType {
@@ -16410,8 +17793,8 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override TestUnpackedTypes BuildPartial() {
- if (result == null) {
- throw new global::System.InvalidOperationException("build() has already been called on this Builder");
+ if (builderIsReadOnly) {
+ return result;
}
result.unpackedInt32_.MakeReadOnly();
result.unpackedInt64_.MakeReadOnly();
@@ -16427,9 +17810,8 @@ namespace Google.ProtocolBuffers.TestProtos { result.unpackedDouble_.MakeReadOnly();
result.unpackedBool_.MakeReadOnly();
result.unpackedEnum_.MakeReadOnly();
- TestUnpackedTypes returnMe = result;
- result = null;
- return returnMe;
+ builderIsReadOnly = true;
+ return result;
}
public override Builder MergeFrom(pb::IMessage other) {
@@ -16443,6 +17825,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder MergeFrom(TestUnpackedTypes other) {
if (other == global::Google.ProtocolBuffers.TestProtos.TestUnpackedTypes.DefaultInstance) return this;
+ PrepareBuilder();
if (other.unpackedInt32_.Count != 0) {
base.AddRange(other.unpackedInt32_, result.unpackedInt32_);
}
@@ -16494,6 +17877,7 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
+ PrepareBuilder();
pb::UnknownFieldSet.Builder unknownFields = null;
uint tag;
string field_name;
@@ -16617,7 +18001,7 @@ namespace Google.ProtocolBuffers.TestProtos { public pbc::IPopsicleList<int> UnpackedInt32List {
- get { return result.unpackedInt32_; }
+ get { return PrepareBuilder().unpackedInt32_; }
}
public int UnpackedInt32Count {
get { return result.UnpackedInt32Count; }
@@ -16626,24 +18010,28 @@ namespace Google.ProtocolBuffers.TestProtos { return result.GetUnpackedInt32(index);
}
public Builder SetUnpackedInt32(int index, int value) {
+ PrepareBuilder();
result.unpackedInt32_[index] = value;
return this;
}
public Builder AddUnpackedInt32(int value) {
+ PrepareBuilder();
result.unpackedInt32_.Add(value);
return this;
}
public Builder AddRangeUnpackedInt32(scg::IEnumerable<int> values) {
+ PrepareBuilder();
base.AddRange(values, result.unpackedInt32_);
return this;
}
public Builder ClearUnpackedInt32() {
+ PrepareBuilder();
result.unpackedInt32_.Clear();
return this;
}
public pbc::IPopsicleList<long> UnpackedInt64List {
- get { return result.unpackedInt64_; }
+ get { return PrepareBuilder().unpackedInt64_; }
}
public int UnpackedInt64Count {
get { return result.UnpackedInt64Count; }
@@ -16652,25 +18040,29 @@ namespace Google.ProtocolBuffers.TestProtos { return result.GetUnpackedInt64(index);
}
public Builder SetUnpackedInt64(int index, long value) {
+ PrepareBuilder();
result.unpackedInt64_[index] = value;
return this;
}
public Builder AddUnpackedInt64(long value) {
+ PrepareBuilder();
result.unpackedInt64_.Add(value);
return this;
}
public Builder AddRangeUnpackedInt64(scg::IEnumerable<long> values) {
+ PrepareBuilder();
base.AddRange(values, result.unpackedInt64_);
return this;
}
public Builder ClearUnpackedInt64() {
+ PrepareBuilder();
result.unpackedInt64_.Clear();
return this;
}
[global::System.CLSCompliant(false)]
public pbc::IPopsicleList<uint> UnpackedUint32List {
- get { return result.unpackedUint32_; }
+ get { return PrepareBuilder().unpackedUint32_; }
}
public int UnpackedUint32Count {
get { return result.UnpackedUint32Count; }
@@ -16681,27 +18073,31 @@ namespace Google.ProtocolBuffers.TestProtos { }
[global::System.CLSCompliant(false)]
public Builder SetUnpackedUint32(int index, uint value) {
+ PrepareBuilder();
result.unpackedUint32_[index] = value;
return this;
}
[global::System.CLSCompliant(false)]
public Builder AddUnpackedUint32(uint value) {
+ PrepareBuilder();
result.unpackedUint32_.Add(value);
return this;
}
[global::System.CLSCompliant(false)]
public Builder AddRangeUnpackedUint32(scg::IEnumerable<uint> values) {
+ PrepareBuilder();
base.AddRange(values, result.unpackedUint32_);
return this;
}
public Builder ClearUnpackedUint32() {
+ PrepareBuilder();
result.unpackedUint32_.Clear();
return this;
}
[global::System.CLSCompliant(false)]
public pbc::IPopsicleList<ulong> UnpackedUint64List {
- get { return result.unpackedUint64_; }
+ get { return PrepareBuilder().unpackedUint64_; }
}
public int UnpackedUint64Count {
get { return result.UnpackedUint64Count; }
@@ -16712,26 +18108,30 @@ namespace Google.ProtocolBuffers.TestProtos { }
[global::System.CLSCompliant(false)]
public Builder SetUnpackedUint64(int index, ulong value) {
+ PrepareBuilder();
result.unpackedUint64_[index] = value;
return this;
}
[global::System.CLSCompliant(false)]
public Builder AddUnpackedUint64(ulong value) {
+ PrepareBuilder();
result.unpackedUint64_.Add(value);
return this;
}
[global::System.CLSCompliant(false)]
public Builder AddRangeUnpackedUint64(scg::IEnumerable<ulong> values) {
+ PrepareBuilder();
base.AddRange(values, result.unpackedUint64_);
return this;
}
public Builder ClearUnpackedUint64() {
+ PrepareBuilder();
result.unpackedUint64_.Clear();
return this;
}
public pbc::IPopsicleList<int> UnpackedSint32List {
- get { return result.unpackedSint32_; }
+ get { return PrepareBuilder().unpackedSint32_; }
}
public int UnpackedSint32Count {
get { return result.UnpackedSint32Count; }
@@ -16740,24 +18140,28 @@ namespace Google.ProtocolBuffers.TestProtos { return result.GetUnpackedSint32(index);
}
public Builder SetUnpackedSint32(int index, int value) {
+ PrepareBuilder();
result.unpackedSint32_[index] = value;
return this;
}
public Builder AddUnpackedSint32(int value) {
+ PrepareBuilder();
result.unpackedSint32_.Add(value);
return this;
}
public Builder AddRangeUnpackedSint32(scg::IEnumerable<int> values) {
+ PrepareBuilder();
base.AddRange(values, result.unpackedSint32_);
return this;
}
public Builder ClearUnpackedSint32() {
+ PrepareBuilder();
result.unpackedSint32_.Clear();
return this;
}
public pbc::IPopsicleList<long> UnpackedSint64List {
- get { return result.unpackedSint64_; }
+ get { return PrepareBuilder().unpackedSint64_; }
}
public int UnpackedSint64Count {
get { return result.UnpackedSint64Count; }
@@ -16766,25 +18170,29 @@ namespace Google.ProtocolBuffers.TestProtos { return result.GetUnpackedSint64(index);
}
public Builder SetUnpackedSint64(int index, long value) {
+ PrepareBuilder();
result.unpackedSint64_[index] = value;
return this;
}
public Builder AddUnpackedSint64(long value) {
+ PrepareBuilder();
result.unpackedSint64_.Add(value);
return this;
}
public Builder AddRangeUnpackedSint64(scg::IEnumerable<long> values) {
+ PrepareBuilder();
base.AddRange(values, result.unpackedSint64_);
return this;
}
public Builder ClearUnpackedSint64() {
+ PrepareBuilder();
result.unpackedSint64_.Clear();
return this;
}
[global::System.CLSCompliant(false)]
public pbc::IPopsicleList<uint> UnpackedFixed32List {
- get { return result.unpackedFixed32_; }
+ get { return PrepareBuilder().unpackedFixed32_; }
}
public int UnpackedFixed32Count {
get { return result.UnpackedFixed32Count; }
@@ -16795,27 +18203,31 @@ namespace Google.ProtocolBuffers.TestProtos { }
[global::System.CLSCompliant(false)]
public Builder SetUnpackedFixed32(int index, uint value) {
+ PrepareBuilder();
result.unpackedFixed32_[index] = value;
return this;
}
[global::System.CLSCompliant(false)]
public Builder AddUnpackedFixed32(uint value) {
+ PrepareBuilder();
result.unpackedFixed32_.Add(value);
return this;
}
[global::System.CLSCompliant(false)]
public Builder AddRangeUnpackedFixed32(scg::IEnumerable<uint> values) {
+ PrepareBuilder();
base.AddRange(values, result.unpackedFixed32_);
return this;
}
public Builder ClearUnpackedFixed32() {
+ PrepareBuilder();
result.unpackedFixed32_.Clear();
return this;
}
[global::System.CLSCompliant(false)]
public pbc::IPopsicleList<ulong> UnpackedFixed64List {
- get { return result.unpackedFixed64_; }
+ get { return PrepareBuilder().unpackedFixed64_; }
}
public int UnpackedFixed64Count {
get { return result.UnpackedFixed64Count; }
@@ -16826,26 +18238,30 @@ namespace Google.ProtocolBuffers.TestProtos { }
[global::System.CLSCompliant(false)]
public Builder SetUnpackedFixed64(int index, ulong value) {
+ PrepareBuilder();
result.unpackedFixed64_[index] = value;
return this;
}
[global::System.CLSCompliant(false)]
public Builder AddUnpackedFixed64(ulong value) {
+ PrepareBuilder();
result.unpackedFixed64_.Add(value);
return this;
}
[global::System.CLSCompliant(false)]
public Builder AddRangeUnpackedFixed64(scg::IEnumerable<ulong> values) {
+ PrepareBuilder();
base.AddRange(values, result.unpackedFixed64_);
return this;
}
public Builder ClearUnpackedFixed64() {
+ PrepareBuilder();
result.unpackedFixed64_.Clear();
return this;
}
public pbc::IPopsicleList<int> UnpackedSfixed32List {
- get { return result.unpackedSfixed32_; }
+ get { return PrepareBuilder().unpackedSfixed32_; }
}
public int UnpackedSfixed32Count {
get { return result.UnpackedSfixed32Count; }
@@ -16854,24 +18270,28 @@ namespace Google.ProtocolBuffers.TestProtos { return result.GetUnpackedSfixed32(index);
}
public Builder SetUnpackedSfixed32(int index, int value) {
+ PrepareBuilder();
result.unpackedSfixed32_[index] = value;
return this;
}
public Builder AddUnpackedSfixed32(int value) {
+ PrepareBuilder();
result.unpackedSfixed32_.Add(value);
return this;
}
public Builder AddRangeUnpackedSfixed32(scg::IEnumerable<int> values) {
+ PrepareBuilder();
base.AddRange(values, result.unpackedSfixed32_);
return this;
}
public Builder ClearUnpackedSfixed32() {
+ PrepareBuilder();
result.unpackedSfixed32_.Clear();
return this;
}
public pbc::IPopsicleList<long> UnpackedSfixed64List {
- get { return result.unpackedSfixed64_; }
+ get { return PrepareBuilder().unpackedSfixed64_; }
}
public int UnpackedSfixed64Count {
get { return result.UnpackedSfixed64Count; }
@@ -16880,24 +18300,28 @@ namespace Google.ProtocolBuffers.TestProtos { return result.GetUnpackedSfixed64(index);
}
public Builder SetUnpackedSfixed64(int index, long value) {
+ PrepareBuilder();
result.unpackedSfixed64_[index] = value;
return this;
}
public Builder AddUnpackedSfixed64(long value) {
+ PrepareBuilder();
result.unpackedSfixed64_.Add(value);
return this;
}
public Builder AddRangeUnpackedSfixed64(scg::IEnumerable<long> values) {
+ PrepareBuilder();
base.AddRange(values, result.unpackedSfixed64_);
return this;
}
public Builder ClearUnpackedSfixed64() {
+ PrepareBuilder();
result.unpackedSfixed64_.Clear();
return this;
}
public pbc::IPopsicleList<float> UnpackedFloatList {
- get { return result.unpackedFloat_; }
+ get { return PrepareBuilder().unpackedFloat_; }
}
public int UnpackedFloatCount {
get { return result.UnpackedFloatCount; }
@@ -16906,24 +18330,28 @@ namespace Google.ProtocolBuffers.TestProtos { return result.GetUnpackedFloat(index);
}
public Builder SetUnpackedFloat(int index, float value) {
+ PrepareBuilder();
result.unpackedFloat_[index] = value;
return this;
}
public Builder AddUnpackedFloat(float value) {
+ PrepareBuilder();
result.unpackedFloat_.Add(value);
return this;
}
public Builder AddRangeUnpackedFloat(scg::IEnumerable<float> values) {
+ PrepareBuilder();
base.AddRange(values, result.unpackedFloat_);
return this;
}
public Builder ClearUnpackedFloat() {
+ PrepareBuilder();
result.unpackedFloat_.Clear();
return this;
}
public pbc::IPopsicleList<double> UnpackedDoubleList {
- get { return result.unpackedDouble_; }
+ get { return PrepareBuilder().unpackedDouble_; }
}
public int UnpackedDoubleCount {
get { return result.UnpackedDoubleCount; }
@@ -16932,24 +18360,28 @@ namespace Google.ProtocolBuffers.TestProtos { return result.GetUnpackedDouble(index);
}
public Builder SetUnpackedDouble(int index, double value) {
+ PrepareBuilder();
result.unpackedDouble_[index] = value;
return this;
}
public Builder AddUnpackedDouble(double value) {
+ PrepareBuilder();
result.unpackedDouble_.Add(value);
return this;
}
public Builder AddRangeUnpackedDouble(scg::IEnumerable<double> values) {
+ PrepareBuilder();
base.AddRange(values, result.unpackedDouble_);
return this;
}
public Builder ClearUnpackedDouble() {
+ PrepareBuilder();
result.unpackedDouble_.Clear();
return this;
}
public pbc::IPopsicleList<bool> UnpackedBoolList {
- get { return result.unpackedBool_; }
+ get { return PrepareBuilder().unpackedBool_; }
}
public int UnpackedBoolCount {
get { return result.UnpackedBoolCount; }
@@ -16958,24 +18390,28 @@ namespace Google.ProtocolBuffers.TestProtos { return result.GetUnpackedBool(index);
}
public Builder SetUnpackedBool(int index, bool value) {
+ PrepareBuilder();
result.unpackedBool_[index] = value;
return this;
}
public Builder AddUnpackedBool(bool value) {
+ PrepareBuilder();
result.unpackedBool_.Add(value);
return this;
}
public Builder AddRangeUnpackedBool(scg::IEnumerable<bool> values) {
+ PrepareBuilder();
base.AddRange(values, result.unpackedBool_);
return this;
}
public Builder ClearUnpackedBool() {
+ PrepareBuilder();
result.unpackedBool_.Clear();
return this;
}
public pbc::IPopsicleList<global::Google.ProtocolBuffers.TestProtos.ForeignEnum> UnpackedEnumList {
- get { return result.unpackedEnum_; }
+ get { return PrepareBuilder().unpackedEnum_; }
}
public int UnpackedEnumCount {
get { return result.UnpackedEnumCount; }
@@ -16984,18 +18420,22 @@ namespace Google.ProtocolBuffers.TestProtos { return result.GetUnpackedEnum(index);
}
public Builder SetUnpackedEnum(int index, global::Google.ProtocolBuffers.TestProtos.ForeignEnum value) {
+ PrepareBuilder();
result.unpackedEnum_[index] = value;
return this;
}
public Builder AddUnpackedEnum(global::Google.ProtocolBuffers.TestProtos.ForeignEnum value) {
+ PrepareBuilder();
result.unpackedEnum_.Add(value);
return this;
}
public Builder AddRangeUnpackedEnum(scg::IEnumerable<global::Google.ProtocolBuffers.TestProtos.ForeignEnum> values) {
+ PrepareBuilder();
base.AddRange(values, result.unpackedEnum_);
return this;
}
public Builder ClearUnpackedEnum() {
+ PrepareBuilder();
result.unpackedEnum_.Clear();
return this;
}
@@ -17095,7 +18535,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(TestPackedExtensions prototype) {
- return (Builder) new Builder().MergeFrom(prototype);
+ return new Builder(prototype);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -17105,21 +18545,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder {
get { return this; }
}
- public Builder() {}
+ public Builder() {
+ result = DefaultInstance ?? new TestPackedExtensions();
+ builderIsReadOnly = result == DefaultInstance;
+ }
+ internal Builder(TestPackedExtensions cloneFrom) {
+ result = cloneFrom;
+ builderIsReadOnly = true;
+ }
+
+ bool builderIsReadOnly;
+ TestPackedExtensions result;
+
+ private TestPackedExtensions PrepareBuilder() {
+ if (builderIsReadOnly) {
+ TestPackedExtensions original = result;
+ result = new TestPackedExtensions();
+ builderIsReadOnly = false;
+ MergeFrom(original);
+ }
+ return result;
+ }
- TestPackedExtensions result = new TestPackedExtensions();
+ public override bool IsInitialized {
+ get { return result.IsInitialized; }
+ }
protected override TestPackedExtensions MessageBeingBuilt {
- get { return result; }
+ get { return PrepareBuilder(); }
}
public override Builder Clear() {
- result = new TestPackedExtensions();
+ result = DefaultInstance ?? new TestPackedExtensions();
+ builderIsReadOnly = true;
return this;
}
public override Builder Clone() {
- return new Builder().MergeFrom(result);
+ if (builderIsReadOnly) {
+ return new Builder(result);
+ } else {
+ return new Builder().MergeFrom(result);
+ }
}
public override pbd::MessageDescriptor DescriptorForType {
@@ -17131,12 +18598,11 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override TestPackedExtensions BuildPartial() {
- if (result == null) {
- throw new global::System.InvalidOperationException("build() has already been called on this Builder");
+ if (builderIsReadOnly) {
+ return result;
}
- TestPackedExtensions returnMe = result;
- result = null;
- return returnMe;
+ builderIsReadOnly = true;
+ return result;
}
public override Builder MergeFrom(pb::IMessage other) {
@@ -17150,6 +18616,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder MergeFrom(TestPackedExtensions other) {
if (other == global::Google.ProtocolBuffers.TestProtos.TestPackedExtensions.DefaultInstance) return this;
+ PrepareBuilder();
this.MergeExtensionFields(other);
this.MergeUnknownFields(other.UnknownFields);
return this;
@@ -17160,6 +18627,7 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
+ PrepareBuilder();
pb::UnknownFieldSet.Builder unknownFields = null;
uint tag;
string field_name;
@@ -17298,7 +18766,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(TestUnpackedExtensions prototype) {
- return (Builder) new Builder().MergeFrom(prototype);
+ return new Builder(prototype);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -17308,21 +18776,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder {
get { return this; }
}
- public Builder() {}
+ public Builder() {
+ result = DefaultInstance ?? new TestUnpackedExtensions();
+ builderIsReadOnly = result == DefaultInstance;
+ }
+ internal Builder(TestUnpackedExtensions cloneFrom) {
+ result = cloneFrom;
+ builderIsReadOnly = true;
+ }
+
+ bool builderIsReadOnly;
+ TestUnpackedExtensions result;
+
+ private TestUnpackedExtensions PrepareBuilder() {
+ if (builderIsReadOnly) {
+ TestUnpackedExtensions original = result;
+ result = new TestUnpackedExtensions();
+ builderIsReadOnly = false;
+ MergeFrom(original);
+ }
+ return result;
+ }
- TestUnpackedExtensions result = new TestUnpackedExtensions();
+ public override bool IsInitialized {
+ get { return result.IsInitialized; }
+ }
protected override TestUnpackedExtensions MessageBeingBuilt {
- get { return result; }
+ get { return PrepareBuilder(); }
}
public override Builder Clear() {
- result = new TestUnpackedExtensions();
+ result = DefaultInstance ?? new TestUnpackedExtensions();
+ builderIsReadOnly = true;
return this;
}
public override Builder Clone() {
- return new Builder().MergeFrom(result);
+ if (builderIsReadOnly) {
+ return new Builder(result);
+ } else {
+ return new Builder().MergeFrom(result);
+ }
}
public override pbd::MessageDescriptor DescriptorForType {
@@ -17334,12 +18829,11 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override TestUnpackedExtensions BuildPartial() {
- if (result == null) {
- throw new global::System.InvalidOperationException("build() has already been called on this Builder");
+ if (builderIsReadOnly) {
+ return result;
}
- TestUnpackedExtensions returnMe = result;
- result = null;
- return returnMe;
+ builderIsReadOnly = true;
+ return result;
}
public override Builder MergeFrom(pb::IMessage other) {
@@ -17353,6 +18847,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder MergeFrom(TestUnpackedExtensions other) {
if (other == global::Google.ProtocolBuffers.TestProtos.TestUnpackedExtensions.DefaultInstance) return this;
+ PrepareBuilder();
this.MergeExtensionFields(other);
this.MergeUnknownFields(other.UnknownFields);
return this;
@@ -17363,6 +18858,7 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
+ PrepareBuilder();
pb::UnknownFieldSet.Builder unknownFields = null;
uint tag;
string field_name;
@@ -17553,7 +19049,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(DynamicMessageType prototype) {
- return (Builder) new Builder().MergeFrom(prototype);
+ return new Builder(prototype);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -17563,21 +19059,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder {
get { return this; }
}
- public Builder() {}
+ public Builder() {
+ result = DefaultInstance ?? new DynamicMessageType();
+ builderIsReadOnly = result == DefaultInstance;
+ }
+ internal Builder(DynamicMessageType cloneFrom) {
+ result = cloneFrom;
+ builderIsReadOnly = true;
+ }
+
+ bool builderIsReadOnly;
+ DynamicMessageType result;
- DynamicMessageType result = new DynamicMessageType();
+ private DynamicMessageType PrepareBuilder() {
+ if (builderIsReadOnly) {
+ DynamicMessageType original = result;
+ result = new DynamicMessageType();
+ builderIsReadOnly = false;
+ MergeFrom(original);
+ }
+ return result;
+ }
+
+ public override bool IsInitialized {
+ get { return result.IsInitialized; }
+ }
protected override DynamicMessageType MessageBeingBuilt {
- get { return result; }
+ get { return PrepareBuilder(); }
}
public override Builder Clear() {
- result = new DynamicMessageType();
+ result = DefaultInstance ?? new DynamicMessageType();
+ builderIsReadOnly = true;
return this;
}
public override Builder Clone() {
- return new Builder().MergeFrom(result);
+ if (builderIsReadOnly) {
+ return new Builder(result);
+ } else {
+ return new Builder().MergeFrom(result);
+ }
}
public override pbd::MessageDescriptor DescriptorForType {
@@ -17589,12 +19112,11 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override DynamicMessageType BuildPartial() {
- if (result == null) {
- throw new global::System.InvalidOperationException("build() has already been called on this Builder");
+ if (builderIsReadOnly) {
+ return result;
}
- DynamicMessageType returnMe = result;
- result = null;
- return returnMe;
+ builderIsReadOnly = true;
+ return result;
}
public override Builder MergeFrom(pb::IMessage other) {
@@ -17608,6 +19130,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder MergeFrom(DynamicMessageType other) {
if (other == global::Google.ProtocolBuffers.TestProtos.TestDynamicExtensions.Types.DynamicMessageType.DefaultInstance) return this;
+ PrepareBuilder();
if (other.HasDynamicField) {
DynamicField = other.DynamicField;
}
@@ -17620,6 +19143,7 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
+ PrepareBuilder();
pb::UnknownFieldSet.Builder unknownFields = null;
uint tag;
string field_name;
@@ -17675,11 +19199,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetDynamicField(value); }
}
public Builder SetDynamicField(int value) {
+ PrepareBuilder();
result.hasDynamicField = true;
result.dynamicField_ = value;
return this;
}
public Builder ClearDynamicField() {
+ PrepareBuilder();
result.hasDynamicField = false;
result.dynamicField_ = 0;
return this;
@@ -17883,7 +19409,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(TestDynamicExtensions prototype) {
- return (Builder) new Builder().MergeFrom(prototype);
+ return new Builder(prototype);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -17893,21 +19419,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder {
get { return this; }
}
- public Builder() {}
+ public Builder() {
+ result = DefaultInstance ?? new TestDynamicExtensions();
+ builderIsReadOnly = result == DefaultInstance;
+ }
+ internal Builder(TestDynamicExtensions cloneFrom) {
+ result = cloneFrom;
+ builderIsReadOnly = true;
+ }
- TestDynamicExtensions result = new TestDynamicExtensions();
+ bool builderIsReadOnly;
+ TestDynamicExtensions result;
+
+ private TestDynamicExtensions PrepareBuilder() {
+ if (builderIsReadOnly) {
+ TestDynamicExtensions original = result;
+ result = new TestDynamicExtensions();
+ builderIsReadOnly = false;
+ MergeFrom(original);
+ }
+ return result;
+ }
+
+ public override bool IsInitialized {
+ get { return result.IsInitialized; }
+ }
protected override TestDynamicExtensions MessageBeingBuilt {
- get { return result; }
+ get { return PrepareBuilder(); }
}
public override Builder Clear() {
- result = new TestDynamicExtensions();
+ result = DefaultInstance ?? new TestDynamicExtensions();
+ builderIsReadOnly = true;
return this;
}
public override Builder Clone() {
- return new Builder().MergeFrom(result);
+ if (builderIsReadOnly) {
+ return new Builder(result);
+ } else {
+ return new Builder().MergeFrom(result);
+ }
}
public override pbd::MessageDescriptor DescriptorForType {
@@ -17919,14 +19472,13 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override TestDynamicExtensions BuildPartial() {
- if (result == null) {
- throw new global::System.InvalidOperationException("build() has already been called on this Builder");
+ if (builderIsReadOnly) {
+ return result;
}
result.repeatedExtension_.MakeReadOnly();
result.packedExtension_.MakeReadOnly();
- TestDynamicExtensions returnMe = result;
- result = null;
- return returnMe;
+ builderIsReadOnly = true;
+ return result;
}
public override Builder MergeFrom(pb::IMessage other) {
@@ -17940,6 +19492,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder MergeFrom(TestDynamicExtensions other) {
if (other == global::Google.ProtocolBuffers.TestProtos.TestDynamicExtensions.DefaultInstance) return this;
+ PrepareBuilder();
if (other.HasScalarExtension) {
ScalarExtension = other.ScalarExtension;
}
@@ -17970,6 +19523,7 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
+ PrepareBuilder();
pb::UnknownFieldSet.Builder unknownFields = null;
uint tag;
string field_name;
@@ -18078,11 +19632,13 @@ namespace Google.ProtocolBuffers.TestProtos { }
[global::System.CLSCompliant(false)]
public Builder SetScalarExtension(uint value) {
+ PrepareBuilder();
result.hasScalarExtension = true;
result.scalarExtension_ = value;
return this;
}
public Builder ClearScalarExtension() {
+ PrepareBuilder();
result.hasScalarExtension = false;
result.scalarExtension_ = 0;
return this;
@@ -18096,11 +19652,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetEnumExtension(value); }
}
public Builder SetEnumExtension(global::Google.ProtocolBuffers.TestProtos.ForeignEnum value) {
+ PrepareBuilder();
result.hasEnumExtension = true;
result.enumExtension_ = value;
return this;
}
public Builder ClearEnumExtension() {
+ PrepareBuilder();
result.hasEnumExtension = false;
result.enumExtension_ = global::Google.ProtocolBuffers.TestProtos.ForeignEnum.FOREIGN_FOO;
return this;
@@ -18114,11 +19672,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetDynamicEnumExtension(value); }
}
public Builder SetDynamicEnumExtension(global::Google.ProtocolBuffers.TestProtos.TestDynamicExtensions.Types.DynamicEnumType value) {
+ PrepareBuilder();
result.hasDynamicEnumExtension = true;
result.dynamicEnumExtension_ = value;
return this;
}
public Builder ClearDynamicEnumExtension() {
+ PrepareBuilder();
result.hasDynamicEnumExtension = false;
result.dynamicEnumExtension_ = global::Google.ProtocolBuffers.TestProtos.TestDynamicExtensions.Types.DynamicEnumType.DYNAMIC_FOO;
return this;
@@ -18133,18 +19693,21 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetMessageExtension(global::Google.ProtocolBuffers.TestProtos.ForeignMessage value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.hasMessageExtension = true;
result.messageExtension_ = value;
return this;
}
public Builder SetMessageExtension(global::Google.ProtocolBuffers.TestProtos.ForeignMessage.Builder builderForValue) {
pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue");
+ PrepareBuilder();
result.hasMessageExtension = true;
result.messageExtension_ = builderForValue.Build();
return this;
}
public Builder MergeMessageExtension(global::Google.ProtocolBuffers.TestProtos.ForeignMessage value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
if (result.hasMessageExtension &&
result.messageExtension_ != global::Google.ProtocolBuffers.TestProtos.ForeignMessage.DefaultInstance) {
result.messageExtension_ = global::Google.ProtocolBuffers.TestProtos.ForeignMessage.CreateBuilder(result.messageExtension_).MergeFrom(value).BuildPartial();
@@ -18155,6 +19718,7 @@ namespace Google.ProtocolBuffers.TestProtos { return this;
}
public Builder ClearMessageExtension() {
+ PrepareBuilder();
result.hasMessageExtension = false;
result.messageExtension_ = global::Google.ProtocolBuffers.TestProtos.ForeignMessage.DefaultInstance;
return this;
@@ -18169,18 +19733,21 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetDynamicMessageExtension(global::Google.ProtocolBuffers.TestProtos.TestDynamicExtensions.Types.DynamicMessageType value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.hasDynamicMessageExtension = true;
result.dynamicMessageExtension_ = value;
return this;
}
public Builder SetDynamicMessageExtension(global::Google.ProtocolBuffers.TestProtos.TestDynamicExtensions.Types.DynamicMessageType.Builder builderForValue) {
pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue");
+ PrepareBuilder();
result.hasDynamicMessageExtension = true;
result.dynamicMessageExtension_ = builderForValue.Build();
return this;
}
public Builder MergeDynamicMessageExtension(global::Google.ProtocolBuffers.TestProtos.TestDynamicExtensions.Types.DynamicMessageType value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
if (result.hasDynamicMessageExtension &&
result.dynamicMessageExtension_ != global::Google.ProtocolBuffers.TestProtos.TestDynamicExtensions.Types.DynamicMessageType.DefaultInstance) {
result.dynamicMessageExtension_ = global::Google.ProtocolBuffers.TestProtos.TestDynamicExtensions.Types.DynamicMessageType.CreateBuilder(result.dynamicMessageExtension_).MergeFrom(value).BuildPartial();
@@ -18191,13 +19758,14 @@ namespace Google.ProtocolBuffers.TestProtos { return this;
}
public Builder ClearDynamicMessageExtension() {
+ PrepareBuilder();
result.hasDynamicMessageExtension = false;
result.dynamicMessageExtension_ = global::Google.ProtocolBuffers.TestProtos.TestDynamicExtensions.Types.DynamicMessageType.DefaultInstance;
return this;
}
public pbc::IPopsicleList<string> RepeatedExtensionList {
- get { return result.repeatedExtension_; }
+ get { return PrepareBuilder().repeatedExtension_; }
}
public int RepeatedExtensionCount {
get { return result.RepeatedExtensionCount; }
@@ -18207,25 +19775,29 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetRepeatedExtension(int index, string value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.repeatedExtension_[index] = value;
return this;
}
public Builder AddRepeatedExtension(string value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.repeatedExtension_.Add(value);
return this;
}
public Builder AddRangeRepeatedExtension(scg::IEnumerable<string> values) {
+ PrepareBuilder();
base.AddRange(values, result.repeatedExtension_);
return this;
}
public Builder ClearRepeatedExtension() {
+ PrepareBuilder();
result.repeatedExtension_.Clear();
return this;
}
public pbc::IPopsicleList<int> PackedExtensionList {
- get { return result.packedExtension_; }
+ get { return PrepareBuilder().packedExtension_; }
}
public int PackedExtensionCount {
get { return result.PackedExtensionCount; }
@@ -18234,18 +19806,22 @@ namespace Google.ProtocolBuffers.TestProtos { return result.GetPackedExtension(index);
}
public Builder SetPackedExtension(int index, int value) {
+ PrepareBuilder();
result.packedExtension_[index] = value;
return this;
}
public Builder AddPackedExtension(int value) {
+ PrepareBuilder();
result.packedExtension_.Add(value);
return this;
}
public Builder AddRangePackedExtension(scg::IEnumerable<int> values) {
+ PrepareBuilder();
base.AddRange(values, result.packedExtension_);
return this;
}
public Builder ClearPackedExtension() {
+ PrepareBuilder();
result.packedExtension_.Clear();
return this;
}
@@ -18479,7 +20055,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(TestRepeatedScalarDifferentTagSizes prototype) {
- return (Builder) new Builder().MergeFrom(prototype);
+ return new Builder(prototype);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -18489,21 +20065,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder {
get { return this; }
}
- public Builder() {}
+ public Builder() {
+ result = DefaultInstance ?? new TestRepeatedScalarDifferentTagSizes();
+ builderIsReadOnly = result == DefaultInstance;
+ }
+ internal Builder(TestRepeatedScalarDifferentTagSizes cloneFrom) {
+ result = cloneFrom;
+ builderIsReadOnly = true;
+ }
+
+ bool builderIsReadOnly;
+ TestRepeatedScalarDifferentTagSizes result;
+
+ private TestRepeatedScalarDifferentTagSizes PrepareBuilder() {
+ if (builderIsReadOnly) {
+ TestRepeatedScalarDifferentTagSizes original = result;
+ result = new TestRepeatedScalarDifferentTagSizes();
+ builderIsReadOnly = false;
+ MergeFrom(original);
+ }
+ return result;
+ }
- TestRepeatedScalarDifferentTagSizes result = new TestRepeatedScalarDifferentTagSizes();
+ public override bool IsInitialized {
+ get { return result.IsInitialized; }
+ }
protected override TestRepeatedScalarDifferentTagSizes MessageBeingBuilt {
- get { return result; }
+ get { return PrepareBuilder(); }
}
public override Builder Clear() {
- result = new TestRepeatedScalarDifferentTagSizes();
+ result = DefaultInstance ?? new TestRepeatedScalarDifferentTagSizes();
+ builderIsReadOnly = true;
return this;
}
public override Builder Clone() {
- return new Builder().MergeFrom(result);
+ if (builderIsReadOnly) {
+ return new Builder(result);
+ } else {
+ return new Builder().MergeFrom(result);
+ }
}
public override pbd::MessageDescriptor DescriptorForType {
@@ -18515,8 +20118,8 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override TestRepeatedScalarDifferentTagSizes BuildPartial() {
- if (result == null) {
- throw new global::System.InvalidOperationException("build() has already been called on this Builder");
+ if (builderIsReadOnly) {
+ return result;
}
result.repeatedFixed32_.MakeReadOnly();
result.repeatedInt32_.MakeReadOnly();
@@ -18524,9 +20127,8 @@ namespace Google.ProtocolBuffers.TestProtos { result.repeatedInt64_.MakeReadOnly();
result.repeatedFloat_.MakeReadOnly();
result.repeatedUint64_.MakeReadOnly();
- TestRepeatedScalarDifferentTagSizes returnMe = result;
- result = null;
- return returnMe;
+ builderIsReadOnly = true;
+ return result;
}
public override Builder MergeFrom(pb::IMessage other) {
@@ -18540,6 +20142,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder MergeFrom(TestRepeatedScalarDifferentTagSizes other) {
if (other == global::Google.ProtocolBuffers.TestProtos.TestRepeatedScalarDifferentTagSizes.DefaultInstance) return this;
+ PrepareBuilder();
if (other.repeatedFixed32_.Count != 0) {
base.AddRange(other.repeatedFixed32_, result.repeatedFixed32_);
}
@@ -18567,6 +20170,7 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
+ PrepareBuilder();
pb::UnknownFieldSet.Builder unknownFields = null;
uint tag;
string field_name;
@@ -18642,7 +20246,7 @@ namespace Google.ProtocolBuffers.TestProtos { [global::System.CLSCompliant(false)]
public pbc::IPopsicleList<uint> RepeatedFixed32List {
- get { return result.repeatedFixed32_; }
+ get { return PrepareBuilder().repeatedFixed32_; }
}
public int RepeatedFixed32Count {
get { return result.RepeatedFixed32Count; }
@@ -18653,26 +20257,30 @@ namespace Google.ProtocolBuffers.TestProtos { }
[global::System.CLSCompliant(false)]
public Builder SetRepeatedFixed32(int index, uint value) {
+ PrepareBuilder();
result.repeatedFixed32_[index] = value;
return this;
}
[global::System.CLSCompliant(false)]
public Builder AddRepeatedFixed32(uint value) {
+ PrepareBuilder();
result.repeatedFixed32_.Add(value);
return this;
}
[global::System.CLSCompliant(false)]
public Builder AddRangeRepeatedFixed32(scg::IEnumerable<uint> values) {
+ PrepareBuilder();
base.AddRange(values, result.repeatedFixed32_);
return this;
}
public Builder ClearRepeatedFixed32() {
+ PrepareBuilder();
result.repeatedFixed32_.Clear();
return this;
}
public pbc::IPopsicleList<int> RepeatedInt32List {
- get { return result.repeatedInt32_; }
+ get { return PrepareBuilder().repeatedInt32_; }
}
public int RepeatedInt32Count {
get { return result.RepeatedInt32Count; }
@@ -18681,25 +20289,29 @@ namespace Google.ProtocolBuffers.TestProtos { return result.GetRepeatedInt32(index);
}
public Builder SetRepeatedInt32(int index, int value) {
+ PrepareBuilder();
result.repeatedInt32_[index] = value;
return this;
}
public Builder AddRepeatedInt32(int value) {
+ PrepareBuilder();
result.repeatedInt32_.Add(value);
return this;
}
public Builder AddRangeRepeatedInt32(scg::IEnumerable<int> values) {
+ PrepareBuilder();
base.AddRange(values, result.repeatedInt32_);
return this;
}
public Builder ClearRepeatedInt32() {
+ PrepareBuilder();
result.repeatedInt32_.Clear();
return this;
}
[global::System.CLSCompliant(false)]
public pbc::IPopsicleList<ulong> RepeatedFixed64List {
- get { return result.repeatedFixed64_; }
+ get { return PrepareBuilder().repeatedFixed64_; }
}
public int RepeatedFixed64Count {
get { return result.RepeatedFixed64Count; }
@@ -18710,26 +20322,30 @@ namespace Google.ProtocolBuffers.TestProtos { }
[global::System.CLSCompliant(false)]
public Builder SetRepeatedFixed64(int index, ulong value) {
+ PrepareBuilder();
result.repeatedFixed64_[index] = value;
return this;
}
[global::System.CLSCompliant(false)]
public Builder AddRepeatedFixed64(ulong value) {
+ PrepareBuilder();
result.repeatedFixed64_.Add(value);
return this;
}
[global::System.CLSCompliant(false)]
public Builder AddRangeRepeatedFixed64(scg::IEnumerable<ulong> values) {
+ PrepareBuilder();
base.AddRange(values, result.repeatedFixed64_);
return this;
}
public Builder ClearRepeatedFixed64() {
+ PrepareBuilder();
result.repeatedFixed64_.Clear();
return this;
}
public pbc::IPopsicleList<long> RepeatedInt64List {
- get { return result.repeatedInt64_; }
+ get { return PrepareBuilder().repeatedInt64_; }
}
public int RepeatedInt64Count {
get { return result.RepeatedInt64Count; }
@@ -18738,24 +20354,28 @@ namespace Google.ProtocolBuffers.TestProtos { return result.GetRepeatedInt64(index);
}
public Builder SetRepeatedInt64(int index, long value) {
+ PrepareBuilder();
result.repeatedInt64_[index] = value;
return this;
}
public Builder AddRepeatedInt64(long value) {
+ PrepareBuilder();
result.repeatedInt64_.Add(value);
return this;
}
public Builder AddRangeRepeatedInt64(scg::IEnumerable<long> values) {
+ PrepareBuilder();
base.AddRange(values, result.repeatedInt64_);
return this;
}
public Builder ClearRepeatedInt64() {
+ PrepareBuilder();
result.repeatedInt64_.Clear();
return this;
}
public pbc::IPopsicleList<float> RepeatedFloatList {
- get { return result.repeatedFloat_; }
+ get { return PrepareBuilder().repeatedFloat_; }
}
public int RepeatedFloatCount {
get { return result.RepeatedFloatCount; }
@@ -18764,25 +20384,29 @@ namespace Google.ProtocolBuffers.TestProtos { return result.GetRepeatedFloat(index);
}
public Builder SetRepeatedFloat(int index, float value) {
+ PrepareBuilder();
result.repeatedFloat_[index] = value;
return this;
}
public Builder AddRepeatedFloat(float value) {
+ PrepareBuilder();
result.repeatedFloat_.Add(value);
return this;
}
public Builder AddRangeRepeatedFloat(scg::IEnumerable<float> values) {
+ PrepareBuilder();
base.AddRange(values, result.repeatedFloat_);
return this;
}
public Builder ClearRepeatedFloat() {
+ PrepareBuilder();
result.repeatedFloat_.Clear();
return this;
}
[global::System.CLSCompliant(false)]
public pbc::IPopsicleList<ulong> RepeatedUint64List {
- get { return result.repeatedUint64_; }
+ get { return PrepareBuilder().repeatedUint64_; }
}
public int RepeatedUint64Count {
get { return result.RepeatedUint64Count; }
@@ -18793,20 +20417,24 @@ namespace Google.ProtocolBuffers.TestProtos { }
[global::System.CLSCompliant(false)]
public Builder SetRepeatedUint64(int index, ulong value) {
+ PrepareBuilder();
result.repeatedUint64_[index] = value;
return this;
}
[global::System.CLSCompliant(false)]
public Builder AddRepeatedUint64(ulong value) {
+ PrepareBuilder();
result.repeatedUint64_.Add(value);
return this;
}
[global::System.CLSCompliant(false)]
public Builder AddRangeRepeatedUint64(scg::IEnumerable<ulong> values) {
+ PrepareBuilder();
base.AddRange(values, result.repeatedUint64_);
return this;
}
public Builder ClearRepeatedUint64() {
+ PrepareBuilder();
result.repeatedUint64_.Clear();
return this;
}
@@ -18902,7 +20530,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(FooRequest prototype) {
- return (Builder) new Builder().MergeFrom(prototype);
+ return new Builder(prototype);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -18912,21 +20540,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder {
get { return this; }
}
- public Builder() {}
+ public Builder() {
+ result = DefaultInstance ?? new FooRequest();
+ builderIsReadOnly = result == DefaultInstance;
+ }
+ internal Builder(FooRequest cloneFrom) {
+ result = cloneFrom;
+ builderIsReadOnly = true;
+ }
- FooRequest result = new FooRequest();
+ bool builderIsReadOnly;
+ FooRequest result;
+
+ private FooRequest PrepareBuilder() {
+ if (builderIsReadOnly) {
+ FooRequest original = result;
+ result = new FooRequest();
+ builderIsReadOnly = false;
+ MergeFrom(original);
+ }
+ return result;
+ }
+
+ public override bool IsInitialized {
+ get { return result.IsInitialized; }
+ }
protected override FooRequest MessageBeingBuilt {
- get { return result; }
+ get { return PrepareBuilder(); }
}
public override Builder Clear() {
- result = new FooRequest();
+ result = DefaultInstance ?? new FooRequest();
+ builderIsReadOnly = true;
return this;
}
public override Builder Clone() {
- return new Builder().MergeFrom(result);
+ if (builderIsReadOnly) {
+ return new Builder(result);
+ } else {
+ return new Builder().MergeFrom(result);
+ }
}
public override pbd::MessageDescriptor DescriptorForType {
@@ -18938,12 +20593,11 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override FooRequest BuildPartial() {
- if (result == null) {
- throw new global::System.InvalidOperationException("build() has already been called on this Builder");
+ if (builderIsReadOnly) {
+ return result;
}
- FooRequest returnMe = result;
- result = null;
- return returnMe;
+ builderIsReadOnly = true;
+ return result;
}
public override Builder MergeFrom(pb::IMessage other) {
@@ -18957,6 +20611,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder MergeFrom(FooRequest other) {
if (other == global::Google.ProtocolBuffers.TestProtos.FooRequest.DefaultInstance) return this;
+ PrepareBuilder();
this.MergeUnknownFields(other.UnknownFields);
return this;
}
@@ -18966,6 +20621,7 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
+ PrepareBuilder();
pb::UnknownFieldSet.Builder unknownFields = null;
uint tag;
string field_name;
@@ -19100,7 +20756,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(FooResponse prototype) {
- return (Builder) new Builder().MergeFrom(prototype);
+ return new Builder(prototype);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -19110,21 +20766,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder {
get { return this; }
}
- public Builder() {}
+ public Builder() {
+ result = DefaultInstance ?? new FooResponse();
+ builderIsReadOnly = result == DefaultInstance;
+ }
+ internal Builder(FooResponse cloneFrom) {
+ result = cloneFrom;
+ builderIsReadOnly = true;
+ }
+
+ bool builderIsReadOnly;
+ FooResponse result;
+
+ private FooResponse PrepareBuilder() {
+ if (builderIsReadOnly) {
+ FooResponse original = result;
+ result = new FooResponse();
+ builderIsReadOnly = false;
+ MergeFrom(original);
+ }
+ return result;
+ }
- FooResponse result = new FooResponse();
+ public override bool IsInitialized {
+ get { return result.IsInitialized; }
+ }
protected override FooResponse MessageBeingBuilt {
- get { return result; }
+ get { return PrepareBuilder(); }
}
public override Builder Clear() {
- result = new FooResponse();
+ result = DefaultInstance ?? new FooResponse();
+ builderIsReadOnly = true;
return this;
}
public override Builder Clone() {
- return new Builder().MergeFrom(result);
+ if (builderIsReadOnly) {
+ return new Builder(result);
+ } else {
+ return new Builder().MergeFrom(result);
+ }
}
public override pbd::MessageDescriptor DescriptorForType {
@@ -19136,12 +20819,11 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override FooResponse BuildPartial() {
- if (result == null) {
- throw new global::System.InvalidOperationException("build() has already been called on this Builder");
+ if (builderIsReadOnly) {
+ return result;
}
- FooResponse returnMe = result;
- result = null;
- return returnMe;
+ builderIsReadOnly = true;
+ return result;
}
public override Builder MergeFrom(pb::IMessage other) {
@@ -19155,6 +20837,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder MergeFrom(FooResponse other) {
if (other == global::Google.ProtocolBuffers.TestProtos.FooResponse.DefaultInstance) return this;
+ PrepareBuilder();
this.MergeUnknownFields(other.UnknownFields);
return this;
}
@@ -19164,6 +20847,7 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
+ PrepareBuilder();
pb::UnknownFieldSet.Builder unknownFields = null;
uint tag;
string field_name;
@@ -19298,7 +20982,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(BarRequest prototype) {
- return (Builder) new Builder().MergeFrom(prototype);
+ return new Builder(prototype);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -19308,21 +20992,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder {
get { return this; }
}
- public Builder() {}
+ public Builder() {
+ result = DefaultInstance ?? new BarRequest();
+ builderIsReadOnly = result == DefaultInstance;
+ }
+ internal Builder(BarRequest cloneFrom) {
+ result = cloneFrom;
+ builderIsReadOnly = true;
+ }
+
+ bool builderIsReadOnly;
+ BarRequest result;
+
+ private BarRequest PrepareBuilder() {
+ if (builderIsReadOnly) {
+ BarRequest original = result;
+ result = new BarRequest();
+ builderIsReadOnly = false;
+ MergeFrom(original);
+ }
+ return result;
+ }
- BarRequest result = new BarRequest();
+ public override bool IsInitialized {
+ get { return result.IsInitialized; }
+ }
protected override BarRequest MessageBeingBuilt {
- get { return result; }
+ get { return PrepareBuilder(); }
}
public override Builder Clear() {
- result = new BarRequest();
+ result = DefaultInstance ?? new BarRequest();
+ builderIsReadOnly = true;
return this;
}
public override Builder Clone() {
- return new Builder().MergeFrom(result);
+ if (builderIsReadOnly) {
+ return new Builder(result);
+ } else {
+ return new Builder().MergeFrom(result);
+ }
}
public override pbd::MessageDescriptor DescriptorForType {
@@ -19334,12 +21045,11 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override BarRequest BuildPartial() {
- if (result == null) {
- throw new global::System.InvalidOperationException("build() has already been called on this Builder");
+ if (builderIsReadOnly) {
+ return result;
}
- BarRequest returnMe = result;
- result = null;
- return returnMe;
+ builderIsReadOnly = true;
+ return result;
}
public override Builder MergeFrom(pb::IMessage other) {
@@ -19353,6 +21063,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder MergeFrom(BarRequest other) {
if (other == global::Google.ProtocolBuffers.TestProtos.BarRequest.DefaultInstance) return this;
+ PrepareBuilder();
this.MergeUnknownFields(other.UnknownFields);
return this;
}
@@ -19362,6 +21073,7 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
+ PrepareBuilder();
pb::UnknownFieldSet.Builder unknownFields = null;
uint tag;
string field_name;
@@ -19496,7 +21208,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(BarResponse prototype) {
- return (Builder) new Builder().MergeFrom(prototype);
+ return new Builder(prototype);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -19506,21 +21218,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder {
get { return this; }
}
- public Builder() {}
+ public Builder() {
+ result = DefaultInstance ?? new BarResponse();
+ builderIsReadOnly = result == DefaultInstance;
+ }
+ internal Builder(BarResponse cloneFrom) {
+ result = cloneFrom;
+ builderIsReadOnly = true;
+ }
- BarResponse result = new BarResponse();
+ bool builderIsReadOnly;
+ BarResponse result;
+
+ private BarResponse PrepareBuilder() {
+ if (builderIsReadOnly) {
+ BarResponse original = result;
+ result = new BarResponse();
+ builderIsReadOnly = false;
+ MergeFrom(original);
+ }
+ return result;
+ }
+
+ public override bool IsInitialized {
+ get { return result.IsInitialized; }
+ }
protected override BarResponse MessageBeingBuilt {
- get { return result; }
+ get { return PrepareBuilder(); }
}
public override Builder Clear() {
- result = new BarResponse();
+ result = DefaultInstance ?? new BarResponse();
+ builderIsReadOnly = true;
return this;
}
public override Builder Clone() {
- return new Builder().MergeFrom(result);
+ if (builderIsReadOnly) {
+ return new Builder(result);
+ } else {
+ return new Builder().MergeFrom(result);
+ }
}
public override pbd::MessageDescriptor DescriptorForType {
@@ -19532,12 +21271,11 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override BarResponse BuildPartial() {
- if (result == null) {
- throw new global::System.InvalidOperationException("build() has already been called on this Builder");
+ if (builderIsReadOnly) {
+ return result;
}
- BarResponse returnMe = result;
- result = null;
- return returnMe;
+ builderIsReadOnly = true;
+ return result;
}
public override Builder MergeFrom(pb::IMessage other) {
@@ -19551,6 +21289,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder MergeFrom(BarResponse other) {
if (other == global::Google.ProtocolBuffers.TestProtos.BarResponse.DefaultInstance) return this;
+ PrepareBuilder();
this.MergeUnknownFields(other.UnknownFields);
return this;
}
@@ -19560,6 +21299,7 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
+ PrepareBuilder();
pb::UnknownFieldSet.Builder unknownFields = null;
uint tag;
string field_name;
diff --git a/src/ProtocolBuffers.Test/TestProtos/UnitTestRpcInterop.cs b/src/ProtocolBuffers.Test/TestProtos/UnitTestRpcInterop.cs index ae309fa7..3c5e9307 100644 --- a/src/ProtocolBuffers.Test/TestProtos/UnitTestRpcInterop.cs +++ b/src/ProtocolBuffers.Test/TestProtos/UnitTestRpcInterop.cs @@ -188,7 +188,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(SearchRequest prototype) {
- return (Builder) new Builder().MergeFrom(prototype);
+ return new Builder(prototype);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -198,21 +198,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder {
get { return this; }
}
- public Builder() {}
+ public Builder() {
+ result = DefaultInstance ?? new SearchRequest();
+ builderIsReadOnly = result == DefaultInstance;
+ }
+ internal Builder(SearchRequest cloneFrom) {
+ result = cloneFrom;
+ builderIsReadOnly = true;
+ }
+
+ bool builderIsReadOnly;
+ SearchRequest result;
- SearchRequest result = new SearchRequest();
+ private SearchRequest PrepareBuilder() {
+ if (builderIsReadOnly) {
+ SearchRequest original = result;
+ result = new SearchRequest();
+ builderIsReadOnly = false;
+ MergeFrom(original);
+ }
+ return result;
+ }
+
+ public override bool IsInitialized {
+ get { return result.IsInitialized; }
+ }
protected override SearchRequest MessageBeingBuilt {
- get { return result; }
+ get { return PrepareBuilder(); }
}
public override Builder Clear() {
- result = new SearchRequest();
+ result = DefaultInstance ?? new SearchRequest();
+ builderIsReadOnly = true;
return this;
}
public override Builder Clone() {
- return new Builder().MergeFrom(result);
+ if (builderIsReadOnly) {
+ return new Builder(result);
+ } else {
+ return new Builder().MergeFrom(result);
+ }
}
public override pbd::MessageDescriptor DescriptorForType {
@@ -224,13 +251,12 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override SearchRequest BuildPartial() {
- if (result == null) {
- throw new global::System.InvalidOperationException("build() has already been called on this Builder");
+ if (builderIsReadOnly) {
+ return result;
}
result.criteria_.MakeReadOnly();
- SearchRequest returnMe = result;
- result = null;
- return returnMe;
+ builderIsReadOnly = true;
+ return result;
}
public override Builder MergeFrom(pb::IMessage other) {
@@ -244,6 +270,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder MergeFrom(SearchRequest other) {
if (other == global::Google.ProtocolBuffers.TestProtos.SearchRequest.DefaultInstance) return this;
+ PrepareBuilder();
if (other.criteria_.Count != 0) {
base.AddRange(other.criteria_, result.criteria_);
}
@@ -256,6 +283,7 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
+ PrepareBuilder();
pb::UnknownFieldSet.Builder unknownFields = null;
uint tag;
string field_name;
@@ -304,7 +332,7 @@ namespace Google.ProtocolBuffers.TestProtos { public pbc::IPopsicleList<string> CriteriaList {
- get { return result.criteria_; }
+ get { return PrepareBuilder().criteria_; }
}
public int CriteriaCount {
get { return result.CriteriaCount; }
@@ -314,19 +342,23 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetCriteria(int index, string value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.criteria_[index] = value;
return this;
}
public Builder AddCriteria(string value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.criteria_.Add(value);
return this;
}
public Builder AddRangeCriteria(scg::IEnumerable<string> values) {
+ PrepareBuilder();
base.AddRange(values, result.criteria_);
return this;
}
public Builder ClearCriteria() {
+ PrepareBuilder();
result.criteria_.Clear();
return this;
}
@@ -487,7 +519,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(ResultItem prototype) {
- return (Builder) new Builder().MergeFrom(prototype);
+ return new Builder(prototype);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -497,21 +529,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder {
get { return this; }
}
- public Builder() {}
+ public Builder() {
+ result = DefaultInstance ?? new ResultItem();
+ builderIsReadOnly = result == DefaultInstance;
+ }
+ internal Builder(ResultItem cloneFrom) {
+ result = cloneFrom;
+ builderIsReadOnly = true;
+ }
+
+ bool builderIsReadOnly;
+ ResultItem result;
- ResultItem result = new ResultItem();
+ private ResultItem PrepareBuilder() {
+ if (builderIsReadOnly) {
+ ResultItem original = result;
+ result = new ResultItem();
+ builderIsReadOnly = false;
+ MergeFrom(original);
+ }
+ return result;
+ }
+
+ public override bool IsInitialized {
+ get { return result.IsInitialized; }
+ }
protected override ResultItem MessageBeingBuilt {
- get { return result; }
+ get { return PrepareBuilder(); }
}
public override Builder Clear() {
- result = new ResultItem();
+ result = DefaultInstance ?? new ResultItem();
+ builderIsReadOnly = true;
return this;
}
public override Builder Clone() {
- return new Builder().MergeFrom(result);
+ if (builderIsReadOnly) {
+ return new Builder(result);
+ } else {
+ return new Builder().MergeFrom(result);
+ }
}
public override pbd::MessageDescriptor DescriptorForType {
@@ -523,12 +582,11 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override ResultItem BuildPartial() {
- if (result == null) {
- throw new global::System.InvalidOperationException("build() has already been called on this Builder");
+ if (builderIsReadOnly) {
+ return result;
}
- ResultItem returnMe = result;
- result = null;
- return returnMe;
+ builderIsReadOnly = true;
+ return result;
}
public override Builder MergeFrom(pb::IMessage other) {
@@ -542,6 +600,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder MergeFrom(ResultItem other) {
if (other == global::Google.ProtocolBuffers.TestProtos.SearchResponse.Types.ResultItem.DefaultInstance) return this;
+ PrepareBuilder();
if (other.HasUrl) {
Url = other.Url;
}
@@ -557,6 +616,7 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
+ PrepareBuilder();
pb::UnknownFieldSet.Builder unknownFields = null;
uint tag;
string field_name;
@@ -617,11 +677,13 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetUrl(string value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.hasUrl = true;
result.url_ = value;
return this;
}
public Builder ClearUrl() {
+ PrepareBuilder();
result.hasUrl = false;
result.url_ = "";
return this;
@@ -636,11 +698,13 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetName(string value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.hasName = true;
result.name_ = value;
return this;
}
public Builder ClearName() {
+ PrepareBuilder();
result.hasName = false;
result.name_ = "";
return this;
@@ -734,7 +798,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(SearchResponse prototype) {
- return (Builder) new Builder().MergeFrom(prototype);
+ return new Builder(prototype);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -744,21 +808,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder {
get { return this; }
}
- public Builder() {}
+ public Builder() {
+ result = DefaultInstance ?? new SearchResponse();
+ builderIsReadOnly = result == DefaultInstance;
+ }
+ internal Builder(SearchResponse cloneFrom) {
+ result = cloneFrom;
+ builderIsReadOnly = true;
+ }
+
+ bool builderIsReadOnly;
+ SearchResponse result;
- SearchResponse result = new SearchResponse();
+ private SearchResponse PrepareBuilder() {
+ if (builderIsReadOnly) {
+ SearchResponse original = result;
+ result = new SearchResponse();
+ builderIsReadOnly = false;
+ MergeFrom(original);
+ }
+ return result;
+ }
+
+ public override bool IsInitialized {
+ get { return result.IsInitialized; }
+ }
protected override SearchResponse MessageBeingBuilt {
- get { return result; }
+ get { return PrepareBuilder(); }
}
public override Builder Clear() {
- result = new SearchResponse();
+ result = DefaultInstance ?? new SearchResponse();
+ builderIsReadOnly = true;
return this;
}
public override Builder Clone() {
- return new Builder().MergeFrom(result);
+ if (builderIsReadOnly) {
+ return new Builder(result);
+ } else {
+ return new Builder().MergeFrom(result);
+ }
}
public override pbd::MessageDescriptor DescriptorForType {
@@ -770,13 +861,12 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override SearchResponse BuildPartial() {
- if (result == null) {
- throw new global::System.InvalidOperationException("build() has already been called on this Builder");
+ if (builderIsReadOnly) {
+ return result;
}
result.results_.MakeReadOnly();
- SearchResponse returnMe = result;
- result = null;
- return returnMe;
+ builderIsReadOnly = true;
+ return result;
}
public override Builder MergeFrom(pb::IMessage other) {
@@ -790,6 +880,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder MergeFrom(SearchResponse other) {
if (other == global::Google.ProtocolBuffers.TestProtos.SearchResponse.DefaultInstance) return this;
+ PrepareBuilder();
if (other.results_.Count != 0) {
base.AddRange(other.results_, result.results_);
}
@@ -802,6 +893,7 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
+ PrepareBuilder();
pb::UnknownFieldSet.Builder unknownFields = null;
uint tag;
string field_name;
@@ -850,7 +942,7 @@ namespace Google.ProtocolBuffers.TestProtos { public pbc::IPopsicleList<global::Google.ProtocolBuffers.TestProtos.SearchResponse.Types.ResultItem> ResultsList {
- get { return result.results_; }
+ get { return PrepareBuilder().results_; }
}
public int ResultsCount {
get { return result.ResultsCount; }
@@ -860,29 +952,35 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetResults(int index, global::Google.ProtocolBuffers.TestProtos.SearchResponse.Types.ResultItem value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.results_[index] = value;
return this;
}
public Builder SetResults(int index, global::Google.ProtocolBuffers.TestProtos.SearchResponse.Types.ResultItem.Builder builderForValue) {
pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue");
+ PrepareBuilder();
result.results_[index] = builderForValue.Build();
return this;
}
public Builder AddResults(global::Google.ProtocolBuffers.TestProtos.SearchResponse.Types.ResultItem value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.results_.Add(value);
return this;
}
public Builder AddResults(global::Google.ProtocolBuffers.TestProtos.SearchResponse.Types.ResultItem.Builder builderForValue) {
pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue");
+ PrepareBuilder();
result.results_.Add(builderForValue.Build());
return this;
}
public Builder AddRangeResults(scg::IEnumerable<global::Google.ProtocolBuffers.TestProtos.SearchResponse.Types.ResultItem> values) {
+ PrepareBuilder();
base.AddRange(values, result.results_);
return this;
}
public Builder ClearResults() {
+ PrepareBuilder();
result.results_.Clear();
return this;
}
@@ -1019,7 +1117,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(RefineSearchRequest prototype) {
- return (Builder) new Builder().MergeFrom(prototype);
+ return new Builder(prototype);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -1029,21 +1127,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder {
get { return this; }
}
- public Builder() {}
+ public Builder() {
+ result = DefaultInstance ?? new RefineSearchRequest();
+ builderIsReadOnly = result == DefaultInstance;
+ }
+ internal Builder(RefineSearchRequest cloneFrom) {
+ result = cloneFrom;
+ builderIsReadOnly = true;
+ }
+
+ bool builderIsReadOnly;
+ RefineSearchRequest result;
- RefineSearchRequest result = new RefineSearchRequest();
+ private RefineSearchRequest PrepareBuilder() {
+ if (builderIsReadOnly) {
+ RefineSearchRequest original = result;
+ result = new RefineSearchRequest();
+ builderIsReadOnly = false;
+ MergeFrom(original);
+ }
+ return result;
+ }
+
+ public override bool IsInitialized {
+ get { return result.IsInitialized; }
+ }
protected override RefineSearchRequest MessageBeingBuilt {
- get { return result; }
+ get { return PrepareBuilder(); }
}
public override Builder Clear() {
- result = new RefineSearchRequest();
+ result = DefaultInstance ?? new RefineSearchRequest();
+ builderIsReadOnly = true;
return this;
}
public override Builder Clone() {
- return new Builder().MergeFrom(result);
+ if (builderIsReadOnly) {
+ return new Builder(result);
+ } else {
+ return new Builder().MergeFrom(result);
+ }
}
public override pbd::MessageDescriptor DescriptorForType {
@@ -1055,13 +1180,12 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override RefineSearchRequest BuildPartial() {
- if (result == null) {
- throw new global::System.InvalidOperationException("build() has already been called on this Builder");
+ if (builderIsReadOnly) {
+ return result;
}
result.criteria_.MakeReadOnly();
- RefineSearchRequest returnMe = result;
- result = null;
- return returnMe;
+ builderIsReadOnly = true;
+ return result;
}
public override Builder MergeFrom(pb::IMessage other) {
@@ -1075,6 +1199,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder MergeFrom(RefineSearchRequest other) {
if (other == global::Google.ProtocolBuffers.TestProtos.RefineSearchRequest.DefaultInstance) return this;
+ PrepareBuilder();
if (other.criteria_.Count != 0) {
base.AddRange(other.criteria_, result.criteria_);
}
@@ -1090,6 +1215,7 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
+ PrepareBuilder();
pb::UnknownFieldSet.Builder unknownFields = null;
uint tag;
string field_name;
@@ -1147,7 +1273,7 @@ namespace Google.ProtocolBuffers.TestProtos { public pbc::IPopsicleList<string> CriteriaList {
- get { return result.criteria_; }
+ get { return PrepareBuilder().criteria_; }
}
public int CriteriaCount {
get { return result.CriteriaCount; }
@@ -1157,19 +1283,23 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetCriteria(int index, string value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.criteria_[index] = value;
return this;
}
public Builder AddCriteria(string value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.criteria_.Add(value);
return this;
}
public Builder AddRangeCriteria(scg::IEnumerable<string> values) {
+ PrepareBuilder();
base.AddRange(values, result.criteria_);
return this;
}
public Builder ClearCriteria() {
+ PrepareBuilder();
result.criteria_.Clear();
return this;
}
@@ -1183,18 +1313,21 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetPreviousResults(global::Google.ProtocolBuffers.TestProtos.SearchResponse value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.hasPreviousResults = true;
result.previousResults_ = value;
return this;
}
public Builder SetPreviousResults(global::Google.ProtocolBuffers.TestProtos.SearchResponse.Builder builderForValue) {
pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue");
+ PrepareBuilder();
result.hasPreviousResults = true;
result.previousResults_ = builderForValue.Build();
return this;
}
public Builder MergePreviousResults(global::Google.ProtocolBuffers.TestProtos.SearchResponse value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
if (result.hasPreviousResults &&
result.previousResults_ != global::Google.ProtocolBuffers.TestProtos.SearchResponse.DefaultInstance) {
result.previousResults_ = global::Google.ProtocolBuffers.TestProtos.SearchResponse.CreateBuilder(result.previousResults_).MergeFrom(value).BuildPartial();
@@ -1205,6 +1338,7 @@ namespace Google.ProtocolBuffers.TestProtos { return this;
}
public Builder ClearPreviousResults() {
+ PrepareBuilder();
result.hasPreviousResults = false;
result.previousResults_ = global::Google.ProtocolBuffers.TestProtos.SearchResponse.DefaultInstance;
return this;
diff --git a/src/ProtocolBuffers.Test/TestProtos/UnitTestXmlSerializerTestProtoFile.cs b/src/ProtocolBuffers.Test/TestProtos/UnitTestXmlSerializerTestProtoFile.cs index 3d818a60..c0e53348 100644 --- a/src/ProtocolBuffers.Test/TestProtos/UnitTestXmlSerializerTestProtoFile.cs +++ b/src/ProtocolBuffers.Test/TestProtos/UnitTestXmlSerializerTestProtoFile.cs @@ -261,7 +261,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(TestXmlChild prototype) {
- return (Builder) new Builder().MergeFrom(prototype);
+ return new Builder(prototype);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -271,21 +271,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder {
get { return this; }
}
- public Builder() {}
+ public Builder() {
+ result = DefaultInstance ?? new TestXmlChild();
+ builderIsReadOnly = result == DefaultInstance;
+ }
+ internal Builder(TestXmlChild cloneFrom) {
+ result = cloneFrom;
+ builderIsReadOnly = true;
+ }
- TestXmlChild result = new TestXmlChild();
+ bool builderIsReadOnly;
+ TestXmlChild result;
+
+ private TestXmlChild PrepareBuilder() {
+ if (builderIsReadOnly) {
+ TestXmlChild original = result;
+ result = new TestXmlChild();
+ builderIsReadOnly = false;
+ MergeFrom(original);
+ }
+ return result;
+ }
+
+ public override bool IsInitialized {
+ get { return result.IsInitialized; }
+ }
protected override TestXmlChild MessageBeingBuilt {
- get { return result; }
+ get { return PrepareBuilder(); }
}
public override Builder Clear() {
- result = new TestXmlChild();
+ result = DefaultInstance ?? new TestXmlChild();
+ builderIsReadOnly = true;
return this;
}
public override Builder Clone() {
- return new Builder().MergeFrom(result);
+ if (builderIsReadOnly) {
+ return new Builder(result);
+ } else {
+ return new Builder().MergeFrom(result);
+ }
}
public override pbd::MessageDescriptor DescriptorForType {
@@ -297,13 +324,12 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override TestXmlChild BuildPartial() {
- if (result == null) {
- throw new global::System.InvalidOperationException("build() has already been called on this Builder");
+ if (builderIsReadOnly) {
+ return result;
}
result.options_.MakeReadOnly();
- TestXmlChild returnMe = result;
- result = null;
- return returnMe;
+ builderIsReadOnly = true;
+ return result;
}
public override Builder MergeFrom(pb::IMessage other) {
@@ -317,6 +343,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder MergeFrom(TestXmlChild other) {
if (other == global::Google.ProtocolBuffers.TestProtos.TestXmlChild.DefaultInstance) return this;
+ PrepareBuilder();
if (other.options_.Count != 0) {
base.AddRange(other.options_, result.options_);
}
@@ -332,6 +359,7 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
+ PrepareBuilder();
pb::UnknownFieldSet.Builder unknownFields = null;
uint tag;
string field_name;
@@ -394,7 +422,7 @@ namespace Google.ProtocolBuffers.TestProtos { public pbc::IPopsicleList<global::Google.ProtocolBuffers.TestProtos.EnumOptions> OptionsList {
- get { return result.options_; }
+ get { return PrepareBuilder().options_; }
}
public int OptionsCount {
get { return result.OptionsCount; }
@@ -403,18 +431,22 @@ namespace Google.ProtocolBuffers.TestProtos { return result.GetOptions(index);
}
public Builder SetOptions(int index, global::Google.ProtocolBuffers.TestProtos.EnumOptions value) {
+ PrepareBuilder();
result.options_[index] = value;
return this;
}
public Builder AddOptions(global::Google.ProtocolBuffers.TestProtos.EnumOptions value) {
+ PrepareBuilder();
result.options_.Add(value);
return this;
}
public Builder AddRangeOptions(scg::IEnumerable<global::Google.ProtocolBuffers.TestProtos.EnumOptions> values) {
+ PrepareBuilder();
base.AddRange(values, result.options_);
return this;
}
public Builder ClearOptions() {
+ PrepareBuilder();
result.options_.Clear();
return this;
}
@@ -428,11 +460,13 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetBinary(pb::ByteString value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.hasBinary = true;
result.binary_ = value;
return this;
}
public Builder ClearBinary() {
+ PrepareBuilder();
result.hasBinary = false;
result.binary_ = pb::ByteString.Empty;
return this;
@@ -529,7 +563,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(TestXmlNoFields prototype) {
- return (Builder) new Builder().MergeFrom(prototype);
+ return new Builder(prototype);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -539,21 +573,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder {
get { return this; }
}
- public Builder() {}
+ public Builder() {
+ result = DefaultInstance ?? new TestXmlNoFields();
+ builderIsReadOnly = result == DefaultInstance;
+ }
+ internal Builder(TestXmlNoFields cloneFrom) {
+ result = cloneFrom;
+ builderIsReadOnly = true;
+ }
- TestXmlNoFields result = new TestXmlNoFields();
+ bool builderIsReadOnly;
+ TestXmlNoFields result;
+
+ private TestXmlNoFields PrepareBuilder() {
+ if (builderIsReadOnly) {
+ TestXmlNoFields original = result;
+ result = new TestXmlNoFields();
+ builderIsReadOnly = false;
+ MergeFrom(original);
+ }
+ return result;
+ }
+
+ public override bool IsInitialized {
+ get { return result.IsInitialized; }
+ }
protected override TestXmlNoFields MessageBeingBuilt {
- get { return result; }
+ get { return PrepareBuilder(); }
}
public override Builder Clear() {
- result = new TestXmlNoFields();
+ result = DefaultInstance ?? new TestXmlNoFields();
+ builderIsReadOnly = true;
return this;
}
public override Builder Clone() {
- return new Builder().MergeFrom(result);
+ if (builderIsReadOnly) {
+ return new Builder(result);
+ } else {
+ return new Builder().MergeFrom(result);
+ }
}
public override pbd::MessageDescriptor DescriptorForType {
@@ -565,12 +626,11 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override TestXmlNoFields BuildPartial() {
- if (result == null) {
- throw new global::System.InvalidOperationException("build() has already been called on this Builder");
+ if (builderIsReadOnly) {
+ return result;
}
- TestXmlNoFields returnMe = result;
- result = null;
- return returnMe;
+ builderIsReadOnly = true;
+ return result;
}
public override Builder MergeFrom(pb::IMessage other) {
@@ -584,6 +644,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder MergeFrom(TestXmlNoFields other) {
if (other == global::Google.ProtocolBuffers.TestProtos.TestXmlNoFields.DefaultInstance) return this;
+ PrepareBuilder();
this.MergeUnknownFields(other.UnknownFields);
return this;
}
@@ -593,6 +654,7 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
+ PrepareBuilder();
pb::UnknownFieldSet.Builder unknownFields = null;
uint tag;
string field_name;
@@ -743,7 +805,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(TestXmlRescursive prototype) {
- return (Builder) new Builder().MergeFrom(prototype);
+ return new Builder(prototype);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -753,21 +815,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder {
get { return this; }
}
- public Builder() {}
+ public Builder() {
+ result = DefaultInstance ?? new TestXmlRescursive();
+ builderIsReadOnly = result == DefaultInstance;
+ }
+ internal Builder(TestXmlRescursive cloneFrom) {
+ result = cloneFrom;
+ builderIsReadOnly = true;
+ }
- TestXmlRescursive result = new TestXmlRescursive();
+ bool builderIsReadOnly;
+ TestXmlRescursive result;
+
+ private TestXmlRescursive PrepareBuilder() {
+ if (builderIsReadOnly) {
+ TestXmlRescursive original = result;
+ result = new TestXmlRescursive();
+ builderIsReadOnly = false;
+ MergeFrom(original);
+ }
+ return result;
+ }
+
+ public override bool IsInitialized {
+ get { return result.IsInitialized; }
+ }
protected override TestXmlRescursive MessageBeingBuilt {
- get { return result; }
+ get { return PrepareBuilder(); }
}
public override Builder Clear() {
- result = new TestXmlRescursive();
+ result = DefaultInstance ?? new TestXmlRescursive();
+ builderIsReadOnly = true;
return this;
}
public override Builder Clone() {
- return new Builder().MergeFrom(result);
+ if (builderIsReadOnly) {
+ return new Builder(result);
+ } else {
+ return new Builder().MergeFrom(result);
+ }
}
public override pbd::MessageDescriptor DescriptorForType {
@@ -779,12 +868,11 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override TestXmlRescursive BuildPartial() {
- if (result == null) {
- throw new global::System.InvalidOperationException("build() has already been called on this Builder");
+ if (builderIsReadOnly) {
+ return result;
}
- TestXmlRescursive returnMe = result;
- result = null;
- return returnMe;
+ builderIsReadOnly = true;
+ return result;
}
public override Builder MergeFrom(pb::IMessage other) {
@@ -798,6 +886,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder MergeFrom(TestXmlRescursive other) {
if (other == global::Google.ProtocolBuffers.TestProtos.TestXmlRescursive.DefaultInstance) return this;
+ PrepareBuilder();
if (other.HasChild) {
MergeChild(other.Child);
}
@@ -810,6 +899,7 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
+ PrepareBuilder();
pb::UnknownFieldSet.Builder unknownFields = null;
uint tag;
string field_name;
@@ -871,18 +961,21 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetChild(global::Google.ProtocolBuffers.TestProtos.TestXmlRescursive value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.hasChild = true;
result.child_ = value;
return this;
}
public Builder SetChild(global::Google.ProtocolBuffers.TestProtos.TestXmlRescursive.Builder builderForValue) {
pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue");
+ PrepareBuilder();
result.hasChild = true;
result.child_ = builderForValue.Build();
return this;
}
public Builder MergeChild(global::Google.ProtocolBuffers.TestProtos.TestXmlRescursive value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
if (result.hasChild &&
result.child_ != global::Google.ProtocolBuffers.TestProtos.TestXmlRescursive.DefaultInstance) {
result.child_ = global::Google.ProtocolBuffers.TestProtos.TestXmlRescursive.CreateBuilder(result.child_).MergeFrom(value).BuildPartial();
@@ -893,6 +986,7 @@ namespace Google.ProtocolBuffers.TestProtos { return this;
}
public Builder ClearChild() {
+ PrepareBuilder();
result.hasChild = false;
result.child_ = global::Google.ProtocolBuffers.TestProtos.TestXmlRescursive.DefaultInstance;
return this;
@@ -1062,7 +1156,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(Children prototype) {
- return (Builder) new Builder().MergeFrom(prototype);
+ return new Builder(prototype);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -1072,21 +1166,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder {
get { return this; }
}
- public Builder() {}
+ public Builder() {
+ result = DefaultInstance ?? new Children();
+ builderIsReadOnly = result == DefaultInstance;
+ }
+ internal Builder(Children cloneFrom) {
+ result = cloneFrom;
+ builderIsReadOnly = true;
+ }
- Children result = new Children();
+ bool builderIsReadOnly;
+ Children result;
+
+ private Children PrepareBuilder() {
+ if (builderIsReadOnly) {
+ Children original = result;
+ result = new Children();
+ builderIsReadOnly = false;
+ MergeFrom(original);
+ }
+ return result;
+ }
+
+ public override bool IsInitialized {
+ get { return result.IsInitialized; }
+ }
protected override Children MessageBeingBuilt {
- get { return result; }
+ get { return PrepareBuilder(); }
}
public override Builder Clear() {
- result = new Children();
+ result = DefaultInstance ?? new Children();
+ builderIsReadOnly = true;
return this;
}
public override Builder Clone() {
- return new Builder().MergeFrom(result);
+ if (builderIsReadOnly) {
+ return new Builder(result);
+ } else {
+ return new Builder().MergeFrom(result);
+ }
}
public override pbd::MessageDescriptor DescriptorForType {
@@ -1098,13 +1219,12 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override Children BuildPartial() {
- if (result == null) {
- throw new global::System.InvalidOperationException("build() has already been called on this Builder");
+ if (builderIsReadOnly) {
+ return result;
}
result.options_.MakeReadOnly();
- Children returnMe = result;
- result = null;
- return returnMe;
+ builderIsReadOnly = true;
+ return result;
}
public override Builder MergeFrom(pb::IMessage other) {
@@ -1118,6 +1238,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder MergeFrom(Children other) {
if (other == global::Google.ProtocolBuffers.TestProtos.TestXmlMessage.Types.Children.DefaultInstance) return this;
+ PrepareBuilder();
if (other.options_.Count != 0) {
base.AddRange(other.options_, result.options_);
}
@@ -1133,6 +1254,7 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
+ PrepareBuilder();
pb::UnknownFieldSet.Builder unknownFields = null;
uint tag;
string field_name;
@@ -1195,7 +1317,7 @@ namespace Google.ProtocolBuffers.TestProtos { public pbc::IPopsicleList<global::Google.ProtocolBuffers.TestProtos.EnumOptions> OptionsList {
- get { return result.options_; }
+ get { return PrepareBuilder().options_; }
}
public int OptionsCount {
get { return result.OptionsCount; }
@@ -1204,18 +1326,22 @@ namespace Google.ProtocolBuffers.TestProtos { return result.GetOptions(index);
}
public Builder SetOptions(int index, global::Google.ProtocolBuffers.TestProtos.EnumOptions value) {
+ PrepareBuilder();
result.options_[index] = value;
return this;
}
public Builder AddOptions(global::Google.ProtocolBuffers.TestProtos.EnumOptions value) {
+ PrepareBuilder();
result.options_.Add(value);
return this;
}
public Builder AddRangeOptions(scg::IEnumerable<global::Google.ProtocolBuffers.TestProtos.EnumOptions> values) {
+ PrepareBuilder();
base.AddRange(values, result.options_);
return this;
}
public Builder ClearOptions() {
+ PrepareBuilder();
result.options_.Clear();
return this;
}
@@ -1229,11 +1355,13 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetBinary(pb::ByteString value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.hasBinary = true;
result.binary_ = value;
return this;
}
public Builder ClearBinary() {
+ PrepareBuilder();
result.hasBinary = false;
result.binary_ = pb::ByteString.Empty;
return this;
@@ -1438,7 +1566,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(TestXmlMessage prototype) {
- return (Builder) new Builder().MergeFrom(prototype);
+ return new Builder(prototype);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -1448,21 +1576,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder {
get { return this; }
}
- public Builder() {}
+ public Builder() {
+ result = DefaultInstance ?? new TestXmlMessage();
+ builderIsReadOnly = result == DefaultInstance;
+ }
+ internal Builder(TestXmlMessage cloneFrom) {
+ result = cloneFrom;
+ builderIsReadOnly = true;
+ }
- TestXmlMessage result = new TestXmlMessage();
+ bool builderIsReadOnly;
+ TestXmlMessage result;
+
+ private TestXmlMessage PrepareBuilder() {
+ if (builderIsReadOnly) {
+ TestXmlMessage original = result;
+ result = new TestXmlMessage();
+ builderIsReadOnly = false;
+ MergeFrom(original);
+ }
+ return result;
+ }
+
+ public override bool IsInitialized {
+ get { return result.IsInitialized; }
+ }
protected override TestXmlMessage MessageBeingBuilt {
- get { return result; }
+ get { return PrepareBuilder(); }
}
public override Builder Clear() {
- result = new TestXmlMessage();
+ result = DefaultInstance ?? new TestXmlMessage();
+ builderIsReadOnly = true;
return this;
}
public override Builder Clone() {
- return new Builder().MergeFrom(result);
+ if (builderIsReadOnly) {
+ return new Builder(result);
+ } else {
+ return new Builder().MergeFrom(result);
+ }
}
public override pbd::MessageDescriptor DescriptorForType {
@@ -1474,15 +1629,14 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override TestXmlMessage BuildPartial() {
- if (result == null) {
- throw new global::System.InvalidOperationException("build() has already been called on this Builder");
+ if (builderIsReadOnly) {
+ return result;
}
result.numbers_.MakeReadOnly();
result.textlines_.MakeReadOnly();
result.children_.MakeReadOnly();
- TestXmlMessage returnMe = result;
- result = null;
- return returnMe;
+ builderIsReadOnly = true;
+ return result;
}
public override Builder MergeFrom(pb::IMessage other) {
@@ -1496,6 +1650,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder MergeFrom(TestXmlMessage other) {
if (other == global::Google.ProtocolBuffers.TestProtos.TestXmlMessage.DefaultInstance) return this;
+ PrepareBuilder();
if (other.HasNumber) {
Number = other.Number;
}
@@ -1527,6 +1682,7 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
+ PrepareBuilder();
pb::UnknownFieldSet.Builder unknownFields = null;
uint tag;
string field_name;
@@ -1612,18 +1768,20 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetNumber(value); }
}
public Builder SetNumber(long value) {
+ PrepareBuilder();
result.hasNumber = true;
result.number_ = value;
return this;
}
public Builder ClearNumber() {
+ PrepareBuilder();
result.hasNumber = false;
result.number_ = 0L;
return this;
}
public pbc::IPopsicleList<int> NumbersList {
- get { return result.numbers_; }
+ get { return PrepareBuilder().numbers_; }
}
public int NumbersCount {
get { return result.NumbersCount; }
@@ -1632,18 +1790,22 @@ namespace Google.ProtocolBuffers.TestProtos { return result.GetNumbers(index);
}
public Builder SetNumbers(int index, int value) {
+ PrepareBuilder();
result.numbers_[index] = value;
return this;
}
public Builder AddNumbers(int value) {
+ PrepareBuilder();
result.numbers_.Add(value);
return this;
}
public Builder AddRangeNumbers(scg::IEnumerable<int> values) {
+ PrepareBuilder();
base.AddRange(values, result.numbers_);
return this;
}
public Builder ClearNumbers() {
+ PrepareBuilder();
result.numbers_.Clear();
return this;
}
@@ -1657,18 +1819,20 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetText(string value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.hasText = true;
result.text_ = value;
return this;
}
public Builder ClearText() {
+ PrepareBuilder();
result.hasText = false;
result.text_ = "";
return this;
}
public pbc::IPopsicleList<string> TextlinesList {
- get { return result.textlines_; }
+ get { return PrepareBuilder().textlines_; }
}
public int TextlinesCount {
get { return result.TextlinesCount; }
@@ -1678,19 +1842,23 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetTextlines(int index, string value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.textlines_[index] = value;
return this;
}
public Builder AddTextlines(string value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.textlines_.Add(value);
return this;
}
public Builder AddRangeTextlines(scg::IEnumerable<string> values) {
+ PrepareBuilder();
base.AddRange(values, result.textlines_);
return this;
}
public Builder ClearTextlines() {
+ PrepareBuilder();
result.textlines_.Clear();
return this;
}
@@ -1703,11 +1871,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetValid(value); }
}
public Builder SetValid(bool value) {
+ PrepareBuilder();
result.hasValid = true;
result.valid_ = value;
return this;
}
public Builder ClearValid() {
+ PrepareBuilder();
result.hasValid = false;
result.valid_ = false;
return this;
@@ -1722,18 +1892,21 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetChild(global::Google.ProtocolBuffers.TestProtos.TestXmlChild value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.hasChild = true;
result.child_ = value;
return this;
}
public Builder SetChild(global::Google.ProtocolBuffers.TestProtos.TestXmlChild.Builder builderForValue) {
pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue");
+ PrepareBuilder();
result.hasChild = true;
result.child_ = builderForValue.Build();
return this;
}
public Builder MergeChild(global::Google.ProtocolBuffers.TestProtos.TestXmlChild value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
if (result.hasChild &&
result.child_ != global::Google.ProtocolBuffers.TestProtos.TestXmlChild.DefaultInstance) {
result.child_ = global::Google.ProtocolBuffers.TestProtos.TestXmlChild.CreateBuilder(result.child_).MergeFrom(value).BuildPartial();
@@ -1744,13 +1917,14 @@ namespace Google.ProtocolBuffers.TestProtos { return this;
}
public Builder ClearChild() {
+ PrepareBuilder();
result.hasChild = false;
result.child_ = global::Google.ProtocolBuffers.TestProtos.TestXmlChild.DefaultInstance;
return this;
}
public pbc::IPopsicleList<global::Google.ProtocolBuffers.TestProtos.TestXmlMessage.Types.Children> ChildrenList {
- get { return result.children_; }
+ get { return PrepareBuilder().children_; }
}
public int ChildrenCount {
get { return result.ChildrenCount; }
@@ -1760,29 +1934,35 @@ namespace Google.ProtocolBuffers.TestProtos { }
public Builder SetChildren(int index, global::Google.ProtocolBuffers.TestProtos.TestXmlMessage.Types.Children value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.children_[index] = value;
return this;
}
public Builder SetChildren(int index, global::Google.ProtocolBuffers.TestProtos.TestXmlMessage.Types.Children.Builder builderForValue) {
pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue");
+ PrepareBuilder();
result.children_[index] = builderForValue.Build();
return this;
}
public Builder AddChildren(global::Google.ProtocolBuffers.TestProtos.TestXmlMessage.Types.Children value) {
pb::ThrowHelper.ThrowIfNull(value, "value");
+ PrepareBuilder();
result.children_.Add(value);
return this;
}
public Builder AddChildren(global::Google.ProtocolBuffers.TestProtos.TestXmlMessage.Types.Children.Builder builderForValue) {
pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue");
+ PrepareBuilder();
result.children_.Add(builderForValue.Build());
return this;
}
public Builder AddRangeChildren(scg::IEnumerable<global::Google.ProtocolBuffers.TestProtos.TestXmlMessage.Types.Children> values) {
+ PrepareBuilder();
base.AddRange(values, result.children_);
return this;
}
public Builder ClearChildren() {
+ PrepareBuilder();
result.children_.Clear();
return this;
}
@@ -1895,7 +2075,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); }
public static Builder CreateBuilder(TestXmlExtension prototype) {
- return (Builder) new Builder().MergeFrom(prototype);
+ return new Builder(prototype);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -1905,21 +2085,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder {
get { return this; }
}
- public Builder() {}
+ public Builder() {
+ result = DefaultInstance ?? new TestXmlExtension();
+ builderIsReadOnly = result == DefaultInstance;
+ }
+ internal Builder(TestXmlExtension cloneFrom) {
+ result = cloneFrom;
+ builderIsReadOnly = true;
+ }
- TestXmlExtension result = new TestXmlExtension();
+ bool builderIsReadOnly;
+ TestXmlExtension result;
+
+ private TestXmlExtension PrepareBuilder() {
+ if (builderIsReadOnly) {
+ TestXmlExtension original = result;
+ result = new TestXmlExtension();
+ builderIsReadOnly = false;
+ MergeFrom(original);
+ }
+ return result;
+ }
+
+ public override bool IsInitialized {
+ get { return result.IsInitialized; }
+ }
protected override TestXmlExtension MessageBeingBuilt {
- get { return result; }
+ get { return PrepareBuilder(); }
}
public override Builder Clear() {
- result = new TestXmlExtension();
+ result = DefaultInstance ?? new TestXmlExtension();
+ builderIsReadOnly = true;
return this;
}
public override Builder Clone() {
- return new Builder().MergeFrom(result);
+ if (builderIsReadOnly) {
+ return new Builder(result);
+ } else {
+ return new Builder().MergeFrom(result);
+ }
}
public override pbd::MessageDescriptor DescriptorForType {
@@ -1931,12 +2138,11 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override TestXmlExtension BuildPartial() {
- if (result == null) {
- throw new global::System.InvalidOperationException("build() has already been called on this Builder");
+ if (builderIsReadOnly) {
+ return result;
}
- TestXmlExtension returnMe = result;
- result = null;
- return returnMe;
+ builderIsReadOnly = true;
+ return result;
}
public override Builder MergeFrom(pb::IMessage other) {
@@ -1950,6 +2156,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder MergeFrom(TestXmlExtension other) {
if (other == global::Google.ProtocolBuffers.TestProtos.TestXmlExtension.DefaultInstance) return this;
+ PrepareBuilder();
if (other.HasNumber) {
Number = other.Number;
}
@@ -1962,6 +2169,7 @@ namespace Google.ProtocolBuffers.TestProtos { }
public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
+ PrepareBuilder();
pb::UnknownFieldSet.Builder unknownFields = null;
uint tag;
string field_name;
@@ -2017,11 +2225,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetNumber(value); }
}
public Builder SetNumber(int value) {
+ PrepareBuilder();
result.hasNumber = true;
result.number_ = value;
return this;
}
public Builder ClearNumber() {
+ PrepareBuilder();
result.hasNumber = false;
result.number_ = 0;
return this;
|