Commit a314d4c9 authored by csharptest's avatar csharptest Committed by rogerk

Regenerated code with changes

parent dc24b605
This diff is collapsed.
...@@ -60,7 +60,7 @@ namespace Google.ProtocolBuffers.TestProtos { ...@@ -60,7 +60,7 @@ namespace Google.ProtocolBuffers.TestProtos {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("ProtoGen", "2.3.0.277")] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("ProtoGen", "2.3.0.277")]
public sealed partial class OptionsMessage : pb::GeneratedMessage<OptionsMessage, OptionsMessage.Builder> { public sealed partial class OptionsMessage : pb::GeneratedMessage<OptionsMessage, OptionsMessage.Builder> {
private static readonly OptionsMessage defaultInstance = new Builder().BuildPartial(); private static readonly OptionsMessage defaultInstance = new OptionsMessage().MakeReadOnly();
private static readonly string[] _optionsMessageFieldNames = new string[] { "customized", "normal", "options_message" }; private static readonly string[] _optionsMessageFieldNames = new string[] { "customized", "normal", "options_message" };
private static readonly uint[] _optionsMessageFieldTags = new uint[] { 26, 10, 18 }; private static readonly uint[] _optionsMessageFieldTags = new uint[] { 26, 10, 18 };
public static OptionsMessage DefaultInstance { public static OptionsMessage DefaultInstance {
...@@ -68,7 +68,7 @@ namespace Google.ProtocolBuffers.TestProtos { ...@@ -68,7 +68,7 @@ namespace Google.ProtocolBuffers.TestProtos {
} }
public override OptionsMessage DefaultInstanceForType { public override OptionsMessage DefaultInstanceForType {
get { return defaultInstance; } get { return DefaultInstance; }
} }
protected override OptionsMessage ThisMessage { protected override OptionsMessage ThisMessage {
...@@ -186,6 +186,10 @@ namespace Google.ProtocolBuffers.TestProtos { ...@@ -186,6 +186,10 @@ namespace Google.ProtocolBuffers.TestProtos {
public static OptionsMessage ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { public static OptionsMessage ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
} }
private OptionsMessage MakeReadOnly() {
return this;
}
public static Builder CreateBuilder() { return new Builder(); } public static Builder CreateBuilder() { return new Builder(); }
public override Builder ToBuilder() { return CreateBuilder(this); } public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); } public override Builder CreateBuilderForType() { return new Builder(); }
...@@ -201,22 +205,22 @@ namespace Google.ProtocolBuffers.TestProtos { ...@@ -201,22 +205,22 @@ namespace Google.ProtocolBuffers.TestProtos {
get { return this; } get { return this; }
} }
public Builder() { public Builder() {
result = DefaultInstance ?? new OptionsMessage(); result = DefaultInstance;
builderIsReadOnly = result == DefaultInstance; resultIsReadOnly = true;
} }
internal Builder(OptionsMessage cloneFrom) { internal Builder(OptionsMessage cloneFrom) {
result = cloneFrom; result = cloneFrom;
builderIsReadOnly = true; resultIsReadOnly = true;
} }
bool builderIsReadOnly; private bool resultIsReadOnly;
OptionsMessage result; private OptionsMessage result;
private OptionsMessage PrepareBuilder() { private OptionsMessage PrepareBuilder() {
if (builderIsReadOnly) { if (resultIsReadOnly) {
OptionsMessage original = result; OptionsMessage original = result;
result = new OptionsMessage(); result = new OptionsMessage();
builderIsReadOnly = false; resultIsReadOnly = false;
MergeFrom(original); MergeFrom(original);
} }
return result; return result;
...@@ -231,13 +235,13 @@ namespace Google.ProtocolBuffers.TestProtos { ...@@ -231,13 +235,13 @@ namespace Google.ProtocolBuffers.TestProtos {
} }
public override Builder Clear() { public override Builder Clear() {
result = DefaultInstance ?? new OptionsMessage(); result = DefaultInstance;
builderIsReadOnly = true; resultIsReadOnly = true;
return this; return this;
} }
public override Builder Clone() { public override Builder Clone() {
if (builderIsReadOnly) { if (resultIsReadOnly) {
return new Builder(result); return new Builder(result);
} else { } else {
return new Builder().MergeFrom(result); return new Builder().MergeFrom(result);
...@@ -253,11 +257,11 @@ namespace Google.ProtocolBuffers.TestProtos { ...@@ -253,11 +257,11 @@ namespace Google.ProtocolBuffers.TestProtos {
} }
public override OptionsMessage BuildPartial() { public override OptionsMessage BuildPartial() {
if (builderIsReadOnly) { if (resultIsReadOnly) {
return result; return result;
} }
builderIsReadOnly = true; resultIsReadOnly = true;
return result; return result.MakeReadOnly();
} }
public override Builder MergeFrom(pb::IMessage other) { public override Builder MergeFrom(pb::IMessage other) {
......
...@@ -64,7 +64,7 @@ namespace Google.ProtocolBuffers.TestProtos { ...@@ -64,7 +64,7 @@ namespace Google.ProtocolBuffers.TestProtos {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("ProtoGen", "2.3.0.277")] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("ProtoGen", "2.3.0.277")]
public sealed partial class TestEmbedOptimizedForSize : pb::GeneratedMessage<TestEmbedOptimizedForSize, TestEmbedOptimizedForSize.Builder> { public sealed partial class TestEmbedOptimizedForSize : pb::GeneratedMessage<TestEmbedOptimizedForSize, TestEmbedOptimizedForSize.Builder> {
private static readonly TestEmbedOptimizedForSize defaultInstance = new Builder().BuildPartial(); private static readonly TestEmbedOptimizedForSize defaultInstance = new TestEmbedOptimizedForSize().MakeReadOnly();
private static readonly string[] _testEmbedOptimizedForSizeFieldNames = new string[] { "optional_message", "repeated_message" }; private static readonly string[] _testEmbedOptimizedForSizeFieldNames = new string[] { "optional_message", "repeated_message" };
private static readonly uint[] _testEmbedOptimizedForSizeFieldTags = new uint[] { 10, 18 }; private static readonly uint[] _testEmbedOptimizedForSizeFieldTags = new uint[] { 10, 18 };
public static TestEmbedOptimizedForSize DefaultInstance { public static TestEmbedOptimizedForSize DefaultInstance {
...@@ -72,7 +72,7 @@ namespace Google.ProtocolBuffers.TestProtos { ...@@ -72,7 +72,7 @@ namespace Google.ProtocolBuffers.TestProtos {
} }
public override TestEmbedOptimizedForSize DefaultInstanceForType { public override TestEmbedOptimizedForSize DefaultInstanceForType {
get { return defaultInstance; } get { return DefaultInstance; }
} }
protected override TestEmbedOptimizedForSize ThisMessage { protected override TestEmbedOptimizedForSize ThisMessage {
...@@ -89,12 +89,12 @@ namespace Google.ProtocolBuffers.TestProtos { ...@@ -89,12 +89,12 @@ namespace Google.ProtocolBuffers.TestProtos {
public const int OptionalMessageFieldNumber = 1; public const int OptionalMessageFieldNumber = 1;
private bool hasOptionalMessage; private bool hasOptionalMessage;
private global::Google.ProtocolBuffers.TestProtos.TestOptimizedForSize optionalMessage_ = global::Google.ProtocolBuffers.TestProtos.TestOptimizedForSize.DefaultInstance; private global::Google.ProtocolBuffers.TestProtos.TestOptimizedForSize optionalMessage_;
public bool HasOptionalMessage { public bool HasOptionalMessage {
get { return hasOptionalMessage; } get { return hasOptionalMessage; }
} }
public global::Google.ProtocolBuffers.TestProtos.TestOptimizedForSize OptionalMessage { public global::Google.ProtocolBuffers.TestProtos.TestOptimizedForSize OptionalMessage {
get { return optionalMessage_; } get { return optionalMessage_ ?? global::Google.ProtocolBuffers.TestProtos.TestOptimizedForSize.DefaultInstance; }
} }
public const int RepeatedMessageFieldNumber = 2; public const int RepeatedMessageFieldNumber = 2;
...@@ -182,6 +182,11 @@ namespace Google.ProtocolBuffers.TestProtos { ...@@ -182,6 +182,11 @@ namespace Google.ProtocolBuffers.TestProtos {
public static TestEmbedOptimizedForSize ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { public static TestEmbedOptimizedForSize ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
} }
private TestEmbedOptimizedForSize MakeReadOnly() {
repeatedMessage_.MakeReadOnly();
return this;
}
public static Builder CreateBuilder() { return new Builder(); } public static Builder CreateBuilder() { return new Builder(); }
public override Builder ToBuilder() { return CreateBuilder(this); } public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); } public override Builder CreateBuilderForType() { return new Builder(); }
...@@ -197,22 +202,22 @@ namespace Google.ProtocolBuffers.TestProtos { ...@@ -197,22 +202,22 @@ namespace Google.ProtocolBuffers.TestProtos {
get { return this; } get { return this; }
} }
public Builder() { public Builder() {
result = DefaultInstance ?? new TestEmbedOptimizedForSize(); result = DefaultInstance;
builderIsReadOnly = result == DefaultInstance; resultIsReadOnly = true;
} }
internal Builder(TestEmbedOptimizedForSize cloneFrom) { internal Builder(TestEmbedOptimizedForSize cloneFrom) {
result = cloneFrom; result = cloneFrom;
builderIsReadOnly = true; resultIsReadOnly = true;
} }
bool builderIsReadOnly; private bool resultIsReadOnly;
TestEmbedOptimizedForSize result; private TestEmbedOptimizedForSize result;
private TestEmbedOptimizedForSize PrepareBuilder() { private TestEmbedOptimizedForSize PrepareBuilder() {
if (builderIsReadOnly) { if (resultIsReadOnly) {
TestEmbedOptimizedForSize original = result; TestEmbedOptimizedForSize original = result;
result = new TestEmbedOptimizedForSize(); result = new TestEmbedOptimizedForSize();
builderIsReadOnly = false; resultIsReadOnly = false;
MergeFrom(original); MergeFrom(original);
} }
return result; return result;
...@@ -227,13 +232,13 @@ namespace Google.ProtocolBuffers.TestProtos { ...@@ -227,13 +232,13 @@ namespace Google.ProtocolBuffers.TestProtos {
} }
public override Builder Clear() { public override Builder Clear() {
result = DefaultInstance ?? new TestEmbedOptimizedForSize(); result = DefaultInstance;
builderIsReadOnly = true; resultIsReadOnly = true;
return this; return this;
} }
public override Builder Clone() { public override Builder Clone() {
if (builderIsReadOnly) { if (resultIsReadOnly) {
return new Builder(result); return new Builder(result);
} else { } else {
return new Builder().MergeFrom(result); return new Builder().MergeFrom(result);
...@@ -249,12 +254,11 @@ namespace Google.ProtocolBuffers.TestProtos { ...@@ -249,12 +254,11 @@ namespace Google.ProtocolBuffers.TestProtos {
} }
public override TestEmbedOptimizedForSize BuildPartial() { public override TestEmbedOptimizedForSize BuildPartial() {
if (builderIsReadOnly) { if (resultIsReadOnly) {
return result; return result;
} }
result.repeatedMessage_.MakeReadOnly(); resultIsReadOnly = true;
builderIsReadOnly = true; return result.MakeReadOnly();
return result;
} }
public override Builder MergeFrom(pb::IMessage other) { public override Builder MergeFrom(pb::IMessage other) {
...@@ -377,7 +381,7 @@ namespace Google.ProtocolBuffers.TestProtos { ...@@ -377,7 +381,7 @@ namespace Google.ProtocolBuffers.TestProtos {
public Builder ClearOptionalMessage() { public Builder ClearOptionalMessage() {
PrepareBuilder(); PrepareBuilder();
result.hasOptionalMessage = false; result.hasOptionalMessage = false;
result.optionalMessage_ = global::Google.ProtocolBuffers.TestProtos.TestOptimizedForSize.DefaultInstance; result.optionalMessage_ = null;
return this; return this;
} }
......
...@@ -43,7 +43,7 @@ namespace Google.ProtocolBuffers.TestProtos { ...@@ -43,7 +43,7 @@ namespace Google.ProtocolBuffers.TestProtos {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("ProtoGen", "2.3.0.277")] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("ProtoGen", "2.3.0.277")]
public sealed partial class ImportMessageLite : pb::GeneratedMessageLite<ImportMessageLite, ImportMessageLite.Builder> { public sealed partial class ImportMessageLite : pb::GeneratedMessageLite<ImportMessageLite, ImportMessageLite.Builder> {
private static readonly ImportMessageLite defaultInstance = new Builder().BuildPartial(); private static readonly ImportMessageLite defaultInstance = new ImportMessageLite().MakeReadOnly();
private static readonly string[] _importMessageLiteFieldNames = new string[] { "d" }; private static readonly string[] _importMessageLiteFieldNames = new string[] { "d" };
private static readonly uint[] _importMessageLiteFieldTags = new uint[] { 8 }; private static readonly uint[] _importMessageLiteFieldTags = new uint[] { 8 };
public static ImportMessageLite DefaultInstance { public static ImportMessageLite DefaultInstance {
...@@ -51,7 +51,7 @@ namespace Google.ProtocolBuffers.TestProtos { ...@@ -51,7 +51,7 @@ namespace Google.ProtocolBuffers.TestProtos {
} }
public override ImportMessageLite DefaultInstanceForType { public override ImportMessageLite DefaultInstanceForType {
get { return defaultInstance; } get { return DefaultInstance; }
} }
protected override ImportMessageLite ThisMessage { protected override ImportMessageLite ThisMessage {
...@@ -146,6 +146,10 @@ namespace Google.ProtocolBuffers.TestProtos { ...@@ -146,6 +146,10 @@ namespace Google.ProtocolBuffers.TestProtos {
public static ImportMessageLite ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { public static ImportMessageLite ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
} }
private ImportMessageLite MakeReadOnly() {
return this;
}
public static Builder CreateBuilder() { return new Builder(); } public static Builder CreateBuilder() { return new Builder(); }
public override Builder ToBuilder() { return CreateBuilder(this); } public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); } public override Builder CreateBuilderForType() { return new Builder(); }
...@@ -161,22 +165,22 @@ namespace Google.ProtocolBuffers.TestProtos { ...@@ -161,22 +165,22 @@ namespace Google.ProtocolBuffers.TestProtos {
get { return this; } get { return this; }
} }
public Builder() { public Builder() {
result = DefaultInstance ?? new ImportMessageLite(); result = DefaultInstance;
builderIsReadOnly = result == DefaultInstance; resultIsReadOnly = true;
} }
internal Builder(ImportMessageLite cloneFrom) { internal Builder(ImportMessageLite cloneFrom) {
result = cloneFrom; result = cloneFrom;
builderIsReadOnly = true; resultIsReadOnly = true;
} }
bool builderIsReadOnly; private bool resultIsReadOnly;
ImportMessageLite result; private ImportMessageLite result;
private ImportMessageLite PrepareBuilder() { private ImportMessageLite PrepareBuilder() {
if (builderIsReadOnly) { if (resultIsReadOnly) {
ImportMessageLite original = result; ImportMessageLite original = result;
result = new ImportMessageLite(); result = new ImportMessageLite();
builderIsReadOnly = false; resultIsReadOnly = false;
MergeFrom(original); MergeFrom(original);
} }
return result; return result;
...@@ -191,13 +195,13 @@ namespace Google.ProtocolBuffers.TestProtos { ...@@ -191,13 +195,13 @@ namespace Google.ProtocolBuffers.TestProtos {
} }
public override Builder Clear() { public override Builder Clear() {
result = DefaultInstance ?? new ImportMessageLite(); result = DefaultInstance;
builderIsReadOnly = true; resultIsReadOnly = true;
return this; return this;
} }
public override Builder Clone() { public override Builder Clone() {
if (builderIsReadOnly) { if (resultIsReadOnly) {
return new Builder(result); return new Builder(result);
} else { } else {
return new Builder().MergeFrom(result); return new Builder().MergeFrom(result);
...@@ -209,11 +213,11 @@ namespace Google.ProtocolBuffers.TestProtos { ...@@ -209,11 +213,11 @@ namespace Google.ProtocolBuffers.TestProtos {
} }
public override ImportMessageLite BuildPartial() { public override ImportMessageLite BuildPartial() {
if (builderIsReadOnly) { if (resultIsReadOnly) {
return result; return result;
} }
builderIsReadOnly = true; resultIsReadOnly = true;
return result; return result.MakeReadOnly();
} }
public override Builder MergeFrom(pb::IMessageLite other) { public override Builder MergeFrom(pb::IMessageLite other) {
......
...@@ -71,7 +71,7 @@ namespace Google.ProtocolBuffers.TestProtos { ...@@ -71,7 +71,7 @@ namespace Google.ProtocolBuffers.TestProtos {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("ProtoGen", "2.3.0.277")] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("ProtoGen", "2.3.0.277")]
public sealed partial class ImportMessage : pb::GeneratedMessage<ImportMessage, ImportMessage.Builder> { public sealed partial class ImportMessage : pb::GeneratedMessage<ImportMessage, ImportMessage.Builder> {
private static readonly ImportMessage defaultInstance = new Builder().BuildPartial(); private static readonly ImportMessage defaultInstance = new ImportMessage().MakeReadOnly();
private static readonly string[] _importMessageFieldNames = new string[] { "d" }; private static readonly string[] _importMessageFieldNames = new string[] { "d" };
private static readonly uint[] _importMessageFieldTags = new uint[] { 8 }; private static readonly uint[] _importMessageFieldTags = new uint[] { 8 };
public static ImportMessage DefaultInstance { public static ImportMessage DefaultInstance {
...@@ -79,7 +79,7 @@ namespace Google.ProtocolBuffers.TestProtos { ...@@ -79,7 +79,7 @@ namespace Google.ProtocolBuffers.TestProtos {
} }
public override ImportMessage DefaultInstanceForType { public override ImportMessage DefaultInstanceForType {
get { return defaultInstance; } get { return DefaultInstance; }
} }
protected override ImportMessage ThisMessage { protected override ImportMessage ThisMessage {
...@@ -165,6 +165,10 @@ namespace Google.ProtocolBuffers.TestProtos { ...@@ -165,6 +165,10 @@ namespace Google.ProtocolBuffers.TestProtos {
public static ImportMessage ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { public static ImportMessage ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
} }
private ImportMessage MakeReadOnly() {
return this;
}
public static Builder CreateBuilder() { return new Builder(); } public static Builder CreateBuilder() { return new Builder(); }
public override Builder ToBuilder() { return CreateBuilder(this); } public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); } public override Builder CreateBuilderForType() { return new Builder(); }
...@@ -180,22 +184,22 @@ namespace Google.ProtocolBuffers.TestProtos { ...@@ -180,22 +184,22 @@ namespace Google.ProtocolBuffers.TestProtos {
get { return this; } get { return this; }
} }
public Builder() { public Builder() {
result = DefaultInstance ?? new ImportMessage(); result = DefaultInstance;
builderIsReadOnly = result == DefaultInstance; resultIsReadOnly = true;
} }
internal Builder(ImportMessage cloneFrom) { internal Builder(ImportMessage cloneFrom) {
result = cloneFrom; result = cloneFrom;
builderIsReadOnly = true; resultIsReadOnly = true;
} }
bool builderIsReadOnly; private bool resultIsReadOnly;
ImportMessage result; private ImportMessage result;
private ImportMessage PrepareBuilder() { private ImportMessage PrepareBuilder() {
if (builderIsReadOnly) { if (resultIsReadOnly) {
ImportMessage original = result; ImportMessage original = result;
result = new ImportMessage(); result = new ImportMessage();
builderIsReadOnly = false; resultIsReadOnly = false;
MergeFrom(original); MergeFrom(original);
} }
return result; return result;
...@@ -210,13 +214,13 @@ namespace Google.ProtocolBuffers.TestProtos { ...@@ -210,13 +214,13 @@ namespace Google.ProtocolBuffers.TestProtos {
} }
public override Builder Clear() { public override Builder Clear() {
result = DefaultInstance ?? new ImportMessage(); result = DefaultInstance;
builderIsReadOnly = true; resultIsReadOnly = true;
return this; return this;
} }
public override Builder Clone() { public override Builder Clone() {
if (builderIsReadOnly) { if (resultIsReadOnly) {
return new Builder(result); return new Builder(result);
} else { } else {
return new Builder().MergeFrom(result); return new Builder().MergeFrom(result);
...@@ -232,11 +236,11 @@ namespace Google.ProtocolBuffers.TestProtos { ...@@ -232,11 +236,11 @@ namespace Google.ProtocolBuffers.TestProtos {
} }
public override ImportMessage BuildPartial() { public override ImportMessage BuildPartial() {
if (builderIsReadOnly) { if (resultIsReadOnly) {
return result; return result;
} }
builderIsReadOnly = true; resultIsReadOnly = true;
return result; return result.MakeReadOnly();
} }
public override Builder MergeFrom(pb::IMessage other) { public override Builder MergeFrom(pb::IMessage other) {
......
...@@ -81,7 +81,7 @@ namespace Google.ProtocolBuffers.TestProtos.NoGenericService { ...@@ -81,7 +81,7 @@ namespace Google.ProtocolBuffers.TestProtos.NoGenericService {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("ProtoGen", "2.3.0.277")] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("ProtoGen", "2.3.0.277")]
public sealed partial class TestMessage : pb::ExtendableMessage<TestMessage, TestMessage.Builder> { public sealed partial class TestMessage : pb::ExtendableMessage<TestMessage, TestMessage.Builder> {
private static readonly TestMessage defaultInstance = new Builder().BuildPartial(); private static readonly TestMessage defaultInstance = new TestMessage().MakeReadOnly();
private static readonly string[] _testMessageFieldNames = new string[] { "a" }; private static readonly string[] _testMessageFieldNames = new string[] { "a" };
private static readonly uint[] _testMessageFieldTags = new uint[] { 8 }; private static readonly uint[] _testMessageFieldTags = new uint[] { 8 };
public static TestMessage DefaultInstance { public static TestMessage DefaultInstance {
...@@ -89,7 +89,7 @@ namespace Google.ProtocolBuffers.TestProtos.NoGenericService { ...@@ -89,7 +89,7 @@ namespace Google.ProtocolBuffers.TestProtos.NoGenericService {
} }
public override TestMessage DefaultInstanceForType { public override TestMessage DefaultInstanceForType {
get { return defaultInstance; } get { return DefaultInstance; }
} }
protected override TestMessage ThisMessage { protected override TestMessage ThisMessage {
...@@ -179,6 +179,10 @@ namespace Google.ProtocolBuffers.TestProtos.NoGenericService { ...@@ -179,6 +179,10 @@ namespace Google.ProtocolBuffers.TestProtos.NoGenericService {
public static TestMessage ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { public static TestMessage ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
} }
private TestMessage MakeReadOnly() {
return this;
}
public static Builder CreateBuilder() { return new Builder(); } public static Builder CreateBuilder() { return new Builder(); }
public override Builder ToBuilder() { return CreateBuilder(this); } public override Builder ToBuilder() { return CreateBuilder(this); }
public override Builder CreateBuilderForType() { return new Builder(); } public override Builder CreateBuilderForType() { return new Builder(); }
...@@ -194,22 +198,22 @@ namespace Google.ProtocolBuffers.TestProtos.NoGenericService { ...@@ -194,22 +198,22 @@ namespace Google.ProtocolBuffers.TestProtos.NoGenericService {
get { return this; } get { return this; }
} }
public Builder() { public Builder() {
result = DefaultInstance ?? new TestMessage(); result = DefaultInstance;
builderIsReadOnly = result == DefaultInstance; resultIsReadOnly = true;
} }
internal Builder(TestMessage cloneFrom) { internal Builder(TestMessage cloneFrom) {
result = cloneFrom; result = cloneFrom;
builderIsReadOnly = true; resultIsReadOnly = true;
} }
bool builderIsReadOnly; private bool resultIsReadOnly;
TestMessage result; private TestMessage result;
private TestMessage PrepareBuilder() { private TestMessage PrepareBuilder() {
if (builderIsReadOnly) { if (resultIsReadOnly) {
TestMessage original = result; TestMessage original = result;
result = new TestMessage(); result = new TestMessage();
builderIsReadOnly = false; resultIsReadOnly = false;
MergeFrom(original); MergeFrom(original);
} }
return result; return result;
...@@ -224,13 +228,13 @@ namespace Google.ProtocolBuffers.TestProtos.NoGenericService { ...@@ -224,13 +228,13 @@ namespace Google.ProtocolBuffers.TestProtos.NoGenericService {
} }
public override Builder Clear() { public override Builder Clear() {
result = DefaultInstance ?? new TestMessage(); result = DefaultInstance;
builderIsReadOnly = true; resultIsReadOnly = true;
return this; return this;
} }
public override Builder Clone() { public override Builder Clone() {
if (builderIsReadOnly) { if (resultIsReadOnly) {
return new Builder(result); return new Builder(result);
} else { } else {
return new Builder().MergeFrom(result); return new Builder().MergeFrom(result);
...@@ -246,11 +250,11 @@ namespace Google.ProtocolBuffers.TestProtos.NoGenericService { ...@@ -246,11 +250,11 @@ namespace Google.ProtocolBuffers.TestProtos.NoGenericService {
} }
public override TestMessage BuildPartial() { public override TestMessage BuildPartial() {
if (builderIsReadOnly) { if (resultIsReadOnly) {
return result; return result;
} }
builderIsReadOnly = true; resultIsReadOnly = true;
return result; return result.MakeReadOnly();
} }
public override Builder MergeFrom(pb::IMessage other) { public override Builder MergeFrom(pb::IMessage other) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment