diff --git a/src/AddressBook/AddressBookProtos.cs b/src/AddressBook/AddressBookProtos.cs index 9b99452e8e..1bad08882d 100644 --- a/src/AddressBook/AddressBookProtos.cs +++ b/src/AddressBook/AddressBookProtos.cs @@ -225,7 +225,7 @@ namespace Google.ProtocolBuffers.Examples.AddressBook { public override Builder ToBuilder() { return CreateBuilder(this); } public override Builder CreateBuilderForType() { return new Builder(); } public static Builder CreateBuilder(PhoneNumber prototype) { - return (Builder) new Builder().MergeFrom(prototype); + return new Builder(prototype); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] @@ -235,21 +235,48 @@ namespace Google.ProtocolBuffers.Examples.AddressBook { protected override Builder ThisBuilder { get { return this; } } - public Builder() {} + public Builder() { + result = DefaultInstance ?? new PhoneNumber(); + builderIsReadOnly = result == DefaultInstance; + } + internal Builder(PhoneNumber cloneFrom) { + result = cloneFrom; + builderIsReadOnly = true; + } - PhoneNumber result = new PhoneNumber(); + bool builderIsReadOnly; + PhoneNumber result; + + private PhoneNumber PrepareBuilder() { + if (builderIsReadOnly) { + PhoneNumber original = result; + result = new PhoneNumber(); + builderIsReadOnly = false; + MergeFrom(original); + } + return result; + } + + public override bool IsInitialized { + get { return result.IsInitialized; } + } protected override PhoneNumber MessageBeingBuilt { - get { return result; } + get { return PrepareBuilder(); } } public override Builder Clear() { - result = new PhoneNumber(); + result = DefaultInstance ?? new PhoneNumber(); + 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 { @@ -261,12 +288,11 @@ namespace Google.ProtocolBuffers.Examples.AddressBook { } public override PhoneNumber BuildPartial() { - if (result == null) { - throw new global::System.InvalidOperationException("build() has already been called on this Builder"); + if (builderIsReadOnly) { + return result; } - PhoneNumber returnMe = result; - result = null; - return returnMe; + builderIsReadOnly = true; + return result; } public override Builder MergeFrom(pb::IMessage other) { @@ -280,6 +306,7 @@ namespace Google.ProtocolBuffers.Examples.AddressBook { public override Builder MergeFrom(PhoneNumber other) { if (other == global::Google.ProtocolBuffers.Examples.AddressBook.Person.Types.PhoneNumber.DefaultInstance) return this; + PrepareBuilder(); if (other.HasNumber) { Number = other.Number; } @@ -295,6 +322,7 @@ namespace Google.ProtocolBuffers.Examples.AddressBook { } public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { + PrepareBuilder(); pb::UnknownFieldSet.Builder unknownFields = null; uint tag; string field_name; @@ -363,11 +391,13 @@ namespace Google.ProtocolBuffers.Examples.AddressBook { } public Builder SetNumber(string value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.hasNumber = true; result.number_ = value; return this; } public Builder ClearNumber() { + PrepareBuilder(); result.hasNumber = false; result.number_ = ""; return this; @@ -381,11 +411,13 @@ namespace Google.ProtocolBuffers.Examples.AddressBook { set { SetType(value); } } public Builder SetType(global::Google.ProtocolBuffers.Examples.AddressBook.Person.Types.PhoneType value) { + PrepareBuilder(); result.hasType = true; result.type_ = value; return this; } public Builder ClearType() { + PrepareBuilder(); result.hasType = false; result.type_ = global::Google.ProtocolBuffers.Examples.AddressBook.Person.Types.PhoneType.HOME; return this; @@ -529,7 +561,7 @@ namespace Google.ProtocolBuffers.Examples.AddressBook { public override Builder ToBuilder() { return CreateBuilder(this); } public override Builder CreateBuilderForType() { return new Builder(); } public static Builder CreateBuilder(Person prototype) { - return (Builder) new Builder().MergeFrom(prototype); + return new Builder(prototype); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] @@ -539,21 +571,48 @@ namespace Google.ProtocolBuffers.Examples.AddressBook { protected override Builder ThisBuilder { get { return this; } } - public Builder() {} + public Builder() { + result = DefaultInstance ?? new Person(); + builderIsReadOnly = result == DefaultInstance; + } + internal Builder(Person cloneFrom) { + result = cloneFrom; + builderIsReadOnly = true; + } - Person result = new Person(); + bool builderIsReadOnly; + Person result; + + private Person PrepareBuilder() { + if (builderIsReadOnly) { + Person original = result; + result = new Person(); + builderIsReadOnly = false; + MergeFrom(original); + } + return result; + } + + public override bool IsInitialized { + get { return result.IsInitialized; } + } protected override Person MessageBeingBuilt { - get { return result; } + get { return PrepareBuilder(); } } public override Builder Clear() { - result = new Person(); + result = DefaultInstance ?? new Person(); + 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,13 +624,12 @@ namespace Google.ProtocolBuffers.Examples.AddressBook { } public override Person BuildPartial() { - if (result == null) { - throw new global::System.InvalidOperationException("build() has already been called on this Builder"); + if (builderIsReadOnly) { + return result; } result.phone_.MakeReadOnly(); - Person returnMe = result; - result = null; - return returnMe; + builderIsReadOnly = true; + return result; } public override Builder MergeFrom(pb::IMessage other) { @@ -585,6 +643,7 @@ namespace Google.ProtocolBuffers.Examples.AddressBook { public override Builder MergeFrom(Person other) { if (other == global::Google.ProtocolBuffers.Examples.AddressBook.Person.DefaultInstance) return this; + PrepareBuilder(); if (other.HasName) { Name = other.Name; } @@ -606,6 +665,7 @@ namespace Google.ProtocolBuffers.Examples.AddressBook { } public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { + PrepareBuilder(); pb::UnknownFieldSet.Builder unknownFields = null; uint tag; string field_name; @@ -674,11 +734,13 @@ namespace Google.ProtocolBuffers.Examples.AddressBook { } 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; @@ -692,11 +754,13 @@ namespace Google.ProtocolBuffers.Examples.AddressBook { set { SetId(value); } } public Builder SetId(int value) { + PrepareBuilder(); result.hasId = true; result.id_ = value; return this; } public Builder ClearId() { + PrepareBuilder(); result.hasId = false; result.id_ = 0; return this; @@ -711,18 +775,20 @@ namespace Google.ProtocolBuffers.Examples.AddressBook { } public Builder SetEmail(string value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.hasEmail = true; result.email_ = value; return this; } public Builder ClearEmail() { + PrepareBuilder(); result.hasEmail = false; result.email_ = ""; return this; } public pbc::IPopsicleList PhoneList { - get { return result.phone_; } + get { return PrepareBuilder().phone_; } } public int PhoneCount { get { return result.PhoneCount; } @@ -732,29 +798,35 @@ namespace Google.ProtocolBuffers.Examples.AddressBook { } public Builder SetPhone(int index, global::Google.ProtocolBuffers.Examples.AddressBook.Person.Types.PhoneNumber value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.phone_[index] = value; return this; } public Builder SetPhone(int index, global::Google.ProtocolBuffers.Examples.AddressBook.Person.Types.PhoneNumber.Builder builderForValue) { pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); + PrepareBuilder(); result.phone_[index] = builderForValue.Build(); return this; } public Builder AddPhone(global::Google.ProtocolBuffers.Examples.AddressBook.Person.Types.PhoneNumber value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.phone_.Add(value); return this; } public Builder AddPhone(global::Google.ProtocolBuffers.Examples.AddressBook.Person.Types.PhoneNumber.Builder builderForValue) { pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); + PrepareBuilder(); result.phone_.Add(builderForValue.Build()); return this; } public Builder AddRangePhone(scg::IEnumerable values) { + PrepareBuilder(); result.phone_.Add(values); return this; } public Builder ClearPhone() { + PrepareBuilder(); result.phone_.Clear(); return this; } @@ -872,7 +944,7 @@ namespace Google.ProtocolBuffers.Examples.AddressBook { public override Builder ToBuilder() { return CreateBuilder(this); } public override Builder CreateBuilderForType() { return new Builder(); } public static Builder CreateBuilder(AddressBook prototype) { - return (Builder) new Builder().MergeFrom(prototype); + return new Builder(prototype); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] @@ -882,21 +954,48 @@ namespace Google.ProtocolBuffers.Examples.AddressBook { protected override Builder ThisBuilder { get { return this; } } - public Builder() {} + public Builder() { + result = DefaultInstance ?? new AddressBook(); + builderIsReadOnly = result == DefaultInstance; + } + internal Builder(AddressBook cloneFrom) { + result = cloneFrom; + builderIsReadOnly = true; + } - AddressBook result = new AddressBook(); + bool builderIsReadOnly; + AddressBook result; + + private AddressBook PrepareBuilder() { + if (builderIsReadOnly) { + AddressBook original = result; + result = new AddressBook(); + builderIsReadOnly = false; + MergeFrom(original); + } + return result; + } + + public override bool IsInitialized { + get { return result.IsInitialized; } + } protected override AddressBook MessageBeingBuilt { - get { return result; } + get { return PrepareBuilder(); } } public override Builder Clear() { - result = new AddressBook(); + result = DefaultInstance ?? new AddressBook(); + 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 { @@ -908,13 +1007,12 @@ namespace Google.ProtocolBuffers.Examples.AddressBook { } public override AddressBook BuildPartial() { - if (result == null) { - throw new global::System.InvalidOperationException("build() has already been called on this Builder"); + if (builderIsReadOnly) { + return result; } result.person_.MakeReadOnly(); - AddressBook returnMe = result; - result = null; - return returnMe; + builderIsReadOnly = true; + return result; } public override Builder MergeFrom(pb::IMessage other) { @@ -928,6 +1026,7 @@ namespace Google.ProtocolBuffers.Examples.AddressBook { public override Builder MergeFrom(AddressBook other) { if (other == global::Google.ProtocolBuffers.Examples.AddressBook.AddressBook.DefaultInstance) return this; + PrepareBuilder(); if (other.person_.Count != 0) { result.person_.Add(other.person_); } @@ -940,6 +1039,7 @@ namespace Google.ProtocolBuffers.Examples.AddressBook { } public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { + PrepareBuilder(); pb::UnknownFieldSet.Builder unknownFields = null; uint tag; string field_name; @@ -988,7 +1088,7 @@ namespace Google.ProtocolBuffers.Examples.AddressBook { public pbc::IPopsicleList PersonList { - get { return result.person_; } + get { return PrepareBuilder().person_; } } public int PersonCount { get { return result.PersonCount; } @@ -998,29 +1098,35 @@ namespace Google.ProtocolBuffers.Examples.AddressBook { } public Builder SetPerson(int index, global::Google.ProtocolBuffers.Examples.AddressBook.Person value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.person_[index] = value; return this; } public Builder SetPerson(int index, global::Google.ProtocolBuffers.Examples.AddressBook.Person.Builder builderForValue) { pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); + PrepareBuilder(); result.person_[index] = builderForValue.Build(); return this; } public Builder AddPerson(global::Google.ProtocolBuffers.Examples.AddressBook.Person value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.person_.Add(value); return this; } public Builder AddPerson(global::Google.ProtocolBuffers.Examples.AddressBook.Person.Builder builderForValue) { pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); + PrepareBuilder(); result.person_.Add(builderForValue.Build()); return this; } public Builder AddRangePerson(scg::IEnumerable values) { + PrepareBuilder(); result.person_.Add(values); return this; } public Builder ClearPerson() { + PrepareBuilder(); result.person_.Clear(); return this; } diff --git a/src/ProtoGen/EnumFieldGenerator.cs b/src/ProtoGen/EnumFieldGenerator.cs index 78384fdd76..8d70bc6765 100644 --- a/src/ProtoGen/EnumFieldGenerator.cs +++ b/src/ProtoGen/EnumFieldGenerator.cs @@ -72,12 +72,14 @@ namespace Google.ProtocolBuffers.ProtoGen writer.WriteLine("}"); AddPublicMemberAttributes(writer); writer.WriteLine("public Builder Set{0}({1} value) {{", PropertyName, TypeName); + writer.WriteLine(" PrepareBuilder();"); writer.WriteLine(" result.has{0} = true;", PropertyName); writer.WriteLine(" result.{0}_ = value;", Name); writer.WriteLine(" return this;"); writer.WriteLine("}"); AddDeprecatedFlag(writer); writer.WriteLine("public Builder Clear{0}() {{", PropertyName); + writer.WriteLine(" PrepareBuilder();"); writer.WriteLine(" result.has{0} = false;", PropertyName); writer.WriteLine(" result.{0}_ = {1};", Name, DefaultValue); writer.WriteLine(" return this;"); diff --git a/src/ProtoGen/MessageFieldGenerator.cs b/src/ProtoGen/MessageFieldGenerator.cs index 8e4bef5bc1..8e2691eef6 100644 --- a/src/ProtoGen/MessageFieldGenerator.cs +++ b/src/ProtoGen/MessageFieldGenerator.cs @@ -73,6 +73,7 @@ namespace Google.ProtocolBuffers.ProtoGen AddDeprecatedFlag(writer); writer.WriteLine("public Builder Set{0}({1} value) {{", PropertyName, TypeName); AddNullCheck(writer); + writer.WriteLine(" PrepareBuilder();"); writer.WriteLine(" result.has{0} = true;", PropertyName); writer.WriteLine(" result.{0}_ = value;", Name); writer.WriteLine(" return this;"); @@ -80,6 +81,7 @@ namespace Google.ProtocolBuffers.ProtoGen AddDeprecatedFlag(writer); writer.WriteLine("public Builder Set{0}({1}.Builder builderForValue) {{", PropertyName, TypeName); AddNullCheck(writer, "builderForValue"); + writer.WriteLine(" PrepareBuilder();"); writer.WriteLine(" result.has{0} = true;", PropertyName); writer.WriteLine(" result.{0}_ = builderForValue.Build();", Name); writer.WriteLine(" return this;"); @@ -87,6 +89,7 @@ namespace Google.ProtocolBuffers.ProtoGen AddDeprecatedFlag(writer); writer.WriteLine("public Builder Merge{0}({1} value) {{", PropertyName, TypeName); AddNullCheck(writer); + writer.WriteLine(" PrepareBuilder();"); writer.WriteLine(" if (result.has{0} &&", PropertyName); writer.WriteLine(" result.{0}_ != {1}) {{", Name, DefaultValue); writer.WriteLine(" result.{0}_ = {1}.CreateBuilder(result.{0}_).MergeFrom(value).BuildPartial();", Name, @@ -99,6 +102,7 @@ namespace Google.ProtocolBuffers.ProtoGen writer.WriteLine("}"); AddDeprecatedFlag(writer); writer.WriteLine("public Builder Clear{0}() {{", PropertyName); + writer.WriteLine(" PrepareBuilder();"); writer.WriteLine(" result.has{0} = false;", PropertyName); writer.WriteLine(" result.{0}_ = {1};", Name, DefaultValue); writer.WriteLine(" return this;"); diff --git a/src/ProtoGen/MessageGenerator.cs b/src/ProtoGen/MessageGenerator.cs index c8b2087f50..89c4aaecc9 100644 --- a/src/ProtoGen/MessageGenerator.cs +++ b/src/ProtoGen/MessageGenerator.cs @@ -556,7 +556,7 @@ namespace Google.ProtocolBuffers.ProtoGen writer.WriteLine("public override Builder ToBuilder() { return CreateBuilder(this); }"); writer.WriteLine("public override Builder CreateBuilderForType() { return new Builder(); }"); writer.WriteLine("public static Builder CreateBuilder({0} prototype) {{", ClassName); - writer.WriteLine(" return (Builder) new Builder().MergeFrom(prototype);"); + writer.WriteLine(" return new Builder(prototype);"); writer.WriteLine("}"); writer.WriteLine(); if (Descriptor.File.CSharpOptions.AddSerializable) @@ -591,21 +591,52 @@ namespace Google.ProtocolBuffers.ProtoGen private void GenerateCommonBuilderMethods(TextGenerator writer) { - writer.WriteLine("public Builder() {{}}", ClassAccessLevel); + //default constructor + writer.WriteLine("public Builder() {"); + //Durring static initialization of message, DefaultInstance is expected to return null. + writer.WriteLine(" result = DefaultInstance ?? new {0}();", ClassName); + writer.WriteLine(" builderIsReadOnly = result == DefaultInstance;"); + writer.WriteLine("}"); + //clone constructor + writer.WriteLine("internal Builder({0} cloneFrom) {{", ClassName); + writer.WriteLine(" result = cloneFrom;"); + writer.WriteLine(" builderIsReadOnly = true;"); + writer.WriteLine("}"); + writer.WriteLine(); + writer.WriteLine("bool builderIsReadOnly;"); + writer.WriteLine("{0} result;", ClassName); + writer.WriteLine(); + writer.WriteLine("private {0} PrepareBuilder() {{", ClassName); + writer.WriteLine(" if (builderIsReadOnly) {"); + writer.WriteLine(" {0} original = result;", ClassName); + writer.WriteLine(" result = new {0}();", ClassName); + writer.WriteLine(" builderIsReadOnly = false;"); + writer.WriteLine(" MergeFrom(original);"); + writer.WriteLine(" }"); + writer.WriteLine(" return result;"); + writer.WriteLine("}"); writer.WriteLine(); - writer.WriteLine("{0} result = new {0}();", ClassName); + writer.WriteLine("public override bool IsInitialized {"); + writer.WriteLine(" get { return result.IsInitialized; }"); + writer.WriteLine("}"); writer.WriteLine(); writer.WriteLine("protected override {0} MessageBeingBuilt {{", ClassName); - writer.WriteLine(" get { return result; }"); + writer.WriteLine(" get { return PrepareBuilder(); }"); writer.WriteLine("}"); writer.WriteLine(); + //Not actually expecting that DefaultInstance would ever be null here; however, we will ensure it does not break writer.WriteLine("public override Builder Clear() {"); - writer.WriteLine(" result = new {0}();", ClassName); + writer.WriteLine(" result = DefaultInstance ?? new {0}();", ClassName); + writer.WriteLine(" builderIsReadOnly = true;"); writer.WriteLine(" return this;"); writer.WriteLine("}"); writer.WriteLine(); writer.WriteLine("public override Builder Clone() {"); - writer.WriteLine(" return new Builder().MergeFrom(result);"); + writer.WriteLine(" if (builderIsReadOnly) {"); + writer.WriteLine(" return new Builder(result);"); + writer.WriteLine(" } else {"); + writer.WriteLine(" return new Builder().MergeFrom(result);"); + writer.WriteLine(" }"); writer.WriteLine("}"); writer.WriteLine(); if (!UseLiteRuntime) @@ -622,17 +653,15 @@ namespace Google.ProtocolBuffers.ProtoGen writer.WriteLine("public override {0} BuildPartial() {{", ClassName); writer.Indent(); - writer.WriteLine("if (result == null) {"); - writer.WriteLine( - " throw new global::System.InvalidOperationException(\"build() has already been called on this Builder\");"); + writer.WriteLine("if (builderIsReadOnly) {"); + writer.WriteLine(" return result;"); writer.WriteLine("}"); foreach (FieldDescriptor field in Descriptor.Fields) { CreateFieldGenerator(field).GenerateBuildingCode(writer); } - writer.WriteLine("{0} returnMe = result;", ClassName); - writer.WriteLine("result = null;"); - writer.WriteLine("return returnMe;"); + writer.WriteLine("builderIsReadOnly = true;"); + writer.WriteLine("return result;"); writer.Outdent(); writer.WriteLine("}"); writer.WriteLine(); @@ -653,6 +682,7 @@ namespace Google.ProtocolBuffers.ProtoGen // fields are set so we can skip the merge. writer.Indent(); writer.WriteLine("if (other == {0}.DefaultInstance) return this;", FullClassName); + writer.WriteLine("PrepareBuilder();"); foreach (FieldDescriptor field in Descriptor.Fields) { CreateFieldGenerator(field).GenerateMergingCode(writer); @@ -685,6 +715,7 @@ namespace Google.ProtocolBuffers.ProtoGen writer.WriteLine( "public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {"); writer.Indent(); + writer.WriteLine("PrepareBuilder();"); if (!UseLiteRuntime) { writer.WriteLine("pb::UnknownFieldSet.Builder unknownFields = null;"); diff --git a/src/ProtoGen/PrimitiveFieldGenerator.cs b/src/ProtoGen/PrimitiveFieldGenerator.cs index 0904ce22c7..69e0d4d933 100644 --- a/src/ProtoGen/PrimitiveFieldGenerator.cs +++ b/src/ProtoGen/PrimitiveFieldGenerator.cs @@ -74,12 +74,14 @@ namespace Google.ProtocolBuffers.ProtoGen AddPublicMemberAttributes(writer); writer.WriteLine("public Builder Set{0}({1} value) {{", PropertyName, TypeName); AddNullCheck(writer); + writer.WriteLine(" PrepareBuilder();"); writer.WriteLine(" result.has{0} = true;", PropertyName); writer.WriteLine(" result.{0}_ = value;", Name); writer.WriteLine(" return this;"); writer.WriteLine("}"); AddDeprecatedFlag(writer); writer.WriteLine("public Builder Clear{0}() {{", PropertyName); + writer.WriteLine(" PrepareBuilder();"); writer.WriteLine(" result.has{0} = false;", PropertyName); writer.WriteLine(" result.{0}_ = {1};", Name, DefaultValue); writer.WriteLine(" return this;"); diff --git a/src/ProtoGen/RepeatedEnumFieldGenerator.cs b/src/ProtoGen/RepeatedEnumFieldGenerator.cs index fcda656467..aacee9371c 100644 --- a/src/ProtoGen/RepeatedEnumFieldGenerator.cs +++ b/src/ProtoGen/RepeatedEnumFieldGenerator.cs @@ -75,7 +75,7 @@ namespace Google.ProtocolBuffers.ProtoGen // We return it via IPopsicleList so that collection initializers work more pleasantly. AddDeprecatedFlag(writer); writer.WriteLine("public pbc::IPopsicleList<{0}> {1}List {{", TypeName, PropertyName); - writer.WriteLine(" get {{ return result.{0}_; }}", Name); + writer.WriteLine(" get {{ return PrepareBuilder().{0}_; }}", Name); writer.WriteLine("}"); AddDeprecatedFlag(writer); writer.WriteLine("public int {0}Count {{", PropertyName); @@ -87,21 +87,25 @@ namespace Google.ProtocolBuffers.ProtoGen writer.WriteLine("}"); AddDeprecatedFlag(writer); writer.WriteLine("public Builder Set{0}(int index, {1} value) {{", PropertyName, TypeName); + writer.WriteLine(" PrepareBuilder();"); writer.WriteLine(" result.{0}_[index] = value;", Name); writer.WriteLine(" return this;"); writer.WriteLine("}"); AddDeprecatedFlag(writer); writer.WriteLine("public Builder Add{0}({1} value) {{", PropertyName, TypeName); + writer.WriteLine(" PrepareBuilder();"); writer.WriteLine(" result.{0}_.Add(value);", Name, TypeName); writer.WriteLine(" return this;"); writer.WriteLine("}"); AddDeprecatedFlag(writer); writer.WriteLine("public Builder AddRange{0}(scg::IEnumerable<{1}> values) {{", PropertyName, TypeName); + writer.WriteLine(" PrepareBuilder();"); writer.WriteLine(" result.{0}_.Add(values);", Name); writer.WriteLine(" return this;"); writer.WriteLine("}"); AddDeprecatedFlag(writer); writer.WriteLine("public Builder Clear{0}() {{", PropertyName); + writer.WriteLine(" PrepareBuilder();"); writer.WriteLine(" result.{0}_.Clear();", Name); writer.WriteLine(" return this;"); writer.WriteLine("}"); diff --git a/src/ProtoGen/RepeatedMessageFieldGenerator.cs b/src/ProtoGen/RepeatedMessageFieldGenerator.cs index d8f0a8eb5e..6cc1e63149 100644 --- a/src/ProtoGen/RepeatedMessageFieldGenerator.cs +++ b/src/ProtoGen/RepeatedMessageFieldGenerator.cs @@ -71,7 +71,7 @@ namespace Google.ProtocolBuffers.ProtoGen // We return it via IPopsicleList so that collection initializers work more pleasantly. AddDeprecatedFlag(writer); writer.WriteLine("public pbc::IPopsicleList<{0}> {1}List {{", TypeName, PropertyName); - writer.WriteLine(" get {{ return result.{0}_; }}", Name); + writer.WriteLine(" get {{ return PrepareBuilder().{0}_; }}", Name); writer.WriteLine("}"); AddDeprecatedFlag(writer); writer.WriteLine("public int {0}Count {{", PropertyName); @@ -84,6 +84,7 @@ namespace Google.ProtocolBuffers.ProtoGen AddDeprecatedFlag(writer); writer.WriteLine("public Builder Set{0}(int index, {1} value) {{", PropertyName, TypeName); AddNullCheck(writer); + writer.WriteLine(" PrepareBuilder();"); writer.WriteLine(" result.{0}_[index] = value;", Name); writer.WriteLine(" return this;"); writer.WriteLine("}"); @@ -91,12 +92,14 @@ namespace Google.ProtocolBuffers.ProtoGen AddDeprecatedFlag(writer); writer.WriteLine("public Builder Set{0}(int index, {1}.Builder builderForValue) {{", PropertyName, TypeName); AddNullCheck(writer, "builderForValue"); + writer.WriteLine(" PrepareBuilder();"); writer.WriteLine(" result.{0}_[index] = builderForValue.Build();", Name); writer.WriteLine(" return this;"); writer.WriteLine("}"); AddDeprecatedFlag(writer); writer.WriteLine("public Builder Add{0}({1} value) {{", PropertyName, TypeName); AddNullCheck(writer); + writer.WriteLine(" PrepareBuilder();"); writer.WriteLine(" result.{0}_.Add(value);", Name, TypeName); writer.WriteLine(" return this;"); writer.WriteLine("}"); @@ -104,16 +107,19 @@ namespace Google.ProtocolBuffers.ProtoGen AddDeprecatedFlag(writer); writer.WriteLine("public Builder Add{0}({1}.Builder builderForValue) {{", PropertyName, TypeName); AddNullCheck(writer, "builderForValue"); + writer.WriteLine(" PrepareBuilder();"); writer.WriteLine(" result.{0}_.Add(builderForValue.Build());", Name); writer.WriteLine(" return this;"); writer.WriteLine("}"); AddDeprecatedFlag(writer); writer.WriteLine("public Builder AddRange{0}(scg::IEnumerable<{1}> values) {{", PropertyName, TypeName); + writer.WriteLine(" PrepareBuilder();"); writer.WriteLine(" result.{0}_.Add(values);", Name); writer.WriteLine(" return this;"); writer.WriteLine("}"); AddDeprecatedFlag(writer); writer.WriteLine("public Builder Clear{0}() {{", PropertyName); + writer.WriteLine(" PrepareBuilder();"); writer.WriteLine(" result.{0}_.Clear();", Name); writer.WriteLine(" return this;"); writer.WriteLine("}"); diff --git a/src/ProtoGen/RepeatedPrimitiveFieldGenerator.cs b/src/ProtoGen/RepeatedPrimitiveFieldGenerator.cs index 33f0fa2b01..645dce5cec 100644 --- a/src/ProtoGen/RepeatedPrimitiveFieldGenerator.cs +++ b/src/ProtoGen/RepeatedPrimitiveFieldGenerator.cs @@ -75,7 +75,7 @@ namespace Google.ProtocolBuffers.ProtoGen // We return it via IPopsicleList so that collection initializers work more pleasantly. AddPublicMemberAttributes(writer); writer.WriteLine("public pbc::IPopsicleList<{0}> {1}List {{", TypeName, PropertyName); - writer.WriteLine(" get {{ return result.{0}_; }}", Name); + writer.WriteLine(" get {{ return PrepareBuilder().{0}_; }}", Name); writer.WriteLine("}"); AddDeprecatedFlag(writer); writer.WriteLine("public int {0}Count {{", PropertyName); @@ -88,22 +88,26 @@ namespace Google.ProtocolBuffers.ProtoGen AddPublicMemberAttributes(writer); writer.WriteLine("public Builder Set{0}(int index, {1} value) {{", PropertyName, TypeName); AddNullCheck(writer); + writer.WriteLine(" PrepareBuilder();"); writer.WriteLine(" result.{0}_[index] = value;", Name); writer.WriteLine(" return this;"); writer.WriteLine("}"); AddPublicMemberAttributes(writer); writer.WriteLine("public Builder Add{0}({1} value) {{", PropertyName, TypeName); AddNullCheck(writer); + writer.WriteLine(" PrepareBuilder();"); writer.WriteLine(" result.{0}_.Add(value);", Name, TypeName); writer.WriteLine(" return this;"); writer.WriteLine("}"); AddPublicMemberAttributes(writer); writer.WriteLine("public Builder AddRange{0}(scg::IEnumerable<{1}> values) {{", PropertyName, TypeName); + writer.WriteLine(" PrepareBuilder();"); writer.WriteLine(" result.{0}_.Add(values);", Name); writer.WriteLine(" return this;"); writer.WriteLine("}"); AddDeprecatedFlag(writer); writer.WriteLine("public Builder Clear{0}() {{", PropertyName); + writer.WriteLine(" PrepareBuilder();"); writer.WriteLine(" result.{0}_.Clear();", Name); writer.WriteLine(" return this;"); writer.WriteLine("}"); diff --git a/src/ProtocolBuffers.Test/GeneratedMessageTest.cs b/src/ProtocolBuffers.Test/GeneratedMessageTest.cs index 410452d327..12224e9b32 100644 --- a/src/ProtocolBuffers.Test/GeneratedMessageTest.cs +++ b/src/ProtocolBuffers.Test/GeneratedMessageTest.cs @@ -111,22 +111,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() { diff --git a/src/ProtocolBuffers.Test/ProtocolBuffers.Test.csproj b/src/ProtocolBuffers.Test/ProtocolBuffers.Test.csproj index d447db48e1..83d2ff5b9d 100644 --- a/src/ProtocolBuffers.Test/ProtocolBuffers.Test.csproj +++ b/src/ProtocolBuffers.Test/ProtocolBuffers.Test.csproj @@ -103,6 +103,7 @@ + diff --git a/src/ProtocolBuffers.Test/ReusableBuilderTest.cs b/src/ProtocolBuffers.Test/ReusableBuilderTest.cs new file mode 100644 index 0000000000..194313cba3 --- /dev/null +++ b/src/ProtocolBuffers.Test/ReusableBuilderTest.cs @@ -0,0 +1,157 @@ +using System; +using System.Collections.Generic; +using System.Text; +using Google.ProtocolBuffers.Collections; +using NUnit.Framework; +using Google.ProtocolBuffers.TestProtos; +using Google.ProtocolBuffers.Serialization; + +namespace Google.ProtocolBuffers +{ + [TestFixture] + public class ReusableBuilderTest + { + [Test] + public void TestModifyDefaultInstance() + { + //verify that the default instance has correctly been marked as read-only + Assert.AreEqual(typeof(PopsicleList), TestAllTypes.DefaultInstance.RepeatedBoolList.GetType()); + PopsicleList list = (PopsicleList)TestAllTypes.DefaultInstance.RepeatedBoolList; + Assert.IsTrue(list.IsReadOnly); + } + + [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 BuildModifyAndRebuild() + { + TestAllTypes.Builder b1 = new TestAllTypes.Builder(); + b1.SetDefaultInt32(1); + b1.AddRepeatedInt32(2); + b1.SetOptionalForeignMessage(ForeignMessage.DefaultInstance); + + TestAllTypes m1 = b1.Build(); + + b1.SetDefaultInt32(5); + b1.AddRepeatedInt32(6); + b1.SetOptionalForeignMessage(b1.OptionalForeignMessage.ToBuilder().SetC(7)); + + TestAllTypes m2 = b1.Build(); + + Assert.AreEqual("{\"optional_foreign_message\":{},\"repeated_int32\":[2],\"default_int32\":1}", m1.ToJson()); + Assert.AreEqual("{\"optional_foreign_message\":{\"c\":7},\"repeated_int32\":[2,6],\"default_int32\":5}", m2.ToJson()); + } + + [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 CloneOnGetRepeatedBoolList() + { + TestAllTypes.Builder builder = TestAllTypes.DefaultInstance.ToBuilder(); + Assert.IsTrue(ReferenceEquals(TestAllTypes.DefaultInstance, builder.Build())); + GC.KeepAlive(builder.RepeatedBoolList); + 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 CloneOnGetRepeatedForeignMessageList() + { + TestAllTypes.Builder builder = TestAllTypes.DefaultInstance.ToBuilder(); + Assert.IsTrue(ReferenceEquals(TestAllTypes.DefaultInstance, builder.Build())); + GC.KeepAlive(builder.RepeatedForeignMessageList); + 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 CloneOnGetRepeatedForeignEnumList() + { + TestAllTypes.Builder builder = TestAllTypes.DefaultInstance.ToBuilder(); + Assert.IsTrue(ReferenceEquals(TestAllTypes.DefaultInstance, builder.Build())); + GC.KeepAlive(builder.RepeatedForeignEnumList); + Assert.IsFalse(ReferenceEquals(TestAllTypes.DefaultInstance, builder.Build())); + } + + } +} diff --git a/src/ProtocolBuffers.Test/TestProtos/UnitTestCSharpOptionsProtoFile.cs b/src/ProtocolBuffers.Test/TestProtos/UnitTestCSharpOptionsProtoFile.cs index 565dc1d078..94ced3d544 100644 --- a/src/ProtocolBuffers.Test/TestProtos/UnitTestCSharpOptionsProtoFile.cs +++ b/src/ProtocolBuffers.Test/TestProtos/UnitTestCSharpOptionsProtoFile.cs @@ -191,7 +191,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()] @@ -201,21 +201,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 { @@ -227,12 +254,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) { @@ -246,6 +272,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; } @@ -264,6 +291,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; @@ -328,11 +356,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; @@ -347,11 +377,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; @@ -366,11 +398,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 fc22c716a7..a3265da756 100644 --- a/src/ProtocolBuffers.Test/TestProtos/UnitTestCustomOptionsProtoFile.cs +++ b/src/ProtocolBuffers.Test/TestProtos/UnitTestCustomOptionsProtoFile.cs @@ -514,7 +514,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()] @@ -524,21 +524,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 { @@ -550,12 +577,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) { @@ -569,6 +595,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; } @@ -581,6 +608,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; @@ -637,11 +665,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; @@ -739,7 +769,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()] @@ -749,21 +779,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 { @@ -775,12 +832,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) { @@ -794,6 +850,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; } @@ -803,6 +860,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; @@ -938,7 +996,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()] @@ -948,21 +1006,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 { @@ -974,12 +1059,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) { @@ -993,6 +1077,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; } @@ -1002,6 +1087,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; @@ -1152,7 +1238,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()] @@ -1162,21 +1248,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 { @@ -1188,12 +1301,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) { @@ -1207,6 +1319,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; } @@ -1216,6 +1329,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; @@ -1351,7 +1465,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()] @@ -1361,21 +1475,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 { @@ -1387,12 +1528,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) { @@ -1406,6 +1546,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; } @@ -1415,6 +1556,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; @@ -1550,7 +1692,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()] @@ -1560,21 +1702,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 { @@ -1586,12 +1755,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) { @@ -1605,6 +1773,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; } @@ -1614,6 +1783,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; @@ -1749,7 +1919,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()] @@ -1759,21 +1929,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 { @@ -1785,12 +1982,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) { @@ -1804,6 +2000,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; } @@ -1813,6 +2010,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; @@ -1948,7 +2146,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()] @@ -1958,21 +2156,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 { @@ -1984,12 +2209,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) { @@ -2003,6 +2227,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; } @@ -2012,6 +2237,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; @@ -2147,7 +2373,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()] @@ -2157,21 +2383,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 { @@ -2183,12 +2436,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) { @@ -2202,6 +2454,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; } @@ -2211,6 +2464,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; @@ -2346,7 +2600,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()] @@ -2356,21 +2610,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 { @@ -2382,12 +2663,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) { @@ -2401,6 +2681,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; } @@ -2410,6 +2691,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; @@ -2597,7 +2879,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()] @@ -2607,21 +2889,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 { @@ -2633,12 +2942,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) { @@ -2652,6 +2960,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; } @@ -2671,6 +2980,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; @@ -2734,11 +3044,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; @@ -2752,11 +3064,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; @@ -2770,11 +3084,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; @@ -2923,7 +3239,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()] @@ -2933,21 +3249,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 { @@ -2959,12 +3302,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) { @@ -2978,6 +3320,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; } @@ -2990,6 +3333,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; @@ -3045,11 +3389,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; @@ -3177,7 +3523,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()] @@ -3187,21 +3533,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 { @@ -3213,12 +3586,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) { @@ -3232,6 +3604,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); } @@ -3251,6 +3624,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; @@ -3325,18 +3699,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(); @@ -3347,6 +3724,7 @@ namespace Google.ProtocolBuffers.TestProtos { return this; } public Builder ClearBar() { + PrepareBuilder(); result.hasBar = false; result.bar_ = global::Google.ProtocolBuffers.TestProtos.ComplexOptionType1.DefaultInstance; return this; @@ -3360,11 +3738,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; @@ -3379,18 +3759,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(); @@ -3401,6 +3784,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; @@ -3547,7 +3931,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()] @@ -3557,21 +3941,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 { @@ -3583,12 +3994,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) { @@ -3602,6 +4012,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; } @@ -3614,6 +4025,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; @@ -3669,11 +4081,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; @@ -3778,7 +4192,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()] @@ -3788,21 +4202,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 { @@ -3814,12 +4255,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) { @@ -3833,6 +4273,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; } @@ -3848,6 +4289,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; @@ -3912,11 +4354,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; @@ -3931,18 +4375,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(); @@ -3953,6 +4400,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; @@ -4066,7 +4514,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()] @@ -4076,21 +4524,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 { @@ -4102,12 +4577,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) { @@ -4121,6 +4595,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; } @@ -4133,6 +4608,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; @@ -4188,11 +4664,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; @@ -4290,7 +4768,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()] @@ -4300,21 +4778,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 { @@ -4326,12 +4831,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) { @@ -4345,6 +4849,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; } @@ -4354,6 +4859,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 149f218271..9af43135bd 100644 --- a/src/ProtocolBuffers.Test/TestProtos/UnitTestEmbedOptimizeForProtoFile.cs +++ b/src/ProtocolBuffers.Test/TestProtos/UnitTestEmbedOptimizeForProtoFile.cs @@ -187,7 +187,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()] @@ -197,21 +197,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 { @@ -223,13 +250,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) { @@ -243,6 +269,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); } @@ -258,6 +285,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; @@ -323,18 +351,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(); @@ -345,13 +376,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 RepeatedMessageList { - get { return result.repeatedMessage_; } + get { return PrepareBuilder().repeatedMessage_; } } public int RepeatedMessageCount { get { return result.RepeatedMessageCount; } @@ -361,29 +393,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 values) { + PrepareBuilder(); result.repeatedMessage_.Add(values); 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 aefa95e1e6..47841404e1 100644 --- a/src/ProtocolBuffers.Test/TestProtos/UnitTestExtrasIssuesProtoFile.cs +++ b/src/ProtocolBuffers.Test/TestProtos/UnitTestExtrasIssuesProtoFile.cs @@ -224,7 +224,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()] @@ -234,21 +234,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; + + private A PrepareBuilder() { + if (builderIsReadOnly) { + A original = result; + result = new A(); + builderIsReadOnly = false; + MergeFrom(original); + } + return result; + } - A result = new A(); + 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 { @@ -260,12 +287,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) { @@ -279,6 +305,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_; } @@ -291,6 +318,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; @@ -346,11 +374,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; @@ -464,7 +494,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()] @@ -474,21 +504,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; + + private B PrepareBuilder() { + if (builderIsReadOnly) { + B original = result; + result = new B(); + builderIsReadOnly = false; + MergeFrom(original); + } + return result; + } - B result = new B(); + 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 { @@ -500,12 +557,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) { @@ -519,6 +575,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_; } @@ -531,6 +588,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; @@ -586,11 +644,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; @@ -704,7 +764,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()] @@ -714,21 +774,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; + + private AB PrepareBuilder() { + if (builderIsReadOnly) { + AB original = result; + result = new AB(); + builderIsReadOnly = false; + MergeFrom(original); + } + return result; + } - AB result = new AB(); + 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 { @@ -740,12 +827,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) { @@ -759,6 +845,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_; } @@ -771,6 +858,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; @@ -826,11 +914,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; @@ -946,7 +1036,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()] @@ -956,21 +1046,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 { @@ -982,12 +1099,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) { @@ -1001,6 +1117,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; } @@ -1013,6 +1130,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; @@ -1070,11 +1188,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; @@ -1241,7 +1361,7 @@ namespace UnitTest.Issues.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); } public override Builder CreateBuilderForType() { return new Builder(); } public static Builder CreateBuilder(NegativeEnumMessage prototype) { - return (Builder) new Builder().MergeFrom(prototype); + return new Builder(prototype); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] @@ -1251,21 +1371,48 @@ namespace UnitTest.Issues.TestProtos { protected override Builder ThisBuilder { get { return this; } } - public Builder() {} + public Builder() { + result = DefaultInstance ?? new NegativeEnumMessage(); + builderIsReadOnly = result == DefaultInstance; + } + internal Builder(NegativeEnumMessage cloneFrom) { + result = cloneFrom; + builderIsReadOnly = true; + } + + bool builderIsReadOnly; + NegativeEnumMessage result; + + private NegativeEnumMessage PrepareBuilder() { + if (builderIsReadOnly) { + NegativeEnumMessage original = result; + result = new NegativeEnumMessage(); + builderIsReadOnly = false; + MergeFrom(original); + } + return result; + } - NegativeEnumMessage result = new NegativeEnumMessage(); + public override bool IsInitialized { + get { return result.IsInitialized; } + } protected override NegativeEnumMessage MessageBeingBuilt { - get { return result; } + get { return PrepareBuilder(); } } public override Builder Clear() { - result = new NegativeEnumMessage(); + result = DefaultInstance ?? new NegativeEnumMessage(); + 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 { @@ -1277,14 +1424,13 @@ namespace UnitTest.Issues.TestProtos { } public override NegativeEnumMessage BuildPartial() { - if (result == null) { - throw new global::System.InvalidOperationException("build() has already been called on this Builder"); + if (builderIsReadOnly) { + return result; } result.values_.MakeReadOnly(); result.packedValues_.MakeReadOnly(); - NegativeEnumMessage returnMe = result; - result = null; - return returnMe; + builderIsReadOnly = true; + return result; } public override Builder MergeFrom(pb::IMessage other) { @@ -1298,6 +1444,7 @@ namespace UnitTest.Issues.TestProtos { public override Builder MergeFrom(NegativeEnumMessage other) { if (other == global::UnitTest.Issues.TestProtos.NegativeEnumMessage.DefaultInstance) return this; + PrepareBuilder(); if (other.HasValue) { Value = other.Value; } @@ -1316,6 +1463,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; @@ -1407,18 +1555,20 @@ namespace UnitTest.Issues.TestProtos { set { SetValue(value); } } public Builder SetValue(global::UnitTest.Issues.TestProtos.NegativeEnum value) { + PrepareBuilder(); result.hasValue = true; result.value_ = value; return this; } public Builder ClearValue() { + PrepareBuilder(); result.hasValue = false; result.value_ = global::UnitTest.Issues.TestProtos.NegativeEnum.FiveBelow; return this; } public pbc::IPopsicleList ValuesList { - get { return result.values_; } + get { return PrepareBuilder().values_; } } public int ValuesCount { get { return result.ValuesCount; } @@ -1427,24 +1577,28 @@ namespace UnitTest.Issues.TestProtos { return result.GetValues(index); } public Builder SetValues(int index, global::UnitTest.Issues.TestProtos.NegativeEnum value) { + PrepareBuilder(); result.values_[index] = value; return this; } public Builder AddValues(global::UnitTest.Issues.TestProtos.NegativeEnum value) { + PrepareBuilder(); result.values_.Add(value); return this; } public Builder AddRangeValues(scg::IEnumerable values) { + PrepareBuilder(); result.values_.Add(values); return this; } public Builder ClearValues() { + PrepareBuilder(); result.values_.Clear(); return this; } public pbc::IPopsicleList PackedValuesList { - get { return result.packedValues_; } + get { return PrepareBuilder().packedValues_; } } public int PackedValuesCount { get { return result.PackedValuesCount; } @@ -1453,18 +1607,22 @@ namespace UnitTest.Issues.TestProtos { return result.GetPackedValues(index); } public Builder SetPackedValues(int index, global::UnitTest.Issues.TestProtos.NegativeEnum value) { + PrepareBuilder(); result.packedValues_[index] = value; return this; } public Builder AddPackedValues(global::UnitTest.Issues.TestProtos.NegativeEnum value) { + PrepareBuilder(); result.packedValues_.Add(value); return this; } public Builder AddRangePackedValues(scg::IEnumerable values) { + PrepareBuilder(); result.packedValues_.Add(values); return this; } public Builder ClearPackedValues() { + PrepareBuilder(); result.packedValues_.Clear(); return this; } @@ -1561,7 +1719,7 @@ namespace UnitTest.Issues.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); } public override Builder CreateBuilderForType() { return new Builder(); } public static Builder CreateBuilder(DeprecatedChild prototype) { - return (Builder) new Builder().MergeFrom(prototype); + return new Builder(prototype); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] @@ -1571,21 +1729,48 @@ namespace UnitTest.Issues.TestProtos { protected override Builder ThisBuilder { get { return this; } } - public Builder() {} + public Builder() { + result = DefaultInstance ?? new DeprecatedChild(); + builderIsReadOnly = result == DefaultInstance; + } + internal Builder(DeprecatedChild cloneFrom) { + result = cloneFrom; + builderIsReadOnly = true; + } - DeprecatedChild result = new DeprecatedChild(); + bool builderIsReadOnly; + DeprecatedChild result; + + private DeprecatedChild PrepareBuilder() { + if (builderIsReadOnly) { + DeprecatedChild original = result; + result = new DeprecatedChild(); + builderIsReadOnly = false; + MergeFrom(original); + } + return result; + } + + public override bool IsInitialized { + get { return result.IsInitialized; } + } protected override DeprecatedChild MessageBeingBuilt { - get { return result; } + get { return PrepareBuilder(); } } public override Builder Clear() { - result = new DeprecatedChild(); + result = DefaultInstance ?? new DeprecatedChild(); + 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 { @@ -1597,12 +1782,11 @@ namespace UnitTest.Issues.TestProtos { } public override DeprecatedChild BuildPartial() { - if (result == null) { - throw new global::System.InvalidOperationException("build() has already been called on this Builder"); + if (builderIsReadOnly) { + return result; } - DeprecatedChild returnMe = result; - result = null; - return returnMe; + builderIsReadOnly = true; + return result; } public override Builder MergeFrom(pb::IMessage other) { @@ -1616,6 +1800,7 @@ namespace UnitTest.Issues.TestProtos { public override Builder MergeFrom(DeprecatedChild other) { if (other == global::UnitTest.Issues.TestProtos.DeprecatedChild.DefaultInstance) return this; + PrepareBuilder(); this.MergeUnknownFields(other.UnknownFields); return this; } @@ -1625,6 +1810,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; @@ -1889,7 +2075,7 @@ namespace UnitTest.Issues.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); } public override Builder CreateBuilderForType() { return new Builder(); } public static Builder CreateBuilder(DeprecatedFieldsMessage prototype) { - return (Builder) new Builder().MergeFrom(prototype); + return new Builder(prototype); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] @@ -1899,21 +2085,48 @@ namespace UnitTest.Issues.TestProtos { protected override Builder ThisBuilder { get { return this; } } - public Builder() {} + public Builder() { + result = DefaultInstance ?? new DeprecatedFieldsMessage(); + builderIsReadOnly = result == DefaultInstance; + } + internal Builder(DeprecatedFieldsMessage cloneFrom) { + result = cloneFrom; + builderIsReadOnly = true; + } - DeprecatedFieldsMessage result = new DeprecatedFieldsMessage(); + bool builderIsReadOnly; + DeprecatedFieldsMessage result; + + private DeprecatedFieldsMessage PrepareBuilder() { + if (builderIsReadOnly) { + DeprecatedFieldsMessage original = result; + result = new DeprecatedFieldsMessage(); + builderIsReadOnly = false; + MergeFrom(original); + } + return result; + } + + public override bool IsInitialized { + get { return result.IsInitialized; } + } protected override DeprecatedFieldsMessage MessageBeingBuilt { - get { return result; } + get { return PrepareBuilder(); } } public override Builder Clear() { - result = new DeprecatedFieldsMessage(); + result = DefaultInstance ?? new DeprecatedFieldsMessage(); + 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 { @@ -1925,15 +2138,14 @@ namespace UnitTest.Issues.TestProtos { } public override DeprecatedFieldsMessage BuildPartial() { - if (result == null) { - throw new global::System.InvalidOperationException("build() has already been called on this Builder"); + if (builderIsReadOnly) { + return result; } result.primitiveArray_.MakeReadOnly(); result.messageArray_.MakeReadOnly(); result.enumArray_.MakeReadOnly(); - DeprecatedFieldsMessage returnMe = result; - result = null; - return returnMe; + builderIsReadOnly = true; + return result; } public override Builder MergeFrom(pb::IMessage other) { @@ -1947,6 +2159,7 @@ namespace UnitTest.Issues.TestProtos { public override Builder MergeFrom(DeprecatedFieldsMessage other) { if (other == global::UnitTest.Issues.TestProtos.DeprecatedFieldsMessage.DefaultInstance) return this; + PrepareBuilder(); if (other.HasPrimitiveValue) { PrimitiveValue = other.PrimitiveValue; } @@ -1974,6 +2187,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; @@ -2076,12 +2290,14 @@ namespace UnitTest.Issues.TestProtos { } [global::System.ObsoleteAttribute()] public Builder SetPrimitiveValue(int value) { + PrepareBuilder(); result.hasPrimitiveValue = true; result.primitiveValue_ = value; return this; } [global::System.ObsoleteAttribute()] public Builder ClearPrimitiveValue() { + PrepareBuilder(); result.hasPrimitiveValue = false; result.primitiveValue_ = 0; return this; @@ -2089,7 +2305,7 @@ namespace UnitTest.Issues.TestProtos { [global::System.ObsoleteAttribute()] public pbc::IPopsicleList PrimitiveArrayList { - get { return result.primitiveArray_; } + get { return PrepareBuilder().primitiveArray_; } } [global::System.ObsoleteAttribute()] public int PrimitiveArrayCount { @@ -2101,21 +2317,25 @@ namespace UnitTest.Issues.TestProtos { } [global::System.ObsoleteAttribute()] public Builder SetPrimitiveArray(int index, int value) { + PrepareBuilder(); result.primitiveArray_[index] = value; return this; } [global::System.ObsoleteAttribute()] public Builder AddPrimitiveArray(int value) { + PrepareBuilder(); result.primitiveArray_.Add(value); return this; } [global::System.ObsoleteAttribute()] public Builder AddRangePrimitiveArray(scg::IEnumerable values) { + PrepareBuilder(); result.primitiveArray_.Add(values); return this; } [global::System.ObsoleteAttribute()] public Builder ClearPrimitiveArray() { + PrepareBuilder(); result.primitiveArray_.Clear(); return this; } @@ -2132,6 +2352,7 @@ namespace UnitTest.Issues.TestProtos { [global::System.ObsoleteAttribute()] public Builder SetMessageValue(global::UnitTest.Issues.TestProtos.DeprecatedChild value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.hasMessageValue = true; result.messageValue_ = value; return this; @@ -2139,6 +2360,7 @@ namespace UnitTest.Issues.TestProtos { [global::System.ObsoleteAttribute()] public Builder SetMessageValue(global::UnitTest.Issues.TestProtos.DeprecatedChild.Builder builderForValue) { pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); + PrepareBuilder(); result.hasMessageValue = true; result.messageValue_ = builderForValue.Build(); return this; @@ -2146,6 +2368,7 @@ namespace UnitTest.Issues.TestProtos { [global::System.ObsoleteAttribute()] public Builder MergeMessageValue(global::UnitTest.Issues.TestProtos.DeprecatedChild value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); if (result.hasMessageValue && result.messageValue_ != global::UnitTest.Issues.TestProtos.DeprecatedChild.DefaultInstance) { result.messageValue_ = global::UnitTest.Issues.TestProtos.DeprecatedChild.CreateBuilder(result.messageValue_).MergeFrom(value).BuildPartial(); @@ -2157,6 +2380,7 @@ namespace UnitTest.Issues.TestProtos { } [global::System.ObsoleteAttribute()] public Builder ClearMessageValue() { + PrepareBuilder(); result.hasMessageValue = false; result.messageValue_ = global::UnitTest.Issues.TestProtos.DeprecatedChild.DefaultInstance; return this; @@ -2164,7 +2388,7 @@ namespace UnitTest.Issues.TestProtos { [global::System.ObsoleteAttribute()] public pbc::IPopsicleList MessageArrayList { - get { return result.messageArray_; } + get { return PrepareBuilder().messageArray_; } } [global::System.ObsoleteAttribute()] public int MessageArrayCount { @@ -2177,34 +2401,40 @@ namespace UnitTest.Issues.TestProtos { [global::System.ObsoleteAttribute()] public Builder SetMessageArray(int index, global::UnitTest.Issues.TestProtos.DeprecatedChild value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.messageArray_[index] = value; return this; } [global::System.ObsoleteAttribute()] public Builder SetMessageArray(int index, global::UnitTest.Issues.TestProtos.DeprecatedChild.Builder builderForValue) { pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); + PrepareBuilder(); result.messageArray_[index] = builderForValue.Build(); return this; } [global::System.ObsoleteAttribute()] public Builder AddMessageArray(global::UnitTest.Issues.TestProtos.DeprecatedChild value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.messageArray_.Add(value); return this; } [global::System.ObsoleteAttribute()] public Builder AddMessageArray(global::UnitTest.Issues.TestProtos.DeprecatedChild.Builder builderForValue) { pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); + PrepareBuilder(); result.messageArray_.Add(builderForValue.Build()); return this; } [global::System.ObsoleteAttribute()] public Builder AddRangeMessageArray(scg::IEnumerable values) { + PrepareBuilder(); result.messageArray_.Add(values); return this; } [global::System.ObsoleteAttribute()] public Builder ClearMessageArray() { + PrepareBuilder(); result.messageArray_.Clear(); return this; } @@ -2220,12 +2450,14 @@ namespace UnitTest.Issues.TestProtos { } [global::System.ObsoleteAttribute()] public Builder SetEnumValue(global::UnitTest.Issues.TestProtos.DeprecatedEnum value) { + PrepareBuilder(); result.hasEnumValue = true; result.enumValue_ = value; return this; } [global::System.ObsoleteAttribute()] public Builder ClearEnumValue() { + PrepareBuilder(); result.hasEnumValue = false; result.enumValue_ = global::UnitTest.Issues.TestProtos.DeprecatedEnum.one; return this; @@ -2233,7 +2465,7 @@ namespace UnitTest.Issues.TestProtos { [global::System.ObsoleteAttribute()] public pbc::IPopsicleList EnumArrayList { - get { return result.enumArray_; } + get { return PrepareBuilder().enumArray_; } } [global::System.ObsoleteAttribute()] public int EnumArrayCount { @@ -2245,21 +2477,25 @@ namespace UnitTest.Issues.TestProtos { } [global::System.ObsoleteAttribute()] public Builder SetEnumArray(int index, global::UnitTest.Issues.TestProtos.DeprecatedEnum value) { + PrepareBuilder(); result.enumArray_[index] = value; return this; } [global::System.ObsoleteAttribute()] public Builder AddEnumArray(global::UnitTest.Issues.TestProtos.DeprecatedEnum value) { + PrepareBuilder(); result.enumArray_.Add(value); return this; } [global::System.ObsoleteAttribute()] public Builder AddRangeEnumArray(scg::IEnumerable values) { + PrepareBuilder(); result.enumArray_.Add(values); return this; } [global::System.ObsoleteAttribute()] public Builder ClearEnumArray() { + PrepareBuilder(); result.enumArray_.Clear(); return this; } diff --git a/src/ProtocolBuffers.Test/TestProtos/UnitTestGoogleSizeProtoFile.cs b/src/ProtocolBuffers.Test/TestProtos/UnitTestGoogleSizeProtoFile.cs index e38fe00785..9ba1919ed8 100644 --- a/src/ProtocolBuffers.Test/TestProtos/UnitTestGoogleSizeProtoFile.cs +++ b/src/ProtocolBuffers.Test/TestProtos/UnitTestGoogleSizeProtoFile.cs @@ -607,7 +607,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()] @@ -617,21 +617,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 { @@ -643,13 +670,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; } @@ -662,11 +688,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; @@ -681,11 +709,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; @@ -700,11 +730,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; @@ -718,11 +750,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; @@ -736,11 +770,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; @@ -754,11 +790,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; @@ -772,11 +810,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; @@ -790,11 +830,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; @@ -808,11 +850,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; @@ -826,11 +870,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; @@ -845,11 +891,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; @@ -857,7 +905,7 @@ namespace Google.ProtocolBuffers.TestProtos { [global::System.CLSCompliant(false)] public pbc::IPopsicleList Field5List { - get { return result.field5_; } + get { return PrepareBuilder().field5_; } } public int Field5Count { get { return result.Field5Count; } @@ -868,20 +916,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 values) { + PrepareBuilder(); result.field5_.Add(values); return this; } public Builder ClearField5() { + PrepareBuilder(); result.field5_.Clear(); return this; } @@ -894,11 +946,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; @@ -913,11 +967,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; @@ -931,11 +987,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; @@ -949,11 +1007,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; @@ -967,11 +1027,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; @@ -985,11 +1047,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; @@ -1003,11 +1067,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; @@ -1021,11 +1087,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; @@ -1039,11 +1107,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; @@ -1057,11 +1127,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; @@ -1075,11 +1147,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; @@ -1094,11 +1168,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; @@ -1113,11 +1189,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; @@ -1131,11 +1209,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; @@ -1149,11 +1229,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; @@ -1167,11 +1249,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; @@ -1185,11 +1269,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; @@ -1203,11 +1289,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; @@ -1221,11 +1309,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; @@ -1239,11 +1329,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; @@ -1257,11 +1349,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; @@ -1275,11 +1369,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; @@ -1294,18 +1390,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(); @@ -1316,6 +1415,7 @@ namespace Google.ProtocolBuffers.TestProtos { return this; } public Builder ClearField15() { + PrepareBuilder(); result.hasField15 = false; result.field15_ = global::Google.ProtocolBuffers.TestProtos.SizeMessage1SubMessage.DefaultInstance; return this; @@ -1329,11 +1429,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; @@ -1347,11 +1449,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; @@ -1365,11 +1469,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; @@ -1383,11 +1489,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; @@ -1402,11 +1510,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; @@ -1420,11 +1530,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; @@ -1699,7 +1811,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()] @@ -1709,21 +1821,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 { @@ -1735,12 +1874,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; } @@ -1752,11 +1890,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; @@ -1770,11 +1910,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; @@ -1788,11 +1930,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; @@ -1807,11 +1951,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; @@ -1825,11 +1971,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; @@ -1843,11 +1991,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; @@ -1861,11 +2011,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; @@ -1879,11 +2031,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; @@ -1897,11 +2051,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; @@ -1915,11 +2071,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; @@ -1933,11 +2091,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; @@ -1953,11 +2113,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; @@ -1971,11 +2133,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; @@ -1989,11 +2153,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; @@ -2007,11 +2173,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; @@ -2027,11 +2195,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; @@ -2045,11 +2215,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; @@ -2064,11 +2236,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; @@ -2084,11 +2258,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; @@ -2104,11 +2280,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; @@ -2377,7 +2555,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()] @@ -2387,21 +2565,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 { @@ -2413,15 +2618,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; } @@ -2433,11 +2637,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; @@ -2451,11 +2657,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; @@ -2470,11 +2678,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; @@ -2489,18 +2699,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 Field14List { - get { return result.field14_; } + get { return PrepareBuilder().field14_; } } public int Field14Count { get { return result.Field14Count; } @@ -2510,19 +2722,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 values) { + PrepareBuilder(); result.field14_.Add(values); return this; } public Builder ClearField14() { + PrepareBuilder(); result.field14_.Clear(); return this; } @@ -2537,11 +2753,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; @@ -2555,11 +2773,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; @@ -2574,11 +2794,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; @@ -2592,11 +2814,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; @@ -2611,11 +2835,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; @@ -2630,18 +2856,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 Field22List { - get { return result.field22_; } + get { return PrepareBuilder().field22_; } } public int Field22Count { get { return result.Field22Count; } @@ -2651,25 +2879,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 values) { + PrepareBuilder(); result.field22_.Add(values); return this; } public Builder ClearField22() { + PrepareBuilder(); result.field22_.Clear(); return this; } public pbc::IPopsicleList Field73List { - get { return result.field73_; } + get { return PrepareBuilder().field73_; } } public int Field73Count { get { return result.Field73Count; } @@ -2678,18 +2910,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 values) { + PrepareBuilder(); result.field73_.Add(values); return this; } public Builder ClearField73() { + PrepareBuilder(); result.field73_.Clear(); return this; } @@ -2702,11 +2938,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; @@ -2721,11 +2959,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; @@ -2740,18 +2980,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(); @@ -2762,6 +3005,7 @@ namespace Google.ProtocolBuffers.TestProtos { return this; } public Builder ClearField31() { + PrepareBuilder(); result.hasField31 = false; result.field31_ = global::Google.ProtocolBuffers.TestProtos.SizeMessage2GroupedMessage.DefaultInstance; return this; @@ -3117,7 +3361,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()] @@ -3127,21 +3371,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 { @@ -3153,16 +3424,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; } @@ -3175,11 +3445,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; @@ -3193,11 +3465,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; @@ -3211,11 +3485,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; @@ -3229,11 +3505,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; @@ -3247,11 +3525,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; @@ -3266,11 +3546,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; @@ -3285,11 +3567,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; @@ -3303,11 +3587,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; @@ -3321,11 +3607,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; @@ -3339,11 +3627,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; @@ -3357,11 +3647,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; @@ -3375,11 +3667,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; @@ -3393,11 +3687,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; @@ -3411,11 +3707,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; @@ -3429,11 +3727,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; @@ -3447,11 +3747,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; @@ -3465,11 +3767,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; @@ -3483,11 +3787,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; @@ -3501,11 +3807,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; @@ -3519,11 +3827,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; @@ -3537,11 +3847,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; @@ -3555,18 +3867,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 Group1List { - get { return result.group1_; } + get { return PrepareBuilder().group1_; } } public int Group1Count { get { return result.Group1Count; } @@ -3576,35 +3890,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 values) { + PrepareBuilder(); result.group1_.Add(values); return this; } public Builder ClearGroup1() { + PrepareBuilder(); result.group1_.Clear(); return this; } public pbc::IPopsicleList Field128List { - get { return result.field128_; } + get { return PrepareBuilder().field128_; } } public int Field128Count { get { return result.Field128Count; } @@ -3614,19 +3934,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 values) { + PrepareBuilder(); result.field128_.Add(values); return this; } public Builder ClearField128() { + PrepareBuilder(); result.field128_.Clear(); return this; } @@ -3639,18 +3963,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 Field127List { - get { return result.field127_; } + get { return PrepareBuilder().field127_; } } public int Field127Count { get { return result.Field127Count; } @@ -3660,19 +3986,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 values) { + PrepareBuilder(); result.field127_.Add(values); return this; } public Builder ClearField127() { + PrepareBuilder(); result.field127_.Clear(); return this; } @@ -3685,18 +4015,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 Field130List { - get { return result.field130_; } + get { return PrepareBuilder().field130_; } } public int Field130Count { get { return result.Field130Count; } @@ -3705,18 +4037,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 values) { + PrepareBuilder(); result.field130_.Add(values); return this; } public Builder ClearField130() { + PrepareBuilder(); result.field130_.Clear(); return this; } @@ -3729,11 +4065,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; @@ -3747,11 +4085,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; @@ -3932,7 +4272,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()] @@ -3942,21 +4282,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 { @@ -3968,12 +4335,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; } @@ -3985,11 +4351,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; @@ -4003,11 +4371,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; @@ -4021,11 +4391,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; @@ -4039,11 +4411,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; @@ -4057,11 +4431,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; @@ -4075,11 +4451,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; @@ -4093,11 +4471,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; @@ -4111,11 +4491,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; @@ -4129,11 +4511,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; @@ -4147,11 +4531,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; @@ -4165,11 +4551,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 93589ecfee..496fb43699 100644 --- a/src/ProtocolBuffers.Test/TestProtos/UnitTestGoogleSpeedProtoFile.cs +++ b/src/ProtocolBuffers.Test/TestProtos/UnitTestGoogleSpeedProtoFile.cs @@ -886,7 +886,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()] @@ -896,21 +896,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 { @@ -922,13 +949,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) { @@ -942,6 +968,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; } @@ -1074,6 +1101,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; @@ -1296,11 +1324,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; @@ -1315,11 +1345,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; @@ -1334,11 +1366,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; @@ -1352,11 +1386,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; @@ -1370,11 +1406,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; @@ -1388,11 +1426,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; @@ -1406,11 +1446,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; @@ -1424,11 +1466,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; @@ -1442,11 +1486,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; @@ -1460,11 +1506,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; @@ -1479,11 +1527,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; @@ -1491,7 +1541,7 @@ namespace Google.ProtocolBuffers.TestProtos { [global::System.CLSCompliant(false)] public pbc::IPopsicleList Field5List { - get { return result.field5_; } + get { return PrepareBuilder().field5_; } } public int Field5Count { get { return result.Field5Count; } @@ -1502,20 +1552,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 values) { + PrepareBuilder(); result.field5_.Add(values); return this; } public Builder ClearField5() { + PrepareBuilder(); result.field5_.Clear(); return this; } @@ -1528,11 +1582,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; @@ -1547,11 +1603,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; @@ -1565,11 +1623,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; @@ -1583,11 +1643,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; @@ -1601,11 +1663,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; @@ -1619,11 +1683,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; @@ -1637,11 +1703,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; @@ -1655,11 +1723,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; @@ -1673,11 +1743,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; @@ -1691,11 +1763,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; @@ -1709,11 +1783,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; @@ -1728,11 +1804,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; @@ -1747,11 +1825,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; @@ -1765,11 +1845,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; @@ -1783,11 +1865,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; @@ -1801,11 +1885,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; @@ -1819,11 +1905,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; @@ -1837,11 +1925,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; @@ -1855,11 +1945,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; @@ -1873,11 +1965,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; @@ -1891,11 +1985,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; @@ -1909,11 +2005,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; @@ -1928,18 +2026,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(); @@ -1950,6 +2051,7 @@ namespace Google.ProtocolBuffers.TestProtos { return this; } public Builder ClearField15() { + PrepareBuilder(); result.hasField15 = false; result.field15_ = global::Google.ProtocolBuffers.TestProtos.SpeedMessage1SubMessage.DefaultInstance; return this; @@ -1963,11 +2065,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; @@ -1981,11 +2085,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; @@ -1999,11 +2105,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; @@ -2017,11 +2125,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; @@ -2036,11 +2146,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; @@ -2054,11 +2166,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; @@ -2480,7 +2594,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()] @@ -2490,21 +2604,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 { @@ -2516,12 +2657,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) { @@ -2535,6 +2675,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; } @@ -2604,6 +2745,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; @@ -2735,11 +2877,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; @@ -2753,11 +2897,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; @@ -2771,11 +2917,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; @@ -2790,11 +2938,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; @@ -2808,11 +2958,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; @@ -2826,11 +2978,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; @@ -2844,11 +2998,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; @@ -2862,11 +3018,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; @@ -2880,11 +3038,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; @@ -2898,11 +3058,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; @@ -2916,11 +3078,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; @@ -2936,11 +3100,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; @@ -2954,11 +3120,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; @@ -2972,11 +3140,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; @@ -2990,11 +3160,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; @@ -3010,11 +3182,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; @@ -3028,11 +3202,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; @@ -3047,11 +3223,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; @@ -3067,11 +3245,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; @@ -3087,11 +3267,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; @@ -3502,7 +3684,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()] @@ -3512,21 +3694,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 { @@ -3538,15 +3747,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) { @@ -3560,6 +3768,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; } @@ -3617,6 +3826,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; @@ -3738,11 +3948,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; @@ -3756,11 +3968,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; @@ -3775,11 +3989,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; @@ -3794,18 +4010,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 Field14List { - get { return result.field14_; } + get { return PrepareBuilder().field14_; } } public int Field14Count { get { return result.Field14Count; } @@ -3815,19 +4033,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 values) { + PrepareBuilder(); result.field14_.Add(values); return this; } public Builder ClearField14() { + PrepareBuilder(); result.field14_.Clear(); return this; } @@ -3842,11 +4064,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; @@ -3860,11 +4084,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; @@ -3879,11 +4105,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; @@ -3897,11 +4125,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; @@ -3916,11 +4146,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; @@ -3935,18 +4167,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 Field22List { - get { return result.field22_; } + get { return PrepareBuilder().field22_; } } public int Field22Count { get { return result.Field22Count; } @@ -3956,25 +4190,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 values) { + PrepareBuilder(); result.field22_.Add(values); return this; } public Builder ClearField22() { + PrepareBuilder(); result.field22_.Clear(); return this; } public pbc::IPopsicleList Field73List { - get { return result.field73_; } + get { return PrepareBuilder().field73_; } } public int Field73Count { get { return result.Field73Count; } @@ -3983,18 +4221,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 values) { + PrepareBuilder(); result.field73_.Add(values); return this; } public Builder ClearField73() { + PrepareBuilder(); result.field73_.Clear(); return this; } @@ -4007,11 +4249,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; @@ -4026,11 +4270,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; @@ -4045,18 +4291,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(); @@ -4067,6 +4316,7 @@ namespace Google.ProtocolBuffers.TestProtos { return this; } public Builder ClearField31() { + PrepareBuilder(); result.hasField31 = false; result.field31_ = global::Google.ProtocolBuffers.TestProtos.SpeedMessage2GroupedMessage.DefaultInstance; return this; @@ -4642,7 +4892,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()] @@ -4652,21 +4902,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 { @@ -4678,16 +4955,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) { @@ -4701,6 +4977,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; } @@ -4800,6 +5077,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; @@ -4973,11 +5251,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; @@ -4991,11 +5271,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; @@ -5009,11 +5291,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; @@ -5027,11 +5311,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; @@ -5045,11 +5331,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; @@ -5064,11 +5352,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; @@ -5083,11 +5373,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; @@ -5101,11 +5393,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; @@ -5119,11 +5413,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; @@ -5137,11 +5433,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; @@ -5155,11 +5453,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; @@ -5173,11 +5473,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; @@ -5191,11 +5493,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; @@ -5209,11 +5513,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; @@ -5227,11 +5533,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; @@ -5245,11 +5553,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; @@ -5263,11 +5573,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; @@ -5281,11 +5593,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; @@ -5299,11 +5613,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; @@ -5317,11 +5633,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; @@ -5335,11 +5653,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; @@ -5353,18 +5673,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 Group1List { - get { return result.group1_; } + get { return PrepareBuilder().group1_; } } public int Group1Count { get { return result.Group1Count; } @@ -5374,35 +5696,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 values) { + PrepareBuilder(); result.group1_.Add(values); return this; } public Builder ClearGroup1() { + PrepareBuilder(); result.group1_.Clear(); return this; } public pbc::IPopsicleList Field128List { - get { return result.field128_; } + get { return PrepareBuilder().field128_; } } public int Field128Count { get { return result.Field128Count; } @@ -5412,19 +5740,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 values) { + PrepareBuilder(); result.field128_.Add(values); return this; } public Builder ClearField128() { + PrepareBuilder(); result.field128_.Clear(); return this; } @@ -5437,18 +5769,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 Field127List { - get { return result.field127_; } + get { return PrepareBuilder().field127_; } } public int Field127Count { get { return result.Field127Count; } @@ -5458,19 +5792,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 values) { + PrepareBuilder(); result.field127_.Add(values); return this; } public Builder ClearField127() { + PrepareBuilder(); result.field127_.Clear(); return this; } @@ -5483,18 +5821,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 Field130List { - get { return result.field130_; } + get { return PrepareBuilder().field130_; } } public int Field130Count { get { return result.Field130Count; } @@ -5503,18 +5843,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 values) { + PrepareBuilder(); result.field130_.Add(values); return this; } public Builder ClearField130() { + PrepareBuilder(); result.field130_.Clear(); return this; } @@ -5527,11 +5871,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; @@ -5545,11 +5891,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; @@ -5823,7 +6171,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()] @@ -5833,21 +6181,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 { @@ -5859,12 +6234,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) { @@ -5878,6 +6252,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; } @@ -5920,6 +6295,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; @@ -6015,11 +6391,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; @@ -6033,11 +6411,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; @@ -6051,11 +6431,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; @@ -6069,11 +6451,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; @@ -6087,11 +6471,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; @@ -6105,11 +6491,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; @@ -6123,11 +6511,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; @@ -6141,11 +6531,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; @@ -6159,11 +6551,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; @@ -6177,11 +6571,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; @@ -6195,11 +6591,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 594c9417b8..98672cf29a 100644 --- a/src/ProtocolBuffers.Test/TestProtos/UnitTestImportLiteProtoFile.cs +++ b/src/ProtocolBuffers.Test/TestProtos/UnitTestImportLiteProtoFile.cs @@ -151,7 +151,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()] @@ -161,21 +161,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 { @@ -183,12 +210,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) { @@ -202,6 +228,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; } @@ -213,6 +240,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)) { @@ -255,11 +283,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 c5da553795..086dda1d45 100644 --- a/src/ProtocolBuffers.Test/TestProtos/UnitTestImportProtoFile.cs +++ b/src/ProtocolBuffers.Test/TestProtos/UnitTestImportProtoFile.cs @@ -170,7 +170,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()] @@ -180,21 +180,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 { @@ -206,12 +233,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) { @@ -225,6 +251,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; } @@ -237,6 +264,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; @@ -292,11 +320,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 590af6d691..6a90612cfb 100644 --- a/src/ProtocolBuffers.Test/TestProtos/UnitTestMessageSetProtoFile.cs +++ b/src/ProtocolBuffers.Test/TestProtos/UnitTestMessageSetProtoFile.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(TestMessageSet 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 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 { @@ -226,12 +253,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) { @@ -245,6 +271,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; @@ -255,6 +282,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; @@ -406,7 +434,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()] @@ -416,21 +444,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 { @@ -442,12 +497,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) { @@ -461,6 +515,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); } @@ -473,6 +528,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; @@ -534,18 +590,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(); @@ -556,6 +615,7 @@ namespace Google.ProtocolBuffers.TestProtos { return this; } public Builder ClearMessageSet() { + PrepareBuilder(); result.hasMessageSet = false; result.messageSet_ = global::Google.ProtocolBuffers.TestProtos.TestMessageSet.DefaultInstance; return this; @@ -671,7 +731,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()] @@ -681,21 +741,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 { @@ -707,12 +794,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) { @@ -726,6 +812,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; } @@ -738,6 +825,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; @@ -793,11 +881,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; @@ -913,7 +1003,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()] @@ -923,21 +1013,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 { @@ -949,12 +1066,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) { @@ -968,6 +1084,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; } @@ -980,6 +1097,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; @@ -1036,11 +1154,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; @@ -1205,7 +1325,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()] @@ -1215,21 +1335,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 { @@ -1241,12 +1388,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) { @@ -1260,6 +1406,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; } @@ -1275,6 +1422,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; @@ -1334,11 +1482,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; @@ -1353,11 +1503,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; @@ -1448,7 +1600,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()] @@ -1458,21 +1610,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 { @@ -1484,13 +1663,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) { @@ -1504,6 +1682,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) { result.item_.Add(other.item_); } @@ -1516,6 +1695,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; @@ -1564,7 +1744,7 @@ namespace Google.ProtocolBuffers.TestProtos { public pbc::IPopsicleList ItemList { - get { return result.item_; } + get { return PrepareBuilder().item_; } } public int ItemCount { get { return result.ItemCount; } @@ -1574,29 +1754,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 values) { + PrepareBuilder(); result.item_.Add(values); 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 5b6528719a..2cd2696b5e 100644 --- a/src/ProtocolBuffers.Test/TestProtos/UnitTestNoGenericServicesProtoFile.cs +++ b/src/ProtocolBuffers.Test/TestProtos/UnitTestNoGenericServicesProtoFile.cs @@ -184,7 +184,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()] @@ -194,21 +194,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 { @@ -220,12 +247,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) { @@ -239,6 +265,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; } @@ -252,6 +279,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; @@ -307,11 +335,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 d436afc88a..10c464a4d2 100644 --- a/src/ProtocolBuffers.Test/TestProtos/UnitTestOptimizeForProtoFile.cs +++ b/src/ProtocolBuffers.Test/TestProtos/UnitTestOptimizeForProtoFile.cs @@ -165,7 +165,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()] @@ -175,21 +175,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 { @@ -201,12 +228,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; } @@ -218,11 +244,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; @@ -237,18 +265,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(); @@ -259,6 +290,7 @@ namespace Google.ProtocolBuffers.TestProtos { return this; } public Builder ClearMsg() { + PrepareBuilder(); result.hasMsg = false; result.msg_ = global::Google.ProtocolBuffers.TestProtos.ForeignMessage.DefaultInstance; return this; @@ -339,7 +371,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()] @@ -349,21 +381,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 { @@ -375,12 +434,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; } @@ -392,11 +450,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; @@ -477,7 +537,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()] @@ -487,21 +547,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 { @@ -513,12 +600,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; } @@ -531,18 +617,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(); @@ -553,6 +642,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 866167430c..547d712aa9 100644 --- a/src/ProtocolBuffers.Test/TestProtos/UnitTestProtoFile.cs +++ b/src/ProtocolBuffers.Test/TestProtos/UnitTestProtoFile.cs @@ -1262,7 +1262,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()] @@ -1272,21 +1272,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 { @@ -1298,12 +1325,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) { @@ -1317,6 +1343,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; } @@ -1329,6 +1356,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; @@ -1384,11 +1412,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; @@ -1502,7 +1532,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()] @@ -1512,21 +1542,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 { @@ -1538,12 +1595,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) { @@ -1557,6 +1613,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; } @@ -1569,6 +1626,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; @@ -1624,11 +1682,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; @@ -1742,7 +1802,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()] @@ -1752,21 +1812,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 { @@ -1778,12 +1865,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) { @@ -1797,6 +1883,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; } @@ -1809,6 +1896,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; @@ -1864,11 +1952,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; @@ -3185,7 +3275,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()] @@ -3195,21 +3285,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 { @@ -3221,8 +3338,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(); @@ -3248,9 +3365,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) { @@ -3264,6 +3380,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; } @@ -3477,6 +3594,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; @@ -3911,11 +4029,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; @@ -3929,11 +4049,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; @@ -3949,11 +4071,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; @@ -3969,11 +4093,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; @@ -3987,11 +4113,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; @@ -4005,11 +4133,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; @@ -4025,11 +4155,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; @@ -4045,11 +4177,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; @@ -4063,11 +4197,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; @@ -4081,11 +4217,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; @@ -4099,11 +4237,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; @@ -4117,11 +4257,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; @@ -4135,11 +4277,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; @@ -4154,11 +4298,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; @@ -4173,11 +4319,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; @@ -4192,18 +4340,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(); @@ -4214,6 +4365,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; @@ -4228,18 +4380,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(); @@ -4250,6 +4405,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; @@ -4264,18 +4420,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(); @@ -4286,6 +4445,7 @@ namespace Google.ProtocolBuffers.TestProtos { return this; } public Builder ClearOptionalForeignMessage() { + PrepareBuilder(); result.hasOptionalForeignMessage = false; result.optionalForeignMessage_ = global::Google.ProtocolBuffers.TestProtos.ForeignMessage.DefaultInstance; return this; @@ -4300,18 +4460,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(); @@ -4322,6 +4485,7 @@ namespace Google.ProtocolBuffers.TestProtos { return this; } public Builder ClearOptionalImportMessage() { + PrepareBuilder(); result.hasOptionalImportMessage = false; result.optionalImportMessage_ = global::Google.ProtocolBuffers.TestProtos.ImportMessage.DefaultInstance; return this; @@ -4335,11 +4499,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; @@ -4353,11 +4519,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; @@ -4371,11 +4539,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; @@ -4390,11 +4560,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; @@ -4409,18 +4581,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 RepeatedInt32List { - get { return result.repeatedInt32_; } + get { return PrepareBuilder().repeatedInt32_; } } public int RepeatedInt32Count { get { return result.RepeatedInt32Count; } @@ -4429,24 +4603,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 values) { + PrepareBuilder(); result.repeatedInt32_.Add(values); return this; } public Builder ClearRepeatedInt32() { + PrepareBuilder(); result.repeatedInt32_.Clear(); return this; } public pbc::IPopsicleList RepeatedInt64List { - get { return result.repeatedInt64_; } + get { return PrepareBuilder().repeatedInt64_; } } public int RepeatedInt64Count { get { return result.RepeatedInt64Count; } @@ -4455,25 +4633,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 values) { + PrepareBuilder(); result.repeatedInt64_.Add(values); return this; } public Builder ClearRepeatedInt64() { + PrepareBuilder(); result.repeatedInt64_.Clear(); return this; } [global::System.CLSCompliant(false)] public pbc::IPopsicleList RepeatedUint32List { - get { return result.repeatedUint32_; } + get { return PrepareBuilder().repeatedUint32_; } } public int RepeatedUint32Count { get { return result.RepeatedUint32Count; } @@ -4484,27 +4666,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 values) { + PrepareBuilder(); result.repeatedUint32_.Add(values); return this; } public Builder ClearRepeatedUint32() { + PrepareBuilder(); result.repeatedUint32_.Clear(); return this; } [global::System.CLSCompliant(false)] public pbc::IPopsicleList RepeatedUint64List { - get { return result.repeatedUint64_; } + get { return PrepareBuilder().repeatedUint64_; } } public int RepeatedUint64Count { get { return result.RepeatedUint64Count; } @@ -4515,26 +4701,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 values) { + PrepareBuilder(); result.repeatedUint64_.Add(values); return this; } public Builder ClearRepeatedUint64() { + PrepareBuilder(); result.repeatedUint64_.Clear(); return this; } public pbc::IPopsicleList RepeatedSint32List { - get { return result.repeatedSint32_; } + get { return PrepareBuilder().repeatedSint32_; } } public int RepeatedSint32Count { get { return result.RepeatedSint32Count; } @@ -4543,24 +4733,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 values) { + PrepareBuilder(); result.repeatedSint32_.Add(values); return this; } public Builder ClearRepeatedSint32() { + PrepareBuilder(); result.repeatedSint32_.Clear(); return this; } public pbc::IPopsicleList RepeatedSint64List { - get { return result.repeatedSint64_; } + get { return PrepareBuilder().repeatedSint64_; } } public int RepeatedSint64Count { get { return result.RepeatedSint64Count; } @@ -4569,25 +4763,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 values) { + PrepareBuilder(); result.repeatedSint64_.Add(values); return this; } public Builder ClearRepeatedSint64() { + PrepareBuilder(); result.repeatedSint64_.Clear(); return this; } [global::System.CLSCompliant(false)] public pbc::IPopsicleList RepeatedFixed32List { - get { return result.repeatedFixed32_; } + get { return PrepareBuilder().repeatedFixed32_; } } public int RepeatedFixed32Count { get { return result.RepeatedFixed32Count; } @@ -4598,27 +4796,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 values) { + PrepareBuilder(); result.repeatedFixed32_.Add(values); return this; } public Builder ClearRepeatedFixed32() { + PrepareBuilder(); result.repeatedFixed32_.Clear(); return this; } [global::System.CLSCompliant(false)] public pbc::IPopsicleList RepeatedFixed64List { - get { return result.repeatedFixed64_; } + get { return PrepareBuilder().repeatedFixed64_; } } public int RepeatedFixed64Count { get { return result.RepeatedFixed64Count; } @@ -4629,26 +4831,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 values) { + PrepareBuilder(); result.repeatedFixed64_.Add(values); return this; } public Builder ClearRepeatedFixed64() { + PrepareBuilder(); result.repeatedFixed64_.Clear(); return this; } public pbc::IPopsicleList RepeatedSfixed32List { - get { return result.repeatedSfixed32_; } + get { return PrepareBuilder().repeatedSfixed32_; } } public int RepeatedSfixed32Count { get { return result.RepeatedSfixed32Count; } @@ -4657,24 +4863,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 values) { + PrepareBuilder(); result.repeatedSfixed32_.Add(values); return this; } public Builder ClearRepeatedSfixed32() { + PrepareBuilder(); result.repeatedSfixed32_.Clear(); return this; } public pbc::IPopsicleList RepeatedSfixed64List { - get { return result.repeatedSfixed64_; } + get { return PrepareBuilder().repeatedSfixed64_; } } public int RepeatedSfixed64Count { get { return result.RepeatedSfixed64Count; } @@ -4683,24 +4893,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 values) { + PrepareBuilder(); result.repeatedSfixed64_.Add(values); return this; } public Builder ClearRepeatedSfixed64() { + PrepareBuilder(); result.repeatedSfixed64_.Clear(); return this; } public pbc::IPopsicleList RepeatedFloatList { - get { return result.repeatedFloat_; } + get { return PrepareBuilder().repeatedFloat_; } } public int RepeatedFloatCount { get { return result.RepeatedFloatCount; } @@ -4709,24 +4923,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 values) { + PrepareBuilder(); result.repeatedFloat_.Add(values); return this; } public Builder ClearRepeatedFloat() { + PrepareBuilder(); result.repeatedFloat_.Clear(); return this; } public pbc::IPopsicleList RepeatedDoubleList { - get { return result.repeatedDouble_; } + get { return PrepareBuilder().repeatedDouble_; } } public int RepeatedDoubleCount { get { return result.RepeatedDoubleCount; } @@ -4735,24 +4953,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 values) { + PrepareBuilder(); result.repeatedDouble_.Add(values); return this; } public Builder ClearRepeatedDouble() { + PrepareBuilder(); result.repeatedDouble_.Clear(); return this; } public pbc::IPopsicleList RepeatedBoolList { - get { return result.repeatedBool_; } + get { return PrepareBuilder().repeatedBool_; } } public int RepeatedBoolCount { get { return result.RepeatedBoolCount; } @@ -4761,24 +4983,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 values) { + PrepareBuilder(); result.repeatedBool_.Add(values); return this; } public Builder ClearRepeatedBool() { + PrepareBuilder(); result.repeatedBool_.Clear(); return this; } public pbc::IPopsicleList RepeatedStringList { - get { return result.repeatedString_; } + get { return PrepareBuilder().repeatedString_; } } public int RepeatedStringCount { get { return result.RepeatedStringCount; } @@ -4788,25 +5014,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 values) { + PrepareBuilder(); result.repeatedString_.Add(values); return this; } public Builder ClearRepeatedString() { + PrepareBuilder(); result.repeatedString_.Clear(); return this; } public pbc::IPopsicleList RepeatedBytesList { - get { return result.repeatedBytes_; } + get { return PrepareBuilder().repeatedBytes_; } } public int RepeatedBytesCount { get { return result.RepeatedBytesCount; } @@ -4816,25 +5046,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 values) { + PrepareBuilder(); result.repeatedBytes_.Add(values); return this; } public Builder ClearRepeatedBytes() { + PrepareBuilder(); result.repeatedBytes_.Clear(); return this; } public pbc::IPopsicleList RepeatedGroupList { - get { return result.repeatedGroup_; } + get { return PrepareBuilder().repeatedGroup_; } } public int RepeatedGroupCount { get { return result.RepeatedGroupCount; } @@ -4844,35 +5078,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 values) { + PrepareBuilder(); result.repeatedGroup_.Add(values); return this; } public Builder ClearRepeatedGroup() { + PrepareBuilder(); result.repeatedGroup_.Clear(); return this; } public pbc::IPopsicleList RepeatedNestedMessageList { - get { return result.repeatedNestedMessage_; } + get { return PrepareBuilder().repeatedNestedMessage_; } } public int RepeatedNestedMessageCount { get { return result.RepeatedNestedMessageCount; } @@ -4882,35 +5122,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 values) { + PrepareBuilder(); result.repeatedNestedMessage_.Add(values); return this; } public Builder ClearRepeatedNestedMessage() { + PrepareBuilder(); result.repeatedNestedMessage_.Clear(); return this; } public pbc::IPopsicleList RepeatedForeignMessageList { - get { return result.repeatedForeignMessage_; } + get { return PrepareBuilder().repeatedForeignMessage_; } } public int RepeatedForeignMessageCount { get { return result.RepeatedForeignMessageCount; } @@ -4920,35 +5166,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 values) { + PrepareBuilder(); result.repeatedForeignMessage_.Add(values); return this; } public Builder ClearRepeatedForeignMessage() { + PrepareBuilder(); result.repeatedForeignMessage_.Clear(); return this; } public pbc::IPopsicleList RepeatedImportMessageList { - get { return result.repeatedImportMessage_; } + get { return PrepareBuilder().repeatedImportMessage_; } } public int RepeatedImportMessageCount { get { return result.RepeatedImportMessageCount; } @@ -4958,35 +5210,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 values) { + PrepareBuilder(); result.repeatedImportMessage_.Add(values); return this; } public Builder ClearRepeatedImportMessage() { + PrepareBuilder(); result.repeatedImportMessage_.Clear(); return this; } public pbc::IPopsicleList RepeatedNestedEnumList { - get { return result.repeatedNestedEnum_; } + get { return PrepareBuilder().repeatedNestedEnum_; } } public int RepeatedNestedEnumCount { get { return result.RepeatedNestedEnumCount; } @@ -4995,24 +5253,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 values) { + PrepareBuilder(); result.repeatedNestedEnum_.Add(values); return this; } public Builder ClearRepeatedNestedEnum() { + PrepareBuilder(); result.repeatedNestedEnum_.Clear(); return this; } public pbc::IPopsicleList RepeatedForeignEnumList { - get { return result.repeatedForeignEnum_; } + get { return PrepareBuilder().repeatedForeignEnum_; } } public int RepeatedForeignEnumCount { get { return result.RepeatedForeignEnumCount; } @@ -5021,24 +5283,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 values) { + PrepareBuilder(); result.repeatedForeignEnum_.Add(values); return this; } public Builder ClearRepeatedForeignEnum() { + PrepareBuilder(); result.repeatedForeignEnum_.Clear(); return this; } public pbc::IPopsicleList RepeatedImportEnumList { - get { return result.repeatedImportEnum_; } + get { return PrepareBuilder().repeatedImportEnum_; } } public int RepeatedImportEnumCount { get { return result.RepeatedImportEnumCount; } @@ -5047,24 +5313,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 values) { + PrepareBuilder(); result.repeatedImportEnum_.Add(values); return this; } public Builder ClearRepeatedImportEnum() { + PrepareBuilder(); result.repeatedImportEnum_.Clear(); return this; } public pbc::IPopsicleList RepeatedStringPieceList { - get { return result.repeatedStringPiece_; } + get { return PrepareBuilder().repeatedStringPiece_; } } public int RepeatedStringPieceCount { get { return result.RepeatedStringPieceCount; } @@ -5074,25 +5344,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 values) { + PrepareBuilder(); result.repeatedStringPiece_.Add(values); return this; } public Builder ClearRepeatedStringPiece() { + PrepareBuilder(); result.repeatedStringPiece_.Clear(); return this; } public pbc::IPopsicleList RepeatedCordList { - get { return result.repeatedCord_; } + get { return PrepareBuilder().repeatedCord_; } } public int RepeatedCordCount { get { return result.RepeatedCordCount; } @@ -5102,19 +5376,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 values) { + PrepareBuilder(); result.repeatedCord_.Add(values); return this; } public Builder ClearRepeatedCord() { + PrepareBuilder(); result.repeatedCord_.Clear(); return this; } @@ -5127,11 +5405,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; @@ -5145,11 +5425,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; @@ -5165,11 +5447,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; @@ -5185,11 +5469,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; @@ -5203,11 +5489,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; @@ -5221,11 +5509,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; @@ -5241,11 +5531,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; @@ -5261,11 +5553,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; @@ -5279,11 +5573,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; @@ -5297,11 +5593,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; @@ -5315,11 +5613,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; @@ -5333,11 +5633,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; @@ -5351,11 +5653,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; @@ -5370,11 +5674,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; @@ -5389,11 +5695,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; @@ -5407,11 +5715,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; @@ -5425,11 +5735,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; @@ -5443,11 +5755,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; @@ -5462,11 +5776,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; @@ -5481,11 +5797,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; @@ -5601,7 +5919,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()] @@ -5611,21 +5929,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 { @@ -5637,12 +5982,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) { @@ -5656,6 +6000,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; } @@ -5668,6 +6013,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; @@ -5726,12 +6072,14 @@ namespace Google.ProtocolBuffers.TestProtos { } [global::System.ObsoleteAttribute()] public Builder SetDeprecatedInt32(int value) { + PrepareBuilder(); result.hasDeprecatedInt32 = true; result.deprecatedInt32_ = value; return this; } [global::System.ObsoleteAttribute()] public Builder ClearDeprecatedInt32() { + PrepareBuilder(); result.hasDeprecatedInt32 = false; result.deprecatedInt32_ = 0; return this; @@ -5845,7 +6193,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()] @@ -5855,21 +6203,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 { @@ -5881,12 +6256,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) { @@ -5900,6 +6274,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; } @@ -5912,6 +6287,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; @@ -5967,11 +6343,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; @@ -6073,7 +6451,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()] @@ -6083,21 +6461,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 { @@ -6109,12 +6514,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) { @@ -6128,6 +6532,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; @@ -6138,6 +6543,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; @@ -6289,7 +6695,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()] @@ -6299,21 +6705,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 { @@ -6325,12 +6758,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) { @@ -6344,6 +6776,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; } @@ -6356,6 +6789,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; @@ -6411,11 +6845,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; @@ -6529,7 +6965,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()] @@ -6539,21 +6975,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 { @@ -6565,12 +7028,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) { @@ -6584,6 +7046,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; } @@ -6596,6 +7059,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; @@ -6651,11 +7115,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; @@ -6755,7 +7221,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()] @@ -6765,21 +7231,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 { @@ -6791,12 +7284,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) { @@ -6810,6 +7302,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; } @@ -6819,6 +7312,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; @@ -7489,7 +7983,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()] @@ -7499,21 +7993,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 { @@ -7525,12 +8046,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) { @@ -7544,6 +8064,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; } @@ -7652,6 +8173,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; @@ -7835,11 +8357,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; @@ -7853,11 +8377,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; @@ -7871,11 +8397,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; @@ -7889,11 +8417,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; @@ -7907,11 +8437,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; @@ -7925,11 +8457,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; @@ -7943,11 +8477,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; @@ -7961,11 +8497,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; @@ -7979,11 +8517,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; @@ -7997,11 +8537,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; @@ -8015,11 +8557,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; @@ -8033,11 +8577,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; @@ -8051,11 +8597,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; @@ -8069,11 +8617,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; @@ -8087,11 +8637,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; @@ -8105,11 +8657,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; @@ -8123,11 +8677,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; @@ -8141,11 +8697,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; @@ -8159,11 +8717,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; @@ -8177,11 +8737,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; @@ -8195,11 +8757,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; @@ -8213,11 +8777,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; @@ -8231,11 +8797,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; @@ -8249,11 +8817,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; @@ -8267,11 +8837,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; @@ -8285,11 +8857,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; @@ -8303,11 +8877,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; @@ -8321,11 +8897,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; @@ -8339,11 +8917,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; @@ -8357,11 +8937,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; @@ -8375,11 +8957,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; @@ -8393,11 +8977,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; @@ -8411,11 +8997,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; @@ -8569,7 +9157,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()] @@ -8579,21 +9167,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 { @@ -8605,13 +9220,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) { @@ -8625,6 +9239,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); } @@ -8643,6 +9258,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; @@ -8712,18 +9328,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(); @@ -8734,13 +9353,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 RepeatedMessageList { - get { return result.repeatedMessage_; } + get { return PrepareBuilder().repeatedMessage_; } } public int RepeatedMessageCount { get { return result.RepeatedMessageCount; } @@ -8750,29 +9370,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 values) { + PrepareBuilder(); result.repeatedMessage_.Add(values); return this; } public Builder ClearRepeatedMessage() { + PrepareBuilder(); result.repeatedMessage_.Clear(); return this; } @@ -8785,11 +9411,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; @@ -8903,7 +9531,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()] @@ -8913,21 +9541,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 { @@ -8939,12 +9594,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) { @@ -8958,6 +9612,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); } @@ -8970,6 +9625,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; @@ -9031,18 +9687,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(); @@ -9053,6 +9712,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; @@ -9150,7 +9810,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()] @@ -9160,21 +9820,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 { @@ -9186,12 +9873,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) { @@ -9205,6 +9891,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; } @@ -9214,6 +9901,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; @@ -9353,7 +10041,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()] @@ -9363,21 +10051,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 { @@ -9389,12 +10104,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) { @@ -9408,6 +10122,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; @@ -9418,6 +10133,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; @@ -9559,7 +10275,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()] @@ -9569,21 +10285,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 { @@ -9595,12 +10338,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) { @@ -9614,6 +10356,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; @@ -9624,6 +10367,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; @@ -9791,7 +10535,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()] @@ -9801,21 +10545,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 { @@ -9827,12 +10598,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) { @@ -9846,6 +10616,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; } @@ -9861,6 +10632,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; @@ -9920,11 +10692,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; @@ -9938,11 +10712,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; @@ -10072,7 +10848,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()] @@ -10082,21 +10858,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 { @@ -10108,12 +10911,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) { @@ -10127,6 +10929,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); } @@ -10142,6 +10945,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; @@ -10207,18 +11011,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(); @@ -10229,6 +11036,7 @@ namespace Google.ProtocolBuffers.TestProtos { return this; } public Builder ClearA() { + PrepareBuilder(); result.hasA = false; result.a_ = global::Google.ProtocolBuffers.TestProtos.TestRecursiveMessage.DefaultInstance; return this; @@ -10242,11 +11050,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; @@ -10360,7 +11170,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()] @@ -10370,21 +11180,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 { @@ -10396,12 +11233,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) { @@ -10415,6 +11251,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); } @@ -10427,6 +11264,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; @@ -10488,18 +11326,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(); @@ -10510,6 +11351,7 @@ namespace Google.ProtocolBuffers.TestProtos { return this; } public Builder ClearBb() { + PrepareBuilder(); result.hasBb = false; result.bb_ = global::Google.ProtocolBuffers.TestProtos.TestMutualRecursionB.DefaultInstance; return this; @@ -10639,7 +11481,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()] @@ -10649,21 +11491,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 { @@ -10675,12 +11544,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) { @@ -10694,6 +11562,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); } @@ -10709,6 +11578,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; @@ -10774,18 +11644,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(); @@ -10796,6 +11669,7 @@ namespace Google.ProtocolBuffers.TestProtos { return this; } public Builder ClearA() { + PrepareBuilder(); result.hasA = false; result.a_ = global::Google.ProtocolBuffers.TestProtos.TestMutualRecursionA.DefaultInstance; return this; @@ -10809,11 +11683,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; @@ -10960,7 +11836,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()] @@ -10970,21 +11846,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 { @@ -10996,12 +11899,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) { @@ -11015,6 +11917,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; } @@ -11027,6 +11930,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; @@ -11082,11 +11986,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; @@ -11200,7 +12106,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()] @@ -11210,21 +12116,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 { @@ -11236,12 +12169,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) { @@ -11255,6 +12187,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; } @@ -11267,6 +12200,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; @@ -11322,11 +12256,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; @@ -11447,7 +12383,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()] @@ -11457,21 +12393,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 { @@ -11483,12 +12446,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) { @@ -11502,6 +12464,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; } @@ -11520,6 +12483,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; @@ -11593,11 +12557,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; @@ -11612,18 +12578,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(); @@ -11634,6 +12603,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; @@ -11648,18 +12618,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(); @@ -11670,6 +12643,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; @@ -11841,7 +12815,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()] @@ -11851,21 +12825,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 { @@ -11877,14 +12878,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) { @@ -11898,6 +12898,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) { result.nestedmessageRepeatedInt32_.Add(other.nestedmessageRepeatedInt32_); } @@ -11913,6 +12914,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; @@ -11966,7 +12968,7 @@ namespace Google.ProtocolBuffers.TestProtos { public pbc::IPopsicleList NestedmessageRepeatedInt32List { - get { return result.nestedmessageRepeatedInt32_; } + get { return PrepareBuilder().nestedmessageRepeatedInt32_; } } public int NestedmessageRepeatedInt32Count { get { return result.NestedmessageRepeatedInt32Count; } @@ -11975,24 +12977,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 values) { + PrepareBuilder(); result.nestedmessageRepeatedInt32_.Add(values); return this; } public Builder ClearNestedmessageRepeatedInt32() { + PrepareBuilder(); result.nestedmessageRepeatedInt32_.Clear(); return this; } public pbc::IPopsicleList NestedmessageRepeatedForeignmessageList { - get { return result.nestedmessageRepeatedForeignmessage_; } + get { return PrepareBuilder().nestedmessageRepeatedForeignmessage_; } } public int NestedmessageRepeatedForeignmessageCount { get { return result.NestedmessageRepeatedForeignmessageCount; } @@ -12002,29 +13008,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 values) { + PrepareBuilder(); result.nestedmessageRepeatedForeignmessage_.Add(values); return this; } public Builder ClearNestedmessageRepeatedForeignmessage() { + PrepareBuilder(); result.nestedmessageRepeatedForeignmessage_.Clear(); return this; } @@ -12112,7 +13124,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()] @@ -12122,21 +13134,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 { @@ -12148,12 +13187,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) { @@ -12167,6 +13205,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); } @@ -12179,6 +13218,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; @@ -12240,18 +13280,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(); @@ -12262,6 +13305,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; @@ -12590,7 +13634,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()] @@ -12600,21 +13644,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 { @@ -12626,8 +13697,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(); @@ -12635,9 +13706,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) { @@ -12651,6 +13721,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; } @@ -12696,6 +13767,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; @@ -12819,11 +13891,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; @@ -12838,11 +13912,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; @@ -12856,11 +13932,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; @@ -12875,18 +13953,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(); @@ -12897,6 +13978,7 @@ namespace Google.ProtocolBuffers.TestProtos { return this; } public Builder ClearMessageField() { + PrepareBuilder(); result.hasMessageField = false; result.messageField_ = global::Google.ProtocolBuffers.TestProtos.ForeignMessage.DefaultInstance; return this; @@ -12911,11 +13993,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; @@ -12930,18 +14014,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 RepeatedPrimitiveFieldList { - get { return result.repeatedPrimitiveField_; } + get { return PrepareBuilder().repeatedPrimitiveField_; } } public int RepeatedPrimitiveFieldCount { get { return result.RepeatedPrimitiveFieldCount; } @@ -12950,24 +14036,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 values) { + PrepareBuilder(); result.repeatedPrimitiveField_.Add(values); return this; } public Builder ClearRepeatedPrimitiveField() { + PrepareBuilder(); result.repeatedPrimitiveField_.Clear(); return this; } public pbc::IPopsicleList RepeatedStringFieldList { - get { return result.repeatedStringField_; } + get { return PrepareBuilder().repeatedStringField_; } } public int RepeatedStringFieldCount { get { return result.RepeatedStringFieldCount; } @@ -12977,25 +14067,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 values) { + PrepareBuilder(); result.repeatedStringField_.Add(values); return this; } public Builder ClearRepeatedStringField() { + PrepareBuilder(); result.repeatedStringField_.Clear(); return this; } public pbc::IPopsicleList RepeatedEnumFieldList { - get { return result.repeatedEnumField_; } + get { return PrepareBuilder().repeatedEnumField_; } } public int RepeatedEnumFieldCount { get { return result.RepeatedEnumFieldCount; } @@ -13004,24 +14098,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 values) { + PrepareBuilder(); result.repeatedEnumField_.Add(values); return this; } public Builder ClearRepeatedEnumField() { + PrepareBuilder(); result.repeatedEnumField_.Clear(); return this; } public pbc::IPopsicleList RepeatedMessageFieldList { - get { return result.repeatedMessageField_; } + get { return PrepareBuilder().repeatedMessageField_; } } public int RepeatedMessageFieldCount { get { return result.RepeatedMessageFieldCount; } @@ -13031,35 +14129,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 values) { + PrepareBuilder(); result.repeatedMessageField_.Add(values); return this; } public Builder ClearRepeatedMessageField() { + PrepareBuilder(); result.repeatedMessageField_.Clear(); return this; } public pbc::IPopsicleList RepeatedStringPieceFieldList { - get { return result.repeatedStringPieceField_; } + get { return PrepareBuilder().repeatedStringPieceField_; } } public int RepeatedStringPieceFieldCount { get { return result.RepeatedStringPieceFieldCount; } @@ -13069,25 +14173,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 values) { + PrepareBuilder(); result.repeatedStringPieceField_.Add(values); return this; } public Builder ClearRepeatedStringPieceField() { + PrepareBuilder(); result.repeatedStringPieceField_.Clear(); return this; } public pbc::IPopsicleList RepeatedCordFieldList { - get { return result.repeatedCordField_; } + get { return PrepareBuilder().repeatedCordField_; } } public int RepeatedCordFieldCount { get { return result.RepeatedCordFieldCount; } @@ -13097,19 +14205,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 values) { + PrepareBuilder(); result.repeatedCordField_.Add(values); return this; } public Builder ClearRepeatedCordField() { + PrepareBuilder(); result.repeatedCordField_.Clear(); return this; } @@ -13259,7 +14371,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()] @@ -13269,21 +14381,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 { @@ -13295,12 +14434,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) { @@ -13314,6 +14452,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; } @@ -13333,6 +14472,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; @@ -13397,11 +14537,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; @@ -13415,11 +14557,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; @@ -13433,11 +14577,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; @@ -13841,7 +14987,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()] @@ -13851,21 +14997,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 { @@ -13877,12 +15050,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) { @@ -13896,6 +15068,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; } @@ -13962,6 +15135,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; @@ -14090,11 +15264,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; @@ -14110,11 +15286,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; @@ -14130,11 +15308,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; @@ -14148,11 +15328,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; @@ -14166,11 +15348,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; @@ -14185,11 +15369,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; @@ -14203,11 +15389,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; @@ -14221,11 +15409,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; @@ -14239,11 +15429,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; @@ -14257,11 +15449,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; @@ -14275,11 +15469,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; @@ -14293,11 +15489,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; @@ -14311,11 +15509,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; @@ -14329,11 +15529,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; @@ -14347,11 +15549,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; @@ -14365,11 +15569,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; @@ -14383,11 +15589,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; @@ -14401,11 +15609,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; @@ -14419,11 +15629,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; @@ -14537,7 +15749,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()] @@ -14547,21 +15759,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 { @@ -14573,12 +15812,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) { @@ -14592,6 +15830,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; } @@ -14604,6 +15843,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; @@ -14660,11 +15900,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; @@ -14778,7 +16020,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()] @@ -14788,21 +16030,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 { @@ -14814,12 +16083,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) { @@ -14833,6 +16101,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; } @@ -14845,6 +16114,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; @@ -14901,11 +16171,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; @@ -15376,7 +16648,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()] @@ -15386,21 +16658,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 { @@ -15412,8 +16711,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(); @@ -15429,9 +16728,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) { @@ -15445,6 +16743,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) { result.packedInt32_.Add(other.packedInt32_); } @@ -15496,6 +16795,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; @@ -15619,7 +16919,7 @@ namespace Google.ProtocolBuffers.TestProtos { public pbc::IPopsicleList PackedInt32List { - get { return result.packedInt32_; } + get { return PrepareBuilder().packedInt32_; } } public int PackedInt32Count { get { return result.PackedInt32Count; } @@ -15628,24 +16928,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 values) { + PrepareBuilder(); result.packedInt32_.Add(values); return this; } public Builder ClearPackedInt32() { + PrepareBuilder(); result.packedInt32_.Clear(); return this; } public pbc::IPopsicleList PackedInt64List { - get { return result.packedInt64_; } + get { return PrepareBuilder().packedInt64_; } } public int PackedInt64Count { get { return result.PackedInt64Count; } @@ -15654,25 +16958,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 values) { + PrepareBuilder(); result.packedInt64_.Add(values); return this; } public Builder ClearPackedInt64() { + PrepareBuilder(); result.packedInt64_.Clear(); return this; } [global::System.CLSCompliant(false)] public pbc::IPopsicleList PackedUint32List { - get { return result.packedUint32_; } + get { return PrepareBuilder().packedUint32_; } } public int PackedUint32Count { get { return result.PackedUint32Count; } @@ -15683,27 +16991,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 values) { + PrepareBuilder(); result.packedUint32_.Add(values); return this; } public Builder ClearPackedUint32() { + PrepareBuilder(); result.packedUint32_.Clear(); return this; } [global::System.CLSCompliant(false)] public pbc::IPopsicleList PackedUint64List { - get { return result.packedUint64_; } + get { return PrepareBuilder().packedUint64_; } } public int PackedUint64Count { get { return result.PackedUint64Count; } @@ -15714,26 +17026,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 values) { + PrepareBuilder(); result.packedUint64_.Add(values); return this; } public Builder ClearPackedUint64() { + PrepareBuilder(); result.packedUint64_.Clear(); return this; } public pbc::IPopsicleList PackedSint32List { - get { return result.packedSint32_; } + get { return PrepareBuilder().packedSint32_; } } public int PackedSint32Count { get { return result.PackedSint32Count; } @@ -15742,24 +17058,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 values) { + PrepareBuilder(); result.packedSint32_.Add(values); return this; } public Builder ClearPackedSint32() { + PrepareBuilder(); result.packedSint32_.Clear(); return this; } public pbc::IPopsicleList PackedSint64List { - get { return result.packedSint64_; } + get { return PrepareBuilder().packedSint64_; } } public int PackedSint64Count { get { return result.PackedSint64Count; } @@ -15768,25 +17088,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 values) { + PrepareBuilder(); result.packedSint64_.Add(values); return this; } public Builder ClearPackedSint64() { + PrepareBuilder(); result.packedSint64_.Clear(); return this; } [global::System.CLSCompliant(false)] public pbc::IPopsicleList PackedFixed32List { - get { return result.packedFixed32_; } + get { return PrepareBuilder().packedFixed32_; } } public int PackedFixed32Count { get { return result.PackedFixed32Count; } @@ -15797,27 +17121,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 values) { + PrepareBuilder(); result.packedFixed32_.Add(values); return this; } public Builder ClearPackedFixed32() { + PrepareBuilder(); result.packedFixed32_.Clear(); return this; } [global::System.CLSCompliant(false)] public pbc::IPopsicleList PackedFixed64List { - get { return result.packedFixed64_; } + get { return PrepareBuilder().packedFixed64_; } } public int PackedFixed64Count { get { return result.PackedFixed64Count; } @@ -15828,26 +17156,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 values) { + PrepareBuilder(); result.packedFixed64_.Add(values); return this; } public Builder ClearPackedFixed64() { + PrepareBuilder(); result.packedFixed64_.Clear(); return this; } public pbc::IPopsicleList PackedSfixed32List { - get { return result.packedSfixed32_; } + get { return PrepareBuilder().packedSfixed32_; } } public int PackedSfixed32Count { get { return result.PackedSfixed32Count; } @@ -15856,24 +17188,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 values) { + PrepareBuilder(); result.packedSfixed32_.Add(values); return this; } public Builder ClearPackedSfixed32() { + PrepareBuilder(); result.packedSfixed32_.Clear(); return this; } public pbc::IPopsicleList PackedSfixed64List { - get { return result.packedSfixed64_; } + get { return PrepareBuilder().packedSfixed64_; } } public int PackedSfixed64Count { get { return result.PackedSfixed64Count; } @@ -15882,24 +17218,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 values) { + PrepareBuilder(); result.packedSfixed64_.Add(values); return this; } public Builder ClearPackedSfixed64() { + PrepareBuilder(); result.packedSfixed64_.Clear(); return this; } public pbc::IPopsicleList PackedFloatList { - get { return result.packedFloat_; } + get { return PrepareBuilder().packedFloat_; } } public int PackedFloatCount { get { return result.PackedFloatCount; } @@ -15908,24 +17248,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 values) { + PrepareBuilder(); result.packedFloat_.Add(values); return this; } public Builder ClearPackedFloat() { + PrepareBuilder(); result.packedFloat_.Clear(); return this; } public pbc::IPopsicleList PackedDoubleList { - get { return result.packedDouble_; } + get { return PrepareBuilder().packedDouble_; } } public int PackedDoubleCount { get { return result.PackedDoubleCount; } @@ -15934,24 +17278,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 values) { + PrepareBuilder(); result.packedDouble_.Add(values); return this; } public Builder ClearPackedDouble() { + PrepareBuilder(); result.packedDouble_.Clear(); return this; } public pbc::IPopsicleList PackedBoolList { - get { return result.packedBool_; } + get { return PrepareBuilder().packedBool_; } } public int PackedBoolCount { get { return result.PackedBoolCount; } @@ -15960,24 +17308,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 values) { + PrepareBuilder(); result.packedBool_.Add(values); return this; } public Builder ClearPackedBool() { + PrepareBuilder(); result.packedBool_.Clear(); return this; } public pbc::IPopsicleList PackedEnumList { - get { return result.packedEnum_; } + get { return PrepareBuilder().packedEnum_; } } public int PackedEnumCount { get { return result.PackedEnumCount; } @@ -15986,18 +17338,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 values) { + PrepareBuilder(); result.packedEnum_.Add(values); return this; } public Builder ClearPackedEnum() { + PrepareBuilder(); result.packedEnum_.Clear(); return this; } @@ -16412,7 +17768,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()] @@ -16422,21 +17778,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 { @@ -16448,8 +17831,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(); @@ -16465,9 +17848,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) { @@ -16481,6 +17863,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) { result.unpackedInt32_.Add(other.unpackedInt32_); } @@ -16532,6 +17915,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; @@ -16655,7 +18039,7 @@ namespace Google.ProtocolBuffers.TestProtos { public pbc::IPopsicleList UnpackedInt32List { - get { return result.unpackedInt32_; } + get { return PrepareBuilder().unpackedInt32_; } } public int UnpackedInt32Count { get { return result.UnpackedInt32Count; } @@ -16664,24 +18048,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 values) { + PrepareBuilder(); result.unpackedInt32_.Add(values); return this; } public Builder ClearUnpackedInt32() { + PrepareBuilder(); result.unpackedInt32_.Clear(); return this; } public pbc::IPopsicleList UnpackedInt64List { - get { return result.unpackedInt64_; } + get { return PrepareBuilder().unpackedInt64_; } } public int UnpackedInt64Count { get { return result.UnpackedInt64Count; } @@ -16690,25 +18078,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 values) { + PrepareBuilder(); result.unpackedInt64_.Add(values); return this; } public Builder ClearUnpackedInt64() { + PrepareBuilder(); result.unpackedInt64_.Clear(); return this; } [global::System.CLSCompliant(false)] public pbc::IPopsicleList UnpackedUint32List { - get { return result.unpackedUint32_; } + get { return PrepareBuilder().unpackedUint32_; } } public int UnpackedUint32Count { get { return result.UnpackedUint32Count; } @@ -16719,27 +18111,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 values) { + PrepareBuilder(); result.unpackedUint32_.Add(values); return this; } public Builder ClearUnpackedUint32() { + PrepareBuilder(); result.unpackedUint32_.Clear(); return this; } [global::System.CLSCompliant(false)] public pbc::IPopsicleList UnpackedUint64List { - get { return result.unpackedUint64_; } + get { return PrepareBuilder().unpackedUint64_; } } public int UnpackedUint64Count { get { return result.UnpackedUint64Count; } @@ -16750,26 +18146,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 values) { + PrepareBuilder(); result.unpackedUint64_.Add(values); return this; } public Builder ClearUnpackedUint64() { + PrepareBuilder(); result.unpackedUint64_.Clear(); return this; } public pbc::IPopsicleList UnpackedSint32List { - get { return result.unpackedSint32_; } + get { return PrepareBuilder().unpackedSint32_; } } public int UnpackedSint32Count { get { return result.UnpackedSint32Count; } @@ -16778,24 +18178,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 values) { + PrepareBuilder(); result.unpackedSint32_.Add(values); return this; } public Builder ClearUnpackedSint32() { + PrepareBuilder(); result.unpackedSint32_.Clear(); return this; } public pbc::IPopsicleList UnpackedSint64List { - get { return result.unpackedSint64_; } + get { return PrepareBuilder().unpackedSint64_; } } public int UnpackedSint64Count { get { return result.UnpackedSint64Count; } @@ -16804,25 +18208,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 values) { + PrepareBuilder(); result.unpackedSint64_.Add(values); return this; } public Builder ClearUnpackedSint64() { + PrepareBuilder(); result.unpackedSint64_.Clear(); return this; } [global::System.CLSCompliant(false)] public pbc::IPopsicleList UnpackedFixed32List { - get { return result.unpackedFixed32_; } + get { return PrepareBuilder().unpackedFixed32_; } } public int UnpackedFixed32Count { get { return result.UnpackedFixed32Count; } @@ -16833,27 +18241,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 values) { + PrepareBuilder(); result.unpackedFixed32_.Add(values); return this; } public Builder ClearUnpackedFixed32() { + PrepareBuilder(); result.unpackedFixed32_.Clear(); return this; } [global::System.CLSCompliant(false)] public pbc::IPopsicleList UnpackedFixed64List { - get { return result.unpackedFixed64_; } + get { return PrepareBuilder().unpackedFixed64_; } } public int UnpackedFixed64Count { get { return result.UnpackedFixed64Count; } @@ -16864,26 +18276,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 values) { + PrepareBuilder(); result.unpackedFixed64_.Add(values); return this; } public Builder ClearUnpackedFixed64() { + PrepareBuilder(); result.unpackedFixed64_.Clear(); return this; } public pbc::IPopsicleList UnpackedSfixed32List { - get { return result.unpackedSfixed32_; } + get { return PrepareBuilder().unpackedSfixed32_; } } public int UnpackedSfixed32Count { get { return result.UnpackedSfixed32Count; } @@ -16892,24 +18308,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 values) { + PrepareBuilder(); result.unpackedSfixed32_.Add(values); return this; } public Builder ClearUnpackedSfixed32() { + PrepareBuilder(); result.unpackedSfixed32_.Clear(); return this; } public pbc::IPopsicleList UnpackedSfixed64List { - get { return result.unpackedSfixed64_; } + get { return PrepareBuilder().unpackedSfixed64_; } } public int UnpackedSfixed64Count { get { return result.UnpackedSfixed64Count; } @@ -16918,24 +18338,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 values) { + PrepareBuilder(); result.unpackedSfixed64_.Add(values); return this; } public Builder ClearUnpackedSfixed64() { + PrepareBuilder(); result.unpackedSfixed64_.Clear(); return this; } public pbc::IPopsicleList UnpackedFloatList { - get { return result.unpackedFloat_; } + get { return PrepareBuilder().unpackedFloat_; } } public int UnpackedFloatCount { get { return result.UnpackedFloatCount; } @@ -16944,24 +18368,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 values) { + PrepareBuilder(); result.unpackedFloat_.Add(values); return this; } public Builder ClearUnpackedFloat() { + PrepareBuilder(); result.unpackedFloat_.Clear(); return this; } public pbc::IPopsicleList UnpackedDoubleList { - get { return result.unpackedDouble_; } + get { return PrepareBuilder().unpackedDouble_; } } public int UnpackedDoubleCount { get { return result.UnpackedDoubleCount; } @@ -16970,24 +18398,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 values) { + PrepareBuilder(); result.unpackedDouble_.Add(values); return this; } public Builder ClearUnpackedDouble() { + PrepareBuilder(); result.unpackedDouble_.Clear(); return this; } public pbc::IPopsicleList UnpackedBoolList { - get { return result.unpackedBool_; } + get { return PrepareBuilder().unpackedBool_; } } public int UnpackedBoolCount { get { return result.UnpackedBoolCount; } @@ -16996,24 +18428,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 values) { + PrepareBuilder(); result.unpackedBool_.Add(values); return this; } public Builder ClearUnpackedBool() { + PrepareBuilder(); result.unpackedBool_.Clear(); return this; } public pbc::IPopsicleList UnpackedEnumList { - get { return result.unpackedEnum_; } + get { return PrepareBuilder().unpackedEnum_; } } public int UnpackedEnumCount { get { return result.UnpackedEnumCount; } @@ -17022,18 +18458,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 values) { + PrepareBuilder(); result.unpackedEnum_.Add(values); return this; } public Builder ClearUnpackedEnum() { + PrepareBuilder(); result.unpackedEnum_.Clear(); return this; } @@ -17134,7 +18574,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()] @@ -17144,21 +18584,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 { @@ -17170,12 +18637,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) { @@ -17189,6 +18655,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; @@ -17199,6 +18666,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; @@ -17338,7 +18806,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()] @@ -17348,21 +18816,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 { @@ -17374,12 +18869,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) { @@ -17393,6 +18887,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; @@ -17403,6 +18898,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; @@ -17595,7 +19091,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()] @@ -17605,21 +19101,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 { @@ -17631,12 +19154,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) { @@ -17650,6 +19172,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; } @@ -17662,6 +19185,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; @@ -17717,11 +19241,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; @@ -17925,7 +19451,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()] @@ -17935,21 +19461,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 { @@ -17961,14 +19514,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) { @@ -17982,6 +19534,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; } @@ -18012,6 +19565,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; @@ -18120,11 +19674,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; @@ -18138,11 +19694,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; @@ -18156,11 +19714,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; @@ -18175,18 +19735,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(); @@ -18197,6 +19760,7 @@ namespace Google.ProtocolBuffers.TestProtos { return this; } public Builder ClearMessageExtension() { + PrepareBuilder(); result.hasMessageExtension = false; result.messageExtension_ = global::Google.ProtocolBuffers.TestProtos.ForeignMessage.DefaultInstance; return this; @@ -18211,18 +19775,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(); @@ -18233,13 +19800,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 RepeatedExtensionList { - get { return result.repeatedExtension_; } + get { return PrepareBuilder().repeatedExtension_; } } public int RepeatedExtensionCount { get { return result.RepeatedExtensionCount; } @@ -18249,25 +19817,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 values) { + PrepareBuilder(); result.repeatedExtension_.Add(values); return this; } public Builder ClearRepeatedExtension() { + PrepareBuilder(); result.repeatedExtension_.Clear(); return this; } public pbc::IPopsicleList PackedExtensionList { - get { return result.packedExtension_; } + get { return PrepareBuilder().packedExtension_; } } public int PackedExtensionCount { get { return result.PackedExtensionCount; } @@ -18276,18 +19848,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 values) { + PrepareBuilder(); result.packedExtension_.Add(values); return this; } public Builder ClearPackedExtension() { + PrepareBuilder(); result.packedExtension_.Clear(); return this; } @@ -18522,7 +20098,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()] @@ -18532,21 +20108,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 { @@ -18558,8 +20161,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(); @@ -18567,9 +20170,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) { @@ -18583,6 +20185,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) { result.repeatedFixed32_.Add(other.repeatedFixed32_); } @@ -18610,6 +20213,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; @@ -18685,7 +20289,7 @@ namespace Google.ProtocolBuffers.TestProtos { [global::System.CLSCompliant(false)] public pbc::IPopsicleList RepeatedFixed32List { - get { return result.repeatedFixed32_; } + get { return PrepareBuilder().repeatedFixed32_; } } public int RepeatedFixed32Count { get { return result.RepeatedFixed32Count; } @@ -18696,26 +20300,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 values) { + PrepareBuilder(); result.repeatedFixed32_.Add(values); return this; } public Builder ClearRepeatedFixed32() { + PrepareBuilder(); result.repeatedFixed32_.Clear(); return this; } public pbc::IPopsicleList RepeatedInt32List { - get { return result.repeatedInt32_; } + get { return PrepareBuilder().repeatedInt32_; } } public int RepeatedInt32Count { get { return result.RepeatedInt32Count; } @@ -18724,25 +20332,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 values) { + PrepareBuilder(); result.repeatedInt32_.Add(values); return this; } public Builder ClearRepeatedInt32() { + PrepareBuilder(); result.repeatedInt32_.Clear(); return this; } [global::System.CLSCompliant(false)] public pbc::IPopsicleList RepeatedFixed64List { - get { return result.repeatedFixed64_; } + get { return PrepareBuilder().repeatedFixed64_; } } public int RepeatedFixed64Count { get { return result.RepeatedFixed64Count; } @@ -18753,26 +20365,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 values) { + PrepareBuilder(); result.repeatedFixed64_.Add(values); return this; } public Builder ClearRepeatedFixed64() { + PrepareBuilder(); result.repeatedFixed64_.Clear(); return this; } public pbc::IPopsicleList RepeatedInt64List { - get { return result.repeatedInt64_; } + get { return PrepareBuilder().repeatedInt64_; } } public int RepeatedInt64Count { get { return result.RepeatedInt64Count; } @@ -18781,24 +20397,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 values) { + PrepareBuilder(); result.repeatedInt64_.Add(values); return this; } public Builder ClearRepeatedInt64() { + PrepareBuilder(); result.repeatedInt64_.Clear(); return this; } public pbc::IPopsicleList RepeatedFloatList { - get { return result.repeatedFloat_; } + get { return PrepareBuilder().repeatedFloat_; } } public int RepeatedFloatCount { get { return result.RepeatedFloatCount; } @@ -18807,25 +20427,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 values) { + PrepareBuilder(); result.repeatedFloat_.Add(values); return this; } public Builder ClearRepeatedFloat() { + PrepareBuilder(); result.repeatedFloat_.Clear(); return this; } [global::System.CLSCompliant(false)] public pbc::IPopsicleList RepeatedUint64List { - get { return result.repeatedUint64_; } + get { return PrepareBuilder().repeatedUint64_; } } public int RepeatedUint64Count { get { return result.RepeatedUint64Count; } @@ -18836,20 +20460,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 values) { + PrepareBuilder(); result.repeatedUint64_.Add(values); return this; } public Builder ClearRepeatedUint64() { + PrepareBuilder(); result.repeatedUint64_.Clear(); return this; } @@ -18946,7 +20574,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()] @@ -18956,21 +20584,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 { @@ -18982,12 +20637,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) { @@ -19001,6 +20655,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; } @@ -19010,6 +20665,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; @@ -19145,7 +20801,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()] @@ -19155,21 +20811,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 { @@ -19181,12 +20864,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) { @@ -19200,6 +20882,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; } @@ -19209,6 +20892,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; @@ -19344,7 +21028,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()] @@ -19354,21 +21038,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 { @@ -19380,12 +21091,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) { @@ -19399,6 +21109,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; } @@ -19408,6 +21119,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; @@ -19543,7 +21255,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()] @@ -19553,21 +21265,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 { @@ -19579,12 +21318,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) { @@ -19598,6 +21336,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; } @@ -19607,6 +21346,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 a2a965eb43..cb80586182 100644 --- a/src/ProtocolBuffers.Test/TestProtos/UnitTestRpcInterop.cs +++ b/src/ProtocolBuffers.Test/TestProtos/UnitTestRpcInterop.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(SearchRequest 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 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 { @@ -225,13 +252,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) { @@ -245,6 +271,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) { result.criteria_.Add(other.criteria_); } @@ -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; @@ -305,7 +333,7 @@ namespace Google.ProtocolBuffers.TestProtos { public pbc::IPopsicleList CriteriaList { - get { return result.criteria_; } + get { return PrepareBuilder().criteria_; } } public int CriteriaCount { get { return result.CriteriaCount; } @@ -315,19 +343,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 values) { + PrepareBuilder(); result.criteria_.Add(values); return this; } public Builder ClearCriteria() { + PrepareBuilder(); result.criteria_.Clear(); return this; } @@ -490,7 +522,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()] @@ -500,21 +532,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 { @@ -526,12 +585,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) { @@ -545,6 +603,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; } @@ -560,6 +619,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; @@ -620,11 +680,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; @@ -639,11 +701,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; @@ -737,7 +801,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()] @@ -747,21 +811,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 { @@ -773,13 +864,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) { @@ -793,6 +883,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) { result.results_.Add(other.results_); } @@ -805,6 +896,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; @@ -853,7 +945,7 @@ namespace Google.ProtocolBuffers.TestProtos { public pbc::IPopsicleList ResultsList { - get { return result.results_; } + get { return PrepareBuilder().results_; } } public int ResultsCount { get { return result.ResultsCount; } @@ -863,29 +955,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 values) { + PrepareBuilder(); result.results_.Add(values); return this; } public Builder ClearResults() { + PrepareBuilder(); result.results_.Clear(); return this; } @@ -1023,7 +1121,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()] @@ -1033,21 +1131,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 { @@ -1059,13 +1184,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) { @@ -1079,6 +1203,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) { result.criteria_.Add(other.criteria_); } @@ -1094,6 +1219,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; @@ -1151,7 +1277,7 @@ namespace Google.ProtocolBuffers.TestProtos { public pbc::IPopsicleList CriteriaList { - get { return result.criteria_; } + get { return PrepareBuilder().criteria_; } } public int CriteriaCount { get { return result.CriteriaCount; } @@ -1161,19 +1287,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 values) { + PrepareBuilder(); result.criteria_.Add(values); return this; } public Builder ClearCriteria() { + PrepareBuilder(); result.criteria_.Clear(); return this; } @@ -1187,18 +1317,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(); @@ -1209,6 +1342,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 ca0be5abf5..798f09ad46 100644 --- a/src/ProtocolBuffers.Test/TestProtos/UnitTestXmlSerializerTestProtoFile.cs +++ b/src/ProtocolBuffers.Test/TestProtos/UnitTestXmlSerializerTestProtoFile.cs @@ -263,7 +263,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.SerializableAttribute()] @@ -274,21 +274,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 { @@ -300,13 +327,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) { @@ -320,6 +346,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) { result.options_.Add(other.options_); } @@ -335,6 +362,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; @@ -397,7 +425,7 @@ namespace Google.ProtocolBuffers.TestProtos { public pbc::IPopsicleList OptionsList { - get { return result.options_; } + get { return PrepareBuilder().options_; } } public int OptionsCount { get { return result.OptionsCount; } @@ -406,18 +434,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 values) { + PrepareBuilder(); result.options_.Add(values); return this; } public Builder ClearOptions() { + PrepareBuilder(); result.options_.Clear(); return this; } @@ -431,11 +463,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; @@ -534,7 +568,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.SerializableAttribute()] @@ -545,21 +579,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 { @@ -571,12 +632,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) { @@ -590,6 +650,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; } @@ -599,6 +660,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; @@ -751,7 +813,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.SerializableAttribute()] @@ -762,21 +824,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 { @@ -788,12 +877,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) { @@ -807,6 +895,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); } @@ -819,6 +908,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; @@ -880,18 +970,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(); @@ -902,6 +995,7 @@ namespace Google.ProtocolBuffers.TestProtos { return this; } public Builder ClearChild() { + PrepareBuilder(); result.hasChild = false; result.child_ = global::Google.ProtocolBuffers.TestProtos.TestXmlRescursive.DefaultInstance; return this; @@ -1075,7 +1169,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.SerializableAttribute()] @@ -1086,21 +1180,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 { @@ -1112,13 +1233,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) { @@ -1132,6 +1252,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) { result.options_.Add(other.options_); } @@ -1147,6 +1268,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; @@ -1209,7 +1331,7 @@ namespace Google.ProtocolBuffers.TestProtos { public pbc::IPopsicleList OptionsList { - get { return result.options_; } + get { return PrepareBuilder().options_; } } public int OptionsCount { get { return result.OptionsCount; } @@ -1218,18 +1340,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 values) { + PrepareBuilder(); result.options_.Add(values); return this; } public Builder ClearOptions() { + PrepareBuilder(); result.options_.Clear(); return this; } @@ -1243,11 +1369,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; @@ -1452,7 +1580,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.SerializableAttribute()] @@ -1463,21 +1591,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 { @@ -1489,15 +1644,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) { @@ -1511,6 +1665,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; } @@ -1542,6 +1697,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; @@ -1627,18 +1783,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 NumbersList { - get { return result.numbers_; } + get { return PrepareBuilder().numbers_; } } public int NumbersCount { get { return result.NumbersCount; } @@ -1647,18 +1805,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 values) { + PrepareBuilder(); result.numbers_.Add(values); return this; } public Builder ClearNumbers() { + PrepareBuilder(); result.numbers_.Clear(); return this; } @@ -1672,18 +1834,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 TextlinesList { - get { return result.textlines_; } + get { return PrepareBuilder().textlines_; } } public int TextlinesCount { get { return result.TextlinesCount; } @@ -1693,19 +1857,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 values) { + PrepareBuilder(); result.textlines_.Add(values); return this; } public Builder ClearTextlines() { + PrepareBuilder(); result.textlines_.Clear(); return this; } @@ -1718,11 +1886,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; @@ -1737,18 +1907,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(); @@ -1759,13 +1932,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 ChildrenList { - get { return result.children_; } + get { return PrepareBuilder().children_; } } public int ChildrenCount { get { return result.ChildrenCount; } @@ -1775,29 +1949,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 values) { + PrepareBuilder(); result.children_.Add(values); return this; } public Builder ClearChildren() { + PrepareBuilder(); result.children_.Clear(); return this; } @@ -1912,7 +2092,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.SerializableAttribute()] @@ -1923,21 +2103,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 { @@ -1949,12 +2156,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) { @@ -1968,6 +2174,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; } @@ -1980,6 +2187,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; @@ -2035,11 +2243,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; diff --git a/src/ProtocolBuffers/DescriptorProtos/CSharpOptions.cs b/src/ProtocolBuffers/DescriptorProtos/CSharpOptions.cs index 76cb1fee7d..2bebb011c1 100644 --- a/src/ProtocolBuffers/DescriptorProtos/CSharpOptions.cs +++ b/src/ProtocolBuffers/DescriptorProtos/CSharpOptions.cs @@ -433,7 +433,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { public override Builder ToBuilder() { return CreateBuilder(this); } public override Builder CreateBuilderForType() { return new Builder(); } public static Builder CreateBuilder(CSharpFileOptions prototype) { - return (Builder) new Builder().MergeFrom(prototype); + return new Builder(prototype); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] @@ -443,21 +443,48 @@ namespace Google.ProtocolBuffers.DescriptorProtos { protected override Builder ThisBuilder { get { return this; } } - public Builder() {} + public Builder() { + result = DefaultInstance ?? new CSharpFileOptions(); + builderIsReadOnly = result == DefaultInstance; + } + internal Builder(CSharpFileOptions cloneFrom) { + result = cloneFrom; + builderIsReadOnly = true; + } + + bool builderIsReadOnly; + CSharpFileOptions result; - CSharpFileOptions result = new CSharpFileOptions(); + private CSharpFileOptions PrepareBuilder() { + if (builderIsReadOnly) { + CSharpFileOptions original = result; + result = new CSharpFileOptions(); + builderIsReadOnly = false; + MergeFrom(original); + } + return result; + } + + public override bool IsInitialized { + get { return result.IsInitialized; } + } protected override CSharpFileOptions MessageBeingBuilt { - get { return result; } + get { return PrepareBuilder(); } } public override Builder Clear() { - result = new CSharpFileOptions(); + result = DefaultInstance ?? new CSharpFileOptions(); + 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 { @@ -469,12 +496,11 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public override CSharpFileOptions BuildPartial() { - if (result == null) { - throw new global::System.InvalidOperationException("build() has already been called on this Builder"); + if (builderIsReadOnly) { + return result; } - CSharpFileOptions returnMe = result; - result = null; - return returnMe; + builderIsReadOnly = true; + return result; } public override Builder MergeFrom(pb::IMessage other) { @@ -488,6 +514,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { public override Builder MergeFrom(CSharpFileOptions other) { if (other == global::Google.ProtocolBuffers.DescriptorProtos.CSharpFileOptions.DefaultInstance) return this; + PrepareBuilder(); if (other.HasNamespace) { Namespace = other.Namespace; } @@ -539,6 +566,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { + PrepareBuilder(); pb::UnknownFieldSet.Builder unknownFields = null; uint tag; string field_name; @@ -655,11 +683,13 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public Builder SetNamespace(string value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.hasNamespace = true; result.namespace_ = value; return this; } public Builder ClearNamespace() { + PrepareBuilder(); result.hasNamespace = false; result.namespace_ = ""; return this; @@ -674,11 +704,13 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public Builder SetUmbrellaClassname(string value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.hasUmbrellaClassname = true; result.umbrellaClassname_ = value; return this; } public Builder ClearUmbrellaClassname() { + PrepareBuilder(); result.hasUmbrellaClassname = false; result.umbrellaClassname_ = ""; return this; @@ -692,11 +724,13 @@ namespace Google.ProtocolBuffers.DescriptorProtos { set { SetPublicClasses(value); } } public Builder SetPublicClasses(bool value) { + PrepareBuilder(); result.hasPublicClasses = true; result.publicClasses_ = value; return this; } public Builder ClearPublicClasses() { + PrepareBuilder(); result.hasPublicClasses = false; result.publicClasses_ = true; return this; @@ -710,11 +744,13 @@ namespace Google.ProtocolBuffers.DescriptorProtos { set { SetMultipleFiles(value); } } public Builder SetMultipleFiles(bool value) { + PrepareBuilder(); result.hasMultipleFiles = true; result.multipleFiles_ = value; return this; } public Builder ClearMultipleFiles() { + PrepareBuilder(); result.hasMultipleFiles = false; result.multipleFiles_ = false; return this; @@ -728,11 +764,13 @@ namespace Google.ProtocolBuffers.DescriptorProtos { set { SetNestClasses(value); } } public Builder SetNestClasses(bool value) { + PrepareBuilder(); result.hasNestClasses = true; result.nestClasses_ = value; return this; } public Builder ClearNestClasses() { + PrepareBuilder(); result.hasNestClasses = false; result.nestClasses_ = false; return this; @@ -746,11 +784,13 @@ namespace Google.ProtocolBuffers.DescriptorProtos { set { SetCodeContracts(value); } } public Builder SetCodeContracts(bool value) { + PrepareBuilder(); result.hasCodeContracts = true; result.codeContracts_ = value; return this; } public Builder ClearCodeContracts() { + PrepareBuilder(); result.hasCodeContracts = false; result.codeContracts_ = false; return this; @@ -764,11 +804,13 @@ namespace Google.ProtocolBuffers.DescriptorProtos { set { SetExpandNamespaceDirectories(value); } } public Builder SetExpandNamespaceDirectories(bool value) { + PrepareBuilder(); result.hasExpandNamespaceDirectories = true; result.expandNamespaceDirectories_ = value; return this; } public Builder ClearExpandNamespaceDirectories() { + PrepareBuilder(); result.hasExpandNamespaceDirectories = false; result.expandNamespaceDirectories_ = false; return this; @@ -782,11 +824,13 @@ namespace Google.ProtocolBuffers.DescriptorProtos { set { SetClsCompliance(value); } } public Builder SetClsCompliance(bool value) { + PrepareBuilder(); result.hasClsCompliance = true; result.clsCompliance_ = value; return this; } public Builder ClearClsCompliance() { + PrepareBuilder(); result.hasClsCompliance = false; result.clsCompliance_ = true; return this; @@ -800,11 +844,13 @@ namespace Google.ProtocolBuffers.DescriptorProtos { set { SetAddSerializable(value); } } public Builder SetAddSerializable(bool value) { + PrepareBuilder(); result.hasAddSerializable = true; result.addSerializable_ = value; return this; } public Builder ClearAddSerializable() { + PrepareBuilder(); result.hasAddSerializable = false; result.addSerializable_ = false; return this; @@ -819,11 +865,13 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public Builder SetFileExtension(string value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.hasFileExtension = true; result.fileExtension_ = value; return this; } public Builder ClearFileExtension() { + PrepareBuilder(); result.hasFileExtension = false; result.fileExtension_ = ".cs"; return this; @@ -838,11 +886,13 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public Builder SetUmbrellaNamespace(string value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.hasUmbrellaNamespace = true; result.umbrellaNamespace_ = value; return this; } public Builder ClearUmbrellaNamespace() { + PrepareBuilder(); result.hasUmbrellaNamespace = false; result.umbrellaNamespace_ = ""; return this; @@ -857,11 +907,13 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public Builder SetOutputDirectory(string value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.hasOutputDirectory = true; result.outputDirectory_ = value; return this; } public Builder ClearOutputDirectory() { + PrepareBuilder(); result.hasOutputDirectory = false; result.outputDirectory_ = "."; return this; @@ -875,11 +927,13 @@ namespace Google.ProtocolBuffers.DescriptorProtos { set { SetIgnoreGoogleProtobuf(value); } } public Builder SetIgnoreGoogleProtobuf(bool value) { + PrepareBuilder(); result.hasIgnoreGoogleProtobuf = true; result.ignoreGoogleProtobuf_ = value; return this; } public Builder ClearIgnoreGoogleProtobuf() { + PrepareBuilder(); result.hasIgnoreGoogleProtobuf = false; result.ignoreGoogleProtobuf_ = false; return this; @@ -893,11 +947,13 @@ namespace Google.ProtocolBuffers.DescriptorProtos { set { SetServiceGeneratorType(value); } } public Builder SetServiceGeneratorType(global::Google.ProtocolBuffers.DescriptorProtos.CSharpServiceType value) { + PrepareBuilder(); result.hasServiceGeneratorType = true; result.serviceGeneratorType_ = value; return this; } public Builder ClearServiceGeneratorType() { + PrepareBuilder(); result.hasServiceGeneratorType = false; result.serviceGeneratorType_ = global::Google.ProtocolBuffers.DescriptorProtos.CSharpServiceType.NONE; return this; @@ -1011,7 +1067,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { public override Builder ToBuilder() { return CreateBuilder(this); } public override Builder CreateBuilderForType() { return new Builder(); } public static Builder CreateBuilder(CSharpFieldOptions prototype) { - return (Builder) new Builder().MergeFrom(prototype); + return new Builder(prototype); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] @@ -1021,21 +1077,48 @@ namespace Google.ProtocolBuffers.DescriptorProtos { protected override Builder ThisBuilder { get { return this; } } - public Builder() {} + public Builder() { + result = DefaultInstance ?? new CSharpFieldOptions(); + builderIsReadOnly = result == DefaultInstance; + } + internal Builder(CSharpFieldOptions cloneFrom) { + result = cloneFrom; + builderIsReadOnly = true; + } + + bool builderIsReadOnly; + CSharpFieldOptions result; - CSharpFieldOptions result = new CSharpFieldOptions(); + private CSharpFieldOptions PrepareBuilder() { + if (builderIsReadOnly) { + CSharpFieldOptions original = result; + result = new CSharpFieldOptions(); + builderIsReadOnly = false; + MergeFrom(original); + } + return result; + } + + public override bool IsInitialized { + get { return result.IsInitialized; } + } protected override CSharpFieldOptions MessageBeingBuilt { - get { return result; } + get { return PrepareBuilder(); } } public override Builder Clear() { - result = new CSharpFieldOptions(); + result = DefaultInstance ?? new CSharpFieldOptions(); + 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 { @@ -1047,12 +1130,11 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public override CSharpFieldOptions BuildPartial() { - if (result == null) { - throw new global::System.InvalidOperationException("build() has already been called on this Builder"); + if (builderIsReadOnly) { + return result; } - CSharpFieldOptions returnMe = result; - result = null; - return returnMe; + builderIsReadOnly = true; + return result; } public override Builder MergeFrom(pb::IMessage other) { @@ -1066,6 +1148,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { public override Builder MergeFrom(CSharpFieldOptions other) { if (other == global::Google.ProtocolBuffers.DescriptorProtos.CSharpFieldOptions.DefaultInstance) return this; + PrepareBuilder(); if (other.HasPropertyName) { PropertyName = other.PropertyName; } @@ -1078,6 +1161,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { + PrepareBuilder(); pb::UnknownFieldSet.Builder unknownFields = null; uint tag; string field_name; @@ -1134,11 +1218,13 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public Builder SetPropertyName(string value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.hasPropertyName = true; result.propertyName_ = value; return this; } public Builder ClearPropertyName() { + PrepareBuilder(); result.hasPropertyName = false; result.propertyName_ = ""; return this; @@ -1252,7 +1338,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { public override Builder ToBuilder() { return CreateBuilder(this); } public override Builder CreateBuilderForType() { return new Builder(); } public static Builder CreateBuilder(CSharpServiceOptions prototype) { - return (Builder) new Builder().MergeFrom(prototype); + return new Builder(prototype); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] @@ -1262,21 +1348,48 @@ namespace Google.ProtocolBuffers.DescriptorProtos { protected override Builder ThisBuilder { get { return this; } } - public Builder() {} + public Builder() { + result = DefaultInstance ?? new CSharpServiceOptions(); + builderIsReadOnly = result == DefaultInstance; + } + internal Builder(CSharpServiceOptions cloneFrom) { + result = cloneFrom; + builderIsReadOnly = true; + } + + bool builderIsReadOnly; + CSharpServiceOptions result; - CSharpServiceOptions result = new CSharpServiceOptions(); + private CSharpServiceOptions PrepareBuilder() { + if (builderIsReadOnly) { + CSharpServiceOptions original = result; + result = new CSharpServiceOptions(); + builderIsReadOnly = false; + MergeFrom(original); + } + return result; + } + + public override bool IsInitialized { + get { return result.IsInitialized; } + } protected override CSharpServiceOptions MessageBeingBuilt { - get { return result; } + get { return PrepareBuilder(); } } public override Builder Clear() { - result = new CSharpServiceOptions(); + result = DefaultInstance ?? new CSharpServiceOptions(); + 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 { @@ -1288,12 +1401,11 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public override CSharpServiceOptions BuildPartial() { - if (result == null) { - throw new global::System.InvalidOperationException("build() has already been called on this Builder"); + if (builderIsReadOnly) { + return result; } - CSharpServiceOptions returnMe = result; - result = null; - return returnMe; + builderIsReadOnly = true; + return result; } public override Builder MergeFrom(pb::IMessage other) { @@ -1307,6 +1419,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { public override Builder MergeFrom(CSharpServiceOptions other) { if (other == global::Google.ProtocolBuffers.DescriptorProtos.CSharpServiceOptions.DefaultInstance) return this; + PrepareBuilder(); if (other.HasInterfaceId) { InterfaceId = other.InterfaceId; } @@ -1319,6 +1432,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { + PrepareBuilder(); pb::UnknownFieldSet.Builder unknownFields = null; uint tag; string field_name; @@ -1375,11 +1489,13 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public Builder SetInterfaceId(string value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.hasInterfaceId = true; result.interfaceId_ = value; return this; } public Builder ClearInterfaceId() { + PrepareBuilder(); result.hasInterfaceId = false; result.interfaceId_ = ""; return this; @@ -1493,7 +1609,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { public override Builder ToBuilder() { return CreateBuilder(this); } public override Builder CreateBuilderForType() { return new Builder(); } public static Builder CreateBuilder(CSharpMethodOptions prototype) { - return (Builder) new Builder().MergeFrom(prototype); + return new Builder(prototype); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] @@ -1503,21 +1619,48 @@ namespace Google.ProtocolBuffers.DescriptorProtos { protected override Builder ThisBuilder { get { return this; } } - public Builder() {} + public Builder() { + result = DefaultInstance ?? new CSharpMethodOptions(); + builderIsReadOnly = result == DefaultInstance; + } + internal Builder(CSharpMethodOptions cloneFrom) { + result = cloneFrom; + builderIsReadOnly = true; + } + + bool builderIsReadOnly; + CSharpMethodOptions result; - CSharpMethodOptions result = new CSharpMethodOptions(); + private CSharpMethodOptions PrepareBuilder() { + if (builderIsReadOnly) { + CSharpMethodOptions original = result; + result = new CSharpMethodOptions(); + builderIsReadOnly = false; + MergeFrom(original); + } + return result; + } + + public override bool IsInitialized { + get { return result.IsInitialized; } + } protected override CSharpMethodOptions MessageBeingBuilt { - get { return result; } + get { return PrepareBuilder(); } } public override Builder Clear() { - result = new CSharpMethodOptions(); + result = DefaultInstance ?? new CSharpMethodOptions(); + 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 { @@ -1529,12 +1672,11 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public override CSharpMethodOptions BuildPartial() { - if (result == null) { - throw new global::System.InvalidOperationException("build() has already been called on this Builder"); + if (builderIsReadOnly) { + return result; } - CSharpMethodOptions returnMe = result; - result = null; - return returnMe; + builderIsReadOnly = true; + return result; } public override Builder MergeFrom(pb::IMessage other) { @@ -1548,6 +1690,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { public override Builder MergeFrom(CSharpMethodOptions other) { if (other == global::Google.ProtocolBuffers.DescriptorProtos.CSharpMethodOptions.DefaultInstance) return this; + PrepareBuilder(); if (other.HasDispatchId) { DispatchId = other.DispatchId; } @@ -1560,6 +1703,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { + PrepareBuilder(); pb::UnknownFieldSet.Builder unknownFields = null; uint tag; string field_name; @@ -1615,11 +1759,13 @@ namespace Google.ProtocolBuffers.DescriptorProtos { set { SetDispatchId(value); } } public Builder SetDispatchId(int value) { + PrepareBuilder(); result.hasDispatchId = true; result.dispatchId_ = value; return this; } public Builder ClearDispatchId() { + PrepareBuilder(); result.hasDispatchId = false; result.dispatchId_ = 0; return this; diff --git a/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs b/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs index ff5429d8c6..de6e2ed840 100644 --- a/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs +++ b/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs @@ -337,7 +337,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { public override Builder ToBuilder() { return CreateBuilder(this); } public override Builder CreateBuilderForType() { return new Builder(); } public static Builder CreateBuilder(FileDescriptorSet prototype) { - return (Builder) new Builder().MergeFrom(prototype); + return new Builder(prototype); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] @@ -347,21 +347,48 @@ namespace Google.ProtocolBuffers.DescriptorProtos { protected override Builder ThisBuilder { get { return this; } } - public Builder() {} + public Builder() { + result = DefaultInstance ?? new FileDescriptorSet(); + builderIsReadOnly = result == DefaultInstance; + } + internal Builder(FileDescriptorSet cloneFrom) { + result = cloneFrom; + builderIsReadOnly = true; + } + + bool builderIsReadOnly; + FileDescriptorSet result; - FileDescriptorSet result = new FileDescriptorSet(); + private FileDescriptorSet PrepareBuilder() { + if (builderIsReadOnly) { + FileDescriptorSet original = result; + result = new FileDescriptorSet(); + builderIsReadOnly = false; + MergeFrom(original); + } + return result; + } + + public override bool IsInitialized { + get { return result.IsInitialized; } + } protected override FileDescriptorSet MessageBeingBuilt { - get { return result; } + get { return PrepareBuilder(); } } public override Builder Clear() { - result = new FileDescriptorSet(); + result = DefaultInstance ?? new FileDescriptorSet(); + 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,13 +400,12 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public override FileDescriptorSet BuildPartial() { - if (result == null) { - throw new global::System.InvalidOperationException("build() has already been called on this Builder"); + if (builderIsReadOnly) { + return result; } result.file_.MakeReadOnly(); - FileDescriptorSet returnMe = result; - result = null; - return returnMe; + builderIsReadOnly = true; + return result; } public override Builder MergeFrom(pb::IMessage other) { @@ -393,6 +419,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { public override Builder MergeFrom(FileDescriptorSet other) { if (other == global::Google.ProtocolBuffers.DescriptorProtos.FileDescriptorSet.DefaultInstance) return this; + PrepareBuilder(); if (other.file_.Count != 0) { result.file_.Add(other.file_); } @@ -405,6 +432,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { + PrepareBuilder(); pb::UnknownFieldSet.Builder unknownFields = null; uint tag; string field_name; @@ -453,7 +481,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { public pbc::IPopsicleList FileList { - get { return result.file_; } + get { return PrepareBuilder().file_; } } public int FileCount { get { return result.FileCount; } @@ -463,29 +491,35 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public Builder SetFile(int index, global::Google.ProtocolBuffers.DescriptorProtos.FileDescriptorProto value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.file_[index] = value; return this; } public Builder SetFile(int index, global::Google.ProtocolBuffers.DescriptorProtos.FileDescriptorProto.Builder builderForValue) { pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); + PrepareBuilder(); result.file_[index] = builderForValue.Build(); return this; } public Builder AddFile(global::Google.ProtocolBuffers.DescriptorProtos.FileDescriptorProto value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.file_.Add(value); return this; } public Builder AddFile(global::Google.ProtocolBuffers.DescriptorProtos.FileDescriptorProto.Builder builderForValue) { pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); + PrepareBuilder(); result.file_.Add(builderForValue.Build()); return this; } public Builder AddRangeFile(scg::IEnumerable values) { + PrepareBuilder(); result.file_.Add(values); return this; } public Builder ClearFile() { + PrepareBuilder(); result.file_.Clear(); return this; } @@ -740,7 +774,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { public override Builder ToBuilder() { return CreateBuilder(this); } public override Builder CreateBuilderForType() { return new Builder(); } public static Builder CreateBuilder(FileDescriptorProto prototype) { - return (Builder) new Builder().MergeFrom(prototype); + return new Builder(prototype); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] @@ -750,21 +784,48 @@ namespace Google.ProtocolBuffers.DescriptorProtos { protected override Builder ThisBuilder { get { return this; } } - public Builder() {} + public Builder() { + result = DefaultInstance ?? new FileDescriptorProto(); + builderIsReadOnly = result == DefaultInstance; + } + internal Builder(FileDescriptorProto cloneFrom) { + result = cloneFrom; + builderIsReadOnly = true; + } - FileDescriptorProto result = new FileDescriptorProto(); + bool builderIsReadOnly; + FileDescriptorProto result; + + private FileDescriptorProto PrepareBuilder() { + if (builderIsReadOnly) { + FileDescriptorProto original = result; + result = new FileDescriptorProto(); + builderIsReadOnly = false; + MergeFrom(original); + } + return result; + } + + public override bool IsInitialized { + get { return result.IsInitialized; } + } protected override FileDescriptorProto MessageBeingBuilt { - get { return result; } + get { return PrepareBuilder(); } } public override Builder Clear() { - result = new FileDescriptorProto(); + result = DefaultInstance ?? new FileDescriptorProto(); + 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 { @@ -776,17 +837,16 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public override FileDescriptorProto BuildPartial() { - if (result == null) { - throw new global::System.InvalidOperationException("build() has already been called on this Builder"); + if (builderIsReadOnly) { + return result; } result.dependency_.MakeReadOnly(); result.messageType_.MakeReadOnly(); result.enumType_.MakeReadOnly(); result.service_.MakeReadOnly(); result.extension_.MakeReadOnly(); - FileDescriptorProto returnMe = result; - result = null; - return returnMe; + builderIsReadOnly = true; + return result; } public override Builder MergeFrom(pb::IMessage other) { @@ -800,6 +860,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { public override Builder MergeFrom(FileDescriptorProto other) { if (other == global::Google.ProtocolBuffers.DescriptorProtos.FileDescriptorProto.DefaultInstance) return this; + PrepareBuilder(); if (other.HasName) { Name = other.Name; } @@ -833,6 +894,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { + PrepareBuilder(); pb::UnknownFieldSet.Builder unknownFields = null; uint tag; string field_name; @@ -922,11 +984,13 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } 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; @@ -941,18 +1005,20 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public Builder SetPackage(string value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.hasPackage = true; result.package_ = value; return this; } public Builder ClearPackage() { + PrepareBuilder(); result.hasPackage = false; result.package_ = ""; return this; } public pbc::IPopsicleList DependencyList { - get { return result.dependency_; } + get { return PrepareBuilder().dependency_; } } public int DependencyCount { get { return result.DependencyCount; } @@ -962,25 +1028,29 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public Builder SetDependency(int index, string value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.dependency_[index] = value; return this; } public Builder AddDependency(string value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.dependency_.Add(value); return this; } public Builder AddRangeDependency(scg::IEnumerable values) { + PrepareBuilder(); result.dependency_.Add(values); return this; } public Builder ClearDependency() { + PrepareBuilder(); result.dependency_.Clear(); return this; } public pbc::IPopsicleList MessageTypeList { - get { return result.messageType_; } + get { return PrepareBuilder().messageType_; } } public int MessageTypeCount { get { return result.MessageTypeCount; } @@ -990,35 +1060,41 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public Builder SetMessageType(int index, global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.messageType_[index] = value; return this; } public Builder SetMessageType(int index, global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto.Builder builderForValue) { pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); + PrepareBuilder(); result.messageType_[index] = builderForValue.Build(); return this; } public Builder AddMessageType(global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.messageType_.Add(value); return this; } public Builder AddMessageType(global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto.Builder builderForValue) { pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); + PrepareBuilder(); result.messageType_.Add(builderForValue.Build()); return this; } public Builder AddRangeMessageType(scg::IEnumerable values) { + PrepareBuilder(); result.messageType_.Add(values); return this; } public Builder ClearMessageType() { + PrepareBuilder(); result.messageType_.Clear(); return this; } public pbc::IPopsicleList EnumTypeList { - get { return result.enumType_; } + get { return PrepareBuilder().enumType_; } } public int EnumTypeCount { get { return result.EnumTypeCount; } @@ -1028,35 +1104,41 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public Builder SetEnumType(int index, global::Google.ProtocolBuffers.DescriptorProtos.EnumDescriptorProto value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.enumType_[index] = value; return this; } public Builder SetEnumType(int index, global::Google.ProtocolBuffers.DescriptorProtos.EnumDescriptorProto.Builder builderForValue) { pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); + PrepareBuilder(); result.enumType_[index] = builderForValue.Build(); return this; } public Builder AddEnumType(global::Google.ProtocolBuffers.DescriptorProtos.EnumDescriptorProto value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.enumType_.Add(value); return this; } public Builder AddEnumType(global::Google.ProtocolBuffers.DescriptorProtos.EnumDescriptorProto.Builder builderForValue) { pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); + PrepareBuilder(); result.enumType_.Add(builderForValue.Build()); return this; } public Builder AddRangeEnumType(scg::IEnumerable values) { + PrepareBuilder(); result.enumType_.Add(values); return this; } public Builder ClearEnumType() { + PrepareBuilder(); result.enumType_.Clear(); return this; } public pbc::IPopsicleList ServiceList { - get { return result.service_; } + get { return PrepareBuilder().service_; } } public int ServiceCount { get { return result.ServiceCount; } @@ -1066,35 +1148,41 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public Builder SetService(int index, global::Google.ProtocolBuffers.DescriptorProtos.ServiceDescriptorProto value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.service_[index] = value; return this; } public Builder SetService(int index, global::Google.ProtocolBuffers.DescriptorProtos.ServiceDescriptorProto.Builder builderForValue) { pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); + PrepareBuilder(); result.service_[index] = builderForValue.Build(); return this; } public Builder AddService(global::Google.ProtocolBuffers.DescriptorProtos.ServiceDescriptorProto value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.service_.Add(value); return this; } public Builder AddService(global::Google.ProtocolBuffers.DescriptorProtos.ServiceDescriptorProto.Builder builderForValue) { pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); + PrepareBuilder(); result.service_.Add(builderForValue.Build()); return this; } public Builder AddRangeService(scg::IEnumerable values) { + PrepareBuilder(); result.service_.Add(values); return this; } public Builder ClearService() { + PrepareBuilder(); result.service_.Clear(); return this; } public pbc::IPopsicleList ExtensionList { - get { return result.extension_; } + get { return PrepareBuilder().extension_; } } public int ExtensionCount { get { return result.ExtensionCount; } @@ -1104,29 +1192,35 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public Builder SetExtension(int index, global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.extension_[index] = value; return this; } public Builder SetExtension(int index, global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto.Builder builderForValue) { pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); + PrepareBuilder(); result.extension_[index] = builderForValue.Build(); return this; } public Builder AddExtension(global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.extension_.Add(value); return this; } public Builder AddExtension(global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto.Builder builderForValue) { pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); + PrepareBuilder(); result.extension_.Add(builderForValue.Build()); return this; } public Builder AddRangeExtension(scg::IEnumerable values) { + PrepareBuilder(); result.extension_.Add(values); return this; } public Builder ClearExtension() { + PrepareBuilder(); result.extension_.Clear(); return this; } @@ -1140,18 +1234,21 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public Builder SetOptions(global::Google.ProtocolBuffers.DescriptorProtos.FileOptions value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.hasOptions = true; result.options_ = value; return this; } public Builder SetOptions(global::Google.ProtocolBuffers.DescriptorProtos.FileOptions.Builder builderForValue) { pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); + PrepareBuilder(); result.hasOptions = true; result.options_ = builderForValue.Build(); return this; } public Builder MergeOptions(global::Google.ProtocolBuffers.DescriptorProtos.FileOptions value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); if (result.hasOptions && result.options_ != global::Google.ProtocolBuffers.DescriptorProtos.FileOptions.DefaultInstance) { result.options_ = global::Google.ProtocolBuffers.DescriptorProtos.FileOptions.CreateBuilder(result.options_).MergeFrom(value).BuildPartial(); @@ -1162,6 +1259,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { return this; } public Builder ClearOptions() { + PrepareBuilder(); result.hasOptions = false; result.options_ = global::Google.ProtocolBuffers.DescriptorProtos.FileOptions.DefaultInstance; return this; @@ -1324,7 +1422,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { public override Builder ToBuilder() { return CreateBuilder(this); } public override Builder CreateBuilderForType() { return new Builder(); } public static Builder CreateBuilder(ExtensionRange prototype) { - return (Builder) new Builder().MergeFrom(prototype); + return new Builder(prototype); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] @@ -1334,21 +1432,48 @@ namespace Google.ProtocolBuffers.DescriptorProtos { protected override Builder ThisBuilder { get { return this; } } - public Builder() {} + public Builder() { + result = DefaultInstance ?? new ExtensionRange(); + builderIsReadOnly = result == DefaultInstance; + } + internal Builder(ExtensionRange cloneFrom) { + result = cloneFrom; + builderIsReadOnly = true; + } - ExtensionRange result = new ExtensionRange(); + bool builderIsReadOnly; + ExtensionRange result; + + private ExtensionRange PrepareBuilder() { + if (builderIsReadOnly) { + ExtensionRange original = result; + result = new ExtensionRange(); + builderIsReadOnly = false; + MergeFrom(original); + } + return result; + } + + public override bool IsInitialized { + get { return result.IsInitialized; } + } protected override ExtensionRange MessageBeingBuilt { - get { return result; } + get { return PrepareBuilder(); } } public override Builder Clear() { - result = new ExtensionRange(); + result = DefaultInstance ?? new ExtensionRange(); + 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 { @@ -1360,12 +1485,11 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public override ExtensionRange BuildPartial() { - if (result == null) { - throw new global::System.InvalidOperationException("build() has already been called on this Builder"); + if (builderIsReadOnly) { + return result; } - ExtensionRange returnMe = result; - result = null; - return returnMe; + builderIsReadOnly = true; + return result; } public override Builder MergeFrom(pb::IMessage other) { @@ -1379,6 +1503,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { public override Builder MergeFrom(ExtensionRange other) { if (other == global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto.Types.ExtensionRange.DefaultInstance) return this; + PrepareBuilder(); if (other.HasStart) { Start = other.Start; } @@ -1394,6 +1519,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { + PrepareBuilder(); pb::UnknownFieldSet.Builder unknownFields = null; uint tag; string field_name; @@ -1453,11 +1579,13 @@ namespace Google.ProtocolBuffers.DescriptorProtos { set { SetStart(value); } } public Builder SetStart(int value) { + PrepareBuilder(); result.hasStart = true; result.start_ = value; return this; } public Builder ClearStart() { + PrepareBuilder(); result.hasStart = false; result.start_ = 0; return this; @@ -1471,11 +1599,13 @@ namespace Google.ProtocolBuffers.DescriptorProtos { set { SetEnd(value); } } public Builder SetEnd(int value) { + PrepareBuilder(); result.hasEnd = true; result.end_ = value; return this; } public Builder ClearEnd() { + PrepareBuilder(); result.hasEnd = false; result.end_ = 0; return this; @@ -1685,7 +1815,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { public override Builder ToBuilder() { return CreateBuilder(this); } public override Builder CreateBuilderForType() { return new Builder(); } public static Builder CreateBuilder(DescriptorProto prototype) { - return (Builder) new Builder().MergeFrom(prototype); + return new Builder(prototype); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] @@ -1695,21 +1825,48 @@ namespace Google.ProtocolBuffers.DescriptorProtos { protected override Builder ThisBuilder { get { return this; } } - public Builder() {} + public Builder() { + result = DefaultInstance ?? new DescriptorProto(); + builderIsReadOnly = result == DefaultInstance; + } + internal Builder(DescriptorProto cloneFrom) { + result = cloneFrom; + builderIsReadOnly = true; + } + + bool builderIsReadOnly; + DescriptorProto result; + + private DescriptorProto PrepareBuilder() { + if (builderIsReadOnly) { + DescriptorProto original = result; + result = new DescriptorProto(); + builderIsReadOnly = false; + MergeFrom(original); + } + return result; + } - DescriptorProto result = new DescriptorProto(); + public override bool IsInitialized { + get { return result.IsInitialized; } + } protected override DescriptorProto MessageBeingBuilt { - get { return result; } + get { return PrepareBuilder(); } } public override Builder Clear() { - result = new DescriptorProto(); + result = DefaultInstance ?? new DescriptorProto(); + 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 { @@ -1721,17 +1878,16 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public override DescriptorProto BuildPartial() { - if (result == null) { - throw new global::System.InvalidOperationException("build() has already been called on this Builder"); + if (builderIsReadOnly) { + return result; } result.field_.MakeReadOnly(); result.extension_.MakeReadOnly(); result.nestedType_.MakeReadOnly(); result.enumType_.MakeReadOnly(); result.extensionRange_.MakeReadOnly(); - DescriptorProto returnMe = result; - result = null; - return returnMe; + builderIsReadOnly = true; + return result; } public override Builder MergeFrom(pb::IMessage other) { @@ -1745,6 +1901,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { public override Builder MergeFrom(DescriptorProto other) { if (other == global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto.DefaultInstance) return this; + PrepareBuilder(); if (other.HasName) { Name = other.Name; } @@ -1775,6 +1932,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { + PrepareBuilder(); pb::UnknownFieldSet.Builder unknownFields = null; uint tag; string field_name; @@ -1860,18 +2018,20 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } 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; } public pbc::IPopsicleList FieldList { - get { return result.field_; } + get { return PrepareBuilder().field_; } } public int FieldCount { get { return result.FieldCount; } @@ -1881,35 +2041,41 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public Builder SetField(int index, global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.field_[index] = value; return this; } public Builder SetField(int index, global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto.Builder builderForValue) { pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); + PrepareBuilder(); result.field_[index] = builderForValue.Build(); return this; } public Builder AddField(global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.field_.Add(value); return this; } public Builder AddField(global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto.Builder builderForValue) { pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); + PrepareBuilder(); result.field_.Add(builderForValue.Build()); return this; } public Builder AddRangeField(scg::IEnumerable values) { + PrepareBuilder(); result.field_.Add(values); return this; } public Builder ClearField() { + PrepareBuilder(); result.field_.Clear(); return this; } public pbc::IPopsicleList ExtensionList { - get { return result.extension_; } + get { return PrepareBuilder().extension_; } } public int ExtensionCount { get { return result.ExtensionCount; } @@ -1919,35 +2085,41 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public Builder SetExtension(int index, global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.extension_[index] = value; return this; } public Builder SetExtension(int index, global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto.Builder builderForValue) { pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); + PrepareBuilder(); result.extension_[index] = builderForValue.Build(); return this; } public Builder AddExtension(global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.extension_.Add(value); return this; } public Builder AddExtension(global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto.Builder builderForValue) { pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); + PrepareBuilder(); result.extension_.Add(builderForValue.Build()); return this; } public Builder AddRangeExtension(scg::IEnumerable values) { + PrepareBuilder(); result.extension_.Add(values); return this; } public Builder ClearExtension() { + PrepareBuilder(); result.extension_.Clear(); return this; } public pbc::IPopsicleList NestedTypeList { - get { return result.nestedType_; } + get { return PrepareBuilder().nestedType_; } } public int NestedTypeCount { get { return result.NestedTypeCount; } @@ -1957,35 +2129,41 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public Builder SetNestedType(int index, global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.nestedType_[index] = value; return this; } public Builder SetNestedType(int index, global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto.Builder builderForValue) { pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); + PrepareBuilder(); result.nestedType_[index] = builderForValue.Build(); return this; } public Builder AddNestedType(global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.nestedType_.Add(value); return this; } public Builder AddNestedType(global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto.Builder builderForValue) { pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); + PrepareBuilder(); result.nestedType_.Add(builderForValue.Build()); return this; } public Builder AddRangeNestedType(scg::IEnumerable values) { + PrepareBuilder(); result.nestedType_.Add(values); return this; } public Builder ClearNestedType() { + PrepareBuilder(); result.nestedType_.Clear(); return this; } public pbc::IPopsicleList EnumTypeList { - get { return result.enumType_; } + get { return PrepareBuilder().enumType_; } } public int EnumTypeCount { get { return result.EnumTypeCount; } @@ -1995,35 +2173,41 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public Builder SetEnumType(int index, global::Google.ProtocolBuffers.DescriptorProtos.EnumDescriptorProto value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.enumType_[index] = value; return this; } public Builder SetEnumType(int index, global::Google.ProtocolBuffers.DescriptorProtos.EnumDescriptorProto.Builder builderForValue) { pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); + PrepareBuilder(); result.enumType_[index] = builderForValue.Build(); return this; } public Builder AddEnumType(global::Google.ProtocolBuffers.DescriptorProtos.EnumDescriptorProto value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.enumType_.Add(value); return this; } public Builder AddEnumType(global::Google.ProtocolBuffers.DescriptorProtos.EnumDescriptorProto.Builder builderForValue) { pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); + PrepareBuilder(); result.enumType_.Add(builderForValue.Build()); return this; } public Builder AddRangeEnumType(scg::IEnumerable values) { + PrepareBuilder(); result.enumType_.Add(values); return this; } public Builder ClearEnumType() { + PrepareBuilder(); result.enumType_.Clear(); return this; } public pbc::IPopsicleList ExtensionRangeList { - get { return result.extensionRange_; } + get { return PrepareBuilder().extensionRange_; } } public int ExtensionRangeCount { get { return result.ExtensionRangeCount; } @@ -2033,29 +2217,35 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public Builder SetExtensionRange(int index, global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto.Types.ExtensionRange value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.extensionRange_[index] = value; return this; } public Builder SetExtensionRange(int index, global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto.Types.ExtensionRange.Builder builderForValue) { pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); + PrepareBuilder(); result.extensionRange_[index] = builderForValue.Build(); return this; } public Builder AddExtensionRange(global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto.Types.ExtensionRange value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.extensionRange_.Add(value); return this; } public Builder AddExtensionRange(global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto.Types.ExtensionRange.Builder builderForValue) { pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); + PrepareBuilder(); result.extensionRange_.Add(builderForValue.Build()); return this; } public Builder AddRangeExtensionRange(scg::IEnumerable values) { + PrepareBuilder(); result.extensionRange_.Add(values); return this; } public Builder ClearExtensionRange() { + PrepareBuilder(); result.extensionRange_.Clear(); return this; } @@ -2069,18 +2259,21 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public Builder SetOptions(global::Google.ProtocolBuffers.DescriptorProtos.MessageOptions value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.hasOptions = true; result.options_ = value; return this; } public Builder SetOptions(global::Google.ProtocolBuffers.DescriptorProtos.MessageOptions.Builder builderForValue) { pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); + PrepareBuilder(); result.hasOptions = true; result.options_ = builderForValue.Build(); return this; } public Builder MergeOptions(global::Google.ProtocolBuffers.DescriptorProtos.MessageOptions value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); if (result.hasOptions && result.options_ != global::Google.ProtocolBuffers.DescriptorProtos.MessageOptions.DefaultInstance) { result.options_ = global::Google.ProtocolBuffers.DescriptorProtos.MessageOptions.CreateBuilder(result.options_).MergeFrom(value).BuildPartial(); @@ -2091,6 +2284,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { return this; } public Builder ClearOptions() { + PrepareBuilder(); result.hasOptions = false; result.options_ = global::Google.ProtocolBuffers.DescriptorProtos.MessageOptions.DefaultInstance; return this; @@ -2358,7 +2552,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { public override Builder ToBuilder() { return CreateBuilder(this); } public override Builder CreateBuilderForType() { return new Builder(); } public static Builder CreateBuilder(FieldDescriptorProto prototype) { - return (Builder) new Builder().MergeFrom(prototype); + return new Builder(prototype); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] @@ -2368,21 +2562,48 @@ namespace Google.ProtocolBuffers.DescriptorProtos { protected override Builder ThisBuilder { get { return this; } } - public Builder() {} + public Builder() { + result = DefaultInstance ?? new FieldDescriptorProto(); + builderIsReadOnly = result == DefaultInstance; + } + internal Builder(FieldDescriptorProto cloneFrom) { + result = cloneFrom; + builderIsReadOnly = true; + } + + bool builderIsReadOnly; + FieldDescriptorProto result; - FieldDescriptorProto result = new FieldDescriptorProto(); + private FieldDescriptorProto PrepareBuilder() { + if (builderIsReadOnly) { + FieldDescriptorProto original = result; + result = new FieldDescriptorProto(); + builderIsReadOnly = false; + MergeFrom(original); + } + return result; + } + + public override bool IsInitialized { + get { return result.IsInitialized; } + } protected override FieldDescriptorProto MessageBeingBuilt { - get { return result; } + get { return PrepareBuilder(); } } public override Builder Clear() { - result = new FieldDescriptorProto(); + result = DefaultInstance ?? new FieldDescriptorProto(); + 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 { @@ -2394,12 +2615,11 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public override FieldDescriptorProto BuildPartial() { - if (result == null) { - throw new global::System.InvalidOperationException("build() has already been called on this Builder"); + if (builderIsReadOnly) { + return result; } - FieldDescriptorProto returnMe = result; - result = null; - return returnMe; + builderIsReadOnly = true; + return result; } public override Builder MergeFrom(pb::IMessage other) { @@ -2413,6 +2633,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { public override Builder MergeFrom(FieldDescriptorProto other) { if (other == global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto.DefaultInstance) return this; + PrepareBuilder(); if (other.HasName) { Name = other.Name; } @@ -2446,6 +2667,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { + PrepareBuilder(); pb::UnknownFieldSet.Builder unknownFields = null; uint tag; string field_name; @@ -2551,11 +2773,13 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } 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; @@ -2569,11 +2793,13 @@ namespace Google.ProtocolBuffers.DescriptorProtos { 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; @@ -2587,11 +2813,13 @@ namespace Google.ProtocolBuffers.DescriptorProtos { set { SetLabel(value); } } public Builder SetLabel(global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto.Types.Label value) { + PrepareBuilder(); result.hasLabel = true; result.label_ = value; return this; } public Builder ClearLabel() { + PrepareBuilder(); result.hasLabel = false; result.label_ = global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto.Types.Label.LABEL_OPTIONAL; return this; @@ -2605,11 +2833,13 @@ namespace Google.ProtocolBuffers.DescriptorProtos { set { SetType(value); } } public Builder SetType(global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto.Types.Type value) { + PrepareBuilder(); result.hasType = true; result.type_ = value; return this; } public Builder ClearType() { + PrepareBuilder(); result.hasType = false; result.type_ = global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto.Types.Type.TYPE_DOUBLE; return this; @@ -2624,11 +2854,13 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public Builder SetTypeName(string value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.hasTypeName = true; result.typeName_ = value; return this; } public Builder ClearTypeName() { + PrepareBuilder(); result.hasTypeName = false; result.typeName_ = ""; return this; @@ -2643,11 +2875,13 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public Builder SetExtendee(string value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.hasExtendee = true; result.extendee_ = value; return this; } public Builder ClearExtendee() { + PrepareBuilder(); result.hasExtendee = false; result.extendee_ = ""; return this; @@ -2662,11 +2896,13 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public Builder SetDefaultValue(string value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.hasDefaultValue = true; result.defaultValue_ = value; return this; } public Builder ClearDefaultValue() { + PrepareBuilder(); result.hasDefaultValue = false; result.defaultValue_ = ""; return this; @@ -2681,18 +2917,21 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public Builder SetOptions(global::Google.ProtocolBuffers.DescriptorProtos.FieldOptions value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.hasOptions = true; result.options_ = value; return this; } public Builder SetOptions(global::Google.ProtocolBuffers.DescriptorProtos.FieldOptions.Builder builderForValue) { pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); + PrepareBuilder(); result.hasOptions = true; result.options_ = builderForValue.Build(); return this; } public Builder MergeOptions(global::Google.ProtocolBuffers.DescriptorProtos.FieldOptions value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); if (result.hasOptions && result.options_ != global::Google.ProtocolBuffers.DescriptorProtos.FieldOptions.DefaultInstance) { result.options_ = global::Google.ProtocolBuffers.DescriptorProtos.FieldOptions.CreateBuilder(result.options_).MergeFrom(value).BuildPartial(); @@ -2703,6 +2942,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { return this; } public Builder ClearOptions() { + PrepareBuilder(); result.hasOptions = false; result.options_ = global::Google.ProtocolBuffers.DescriptorProtos.FieldOptions.DefaultInstance; return this; @@ -2856,7 +3096,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { public override Builder ToBuilder() { return CreateBuilder(this); } public override Builder CreateBuilderForType() { return new Builder(); } public static Builder CreateBuilder(EnumDescriptorProto prototype) { - return (Builder) new Builder().MergeFrom(prototype); + return new Builder(prototype); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] @@ -2866,21 +3106,48 @@ namespace Google.ProtocolBuffers.DescriptorProtos { protected override Builder ThisBuilder { get { return this; } } - public Builder() {} + public Builder() { + result = DefaultInstance ?? new EnumDescriptorProto(); + builderIsReadOnly = result == DefaultInstance; + } + internal Builder(EnumDescriptorProto cloneFrom) { + result = cloneFrom; + builderIsReadOnly = true; + } + + bool builderIsReadOnly; + EnumDescriptorProto result; + + private EnumDescriptorProto PrepareBuilder() { + if (builderIsReadOnly) { + EnumDescriptorProto original = result; + result = new EnumDescriptorProto(); + builderIsReadOnly = false; + MergeFrom(original); + } + return result; + } - EnumDescriptorProto result = new EnumDescriptorProto(); + public override bool IsInitialized { + get { return result.IsInitialized; } + } protected override EnumDescriptorProto MessageBeingBuilt { - get { return result; } + get { return PrepareBuilder(); } } public override Builder Clear() { - result = new EnumDescriptorProto(); + result = DefaultInstance ?? new EnumDescriptorProto(); + 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 { @@ -2892,13 +3159,12 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public override EnumDescriptorProto BuildPartial() { - if (result == null) { - throw new global::System.InvalidOperationException("build() has already been called on this Builder"); + if (builderIsReadOnly) { + return result; } result.value_.MakeReadOnly(); - EnumDescriptorProto returnMe = result; - result = null; - return returnMe; + builderIsReadOnly = true; + return result; } public override Builder MergeFrom(pb::IMessage other) { @@ -2912,6 +3178,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { public override Builder MergeFrom(EnumDescriptorProto other) { if (other == global::Google.ProtocolBuffers.DescriptorProtos.EnumDescriptorProto.DefaultInstance) return this; + PrepareBuilder(); if (other.HasName) { Name = other.Name; } @@ -2930,6 +3197,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { + PrepareBuilder(); pb::UnknownFieldSet.Builder unknownFields = null; uint tag; string field_name; @@ -2999,18 +3267,20 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } 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; } public pbc::IPopsicleList ValueList { - get { return result.value_; } + get { return PrepareBuilder().value_; } } public int ValueCount { get { return result.ValueCount; } @@ -3020,29 +3290,35 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public Builder SetValue(int index, global::Google.ProtocolBuffers.DescriptorProtos.EnumValueDescriptorProto value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.value_[index] = value; return this; } public Builder SetValue(int index, global::Google.ProtocolBuffers.DescriptorProtos.EnumValueDescriptorProto.Builder builderForValue) { pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); + PrepareBuilder(); result.value_[index] = builderForValue.Build(); return this; } public Builder AddValue(global::Google.ProtocolBuffers.DescriptorProtos.EnumValueDescriptorProto value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.value_.Add(value); return this; } public Builder AddValue(global::Google.ProtocolBuffers.DescriptorProtos.EnumValueDescriptorProto.Builder builderForValue) { pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); + PrepareBuilder(); result.value_.Add(builderForValue.Build()); return this; } public Builder AddRangeValue(scg::IEnumerable values) { + PrepareBuilder(); result.value_.Add(values); return this; } public Builder ClearValue() { + PrepareBuilder(); result.value_.Clear(); return this; } @@ -3056,18 +3332,21 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public Builder SetOptions(global::Google.ProtocolBuffers.DescriptorProtos.EnumOptions value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.hasOptions = true; result.options_ = value; return this; } public Builder SetOptions(global::Google.ProtocolBuffers.DescriptorProtos.EnumOptions.Builder builderForValue) { pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); + PrepareBuilder(); result.hasOptions = true; result.options_ = builderForValue.Build(); return this; } public Builder MergeOptions(global::Google.ProtocolBuffers.DescriptorProtos.EnumOptions value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); if (result.hasOptions && result.options_ != global::Google.ProtocolBuffers.DescriptorProtos.EnumOptions.DefaultInstance) { result.options_ = global::Google.ProtocolBuffers.DescriptorProtos.EnumOptions.CreateBuilder(result.options_).MergeFrom(value).BuildPartial(); @@ -3078,6 +3357,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { return this; } public Builder ClearOptions() { + PrepareBuilder(); result.hasOptions = false; result.options_ = global::Google.ProtocolBuffers.DescriptorProtos.EnumOptions.DefaultInstance; return this; @@ -3226,7 +3506,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { public override Builder ToBuilder() { return CreateBuilder(this); } public override Builder CreateBuilderForType() { return new Builder(); } public static Builder CreateBuilder(EnumValueDescriptorProto prototype) { - return (Builder) new Builder().MergeFrom(prototype); + return new Builder(prototype); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] @@ -3236,21 +3516,48 @@ namespace Google.ProtocolBuffers.DescriptorProtos { protected override Builder ThisBuilder { get { return this; } } - public Builder() {} + public Builder() { + result = DefaultInstance ?? new EnumValueDescriptorProto(); + builderIsReadOnly = result == DefaultInstance; + } + internal Builder(EnumValueDescriptorProto cloneFrom) { + result = cloneFrom; + builderIsReadOnly = true; + } - EnumValueDescriptorProto result = new EnumValueDescriptorProto(); + bool builderIsReadOnly; + EnumValueDescriptorProto result; + + private EnumValueDescriptorProto PrepareBuilder() { + if (builderIsReadOnly) { + EnumValueDescriptorProto original = result; + result = new EnumValueDescriptorProto(); + builderIsReadOnly = false; + MergeFrom(original); + } + return result; + } + + public override bool IsInitialized { + get { return result.IsInitialized; } + } protected override EnumValueDescriptorProto MessageBeingBuilt { - get { return result; } + get { return PrepareBuilder(); } } public override Builder Clear() { - result = new EnumValueDescriptorProto(); + result = DefaultInstance ?? new EnumValueDescriptorProto(); + 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 { @@ -3262,12 +3569,11 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public override EnumValueDescriptorProto BuildPartial() { - if (result == null) { - throw new global::System.InvalidOperationException("build() has already been called on this Builder"); + if (builderIsReadOnly) { + return result; } - EnumValueDescriptorProto returnMe = result; - result = null; - return returnMe; + builderIsReadOnly = true; + return result; } public override Builder MergeFrom(pb::IMessage other) { @@ -3281,6 +3587,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { public override Builder MergeFrom(EnumValueDescriptorProto other) { if (other == global::Google.ProtocolBuffers.DescriptorProtos.EnumValueDescriptorProto.DefaultInstance) return this; + PrepareBuilder(); if (other.HasName) { Name = other.Name; } @@ -3299,6 +3606,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { + PrepareBuilder(); pb::UnknownFieldSet.Builder unknownFields = null; uint tag; string field_name; @@ -3368,11 +3676,13 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } 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; @@ -3386,11 +3696,13 @@ namespace Google.ProtocolBuffers.DescriptorProtos { 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; @@ -3405,18 +3717,21 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public Builder SetOptions(global::Google.ProtocolBuffers.DescriptorProtos.EnumValueOptions value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.hasOptions = true; result.options_ = value; return this; } public Builder SetOptions(global::Google.ProtocolBuffers.DescriptorProtos.EnumValueOptions.Builder builderForValue) { pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); + PrepareBuilder(); result.hasOptions = true; result.options_ = builderForValue.Build(); return this; } public Builder MergeOptions(global::Google.ProtocolBuffers.DescriptorProtos.EnumValueOptions value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); if (result.hasOptions && result.options_ != global::Google.ProtocolBuffers.DescriptorProtos.EnumValueOptions.DefaultInstance) { result.options_ = global::Google.ProtocolBuffers.DescriptorProtos.EnumValueOptions.CreateBuilder(result.options_).MergeFrom(value).BuildPartial(); @@ -3427,6 +3742,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { return this; } public Builder ClearOptions() { + PrepareBuilder(); result.hasOptions = false; result.options_ = global::Google.ProtocolBuffers.DescriptorProtos.EnumValueOptions.DefaultInstance; return this; @@ -3580,7 +3896,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { public override Builder ToBuilder() { return CreateBuilder(this); } public override Builder CreateBuilderForType() { return new Builder(); } public static Builder CreateBuilder(ServiceDescriptorProto prototype) { - return (Builder) new Builder().MergeFrom(prototype); + return new Builder(prototype); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] @@ -3590,21 +3906,48 @@ namespace Google.ProtocolBuffers.DescriptorProtos { protected override Builder ThisBuilder { get { return this; } } - public Builder() {} + public Builder() { + result = DefaultInstance ?? new ServiceDescriptorProto(); + builderIsReadOnly = result == DefaultInstance; + } + internal Builder(ServiceDescriptorProto cloneFrom) { + result = cloneFrom; + builderIsReadOnly = true; + } + + bool builderIsReadOnly; + ServiceDescriptorProto result; + + private ServiceDescriptorProto PrepareBuilder() { + if (builderIsReadOnly) { + ServiceDescriptorProto original = result; + result = new ServiceDescriptorProto(); + builderIsReadOnly = false; + MergeFrom(original); + } + return result; + } - ServiceDescriptorProto result = new ServiceDescriptorProto(); + public override bool IsInitialized { + get { return result.IsInitialized; } + } protected override ServiceDescriptorProto MessageBeingBuilt { - get { return result; } + get { return PrepareBuilder(); } } public override Builder Clear() { - result = new ServiceDescriptorProto(); + result = DefaultInstance ?? new ServiceDescriptorProto(); + 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 { @@ -3616,13 +3959,12 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public override ServiceDescriptorProto BuildPartial() { - if (result == null) { - throw new global::System.InvalidOperationException("build() has already been called on this Builder"); + if (builderIsReadOnly) { + return result; } result.method_.MakeReadOnly(); - ServiceDescriptorProto returnMe = result; - result = null; - return returnMe; + builderIsReadOnly = true; + return result; } public override Builder MergeFrom(pb::IMessage other) { @@ -3636,6 +3978,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { public override Builder MergeFrom(ServiceDescriptorProto other) { if (other == global::Google.ProtocolBuffers.DescriptorProtos.ServiceDescriptorProto.DefaultInstance) return this; + PrepareBuilder(); if (other.HasName) { Name = other.Name; } @@ -3654,6 +3997,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { + PrepareBuilder(); pb::UnknownFieldSet.Builder unknownFields = null; uint tag; string field_name; @@ -3723,18 +4067,20 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } 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; } public pbc::IPopsicleList MethodList { - get { return result.method_; } + get { return PrepareBuilder().method_; } } public int MethodCount { get { return result.MethodCount; } @@ -3744,29 +4090,35 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public Builder SetMethod(int index, global::Google.ProtocolBuffers.DescriptorProtos.MethodDescriptorProto value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.method_[index] = value; return this; } public Builder SetMethod(int index, global::Google.ProtocolBuffers.DescriptorProtos.MethodDescriptorProto.Builder builderForValue) { pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); + PrepareBuilder(); result.method_[index] = builderForValue.Build(); return this; } public Builder AddMethod(global::Google.ProtocolBuffers.DescriptorProtos.MethodDescriptorProto value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.method_.Add(value); return this; } public Builder AddMethod(global::Google.ProtocolBuffers.DescriptorProtos.MethodDescriptorProto.Builder builderForValue) { pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); + PrepareBuilder(); result.method_.Add(builderForValue.Build()); return this; } public Builder AddRangeMethod(scg::IEnumerable values) { + PrepareBuilder(); result.method_.Add(values); return this; } public Builder ClearMethod() { + PrepareBuilder(); result.method_.Clear(); return this; } @@ -3780,18 +4132,21 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public Builder SetOptions(global::Google.ProtocolBuffers.DescriptorProtos.ServiceOptions value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.hasOptions = true; result.options_ = value; return this; } public Builder SetOptions(global::Google.ProtocolBuffers.DescriptorProtos.ServiceOptions.Builder builderForValue) { pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); + PrepareBuilder(); result.hasOptions = true; result.options_ = builderForValue.Build(); return this; } public Builder MergeOptions(global::Google.ProtocolBuffers.DescriptorProtos.ServiceOptions value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); if (result.hasOptions && result.options_ != global::Google.ProtocolBuffers.DescriptorProtos.ServiceOptions.DefaultInstance) { result.options_ = global::Google.ProtocolBuffers.DescriptorProtos.ServiceOptions.CreateBuilder(result.options_).MergeFrom(value).BuildPartial(); @@ -3802,6 +4157,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { return this; } public Builder ClearOptions() { + PrepareBuilder(); result.hasOptions = false; result.options_ = global::Google.ProtocolBuffers.DescriptorProtos.ServiceOptions.DefaultInstance; return this; @@ -3966,7 +4322,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { public override Builder ToBuilder() { return CreateBuilder(this); } public override Builder CreateBuilderForType() { return new Builder(); } public static Builder CreateBuilder(MethodDescriptorProto prototype) { - return (Builder) new Builder().MergeFrom(prototype); + return new Builder(prototype); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] @@ -3976,21 +4332,48 @@ namespace Google.ProtocolBuffers.DescriptorProtos { protected override Builder ThisBuilder { get { return this; } } - public Builder() {} + public Builder() { + result = DefaultInstance ?? new MethodDescriptorProto(); + builderIsReadOnly = result == DefaultInstance; + } + internal Builder(MethodDescriptorProto cloneFrom) { + result = cloneFrom; + builderIsReadOnly = true; + } + + bool builderIsReadOnly; + MethodDescriptorProto result; + + private MethodDescriptorProto PrepareBuilder() { + if (builderIsReadOnly) { + MethodDescriptorProto original = result; + result = new MethodDescriptorProto(); + builderIsReadOnly = false; + MergeFrom(original); + } + return result; + } - MethodDescriptorProto result = new MethodDescriptorProto(); + public override bool IsInitialized { + get { return result.IsInitialized; } + } protected override MethodDescriptorProto MessageBeingBuilt { - get { return result; } + get { return PrepareBuilder(); } } public override Builder Clear() { - result = new MethodDescriptorProto(); + result = DefaultInstance ?? new MethodDescriptorProto(); + 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 { @@ -4002,12 +4385,11 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public override MethodDescriptorProto BuildPartial() { - if (result == null) { - throw new global::System.InvalidOperationException("build() has already been called on this Builder"); + if (builderIsReadOnly) { + return result; } - MethodDescriptorProto returnMe = result; - result = null; - return returnMe; + builderIsReadOnly = true; + return result; } public override Builder MergeFrom(pb::IMessage other) { @@ -4021,6 +4403,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { public override Builder MergeFrom(MethodDescriptorProto other) { if (other == global::Google.ProtocolBuffers.DescriptorProtos.MethodDescriptorProto.DefaultInstance) return this; + PrepareBuilder(); if (other.HasName) { Name = other.Name; } @@ -4042,6 +4425,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { + PrepareBuilder(); pb::UnknownFieldSet.Builder unknownFields = null; uint tag; string field_name; @@ -4115,11 +4499,13 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } 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; @@ -4134,11 +4520,13 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public Builder SetInputType(string value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.hasInputType = true; result.inputType_ = value; return this; } public Builder ClearInputType() { + PrepareBuilder(); result.hasInputType = false; result.inputType_ = ""; return this; @@ -4153,11 +4541,13 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public Builder SetOutputType(string value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.hasOutputType = true; result.outputType_ = value; return this; } public Builder ClearOutputType() { + PrepareBuilder(); result.hasOutputType = false; result.outputType_ = ""; return this; @@ -4172,18 +4562,21 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public Builder SetOptions(global::Google.ProtocolBuffers.DescriptorProtos.MethodOptions value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.hasOptions = true; result.options_ = value; return this; } public Builder SetOptions(global::Google.ProtocolBuffers.DescriptorProtos.MethodOptions.Builder builderForValue) { pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); + PrepareBuilder(); result.hasOptions = true; result.options_ = builderForValue.Build(); return this; } public Builder MergeOptions(global::Google.ProtocolBuffers.DescriptorProtos.MethodOptions value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); if (result.hasOptions && result.options_ != global::Google.ProtocolBuffers.DescriptorProtos.MethodOptions.DefaultInstance) { result.options_ = global::Google.ProtocolBuffers.DescriptorProtos.MethodOptions.CreateBuilder(result.options_).MergeFrom(value).BuildPartial(); @@ -4194,6 +4587,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { return this; } public Builder ClearOptions() { + PrepareBuilder(); result.hasOptions = false; result.options_ = global::Google.ProtocolBuffers.DescriptorProtos.MethodOptions.DefaultInstance; return this; @@ -4444,7 +4838,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { public override Builder ToBuilder() { return CreateBuilder(this); } public override Builder CreateBuilderForType() { return new Builder(); } public static Builder CreateBuilder(FileOptions prototype) { - return (Builder) new Builder().MergeFrom(prototype); + return new Builder(prototype); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] @@ -4454,21 +4848,48 @@ namespace Google.ProtocolBuffers.DescriptorProtos { protected override Builder ThisBuilder { get { return this; } } - public Builder() {} + public Builder() { + result = DefaultInstance ?? new FileOptions(); + builderIsReadOnly = result == DefaultInstance; + } + internal Builder(FileOptions cloneFrom) { + result = cloneFrom; + builderIsReadOnly = true; + } + + bool builderIsReadOnly; + FileOptions result; - FileOptions result = new FileOptions(); + private FileOptions PrepareBuilder() { + if (builderIsReadOnly) { + FileOptions original = result; + result = new FileOptions(); + builderIsReadOnly = false; + MergeFrom(original); + } + return result; + } + + public override bool IsInitialized { + get { return result.IsInitialized; } + } protected override FileOptions MessageBeingBuilt { - get { return result; } + get { return PrepareBuilder(); } } public override Builder Clear() { - result = new FileOptions(); + result = DefaultInstance ?? new FileOptions(); + 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 { @@ -4480,13 +4901,12 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public override FileOptions BuildPartial() { - if (result == null) { - throw new global::System.InvalidOperationException("build() has already been called on this Builder"); + if (builderIsReadOnly) { + return result; } result.uninterpretedOption_.MakeReadOnly(); - FileOptions returnMe = result; - result = null; - return returnMe; + builderIsReadOnly = true; + return result; } public override Builder MergeFrom(pb::IMessage other) { @@ -4500,6 +4920,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { public override Builder MergeFrom(FileOptions other) { if (other == global::Google.ProtocolBuffers.DescriptorProtos.FileOptions.DefaultInstance) return this; + PrepareBuilder(); if (other.HasJavaPackage) { JavaPackage = other.JavaPackage; } @@ -4534,6 +4955,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { + PrepareBuilder(); pb::UnknownFieldSet.Builder unknownFields = null; uint tag; string field_name; @@ -4626,11 +5048,13 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public Builder SetJavaPackage(string value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.hasJavaPackage = true; result.javaPackage_ = value; return this; } public Builder ClearJavaPackage() { + PrepareBuilder(); result.hasJavaPackage = false; result.javaPackage_ = ""; return this; @@ -4645,11 +5069,13 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public Builder SetJavaOuterClassname(string value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.hasJavaOuterClassname = true; result.javaOuterClassname_ = value; return this; } public Builder ClearJavaOuterClassname() { + PrepareBuilder(); result.hasJavaOuterClassname = false; result.javaOuterClassname_ = ""; return this; @@ -4663,11 +5089,13 @@ namespace Google.ProtocolBuffers.DescriptorProtos { set { SetJavaMultipleFiles(value); } } public Builder SetJavaMultipleFiles(bool value) { + PrepareBuilder(); result.hasJavaMultipleFiles = true; result.javaMultipleFiles_ = value; return this; } public Builder ClearJavaMultipleFiles() { + PrepareBuilder(); result.hasJavaMultipleFiles = false; result.javaMultipleFiles_ = false; return this; @@ -4681,11 +5109,13 @@ namespace Google.ProtocolBuffers.DescriptorProtos { set { SetOptimizeFor(value); } } public Builder SetOptimizeFor(global::Google.ProtocolBuffers.DescriptorProtos.FileOptions.Types.OptimizeMode value) { + PrepareBuilder(); result.hasOptimizeFor = true; result.optimizeFor_ = value; return this; } public Builder ClearOptimizeFor() { + PrepareBuilder(); result.hasOptimizeFor = false; result.optimizeFor_ = global::Google.ProtocolBuffers.DescriptorProtos.FileOptions.Types.OptimizeMode.SPEED; return this; @@ -4699,11 +5129,13 @@ namespace Google.ProtocolBuffers.DescriptorProtos { set { SetCcGenericServices(value); } } public Builder SetCcGenericServices(bool value) { + PrepareBuilder(); result.hasCcGenericServices = true; result.ccGenericServices_ = value; return this; } public Builder ClearCcGenericServices() { + PrepareBuilder(); result.hasCcGenericServices = false; result.ccGenericServices_ = true; return this; @@ -4717,11 +5149,13 @@ namespace Google.ProtocolBuffers.DescriptorProtos { set { SetJavaGenericServices(value); } } public Builder SetJavaGenericServices(bool value) { + PrepareBuilder(); result.hasJavaGenericServices = true; result.javaGenericServices_ = value; return this; } public Builder ClearJavaGenericServices() { + PrepareBuilder(); result.hasJavaGenericServices = false; result.javaGenericServices_ = true; return this; @@ -4735,18 +5169,20 @@ namespace Google.ProtocolBuffers.DescriptorProtos { set { SetPyGenericServices(value); } } public Builder SetPyGenericServices(bool value) { + PrepareBuilder(); result.hasPyGenericServices = true; result.pyGenericServices_ = value; return this; } public Builder ClearPyGenericServices() { + PrepareBuilder(); result.hasPyGenericServices = false; result.pyGenericServices_ = true; return this; } public pbc::IPopsicleList UninterpretedOptionList { - get { return result.uninterpretedOption_; } + get { return PrepareBuilder().uninterpretedOption_; } } public int UninterpretedOptionCount { get { return result.UninterpretedOptionCount; } @@ -4756,29 +5192,35 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public Builder SetUninterpretedOption(int index, global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.uninterpretedOption_[index] = value; return this; } public Builder SetUninterpretedOption(int index, global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption.Builder builderForValue) { pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); + PrepareBuilder(); result.uninterpretedOption_[index] = builderForValue.Build(); return this; } public Builder AddUninterpretedOption(global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.uninterpretedOption_.Add(value); return this; } public Builder AddUninterpretedOption(global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption.Builder builderForValue) { pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); + PrepareBuilder(); result.uninterpretedOption_.Add(builderForValue.Build()); return this; } public Builder AddRangeUninterpretedOption(scg::IEnumerable values) { + PrepareBuilder(); result.uninterpretedOption_.Add(values); return this; } public Builder ClearUninterpretedOption() { + PrepareBuilder(); result.uninterpretedOption_.Clear(); return this; } @@ -4932,7 +5374,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { public override Builder ToBuilder() { return CreateBuilder(this); } public override Builder CreateBuilderForType() { return new Builder(); } public static Builder CreateBuilder(MessageOptions prototype) { - return (Builder) new Builder().MergeFrom(prototype); + return new Builder(prototype); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] @@ -4942,21 +5384,48 @@ namespace Google.ProtocolBuffers.DescriptorProtos { protected override Builder ThisBuilder { get { return this; } } - public Builder() {} + public Builder() { + result = DefaultInstance ?? new MessageOptions(); + builderIsReadOnly = result == DefaultInstance; + } + internal Builder(MessageOptions cloneFrom) { + result = cloneFrom; + builderIsReadOnly = true; + } - MessageOptions result = new MessageOptions(); + bool builderIsReadOnly; + MessageOptions result; + + private MessageOptions PrepareBuilder() { + if (builderIsReadOnly) { + MessageOptions original = result; + result = new MessageOptions(); + builderIsReadOnly = false; + MergeFrom(original); + } + return result; + } + + public override bool IsInitialized { + get { return result.IsInitialized; } + } protected override MessageOptions MessageBeingBuilt { - get { return result; } + get { return PrepareBuilder(); } } public override Builder Clear() { - result = new MessageOptions(); + result = DefaultInstance ?? new MessageOptions(); + 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 { @@ -4968,13 +5437,12 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public override MessageOptions BuildPartial() { - if (result == null) { - throw new global::System.InvalidOperationException("build() has already been called on this Builder"); + if (builderIsReadOnly) { + return result; } result.uninterpretedOption_.MakeReadOnly(); - MessageOptions returnMe = result; - result = null; - return returnMe; + builderIsReadOnly = true; + return result; } public override Builder MergeFrom(pb::IMessage other) { @@ -4988,6 +5456,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { public override Builder MergeFrom(MessageOptions other) { if (other == global::Google.ProtocolBuffers.DescriptorProtos.MessageOptions.DefaultInstance) return this; + PrepareBuilder(); if (other.HasMessageSetWireFormat) { MessageSetWireFormat = other.MessageSetWireFormat; } @@ -5007,6 +5476,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { + PrepareBuilder(); pb::UnknownFieldSet.Builder unknownFields = null; uint tag; string field_name; @@ -5070,11 +5540,13 @@ namespace Google.ProtocolBuffers.DescriptorProtos { set { SetMessageSetWireFormat(value); } } public Builder SetMessageSetWireFormat(bool value) { + PrepareBuilder(); result.hasMessageSetWireFormat = true; result.messageSetWireFormat_ = value; return this; } public Builder ClearMessageSetWireFormat() { + PrepareBuilder(); result.hasMessageSetWireFormat = false; result.messageSetWireFormat_ = false; return this; @@ -5088,18 +5560,20 @@ namespace Google.ProtocolBuffers.DescriptorProtos { set { SetNoStandardDescriptorAccessor(value); } } public Builder SetNoStandardDescriptorAccessor(bool value) { + PrepareBuilder(); result.hasNoStandardDescriptorAccessor = true; result.noStandardDescriptorAccessor_ = value; return this; } public Builder ClearNoStandardDescriptorAccessor() { + PrepareBuilder(); result.hasNoStandardDescriptorAccessor = false; result.noStandardDescriptorAccessor_ = false; return this; } public pbc::IPopsicleList UninterpretedOptionList { - get { return result.uninterpretedOption_; } + get { return PrepareBuilder().uninterpretedOption_; } } public int UninterpretedOptionCount { get { return result.UninterpretedOptionCount; } @@ -5109,29 +5583,35 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public Builder SetUninterpretedOption(int index, global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.uninterpretedOption_[index] = value; return this; } public Builder SetUninterpretedOption(int index, global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption.Builder builderForValue) { pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); + PrepareBuilder(); result.uninterpretedOption_[index] = builderForValue.Build(); return this; } public Builder AddUninterpretedOption(global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.uninterpretedOption_.Add(value); return this; } public Builder AddUninterpretedOption(global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption.Builder builderForValue) { pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); + PrepareBuilder(); result.uninterpretedOption_.Add(builderForValue.Build()); return this; } public Builder AddRangeUninterpretedOption(scg::IEnumerable values) { + PrepareBuilder(); result.uninterpretedOption_.Add(values); return this; } public Builder ClearUninterpretedOption() { + PrepareBuilder(); result.uninterpretedOption_.Clear(); return this; } @@ -5333,7 +5813,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { public override Builder ToBuilder() { return CreateBuilder(this); } public override Builder CreateBuilderForType() { return new Builder(); } public static Builder CreateBuilder(FieldOptions prototype) { - return (Builder) new Builder().MergeFrom(prototype); + return new Builder(prototype); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] @@ -5343,21 +5823,48 @@ namespace Google.ProtocolBuffers.DescriptorProtos { protected override Builder ThisBuilder { get { return this; } } - public Builder() {} + public Builder() { + result = DefaultInstance ?? new FieldOptions(); + builderIsReadOnly = result == DefaultInstance; + } + internal Builder(FieldOptions cloneFrom) { + result = cloneFrom; + builderIsReadOnly = true; + } - FieldOptions result = new FieldOptions(); + bool builderIsReadOnly; + FieldOptions result; + + private FieldOptions PrepareBuilder() { + if (builderIsReadOnly) { + FieldOptions original = result; + result = new FieldOptions(); + builderIsReadOnly = false; + MergeFrom(original); + } + return result; + } + + public override bool IsInitialized { + get { return result.IsInitialized; } + } protected override FieldOptions MessageBeingBuilt { - get { return result; } + get { return PrepareBuilder(); } } public override Builder Clear() { - result = new FieldOptions(); + result = DefaultInstance ?? new FieldOptions(); + 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 { @@ -5369,13 +5876,12 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public override FieldOptions BuildPartial() { - if (result == null) { - throw new global::System.InvalidOperationException("build() has already been called on this Builder"); + if (builderIsReadOnly) { + return result; } result.uninterpretedOption_.MakeReadOnly(); - FieldOptions returnMe = result; - result = null; - return returnMe; + builderIsReadOnly = true; + return result; } public override Builder MergeFrom(pb::IMessage other) { @@ -5389,6 +5895,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { public override Builder MergeFrom(FieldOptions other) { if (other == global::Google.ProtocolBuffers.DescriptorProtos.FieldOptions.DefaultInstance) return this; + PrepareBuilder(); if (other.HasCtype) { Ctype = other.Ctype; } @@ -5414,6 +5921,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { + PrepareBuilder(); pb::UnknownFieldSet.Builder unknownFields = null; uint tag; string field_name; @@ -5493,11 +6001,13 @@ namespace Google.ProtocolBuffers.DescriptorProtos { set { SetCtype(value); } } public Builder SetCtype(global::Google.ProtocolBuffers.DescriptorProtos.FieldOptions.Types.CType value) { + PrepareBuilder(); result.hasCtype = true; result.ctype_ = value; return this; } public Builder ClearCtype() { + PrepareBuilder(); result.hasCtype = false; result.ctype_ = global::Google.ProtocolBuffers.DescriptorProtos.FieldOptions.Types.CType.STRING; return this; @@ -5511,11 +6021,13 @@ namespace Google.ProtocolBuffers.DescriptorProtos { set { SetPacked(value); } } public Builder SetPacked(bool value) { + PrepareBuilder(); result.hasPacked = true; result.packed_ = value; return this; } public Builder ClearPacked() { + PrepareBuilder(); result.hasPacked = false; result.packed_ = false; return this; @@ -5529,11 +6041,13 @@ namespace Google.ProtocolBuffers.DescriptorProtos { set { SetDeprecated(value); } } public Builder SetDeprecated(bool value) { + PrepareBuilder(); result.hasDeprecated = true; result.deprecated_ = value; return this; } public Builder ClearDeprecated() { + PrepareBuilder(); result.hasDeprecated = false; result.deprecated_ = false; return this; @@ -5548,18 +6062,20 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public Builder SetExperimentalMapKey(string value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.hasExperimentalMapKey = true; result.experimentalMapKey_ = value; return this; } public Builder ClearExperimentalMapKey() { + PrepareBuilder(); result.hasExperimentalMapKey = false; result.experimentalMapKey_ = ""; return this; } public pbc::IPopsicleList UninterpretedOptionList { - get { return result.uninterpretedOption_; } + get { return PrepareBuilder().uninterpretedOption_; } } public int UninterpretedOptionCount { get { return result.UninterpretedOptionCount; } @@ -5569,29 +6085,35 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public Builder SetUninterpretedOption(int index, global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.uninterpretedOption_[index] = value; return this; } public Builder SetUninterpretedOption(int index, global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption.Builder builderForValue) { pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); + PrepareBuilder(); result.uninterpretedOption_[index] = builderForValue.Build(); return this; } public Builder AddUninterpretedOption(global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.uninterpretedOption_.Add(value); return this; } public Builder AddUninterpretedOption(global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption.Builder builderForValue) { pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); + PrepareBuilder(); result.uninterpretedOption_.Add(builderForValue.Build()); return this; } public Builder AddRangeUninterpretedOption(scg::IEnumerable values) { + PrepareBuilder(); result.uninterpretedOption_.Add(values); return this; } public Builder ClearUninterpretedOption() { + PrepareBuilder(); result.uninterpretedOption_.Clear(); return this; } @@ -5713,7 +6235,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { public override Builder ToBuilder() { return CreateBuilder(this); } public override Builder CreateBuilderForType() { return new Builder(); } public static Builder CreateBuilder(EnumOptions prototype) { - return (Builder) new Builder().MergeFrom(prototype); + return new Builder(prototype); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] @@ -5723,21 +6245,48 @@ namespace Google.ProtocolBuffers.DescriptorProtos { protected override Builder ThisBuilder { get { return this; } } - public Builder() {} + public Builder() { + result = DefaultInstance ?? new EnumOptions(); + builderIsReadOnly = result == DefaultInstance; + } + internal Builder(EnumOptions cloneFrom) { + result = cloneFrom; + builderIsReadOnly = true; + } + + bool builderIsReadOnly; + EnumOptions result; + + private EnumOptions PrepareBuilder() { + if (builderIsReadOnly) { + EnumOptions original = result; + result = new EnumOptions(); + builderIsReadOnly = false; + MergeFrom(original); + } + return result; + } - EnumOptions result = new EnumOptions(); + public override bool IsInitialized { + get { return result.IsInitialized; } + } protected override EnumOptions MessageBeingBuilt { - get { return result; } + get { return PrepareBuilder(); } } public override Builder Clear() { - result = new EnumOptions(); + result = DefaultInstance ?? new EnumOptions(); + 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 { @@ -5749,13 +6298,12 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public override EnumOptions BuildPartial() { - if (result == null) { - throw new global::System.InvalidOperationException("build() has already been called on this Builder"); + if (builderIsReadOnly) { + return result; } result.uninterpretedOption_.MakeReadOnly(); - EnumOptions returnMe = result; - result = null; - return returnMe; + builderIsReadOnly = true; + return result; } public override Builder MergeFrom(pb::IMessage other) { @@ -5769,6 +6317,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { public override Builder MergeFrom(EnumOptions other) { if (other == global::Google.ProtocolBuffers.DescriptorProtos.EnumOptions.DefaultInstance) return this; + PrepareBuilder(); if (other.uninterpretedOption_.Count != 0) { result.uninterpretedOption_.Add(other.uninterpretedOption_); } @@ -5782,6 +6331,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { + PrepareBuilder(); pb::UnknownFieldSet.Builder unknownFields = null; uint tag; string field_name; @@ -5830,7 +6380,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { public pbc::IPopsicleList UninterpretedOptionList { - get { return result.uninterpretedOption_; } + get { return PrepareBuilder().uninterpretedOption_; } } public int UninterpretedOptionCount { get { return result.UninterpretedOptionCount; } @@ -5840,29 +6390,35 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public Builder SetUninterpretedOption(int index, global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.uninterpretedOption_[index] = value; return this; } public Builder SetUninterpretedOption(int index, global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption.Builder builderForValue) { pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); + PrepareBuilder(); result.uninterpretedOption_[index] = builderForValue.Build(); return this; } public Builder AddUninterpretedOption(global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.uninterpretedOption_.Add(value); return this; } public Builder AddUninterpretedOption(global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption.Builder builderForValue) { pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); + PrepareBuilder(); result.uninterpretedOption_.Add(builderForValue.Build()); return this; } public Builder AddRangeUninterpretedOption(scg::IEnumerable values) { + PrepareBuilder(); result.uninterpretedOption_.Add(values); return this; } public Builder ClearUninterpretedOption() { + PrepareBuilder(); result.uninterpretedOption_.Clear(); return this; } @@ -5984,7 +6540,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { public override Builder ToBuilder() { return CreateBuilder(this); } public override Builder CreateBuilderForType() { return new Builder(); } public static Builder CreateBuilder(EnumValueOptions prototype) { - return (Builder) new Builder().MergeFrom(prototype); + return new Builder(prototype); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] @@ -5994,21 +6550,48 @@ namespace Google.ProtocolBuffers.DescriptorProtos { protected override Builder ThisBuilder { get { return this; } } - public Builder() {} + public Builder() { + result = DefaultInstance ?? new EnumValueOptions(); + builderIsReadOnly = result == DefaultInstance; + } + internal Builder(EnumValueOptions cloneFrom) { + result = cloneFrom; + builderIsReadOnly = true; + } + + bool builderIsReadOnly; + EnumValueOptions result; - EnumValueOptions result = new EnumValueOptions(); + private EnumValueOptions PrepareBuilder() { + if (builderIsReadOnly) { + EnumValueOptions original = result; + result = new EnumValueOptions(); + builderIsReadOnly = false; + MergeFrom(original); + } + return result; + } + + public override bool IsInitialized { + get { return result.IsInitialized; } + } protected override EnumValueOptions MessageBeingBuilt { - get { return result; } + get { return PrepareBuilder(); } } public override Builder Clear() { - result = new EnumValueOptions(); + result = DefaultInstance ?? new EnumValueOptions(); + 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 { @@ -6020,13 +6603,12 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public override EnumValueOptions BuildPartial() { - if (result == null) { - throw new global::System.InvalidOperationException("build() has already been called on this Builder"); + if (builderIsReadOnly) { + return result; } result.uninterpretedOption_.MakeReadOnly(); - EnumValueOptions returnMe = result; - result = null; - return returnMe; + builderIsReadOnly = true; + return result; } public override Builder MergeFrom(pb::IMessage other) { @@ -6040,6 +6622,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { public override Builder MergeFrom(EnumValueOptions other) { if (other == global::Google.ProtocolBuffers.DescriptorProtos.EnumValueOptions.DefaultInstance) return this; + PrepareBuilder(); if (other.uninterpretedOption_.Count != 0) { result.uninterpretedOption_.Add(other.uninterpretedOption_); } @@ -6053,6 +6636,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { + PrepareBuilder(); pb::UnknownFieldSet.Builder unknownFields = null; uint tag; string field_name; @@ -6101,7 +6685,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { public pbc::IPopsicleList UninterpretedOptionList { - get { return result.uninterpretedOption_; } + get { return PrepareBuilder().uninterpretedOption_; } } public int UninterpretedOptionCount { get { return result.UninterpretedOptionCount; } @@ -6111,29 +6695,35 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public Builder SetUninterpretedOption(int index, global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.uninterpretedOption_[index] = value; return this; } public Builder SetUninterpretedOption(int index, global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption.Builder builderForValue) { pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); + PrepareBuilder(); result.uninterpretedOption_[index] = builderForValue.Build(); return this; } public Builder AddUninterpretedOption(global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.uninterpretedOption_.Add(value); return this; } public Builder AddUninterpretedOption(global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption.Builder builderForValue) { pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); + PrepareBuilder(); result.uninterpretedOption_.Add(builderForValue.Build()); return this; } public Builder AddRangeUninterpretedOption(scg::IEnumerable values) { + PrepareBuilder(); result.uninterpretedOption_.Add(values); return this; } public Builder ClearUninterpretedOption() { + PrepareBuilder(); result.uninterpretedOption_.Clear(); return this; } @@ -6255,7 +6845,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { public override Builder ToBuilder() { return CreateBuilder(this); } public override Builder CreateBuilderForType() { return new Builder(); } public static Builder CreateBuilder(ServiceOptions prototype) { - return (Builder) new Builder().MergeFrom(prototype); + return new Builder(prototype); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] @@ -6265,21 +6855,48 @@ namespace Google.ProtocolBuffers.DescriptorProtos { protected override Builder ThisBuilder { get { return this; } } - public Builder() {} + public Builder() { + result = DefaultInstance ?? new ServiceOptions(); + builderIsReadOnly = result == DefaultInstance; + } + internal Builder(ServiceOptions cloneFrom) { + result = cloneFrom; + builderIsReadOnly = true; + } + + bool builderIsReadOnly; + ServiceOptions result; + + private ServiceOptions PrepareBuilder() { + if (builderIsReadOnly) { + ServiceOptions original = result; + result = new ServiceOptions(); + builderIsReadOnly = false; + MergeFrom(original); + } + return result; + } - ServiceOptions result = new ServiceOptions(); + public override bool IsInitialized { + get { return result.IsInitialized; } + } protected override ServiceOptions MessageBeingBuilt { - get { return result; } + get { return PrepareBuilder(); } } public override Builder Clear() { - result = new ServiceOptions(); + result = DefaultInstance ?? new ServiceOptions(); + 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 { @@ -6291,13 +6908,12 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public override ServiceOptions BuildPartial() { - if (result == null) { - throw new global::System.InvalidOperationException("build() has already been called on this Builder"); + if (builderIsReadOnly) { + return result; } result.uninterpretedOption_.MakeReadOnly(); - ServiceOptions returnMe = result; - result = null; - return returnMe; + builderIsReadOnly = true; + return result; } public override Builder MergeFrom(pb::IMessage other) { @@ -6311,6 +6927,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { public override Builder MergeFrom(ServiceOptions other) { if (other == global::Google.ProtocolBuffers.DescriptorProtos.ServiceOptions.DefaultInstance) return this; + PrepareBuilder(); if (other.uninterpretedOption_.Count != 0) { result.uninterpretedOption_.Add(other.uninterpretedOption_); } @@ -6324,6 +6941,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { + PrepareBuilder(); pb::UnknownFieldSet.Builder unknownFields = null; uint tag; string field_name; @@ -6372,7 +6990,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { public pbc::IPopsicleList UninterpretedOptionList { - get { return result.uninterpretedOption_; } + get { return PrepareBuilder().uninterpretedOption_; } } public int UninterpretedOptionCount { get { return result.UninterpretedOptionCount; } @@ -6382,29 +7000,35 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public Builder SetUninterpretedOption(int index, global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.uninterpretedOption_[index] = value; return this; } public Builder SetUninterpretedOption(int index, global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption.Builder builderForValue) { pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); + PrepareBuilder(); result.uninterpretedOption_[index] = builderForValue.Build(); return this; } public Builder AddUninterpretedOption(global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.uninterpretedOption_.Add(value); return this; } public Builder AddUninterpretedOption(global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption.Builder builderForValue) { pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); + PrepareBuilder(); result.uninterpretedOption_.Add(builderForValue.Build()); return this; } public Builder AddRangeUninterpretedOption(scg::IEnumerable values) { + PrepareBuilder(); result.uninterpretedOption_.Add(values); return this; } public Builder ClearUninterpretedOption() { + PrepareBuilder(); result.uninterpretedOption_.Clear(); return this; } @@ -6526,7 +7150,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { public override Builder ToBuilder() { return CreateBuilder(this); } public override Builder CreateBuilderForType() { return new Builder(); } public static Builder CreateBuilder(MethodOptions prototype) { - return (Builder) new Builder().MergeFrom(prototype); + return new Builder(prototype); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] @@ -6536,21 +7160,48 @@ namespace Google.ProtocolBuffers.DescriptorProtos { protected override Builder ThisBuilder { get { return this; } } - public Builder() {} + public Builder() { + result = DefaultInstance ?? new MethodOptions(); + builderIsReadOnly = result == DefaultInstance; + } + internal Builder(MethodOptions cloneFrom) { + result = cloneFrom; + builderIsReadOnly = true; + } - MethodOptions result = new MethodOptions(); + bool builderIsReadOnly; + MethodOptions result; + + private MethodOptions PrepareBuilder() { + if (builderIsReadOnly) { + MethodOptions original = result; + result = new MethodOptions(); + builderIsReadOnly = false; + MergeFrom(original); + } + return result; + } + + public override bool IsInitialized { + get { return result.IsInitialized; } + } protected override MethodOptions MessageBeingBuilt { - get { return result; } + get { return PrepareBuilder(); } } public override Builder Clear() { - result = new MethodOptions(); + result = DefaultInstance ?? new MethodOptions(); + 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 { @@ -6562,13 +7213,12 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public override MethodOptions BuildPartial() { - if (result == null) { - throw new global::System.InvalidOperationException("build() has already been called on this Builder"); + if (builderIsReadOnly) { + return result; } result.uninterpretedOption_.MakeReadOnly(); - MethodOptions returnMe = result; - result = null; - return returnMe; + builderIsReadOnly = true; + return result; } public override Builder MergeFrom(pb::IMessage other) { @@ -6582,6 +7232,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { public override Builder MergeFrom(MethodOptions other) { if (other == global::Google.ProtocolBuffers.DescriptorProtos.MethodOptions.DefaultInstance) return this; + PrepareBuilder(); if (other.uninterpretedOption_.Count != 0) { result.uninterpretedOption_.Add(other.uninterpretedOption_); } @@ -6595,6 +7246,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { + PrepareBuilder(); pb::UnknownFieldSet.Builder unknownFields = null; uint tag; string field_name; @@ -6643,7 +7295,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { public pbc::IPopsicleList UninterpretedOptionList { - get { return result.uninterpretedOption_; } + get { return PrepareBuilder().uninterpretedOption_; } } public int UninterpretedOptionCount { get { return result.UninterpretedOptionCount; } @@ -6653,29 +7305,35 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public Builder SetUninterpretedOption(int index, global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.uninterpretedOption_[index] = value; return this; } public Builder SetUninterpretedOption(int index, global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption.Builder builderForValue) { pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); + PrepareBuilder(); result.uninterpretedOption_[index] = builderForValue.Build(); return this; } public Builder AddUninterpretedOption(global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.uninterpretedOption_.Add(value); return this; } public Builder AddUninterpretedOption(global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption.Builder builderForValue) { pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); + PrepareBuilder(); result.uninterpretedOption_.Add(builderForValue.Build()); return this; } public Builder AddRangeUninterpretedOption(scg::IEnumerable values) { + PrepareBuilder(); result.uninterpretedOption_.Add(values); return this; } public Builder ClearUninterpretedOption() { + PrepareBuilder(); result.uninterpretedOption_.Clear(); return this; } @@ -6839,7 +7497,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { public override Builder ToBuilder() { return CreateBuilder(this); } public override Builder CreateBuilderForType() { return new Builder(); } public static Builder CreateBuilder(NamePart prototype) { - return (Builder) new Builder().MergeFrom(prototype); + return new Builder(prototype); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] @@ -6849,21 +7507,48 @@ namespace Google.ProtocolBuffers.DescriptorProtos { protected override Builder ThisBuilder { get { return this; } } - public Builder() {} + public Builder() { + result = DefaultInstance ?? new NamePart(); + builderIsReadOnly = result == DefaultInstance; + } + internal Builder(NamePart cloneFrom) { + result = cloneFrom; + builderIsReadOnly = true; + } + + bool builderIsReadOnly; + NamePart result; + + private NamePart PrepareBuilder() { + if (builderIsReadOnly) { + NamePart original = result; + result = new NamePart(); + builderIsReadOnly = false; + MergeFrom(original); + } + return result; + } - NamePart result = new NamePart(); + public override bool IsInitialized { + get { return result.IsInitialized; } + } protected override NamePart MessageBeingBuilt { - get { return result; } + get { return PrepareBuilder(); } } public override Builder Clear() { - result = new NamePart(); + result = DefaultInstance ?? new NamePart(); + 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 { @@ -6875,12 +7560,11 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public override NamePart BuildPartial() { - if (result == null) { - throw new global::System.InvalidOperationException("build() has already been called on this Builder"); + if (builderIsReadOnly) { + return result; } - NamePart returnMe = result; - result = null; - return returnMe; + builderIsReadOnly = true; + return result; } public override Builder MergeFrom(pb::IMessage other) { @@ -6894,6 +7578,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { public override Builder MergeFrom(NamePart other) { if (other == global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption.Types.NamePart.DefaultInstance) return this; + PrepareBuilder(); if (other.HasNamePart_) { NamePart_ = other.NamePart_; } @@ -6909,6 +7594,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { + PrepareBuilder(); pb::UnknownFieldSet.Builder unknownFields = null; uint tag; string field_name; @@ -6969,11 +7655,13 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public Builder SetNamePart_(string value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.hasNamePart_ = true; result.namePart_ = value; return this; } public Builder ClearNamePart_() { + PrepareBuilder(); result.hasNamePart_ = false; result.namePart_ = ""; return this; @@ -6987,11 +7675,13 @@ namespace Google.ProtocolBuffers.DescriptorProtos { set { SetIsExtension(value); } } public Builder SetIsExtension(bool value) { + PrepareBuilder(); result.hasIsExtension = true; result.isExtension_ = value; return this; } public Builder ClearIsExtension() { + PrepareBuilder(); result.hasIsExtension = false; result.isExtension_ = false; return this; @@ -7166,7 +7856,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { public override Builder ToBuilder() { return CreateBuilder(this); } public override Builder CreateBuilderForType() { return new Builder(); } public static Builder CreateBuilder(UninterpretedOption prototype) { - return (Builder) new Builder().MergeFrom(prototype); + return new Builder(prototype); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] @@ -7176,21 +7866,48 @@ namespace Google.ProtocolBuffers.DescriptorProtos { protected override Builder ThisBuilder { get { return this; } } - public Builder() {} + public Builder() { + result = DefaultInstance ?? new UninterpretedOption(); + builderIsReadOnly = result == DefaultInstance; + } + internal Builder(UninterpretedOption cloneFrom) { + result = cloneFrom; + builderIsReadOnly = true; + } + + bool builderIsReadOnly; + UninterpretedOption result; + + private UninterpretedOption PrepareBuilder() { + if (builderIsReadOnly) { + UninterpretedOption original = result; + result = new UninterpretedOption(); + builderIsReadOnly = false; + MergeFrom(original); + } + return result; + } - UninterpretedOption result = new UninterpretedOption(); + public override bool IsInitialized { + get { return result.IsInitialized; } + } protected override UninterpretedOption MessageBeingBuilt { - get { return result; } + get { return PrepareBuilder(); } } public override Builder Clear() { - result = new UninterpretedOption(); + result = DefaultInstance ?? new UninterpretedOption(); + 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 { @@ -7202,13 +7919,12 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public override UninterpretedOption BuildPartial() { - if (result == null) { - throw new global::System.InvalidOperationException("build() has already been called on this Builder"); + if (builderIsReadOnly) { + return result; } result.name_.MakeReadOnly(); - UninterpretedOption returnMe = result; - result = null; - return returnMe; + builderIsReadOnly = true; + return result; } public override Builder MergeFrom(pb::IMessage other) { @@ -7222,6 +7938,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { public override Builder MergeFrom(UninterpretedOption other) { if (other == global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption.DefaultInstance) return this; + PrepareBuilder(); if (other.name_.Count != 0) { result.name_.Add(other.name_); } @@ -7249,6 +7966,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { + PrepareBuilder(); pb::UnknownFieldSet.Builder unknownFields = null; uint tag; string field_name; @@ -7317,7 +8035,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { public pbc::IPopsicleList NameList { - get { return result.name_; } + get { return PrepareBuilder().name_; } } public int NameCount { get { return result.NameCount; } @@ -7327,29 +8045,35 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public Builder SetName(int index, global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption.Types.NamePart value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.name_[index] = value; return this; } public Builder SetName(int index, global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption.Types.NamePart.Builder builderForValue) { pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); + PrepareBuilder(); result.name_[index] = builderForValue.Build(); return this; } public Builder AddName(global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption.Types.NamePart value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.name_.Add(value); return this; } public Builder AddName(global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption.Types.NamePart.Builder builderForValue) { pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); + PrepareBuilder(); result.name_.Add(builderForValue.Build()); return this; } public Builder AddRangeName(scg::IEnumerable values) { + PrepareBuilder(); result.name_.Add(values); return this; } public Builder ClearName() { + PrepareBuilder(); result.name_.Clear(); return this; } @@ -7363,11 +8087,13 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public Builder SetIdentifierValue(string value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.hasIdentifierValue = true; result.identifierValue_ = value; return this; } public Builder ClearIdentifierValue() { + PrepareBuilder(); result.hasIdentifierValue = false; result.identifierValue_ = ""; return this; @@ -7383,11 +8109,13 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } [global::System.CLSCompliant(false)] public Builder SetPositiveIntValue(ulong value) { + PrepareBuilder(); result.hasPositiveIntValue = true; result.positiveIntValue_ = value; return this; } public Builder ClearPositiveIntValue() { + PrepareBuilder(); result.hasPositiveIntValue = false; result.positiveIntValue_ = 0UL; return this; @@ -7401,11 +8129,13 @@ namespace Google.ProtocolBuffers.DescriptorProtos { set { SetNegativeIntValue(value); } } public Builder SetNegativeIntValue(long value) { + PrepareBuilder(); result.hasNegativeIntValue = true; result.negativeIntValue_ = value; return this; } public Builder ClearNegativeIntValue() { + PrepareBuilder(); result.hasNegativeIntValue = false; result.negativeIntValue_ = 0L; return this; @@ -7419,11 +8149,13 @@ namespace Google.ProtocolBuffers.DescriptorProtos { set { SetDoubleValue(value); } } public Builder SetDoubleValue(double value) { + PrepareBuilder(); result.hasDoubleValue = true; result.doubleValue_ = value; return this; } public Builder ClearDoubleValue() { + PrepareBuilder(); result.hasDoubleValue = false; result.doubleValue_ = 0D; return this; @@ -7438,11 +8170,13 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public Builder SetStringValue(pb::ByteString value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.hasStringValue = true; result.stringValue_ = value; return this; } public Builder ClearStringValue() { + PrepareBuilder(); result.hasStringValue = false; result.stringValue_ = pb::ByteString.Empty; return this; diff --git a/src/ProtocolBuffers/GeneratedBuilder.cs b/src/ProtocolBuffers/GeneratedBuilder.cs index a56be42e6d..fd6fe4d743 100644 --- a/src/ProtocolBuffers/GeneratedBuilder.cs +++ b/src/ProtocolBuffers/GeneratedBuilder.cs @@ -58,12 +58,7 @@ namespace Google.ProtocolBuffers protected internal FieldAccessorTable InternalFieldAccessors { - get { return MessageBeingBuilt.FieldAccessorsFromBuilder; } - } - - public override bool IsInitialized - { - get { return MessageBeingBuilt.IsInitialized; } + get { return DefaultInstanceForType.FieldAccessorsFromBuilder; } } public override IDictionary AllFields @@ -97,7 +92,7 @@ namespace Google.ProtocolBuffers public override MessageDescriptor DescriptorForType { - get { return MessageBeingBuilt.DescriptorForType; } + get { return DefaultInstanceForType.DescriptorForType; } } public override int GetRepeatedFieldCount(FieldDescriptor field) @@ -204,7 +199,7 @@ namespace Google.ProtocolBuffers public override TMessage Build() { // If the message is null, we'll throw a more appropriate exception in BuildPartial. - if (MessageBeingBuilt != null && !IsInitialized) + if (!IsInitialized) { throw new UninitializedMessageException(MessageBeingBuilt); } diff --git a/src/ProtocolBuffers/GeneratedBuilderLite.cs b/src/ProtocolBuffers/GeneratedBuilderLite.cs index a5f7f89190..4030e80175 100644 --- a/src/ProtocolBuffers/GeneratedBuilderLite.cs +++ b/src/ProtocolBuffers/GeneratedBuilderLite.cs @@ -61,11 +61,6 @@ namespace Google.ProtocolBuffers public abstract TBuilder MergeFrom(TMessage other); - public override bool IsInitialized - { - get { return MessageBeingBuilt.IsInitialized; } - } - /// /// Called by derived classes to parse an unknown field. /// @@ -96,7 +91,7 @@ namespace Google.ProtocolBuffers public override TMessage Build() { // If the message is null, we'll throw a more appropriate exception in BuildPartial. - if (MessageBeingBuilt != null && !IsInitialized) + if (!IsInitialized) { throw new UninitializedMessageException(MessageBeingBuilt); } diff --git a/src/ProtocolBuffersLite.Test/TestProtos/UnitTestExtrasFullProtoFile.cs b/src/ProtocolBuffersLite.Test/TestProtos/UnitTestExtrasFullProtoFile.cs index 9119e4e9d5..260e6397e0 100644 --- a/src/ProtocolBuffersLite.Test/TestProtos/UnitTestExtrasFullProtoFile.cs +++ b/src/ProtocolBuffersLite.Test/TestProtos/UnitTestExtrasFullProtoFile.cs @@ -243,7 +243,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); } public override Builder CreateBuilderForType() { return new Builder(); } public static Builder CreateBuilder(PhoneNumber prototype) { - return (Builder) new Builder().MergeFrom(prototype); + return new Builder(prototype); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] @@ -253,21 +253,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder { get { return this; } } - public Builder() {} + public Builder() { + result = DefaultInstance ?? new PhoneNumber(); + builderIsReadOnly = result == DefaultInstance; + } + internal Builder(PhoneNumber cloneFrom) { + result = cloneFrom; + builderIsReadOnly = true; + } + + bool builderIsReadOnly; + PhoneNumber result; - PhoneNumber result = new PhoneNumber(); + private PhoneNumber PrepareBuilder() { + if (builderIsReadOnly) { + PhoneNumber original = result; + result = new PhoneNumber(); + builderIsReadOnly = false; + MergeFrom(original); + } + return result; + } + + public override bool IsInitialized { + get { return result.IsInitialized; } + } protected override PhoneNumber MessageBeingBuilt { - get { return result; } + get { return PrepareBuilder(); } } public override Builder Clear() { - result = new PhoneNumber(); + result = DefaultInstance ?? new PhoneNumber(); + 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 { @@ -279,12 +306,11 @@ namespace Google.ProtocolBuffers.TestProtos { } public override PhoneNumber BuildPartial() { - if (result == null) { - throw new global::System.InvalidOperationException("build() has already been called on this Builder"); + if (builderIsReadOnly) { + return result; } - PhoneNumber returnMe = result; - result = null; - return returnMe; + builderIsReadOnly = true; + return result; } @@ -297,11 +323,13 @@ namespace Google.ProtocolBuffers.TestProtos { } public Builder SetNumber(string value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.hasNumber = true; result.number_ = value; return this; } public Builder ClearNumber() { + PrepareBuilder(); result.hasNumber = false; result.number_ = ""; return this; @@ -315,11 +343,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetType(value); } } public Builder SetType(global::Google.ProtocolBuffers.TestProtos.TestInteropPerson.Types.PhoneType value) { + PrepareBuilder(); result.hasType = true; result.type_ = value; return this; } public Builder ClearType() { + PrepareBuilder(); result.hasType = false; result.type_ = global::Google.ProtocolBuffers.TestProtos.TestInteropPerson.Types.PhoneType.HOME; return this; @@ -441,7 +471,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); } public override Builder CreateBuilderForType() { return new Builder(); } public static Builder CreateBuilder(Addresses prototype) { - return (Builder) new Builder().MergeFrom(prototype); + return new Builder(prototype); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] @@ -451,21 +481,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder { get { return this; } } - public Builder() {} + public Builder() { + result = DefaultInstance ?? new Addresses(); + builderIsReadOnly = result == DefaultInstance; + } + internal Builder(Addresses cloneFrom) { + result = cloneFrom; + builderIsReadOnly = true; + } + + bool builderIsReadOnly; + Addresses result; + + private Addresses PrepareBuilder() { + if (builderIsReadOnly) { + Addresses original = result; + result = new Addresses(); + builderIsReadOnly = false; + MergeFrom(original); + } + return result; + } - Addresses result = new Addresses(); + public override bool IsInitialized { + get { return result.IsInitialized; } + } protected override Addresses MessageBeingBuilt { - get { return result; } + get { return PrepareBuilder(); } } public override Builder Clear() { - result = new Addresses(); + result = DefaultInstance ?? new Addresses(); + 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 { @@ -477,12 +534,11 @@ namespace Google.ProtocolBuffers.TestProtos { } public override Addresses BuildPartial() { - if (result == null) { - throw new global::System.InvalidOperationException("build() has already been called on this Builder"); + if (builderIsReadOnly) { + return result; } - Addresses returnMe = result; - result = null; - return returnMe; + builderIsReadOnly = true; + return result; } @@ -495,11 +551,13 @@ namespace Google.ProtocolBuffers.TestProtos { } public Builder SetAddress(string value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.hasAddress = true; result.address_ = value; return this; } public Builder ClearAddress() { + PrepareBuilder(); result.hasAddress = false; result.address_ = ""; return this; @@ -514,11 +572,13 @@ namespace Google.ProtocolBuffers.TestProtos { } public Builder SetAddress2(string value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.hasAddress2 = true; result.address2_ = value; return this; } public Builder ClearAddress2() { + PrepareBuilder(); result.hasAddress2 = false; result.address2_ = ""; return this; @@ -533,11 +593,13 @@ namespace Google.ProtocolBuffers.TestProtos { } public Builder SetCity(string value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.hasCity = true; result.city_ = value; return this; } public Builder ClearCity() { + PrepareBuilder(); result.hasCity = false; result.city_ = ""; return this; @@ -552,11 +614,13 @@ namespace Google.ProtocolBuffers.TestProtos { } public Builder SetState(string value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.hasState = true; result.state_ = value; return this; } public Builder ClearState() { + PrepareBuilder(); result.hasState = false; result.state_ = ""; return this; @@ -572,11 +636,13 @@ namespace Google.ProtocolBuffers.TestProtos { } [global::System.CLSCompliant(false)] public Builder SetZip(uint value) { + PrepareBuilder(); result.hasZip = true; result.zip_ = value; return this; } public Builder ClearZip() { + PrepareBuilder(); result.hasZip = false; result.zip_ = 0; return this; @@ -690,7 +756,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); } public override Builder CreateBuilderForType() { return new Builder(); } public static Builder CreateBuilder(TestInteropPerson prototype) { - return (Builder) new Builder().MergeFrom(prototype); + return new Builder(prototype); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] @@ -700,21 +766,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder { get { return this; } } - public Builder() {} + public Builder() { + result = DefaultInstance ?? new TestInteropPerson(); + builderIsReadOnly = result == DefaultInstance; + } + internal Builder(TestInteropPerson cloneFrom) { + result = cloneFrom; + builderIsReadOnly = true; + } - TestInteropPerson result = new TestInteropPerson(); + bool builderIsReadOnly; + TestInteropPerson result; + + private TestInteropPerson PrepareBuilder() { + if (builderIsReadOnly) { + TestInteropPerson original = result; + result = new TestInteropPerson(); + builderIsReadOnly = false; + MergeFrom(original); + } + return result; + } + + public override bool IsInitialized { + get { return result.IsInitialized; } + } protected override TestInteropPerson MessageBeingBuilt { - get { return result; } + get { return PrepareBuilder(); } } public override Builder Clear() { - result = new TestInteropPerson(); + result = DefaultInstance ?? new TestInteropPerson(); + 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 { @@ -726,15 +819,14 @@ namespace Google.ProtocolBuffers.TestProtos { } public override TestInteropPerson BuildPartial() { - if (result == null) { - throw new global::System.InvalidOperationException("build() has already been called on this Builder"); + if (builderIsReadOnly) { + return result; } result.codes_.MakeReadOnly(); result.phone_.MakeReadOnly(); result.addresses_.MakeReadOnly(); - TestInteropPerson returnMe = result; - result = null; - return returnMe; + builderIsReadOnly = true; + return result; } @@ -747,11 +839,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; @@ -765,11 +859,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetId(value); } } public Builder SetId(int value) { + PrepareBuilder(); result.hasId = true; result.id_ = value; return this; } public Builder ClearId() { + PrepareBuilder(); result.hasId = false; result.id_ = 0; return this; @@ -784,18 +880,20 @@ namespace Google.ProtocolBuffers.TestProtos { } public Builder SetEmail(string value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.hasEmail = true; result.email_ = value; return this; } public Builder ClearEmail() { + PrepareBuilder(); result.hasEmail = false; result.email_ = ""; return this; } public pbc::IPopsicleList CodesList { - get { return result.codes_; } + get { return PrepareBuilder().codes_; } } public int CodesCount { get { return result.CodesCount; } @@ -804,24 +902,28 @@ namespace Google.ProtocolBuffers.TestProtos { return result.GetCodes(index); } public Builder SetCodes(int index, int value) { + PrepareBuilder(); result.codes_[index] = value; return this; } public Builder AddCodes(int value) { + PrepareBuilder(); result.codes_.Add(value); return this; } public Builder AddRangeCodes(scg::IEnumerable values) { + PrepareBuilder(); result.codes_.Add(values); return this; } public Builder ClearCodes() { + PrepareBuilder(); result.codes_.Clear(); return this; } public pbc::IPopsicleList PhoneList { - get { return result.phone_; } + get { return PrepareBuilder().phone_; } } public int PhoneCount { get { return result.PhoneCount; } @@ -831,35 +933,41 @@ namespace Google.ProtocolBuffers.TestProtos { } public Builder SetPhone(int index, global::Google.ProtocolBuffers.TestProtos.TestInteropPerson.Types.PhoneNumber value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.phone_[index] = value; return this; } public Builder SetPhone(int index, global::Google.ProtocolBuffers.TestProtos.TestInteropPerson.Types.PhoneNumber.Builder builderForValue) { pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); + PrepareBuilder(); result.phone_[index] = builderForValue.Build(); return this; } public Builder AddPhone(global::Google.ProtocolBuffers.TestProtos.TestInteropPerson.Types.PhoneNumber value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.phone_.Add(value); return this; } public Builder AddPhone(global::Google.ProtocolBuffers.TestProtos.TestInteropPerson.Types.PhoneNumber.Builder builderForValue) { pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); + PrepareBuilder(); result.phone_.Add(builderForValue.Build()); return this; } public Builder AddRangePhone(scg::IEnumerable values) { + PrepareBuilder(); result.phone_.Add(values); return this; } public Builder ClearPhone() { + PrepareBuilder(); result.phone_.Clear(); return this; } public pbc::IPopsicleList AddressesList { - get { return result.addresses_; } + get { return PrepareBuilder().addresses_; } } public int AddressesCount { get { return result.AddressesCount; } @@ -869,29 +977,35 @@ namespace Google.ProtocolBuffers.TestProtos { } public Builder SetAddresses(int index, global::Google.ProtocolBuffers.TestProtos.TestInteropPerson.Types.Addresses value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.addresses_[index] = value; return this; } public Builder SetAddresses(int index, global::Google.ProtocolBuffers.TestProtos.TestInteropPerson.Types.Addresses.Builder builderForValue) { pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); + PrepareBuilder(); result.addresses_[index] = builderForValue.Build(); return this; } public Builder AddAddresses(global::Google.ProtocolBuffers.TestProtos.TestInteropPerson.Types.Addresses value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.addresses_.Add(value); return this; } public Builder AddAddresses(global::Google.ProtocolBuffers.TestProtos.TestInteropPerson.Types.Addresses.Builder builderForValue) { pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); + PrepareBuilder(); result.addresses_.Add(builderForValue.Build()); return this; } public Builder AddRangeAddresses(scg::IEnumerable values) { + PrepareBuilder(); result.addresses_.Add(values); return this; } public Builder ClearAddresses() { + PrepareBuilder(); result.addresses_.Clear(); return this; } @@ -971,7 +1085,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); } public override Builder CreateBuilderForType() { return new Builder(); } public static Builder CreateBuilder(TestInteropEmployeeId prototype) { - return (Builder) new Builder().MergeFrom(prototype); + return new Builder(prototype); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] @@ -981,21 +1095,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder { get { return this; } } - public Builder() {} + public Builder() { + result = DefaultInstance ?? new TestInteropEmployeeId(); + builderIsReadOnly = result == DefaultInstance; + } + internal Builder(TestInteropEmployeeId cloneFrom) { + result = cloneFrom; + builderIsReadOnly = true; + } + + bool builderIsReadOnly; + TestInteropEmployeeId result; + + private TestInteropEmployeeId PrepareBuilder() { + if (builderIsReadOnly) { + TestInteropEmployeeId original = result; + result = new TestInteropEmployeeId(); + builderIsReadOnly = false; + MergeFrom(original); + } + return result; + } - TestInteropEmployeeId result = new TestInteropEmployeeId(); + public override bool IsInitialized { + get { return result.IsInitialized; } + } protected override TestInteropEmployeeId MessageBeingBuilt { - get { return result; } + get { return PrepareBuilder(); } } public override Builder Clear() { - result = new TestInteropEmployeeId(); + result = DefaultInstance ?? new TestInteropEmployeeId(); + 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 { @@ -1007,12 +1148,11 @@ namespace Google.ProtocolBuffers.TestProtos { } public override TestInteropEmployeeId BuildPartial() { - if (result == null) { - throw new global::System.InvalidOperationException("build() has already been called on this Builder"); + if (builderIsReadOnly) { + return result; } - TestInteropEmployeeId returnMe = result; - result = null; - return returnMe; + builderIsReadOnly = true; + return result; } @@ -1025,11 +1165,13 @@ namespace Google.ProtocolBuffers.TestProtos { } public Builder SetNumber(string value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.hasNumber = true; result.number_ = value; return this; } public Builder ClearNumber() { + PrepareBuilder(); result.hasNumber = false; result.number_ = ""; return this; @@ -1153,7 +1295,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); } public override Builder CreateBuilderForType() { return new Builder(); } public static Builder CreateBuilder(SubA prototype) { - return (Builder) new Builder().MergeFrom(prototype); + return new Builder(prototype); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] @@ -1163,21 +1305,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder { get { return this; } } - public Builder() {} + public Builder() { + result = DefaultInstance ?? new SubA(); + builderIsReadOnly = result == DefaultInstance; + } + internal Builder(SubA cloneFrom) { + result = cloneFrom; + builderIsReadOnly = true; + } + + bool builderIsReadOnly; + SubA result; - SubA result = new SubA(); + private SubA PrepareBuilder() { + if (builderIsReadOnly) { + SubA original = result; + result = new SubA(); + builderIsReadOnly = false; + MergeFrom(original); + } + return result; + } + + public override bool IsInitialized { + get { return result.IsInitialized; } + } protected override SubA MessageBeingBuilt { - get { return result; } + get { return PrepareBuilder(); } } public override Builder Clear() { - result = new SubA(); + result = DefaultInstance ?? new SubA(); + 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 { @@ -1189,13 +1358,12 @@ namespace Google.ProtocolBuffers.TestProtos { } public override SubA BuildPartial() { - if (result == null) { - throw new global::System.InvalidOperationException("build() has already been called on this Builder"); + if (builderIsReadOnly) { + return result; } result.values_.MakeReadOnly(); - SubA returnMe = result; - result = null; - return returnMe; + builderIsReadOnly = true; + return result; } @@ -1207,18 +1375,20 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetCount(value); } } public Builder SetCount(int value) { + PrepareBuilder(); result.hasCount = true; result.count_ = value; return this; } public Builder ClearCount() { + PrepareBuilder(); result.hasCount = false; result.count_ = 0; return this; } public pbc::IPopsicleList ValuesList { - get { return result.values_; } + get { return PrepareBuilder().values_; } } public int ValuesCount { get { return result.ValuesCount; } @@ -1228,19 +1398,23 @@ namespace Google.ProtocolBuffers.TestProtos { } public Builder SetValues(int index, string value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.values_[index] = value; return this; } public Builder AddValues(string value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.values_.Add(value); return this; } public Builder AddRangeValues(scg::IEnumerable values) { + PrepareBuilder(); result.values_.Add(values); return this; } public Builder ClearValues() { + PrepareBuilder(); result.values_.Clear(); return this; } @@ -1327,7 +1501,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); } public override Builder CreateBuilderForType() { return new Builder(); } public static Builder CreateBuilder(TestMissingFieldsA prototype) { - return (Builder) new Builder().MergeFrom(prototype); + return new Builder(prototype); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] @@ -1337,21 +1511,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder { get { return this; } } - public Builder() {} + public Builder() { + result = DefaultInstance ?? new TestMissingFieldsA(); + builderIsReadOnly = result == DefaultInstance; + } + internal Builder(TestMissingFieldsA cloneFrom) { + result = cloneFrom; + builderIsReadOnly = true; + } + + bool builderIsReadOnly; + TestMissingFieldsA result; + + private TestMissingFieldsA PrepareBuilder() { + if (builderIsReadOnly) { + TestMissingFieldsA original = result; + result = new TestMissingFieldsA(); + builderIsReadOnly = false; + MergeFrom(original); + } + return result; + } - TestMissingFieldsA result = new TestMissingFieldsA(); + public override bool IsInitialized { + get { return result.IsInitialized; } + } protected override TestMissingFieldsA MessageBeingBuilt { - get { return result; } + get { return PrepareBuilder(); } } public override Builder Clear() { - result = new TestMissingFieldsA(); + result = DefaultInstance ?? new TestMissingFieldsA(); + 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 { @@ -1363,12 +1564,11 @@ namespace Google.ProtocolBuffers.TestProtos { } public override TestMissingFieldsA BuildPartial() { - if (result == null) { - throw new global::System.InvalidOperationException("build() has already been called on this Builder"); + if (builderIsReadOnly) { + return result; } - TestMissingFieldsA returnMe = result; - result = null; - return returnMe; + builderIsReadOnly = true; + return result; } @@ -1381,11 +1581,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; @@ -1399,11 +1601,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetId(value); } } public Builder SetId(int value) { + PrepareBuilder(); result.hasId = true; result.id_ = value; return this; } public Builder ClearId() { + PrepareBuilder(); result.hasId = false; result.id_ = 0; return this; @@ -1418,11 +1622,13 @@ namespace Google.ProtocolBuffers.TestProtos { } public Builder SetEmail(string value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.hasEmail = true; result.email_ = value; return this; } public Builder ClearEmail() { + PrepareBuilder(); result.hasEmail = false; result.email_ = ""; return this; @@ -1437,18 +1643,21 @@ namespace Google.ProtocolBuffers.TestProtos { } public Builder SetTestA(global::Google.ProtocolBuffers.TestProtos.TestMissingFieldsA.Types.SubA value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.hasTestA = true; result.testA_ = value; return this; } public Builder SetTestA(global::Google.ProtocolBuffers.TestProtos.TestMissingFieldsA.Types.SubA.Builder builderForValue) { pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); + PrepareBuilder(); result.hasTestA = true; result.testA_ = builderForValue.Build(); return this; } public Builder MergeTestA(global::Google.ProtocolBuffers.TestProtos.TestMissingFieldsA.Types.SubA value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); if (result.hasTestA && result.testA_ != global::Google.ProtocolBuffers.TestProtos.TestMissingFieldsA.Types.SubA.DefaultInstance) { result.testA_ = global::Google.ProtocolBuffers.TestProtos.TestMissingFieldsA.Types.SubA.CreateBuilder(result.testA_).MergeFrom(value).BuildPartial(); @@ -1459,6 +1668,7 @@ namespace Google.ProtocolBuffers.TestProtos { return this; } public Builder ClearTestA() { + PrepareBuilder(); result.hasTestA = false; result.testA_ = global::Google.ProtocolBuffers.TestProtos.TestMissingFieldsA.Types.SubA.DefaultInstance; return this; @@ -1572,7 +1782,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); } public override Builder CreateBuilderForType() { return new Builder(); } public static Builder CreateBuilder(SubB prototype) { - return (Builder) new Builder().MergeFrom(prototype); + return new Builder(prototype); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] @@ -1582,21 +1792,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder { get { return this; } } - public Builder() {} + public Builder() { + result = DefaultInstance ?? new SubB(); + builderIsReadOnly = result == DefaultInstance; + } + internal Builder(SubB cloneFrom) { + result = cloneFrom; + builderIsReadOnly = true; + } + + bool builderIsReadOnly; + SubB result; - SubB result = new SubB(); + private SubB PrepareBuilder() { + if (builderIsReadOnly) { + SubB original = result; + result = new SubB(); + builderIsReadOnly = false; + MergeFrom(original); + } + return result; + } + + public override bool IsInitialized { + get { return result.IsInitialized; } + } protected override SubB MessageBeingBuilt { - get { return result; } + get { return PrepareBuilder(); } } public override Builder Clear() { - result = new SubB(); + result = DefaultInstance ?? new SubB(); + 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 { @@ -1608,18 +1845,17 @@ namespace Google.ProtocolBuffers.TestProtos { } public override SubB BuildPartial() { - if (result == null) { - throw new global::System.InvalidOperationException("build() has already been called on this Builder"); + if (builderIsReadOnly) { + return result; } result.values_.MakeReadOnly(); - SubB returnMe = result; - result = null; - return returnMe; + builderIsReadOnly = true; + return result; } public pbc::IPopsicleList ValuesList { - get { return result.values_; } + get { return PrepareBuilder().values_; } } public int ValuesCount { get { return result.ValuesCount; } @@ -1629,19 +1865,23 @@ namespace Google.ProtocolBuffers.TestProtos { } public Builder SetValues(int index, string value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.values_[index] = value; return this; } public Builder AddValues(string value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.values_.Add(value); return this; } public Builder AddRangeValues(scg::IEnumerable values) { + PrepareBuilder(); result.values_.Add(values); return this; } public Builder ClearValues() { + PrepareBuilder(); result.values_.Clear(); return this; } @@ -1728,7 +1968,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); } public override Builder CreateBuilderForType() { return new Builder(); } public static Builder CreateBuilder(TestMissingFieldsB prototype) { - return (Builder) new Builder().MergeFrom(prototype); + return new Builder(prototype); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] @@ -1738,21 +1978,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder { get { return this; } } - public Builder() {} + public Builder() { + result = DefaultInstance ?? new TestMissingFieldsB(); + builderIsReadOnly = result == DefaultInstance; + } + internal Builder(TestMissingFieldsB cloneFrom) { + result = cloneFrom; + builderIsReadOnly = true; + } + + bool builderIsReadOnly; + TestMissingFieldsB result; + + private TestMissingFieldsB PrepareBuilder() { + if (builderIsReadOnly) { + TestMissingFieldsB original = result; + result = new TestMissingFieldsB(); + builderIsReadOnly = false; + MergeFrom(original); + } + return result; + } - TestMissingFieldsB result = new TestMissingFieldsB(); + public override bool IsInitialized { + get { return result.IsInitialized; } + } protected override TestMissingFieldsB MessageBeingBuilt { - get { return result; } + get { return PrepareBuilder(); } } public override Builder Clear() { - result = new TestMissingFieldsB(); + result = DefaultInstance ?? new TestMissingFieldsB(); + 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 { @@ -1764,12 +2031,11 @@ namespace Google.ProtocolBuffers.TestProtos { } public override TestMissingFieldsB BuildPartial() { - if (result == null) { - throw new global::System.InvalidOperationException("build() has already been called on this Builder"); + if (builderIsReadOnly) { + return result; } - TestMissingFieldsB returnMe = result; - result = null; - return returnMe; + builderIsReadOnly = true; + return result; } @@ -1782,11 +2048,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; @@ -1800,11 +2068,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetId(value); } } public Builder SetId(int value) { + PrepareBuilder(); result.hasId = true; result.id_ = value; return this; } public Builder ClearId() { + PrepareBuilder(); result.hasId = false; result.id_ = 0; return this; @@ -1819,11 +2089,13 @@ namespace Google.ProtocolBuffers.TestProtos { } public Builder SetWebsite(string value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.hasWebsite = true; result.website_ = value; return this; } public Builder ClearWebsite() { + PrepareBuilder(); result.hasWebsite = false; result.website_ = ""; return this; @@ -1838,18 +2110,21 @@ namespace Google.ProtocolBuffers.TestProtos { } public Builder SetTestB(global::Google.ProtocolBuffers.TestProtos.TestMissingFieldsB.Types.SubB value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.hasTestB = true; result.testB_ = value; return this; } public Builder SetTestB(global::Google.ProtocolBuffers.TestProtos.TestMissingFieldsB.Types.SubB.Builder builderForValue) { pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); + PrepareBuilder(); result.hasTestB = true; result.testB_ = builderForValue.Build(); return this; } public Builder MergeTestB(global::Google.ProtocolBuffers.TestProtos.TestMissingFieldsB.Types.SubB value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); if (result.hasTestB && result.testB_ != global::Google.ProtocolBuffers.TestProtos.TestMissingFieldsB.Types.SubB.DefaultInstance) { result.testB_ = global::Google.ProtocolBuffers.TestProtos.TestMissingFieldsB.Types.SubB.CreateBuilder(result.testB_).MergeFrom(value).BuildPartial(); @@ -1860,6 +2135,7 @@ namespace Google.ProtocolBuffers.TestProtos { return this; } public Builder ClearTestB() { + PrepareBuilder(); result.hasTestB = false; result.testB_ = global::Google.ProtocolBuffers.TestProtos.TestMissingFieldsB.Types.SubB.DefaultInstance; return this; diff --git a/src/ProtocolBuffersLite.Test/TestProtos/UnitTestExtrasLiteProtoFile.cs b/src/ProtocolBuffersLite.Test/TestProtos/UnitTestExtrasLiteProtoFile.cs index 07de8a6f33..550bc012f5 100644 --- a/src/ProtocolBuffersLite.Test/TestProtos/UnitTestExtrasLiteProtoFile.cs +++ b/src/ProtocolBuffersLite.Test/TestProtos/UnitTestExtrasLiteProtoFile.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(TestRequiredLite prototype) { - return (Builder) new Builder().MergeFrom(prototype); + return new Builder(prototype); } [global::System.SerializableAttribute()] @@ -200,21 +200,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder { get { return this; } } - public Builder() {} + public Builder() { + result = DefaultInstance ?? new TestRequiredLite(); + builderIsReadOnly = result == DefaultInstance; + } + internal Builder(TestRequiredLite cloneFrom) { + result = cloneFrom; + builderIsReadOnly = true; + } + + bool builderIsReadOnly; + TestRequiredLite result; + + private TestRequiredLite PrepareBuilder() { + if (builderIsReadOnly) { + TestRequiredLite original = result; + result = new TestRequiredLite(); + builderIsReadOnly = false; + MergeFrom(original); + } + return result; + } - TestRequiredLite result = new TestRequiredLite(); + public override bool IsInitialized { + get { return result.IsInitialized; } + } protected override TestRequiredLite MessageBeingBuilt { - get { return result; } + get { return PrepareBuilder(); } } public override Builder Clear() { - result = new TestRequiredLite(); + result = DefaultInstance ?? new TestRequiredLite(); + 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 TestRequiredLite DefaultInstanceForType { @@ -222,12 +249,11 @@ namespace Google.ProtocolBuffers.TestProtos { } public override TestRequiredLite BuildPartial() { - if (result == null) { - throw new global::System.InvalidOperationException("build() has already been called on this Builder"); + if (builderIsReadOnly) { + return result; } - TestRequiredLite returnMe = result; - result = null; - return returnMe; + builderIsReadOnly = true; + return result; } public override Builder MergeFrom(pb::IMessageLite other) { @@ -241,6 +267,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder MergeFrom(TestRequiredLite other) { if (other == global::Google.ProtocolBuffers.TestProtos.TestRequiredLite.DefaultInstance) return this; + PrepareBuilder(); if (other.HasD) { D = other.D; } @@ -255,6 +282,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)) { @@ -305,11 +333,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; @@ -323,11 +353,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetEn(value); } } public Builder SetEn(global::Google.ProtocolBuffers.TestProtos.ExtraEnum value) { + PrepareBuilder(); result.hasEn = true; result.en_ = value; return this; } public Builder ClearEn() { + PrepareBuilder(); result.hasEn = false; result.en_ = global::Google.ProtocolBuffers.TestProtos.ExtraEnum.DEFAULT; return this; @@ -505,7 +537,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); } public override Builder CreateBuilderForType() { return new Builder(); } public static Builder CreateBuilder(PhoneNumber prototype) { - return (Builder) new Builder().MergeFrom(prototype); + return new Builder(prototype); } [global::System.SerializableAttribute()] @@ -516,21 +548,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder { get { return this; } } - public Builder() {} + public Builder() { + result = DefaultInstance ?? new PhoneNumber(); + builderIsReadOnly = result == DefaultInstance; + } + internal Builder(PhoneNumber cloneFrom) { + result = cloneFrom; + builderIsReadOnly = true; + } - PhoneNumber result = new PhoneNumber(); + bool builderIsReadOnly; + PhoneNumber result; + + private PhoneNumber PrepareBuilder() { + if (builderIsReadOnly) { + PhoneNumber original = result; + result = new PhoneNumber(); + builderIsReadOnly = false; + MergeFrom(original); + } + return result; + } + + public override bool IsInitialized { + get { return result.IsInitialized; } + } protected override PhoneNumber MessageBeingBuilt { - get { return result; } + get { return PrepareBuilder(); } } public override Builder Clear() { - result = new PhoneNumber(); + result = DefaultInstance ?? new PhoneNumber(); + 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 PhoneNumber DefaultInstanceForType { @@ -538,12 +597,11 @@ namespace Google.ProtocolBuffers.TestProtos { } public override PhoneNumber BuildPartial() { - if (result == null) { - throw new global::System.InvalidOperationException("build() has already been called on this Builder"); + if (builderIsReadOnly) { + return result; } - PhoneNumber returnMe = result; - result = null; - return returnMe; + builderIsReadOnly = true; + return result; } public override Builder MergeFrom(pb::IMessageLite other) { @@ -557,6 +615,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder MergeFrom(PhoneNumber other) { if (other == global::Google.ProtocolBuffers.TestProtos.TestInteropPersonLite.Types.PhoneNumber.DefaultInstance) return this; + PrepareBuilder(); if (other.HasNumber) { Number = other.Number; } @@ -571,6 +630,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)) { @@ -622,11 +682,13 @@ namespace Google.ProtocolBuffers.TestProtos { } public Builder SetNumber(string value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.hasNumber = true; result.number_ = value; return this; } public Builder ClearNumber() { + PrepareBuilder(); result.hasNumber = false; result.number_ = ""; return this; @@ -640,11 +702,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetType(value); } } public Builder SetType(global::Google.ProtocolBuffers.TestProtos.TestInteropPersonLite.Types.PhoneType value) { + PrepareBuilder(); result.hasType = true; result.type_ = value; return this; } public Builder ClearType() { + PrepareBuilder(); result.hasType = false; result.type_ = global::Google.ProtocolBuffers.TestProtos.TestInteropPersonLite.Types.PhoneType.HOME; return this; @@ -849,7 +913,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); } public override Builder CreateBuilderForType() { return new Builder(); } public static Builder CreateBuilder(Addresses prototype) { - return (Builder) new Builder().MergeFrom(prototype); + return new Builder(prototype); } [global::System.SerializableAttribute()] @@ -860,21 +924,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder { get { return this; } } - public Builder() {} + public Builder() { + result = DefaultInstance ?? new Addresses(); + builderIsReadOnly = result == DefaultInstance; + } + internal Builder(Addresses cloneFrom) { + result = cloneFrom; + builderIsReadOnly = true; + } + + bool builderIsReadOnly; + Addresses result; - Addresses result = new Addresses(); + private Addresses PrepareBuilder() { + if (builderIsReadOnly) { + Addresses original = result; + result = new Addresses(); + builderIsReadOnly = false; + MergeFrom(original); + } + return result; + } + + public override bool IsInitialized { + get { return result.IsInitialized; } + } protected override Addresses MessageBeingBuilt { - get { return result; } + get { return PrepareBuilder(); } } public override Builder Clear() { - result = new Addresses(); + result = DefaultInstance ?? new Addresses(); + 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 Addresses DefaultInstanceForType { @@ -882,12 +973,11 @@ namespace Google.ProtocolBuffers.TestProtos { } public override Addresses BuildPartial() { - if (result == null) { - throw new global::System.InvalidOperationException("build() has already been called on this Builder"); + if (builderIsReadOnly) { + return result; } - Addresses returnMe = result; - result = null; - return returnMe; + builderIsReadOnly = true; + return result; } public override Builder MergeFrom(pb::IMessageLite other) { @@ -901,6 +991,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder MergeFrom(Addresses other) { if (other == global::Google.ProtocolBuffers.TestProtos.TestInteropPersonLite.Types.Addresses.DefaultInstance) return this; + PrepareBuilder(); if (other.HasAddress) { Address = other.Address; } @@ -924,6 +1015,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)) { @@ -983,11 +1075,13 @@ namespace Google.ProtocolBuffers.TestProtos { } public Builder SetAddress(string value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.hasAddress = true; result.address_ = value; return this; } public Builder ClearAddress() { + PrepareBuilder(); result.hasAddress = false; result.address_ = ""; return this; @@ -1002,11 +1096,13 @@ namespace Google.ProtocolBuffers.TestProtos { } public Builder SetAddress2(string value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.hasAddress2 = true; result.address2_ = value; return this; } public Builder ClearAddress2() { + PrepareBuilder(); result.hasAddress2 = false; result.address2_ = ""; return this; @@ -1021,11 +1117,13 @@ namespace Google.ProtocolBuffers.TestProtos { } public Builder SetCity(string value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.hasCity = true; result.city_ = value; return this; } public Builder ClearCity() { + PrepareBuilder(); result.hasCity = false; result.city_ = ""; return this; @@ -1040,11 +1138,13 @@ namespace Google.ProtocolBuffers.TestProtos { } public Builder SetState(string value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.hasState = true; result.state_ = value; return this; } public Builder ClearState() { + PrepareBuilder(); result.hasState = false; result.state_ = ""; return this; @@ -1060,11 +1160,13 @@ namespace Google.ProtocolBuffers.TestProtos { } [global::System.CLSCompliant(false)] public Builder SetZip(uint value) { + PrepareBuilder(); result.hasZip = true; result.zip_ = value; return this; } public Builder ClearZip() { + PrepareBuilder(); result.hasZip = false; result.zip_ = 0; return this; @@ -1301,7 +1403,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); } public override Builder CreateBuilderForType() { return new Builder(); } public static Builder CreateBuilder(TestInteropPersonLite prototype) { - return (Builder) new Builder().MergeFrom(prototype); + return new Builder(prototype); } [global::System.SerializableAttribute()] @@ -1312,21 +1414,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder { get { return this; } } - public Builder() {} + public Builder() { + result = DefaultInstance ?? new TestInteropPersonLite(); + builderIsReadOnly = result == DefaultInstance; + } + internal Builder(TestInteropPersonLite cloneFrom) { + result = cloneFrom; + builderIsReadOnly = true; + } - TestInteropPersonLite result = new TestInteropPersonLite(); + bool builderIsReadOnly; + TestInteropPersonLite result; + + private TestInteropPersonLite PrepareBuilder() { + if (builderIsReadOnly) { + TestInteropPersonLite original = result; + result = new TestInteropPersonLite(); + builderIsReadOnly = false; + MergeFrom(original); + } + return result; + } + + public override bool IsInitialized { + get { return result.IsInitialized; } + } protected override TestInteropPersonLite MessageBeingBuilt { - get { return result; } + get { return PrepareBuilder(); } } public override Builder Clear() { - result = new TestInteropPersonLite(); + result = DefaultInstance ?? new TestInteropPersonLite(); + 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 TestInteropPersonLite DefaultInstanceForType { @@ -1334,15 +1463,14 @@ namespace Google.ProtocolBuffers.TestProtos { } public override TestInteropPersonLite BuildPartial() { - if (result == null) { - throw new global::System.InvalidOperationException("build() has already been called on this Builder"); + if (builderIsReadOnly) { + return result; } result.codes_.MakeReadOnly(); result.phone_.MakeReadOnly(); result.addresses_.MakeReadOnly(); - TestInteropPersonLite returnMe = result; - result = null; - return returnMe; + builderIsReadOnly = true; + return result; } public override Builder MergeFrom(pb::IMessageLite other) { @@ -1356,6 +1484,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder MergeFrom(TestInteropPersonLite other) { if (other == global::Google.ProtocolBuffers.TestProtos.TestInteropPersonLite.DefaultInstance) return this; + PrepareBuilder(); if (other.HasName) { Name = other.Name; } @@ -1383,6 +1512,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)) { @@ -1447,11 +1577,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; @@ -1465,11 +1597,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetId(value); } } public Builder SetId(int value) { + PrepareBuilder(); result.hasId = true; result.id_ = value; return this; } public Builder ClearId() { + PrepareBuilder(); result.hasId = false; result.id_ = 0; return this; @@ -1484,18 +1618,20 @@ namespace Google.ProtocolBuffers.TestProtos { } public Builder SetEmail(string value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.hasEmail = true; result.email_ = value; return this; } public Builder ClearEmail() { + PrepareBuilder(); result.hasEmail = false; result.email_ = ""; return this; } public pbc::IPopsicleList CodesList { - get { return result.codes_; } + get { return PrepareBuilder().codes_; } } public int CodesCount { get { return result.CodesCount; } @@ -1504,24 +1640,28 @@ namespace Google.ProtocolBuffers.TestProtos { return result.GetCodes(index); } public Builder SetCodes(int index, int value) { + PrepareBuilder(); result.codes_[index] = value; return this; } public Builder AddCodes(int value) { + PrepareBuilder(); result.codes_.Add(value); return this; } public Builder AddRangeCodes(scg::IEnumerable values) { + PrepareBuilder(); result.codes_.Add(values); return this; } public Builder ClearCodes() { + PrepareBuilder(); result.codes_.Clear(); return this; } public pbc::IPopsicleList PhoneList { - get { return result.phone_; } + get { return PrepareBuilder().phone_; } } public int PhoneCount { get { return result.PhoneCount; } @@ -1531,35 +1671,41 @@ namespace Google.ProtocolBuffers.TestProtos { } public Builder SetPhone(int index, global::Google.ProtocolBuffers.TestProtos.TestInteropPersonLite.Types.PhoneNumber value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.phone_[index] = value; return this; } public Builder SetPhone(int index, global::Google.ProtocolBuffers.TestProtos.TestInteropPersonLite.Types.PhoneNumber.Builder builderForValue) { pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); + PrepareBuilder(); result.phone_[index] = builderForValue.Build(); return this; } public Builder AddPhone(global::Google.ProtocolBuffers.TestProtos.TestInteropPersonLite.Types.PhoneNumber value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.phone_.Add(value); return this; } public Builder AddPhone(global::Google.ProtocolBuffers.TestProtos.TestInteropPersonLite.Types.PhoneNumber.Builder builderForValue) { pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); + PrepareBuilder(); result.phone_.Add(builderForValue.Build()); return this; } public Builder AddRangePhone(scg::IEnumerable values) { + PrepareBuilder(); result.phone_.Add(values); return this; } public Builder ClearPhone() { + PrepareBuilder(); result.phone_.Clear(); return this; } public pbc::IPopsicleList AddressesList { - get { return result.addresses_; } + get { return PrepareBuilder().addresses_; } } public int AddressesCount { get { return result.AddressesCount; } @@ -1569,29 +1715,35 @@ namespace Google.ProtocolBuffers.TestProtos { } public Builder SetAddresses(int index, global::Google.ProtocolBuffers.TestProtos.TestInteropPersonLite.Types.Addresses value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.addresses_[index] = value; return this; } public Builder SetAddresses(int index, global::Google.ProtocolBuffers.TestProtos.TestInteropPersonLite.Types.Addresses.Builder builderForValue) { pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); + PrepareBuilder(); result.addresses_[index] = builderForValue.Build(); return this; } public Builder AddAddresses(global::Google.ProtocolBuffers.TestProtos.TestInteropPersonLite.Types.Addresses value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.addresses_.Add(value); return this; } public Builder AddAddresses(global::Google.ProtocolBuffers.TestProtos.TestInteropPersonLite.Types.Addresses.Builder builderForValue) { pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); + PrepareBuilder(); result.addresses_.Add(builderForValue.Build()); return this; } public Builder AddRangeAddresses(scg::IEnumerable values) { + PrepareBuilder(); result.addresses_.Add(values); return this; } public Builder ClearAddresses() { + PrepareBuilder(); result.addresses_.Clear(); return this; } @@ -1715,7 +1867,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); } public override Builder CreateBuilderForType() { return new Builder(); } public static Builder CreateBuilder(TestInteropEmployeeIdLite prototype) { - return (Builder) new Builder().MergeFrom(prototype); + return new Builder(prototype); } [global::System.SerializableAttribute()] @@ -1726,21 +1878,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder { get { return this; } } - public Builder() {} + public Builder() { + result = DefaultInstance ?? new TestInteropEmployeeIdLite(); + builderIsReadOnly = result == DefaultInstance; + } + internal Builder(TestInteropEmployeeIdLite cloneFrom) { + result = cloneFrom; + builderIsReadOnly = true; + } - TestInteropEmployeeIdLite result = new TestInteropEmployeeIdLite(); + bool builderIsReadOnly; + TestInteropEmployeeIdLite result; + + private TestInteropEmployeeIdLite PrepareBuilder() { + if (builderIsReadOnly) { + TestInteropEmployeeIdLite original = result; + result = new TestInteropEmployeeIdLite(); + builderIsReadOnly = false; + MergeFrom(original); + } + return result; + } + + public override bool IsInitialized { + get { return result.IsInitialized; } + } protected override TestInteropEmployeeIdLite MessageBeingBuilt { - get { return result; } + get { return PrepareBuilder(); } } public override Builder Clear() { - result = new TestInteropEmployeeIdLite(); + result = DefaultInstance ?? new TestInteropEmployeeIdLite(); + 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 TestInteropEmployeeIdLite DefaultInstanceForType { @@ -1748,12 +1927,11 @@ namespace Google.ProtocolBuffers.TestProtos { } public override TestInteropEmployeeIdLite BuildPartial() { - if (result == null) { - throw new global::System.InvalidOperationException("build() has already been called on this Builder"); + if (builderIsReadOnly) { + return result; } - TestInteropEmployeeIdLite returnMe = result; - result = null; - return returnMe; + builderIsReadOnly = true; + return result; } public override Builder MergeFrom(pb::IMessageLite other) { @@ -1767,6 +1945,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder MergeFrom(TestInteropEmployeeIdLite other) { if (other == global::Google.ProtocolBuffers.TestProtos.TestInteropEmployeeIdLite.DefaultInstance) return this; + PrepareBuilder(); if (other.HasNumber) { Number = other.Number; } @@ -1778,6 +1957,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)) { @@ -1821,11 +2001,13 @@ namespace Google.ProtocolBuffers.TestProtos { } public Builder SetNumber(string value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.hasNumber = true; result.number_ = value; return this; } public Builder ClearNumber() { + PrepareBuilder(); result.hasNumber = false; result.number_ = ""; return this; diff --git a/src/ProtocolBuffersLite.Test/TestProtos/UnitTestImportLiteProtoFile.cs b/src/ProtocolBuffersLite.Test/TestProtos/UnitTestImportLiteProtoFile.cs index 594c9417b8..98672cf29a 100644 --- a/src/ProtocolBuffersLite.Test/TestProtos/UnitTestImportLiteProtoFile.cs +++ b/src/ProtocolBuffersLite.Test/TestProtos/UnitTestImportLiteProtoFile.cs @@ -151,7 +151,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()] @@ -161,21 +161,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 { @@ -183,12 +210,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) { @@ -202,6 +228,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; } @@ -213,6 +240,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)) { @@ -255,11 +283,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/ProtocolBuffersLite.Test/TestProtos/UnitTestImportProtoFile.cs b/src/ProtocolBuffersLite.Test/TestProtos/UnitTestImportProtoFile.cs index c5da553795..086dda1d45 100644 --- a/src/ProtocolBuffersLite.Test/TestProtos/UnitTestImportProtoFile.cs +++ b/src/ProtocolBuffersLite.Test/TestProtos/UnitTestImportProtoFile.cs @@ -170,7 +170,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()] @@ -180,21 +180,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 { @@ -206,12 +233,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) { @@ -225,6 +251,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; } @@ -237,6 +264,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; @@ -292,11 +320,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/ProtocolBuffersLite.Test/TestProtos/UnitTestLiteImportNonLiteProtoFile.cs b/src/ProtocolBuffersLite.Test/TestProtos/UnitTestLiteImportNonLiteProtoFile.cs index 7d72f28867..2b059eb295 100644 --- a/src/ProtocolBuffersLite.Test/TestProtos/UnitTestLiteImportNonLiteProtoFile.cs +++ b/src/ProtocolBuffersLite.Test/TestProtos/UnitTestLiteImportNonLiteProtoFile.cs @@ -140,7 +140,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); } public override Builder CreateBuilderForType() { return new Builder(); } public static Builder CreateBuilder(TestLiteImportsNonlite prototype) { - return (Builder) new Builder().MergeFrom(prototype); + return new Builder(prototype); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] @@ -150,21 +150,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder { get { return this; } } - public Builder() {} + public Builder() { + result = DefaultInstance ?? new TestLiteImportsNonlite(); + builderIsReadOnly = result == DefaultInstance; + } + internal Builder(TestLiteImportsNonlite cloneFrom) { + result = cloneFrom; + builderIsReadOnly = true; + } + + bool builderIsReadOnly; + TestLiteImportsNonlite result; - TestLiteImportsNonlite result = new TestLiteImportsNonlite(); + private TestLiteImportsNonlite PrepareBuilder() { + if (builderIsReadOnly) { + TestLiteImportsNonlite original = result; + result = new TestLiteImportsNonlite(); + builderIsReadOnly = false; + MergeFrom(original); + } + return result; + } + + public override bool IsInitialized { + get { return result.IsInitialized; } + } protected override TestLiteImportsNonlite MessageBeingBuilt { - get { return result; } + get { return PrepareBuilder(); } } public override Builder Clear() { - result = new TestLiteImportsNonlite(); + result = DefaultInstance ?? new TestLiteImportsNonlite(); + 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 TestLiteImportsNonlite DefaultInstanceForType { @@ -172,12 +199,11 @@ namespace Google.ProtocolBuffers.TestProtos { } public override TestLiteImportsNonlite BuildPartial() { - if (result == null) { - throw new global::System.InvalidOperationException("build() has already been called on this Builder"); + if (builderIsReadOnly) { + return result; } - TestLiteImportsNonlite returnMe = result; - result = null; - return returnMe; + builderIsReadOnly = true; + return result; } public override Builder MergeFrom(pb::IMessageLite other) { @@ -191,6 +217,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder MergeFrom(TestLiteImportsNonlite other) { if (other == global::Google.ProtocolBuffers.TestProtos.TestLiteImportsNonlite.DefaultInstance) return this; + PrepareBuilder(); if (other.HasMessage) { MergeMessage(other.Message); } @@ -202,6 +229,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)) { @@ -250,18 +278,21 @@ namespace Google.ProtocolBuffers.TestProtos { } public Builder SetMessage(global::Google.ProtocolBuffers.TestProtos.TestAllTypes value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.hasMessage = true; result.message_ = value; return this; } public Builder SetMessage(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Builder builderForValue) { pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); + PrepareBuilder(); result.hasMessage = true; result.message_ = builderForValue.Build(); return this; } public Builder MergeMessage(global::Google.ProtocolBuffers.TestProtos.TestAllTypes value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); if (result.hasMessage && result.message_ != global::Google.ProtocolBuffers.TestProtos.TestAllTypes.DefaultInstance) { result.message_ = global::Google.ProtocolBuffers.TestProtos.TestAllTypes.CreateBuilder(result.message_).MergeFrom(value).BuildPartial(); @@ -272,6 +303,7 @@ namespace Google.ProtocolBuffers.TestProtos { return this; } public Builder ClearMessage() { + PrepareBuilder(); result.hasMessage = false; result.message_ = global::Google.ProtocolBuffers.TestProtos.TestAllTypes.DefaultInstance; return this; diff --git a/src/ProtocolBuffersLite.Test/TestProtos/UnitTestLiteProtoFile.cs b/src/ProtocolBuffersLite.Test/TestProtos/UnitTestLiteProtoFile.cs index 3135a4ba70..90c792b388 100644 --- a/src/ProtocolBuffersLite.Test/TestProtos/UnitTestLiteProtoFile.cs +++ b/src/ProtocolBuffersLite.Test/TestProtos/UnitTestLiteProtoFile.cs @@ -1369,7 +1369,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()] @@ -1379,21 +1379,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 NestedMessage DefaultInstanceForType { @@ -1401,12 +1428,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::IMessageLite other) { @@ -1420,6 +1446,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder MergeFrom(NestedMessage other) { if (other == global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.NestedMessage.DefaultInstance) return this; + PrepareBuilder(); if (other.HasBb) { Bb = other.Bb; } @@ -1431,6 +1458,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)) { @@ -1473,11 +1501,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; @@ -1600,7 +1630,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()] @@ -1610,21 +1640,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 OptionalGroup DefaultInstanceForType { @@ -1632,12 +1689,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::IMessageLite other) { @@ -1651,6 +1707,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder MergeFrom(OptionalGroup other) { if (other == global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.OptionalGroup.DefaultInstance) return this; + PrepareBuilder(); if (other.HasA) { A = other.A; } @@ -1662,6 +1719,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)) { @@ -1704,11 +1762,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; @@ -1831,7 +1891,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()] @@ -1841,21 +1901,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; + + private RepeatedGroup PrepareBuilder() { + if (builderIsReadOnly) { + RepeatedGroup original = result; + result = new RepeatedGroup(); + builderIsReadOnly = false; + MergeFrom(original); + } + return result; + } - RepeatedGroup result = new RepeatedGroup(); + 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 RepeatedGroup DefaultInstanceForType { @@ -1863,12 +1950,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::IMessageLite other) { @@ -1882,6 +1968,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder MergeFrom(RepeatedGroup other) { if (other == global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.RepeatedGroup.DefaultInstance) return this; + PrepareBuilder(); if (other.HasA) { A = other.A; } @@ -1893,6 +1980,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)) { @@ -1935,11 +2023,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; @@ -3546,7 +3636,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); } public override Builder CreateBuilderForType() { return new Builder(); } public static Builder CreateBuilder(TestAllTypesLite prototype) { - return (Builder) new Builder().MergeFrom(prototype); + return new Builder(prototype); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] @@ -3556,21 +3646,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder { get { return this; } } - public Builder() {} + public Builder() { + result = DefaultInstance ?? new TestAllTypesLite(); + builderIsReadOnly = result == DefaultInstance; + } + internal Builder(TestAllTypesLite cloneFrom) { + result = cloneFrom; + builderIsReadOnly = true; + } - TestAllTypesLite result = new TestAllTypesLite(); + bool builderIsReadOnly; + TestAllTypesLite result; + + private TestAllTypesLite PrepareBuilder() { + if (builderIsReadOnly) { + TestAllTypesLite original = result; + result = new TestAllTypesLite(); + builderIsReadOnly = false; + MergeFrom(original); + } + return result; + } + + public override bool IsInitialized { + get { return result.IsInitialized; } + } protected override TestAllTypesLite MessageBeingBuilt { - get { return result; } + get { return PrepareBuilder(); } } public override Builder Clear() { - result = new TestAllTypesLite(); + result = DefaultInstance ?? new TestAllTypesLite(); + 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 TestAllTypesLite DefaultInstanceForType { @@ -3578,8 +3695,8 @@ namespace Google.ProtocolBuffers.TestProtos { } public override TestAllTypesLite 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(); @@ -3605,9 +3722,8 @@ namespace Google.ProtocolBuffers.TestProtos { result.repeatedImportEnum_.MakeReadOnly(); result.repeatedStringPiece_.MakeReadOnly(); result.repeatedCord_.MakeReadOnly(); - TestAllTypesLite returnMe = result; - result = null; - return returnMe; + builderIsReadOnly = true; + return result; } public override Builder MergeFrom(pb::IMessageLite other) { @@ -3621,6 +3737,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder MergeFrom(TestAllTypesLite other) { if (other == global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.DefaultInstance) return this; + PrepareBuilder(); if (other.HasOptionalInt32) { OptionalInt32 = other.OptionalInt32; } @@ -3833,6 +3950,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)) { @@ -4206,11 +4324,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; @@ -4224,11 +4344,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; @@ -4244,11 +4366,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; @@ -4264,11 +4388,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; @@ -4282,11 +4408,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; @@ -4300,11 +4428,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; @@ -4320,11 +4450,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; @@ -4340,11 +4472,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; @@ -4358,11 +4492,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; @@ -4376,11 +4512,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; @@ -4394,11 +4532,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; @@ -4412,11 +4552,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; @@ -4430,11 +4572,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; @@ -4449,11 +4593,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; @@ -4468,11 +4614,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; @@ -4487,18 +4635,21 @@ namespace Google.ProtocolBuffers.TestProtos { } public Builder SetOptionalGroup(global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.OptionalGroup value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.hasOptionalGroup = true; result.optionalGroup_ = value; return this; } public Builder SetOptionalGroup(global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.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.TestAllTypesLite.Types.OptionalGroup value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); if (result.hasOptionalGroup && result.optionalGroup_ != global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.OptionalGroup.DefaultInstance) { result.optionalGroup_ = global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.OptionalGroup.CreateBuilder(result.optionalGroup_).MergeFrom(value).BuildPartial(); @@ -4509,6 +4660,7 @@ namespace Google.ProtocolBuffers.TestProtos { return this; } public Builder ClearOptionalGroup() { + PrepareBuilder(); result.hasOptionalGroup = false; result.optionalGroup_ = global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.OptionalGroup.DefaultInstance; return this; @@ -4523,18 +4675,21 @@ namespace Google.ProtocolBuffers.TestProtos { } public Builder SetOptionalNestedMessage(global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.NestedMessage value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.hasOptionalNestedMessage = true; result.optionalNestedMessage_ = value; return this; } public Builder SetOptionalNestedMessage(global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.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.TestAllTypesLite.Types.NestedMessage value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); if (result.hasOptionalNestedMessage && result.optionalNestedMessage_ != global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.NestedMessage.DefaultInstance) { result.optionalNestedMessage_ = global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.NestedMessage.CreateBuilder(result.optionalNestedMessage_).MergeFrom(value).BuildPartial(); @@ -4545,6 +4700,7 @@ namespace Google.ProtocolBuffers.TestProtos { return this; } public Builder ClearOptionalNestedMessage() { + PrepareBuilder(); result.hasOptionalNestedMessage = false; result.optionalNestedMessage_ = global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.NestedMessage.DefaultInstance; return this; @@ -4559,18 +4715,21 @@ namespace Google.ProtocolBuffers.TestProtos { } public Builder SetOptionalForeignMessage(global::Google.ProtocolBuffers.TestProtos.ForeignMessageLite value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.hasOptionalForeignMessage = true; result.optionalForeignMessage_ = value; return this; } public Builder SetOptionalForeignMessage(global::Google.ProtocolBuffers.TestProtos.ForeignMessageLite.Builder builderForValue) { pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); + PrepareBuilder(); result.hasOptionalForeignMessage = true; result.optionalForeignMessage_ = builderForValue.Build(); return this; } public Builder MergeOptionalForeignMessage(global::Google.ProtocolBuffers.TestProtos.ForeignMessageLite value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); if (result.hasOptionalForeignMessage && result.optionalForeignMessage_ != global::Google.ProtocolBuffers.TestProtos.ForeignMessageLite.DefaultInstance) { result.optionalForeignMessage_ = global::Google.ProtocolBuffers.TestProtos.ForeignMessageLite.CreateBuilder(result.optionalForeignMessage_).MergeFrom(value).BuildPartial(); @@ -4581,6 +4740,7 @@ namespace Google.ProtocolBuffers.TestProtos { return this; } public Builder ClearOptionalForeignMessage() { + PrepareBuilder(); result.hasOptionalForeignMessage = false; result.optionalForeignMessage_ = global::Google.ProtocolBuffers.TestProtos.ForeignMessageLite.DefaultInstance; return this; @@ -4595,18 +4755,21 @@ namespace Google.ProtocolBuffers.TestProtos { } public Builder SetOptionalImportMessage(global::Google.ProtocolBuffers.TestProtos.ImportMessageLite value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.hasOptionalImportMessage = true; result.optionalImportMessage_ = value; return this; } public Builder SetOptionalImportMessage(global::Google.ProtocolBuffers.TestProtos.ImportMessageLite.Builder builderForValue) { pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); + PrepareBuilder(); result.hasOptionalImportMessage = true; result.optionalImportMessage_ = builderForValue.Build(); return this; } public Builder MergeOptionalImportMessage(global::Google.ProtocolBuffers.TestProtos.ImportMessageLite value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); if (result.hasOptionalImportMessage && result.optionalImportMessage_ != global::Google.ProtocolBuffers.TestProtos.ImportMessageLite.DefaultInstance) { result.optionalImportMessage_ = global::Google.ProtocolBuffers.TestProtos.ImportMessageLite.CreateBuilder(result.optionalImportMessage_).MergeFrom(value).BuildPartial(); @@ -4617,6 +4780,7 @@ namespace Google.ProtocolBuffers.TestProtos { return this; } public Builder ClearOptionalImportMessage() { + PrepareBuilder(); result.hasOptionalImportMessage = false; result.optionalImportMessage_ = global::Google.ProtocolBuffers.TestProtos.ImportMessageLite.DefaultInstance; return this; @@ -4630,11 +4794,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetOptionalNestedEnum(value); } } public Builder SetOptionalNestedEnum(global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.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.TestAllTypesLite.Types.NestedEnum.FOO; return this; @@ -4648,11 +4814,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetOptionalForeignEnum(value); } } public Builder SetOptionalForeignEnum(global::Google.ProtocolBuffers.TestProtos.ForeignEnumLite value) { + PrepareBuilder(); result.hasOptionalForeignEnum = true; result.optionalForeignEnum_ = value; return this; } public Builder ClearOptionalForeignEnum() { + PrepareBuilder(); result.hasOptionalForeignEnum = false; result.optionalForeignEnum_ = global::Google.ProtocolBuffers.TestProtos.ForeignEnumLite.FOREIGN_LITE_FOO; return this; @@ -4666,11 +4834,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetOptionalImportEnum(value); } } public Builder SetOptionalImportEnum(global::Google.ProtocolBuffers.TestProtos.ImportEnumLite value) { + PrepareBuilder(); result.hasOptionalImportEnum = true; result.optionalImportEnum_ = value; return this; } public Builder ClearOptionalImportEnum() { + PrepareBuilder(); result.hasOptionalImportEnum = false; result.optionalImportEnum_ = global::Google.ProtocolBuffers.TestProtos.ImportEnumLite.IMPORT_LITE_FOO; return this; @@ -4685,11 +4855,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; @@ -4704,18 +4876,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 RepeatedInt32List { - get { return result.repeatedInt32_; } + get { return PrepareBuilder().repeatedInt32_; } } public int RepeatedInt32Count { get { return result.RepeatedInt32Count; } @@ -4724,24 +4898,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 values) { + PrepareBuilder(); result.repeatedInt32_.Add(values); return this; } public Builder ClearRepeatedInt32() { + PrepareBuilder(); result.repeatedInt32_.Clear(); return this; } public pbc::IPopsicleList RepeatedInt64List { - get { return result.repeatedInt64_; } + get { return PrepareBuilder().repeatedInt64_; } } public int RepeatedInt64Count { get { return result.RepeatedInt64Count; } @@ -4750,25 +4928,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 values) { + PrepareBuilder(); result.repeatedInt64_.Add(values); return this; } public Builder ClearRepeatedInt64() { + PrepareBuilder(); result.repeatedInt64_.Clear(); return this; } [global::System.CLSCompliant(false)] public pbc::IPopsicleList RepeatedUint32List { - get { return result.repeatedUint32_; } + get { return PrepareBuilder().repeatedUint32_; } } public int RepeatedUint32Count { get { return result.RepeatedUint32Count; } @@ -4779,27 +4961,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 values) { + PrepareBuilder(); result.repeatedUint32_.Add(values); return this; } public Builder ClearRepeatedUint32() { + PrepareBuilder(); result.repeatedUint32_.Clear(); return this; } [global::System.CLSCompliant(false)] public pbc::IPopsicleList RepeatedUint64List { - get { return result.repeatedUint64_; } + get { return PrepareBuilder().repeatedUint64_; } } public int RepeatedUint64Count { get { return result.RepeatedUint64Count; } @@ -4810,26 +4996,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 values) { + PrepareBuilder(); result.repeatedUint64_.Add(values); return this; } public Builder ClearRepeatedUint64() { + PrepareBuilder(); result.repeatedUint64_.Clear(); return this; } public pbc::IPopsicleList RepeatedSint32List { - get { return result.repeatedSint32_; } + get { return PrepareBuilder().repeatedSint32_; } } public int RepeatedSint32Count { get { return result.RepeatedSint32Count; } @@ -4838,24 +5028,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 values) { + PrepareBuilder(); result.repeatedSint32_.Add(values); return this; } public Builder ClearRepeatedSint32() { + PrepareBuilder(); result.repeatedSint32_.Clear(); return this; } public pbc::IPopsicleList RepeatedSint64List { - get { return result.repeatedSint64_; } + get { return PrepareBuilder().repeatedSint64_; } } public int RepeatedSint64Count { get { return result.RepeatedSint64Count; } @@ -4864,25 +5058,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 values) { + PrepareBuilder(); result.repeatedSint64_.Add(values); return this; } public Builder ClearRepeatedSint64() { + PrepareBuilder(); result.repeatedSint64_.Clear(); return this; } [global::System.CLSCompliant(false)] public pbc::IPopsicleList RepeatedFixed32List { - get { return result.repeatedFixed32_; } + get { return PrepareBuilder().repeatedFixed32_; } } public int RepeatedFixed32Count { get { return result.RepeatedFixed32Count; } @@ -4893,27 +5091,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 values) { + PrepareBuilder(); result.repeatedFixed32_.Add(values); return this; } public Builder ClearRepeatedFixed32() { + PrepareBuilder(); result.repeatedFixed32_.Clear(); return this; } [global::System.CLSCompliant(false)] public pbc::IPopsicleList RepeatedFixed64List { - get { return result.repeatedFixed64_; } + get { return PrepareBuilder().repeatedFixed64_; } } public int RepeatedFixed64Count { get { return result.RepeatedFixed64Count; } @@ -4924,26 +5126,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 values) { + PrepareBuilder(); result.repeatedFixed64_.Add(values); return this; } public Builder ClearRepeatedFixed64() { + PrepareBuilder(); result.repeatedFixed64_.Clear(); return this; } public pbc::IPopsicleList RepeatedSfixed32List { - get { return result.repeatedSfixed32_; } + get { return PrepareBuilder().repeatedSfixed32_; } } public int RepeatedSfixed32Count { get { return result.RepeatedSfixed32Count; } @@ -4952,24 +5158,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 values) { + PrepareBuilder(); result.repeatedSfixed32_.Add(values); return this; } public Builder ClearRepeatedSfixed32() { + PrepareBuilder(); result.repeatedSfixed32_.Clear(); return this; } public pbc::IPopsicleList RepeatedSfixed64List { - get { return result.repeatedSfixed64_; } + get { return PrepareBuilder().repeatedSfixed64_; } } public int RepeatedSfixed64Count { get { return result.RepeatedSfixed64Count; } @@ -4978,24 +5188,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 values) { + PrepareBuilder(); result.repeatedSfixed64_.Add(values); return this; } public Builder ClearRepeatedSfixed64() { + PrepareBuilder(); result.repeatedSfixed64_.Clear(); return this; } public pbc::IPopsicleList RepeatedFloatList { - get { return result.repeatedFloat_; } + get { return PrepareBuilder().repeatedFloat_; } } public int RepeatedFloatCount { get { return result.RepeatedFloatCount; } @@ -5004,24 +5218,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 values) { + PrepareBuilder(); result.repeatedFloat_.Add(values); return this; } public Builder ClearRepeatedFloat() { + PrepareBuilder(); result.repeatedFloat_.Clear(); return this; } public pbc::IPopsicleList RepeatedDoubleList { - get { return result.repeatedDouble_; } + get { return PrepareBuilder().repeatedDouble_; } } public int RepeatedDoubleCount { get { return result.RepeatedDoubleCount; } @@ -5030,24 +5248,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 values) { + PrepareBuilder(); result.repeatedDouble_.Add(values); return this; } public Builder ClearRepeatedDouble() { + PrepareBuilder(); result.repeatedDouble_.Clear(); return this; } public pbc::IPopsicleList RepeatedBoolList { - get { return result.repeatedBool_; } + get { return PrepareBuilder().repeatedBool_; } } public int RepeatedBoolCount { get { return result.RepeatedBoolCount; } @@ -5056,24 +5278,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 values) { + PrepareBuilder(); result.repeatedBool_.Add(values); return this; } public Builder ClearRepeatedBool() { + PrepareBuilder(); result.repeatedBool_.Clear(); return this; } public pbc::IPopsicleList RepeatedStringList { - get { return result.repeatedString_; } + get { return PrepareBuilder().repeatedString_; } } public int RepeatedStringCount { get { return result.RepeatedStringCount; } @@ -5083,25 +5309,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 values) { + PrepareBuilder(); result.repeatedString_.Add(values); return this; } public Builder ClearRepeatedString() { + PrepareBuilder(); result.repeatedString_.Clear(); return this; } public pbc::IPopsicleList RepeatedBytesList { - get { return result.repeatedBytes_; } + get { return PrepareBuilder().repeatedBytes_; } } public int RepeatedBytesCount { get { return result.RepeatedBytesCount; } @@ -5111,25 +5341,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 values) { + PrepareBuilder(); result.repeatedBytes_.Add(values); return this; } public Builder ClearRepeatedBytes() { + PrepareBuilder(); result.repeatedBytes_.Clear(); return this; } public pbc::IPopsicleList RepeatedGroupList { - get { return result.repeatedGroup_; } + get { return PrepareBuilder().repeatedGroup_; } } public int RepeatedGroupCount { get { return result.RepeatedGroupCount; } @@ -5139,35 +5373,41 @@ namespace Google.ProtocolBuffers.TestProtos { } public Builder SetRepeatedGroup(int index, global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.RepeatedGroup value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.repeatedGroup_[index] = value; return this; } public Builder SetRepeatedGroup(int index, global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.RepeatedGroup.Builder builderForValue) { pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); + PrepareBuilder(); result.repeatedGroup_[index] = builderForValue.Build(); return this; } public Builder AddRepeatedGroup(global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.RepeatedGroup value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.repeatedGroup_.Add(value); return this; } public Builder AddRepeatedGroup(global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.RepeatedGroup.Builder builderForValue) { pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); + PrepareBuilder(); result.repeatedGroup_.Add(builderForValue.Build()); return this; } public Builder AddRangeRepeatedGroup(scg::IEnumerable values) { + PrepareBuilder(); result.repeatedGroup_.Add(values); return this; } public Builder ClearRepeatedGroup() { + PrepareBuilder(); result.repeatedGroup_.Clear(); return this; } public pbc::IPopsicleList RepeatedNestedMessageList { - get { return result.repeatedNestedMessage_; } + get { return PrepareBuilder().repeatedNestedMessage_; } } public int RepeatedNestedMessageCount { get { return result.RepeatedNestedMessageCount; } @@ -5177,35 +5417,41 @@ namespace Google.ProtocolBuffers.TestProtos { } public Builder SetRepeatedNestedMessage(int index, global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.NestedMessage value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.repeatedNestedMessage_[index] = value; return this; } public Builder SetRepeatedNestedMessage(int index, global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.NestedMessage.Builder builderForValue) { pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); + PrepareBuilder(); result.repeatedNestedMessage_[index] = builderForValue.Build(); return this; } public Builder AddRepeatedNestedMessage(global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.NestedMessage value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.repeatedNestedMessage_.Add(value); return this; } public Builder AddRepeatedNestedMessage(global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.NestedMessage.Builder builderForValue) { pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); + PrepareBuilder(); result.repeatedNestedMessage_.Add(builderForValue.Build()); return this; } public Builder AddRangeRepeatedNestedMessage(scg::IEnumerable values) { + PrepareBuilder(); result.repeatedNestedMessage_.Add(values); return this; } public Builder ClearRepeatedNestedMessage() { + PrepareBuilder(); result.repeatedNestedMessage_.Clear(); return this; } public pbc::IPopsicleList RepeatedForeignMessageList { - get { return result.repeatedForeignMessage_; } + get { return PrepareBuilder().repeatedForeignMessage_; } } public int RepeatedForeignMessageCount { get { return result.RepeatedForeignMessageCount; } @@ -5215,35 +5461,41 @@ namespace Google.ProtocolBuffers.TestProtos { } public Builder SetRepeatedForeignMessage(int index, global::Google.ProtocolBuffers.TestProtos.ForeignMessageLite value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.repeatedForeignMessage_[index] = value; return this; } public Builder SetRepeatedForeignMessage(int index, global::Google.ProtocolBuffers.TestProtos.ForeignMessageLite.Builder builderForValue) { pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); + PrepareBuilder(); result.repeatedForeignMessage_[index] = builderForValue.Build(); return this; } public Builder AddRepeatedForeignMessage(global::Google.ProtocolBuffers.TestProtos.ForeignMessageLite value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.repeatedForeignMessage_.Add(value); return this; } public Builder AddRepeatedForeignMessage(global::Google.ProtocolBuffers.TestProtos.ForeignMessageLite.Builder builderForValue) { pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); + PrepareBuilder(); result.repeatedForeignMessage_.Add(builderForValue.Build()); return this; } public Builder AddRangeRepeatedForeignMessage(scg::IEnumerable values) { + PrepareBuilder(); result.repeatedForeignMessage_.Add(values); return this; } public Builder ClearRepeatedForeignMessage() { + PrepareBuilder(); result.repeatedForeignMessage_.Clear(); return this; } public pbc::IPopsicleList RepeatedImportMessageList { - get { return result.repeatedImportMessage_; } + get { return PrepareBuilder().repeatedImportMessage_; } } public int RepeatedImportMessageCount { get { return result.RepeatedImportMessageCount; } @@ -5253,35 +5505,41 @@ namespace Google.ProtocolBuffers.TestProtos { } public Builder SetRepeatedImportMessage(int index, global::Google.ProtocolBuffers.TestProtos.ImportMessageLite value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.repeatedImportMessage_[index] = value; return this; } public Builder SetRepeatedImportMessage(int index, global::Google.ProtocolBuffers.TestProtos.ImportMessageLite.Builder builderForValue) { pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); + PrepareBuilder(); result.repeatedImportMessage_[index] = builderForValue.Build(); return this; } public Builder AddRepeatedImportMessage(global::Google.ProtocolBuffers.TestProtos.ImportMessageLite value) { pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); result.repeatedImportMessage_.Add(value); return this; } public Builder AddRepeatedImportMessage(global::Google.ProtocolBuffers.TestProtos.ImportMessageLite.Builder builderForValue) { pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); + PrepareBuilder(); result.repeatedImportMessage_.Add(builderForValue.Build()); return this; } public Builder AddRangeRepeatedImportMessage(scg::IEnumerable values) { + PrepareBuilder(); result.repeatedImportMessage_.Add(values); return this; } public Builder ClearRepeatedImportMessage() { + PrepareBuilder(); result.repeatedImportMessage_.Clear(); return this; } public pbc::IPopsicleList RepeatedNestedEnumList { - get { return result.repeatedNestedEnum_; } + get { return PrepareBuilder().repeatedNestedEnum_; } } public int RepeatedNestedEnumCount { get { return result.RepeatedNestedEnumCount; } @@ -5290,24 +5548,28 @@ namespace Google.ProtocolBuffers.TestProtos { return result.GetRepeatedNestedEnum(index); } public Builder SetRepeatedNestedEnum(int index, global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.NestedEnum value) { + PrepareBuilder(); result.repeatedNestedEnum_[index] = value; return this; } public Builder AddRepeatedNestedEnum(global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.NestedEnum value) { + PrepareBuilder(); result.repeatedNestedEnum_.Add(value); return this; } public Builder AddRangeRepeatedNestedEnum(scg::IEnumerable values) { + PrepareBuilder(); result.repeatedNestedEnum_.Add(values); return this; } public Builder ClearRepeatedNestedEnum() { + PrepareBuilder(); result.repeatedNestedEnum_.Clear(); return this; } public pbc::IPopsicleList RepeatedForeignEnumList { - get { return result.repeatedForeignEnum_; } + get { return PrepareBuilder().repeatedForeignEnum_; } } public int RepeatedForeignEnumCount { get { return result.RepeatedForeignEnumCount; } @@ -5316,24 +5578,28 @@ namespace Google.ProtocolBuffers.TestProtos { return result.GetRepeatedForeignEnum(index); } public Builder SetRepeatedForeignEnum(int index, global::Google.ProtocolBuffers.TestProtos.ForeignEnumLite value) { + PrepareBuilder(); result.repeatedForeignEnum_[index] = value; return this; } public Builder AddRepeatedForeignEnum(global::Google.ProtocolBuffers.TestProtos.ForeignEnumLite value) { + PrepareBuilder(); result.repeatedForeignEnum_.Add(value); return this; } public Builder AddRangeRepeatedForeignEnum(scg::IEnumerable values) { + PrepareBuilder(); result.repeatedForeignEnum_.Add(values); return this; } public Builder ClearRepeatedForeignEnum() { + PrepareBuilder(); result.repeatedForeignEnum_.Clear(); return this; } public pbc::IPopsicleList RepeatedImportEnumList { - get { return result.repeatedImportEnum_; } + get { return PrepareBuilder().repeatedImportEnum_; } } public int RepeatedImportEnumCount { get { return result.RepeatedImportEnumCount; } @@ -5342,24 +5608,28 @@ namespace Google.ProtocolBuffers.TestProtos { return result.GetRepeatedImportEnum(index); } public Builder SetRepeatedImportEnum(int index, global::Google.ProtocolBuffers.TestProtos.ImportEnumLite value) { + PrepareBuilder(); result.repeatedImportEnum_[index] = value; return this; } public Builder AddRepeatedImportEnum(global::Google.ProtocolBuffers.TestProtos.ImportEnumLite value) { + PrepareBuilder(); result.repeatedImportEnum_.Add(value); return this; } public Builder AddRangeRepeatedImportEnum(scg::IEnumerable values) { + PrepareBuilder(); result.repeatedImportEnum_.Add(values); return this; } public Builder ClearRepeatedImportEnum() { + PrepareBuilder(); result.repeatedImportEnum_.Clear(); return this; } public pbc::IPopsicleList RepeatedStringPieceList { - get { return result.repeatedStringPiece_; } + get { return PrepareBuilder().repeatedStringPiece_; } } public int RepeatedStringPieceCount { get { return result.RepeatedStringPieceCount; } @@ -5369,25 +5639,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 values) { + PrepareBuilder(); result.repeatedStringPiece_.Add(values); return this; } public Builder ClearRepeatedStringPiece() { + PrepareBuilder(); result.repeatedStringPiece_.Clear(); return this; } public pbc::IPopsicleList RepeatedCordList { - get { return result.repeatedCord_; } + get { return PrepareBuilder().repeatedCord_; } } public int RepeatedCordCount { get { return result.RepeatedCordCount; } @@ -5397,19 +5671,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 values) { + PrepareBuilder(); result.repeatedCord_.Add(values); return this; } public Builder ClearRepeatedCord() { + PrepareBuilder(); result.repeatedCord_.Clear(); return this; } @@ -5422,11 +5700,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; @@ -5440,11 +5720,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; @@ -5460,11 +5742,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; @@ -5480,11 +5764,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; @@ -5498,11 +5784,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; @@ -5516,11 +5804,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; @@ -5536,11 +5826,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; @@ -5556,11 +5848,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; @@ -5574,11 +5868,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; @@ -5592,11 +5888,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; @@ -5610,11 +5908,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; @@ -5628,11 +5928,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; @@ -5646,11 +5948,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; @@ -5665,11 +5969,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; @@ -5684,11 +5990,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.FromBase64("d29ybGQ="); return this; @@ -5702,11 +6010,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetDefaultNestedEnum(value); } } public Builder SetDefaultNestedEnum(global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.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.TestAllTypesLite.Types.NestedEnum.BAR; return this; @@ -5720,11 +6030,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetDefaultForeignEnum(value); } } public Builder SetDefaultForeignEnum(global::Google.ProtocolBuffers.TestProtos.ForeignEnumLite value) { + PrepareBuilder(); result.hasDefaultForeignEnum = true; result.defaultForeignEnum_ = value; return this; } public Builder ClearDefaultForeignEnum() { + PrepareBuilder(); result.hasDefaultForeignEnum = false; result.defaultForeignEnum_ = global::Google.ProtocolBuffers.TestProtos.ForeignEnumLite.FOREIGN_LITE_BAR; return this; @@ -5738,11 +6050,13 @@ namespace Google.ProtocolBuffers.TestProtos { set { SetDefaultImportEnum(value); } } public Builder SetDefaultImportEnum(global::Google.ProtocolBuffers.TestProtos.ImportEnumLite value) { + PrepareBuilder(); result.hasDefaultImportEnum = true; result.defaultImportEnum_ = value; return this; } public Builder ClearDefaultImportEnum() { + PrepareBuilder(); result.hasDefaultImportEnum = false; result.defaultImportEnum_ = global::Google.ProtocolBuffers.TestProtos.ImportEnumLite.IMPORT_LITE_BAR; return this; @@ -5757,11 +6071,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; @@ -5776,11 +6092,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; @@ -5903,7 +6221,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); } public override Builder CreateBuilderForType() { return new Builder(); } public static Builder CreateBuilder(ForeignMessageLite prototype) { - return (Builder) new Builder().MergeFrom(prototype); + return new Builder(prototype); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] @@ -5913,21 +6231,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder { get { return this; } } - public Builder() {} + public Builder() { + result = DefaultInstance ?? new ForeignMessageLite(); + builderIsReadOnly = result == DefaultInstance; + } + internal Builder(ForeignMessageLite cloneFrom) { + result = cloneFrom; + builderIsReadOnly = true; + } + + bool builderIsReadOnly; + ForeignMessageLite result; + + private ForeignMessageLite PrepareBuilder() { + if (builderIsReadOnly) { + ForeignMessageLite original = result; + result = new ForeignMessageLite(); + builderIsReadOnly = false; + MergeFrom(original); + } + return result; + } - ForeignMessageLite result = new ForeignMessageLite(); + public override bool IsInitialized { + get { return result.IsInitialized; } + } protected override ForeignMessageLite MessageBeingBuilt { - get { return result; } + get { return PrepareBuilder(); } } public override Builder Clear() { - result = new ForeignMessageLite(); + result = DefaultInstance ?? new ForeignMessageLite(); + 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 ForeignMessageLite DefaultInstanceForType { @@ -5935,12 +6280,11 @@ namespace Google.ProtocolBuffers.TestProtos { } public override ForeignMessageLite BuildPartial() { - if (result == null) { - throw new global::System.InvalidOperationException("build() has already been called on this Builder"); + if (builderIsReadOnly) { + return result; } - ForeignMessageLite returnMe = result; - result = null; - return returnMe; + builderIsReadOnly = true; + return result; } public override Builder MergeFrom(pb::IMessageLite other) { @@ -5954,6 +6298,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder MergeFrom(ForeignMessageLite other) { if (other == global::Google.ProtocolBuffers.TestProtos.ForeignMessageLite.DefaultInstance) return this; + PrepareBuilder(); if (other.HasC) { C = other.C; } @@ -5965,6 +6310,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)) { @@ -6007,11 +6353,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; @@ -6572,7 +6920,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); } public override Builder CreateBuilderForType() { return new Builder(); } public static Builder CreateBuilder(TestPackedTypesLite prototype) { - return (Builder) new Builder().MergeFrom(prototype); + return new Builder(prototype); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] @@ -6582,21 +6930,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder { get { return this; } } - public Builder() {} + public Builder() { + result = DefaultInstance ?? new TestPackedTypesLite(); + builderIsReadOnly = result == DefaultInstance; + } + internal Builder(TestPackedTypesLite cloneFrom) { + result = cloneFrom; + builderIsReadOnly = true; + } + + bool builderIsReadOnly; + TestPackedTypesLite result; - TestPackedTypesLite result = new TestPackedTypesLite(); + private TestPackedTypesLite PrepareBuilder() { + if (builderIsReadOnly) { + TestPackedTypesLite original = result; + result = new TestPackedTypesLite(); + builderIsReadOnly = false; + MergeFrom(original); + } + return result; + } + + public override bool IsInitialized { + get { return result.IsInitialized; } + } protected override TestPackedTypesLite MessageBeingBuilt { - get { return result; } + get { return PrepareBuilder(); } } public override Builder Clear() { - result = new TestPackedTypesLite(); + result = DefaultInstance ?? new TestPackedTypesLite(); + 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 TestPackedTypesLite DefaultInstanceForType { @@ -6604,8 +6979,8 @@ namespace Google.ProtocolBuffers.TestProtos { } public override TestPackedTypesLite 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(); @@ -6621,9 +6996,8 @@ namespace Google.ProtocolBuffers.TestProtos { result.packedDouble_.MakeReadOnly(); result.packedBool_.MakeReadOnly(); result.packedEnum_.MakeReadOnly(); - TestPackedTypesLite returnMe = result; - result = null; - return returnMe; + builderIsReadOnly = true; + return result; } public override Builder MergeFrom(pb::IMessageLite other) { @@ -6637,6 +7011,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder MergeFrom(TestPackedTypesLite other) { if (other == global::Google.ProtocolBuffers.TestProtos.TestPackedTypesLite.DefaultInstance) return this; + PrepareBuilder(); if (other.packedInt32_.Count != 0) { result.packedInt32_.Add(other.packedInt32_); } @@ -6687,6 +7062,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)) { @@ -6789,7 +7165,7 @@ namespace Google.ProtocolBuffers.TestProtos { public pbc::IPopsicleList PackedInt32List { - get { return result.packedInt32_; } + get { return PrepareBuilder().packedInt32_; } } public int PackedInt32Count { get { return result.PackedInt32Count; } @@ -6798,24 +7174,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 values) { + PrepareBuilder(); result.packedInt32_.Add(values); return this; } public Builder ClearPackedInt32() { + PrepareBuilder(); result.packedInt32_.Clear(); return this; } public pbc::IPopsicleList PackedInt64List { - get { return result.packedInt64_; } + get { return PrepareBuilder().packedInt64_; } } public int PackedInt64Count { get { return result.PackedInt64Count; } @@ -6824,25 +7204,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 values) { + PrepareBuilder(); result.packedInt64_.Add(values); return this; } public Builder ClearPackedInt64() { + PrepareBuilder(); result.packedInt64_.Clear(); return this; } [global::System.CLSCompliant(false)] public pbc::IPopsicleList PackedUint32List { - get { return result.packedUint32_; } + get { return PrepareBuilder().packedUint32_; } } public int PackedUint32Count { get { return result.PackedUint32Count; } @@ -6853,27 +7237,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 values) { + PrepareBuilder(); result.packedUint32_.Add(values); return this; } public Builder ClearPackedUint32() { + PrepareBuilder(); result.packedUint32_.Clear(); return this; } [global::System.CLSCompliant(false)] public pbc::IPopsicleList PackedUint64List { - get { return result.packedUint64_; } + get { return PrepareBuilder().packedUint64_; } } public int PackedUint64Count { get { return result.PackedUint64Count; } @@ -6884,26 +7272,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 values) { + PrepareBuilder(); result.packedUint64_.Add(values); return this; } public Builder ClearPackedUint64() { + PrepareBuilder(); result.packedUint64_.Clear(); return this; } public pbc::IPopsicleList PackedSint32List { - get { return result.packedSint32_; } + get { return PrepareBuilder().packedSint32_; } } public int PackedSint32Count { get { return result.PackedSint32Count; } @@ -6912,24 +7304,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 values) { + PrepareBuilder(); result.packedSint32_.Add(values); return this; } public Builder ClearPackedSint32() { + PrepareBuilder(); result.packedSint32_.Clear(); return this; } public pbc::IPopsicleList PackedSint64List { - get { return result.packedSint64_; } + get { return PrepareBuilder().packedSint64_; } } public int PackedSint64Count { get { return result.PackedSint64Count; } @@ -6938,25 +7334,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 values) { + PrepareBuilder(); result.packedSint64_.Add(values); return this; } public Builder ClearPackedSint64() { + PrepareBuilder(); result.packedSint64_.Clear(); return this; } [global::System.CLSCompliant(false)] public pbc::IPopsicleList PackedFixed32List { - get { return result.packedFixed32_; } + get { return PrepareBuilder().packedFixed32_; } } public int PackedFixed32Count { get { return result.PackedFixed32Count; } @@ -6967,27 +7367,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 values) { + PrepareBuilder(); result.packedFixed32_.Add(values); return this; } public Builder ClearPackedFixed32() { + PrepareBuilder(); result.packedFixed32_.Clear(); return this; } [global::System.CLSCompliant(false)] public pbc::IPopsicleList PackedFixed64List { - get { return result.packedFixed64_; } + get { return PrepareBuilder().packedFixed64_; } } public int PackedFixed64Count { get { return result.PackedFixed64Count; } @@ -6998,26 +7402,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 values) { + PrepareBuilder(); result.packedFixed64_.Add(values); return this; } public Builder ClearPackedFixed64() { + PrepareBuilder(); result.packedFixed64_.Clear(); return this; } public pbc::IPopsicleList PackedSfixed32List { - get { return result.packedSfixed32_; } + get { return PrepareBuilder().packedSfixed32_; } } public int PackedSfixed32Count { get { return result.PackedSfixed32Count; } @@ -7026,24 +7434,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 values) { + PrepareBuilder(); result.packedSfixed32_.Add(values); return this; } public Builder ClearPackedSfixed32() { + PrepareBuilder(); result.packedSfixed32_.Clear(); return this; } public pbc::IPopsicleList PackedSfixed64List { - get { return result.packedSfixed64_; } + get { return PrepareBuilder().packedSfixed64_; } } public int PackedSfixed64Count { get { return result.PackedSfixed64Count; } @@ -7052,24 +7464,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 values) { + PrepareBuilder(); result.packedSfixed64_.Add(values); return this; } public Builder ClearPackedSfixed64() { + PrepareBuilder(); result.packedSfixed64_.Clear(); return this; } public pbc::IPopsicleList PackedFloatList { - get { return result.packedFloat_; } + get { return PrepareBuilder().packedFloat_; } } public int PackedFloatCount { get { return result.PackedFloatCount; } @@ -7078,24 +7494,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 values) { + PrepareBuilder(); result.packedFloat_.Add(values); return this; } public Builder ClearPackedFloat() { + PrepareBuilder(); result.packedFloat_.Clear(); return this; } public pbc::IPopsicleList PackedDoubleList { - get { return result.packedDouble_; } + get { return PrepareBuilder().packedDouble_; } } public int PackedDoubleCount { get { return result.PackedDoubleCount; } @@ -7104,24 +7524,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 values) { + PrepareBuilder(); result.packedDouble_.Add(values); return this; } public Builder ClearPackedDouble() { + PrepareBuilder(); result.packedDouble_.Clear(); return this; } public pbc::IPopsicleList PackedBoolList { - get { return result.packedBool_; } + get { return PrepareBuilder().packedBool_; } } public int PackedBoolCount { get { return result.PackedBoolCount; } @@ -7130,24 +7554,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 values) { + PrepareBuilder(); result.packedBool_.Add(values); return this; } public Builder ClearPackedBool() { + PrepareBuilder(); result.packedBool_.Clear(); return this; } public pbc::IPopsicleList PackedEnumList { - get { return result.packedEnum_; } + get { return PrepareBuilder().packedEnum_; } } public int PackedEnumCount { get { return result.PackedEnumCount; } @@ -7156,18 +7584,22 @@ namespace Google.ProtocolBuffers.TestProtos { return result.GetPackedEnum(index); } public Builder SetPackedEnum(int index, global::Google.ProtocolBuffers.TestProtos.ForeignEnumLite value) { + PrepareBuilder(); result.packedEnum_[index] = value; return this; } public Builder AddPackedEnum(global::Google.ProtocolBuffers.TestProtos.ForeignEnumLite value) { + PrepareBuilder(); result.packedEnum_.Add(value); return this; } public Builder AddRangePackedEnum(scg::IEnumerable values) { + PrepareBuilder(); result.packedEnum_.Add(values); return this; } public Builder ClearPackedEnum() { + PrepareBuilder(); result.packedEnum_.Clear(); return this; } @@ -7672,7 +8104,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); } public override Builder CreateBuilderForType() { return new Builder(); } public static Builder CreateBuilder(TestUnpackedTypesLite prototype) { - return (Builder) new Builder().MergeFrom(prototype); + return new Builder(prototype); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] @@ -7682,21 +8114,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder { get { return this; } } - public Builder() {} + public Builder() { + result = DefaultInstance ?? new TestUnpackedTypesLite(); + builderIsReadOnly = result == DefaultInstance; + } + internal Builder(TestUnpackedTypesLite cloneFrom) { + result = cloneFrom; + builderIsReadOnly = true; + } - TestUnpackedTypesLite result = new TestUnpackedTypesLite(); + bool builderIsReadOnly; + TestUnpackedTypesLite result; + + private TestUnpackedTypesLite PrepareBuilder() { + if (builderIsReadOnly) { + TestUnpackedTypesLite original = result; + result = new TestUnpackedTypesLite(); + builderIsReadOnly = false; + MergeFrom(original); + } + return result; + } + + public override bool IsInitialized { + get { return result.IsInitialized; } + } protected override TestUnpackedTypesLite MessageBeingBuilt { - get { return result; } + get { return PrepareBuilder(); } } public override Builder Clear() { - result = new TestUnpackedTypesLite(); + result = DefaultInstance ?? new TestUnpackedTypesLite(); + 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 TestUnpackedTypesLite DefaultInstanceForType { @@ -7704,8 +8163,8 @@ namespace Google.ProtocolBuffers.TestProtos { } public override TestUnpackedTypesLite 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(); @@ -7721,9 +8180,8 @@ namespace Google.ProtocolBuffers.TestProtos { result.unpackedDouble_.MakeReadOnly(); result.unpackedBool_.MakeReadOnly(); result.unpackedEnum_.MakeReadOnly(); - TestUnpackedTypesLite returnMe = result; - result = null; - return returnMe; + builderIsReadOnly = true; + return result; } public override Builder MergeFrom(pb::IMessageLite other) { @@ -7737,6 +8195,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder MergeFrom(TestUnpackedTypesLite other) { if (other == global::Google.ProtocolBuffers.TestProtos.TestUnpackedTypesLite.DefaultInstance) return this; + PrepareBuilder(); if (other.unpackedInt32_.Count != 0) { result.unpackedInt32_.Add(other.unpackedInt32_); } @@ -7787,6 +8246,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)) { @@ -7889,7 +8349,7 @@ namespace Google.ProtocolBuffers.TestProtos { public pbc::IPopsicleList UnpackedInt32List { - get { return result.unpackedInt32_; } + get { return PrepareBuilder().unpackedInt32_; } } public int UnpackedInt32Count { get { return result.UnpackedInt32Count; } @@ -7898,24 +8358,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 values) { + PrepareBuilder(); result.unpackedInt32_.Add(values); return this; } public Builder ClearUnpackedInt32() { + PrepareBuilder(); result.unpackedInt32_.Clear(); return this; } public pbc::IPopsicleList UnpackedInt64List { - get { return result.unpackedInt64_; } + get { return PrepareBuilder().unpackedInt64_; } } public int UnpackedInt64Count { get { return result.UnpackedInt64Count; } @@ -7924,25 +8388,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 values) { + PrepareBuilder(); result.unpackedInt64_.Add(values); return this; } public Builder ClearUnpackedInt64() { + PrepareBuilder(); result.unpackedInt64_.Clear(); return this; } [global::System.CLSCompliant(false)] public pbc::IPopsicleList UnpackedUint32List { - get { return result.unpackedUint32_; } + get { return PrepareBuilder().unpackedUint32_; } } public int UnpackedUint32Count { get { return result.UnpackedUint32Count; } @@ -7953,27 +8421,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 values) { + PrepareBuilder(); result.unpackedUint32_.Add(values); return this; } public Builder ClearUnpackedUint32() { + PrepareBuilder(); result.unpackedUint32_.Clear(); return this; } [global::System.CLSCompliant(false)] public pbc::IPopsicleList UnpackedUint64List { - get { return result.unpackedUint64_; } + get { return PrepareBuilder().unpackedUint64_; } } public int UnpackedUint64Count { get { return result.UnpackedUint64Count; } @@ -7984,26 +8456,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 values) { + PrepareBuilder(); result.unpackedUint64_.Add(values); return this; } public Builder ClearUnpackedUint64() { + PrepareBuilder(); result.unpackedUint64_.Clear(); return this; } public pbc::IPopsicleList UnpackedSint32List { - get { return result.unpackedSint32_; } + get { return PrepareBuilder().unpackedSint32_; } } public int UnpackedSint32Count { get { return result.UnpackedSint32Count; } @@ -8012,24 +8488,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 values) { + PrepareBuilder(); result.unpackedSint32_.Add(values); return this; } public Builder ClearUnpackedSint32() { + PrepareBuilder(); result.unpackedSint32_.Clear(); return this; } public pbc::IPopsicleList UnpackedSint64List { - get { return result.unpackedSint64_; } + get { return PrepareBuilder().unpackedSint64_; } } public int UnpackedSint64Count { get { return result.UnpackedSint64Count; } @@ -8038,25 +8518,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 values) { + PrepareBuilder(); result.unpackedSint64_.Add(values); return this; } public Builder ClearUnpackedSint64() { + PrepareBuilder(); result.unpackedSint64_.Clear(); return this; } [global::System.CLSCompliant(false)] public pbc::IPopsicleList UnpackedFixed32List { - get { return result.unpackedFixed32_; } + get { return PrepareBuilder().unpackedFixed32_; } } public int UnpackedFixed32Count { get { return result.UnpackedFixed32Count; } @@ -8067,27 +8551,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 values) { + PrepareBuilder(); result.unpackedFixed32_.Add(values); return this; } public Builder ClearUnpackedFixed32() { + PrepareBuilder(); result.unpackedFixed32_.Clear(); return this; } [global::System.CLSCompliant(false)] public pbc::IPopsicleList UnpackedFixed64List { - get { return result.unpackedFixed64_; } + get { return PrepareBuilder().unpackedFixed64_; } } public int UnpackedFixed64Count { get { return result.UnpackedFixed64Count; } @@ -8098,26 +8586,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 values) { + PrepareBuilder(); result.unpackedFixed64_.Add(values); return this; } public Builder ClearUnpackedFixed64() { + PrepareBuilder(); result.unpackedFixed64_.Clear(); return this; } public pbc::IPopsicleList UnpackedSfixed32List { - get { return result.unpackedSfixed32_; } + get { return PrepareBuilder().unpackedSfixed32_; } } public int UnpackedSfixed32Count { get { return result.UnpackedSfixed32Count; } @@ -8126,24 +8618,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 values) { + PrepareBuilder(); result.unpackedSfixed32_.Add(values); return this; } public Builder ClearUnpackedSfixed32() { + PrepareBuilder(); result.unpackedSfixed32_.Clear(); return this; } public pbc::IPopsicleList UnpackedSfixed64List { - get { return result.unpackedSfixed64_; } + get { return PrepareBuilder().unpackedSfixed64_; } } public int UnpackedSfixed64Count { get { return result.UnpackedSfixed64Count; } @@ -8152,24 +8648,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 values) { + PrepareBuilder(); result.unpackedSfixed64_.Add(values); return this; } public Builder ClearUnpackedSfixed64() { + PrepareBuilder(); result.unpackedSfixed64_.Clear(); return this; } public pbc::IPopsicleList UnpackedFloatList { - get { return result.unpackedFloat_; } + get { return PrepareBuilder().unpackedFloat_; } } public int UnpackedFloatCount { get { return result.UnpackedFloatCount; } @@ -8178,24 +8678,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 values) { + PrepareBuilder(); result.unpackedFloat_.Add(values); return this; } public Builder ClearUnpackedFloat() { + PrepareBuilder(); result.unpackedFloat_.Clear(); return this; } public pbc::IPopsicleList UnpackedDoubleList { - get { return result.unpackedDouble_; } + get { return PrepareBuilder().unpackedDouble_; } } public int UnpackedDoubleCount { get { return result.UnpackedDoubleCount; } @@ -8204,24 +8708,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 values) { + PrepareBuilder(); result.unpackedDouble_.Add(values); return this; } public Builder ClearUnpackedDouble() { + PrepareBuilder(); result.unpackedDouble_.Clear(); return this; } public pbc::IPopsicleList UnpackedBoolList { - get { return result.unpackedBool_; } + get { return PrepareBuilder().unpackedBool_; } } public int UnpackedBoolCount { get { return result.UnpackedBoolCount; } @@ -8230,24 +8738,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 values) { + PrepareBuilder(); result.unpackedBool_.Add(values); return this; } public Builder ClearUnpackedBool() { + PrepareBuilder(); result.unpackedBool_.Clear(); return this; } public pbc::IPopsicleList UnpackedEnumList { - get { return result.unpackedEnum_; } + get { return PrepareBuilder().unpackedEnum_; } } public int UnpackedEnumCount { get { return result.UnpackedEnumCount; } @@ -8256,18 +8768,22 @@ namespace Google.ProtocolBuffers.TestProtos { return result.GetUnpackedEnum(index); } public Builder SetUnpackedEnum(int index, global::Google.ProtocolBuffers.TestProtos.ForeignEnumLite value) { + PrepareBuilder(); result.unpackedEnum_[index] = value; return this; } public Builder AddUnpackedEnum(global::Google.ProtocolBuffers.TestProtos.ForeignEnumLite value) { + PrepareBuilder(); result.unpackedEnum_.Add(value); return this; } public Builder AddRangeUnpackedEnum(scg::IEnumerable values) { + PrepareBuilder(); result.unpackedEnum_.Add(values); return this; } public Builder ClearUnpackedEnum() { + PrepareBuilder(); result.unpackedEnum_.Clear(); return this; } @@ -8377,7 +8893,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); } public override Builder CreateBuilderForType() { return new Builder(); } public static Builder CreateBuilder(TestAllExtensionsLite prototype) { - return (Builder) new Builder().MergeFrom(prototype); + return new Builder(prototype); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] @@ -8387,21 +8903,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder { get { return this; } } - public Builder() {} + public Builder() { + result = DefaultInstance ?? new TestAllExtensionsLite(); + builderIsReadOnly = result == DefaultInstance; + } + internal Builder(TestAllExtensionsLite cloneFrom) { + result = cloneFrom; + builderIsReadOnly = true; + } - TestAllExtensionsLite result = new TestAllExtensionsLite(); + bool builderIsReadOnly; + TestAllExtensionsLite result; + + private TestAllExtensionsLite PrepareBuilder() { + if (builderIsReadOnly) { + TestAllExtensionsLite original = result; + result = new TestAllExtensionsLite(); + builderIsReadOnly = false; + MergeFrom(original); + } + return result; + } + + public override bool IsInitialized { + get { return result.IsInitialized; } + } protected override TestAllExtensionsLite MessageBeingBuilt { - get { return result; } + get { return PrepareBuilder(); } } public override Builder Clear() { - result = new TestAllExtensionsLite(); + result = DefaultInstance ?? new TestAllExtensionsLite(); + 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 TestAllExtensionsLite DefaultInstanceForType { @@ -8409,12 +8952,11 @@ namespace Google.ProtocolBuffers.TestProtos { } public override TestAllExtensionsLite BuildPartial() { - if (result == null) { - throw new global::System.InvalidOperationException("build() has already been called on this Builder"); + if (builderIsReadOnly) { + return result; } - TestAllExtensionsLite returnMe = result; - result = null; - return returnMe; + builderIsReadOnly = true; + return result; } public override Builder MergeFrom(pb::IMessageLite other) { @@ -8428,6 +8970,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder MergeFrom(TestAllExtensionsLite other) { if (other == global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance) return this; + PrepareBuilder(); this.MergeExtensionFields(other); return this; } @@ -8437,6 +8980,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)) { @@ -8584,7 +9128,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_lite prototype) { - return (Builder) new Builder().MergeFrom(prototype); + return new Builder(prototype); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] @@ -8594,21 +9138,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder { get { return this; } } - public Builder() {} + public Builder() { + result = DefaultInstance ?? new OptionalGroup_extension_lite(); + builderIsReadOnly = result == DefaultInstance; + } + internal Builder(OptionalGroup_extension_lite cloneFrom) { + result = cloneFrom; + builderIsReadOnly = true; + } + + bool builderIsReadOnly; + OptionalGroup_extension_lite result; + + private OptionalGroup_extension_lite PrepareBuilder() { + if (builderIsReadOnly) { + OptionalGroup_extension_lite original = result; + result = new OptionalGroup_extension_lite(); + builderIsReadOnly = false; + MergeFrom(original); + } + return result; + } - OptionalGroup_extension_lite result = new OptionalGroup_extension_lite(); + public override bool IsInitialized { + get { return result.IsInitialized; } + } protected override OptionalGroup_extension_lite MessageBeingBuilt { - get { return result; } + get { return PrepareBuilder(); } } public override Builder Clear() { - result = new OptionalGroup_extension_lite(); + result = DefaultInstance ?? new OptionalGroup_extension_lite(); + 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 OptionalGroup_extension_lite DefaultInstanceForType { @@ -8616,12 +9187,11 @@ namespace Google.ProtocolBuffers.TestProtos { } public override OptionalGroup_extension_lite BuildPartial() { - if (result == null) { - throw new global::System.InvalidOperationException("build() has already been called on this Builder"); + if (builderIsReadOnly) { + return result; } - OptionalGroup_extension_lite returnMe = result; - result = null; - return returnMe; + builderIsReadOnly = true; + return result; } public override Builder MergeFrom(pb::IMessageLite other) { @@ -8635,6 +9205,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder MergeFrom(OptionalGroup_extension_lite other) { if (other == global::Google.ProtocolBuffers.TestProtos.OptionalGroup_extension_lite.DefaultInstance) return this; + PrepareBuilder(); if (other.HasA) { A = other.A; } @@ -8646,6 +9217,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)) { @@ -8688,11 +9260,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; @@ -8815,7 +9389,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_lite prototype) { - return (Builder) new Builder().MergeFrom(prototype); + return new Builder(prototype); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] @@ -8825,21 +9399,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder { get { return this; } } - public Builder() {} + public Builder() { + result = DefaultInstance ?? new RepeatedGroup_extension_lite(); + builderIsReadOnly = result == DefaultInstance; + } + internal Builder(RepeatedGroup_extension_lite cloneFrom) { + result = cloneFrom; + builderIsReadOnly = true; + } + + bool builderIsReadOnly; + RepeatedGroup_extension_lite result; + + private RepeatedGroup_extension_lite PrepareBuilder() { + if (builderIsReadOnly) { + RepeatedGroup_extension_lite original = result; + result = new RepeatedGroup_extension_lite(); + builderIsReadOnly = false; + MergeFrom(original); + } + return result; + } - RepeatedGroup_extension_lite result = new RepeatedGroup_extension_lite(); + public override bool IsInitialized { + get { return result.IsInitialized; } + } protected override RepeatedGroup_extension_lite MessageBeingBuilt { - get { return result; } + get { return PrepareBuilder(); } } public override Builder Clear() { - result = new RepeatedGroup_extension_lite(); + result = DefaultInstance ?? new RepeatedGroup_extension_lite(); + 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 RepeatedGroup_extension_lite DefaultInstanceForType { @@ -8847,12 +9448,11 @@ namespace Google.ProtocolBuffers.TestProtos { } public override RepeatedGroup_extension_lite BuildPartial() { - if (result == null) { - throw new global::System.InvalidOperationException("build() has already been called on this Builder"); + if (builderIsReadOnly) { + return result; } - RepeatedGroup_extension_lite returnMe = result; - result = null; - return returnMe; + builderIsReadOnly = true; + return result; } public override Builder MergeFrom(pb::IMessageLite other) { @@ -8866,6 +9466,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder MergeFrom(RepeatedGroup_extension_lite other) { if (other == global::Google.ProtocolBuffers.TestProtos.RepeatedGroup_extension_lite.DefaultInstance) return this; + PrepareBuilder(); if (other.HasA) { A = other.A; } @@ -8877,6 +9478,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)) { @@ -8919,11 +9521,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; @@ -9034,7 +9638,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); } public override Builder CreateBuilderForType() { return new Builder(); } public static Builder CreateBuilder(TestPackedExtensionsLite prototype) { - return (Builder) new Builder().MergeFrom(prototype); + return new Builder(prototype); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] @@ -9044,21 +9648,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder { get { return this; } } - public Builder() {} + public Builder() { + result = DefaultInstance ?? new TestPackedExtensionsLite(); + builderIsReadOnly = result == DefaultInstance; + } + internal Builder(TestPackedExtensionsLite cloneFrom) { + result = cloneFrom; + builderIsReadOnly = true; + } - TestPackedExtensionsLite result = new TestPackedExtensionsLite(); + bool builderIsReadOnly; + TestPackedExtensionsLite result; + + private TestPackedExtensionsLite PrepareBuilder() { + if (builderIsReadOnly) { + TestPackedExtensionsLite original = result; + result = new TestPackedExtensionsLite(); + builderIsReadOnly = false; + MergeFrom(original); + } + return result; + } + + public override bool IsInitialized { + get { return result.IsInitialized; } + } protected override TestPackedExtensionsLite MessageBeingBuilt { - get { return result; } + get { return PrepareBuilder(); } } public override Builder Clear() { - result = new TestPackedExtensionsLite(); + result = DefaultInstance ?? new TestPackedExtensionsLite(); + 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 TestPackedExtensionsLite DefaultInstanceForType { @@ -9066,12 +9697,11 @@ namespace Google.ProtocolBuffers.TestProtos { } public override TestPackedExtensionsLite BuildPartial() { - if (result == null) { - throw new global::System.InvalidOperationException("build() has already been called on this Builder"); + if (builderIsReadOnly) { + return result; } - TestPackedExtensionsLite returnMe = result; - result = null; - return returnMe; + builderIsReadOnly = true; + return result; } public override Builder MergeFrom(pb::IMessageLite other) { @@ -9085,6 +9715,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder MergeFrom(TestPackedExtensionsLite other) { if (other == global::Google.ProtocolBuffers.TestProtos.TestPackedExtensionsLite.DefaultInstance) return this; + PrepareBuilder(); this.MergeExtensionFields(other); return this; } @@ -9094,6 +9725,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)) { @@ -9229,7 +9861,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); } public override Builder CreateBuilderForType() { return new Builder(); } public static Builder CreateBuilder(TestUnpackedExtensionsLite prototype) { - return (Builder) new Builder().MergeFrom(prototype); + return new Builder(prototype); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] @@ -9239,21 +9871,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder { get { return this; } } - public Builder() {} + public Builder() { + result = DefaultInstance ?? new TestUnpackedExtensionsLite(); + builderIsReadOnly = result == DefaultInstance; + } + internal Builder(TestUnpackedExtensionsLite cloneFrom) { + result = cloneFrom; + builderIsReadOnly = true; + } + + bool builderIsReadOnly; + TestUnpackedExtensionsLite result; - TestUnpackedExtensionsLite result = new TestUnpackedExtensionsLite(); + private TestUnpackedExtensionsLite PrepareBuilder() { + if (builderIsReadOnly) { + TestUnpackedExtensionsLite original = result; + result = new TestUnpackedExtensionsLite(); + builderIsReadOnly = false; + MergeFrom(original); + } + return result; + } + + public override bool IsInitialized { + get { return result.IsInitialized; } + } protected override TestUnpackedExtensionsLite MessageBeingBuilt { - get { return result; } + get { return PrepareBuilder(); } } public override Builder Clear() { - result = new TestUnpackedExtensionsLite(); + result = DefaultInstance ?? new TestUnpackedExtensionsLite(); + 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 TestUnpackedExtensionsLite DefaultInstanceForType { @@ -9261,12 +9920,11 @@ namespace Google.ProtocolBuffers.TestProtos { } public override TestUnpackedExtensionsLite BuildPartial() { - if (result == null) { - throw new global::System.InvalidOperationException("build() has already been called on this Builder"); + if (builderIsReadOnly) { + return result; } - TestUnpackedExtensionsLite returnMe = result; - result = null; - return returnMe; + builderIsReadOnly = true; + return result; } public override Builder MergeFrom(pb::IMessageLite other) { @@ -9280,6 +9938,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder MergeFrom(TestUnpackedExtensionsLite other) { if (other == global::Google.ProtocolBuffers.TestProtos.TestUnpackedExtensionsLite.DefaultInstance) return this; + PrepareBuilder(); this.MergeExtensionFields(other); return this; } @@ -9289,6 +9948,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)) { @@ -9419,7 +10079,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); } public override Builder CreateBuilderForType() { return new Builder(); } public static Builder CreateBuilder(TestNestedExtensionLite prototype) { - return (Builder) new Builder().MergeFrom(prototype); + return new Builder(prototype); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] @@ -9429,21 +10089,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder { get { return this; } } - public Builder() {} + public Builder() { + result = DefaultInstance ?? new TestNestedExtensionLite(); + builderIsReadOnly = result == DefaultInstance; + } + internal Builder(TestNestedExtensionLite cloneFrom) { + result = cloneFrom; + builderIsReadOnly = true; + } + + bool builderIsReadOnly; + TestNestedExtensionLite result; + + private TestNestedExtensionLite PrepareBuilder() { + if (builderIsReadOnly) { + TestNestedExtensionLite original = result; + result = new TestNestedExtensionLite(); + builderIsReadOnly = false; + MergeFrom(original); + } + return result; + } - TestNestedExtensionLite result = new TestNestedExtensionLite(); + public override bool IsInitialized { + get { return result.IsInitialized; } + } protected override TestNestedExtensionLite MessageBeingBuilt { - get { return result; } + get { return PrepareBuilder(); } } public override Builder Clear() { - result = new TestNestedExtensionLite(); + result = DefaultInstance ?? new TestNestedExtensionLite(); + 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 TestNestedExtensionLite DefaultInstanceForType { @@ -9451,12 +10138,11 @@ namespace Google.ProtocolBuffers.TestProtos { } public override TestNestedExtensionLite BuildPartial() { - if (result == null) { - throw new global::System.InvalidOperationException("build() has already been called on this Builder"); + if (builderIsReadOnly) { + return result; } - TestNestedExtensionLite returnMe = result; - result = null; - return returnMe; + builderIsReadOnly = true; + return result; } public override Builder MergeFrom(pb::IMessageLite other) { @@ -9470,6 +10156,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder MergeFrom(TestNestedExtensionLite other) { if (other == global::Google.ProtocolBuffers.TestProtos.TestNestedExtensionLite.DefaultInstance) return this; + PrepareBuilder(); return this; } @@ -9478,6 +10165,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)) { @@ -9627,7 +10315,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder ToBuilder() { return CreateBuilder(this); } public override Builder CreateBuilderForType() { return new Builder(); } public static Builder CreateBuilder(TestDeprecatedLite prototype) { - return (Builder) new Builder().MergeFrom(prototype); + return new Builder(prototype); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] @@ -9637,21 +10325,48 @@ namespace Google.ProtocolBuffers.TestProtos { protected override Builder ThisBuilder { get { return this; } } - public Builder() {} + public Builder() { + result = DefaultInstance ?? new TestDeprecatedLite(); + builderIsReadOnly = result == DefaultInstance; + } + internal Builder(TestDeprecatedLite cloneFrom) { + result = cloneFrom; + builderIsReadOnly = true; + } - TestDeprecatedLite result = new TestDeprecatedLite(); + bool builderIsReadOnly; + TestDeprecatedLite result; + + private TestDeprecatedLite PrepareBuilder() { + if (builderIsReadOnly) { + TestDeprecatedLite original = result; + result = new TestDeprecatedLite(); + builderIsReadOnly = false; + MergeFrom(original); + } + return result; + } + + public override bool IsInitialized { + get { return result.IsInitialized; } + } protected override TestDeprecatedLite MessageBeingBuilt { - get { return result; } + get { return PrepareBuilder(); } } public override Builder Clear() { - result = new TestDeprecatedLite(); + result = DefaultInstance ?? new TestDeprecatedLite(); + 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 TestDeprecatedLite DefaultInstanceForType { @@ -9659,12 +10374,11 @@ namespace Google.ProtocolBuffers.TestProtos { } public override TestDeprecatedLite BuildPartial() { - if (result == null) { - throw new global::System.InvalidOperationException("build() has already been called on this Builder"); + if (builderIsReadOnly) { + return result; } - TestDeprecatedLite returnMe = result; - result = null; - return returnMe; + builderIsReadOnly = true; + return result; } public override Builder MergeFrom(pb::IMessageLite other) { @@ -9678,6 +10392,7 @@ namespace Google.ProtocolBuffers.TestProtos { public override Builder MergeFrom(TestDeprecatedLite other) { if (other == global::Google.ProtocolBuffers.TestProtos.TestDeprecatedLite.DefaultInstance) return this; + PrepareBuilder(); if (other.HasDeprecatedField) { DeprecatedField = other.DeprecatedField; } @@ -9689,6 +10404,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)) { @@ -9734,12 +10450,14 @@ namespace Google.ProtocolBuffers.TestProtos { } [global::System.ObsoleteAttribute()] public Builder SetDeprecatedField(int value) { + PrepareBuilder(); result.hasDeprecatedField = true; result.deprecatedField_ = value; return this; } [global::System.ObsoleteAttribute()] public Builder ClearDeprecatedField() { + PrepareBuilder(); result.hasDeprecatedField = false; result.deprecatedField_ = 0; return this; diff --git a/src/ProtocolBuffersLite.Test/TestProtos/UnitTestProtoFile.cs b/src/ProtocolBuffersLite.Test/TestProtos/UnitTestProtoFile.cs index 866167430c..547d712aa9 100644 --- a/src/ProtocolBuffersLite.Test/TestProtos/UnitTestProtoFile.cs +++ b/src/ProtocolBuffersLite.Test/TestProtos/UnitTestProtoFile.cs @@ -1262,7 +1262,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()] @@ -1272,21 +1272,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 { @@ -1298,12 +1325,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) { @@ -1317,6 +1343,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; } @@ -1329,6 +1356,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; @@ -1384,11 +1412,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; @@ -1502,7 +1532,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()] @@ -1512,21 +1542,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 { @@ -1538,12 +1595,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) { @@ -1557,6 +1613,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; } @@ -1569,6 +1626,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; @@ -1624,11 +1682,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; @@ -1742,7 +1802,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()] @@ -1752,21 +1812,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 { @@ -1778,12 +1865,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) { @@ -1797,6 +1883,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; } @@ -1809,6 +1896,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; @@ -1864,11 +1952,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; @@ -3185,7 +3275,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()] @@ -3195,21 +3285,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 { @@ -3221,8 +3338,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(); @@ -3248,9 +3365,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) { @@ -3264,6 +3380,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; } @@ -3477,6 +3594,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; @@ -3911,11 +4029,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; @@ -3929,11 +4049,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; @@ -3949,11 +4071,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; @@ -3969,11 +4093,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; @@ -3987,11 +4113,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; @@ -4005,11 +4133,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; @@ -4025,11 +4155,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; @@ -4045,11 +4177,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; @@ -4063,11 +4197,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; @@ -4081,11 +4217,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; @@ -4099,11 +4237,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; @@ -4117,11 +4257,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; @@ -4135,11 +4277,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; @@ -4154,11 +4298,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; @@ -4173,11 +4319,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; @@ -4192,18 +4340,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(); @@ -4214,6 +4365,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; @@ -4228,18 +4380,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(); @@ -4250,6 +4405,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; @@ -4264,18 +4420,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(); @@ -4286,6 +4445,7 @@ namespace Google.ProtocolBuffers.TestProtos { return this; } public Builder ClearOptionalForeignMessage() { + PrepareBuilder(); result.hasOptionalForeignMessage = false; result.optionalForeignMessage_ = global::Google.ProtocolBuffers.TestProtos.ForeignMessage.DefaultInstance; return this; @@ -4300,18 +4460,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(); @@ -4322,6 +4485,7 @@ namespace Google.ProtocolBuffers.TestProtos { return this; } public Builder ClearOptionalImportMessage() { + PrepareBuilder(); result.hasOptionalImportMessage = false; result.optionalImportMessage_ = global::Google.ProtocolBuffers.TestProtos.ImportMessage.DefaultInstance; return this; @@ -4335,11 +4499,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; @@ -4353,11 +4519,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; @@ -4371,11 +4539,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; @@ -4390,11 +4560,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; @@ -4409,18 +4581,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 RepeatedInt32List { - get { return result.repeatedInt32_; } + get { return PrepareBuilder().repeatedInt32_; } } public int RepeatedInt32Count { get { return result.RepeatedInt32Count; } @@ -4429,24 +4603,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 values) { + PrepareBuilder(); result.repeatedInt32_.Add(values); return this; } public Builder ClearRepeatedInt32() { + PrepareBuilder(); result.repeatedInt32_.Clear(); return this; } public pbc::IPopsicleList RepeatedInt64List { - get { return result.repeatedInt64_; } + get { return PrepareBuilder().repeatedInt64_; } } public int RepeatedInt64Count { get { return result.RepeatedInt64Count; } @@ -4455,25 +4633,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 values) { + PrepareBuilder(); result.repeatedInt64_.Add(values); return this; } public Builder ClearRepeatedInt64() { + PrepareBuilder(); result.repeatedInt64_.Clear(); return this; } [global::System.CLSCompliant(false)] public pbc::IPopsicleList RepeatedUint32List { - get { return result.repeatedUint32_; } + get { return PrepareBuilder().repeatedUint32_; } } public int RepeatedUint32Count { get { return result.RepeatedUint32Count; } @@ -4484,27 +4666,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 values) { + PrepareBuilder(); result.repeatedUint32_.Add(values); return this; } public Builder ClearRepeatedUint32() { + PrepareBuilder(); result.repeatedUint32_.Clear(); return this; } [global::System.CLSCompliant(false)] public pbc::IPopsicleList RepeatedUint64List { - get { return result.repeatedUint64_; } + get { return PrepareBuilder().repeatedUint64_; } } public int RepeatedUint64Count { get { return result.RepeatedUint64Count; } @@ -4515,26 +4701,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 values) { + PrepareBuilder(); result.repeatedUint64_.Add(values); return this; } public Builder ClearRepeatedUint64() { + PrepareBuilder(); result.repeatedUint64_.Clear(); return this; } public pbc::IPopsicleList RepeatedSint32List { - get { return result.repeatedSint32_; } + get { return PrepareBuilder().repeatedSint32_; } } public int RepeatedSint32Count { get { return result.RepeatedSint32Count; } @@ -4543,24 +4733,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 values) { + PrepareBuilder(); result.repeatedSint32_.Add(values); return this; } public Builder ClearRepeatedSint32() { + PrepareBuilder(); result.repeatedSint32_.Clear(); return this; } public pbc::IPopsicleList RepeatedSint64List { - get { return result.repeatedSint64_; } + get { return PrepareBuilder().repeatedSint64_; } } public int RepeatedSint64Count { get { return result.RepeatedSint64Count; } @@ -4569,25 +4763,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 values) { + PrepareBuilder(); result.repeatedSint64_.Add(values); return this; } public Builder ClearRepeatedSint64() { + PrepareBuilder(); result.repeatedSint64_.Clear(); return this; } [global::System.CLSCompliant(false)] public pbc::IPopsicleList RepeatedFixed32List { - get { return result.repeatedFixed32_; } + get { return PrepareBuilder().repeatedFixed32_; } } public int RepeatedFixed32Count { get { return result.RepeatedFixed32Count; } @@ -4598,27 +4796,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 values) { + PrepareBuilder(); result.repeatedFixed32_.Add(values); return this; } public Builder ClearRepeatedFixed32() { + PrepareBuilder(); result.repeatedFixed32_.Clear(); return this; } [global::System.CLSCompliant(false)] public pbc::IPopsicleList RepeatedFixed64List { - get { return result.repeatedFixed64_; } + get { return PrepareBuilder().repeatedFixed64_; } } public int RepeatedFixed64Count { get { return result.RepeatedFixed64Count; } @@ -4629,26 +4831,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 values) { + PrepareBuilder(); result.repeatedFixed64_.Add(values); return this; } public Builder ClearRepeatedFixed64() { + PrepareBuilder(); result.repeatedFixed64_.Clear(); return this; } public pbc::IPopsicleList RepeatedSfixed32List { - get { return result.repeatedSfixed32_; } + get { return PrepareBuilder().repeatedSfixed32_; } } public int RepeatedSfixed32Count { get { return result.RepeatedSfixed32Count; } @@ -4657,24 +4863,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 values) { + PrepareBuilder(); result.repeatedSfixed32_.Add(values); return this; } public Builder ClearRepeatedSfixed32() { + PrepareBuilder(); result.repeatedSfixed32_.Clear(); return this; } public pbc::IPopsicleList RepeatedSfixed64List { - get { return result.repeatedSfixed64_; } + get { return PrepareBuilder().repeatedSfixed64_; } } public int RepeatedSfixed64Count { get { return result.RepeatedSfixed64Count; } @@ -4683,24 +4893,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 values) { + PrepareBuilder(); result.repeatedSfixed64_.Add(values); return this; } public Builder ClearRepeatedSfixed64() { + PrepareBuilder(); result.repeatedSfixed64_.Clear(); return this; } public pbc::IPopsicleList RepeatedFloatList { - get { return result.repeatedFloat_; } + get { return PrepareBuilder().repeatedFloat_; } } public int RepeatedFloatCount { get { return result.RepeatedFloatCount; } @@ -4709,24 +4923,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 values) { + PrepareBuilder(); result.repeatedFloat_.Add(values); return this; } public Builder ClearRepeatedFloat() { + PrepareBuilder(); result.repeatedFloat_.Clear(); return this; } public pbc::IPopsicleList RepeatedDoubleList { - get { return result.repeatedDouble_; } + get { return PrepareBuilder().repeatedDouble_; } } public int RepeatedDoubleCount { get { return result.RepeatedDoubleCount; } @@ -4735,24 +4953,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 values) { + PrepareBuilder(); result.repeatedDouble_.Add(values); return this; } public Builder ClearRepeatedDouble() { + PrepareBuilder(); result.repeatedDouble_.Clear(); return this; } public pbc::IPopsicleList RepeatedBoolList { - get { return result.repeatedBool_; } + get { return PrepareBuilder().repeatedBool_; } } public int RepeatedBoolCount { get { return result.RepeatedBoolCount; } @@ -4761,24 +4983,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 values) { + PrepareBuilder(); result.repeatedBool_.Add(values); return this; } public Builder ClearRepeatedBool() { + PrepareBuilder(); result.repeatedBool_.Clear(); return this; } public pbc::IPopsicleList RepeatedStringList { - get { return result.repeatedString_; } + get { return PrepareBuilder().repeatedString_; } } public int RepeatedStringCount { get { return result.RepeatedStringCount; } @@ -4788,25 +5014,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 values) { + PrepareBuilder(); result.repeatedString_.Add(values); return this; } public Builder ClearRepeatedString() { + PrepareBuilder(); result.repeatedString_.Clear(); return this; } public pbc::IPopsicleList RepeatedBytesList { - get { return result.repeatedBytes_; } + get { return PrepareBuilder().repeatedBytes_; } } public int RepeatedBytesCount { get { return result.RepeatedBytesCount; } @@ -4816,25 +5046,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 values) { + PrepareBuilder(); result.repeatedBytes_.Add(values); return this; } public Builder ClearRepeatedBytes() { + PrepareBuilder(); result.repeatedBytes_.Clear(); return this; } public pbc::IPopsicleList RepeatedGroupList { - get { return result.repeatedGroup_; } + get { return PrepareBuilder().repeatedGroup_; } } public int RepeatedGroupCount { get { return result.RepeatedGroupCount; } @@ -4844,35 +5078,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 values) { + PrepareBuilder(); result.repeatedGroup_.Add(values); return this; } public Builder ClearRepeatedGroup() { + PrepareBuilder(); result.repeatedGroup_.Clear(); return this; } public pbc::IPopsicleList RepeatedNestedMessageList { - get { return result.repeatedNestedMessage_; } + get { return PrepareBuilder().repeatedNestedMessage_; } } public int RepeatedNestedMessageCount { get { return result.RepeatedNestedMessageCount; } @@ -4882,35 +5122,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 values) { + PrepareBuilder(); result.repeatedNestedMessage_.Add(values); return this; } public Builder ClearRepeatedNestedMessage() { + PrepareBuilder(); result.repeatedNestedMessage_.Clear(); return this; } public pbc::IPopsicleList RepeatedForeignMessageList { - get { return result.repeatedForeignMessage_; } + get { return PrepareBuilder().repeatedForeignMessage_; } } public int RepeatedForeignMessageCount { get { return result.RepeatedForeignMessageCount; } @@ -4920,35 +5166,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 values) { + PrepareBuilder(); result.repeatedForeignMessage_.Add(values); return this; } public Builder ClearRepeatedForeignMessage() { + PrepareBuilder(); result.repeatedForeignMessage_.Clear(); return this; } public pbc::IPopsicleList RepeatedImportMessageList { - get { return result.repeatedImportMessage_; } + get { return PrepareBuilder().repeatedImportMessage_; } } public int RepeatedImportMessageCount { get { return result.RepeatedImportMessageCount; } @@ -4958,35 +5210,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 values) { + PrepareBuilder(); result.repeatedImportMessage_.Add(values); return this; } public Builder ClearRepeatedImportMessage() { + PrepareBuilder(); result.repeatedImportMessage_.Clear(); return this; } public pbc::IPopsicleList RepeatedNestedEnumList { - get { return result.repeatedNestedEnum_; } + get { return PrepareBuilder().repeatedNestedEnum_; } } public int RepeatedNestedEnumCount { get { return result.RepeatedNestedEnumCount; } @@ -4995,24 +5253,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 values) { + PrepareBuilder(); result.repeatedNestedEnum_.Add(values); return this; } public Builder ClearRepeatedNestedEnum() { + PrepareBuilder(); result.repeatedNestedEnum_.Clear(); return this; } public pbc::IPopsicleList RepeatedForeignEnumList { - get { return result.repeatedForeignEnum_; } + get { return PrepareBuilder().repeatedForeignEnum_; } } public int RepeatedForeignEnumCount { get { return result.RepeatedForeignEnumCount; } @@ -5021,24 +5283,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 values) { + PrepareBuilder(); result.repeatedForeignEnum_.Add(values); return this; } public Builder ClearRepeatedForeignEnum() { + PrepareBuilder(); result.repeatedForeignEnum_.Clear(); return this; } public pbc::IPopsicleList RepeatedImportEnumList { - get { return result.repeatedImportEnum_; } + get { return PrepareBuilder().repeatedImportEnum_; } } public int RepeatedImportEnumCount { get { return result.RepeatedImportEnumCount; } @@ -5047,24 +5313,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 values) { + PrepareBuilder(); result.repeatedImportEnum_.Add(values); return this; } public Builder ClearRepeatedImportEnum() { + PrepareBuilder(); result.repeatedImportEnum_.Clear(); return this; } public pbc::IPopsicleList RepeatedStringPieceList { - get { return result.repeatedStringPiece_; } + get { return PrepareBuilder().repeatedStringPiece_; } } public int RepeatedStringPieceCount { get { return result.RepeatedStringPieceCount; } @@ -5074,25 +5344,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 values) { + PrepareBuilder(); result.repeatedStringPiece_.Add(values); return this; } public Builder ClearRepeatedStringPiece() { + PrepareBuilder(); result.repeatedStringPiece_.Clear(); return this; } public pbc::IPopsicleList RepeatedCordList { - get { return result.repeatedCord_; } + get { return PrepareBuilder().repeatedCord_; } } public int RepeatedCordCount { get { return result.RepeatedCordCount; } @@ -5102,19 +5376,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 values) { + PrepareBuilder(); result.repeatedCord_.Add(values); return this; } public Builder ClearRepeatedCord() { + PrepareBuilder(); result.repeatedCord_.Clear(); return this; } @@ -5127,11 +5405,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; @@ -5145,11 +5425,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; @@ -5165,11 +5447,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; @@ -5185,11 +5469,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; @@ -5203,11 +5489,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; @@ -5221,11 +5509,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; @@ -5241,11 +5531,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; @@ -5261,11 +5553,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; @@ -5279,11 +5573,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; @@ -5297,11 +5593,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; @@ -5315,11 +5613,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; @@ -5333,11 +5633,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; @@ -5351,11 +5653,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; @@ -5370,11 +5674,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; @@ -5389,11 +5695,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; @@ -5407,11 +5715,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; @@ -5425,11 +5735,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; @@ -5443,11 +5755,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; @@ -5462,11 +5776,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; @@ -5481,11 +5797,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; @@ -5601,7 +5919,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()] @@ -5611,21 +5929,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 { @@ -5637,12 +5982,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) { @@ -5656,6 +6000,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; } @@ -5668,6 +6013,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; @@ -5726,12 +6072,14 @@ namespace Google.ProtocolBuffers.TestProtos { } [global::System.ObsoleteAttribute()] public Builder SetDeprecatedInt32(int value) { + PrepareBuilder(); result.hasDeprecatedInt32 = true; result.deprecatedInt32_ = value; return this; } [global::System.ObsoleteAttribute()] public Builder ClearDeprecatedInt32() { + PrepareBuilder(); result.hasDeprecatedInt32 = false; result.deprecatedInt32_ = 0; return this; @@ -5845,7 +6193,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()] @@ -5855,21 +6203,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 { @@ -5881,12 +6256,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) { @@ -5900,6 +6274,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; } @@ -5912,6 +6287,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; @@ -5967,11 +6343,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; @@ -6073,7 +6451,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()] @@ -6083,21 +6461,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 { @@ -6109,12 +6514,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) { @@ -6128,6 +6532,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; @@ -6138,6 +6543,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; @@ -6289,7 +6695,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()] @@ -6299,21 +6705,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 { @@ -6325,12 +6758,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) { @@ -6344,6 +6776,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; } @@ -6356,6 +6789,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; @@ -6411,11 +6845,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; @@ -6529,7 +6965,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()] @@ -6539,21 +6975,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 { @@ -6565,12 +7028,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) { @@ -6584,6 +7046,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; } @@ -6596,6 +7059,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; @@ -6651,11 +7115,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; @@ -6755,7 +7221,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()] @@ -6765,21 +7231,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 { @@ -6791,12 +7284,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) { @@ -6810,6 +7302,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; } @@ -6819,6 +7312,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; @@ -7489,7 +7983,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()] @@ -7499,21 +7993,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 { @@ -7525,12 +8046,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) { @@ -7544,6 +8064,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; } @@ -7652,6 +8173,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; @@ -7835,11 +8357,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; @@ -7853,11 +8377,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; @@ -7871,11 +8397,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; @@ -7889,11 +8417,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; @@ -7907,11 +8437,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; @@ -7925,11 +8457,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; @@ -7943,11 +8477,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; @@ -7961,11 +8497,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; @@ -7979,11 +8517,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; @@ -7997,11 +8537,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; @@ -8015,11 +8557,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; @@ -8033,11 +8577,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; @@ -8051,11 +8597,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; @@ -8069,11 +8617,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; @@ -8087,11 +8637,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; @@ -8105,11 +8657,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; @@ -8123,11 +8677,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; @@ -8141,11 +8697,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; @@ -8159,11 +8717,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; @@ -8177,11 +8737,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; @@ -8195,11 +8757,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; @@ -8213,11 +8777,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; @@ -8231,11 +8797,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; @@ -8249,11 +8817,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; @@ -8267,11 +8837,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; @@ -8285,11 +8857,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; @@ -8303,11 +8877,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; @@ -8321,11 +8897,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; @@ -8339,11 +8917,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; @@ -8357,11 +8937,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; @@ -8375,11 +8957,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; @@ -8393,11 +8977,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; @@ -8411,11 +8997,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; @@ -8569,7 +9157,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()] @@ -8579,21 +9167,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 { @@ -8605,13 +9220,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) { @@ -8625,6 +9239,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); } @@ -8643,6 +9258,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; @@ -8712,18 +9328,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(); @@ -8734,13 +9353,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 RepeatedMessageList { - get { return result.repeatedMessage_; } + get { return PrepareBuilder().repeatedMessage_; } } public int RepeatedMessageCount { get { return result.RepeatedMessageCount; } @@ -8750,29 +9370,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 values) { + PrepareBuilder(); result.repeatedMessage_.Add(values); return this; } public Builder ClearRepeatedMessage() { + PrepareBuilder(); result.repeatedMessage_.Clear(); return this; } @@ -8785,11 +9411,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; @@ -8903,7 +9531,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()] @@ -8913,21 +9541,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 { @@ -8939,12 +9594,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) { @@ -8958,6 +9612,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); } @@ -8970,6 +9625,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; @@ -9031,18 +9687,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(); @@ -9053,6 +9712,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; @@ -9150,7 +9810,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()] @@ -9160,21 +9820,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 { @@ -9186,12 +9873,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) { @@ -9205,6 +9891,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; } @@ -9214,6 +9901,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; @@ -9353,7 +10041,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()] @@ -9363,21 +10051,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 { @@ -9389,12 +10104,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) { @@ -9408,6 +10122,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; @@ -9418,6 +10133,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; @@ -9559,7 +10275,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()] @@ -9569,21 +10285,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 { @@ -9595,12 +10338,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) { @@ -9614,6 +10356,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; @@ -9624,6 +10367,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; @@ -9791,7 +10535,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()] @@ -9801,21 +10545,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 { @@ -9827,12 +10598,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) { @@ -9846,6 +10616,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; } @@ -9861,6 +10632,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; @@ -9920,11 +10692,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; @@ -9938,11 +10712,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; @@ -10072,7 +10848,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()] @@ -10082,21 +10858,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 { @@ -10108,12 +10911,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) { @@ -10127,6 +10929,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); } @@ -10142,6 +10945,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; @@ -10207,18 +11011,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(); @@ -10229,6 +11036,7 @@ namespace Google.ProtocolBuffers.TestProtos { return this; } public Builder ClearA() { + PrepareBuilder(); result.hasA = false; result.a_ = global::Google.ProtocolBuffers.TestProtos.TestRecursiveMessage.DefaultInstance; return this; @@ -10242,11 +11050,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; @@ -10360,7 +11170,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()] @@ -10370,21 +11180,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 { @@ -10396,12 +11233,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) { @@ -10415,6 +11251,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); } @@ -10427,6 +11264,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; @@ -10488,18 +11326,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(); @@ -10510,6 +11351,7 @@ namespace Google.ProtocolBuffers.TestProtos { return this; } public Builder ClearBb() { + PrepareBuilder(); result.hasBb = false; result.bb_ = global::Google.ProtocolBuffers.TestProtos.TestMutualRecursionB.DefaultInstance; return this; @@ -10639,7 +11481,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()] @@ -10649,21 +11491,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 { @@ -10675,12 +11544,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) { @@ -10694,6 +11562,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); } @@ -10709,6 +11578,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; @@ -10774,18 +11644,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(); @@ -10796,6 +11669,7 @@ namespace Google.ProtocolBuffers.TestProtos { return this; } public Builder ClearA() { + PrepareBuilder(); result.hasA = false; result.a_ = global::Google.ProtocolBuffers.TestProtos.TestMutualRecursionA.DefaultInstance; return this; @@ -10809,11 +11683,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; @@ -10960,7 +11836,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()] @@ -10970,21 +11846,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 { @@ -10996,12 +11899,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) { @@ -11015,6 +11917,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; } @@ -11027,6 +11930,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; @@ -11082,11 +11986,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; @@ -11200,7 +12106,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()] @@ -11210,21 +12116,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 { @@ -11236,12 +12169,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) { @@ -11255,6 +12187,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; } @@ -11267,6 +12200,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; @@ -11322,11 +12256,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; @@ -11447,7 +12383,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()] @@ -11457,21 +12393,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 { @@ -11483,12 +12446,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) { @@ -11502,6 +12464,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; } @@ -11520,6 +12483,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; @@ -11593,11 +12557,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; @@ -11612,18 +12578,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(); @@ -11634,6 +12603,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; @@ -11648,18 +12618,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(); @@ -11670,6 +12643,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; @@ -11841,7 +12815,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()] @@ -11851,21 +12825,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 { @@ -11877,14 +12878,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) { @@ -11898,6 +12898,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) { result.nestedmessageRepeatedInt32_.Add(other.nestedmessageRepeatedInt32_); } @@ -11913,6 +12914,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; @@ -11966,7 +12968,7 @@ namespace Google.ProtocolBuffers.TestProtos { public pbc::IPopsicleList NestedmessageRepeatedInt32List { - get { return result.nestedmessageRepeatedInt32_; } + get { return PrepareBuilder().nestedmessageRepeatedInt32_; } } public int NestedmessageRepeatedInt32Count { get { return result.NestedmessageRepeatedInt32Count; } @@ -11975,24 +12977,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 values) { + PrepareBuilder(); result.nestedmessageRepeatedInt32_.Add(values); return this; } public Builder ClearNestedmessageRepeatedInt32() { + PrepareBuilder(); result.nestedmessageRepeatedInt32_.Clear(); return this; } public pbc::IPopsicleList NestedmessageRepeatedForeignmessageList { - get { return result.nestedmessageRepeatedForeignmessage_; } + get { return PrepareBuilder().nestedmessageRepeatedForeignmessage_; } } public int NestedmessageRepeatedForeignmessageCount { get { return result.NestedmessageRepeatedForeignmessageCount; } @@ -12002,29 +13008,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 values) { + PrepareBuilder(); result.nestedmessageRepeatedForeignmessage_.Add(values); return this; } public Builder ClearNestedmessageRepeatedForeignmessage() { + PrepareBuilder(); result.nestedmessageRepeatedForeignmessage_.Clear(); return this; } @@ -12112,7 +13124,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()] @@ -12122,21 +13134,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 { @@ -12148,12 +13187,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) { @@ -12167,6 +13205,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); } @@ -12179,6 +13218,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; @@ -12240,18 +13280,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(); @@ -12262,6 +13305,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; @@ -12590,7 +13634,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()] @@ -12600,21 +13644,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 { @@ -12626,8 +13697,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(); @@ -12635,9 +13706,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) { @@ -12651,6 +13721,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; } @@ -12696,6 +13767,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; @@ -12819,11 +13891,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; @@ -12838,11 +13912,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; @@ -12856,11 +13932,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; @@ -12875,18 +13953,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(); @@ -12897,6 +13978,7 @@ namespace Google.ProtocolBuffers.TestProtos { return this; } public Builder ClearMessageField() { + PrepareBuilder(); result.hasMessageField = false; result.messageField_ = global::Google.ProtocolBuffers.TestProtos.ForeignMessage.DefaultInstance; return this; @@ -12911,11 +13993,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; @@ -12930,18 +14014,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 RepeatedPrimitiveFieldList { - get { return result.repeatedPrimitiveField_; } + get { return PrepareBuilder().repeatedPrimitiveField_; } } public int RepeatedPrimitiveFieldCount { get { return result.RepeatedPrimitiveFieldCount; } @@ -12950,24 +14036,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 values) { + PrepareBuilder(); result.repeatedPrimitiveField_.Add(values); return this; } public Builder ClearRepeatedPrimitiveField() { + PrepareBuilder(); result.repeatedPrimitiveField_.Clear(); return this; } public pbc::IPopsicleList RepeatedStringFieldList { - get { return result.repeatedStringField_; } + get { return PrepareBuilder().repeatedStringField_; } } public int RepeatedStringFieldCount { get { return result.RepeatedStringFieldCount; } @@ -12977,25 +14067,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 values) { + PrepareBuilder(); result.repeatedStringField_.Add(values); return this; } public Builder ClearRepeatedStringField() { + PrepareBuilder(); result.repeatedStringField_.Clear(); return this; } public pbc::IPopsicleList RepeatedEnumFieldList { - get { return result.repeatedEnumField_; } + get { return PrepareBuilder().repeatedEnumField_; } } public int RepeatedEnumFieldCount { get { return result.RepeatedEnumFieldCount; } @@ -13004,24 +14098,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 values) { + PrepareBuilder(); result.repeatedEnumField_.Add(values); return this; } public Builder ClearRepeatedEnumField() { + PrepareBuilder(); result.repeatedEnumField_.Clear(); return this; } public pbc::IPopsicleList RepeatedMessageFieldList { - get { return result.repeatedMessageField_; } + get { return PrepareBuilder().repeatedMessageField_; } } public int RepeatedMessageFieldCount { get { return result.RepeatedMessageFieldCount; } @@ -13031,35 +14129,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 values) { + PrepareBuilder(); result.repeatedMessageField_.Add(values); return this; } public Builder ClearRepeatedMessageField() { + PrepareBuilder(); result.repeatedMessageField_.Clear(); return this; } public pbc::IPopsicleList RepeatedStringPieceFieldList { - get { return result.repeatedStringPieceField_; } + get { return PrepareBuilder().repeatedStringPieceField_; } } public int RepeatedStringPieceFieldCount { get { return result.RepeatedStringPieceFieldCount; } @@ -13069,25 +14173,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 values) { + PrepareBuilder(); result.repeatedStringPieceField_.Add(values); return this; } public Builder ClearRepeatedStringPieceField() { + PrepareBuilder(); result.repeatedStringPieceField_.Clear(); return this; } public pbc::IPopsicleList RepeatedCordFieldList { - get { return result.repeatedCordField_; } + get { return PrepareBuilder().repeatedCordField_; } } public int RepeatedCordFieldCount { get { return result.RepeatedCordFieldCount; } @@ -13097,19 +14205,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 values) { + PrepareBuilder(); result.repeatedCordField_.Add(values); return this; } public Builder ClearRepeatedCordField() { + PrepareBuilder(); result.repeatedCordField_.Clear(); return this; } @@ -13259,7 +14371,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()] @@ -13269,21 +14381,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 { @@ -13295,12 +14434,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) { @@ -13314,6 +14452,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; } @@ -13333,6 +14472,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; @@ -13397,11 +14537,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; @@ -13415,11 +14557,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; @@ -13433,11 +14577,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; @@ -13841,7 +14987,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()] @@ -13851,21 +14997,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 { @@ -13877,12 +15050,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) { @@ -13896,6 +15068,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; } @@ -13962,6 +15135,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; @@ -14090,11 +15264,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; @@ -14110,11 +15286,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; @@ -14130,11 +15308,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; @@ -14148,11 +15328,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; @@ -14166,11 +15348,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; @@ -14185,11 +15369,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; @@ -14203,11 +15389,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; @@ -14221,11 +15409,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; @@ -14239,11 +15429,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; @@ -14257,11 +15449,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; @@ -14275,11 +15469,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; @@ -14293,11 +15489,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; @@ -14311,11 +15509,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; @@ -14329,11 +15529,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; @@ -14347,11 +15549,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; @@ -14365,11 +15569,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; @@ -14383,11 +15589,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; @@ -14401,11 +15609,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; @@ -14419,11 +15629,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; @@ -14537,7 +15749,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()] @@ -14547,21 +15759,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 { @@ -14573,12 +15812,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) { @@ -14592,6 +15830,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; } @@ -14604,6 +15843,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; @@ -14660,11 +15900,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; @@ -14778,7 +16020,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()] @@ -14788,21 +16030,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 { @@ -14814,12 +16083,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) { @@ -14833,6 +16101,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; } @@ -14845,6 +16114,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; @@ -14901,11 +16171,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; @@ -15376,7 +16648,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()] @@ -15386,21 +16658,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 { @@ -15412,8 +16711,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(); @@ -15429,9 +16728,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) { @@ -15445,6 +16743,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) { result.packedInt32_.Add(other.packedInt32_); } @@ -15496,6 +16795,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; @@ -15619,7 +16919,7 @@ namespace Google.ProtocolBuffers.TestProtos { public pbc::IPopsicleList PackedInt32List { - get { return result.packedInt32_; } + get { return PrepareBuilder().packedInt32_; } } public int PackedInt32Count { get { return result.PackedInt32Count; } @@ -15628,24 +16928,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 values) { + PrepareBuilder(); result.packedInt32_.Add(values); return this; } public Builder ClearPackedInt32() { + PrepareBuilder(); result.packedInt32_.Clear(); return this; } public pbc::IPopsicleList PackedInt64List { - get { return result.packedInt64_; } + get { return PrepareBuilder().packedInt64_; } } public int PackedInt64Count { get { return result.PackedInt64Count; } @@ -15654,25 +16958,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 values) { + PrepareBuilder(); result.packedInt64_.Add(values); return this; } public Builder ClearPackedInt64() { + PrepareBuilder(); result.packedInt64_.Clear(); return this; } [global::System.CLSCompliant(false)] public pbc::IPopsicleList PackedUint32List { - get { return result.packedUint32_; } + get { return PrepareBuilder().packedUint32_; } } public int PackedUint32Count { get { return result.PackedUint32Count; } @@ -15683,27 +16991,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 values) { + PrepareBuilder(); result.packedUint32_.Add(values); return this; } public Builder ClearPackedUint32() { + PrepareBuilder(); result.packedUint32_.Clear(); return this; } [global::System.CLSCompliant(false)] public pbc::IPopsicleList PackedUint64List { - get { return result.packedUint64_; } + get { return PrepareBuilder().packedUint64_; } } public int PackedUint64Count { get { return result.PackedUint64Count; } @@ -15714,26 +17026,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 values) { + PrepareBuilder(); result.packedUint64_.Add(values); return this; } public Builder ClearPackedUint64() { + PrepareBuilder(); result.packedUint64_.Clear(); return this; } public pbc::IPopsicleList PackedSint32List { - get { return result.packedSint32_; } + get { return PrepareBuilder().packedSint32_; } } public int PackedSint32Count { get { return result.PackedSint32Count; } @@ -15742,24 +17058,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 values) { + PrepareBuilder(); result.packedSint32_.Add(values); return this; } public Builder ClearPackedSint32() { + PrepareBuilder(); result.packedSint32_.Clear(); return this; } public pbc::IPopsicleList PackedSint64List { - get { return result.packedSint64_; } + get { return PrepareBuilder().packedSint64_; } } public int PackedSint64Count { get { return result.PackedSint64Count; } @@ -15768,25 +17088,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 values) { + PrepareBuilder(); result.packedSint64_.Add(values); return this; } public Builder ClearPackedSint64() { + PrepareBuilder(); result.packedSint64_.Clear(); return this; } [global::System.CLSCompliant(false)] public pbc::IPopsicleList PackedFixed32List { - get { return result.packedFixed32_; } + get { return PrepareBuilder().packedFixed32_; } } public int PackedFixed32Count { get { return result.PackedFixed32Count; } @@ -15797,27 +17121,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 values) { + PrepareBuilder(); result.packedFixed32_.Add(values); return this; } public Builder ClearPackedFixed32() { + PrepareBuilder(); result.packedFixed32_.Clear(); return this; } [global::System.CLSCompliant(false)] public pbc::IPopsicleList PackedFixed64List { - get { return result.packedFixed64_; } + get { return PrepareBuilder().packedFixed64_; } } public int PackedFixed64Count { get { return result.PackedFixed64Count; } @@ -15828,26 +17156,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 values) { + PrepareBuilder(); result.packedFixed64_.Add(values); return this; } public Builder ClearPackedFixed64() { + PrepareBuilder(); result.packedFixed64_.Clear(); return this; } public pbc::IPopsicleList PackedSfixed32List { - get { return result.packedSfixed32_; } + get { return PrepareBuilder().packedSfixed32_; } } public int PackedSfixed32Count { get { return result.PackedSfixed32Count; } @@ -15856,24 +17188,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 values) { + PrepareBuilder(); result.packedSfixed32_.Add(values); return this; } public Builder ClearPackedSfixed32() { + PrepareBuilder(); result.packedSfixed32_.Clear(); return this; } public pbc::IPopsicleList PackedSfixed64List { - get { return result.packedSfixed64_; } + get { return PrepareBuilder().packedSfixed64_; } } public int PackedSfixed64Count { get { return result.PackedSfixed64Count; } @@ -15882,24 +17218,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 values) { + PrepareBuilder(); result.packedSfixed64_.Add(values); return this; } public Builder ClearPackedSfixed64() { + PrepareBuilder(); result.packedSfixed64_.Clear(); return this; } public pbc::IPopsicleList PackedFloatList { - get { return result.packedFloat_; } + get { return PrepareBuilder().packedFloat_; } } public int PackedFloatCount { get { return result.PackedFloatCount; } @@ -15908,24 +17248,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 values) { + PrepareBuilder(); result.packedFloat_.Add(values); return this; } public Builder ClearPackedFloat() { + PrepareBuilder(); result.packedFloat_.Clear(); return this; } public pbc::IPopsicleList PackedDoubleList { - get { return result.packedDouble_; } + get { return PrepareBuilder().packedDouble_; } } public int PackedDoubleCount { get { return result.PackedDoubleCount; } @@ -15934,24 +17278,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 values) { + PrepareBuilder(); result.packedDouble_.Add(values); return this; } public Builder ClearPackedDouble() { + PrepareBuilder(); result.packedDouble_.Clear(); return this; } public pbc::IPopsicleList PackedBoolList { - get { return result.packedBool_; } + get { return PrepareBuilder().packedBool_; } } public int PackedBoolCount { get { return result.PackedBoolCount; } @@ -15960,24 +17308,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 values) { + PrepareBuilder(); result.packedBool_.Add(values); return this; } public Builder ClearPackedBool() { + PrepareBuilder(); result.packedBool_.Clear(); return this; } public pbc::IPopsicleList PackedEnumList { - get { return result.packedEnum_; } + get { return PrepareBuilder().packedEnum_; } } public int PackedEnumCount { get { return result.PackedEnumCount; } @@ -15986,18 +17338,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 values) { + PrepareBuilder(); result.packedEnum_.Add(values); return this; } public Builder ClearPackedEnum() { + PrepareBuilder(); result.packedEnum_.Clear(); return this; } @@ -16412,7 +17768,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()] @@ -16422,21 +17778,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 { @@ -16448,8 +17831,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(); @@ -16465,9 +17848,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) { @@ -16481,6 +17863,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) { result.unpackedInt32_.Add(other.unpackedInt32_); } @@ -16532,6 +17915,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; @@ -16655,7 +18039,7 @@ namespace Google.ProtocolBuffers.TestProtos { public pbc::IPopsicleList UnpackedInt32List { - get { return result.unpackedInt32_; } + get { return PrepareBuilder().unpackedInt32_; } } public int UnpackedInt32Count { get { return result.UnpackedInt32Count; } @@ -16664,24 +18048,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 values) { + PrepareBuilder(); result.unpackedInt32_.Add(values); return this; } public Builder ClearUnpackedInt32() { + PrepareBuilder(); result.unpackedInt32_.Clear(); return this; } public pbc::IPopsicleList UnpackedInt64List { - get { return result.unpackedInt64_; } + get { return PrepareBuilder().unpackedInt64_; } } public int UnpackedInt64Count { get { return result.UnpackedInt64Count; } @@ -16690,25 +18078,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 values) { + PrepareBuilder(); result.unpackedInt64_.Add(values); return this; } public Builder ClearUnpackedInt64() { + PrepareBuilder(); result.unpackedInt64_.Clear(); return this; } [global::System.CLSCompliant(false)] public pbc::IPopsicleList UnpackedUint32List { - get { return result.unpackedUint32_; } + get { return PrepareBuilder().unpackedUint32_; } } public int UnpackedUint32Count { get { return result.UnpackedUint32Count; } @@ -16719,27 +18111,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 values) { + PrepareBuilder(); result.unpackedUint32_.Add(values); return this; } public Builder ClearUnpackedUint32() { + PrepareBuilder(); result.unpackedUint32_.Clear(); return this; } [global::System.CLSCompliant(false)] public pbc::IPopsicleList UnpackedUint64List { - get { return result.unpackedUint64_; } + get { return PrepareBuilder().unpackedUint64_; } } public int UnpackedUint64Count { get { return result.UnpackedUint64Count; } @@ -16750,26 +18146,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 values) { + PrepareBuilder(); result.unpackedUint64_.Add(values); return this; } public Builder ClearUnpackedUint64() { + PrepareBuilder(); result.unpackedUint64_.Clear(); return this; } public pbc::IPopsicleList UnpackedSint32List { - get { return result.unpackedSint32_; } + get { return PrepareBuilder().unpackedSint32_; } } public int UnpackedSint32Count { get { return result.UnpackedSint32Count; } @@ -16778,24 +18178,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 values) { + PrepareBuilder(); result.unpackedSint32_.Add(values); return this; } public Builder ClearUnpackedSint32() { + PrepareBuilder(); result.unpackedSint32_.Clear(); return this; } public pbc::IPopsicleList UnpackedSint64List { - get { return result.unpackedSint64_; } + get { return PrepareBuilder().unpackedSint64_; } } public int UnpackedSint64Count { get { return result.UnpackedSint64Count; } @@ -16804,25 +18208,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 values) { + PrepareBuilder(); result.unpackedSint64_.Add(values); return this; } public Builder ClearUnpackedSint64() { + PrepareBuilder(); result.unpackedSint64_.Clear(); return this; } [global::System.CLSCompliant(false)] public pbc::IPopsicleList UnpackedFixed32List { - get { return result.unpackedFixed32_; } + get { return PrepareBuilder().unpackedFixed32_; } } public int UnpackedFixed32Count { get { return result.UnpackedFixed32Count; } @@ -16833,27 +18241,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 values) { + PrepareBuilder(); result.unpackedFixed32_.Add(values); return this; } public Builder ClearUnpackedFixed32() { + PrepareBuilder(); result.unpackedFixed32_.Clear(); return this; } [global::System.CLSCompliant(false)] public pbc::IPopsicleList UnpackedFixed64List { - get { return result.unpackedFixed64_; } + get { return PrepareBuilder().unpackedFixed64_; } } public int UnpackedFixed64Count { get { return result.UnpackedFixed64Count; } @@ -16864,26 +18276,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 values) { + PrepareBuilder(); result.unpackedFixed64_.Add(values); return this; } public Builder ClearUnpackedFixed64() { + PrepareBuilder(); result.unpackedFixed64_.Clear(); return this; } public pbc::IPopsicleList UnpackedSfixed32List { - get { return result.unpackedSfixed32_; } + get { return PrepareBuilder().unpackedSfixed32_; } } public int UnpackedSfixed32Count { get { return result.UnpackedSfixed32Count; } @@ -16892,24 +18308,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 values) { + PrepareBuilder(); result.unpackedSfixed32_.Add(values); return this; } public Builder ClearUnpackedSfixed32() { + PrepareBuilder(); result.unpackedSfixed32_.Clear(); return this; } public pbc::IPopsicleList UnpackedSfixed64List { - get { return result.unpackedSfixed64_; } + get { return PrepareBuilder().unpackedSfixed64_; } } public int UnpackedSfixed64Count { get { return result.UnpackedSfixed64Count; } @@ -16918,24 +18338,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 values) { + PrepareBuilder(); result.unpackedSfixed64_.Add(values); return this; } public Builder ClearUnpackedSfixed64() { + PrepareBuilder(); result.unpackedSfixed64_.Clear(); return this; } public pbc::IPopsicleList UnpackedFloatList { - get { return result.unpackedFloat_; } + get { return PrepareBuilder().unpackedFloat_; } } public int UnpackedFloatCount { get { return result.UnpackedFloatCount; } @@ -16944,24 +18368,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 values) { + PrepareBuilder(); result.unpackedFloat_.Add(values); return this; } public Builder ClearUnpackedFloat() { + PrepareBuilder(); result.unpackedFloat_.Clear(); return this; } public pbc::IPopsicleList UnpackedDoubleList { - get { return result.unpackedDouble_; } + get { return PrepareBuilder().unpackedDouble_; } } public int UnpackedDoubleCount { get { return result.UnpackedDoubleCount; } @@ -16970,24 +18398,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 values) { + PrepareBuilder(); result.unpackedDouble_.Add(values); return this; } public Builder ClearUnpackedDouble() { + PrepareBuilder(); result.unpackedDouble_.Clear(); return this; } public pbc::IPopsicleList UnpackedBoolList { - get { return result.unpackedBool_; } + get { return PrepareBuilder().unpackedBool_; } } public int UnpackedBoolCount { get { return result.UnpackedBoolCount; } @@ -16996,24 +18428,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 values) { + PrepareBuilder(); result.unpackedBool_.Add(values); return this; } public Builder ClearUnpackedBool() { + PrepareBuilder(); result.unpackedBool_.Clear(); return this; } public pbc::IPopsicleList UnpackedEnumList { - get { return result.unpackedEnum_; } + get { return PrepareBuilder().unpackedEnum_; } } public int UnpackedEnumCount { get { return result.UnpackedEnumCount; } @@ -17022,18 +18458,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 values) { + PrepareBuilder(); result.unpackedEnum_.Add(values); return this; } public Builder ClearUnpackedEnum() { + PrepareBuilder(); result.unpackedEnum_.Clear(); return this; } @@ -17134,7 +18574,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()] @@ -17144,21 +18584,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 { @@ -17170,12 +18637,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) { @@ -17189,6 +18655,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; @@ -17199,6 +18666,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; @@ -17338,7 +18806,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()] @@ -17348,21 +18816,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 { @@ -17374,12 +18869,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) { @@ -17393,6 +18887,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; @@ -17403,6 +18898,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; @@ -17595,7 +19091,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()] @@ -17605,21 +19101,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 { @@ -17631,12 +19154,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) { @@ -17650,6 +19172,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; } @@ -17662,6 +19185,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; @@ -17717,11 +19241,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; @@ -17925,7 +19451,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()] @@ -17935,21 +19461,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 { @@ -17961,14 +19514,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) { @@ -17982,6 +19534,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; } @@ -18012,6 +19565,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; @@ -18120,11 +19674,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; @@ -18138,11 +19694,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; @@ -18156,11 +19714,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; @@ -18175,18 +19735,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(); @@ -18197,6 +19760,7 @@ namespace Google.ProtocolBuffers.TestProtos { return this; } public Builder ClearMessageExtension() { + PrepareBuilder(); result.hasMessageExtension = false; result.messageExtension_ = global::Google.ProtocolBuffers.TestProtos.ForeignMessage.DefaultInstance; return this; @@ -18211,18 +19775,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(); @@ -18233,13 +19800,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 RepeatedExtensionList { - get { return result.repeatedExtension_; } + get { return PrepareBuilder().repeatedExtension_; } } public int RepeatedExtensionCount { get { return result.RepeatedExtensionCount; } @@ -18249,25 +19817,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 values) { + PrepareBuilder(); result.repeatedExtension_.Add(values); return this; } public Builder ClearRepeatedExtension() { + PrepareBuilder(); result.repeatedExtension_.Clear(); return this; } public pbc::IPopsicleList PackedExtensionList { - get { return result.packedExtension_; } + get { return PrepareBuilder().packedExtension_; } } public int PackedExtensionCount { get { return result.PackedExtensionCount; } @@ -18276,18 +19848,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 values) { + PrepareBuilder(); result.packedExtension_.Add(values); return this; } public Builder ClearPackedExtension() { + PrepareBuilder(); result.packedExtension_.Clear(); return this; } @@ -18522,7 +20098,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()] @@ -18532,21 +20108,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 { @@ -18558,8 +20161,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(); @@ -18567,9 +20170,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) { @@ -18583,6 +20185,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) { result.repeatedFixed32_.Add(other.repeatedFixed32_); } @@ -18610,6 +20213,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; @@ -18685,7 +20289,7 @@ namespace Google.ProtocolBuffers.TestProtos { [global::System.CLSCompliant(false)] public pbc::IPopsicleList RepeatedFixed32List { - get { return result.repeatedFixed32_; } + get { return PrepareBuilder().repeatedFixed32_; } } public int RepeatedFixed32Count { get { return result.RepeatedFixed32Count; } @@ -18696,26 +20300,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 values) { + PrepareBuilder(); result.repeatedFixed32_.Add(values); return this; } public Builder ClearRepeatedFixed32() { + PrepareBuilder(); result.repeatedFixed32_.Clear(); return this; } public pbc::IPopsicleList RepeatedInt32List { - get { return result.repeatedInt32_; } + get { return PrepareBuilder().repeatedInt32_; } } public int RepeatedInt32Count { get { return result.RepeatedInt32Count; } @@ -18724,25 +20332,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 values) { + PrepareBuilder(); result.repeatedInt32_.Add(values); return this; } public Builder ClearRepeatedInt32() { + PrepareBuilder(); result.repeatedInt32_.Clear(); return this; } [global::System.CLSCompliant(false)] public pbc::IPopsicleList RepeatedFixed64List { - get { return result.repeatedFixed64_; } + get { return PrepareBuilder().repeatedFixed64_; } } public int RepeatedFixed64Count { get { return result.RepeatedFixed64Count; } @@ -18753,26 +20365,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 values) { + PrepareBuilder(); result.repeatedFixed64_.Add(values); return this; } public Builder ClearRepeatedFixed64() { + PrepareBuilder(); result.repeatedFixed64_.Clear(); return this; } public pbc::IPopsicleList RepeatedInt64List { - get { return result.repeatedInt64_; } + get { return PrepareBuilder().repeatedInt64_; } } public int RepeatedInt64Count { get { return result.RepeatedInt64Count; } @@ -18781,24 +20397,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 values) { + PrepareBuilder(); result.repeatedInt64_.Add(values); return this; } public Builder ClearRepeatedInt64() { + PrepareBuilder(); result.repeatedInt64_.Clear(); return this; } public pbc::IPopsicleList RepeatedFloatList { - get { return result.repeatedFloat_; } + get { return PrepareBuilder().repeatedFloat_; } } public int RepeatedFloatCount { get { return result.RepeatedFloatCount; } @@ -18807,25 +20427,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 values) { + PrepareBuilder(); result.repeatedFloat_.Add(values); return this; } public Builder ClearRepeatedFloat() { + PrepareBuilder(); result.repeatedFloat_.Clear(); return this; } [global::System.CLSCompliant(false)] public pbc::IPopsicleList RepeatedUint64List { - get { return result.repeatedUint64_; } + get { return PrepareBuilder().repeatedUint64_; } } public int RepeatedUint64Count { get { return result.RepeatedUint64Count; } @@ -18836,20 +20460,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 values) { + PrepareBuilder(); result.repeatedUint64_.Add(values); return this; } public Builder ClearRepeatedUint64() { + PrepareBuilder(); result.repeatedUint64_.Clear(); return this; } @@ -18946,7 +20574,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()] @@ -18956,21 +20584,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 { @@ -18982,12 +20637,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) { @@ -19001,6 +20655,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; } @@ -19010,6 +20665,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; @@ -19145,7 +20801,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()] @@ -19155,21 +20811,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 { @@ -19181,12 +20864,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) { @@ -19200,6 +20882,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; } @@ -19209,6 +20892,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; @@ -19344,7 +21028,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()] @@ -19354,21 +21038,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 { @@ -19380,12 +21091,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) { @@ -19399,6 +21109,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; } @@ -19408,6 +21119,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; @@ -19543,7 +21255,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()] @@ -19553,21 +21265,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 { @@ -19579,12 +21318,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) { @@ -19598,6 +21336,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; } @@ -19607,6 +21346,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;