Commit bfee2dfe authored by Jon Skeet's avatar Jon Skeet

Implement freezing for messages and repeated fields.

Fixes issue #523.
parent 94071b54
...@@ -76,6 +76,9 @@ namespace Google.ProtocolBuffers.Examples.AddressBook { ...@@ -76,6 +76,9 @@ namespace Google.ProtocolBuffers.Examples.AddressBook {
get { return global::Google.ProtocolBuffers.Examples.AddressBook.Addressbook.internal__static_tutorial_Person__FieldAccessorTable; } get { return global::Google.ProtocolBuffers.Examples.AddressBook.Addressbook.internal__static_tutorial_Person__FieldAccessorTable; }
} }
private bool _frozen = false;
public bool IsFrozen { get { return _frozen; } }
public Person() { } public Person() { }
public Person(Person other) { public Person(Person other) {
...@@ -89,30 +92,44 @@ namespace Google.ProtocolBuffers.Examples.AddressBook { ...@@ -89,30 +92,44 @@ namespace Google.ProtocolBuffers.Examples.AddressBook {
return new Person(this); return new Person(this);
} }
public void Freeze() {
if (IsFrozen) {
return;
}
_frozen = true;
phone_.Freeze();
}
public const int NameFieldNumber = 1; public const int NameFieldNumber = 1;
private string name_ = ""; private string name_ = "";
public string Name { public string Name {
get { return name_; } get { return name_; }
set { name_ = value ?? ""; } set {
pb::Freezable.CheckMutable(this);
name_ = value ?? "";
}
} }
public const int IdFieldNumber = 2; public const int IdFieldNumber = 2;
private int id_; private int id_;
public int Id { public int Id {
get { return id_; } get { return id_; }
set { id_ = value; } set {
pb::Freezable.CheckMutable(this);
id_ = value;
}
} }
public const int EmailFieldNumber = 3; public const int EmailFieldNumber = 3;
private string email_ = ""; private string email_ = "";
public string Email { public string Email {
get { return email_; } get { return email_; }
set { email_ = value ?? ""; } set {
pb::Freezable.CheckMutable(this);
email_ = value ?? "";
}
} }
public const int PhoneFieldNumber = 4; public const int PhoneFieldNumber = 4;
private readonly pbc::RepeatedField<global::Google.ProtocolBuffers.Examples.AddressBook.Person.Types.PhoneNumber> phone_ = new pbc::RepeatedField<global::Google.ProtocolBuffers.Examples.AddressBook.Person.Types.PhoneNumber>(); private readonly pbc::RepeatedField<global::Google.ProtocolBuffers.Examples.AddressBook.Person.Types.PhoneNumber> phone_ = new pbc::RepeatedField<global::Google.ProtocolBuffers.Examples.AddressBook.Person.Types.PhoneNumber>();
public pbc::RepeatedField<global::Google.ProtocolBuffers.Examples.AddressBook.Person.Types.PhoneNumber> Phone { public pbc::RepeatedField<global::Google.ProtocolBuffers.Examples.AddressBook.Person.Types.PhoneNumber> Phone {
...@@ -254,6 +271,9 @@ namespace Google.ProtocolBuffers.Examples.AddressBook { ...@@ -254,6 +271,9 @@ namespace Google.ProtocolBuffers.Examples.AddressBook {
get { return global::Google.ProtocolBuffers.Examples.AddressBook.Addressbook.internal__static_tutorial_Person_PhoneNumber__FieldAccessorTable; } get { return global::Google.ProtocolBuffers.Examples.AddressBook.Addressbook.internal__static_tutorial_Person_PhoneNumber__FieldAccessorTable; }
} }
private bool _frozen = false;
public bool IsFrozen { get { return _frozen; } }
public PhoneNumber() { } public PhoneNumber() { }
public PhoneNumber(PhoneNumber other) { public PhoneNumber(PhoneNumber other) {
...@@ -265,22 +285,33 @@ namespace Google.ProtocolBuffers.Examples.AddressBook { ...@@ -265,22 +285,33 @@ namespace Google.ProtocolBuffers.Examples.AddressBook {
return new PhoneNumber(this); return new PhoneNumber(this);
} }
public void Freeze() {
if (IsFrozen) {
return;
}
_frozen = true;
}
public const int NumberFieldNumber = 1; public const int NumberFieldNumber = 1;
private string number_ = ""; private string number_ = "";
public string Number { public string Number {
get { return number_; } get { return number_; }
set { number_ = value ?? ""; } set {
pb::Freezable.CheckMutable(this);
number_ = value ?? "";
}
} }
public const int TypeFieldNumber = 2; public const int TypeFieldNumber = 2;
private global::Google.ProtocolBuffers.Examples.AddressBook.Person.Types.PhoneType type_ = global::Google.ProtocolBuffers.Examples.AddressBook.Person.Types.PhoneType.HOME; private global::Google.ProtocolBuffers.Examples.AddressBook.Person.Types.PhoneType type_ = global::Google.ProtocolBuffers.Examples.AddressBook.Person.Types.PhoneType.HOME;
public global::Google.ProtocolBuffers.Examples.AddressBook.Person.Types.PhoneType Type { public global::Google.ProtocolBuffers.Examples.AddressBook.Person.Types.PhoneType Type {
get { return type_; } get { return type_; }
set { type_ = value; } set {
pb::Freezable.CheckMutable(this);
type_ = value;
}
} }
public override bool Equals(object other) { public override bool Equals(object other) {
return Equals(other as PhoneNumber); return Equals(other as PhoneNumber);
} }
...@@ -382,6 +413,9 @@ namespace Google.ProtocolBuffers.Examples.AddressBook { ...@@ -382,6 +413,9 @@ namespace Google.ProtocolBuffers.Examples.AddressBook {
get { return global::Google.ProtocolBuffers.Examples.AddressBook.Addressbook.internal__static_tutorial_AddressBook__FieldAccessorTable; } get { return global::Google.ProtocolBuffers.Examples.AddressBook.Addressbook.internal__static_tutorial_AddressBook__FieldAccessorTable; }
} }
private bool _frozen = false;
public bool IsFrozen { get { return _frozen; } }
public AddressBook() { } public AddressBook() { }
public AddressBook(AddressBook other) { public AddressBook(AddressBook other) {
...@@ -392,6 +426,14 @@ namespace Google.ProtocolBuffers.Examples.AddressBook { ...@@ -392,6 +426,14 @@ namespace Google.ProtocolBuffers.Examples.AddressBook {
return new AddressBook(this); return new AddressBook(this);
} }
public void Freeze() {
if (IsFrozen) {
return;
}
_frozen = true;
person_.Freeze();
}
public const int PersonFieldNumber = 1; public const int PersonFieldNumber = 1;
private readonly pbc::RepeatedField<global::Google.ProtocolBuffers.Examples.AddressBook.Person> person_ = new pbc::RepeatedField<global::Google.ProtocolBuffers.Examples.AddressBook.Person>(); private readonly pbc::RepeatedField<global::Google.ProtocolBuffers.Examples.AddressBook.Person> person_ = new pbc::RepeatedField<global::Google.ProtocolBuffers.Examples.AddressBook.Person>();
public pbc::RepeatedField<global::Google.ProtocolBuffers.Examples.AddressBook.Person> Person { public pbc::RepeatedField<global::Google.ProtocolBuffers.Examples.AddressBook.Person> Person {
......
using Google.Protobuf.TestProtos; using System;
using Google.Protobuf.TestProtos;
using NUnit.Framework; using NUnit.Framework;
namespace Google.Protobuf namespace Google.Protobuf
...@@ -257,5 +258,22 @@ namespace Google.Protobuf ...@@ -257,5 +258,22 @@ namespace Google.Protobuf
original.OneofNestedMessage.Bb = 30; original.OneofNestedMessage.Bb = 30;
Assert.AreNotEqual(original, clone); Assert.AreNotEqual(original, clone);
} }
[Test]
public void Freeze()
{
var frozen = new TestAllTypes();
frozen.Freeze();
Assert.IsTrue(frozen.IsFrozen);
Assert.Throws<InvalidOperationException>(() => frozen.ClearOneofField());
Assert.Throws<InvalidOperationException>(() => frozen.SingleInt32 = 0);
Assert.Throws<InvalidOperationException>(() => frozen.SingleNestedMessage = null);
Assert.Throws<InvalidOperationException>(() => frozen.SingleNestedEnum = 0);
Assert.Throws<InvalidOperationException>(() => frozen.OneofString = null);
Assert.Throws<InvalidOperationException>(() => frozen.OneofUint32 = 0U);
Assert.Throws<InvalidOperationException>(() => frozen.RepeatedDouble.Add(0.0));
Assert.Throws<InvalidOperationException>(() => frozen.RepeatedNestedMessage.Add(new TestAllTypes.Types.NestedMessage()));
}
} }
} }
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using Google.Protobuf.Collections; using Google.Protobuf.Collections;
using Google.Protobuf.TestProtos;
using NUnit.Framework; using NUnit.Framework;
namespace Google.Protobuf namespace Google.Protobuf
...@@ -11,8 +12,8 @@ namespace Google.Protobuf ...@@ -11,8 +12,8 @@ namespace Google.Protobuf
public void NullValuesRejected() public void NullValuesRejected()
{ {
var list = new RepeatedField<string>(); var list = new RepeatedField<string>();
Assert.Throws<ArgumentNullException>(() => list.Add((string) null)); Assert.Throws<ArgumentNullException>(() => list.Add((string)null));
Assert.Throws<ArgumentNullException>(() => list.Add((IEnumerable<string>) null)); Assert.Throws<ArgumentNullException>(() => list.Add((IEnumerable<string>)null));
Assert.Throws<ArgumentNullException>(() => list.Add((RepeatedField<string>)null)); Assert.Throws<ArgumentNullException>(() => list.Add((RepeatedField<string>)null));
Assert.Throws<ArgumentNullException>(() => list.Contains(null)); Assert.Throws<ArgumentNullException>(() => list.Contains(null));
Assert.Throws<ArgumentNullException>(() => list.IndexOf(null)); Assert.Throws<ArgumentNullException>(() => list.IndexOf(null));
...@@ -47,5 +48,47 @@ namespace Google.Protobuf ...@@ -47,5 +48,47 @@ namespace Google.Protobuf
Assert.AreEqual("foo", list[1]); Assert.AreEqual("foo", list[1]);
Assert.AreEqual("bar", list[2]); Assert.AreEqual("bar", list[2]);
} }
[Test]
public void Freeze_FreezesElements()
{
var list = new RepeatedField<TestAllTypes> { new TestAllTypes() };
Assert.IsFalse(list[0].IsFrozen);
list.Freeze();
Assert.IsTrue(list[0].IsFrozen);
}
[Test]
public void Freeze_PreventsMutations()
{
var list = new RepeatedField<int> { 0 };
list.Freeze();
Assert.Throws<InvalidOperationException>(() => list.Add(1));
Assert.Throws<InvalidOperationException>(() => list[0] = 1);
Assert.Throws<InvalidOperationException>(() => list.Clear());
Assert.Throws<InvalidOperationException>(() => list.RemoveAt(0));
Assert.Throws<InvalidOperationException>(() => list.Remove(0));
Assert.Throws<InvalidOperationException>(() => list.Insert(0, 0));
}
[Test]
public void Freeze_ReportsFrozen()
{
var list = new RepeatedField<int> { 0 };
Assert.IsFalse(list.IsFrozen);
Assert.IsFalse(list.IsReadOnly);
list.Freeze();
Assert.IsTrue(list.IsFrozen);
Assert.IsTrue(list.IsReadOnly);
}
[Test]
public void Clone_ReturnsMutable()
{
var list = new RepeatedField<int> { 0 };
list.Freeze();
var clone = list.Clone();
clone[0] = 1;
}
} }
} }
...@@ -74,6 +74,9 @@ namespace Google.Protobuf.TestProtos { ...@@ -74,6 +74,9 @@ namespace Google.Protobuf.TestProtos {
get { return global::Google.Protobuf.TestProtos.UnittestImportProto3.internal__static_protobuf_unittest_import_ImportMessage__FieldAccessorTable; } get { return global::Google.Protobuf.TestProtos.UnittestImportProto3.internal__static_protobuf_unittest_import_ImportMessage__FieldAccessorTable; }
} }
private bool _frozen = false;
public bool IsFrozen { get { return _frozen; } }
public ImportMessage() { } public ImportMessage() { }
public ImportMessage(ImportMessage other) { public ImportMessage(ImportMessage other) {
...@@ -84,14 +87,23 @@ namespace Google.Protobuf.TestProtos { ...@@ -84,14 +87,23 @@ namespace Google.Protobuf.TestProtos {
return new ImportMessage(this); return new ImportMessage(this);
} }
public void Freeze() {
if (IsFrozen) {
return;
}
_frozen = true;
}
public const int DFieldNumber = 1; public const int DFieldNumber = 1;
private int d_; private int d_;
public int D { public int D {
get { return d_; } get { return d_; }
set { d_ = value; } set {
pb::Freezable.CheckMutable(this);
d_ = value;
}
} }
public override bool Equals(object other) { public override bool Equals(object other) {
return Equals(other as ImportMessage); return Equals(other as ImportMessage);
} }
......
...@@ -59,6 +59,9 @@ namespace Google.Protobuf.TestProtos { ...@@ -59,6 +59,9 @@ namespace Google.Protobuf.TestProtos {
get { return global::Google.Protobuf.TestProtos.UnittestImportPublicProto3.internal__static_protobuf_unittest_import_PublicImportMessage__FieldAccessorTable; } get { return global::Google.Protobuf.TestProtos.UnittestImportPublicProto3.internal__static_protobuf_unittest_import_PublicImportMessage__FieldAccessorTable; }
} }
private bool _frozen = false;
public bool IsFrozen { get { return _frozen; } }
public PublicImportMessage() { } public PublicImportMessage() { }
public PublicImportMessage(PublicImportMessage other) { public PublicImportMessage(PublicImportMessage other) {
...@@ -69,14 +72,23 @@ namespace Google.Protobuf.TestProtos { ...@@ -69,14 +72,23 @@ namespace Google.Protobuf.TestProtos {
return new PublicImportMessage(this); return new PublicImportMessage(this);
} }
public void Freeze() {
if (IsFrozen) {
return;
}
_frozen = true;
}
public const int EFieldNumber = 1; public const int EFieldNumber = 1;
private int e_; private int e_;
public int E { public int E {
get { return e_; } get { return e_; }
set { e_ = value; } set {
pb::Freezable.CheckMutable(this);
e_ = value;
}
} }
public override bool Equals(object other) { public override bool Equals(object other) {
return Equals(other as PublicImportMessage); return Equals(other as PublicImportMessage);
} }
......
...@@ -104,6 +104,9 @@ namespace UnitTest.Issues.TestProtos { ...@@ -104,6 +104,9 @@ namespace UnitTest.Issues.TestProtos {
get { return global::UnitTest.Issues.TestProtos.UnittestIssues.internal__static_unittest_issues_NegativeEnumMessage__FieldAccessorTable; } get { return global::UnitTest.Issues.TestProtos.UnittestIssues.internal__static_unittest_issues_NegativeEnumMessage__FieldAccessorTable; }
} }
private bool _frozen = false;
public bool IsFrozen { get { return _frozen; } }
public NegativeEnumMessage() { } public NegativeEnumMessage() { }
public NegativeEnumMessage(NegativeEnumMessage other) { public NegativeEnumMessage(NegativeEnumMessage other) {
...@@ -116,14 +119,25 @@ namespace UnitTest.Issues.TestProtos { ...@@ -116,14 +119,25 @@ namespace UnitTest.Issues.TestProtos {
return new NegativeEnumMessage(this); return new NegativeEnumMessage(this);
} }
public void Freeze() {
if (IsFrozen) {
return;
}
_frozen = true;
values_.Freeze();
packedValues_.Freeze();
}
public const int ValueFieldNumber = 1; public const int ValueFieldNumber = 1;
private global::UnitTest.Issues.TestProtos.NegativeEnum value_ = global::UnitTest.Issues.TestProtos.NegativeEnum.NEGATIVE_ENUM_ZERO; private global::UnitTest.Issues.TestProtos.NegativeEnum value_ = global::UnitTest.Issues.TestProtos.NegativeEnum.NEGATIVE_ENUM_ZERO;
public global::UnitTest.Issues.TestProtos.NegativeEnum Value { public global::UnitTest.Issues.TestProtos.NegativeEnum Value {
get { return value_; } get { return value_; }
set { value_ = value; } set {
pb::Freezable.CheckMutable(this);
value_ = value;
}
} }
public const int ValuesFieldNumber = 2; public const int ValuesFieldNumber = 2;
private readonly pbc::RepeatedField<global::UnitTest.Issues.TestProtos.NegativeEnum> values_ = new pbc::RepeatedField<global::UnitTest.Issues.TestProtos.NegativeEnum>(); private readonly pbc::RepeatedField<global::UnitTest.Issues.TestProtos.NegativeEnum> values_ = new pbc::RepeatedField<global::UnitTest.Issues.TestProtos.NegativeEnum>();
public pbc::RepeatedField<global::UnitTest.Issues.TestProtos.NegativeEnum> Values { public pbc::RepeatedField<global::UnitTest.Issues.TestProtos.NegativeEnum> Values {
...@@ -255,6 +269,9 @@ namespace UnitTest.Issues.TestProtos { ...@@ -255,6 +269,9 @@ namespace UnitTest.Issues.TestProtos {
get { return global::UnitTest.Issues.TestProtos.UnittestIssues.internal__static_unittest_issues_DeprecatedChild__FieldAccessorTable; } get { return global::UnitTest.Issues.TestProtos.UnittestIssues.internal__static_unittest_issues_DeprecatedChild__FieldAccessorTable; }
} }
private bool _frozen = false;
public bool IsFrozen { get { return _frozen; } }
public DeprecatedChild() { } public DeprecatedChild() { }
public DeprecatedChild(DeprecatedChild other) { public DeprecatedChild(DeprecatedChild other) {
...@@ -264,6 +281,13 @@ namespace UnitTest.Issues.TestProtos { ...@@ -264,6 +281,13 @@ namespace UnitTest.Issues.TestProtos {
return new DeprecatedChild(this); return new DeprecatedChild(this);
} }
public void Freeze() {
if (IsFrozen) {
return;
}
_frozen = true;
}
public override bool Equals(object other) { public override bool Equals(object other) {
return Equals(other as DeprecatedChild); return Equals(other as DeprecatedChild);
} }
...@@ -328,6 +352,9 @@ namespace UnitTest.Issues.TestProtos { ...@@ -328,6 +352,9 @@ namespace UnitTest.Issues.TestProtos {
get { return global::UnitTest.Issues.TestProtos.UnittestIssues.internal__static_unittest_issues_DeprecatedFieldsMessage__FieldAccessorTable; } get { return global::UnitTest.Issues.TestProtos.UnittestIssues.internal__static_unittest_issues_DeprecatedFieldsMessage__FieldAccessorTable; }
} }
private bool _frozen = false;
public bool IsFrozen { get { return _frozen; } }
public DeprecatedFieldsMessage() { } public DeprecatedFieldsMessage() { }
public DeprecatedFieldsMessage(DeprecatedFieldsMessage other) { public DeprecatedFieldsMessage(DeprecatedFieldsMessage other) {
...@@ -343,15 +370,28 @@ namespace UnitTest.Issues.TestProtos { ...@@ -343,15 +370,28 @@ namespace UnitTest.Issues.TestProtos {
return new DeprecatedFieldsMessage(this); return new DeprecatedFieldsMessage(this);
} }
public void Freeze() {
if (IsFrozen) {
return;
}
_frozen = true;
primitiveArray_.Freeze();
if (messageValue_ != null) MessageValue.Freeze();
messageArray_.Freeze();
enumArray_.Freeze();
}
public const int PrimitiveValueFieldNumber = 1; public const int PrimitiveValueFieldNumber = 1;
private int primitiveValue_; private int primitiveValue_;
[global::System.ObsoleteAttribute()] [global::System.ObsoleteAttribute()]
public int PrimitiveValue { public int PrimitiveValue {
get { return primitiveValue_; } get { return primitiveValue_; }
set { primitiveValue_ = value; } set {
pb::Freezable.CheckMutable(this);
primitiveValue_ = value;
}
} }
public const int PrimitiveArrayFieldNumber = 2; public const int PrimitiveArrayFieldNumber = 2;
private readonly pbc::RepeatedField<int> primitiveArray_ = new pbc::RepeatedField<int>(); private readonly pbc::RepeatedField<int> primitiveArray_ = new pbc::RepeatedField<int>();
[global::System.ObsoleteAttribute()] [global::System.ObsoleteAttribute()]
...@@ -364,7 +404,10 @@ namespace UnitTest.Issues.TestProtos { ...@@ -364,7 +404,10 @@ namespace UnitTest.Issues.TestProtos {
[global::System.ObsoleteAttribute()] [global::System.ObsoleteAttribute()]
public global::UnitTest.Issues.TestProtos.DeprecatedChild MessageValue { public global::UnitTest.Issues.TestProtos.DeprecatedChild MessageValue {
get { return messageValue_; } get { return messageValue_; }
set { messageValue_ = value; } set {
pb::Freezable.CheckMutable(this);
messageValue_ = value;
}
} }
public const int MessageArrayFieldNumber = 4; public const int MessageArrayFieldNumber = 4;
...@@ -379,10 +422,12 @@ namespace UnitTest.Issues.TestProtos { ...@@ -379,10 +422,12 @@ namespace UnitTest.Issues.TestProtos {
[global::System.ObsoleteAttribute()] [global::System.ObsoleteAttribute()]
public global::UnitTest.Issues.TestProtos.DeprecatedEnum EnumValue { public global::UnitTest.Issues.TestProtos.DeprecatedEnum EnumValue {
get { return enumValue_; } get { return enumValue_; }
set { enumValue_ = value; } set {
pb::Freezable.CheckMutable(this);
enumValue_ = value;
}
} }
public const int EnumArrayFieldNumber = 6; public const int EnumArrayFieldNumber = 6;
private readonly pbc::RepeatedField<global::UnitTest.Issues.TestProtos.DeprecatedEnum> enumArray_ = new pbc::RepeatedField<global::UnitTest.Issues.TestProtos.DeprecatedEnum>(); private readonly pbc::RepeatedField<global::UnitTest.Issues.TestProtos.DeprecatedEnum> enumArray_ = new pbc::RepeatedField<global::UnitTest.Issues.TestProtos.DeprecatedEnum>();
[global::System.ObsoleteAttribute()] [global::System.ObsoleteAttribute()]
...@@ -403,7 +448,8 @@ namespace UnitTest.Issues.TestProtos { ...@@ -403,7 +448,8 @@ namespace UnitTest.Issues.TestProtos {
} }
if (PrimitiveValue != other.PrimitiveValue) return false; if (PrimitiveValue != other.PrimitiveValue) return false;
if(!primitiveArray_.Equals(other.primitiveArray_)) return false; if(!primitiveArray_.Equals(other.primitiveArray_)) return false;
if (!object.Equals(MessageValue, other.MessageValue)) return false;if(!messageArray_.Equals(other.messageArray_)) return false; if (!object.Equals(MessageValue, other.MessageValue)) return false;
if(!messageArray_.Equals(other.messageArray_)) return false;
if (EnumValue != other.EnumValue) return false; if (EnumValue != other.EnumValue) return false;
if(!enumArray_.Equals(other.enumArray_)) return false; if(!enumArray_.Equals(other.enumArray_)) return false;
return true; return true;
...@@ -563,6 +609,9 @@ namespace UnitTest.Issues.TestProtos { ...@@ -563,6 +609,9 @@ namespace UnitTest.Issues.TestProtos {
get { return global::UnitTest.Issues.TestProtos.UnittestIssues.internal__static_unittest_issues_ItemField__FieldAccessorTable; } get { return global::UnitTest.Issues.TestProtos.UnittestIssues.internal__static_unittest_issues_ItemField__FieldAccessorTable; }
} }
private bool _frozen = false;
public bool IsFrozen { get { return _frozen; } }
public ItemField() { } public ItemField() { }
public ItemField(ItemField other) { public ItemField(ItemField other) {
...@@ -573,14 +622,23 @@ namespace UnitTest.Issues.TestProtos { ...@@ -573,14 +622,23 @@ namespace UnitTest.Issues.TestProtos {
return new ItemField(this); return new ItemField(this);
} }
public void Freeze() {
if (IsFrozen) {
return;
}
_frozen = true;
}
public const int ItemFieldNumber = 1; public const int ItemFieldNumber = 1;
private int item_; private int item_;
public int Item { public int Item {
get { return item_; } get { return item_; }
set { item_ = value; } set {
pb::Freezable.CheckMutable(this);
item_ = value;
}
} }
public override bool Equals(object other) { public override bool Equals(object other) {
return Equals(other as ItemField); return Equals(other as ItemField);
} }
......
...@@ -416,6 +416,9 @@ namespace Google.Protobuf.TestProtos { ...@@ -416,6 +416,9 @@ namespace Google.Protobuf.TestProtos {
get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestAllTypes__FieldAccessorTable; } get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestAllTypes__FieldAccessorTable; }
} }
private bool _frozen = false;
public bool IsFrozen { get { return _frozen; } }
public TestAllTypes() { } public TestAllTypes() { }
public TestAllTypes(TestAllTypes other) { public TestAllTypes(TestAllTypes other) {
...@@ -484,176 +487,258 @@ namespace Google.Protobuf.TestProtos { ...@@ -484,176 +487,258 @@ namespace Google.Protobuf.TestProtos {
return new TestAllTypes(this); return new TestAllTypes(this);
} }
public void Freeze() {
if (IsFrozen) {
return;
}
_frozen = true;
if (singleNestedMessage_ != null) SingleNestedMessage.Freeze();
if (singleForeignMessage_ != null) SingleForeignMessage.Freeze();
if (singleImportMessage_ != null) SingleImportMessage.Freeze();
if (singlePublicImportMessage_ != null) SinglePublicImportMessage.Freeze();
repeatedInt32_.Freeze();
repeatedInt64_.Freeze();
repeatedUint32_.Freeze();
repeatedUint64_.Freeze();
repeatedSint32_.Freeze();
repeatedSint64_.Freeze();
repeatedFixed32_.Freeze();
repeatedFixed64_.Freeze();
repeatedSfixed32_.Freeze();
repeatedSfixed64_.Freeze();
repeatedFloat_.Freeze();
repeatedDouble_.Freeze();
repeatedBool_.Freeze();
repeatedString_.Freeze();
repeatedBytes_.Freeze();
repeatedNestedMessage_.Freeze();
repeatedForeignMessage_.Freeze();
repeatedImportMessage_.Freeze();
repeatedNestedEnum_.Freeze();
repeatedForeignEnum_.Freeze();
repeatedImportEnum_.Freeze();
repeatedPublicImportMessage_.Freeze();
if (oneofField_ is IFreezable) ((IFreezable) oneofField_).Freeze();
}
public const int SingleInt32FieldNumber = 1; public const int SingleInt32FieldNumber = 1;
private int singleInt32_; private int singleInt32_;
public int SingleInt32 { public int SingleInt32 {
get { return singleInt32_; } get { return singleInt32_; }
set { singleInt32_ = value; } set {
pb::Freezable.CheckMutable(this);
singleInt32_ = value;
}
} }
public const int SingleInt64FieldNumber = 2; public const int SingleInt64FieldNumber = 2;
private long singleInt64_; private long singleInt64_;
public long SingleInt64 { public long SingleInt64 {
get { return singleInt64_; } get { return singleInt64_; }
set { singleInt64_ = value; } set {
pb::Freezable.CheckMutable(this);
singleInt64_ = value;
}
} }
public const int SingleUint32FieldNumber = 3; public const int SingleUint32FieldNumber = 3;
private uint singleUint32_; private uint singleUint32_;
public uint SingleUint32 { public uint SingleUint32 {
get { return singleUint32_; } get { return singleUint32_; }
set { singleUint32_ = value; } set {
pb::Freezable.CheckMutable(this);
singleUint32_ = value;
}
} }
public const int SingleUint64FieldNumber = 4; public const int SingleUint64FieldNumber = 4;
private ulong singleUint64_; private ulong singleUint64_;
public ulong SingleUint64 { public ulong SingleUint64 {
get { return singleUint64_; } get { return singleUint64_; }
set { singleUint64_ = value; } set {
pb::Freezable.CheckMutable(this);
singleUint64_ = value;
}
} }
public const int SingleSint32FieldNumber = 5; public const int SingleSint32FieldNumber = 5;
private int singleSint32_; private int singleSint32_;
public int SingleSint32 { public int SingleSint32 {
get { return singleSint32_; } get { return singleSint32_; }
set { singleSint32_ = value; } set {
pb::Freezable.CheckMutable(this);
singleSint32_ = value;
}
} }
public const int SingleSint64FieldNumber = 6; public const int SingleSint64FieldNumber = 6;
private long singleSint64_; private long singleSint64_;
public long SingleSint64 { public long SingleSint64 {
get { return singleSint64_; } get { return singleSint64_; }
set { singleSint64_ = value; } set {
pb::Freezable.CheckMutable(this);
singleSint64_ = value;
}
} }
public const int SingleFixed32FieldNumber = 7; public const int SingleFixed32FieldNumber = 7;
private uint singleFixed32_; private uint singleFixed32_;
public uint SingleFixed32 { public uint SingleFixed32 {
get { return singleFixed32_; } get { return singleFixed32_; }
set { singleFixed32_ = value; } set {
pb::Freezable.CheckMutable(this);
singleFixed32_ = value;
}
} }
public const int SingleFixed64FieldNumber = 8; public const int SingleFixed64FieldNumber = 8;
private ulong singleFixed64_; private ulong singleFixed64_;
public ulong SingleFixed64 { public ulong SingleFixed64 {
get { return singleFixed64_; } get { return singleFixed64_; }
set { singleFixed64_ = value; } set {
pb::Freezable.CheckMutable(this);
singleFixed64_ = value;
}
} }
public const int SingleSfixed32FieldNumber = 9; public const int SingleSfixed32FieldNumber = 9;
private int singleSfixed32_; private int singleSfixed32_;
public int SingleSfixed32 { public int SingleSfixed32 {
get { return singleSfixed32_; } get { return singleSfixed32_; }
set { singleSfixed32_ = value; } set {
pb::Freezable.CheckMutable(this);
singleSfixed32_ = value;
}
} }
public const int SingleSfixed64FieldNumber = 10; public const int SingleSfixed64FieldNumber = 10;
private long singleSfixed64_; private long singleSfixed64_;
public long SingleSfixed64 { public long SingleSfixed64 {
get { return singleSfixed64_; } get { return singleSfixed64_; }
set { singleSfixed64_ = value; } set {
pb::Freezable.CheckMutable(this);
singleSfixed64_ = value;
}
} }
public const int SingleFloatFieldNumber = 11; public const int SingleFloatFieldNumber = 11;
private float singleFloat_; private float singleFloat_;
public float SingleFloat { public float SingleFloat {
get { return singleFloat_; } get { return singleFloat_; }
set { singleFloat_ = value; } set {
pb::Freezable.CheckMutable(this);
singleFloat_ = value;
}
} }
public const int SingleDoubleFieldNumber = 12; public const int SingleDoubleFieldNumber = 12;
private double singleDouble_; private double singleDouble_;
public double SingleDouble { public double SingleDouble {
get { return singleDouble_; } get { return singleDouble_; }
set { singleDouble_ = value; } set {
pb::Freezable.CheckMutable(this);
singleDouble_ = value;
}
} }
public const int SingleBoolFieldNumber = 13; public const int SingleBoolFieldNumber = 13;
private bool singleBool_; private bool singleBool_;
public bool SingleBool { public bool SingleBool {
get { return singleBool_; } get { return singleBool_; }
set { singleBool_ = value; } set {
pb::Freezable.CheckMutable(this);
singleBool_ = value;
}
} }
public const int SingleStringFieldNumber = 14; public const int SingleStringFieldNumber = 14;
private string singleString_ = ""; private string singleString_ = "";
public string SingleString { public string SingleString {
get { return singleString_; } get { return singleString_; }
set { singleString_ = value ?? ""; } set {
pb::Freezable.CheckMutable(this);
singleString_ = value ?? "";
}
} }
public const int SingleBytesFieldNumber = 15; public const int SingleBytesFieldNumber = 15;
private pb::ByteString singleBytes_ = pb::ByteString.Empty; private pb::ByteString singleBytes_ = pb::ByteString.Empty;
public pb::ByteString SingleBytes { public pb::ByteString SingleBytes {
get { return singleBytes_; } get { return singleBytes_; }
set { singleBytes_ = value ?? pb::ByteString.Empty; } set {
pb::Freezable.CheckMutable(this);
singleBytes_ = value ?? pb::ByteString.Empty;
}
} }
public const int SingleNestedMessageFieldNumber = 18; public const int SingleNestedMessageFieldNumber = 18;
private global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedMessage singleNestedMessage_; private global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedMessage singleNestedMessage_;
public global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedMessage SingleNestedMessage { public global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedMessage SingleNestedMessage {
get { return singleNestedMessage_; } get { return singleNestedMessage_; }
set { singleNestedMessage_ = value; } set {
pb::Freezable.CheckMutable(this);
singleNestedMessage_ = value;
}
} }
public const int SingleForeignMessageFieldNumber = 19; public const int SingleForeignMessageFieldNumber = 19;
private global::Google.Protobuf.TestProtos.ForeignMessage singleForeignMessage_; private global::Google.Protobuf.TestProtos.ForeignMessage singleForeignMessage_;
public global::Google.Protobuf.TestProtos.ForeignMessage SingleForeignMessage { public global::Google.Protobuf.TestProtos.ForeignMessage SingleForeignMessage {
get { return singleForeignMessage_; } get { return singleForeignMessage_; }
set { singleForeignMessage_ = value; } set {
pb::Freezable.CheckMutable(this);
singleForeignMessage_ = value;
}
} }
public const int SingleImportMessageFieldNumber = 20; public const int SingleImportMessageFieldNumber = 20;
private global::Google.Protobuf.TestProtos.ImportMessage singleImportMessage_; private global::Google.Protobuf.TestProtos.ImportMessage singleImportMessage_;
public global::Google.Protobuf.TestProtos.ImportMessage SingleImportMessage { public global::Google.Protobuf.TestProtos.ImportMessage SingleImportMessage {
get { return singleImportMessage_; } get { return singleImportMessage_; }
set { singleImportMessage_ = value; } set {
pb::Freezable.CheckMutable(this);
singleImportMessage_ = value;
}
} }
public const int SingleNestedEnumFieldNumber = 21; public const int SingleNestedEnumFieldNumber = 21;
private global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedEnum singleNestedEnum_ = global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedEnum.NESTED_ENUM_UNSPECIFIED; private global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedEnum singleNestedEnum_ = global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedEnum.NESTED_ENUM_UNSPECIFIED;
public global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedEnum SingleNestedEnum { public global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedEnum SingleNestedEnum {
get { return singleNestedEnum_; } get { return singleNestedEnum_; }
set { singleNestedEnum_ = value; } set {
pb::Freezable.CheckMutable(this);
singleNestedEnum_ = value;
}
} }
public const int SingleForeignEnumFieldNumber = 22; public const int SingleForeignEnumFieldNumber = 22;
private global::Google.Protobuf.TestProtos.ForeignEnum singleForeignEnum_ = global::Google.Protobuf.TestProtos.ForeignEnum.FOREIGN_UNSPECIFIED; private global::Google.Protobuf.TestProtos.ForeignEnum singleForeignEnum_ = global::Google.Protobuf.TestProtos.ForeignEnum.FOREIGN_UNSPECIFIED;
public global::Google.Protobuf.TestProtos.ForeignEnum SingleForeignEnum { public global::Google.Protobuf.TestProtos.ForeignEnum SingleForeignEnum {
get { return singleForeignEnum_; } get { return singleForeignEnum_; }
set { singleForeignEnum_ = value; } set {
pb::Freezable.CheckMutable(this);
singleForeignEnum_ = value;
}
} }
public const int SingleImportEnumFieldNumber = 23; public const int SingleImportEnumFieldNumber = 23;
private global::Google.Protobuf.TestProtos.ImportEnum singleImportEnum_ = global::Google.Protobuf.TestProtos.ImportEnum.IMPORT_ENUM_UNSPECIFIED; private global::Google.Protobuf.TestProtos.ImportEnum singleImportEnum_ = global::Google.Protobuf.TestProtos.ImportEnum.IMPORT_ENUM_UNSPECIFIED;
public global::Google.Protobuf.TestProtos.ImportEnum SingleImportEnum { public global::Google.Protobuf.TestProtos.ImportEnum SingleImportEnum {
get { return singleImportEnum_; } get { return singleImportEnum_; }
set { singleImportEnum_ = value; } set {
pb::Freezable.CheckMutable(this);
singleImportEnum_ = value;
}
} }
public const int SinglePublicImportMessageFieldNumber = 26; public const int SinglePublicImportMessageFieldNumber = 26;
private global::Google.Protobuf.TestProtos.PublicImportMessage singlePublicImportMessage_; private global::Google.Protobuf.TestProtos.PublicImportMessage singlePublicImportMessage_;
public global::Google.Protobuf.TestProtos.PublicImportMessage SinglePublicImportMessage { public global::Google.Protobuf.TestProtos.PublicImportMessage SinglePublicImportMessage {
get { return singlePublicImportMessage_; } get { return singlePublicImportMessage_; }
set { singlePublicImportMessage_ = value; } set {
pb::Freezable.CheckMutable(this);
singlePublicImportMessage_ = value;
}
} }
public const int RepeatedInt32FieldNumber = 31; public const int RepeatedInt32FieldNumber = 31;
...@@ -792,6 +877,7 @@ namespace Google.Protobuf.TestProtos { ...@@ -792,6 +877,7 @@ namespace Google.Protobuf.TestProtos {
public uint OneofUint32 { public uint OneofUint32 {
get { return oneofFieldCase_ == OneofFieldOneofCase.OneofUint32 ? (uint) oneofField_ : 0; } get { return oneofFieldCase_ == OneofFieldOneofCase.OneofUint32 ? (uint) oneofField_ : 0; }
set { set {
pb::Freezable.CheckMutable(this);
oneofField_ = value; oneofField_ = value;
oneofFieldCase_ = OneofFieldOneofCase.OneofUint32; oneofFieldCase_ = OneofFieldOneofCase.OneofUint32;
} }
...@@ -801,6 +887,7 @@ namespace Google.Protobuf.TestProtos { ...@@ -801,6 +887,7 @@ namespace Google.Protobuf.TestProtos {
public global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedMessage OneofNestedMessage { public global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedMessage OneofNestedMessage {
get { return oneofFieldCase_ == OneofFieldOneofCase.OneofNestedMessage ? (global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedMessage) oneofField_ : null; } get { return oneofFieldCase_ == OneofFieldOneofCase.OneofNestedMessage ? (global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedMessage) oneofField_ : null; }
set { set {
pb::Freezable.CheckMutable(this);
oneofField_ = value; oneofField_ = value;
oneofFieldCase_ = value == null ? OneofFieldOneofCase.None : OneofFieldOneofCase.OneofNestedMessage; oneofFieldCase_ = value == null ? OneofFieldOneofCase.None : OneofFieldOneofCase.OneofNestedMessage;
} }
...@@ -810,6 +897,7 @@ namespace Google.Protobuf.TestProtos { ...@@ -810,6 +897,7 @@ namespace Google.Protobuf.TestProtos {
public string OneofString { public string OneofString {
get { return oneofFieldCase_ == OneofFieldOneofCase.OneofString ? (string) oneofField_ : ""; } get { return oneofFieldCase_ == OneofFieldOneofCase.OneofString ? (string) oneofField_ : ""; }
set { set {
pb::Freezable.CheckMutable(this);
oneofField_ = value ?? ""; oneofField_ = value ?? "";
oneofFieldCase_ = OneofFieldOneofCase.OneofString; oneofFieldCase_ = OneofFieldOneofCase.OneofString;
} }
...@@ -819,6 +907,7 @@ namespace Google.Protobuf.TestProtos { ...@@ -819,6 +907,7 @@ namespace Google.Protobuf.TestProtos {
public pb::ByteString OneofBytes { public pb::ByteString OneofBytes {
get { return oneofFieldCase_ == OneofFieldOneofCase.OneofBytes ? (pb::ByteString) oneofField_ : pb::ByteString.Empty; } get { return oneofFieldCase_ == OneofFieldOneofCase.OneofBytes ? (pb::ByteString) oneofField_ : pb::ByteString.Empty; }
set { set {
pb::Freezable.CheckMutable(this);
oneofField_ = value ?? pb::ByteString.Empty; oneofField_ = value ?? pb::ByteString.Empty;
oneofFieldCase_ = OneofFieldOneofCase.OneofBytes; oneofFieldCase_ = OneofFieldOneofCase.OneofBytes;
} }
...@@ -838,6 +927,7 @@ namespace Google.Protobuf.TestProtos { ...@@ -838,6 +927,7 @@ namespace Google.Protobuf.TestProtos {
} }
public void ClearOneofField() { public void ClearOneofField() {
pb::Freezable.CheckMutable(this);
oneofFieldCase_ = OneofFieldOneofCase.None; oneofFieldCase_ = OneofFieldOneofCase.None;
oneofField_ = null; oneofField_ = null;
} }
...@@ -868,10 +958,14 @@ namespace Google.Protobuf.TestProtos { ...@@ -868,10 +958,14 @@ namespace Google.Protobuf.TestProtos {
if (SingleBool != other.SingleBool) return false; if (SingleBool != other.SingleBool) return false;
if (SingleString != other.SingleString) return false; if (SingleString != other.SingleString) return false;
if (SingleBytes != other.SingleBytes) return false; if (SingleBytes != other.SingleBytes) return false;
if (!object.Equals(SingleNestedMessage, other.SingleNestedMessage)) return false;if (!object.Equals(SingleForeignMessage, other.SingleForeignMessage)) return false;if (!object.Equals(SingleImportMessage, other.SingleImportMessage)) return false;if (SingleNestedEnum != other.SingleNestedEnum) return false; if (!object.Equals(SingleNestedMessage, other.SingleNestedMessage)) return false;
if (!object.Equals(SingleForeignMessage, other.SingleForeignMessage)) return false;
if (!object.Equals(SingleImportMessage, other.SingleImportMessage)) return false;
if (SingleNestedEnum != other.SingleNestedEnum) return false;
if (SingleForeignEnum != other.SingleForeignEnum) return false; if (SingleForeignEnum != other.SingleForeignEnum) return false;
if (SingleImportEnum != other.SingleImportEnum) return false; if (SingleImportEnum != other.SingleImportEnum) return false;
if (!object.Equals(SinglePublicImportMessage, other.SinglePublicImportMessage)) return false;if(!repeatedInt32_.Equals(other.repeatedInt32_)) return false; if (!object.Equals(SinglePublicImportMessage, other.SinglePublicImportMessage)) return false;
if(!repeatedInt32_.Equals(other.repeatedInt32_)) return false;
if(!repeatedInt64_.Equals(other.repeatedInt64_)) return false; if(!repeatedInt64_.Equals(other.repeatedInt64_)) return false;
if(!repeatedUint32_.Equals(other.repeatedUint32_)) return false; if(!repeatedUint32_.Equals(other.repeatedUint32_)) return false;
if(!repeatedUint64_.Equals(other.repeatedUint64_)) return false; if(!repeatedUint64_.Equals(other.repeatedUint64_)) return false;
...@@ -894,7 +988,8 @@ namespace Google.Protobuf.TestProtos { ...@@ -894,7 +988,8 @@ namespace Google.Protobuf.TestProtos {
if(!repeatedImportEnum_.Equals(other.repeatedImportEnum_)) return false; if(!repeatedImportEnum_.Equals(other.repeatedImportEnum_)) return false;
if(!repeatedPublicImportMessage_.Equals(other.repeatedPublicImportMessage_)) return false; if(!repeatedPublicImportMessage_.Equals(other.repeatedPublicImportMessage_)) return false;
if (OneofUint32 != other.OneofUint32) return false; if (OneofUint32 != other.OneofUint32) return false;
if (!object.Equals(OneofNestedMessage, other.OneofNestedMessage)) return false;if (OneofString != other.OneofString) return false; if (!object.Equals(OneofNestedMessage, other.OneofNestedMessage)) return false;
if (OneofString != other.OneofString) return false;
if (OneofBytes != other.OneofBytes) return false; if (OneofBytes != other.OneofBytes) return false;
return true; return true;
} }
...@@ -1764,6 +1859,9 @@ namespace Google.Protobuf.TestProtos { ...@@ -1764,6 +1859,9 @@ namespace Google.Protobuf.TestProtos {
get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestAllTypes_NestedMessage__FieldAccessorTable; } get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestAllTypes_NestedMessage__FieldAccessorTable; }
} }
private bool _frozen = false;
public bool IsFrozen { get { return _frozen; } }
public NestedMessage() { } public NestedMessage() { }
public NestedMessage(NestedMessage other) { public NestedMessage(NestedMessage other) {
...@@ -1774,14 +1872,23 @@ namespace Google.Protobuf.TestProtos { ...@@ -1774,14 +1872,23 @@ namespace Google.Protobuf.TestProtos {
return new NestedMessage(this); return new NestedMessage(this);
} }
public void Freeze() {
if (IsFrozen) {
return;
}
_frozen = true;
}
public const int BbFieldNumber = 1; public const int BbFieldNumber = 1;
private int bb_; private int bb_;
public int Bb { public int Bb {
get { return bb_; } get { return bb_; }
set { bb_ = value; } set {
pb::Freezable.CheckMutable(this);
bb_ = value;
}
} }
public override bool Equals(object other) { public override bool Equals(object other) {
return Equals(other as NestedMessage); return Equals(other as NestedMessage);
} }
...@@ -1867,6 +1974,9 @@ namespace Google.Protobuf.TestProtos { ...@@ -1867,6 +1974,9 @@ namespace Google.Protobuf.TestProtos {
get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_NestedTestAllTypes__FieldAccessorTable; } get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_NestedTestAllTypes__FieldAccessorTable; }
} }
private bool _frozen = false;
public bool IsFrozen { get { return _frozen; } }
public NestedTestAllTypes() { } public NestedTestAllTypes() { }
public NestedTestAllTypes(NestedTestAllTypes other) { public NestedTestAllTypes(NestedTestAllTypes other) {
...@@ -1879,18 +1989,34 @@ namespace Google.Protobuf.TestProtos { ...@@ -1879,18 +1989,34 @@ namespace Google.Protobuf.TestProtos {
return new NestedTestAllTypes(this); return new NestedTestAllTypes(this);
} }
public void Freeze() {
if (IsFrozen) {
return;
}
_frozen = true;
if (child_ != null) Child.Freeze();
if (payload_ != null) Payload.Freeze();
repeatedChild_.Freeze();
}
public const int ChildFieldNumber = 1; public const int ChildFieldNumber = 1;
private global::Google.Protobuf.TestProtos.NestedTestAllTypes child_; private global::Google.Protobuf.TestProtos.NestedTestAllTypes child_;
public global::Google.Protobuf.TestProtos.NestedTestAllTypes Child { public global::Google.Protobuf.TestProtos.NestedTestAllTypes Child {
get { return child_; } get { return child_; }
set { child_ = value; } set {
pb::Freezable.CheckMutable(this);
child_ = value;
}
} }
public const int PayloadFieldNumber = 2; public const int PayloadFieldNumber = 2;
private global::Google.Protobuf.TestProtos.TestAllTypes payload_; private global::Google.Protobuf.TestProtos.TestAllTypes payload_;
public global::Google.Protobuf.TestProtos.TestAllTypes Payload { public global::Google.Protobuf.TestProtos.TestAllTypes Payload {
get { return payload_; } get { return payload_; }
set { payload_ = value; } set {
pb::Freezable.CheckMutable(this);
payload_ = value;
}
} }
public const int RepeatedChildFieldNumber = 3; public const int RepeatedChildFieldNumber = 3;
...@@ -1910,7 +2036,9 @@ namespace Google.Protobuf.TestProtos { ...@@ -1910,7 +2036,9 @@ namespace Google.Protobuf.TestProtos {
if (ReferenceEquals(other, this)) { if (ReferenceEquals(other, this)) {
return true; return true;
} }
if (!object.Equals(Child, other.Child)) return false;if (!object.Equals(Payload, other.Payload)) return false;if(!repeatedChild_.Equals(other.repeatedChild_)) return false; if (!object.Equals(Child, other.Child)) return false;
if (!object.Equals(Payload, other.Payload)) return false;
if(!repeatedChild_.Equals(other.repeatedChild_)) return false;
return true; return true;
} }
...@@ -2021,6 +2149,9 @@ namespace Google.Protobuf.TestProtos { ...@@ -2021,6 +2149,9 @@ namespace Google.Protobuf.TestProtos {
get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestDeprecatedFields__FieldAccessorTable; } get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestDeprecatedFields__FieldAccessorTable; }
} }
private bool _frozen = false;
public bool IsFrozen { get { return _frozen; } }
public TestDeprecatedFields() { } public TestDeprecatedFields() { }
public TestDeprecatedFields(TestDeprecatedFields other) { public TestDeprecatedFields(TestDeprecatedFields other) {
...@@ -2031,15 +2162,24 @@ namespace Google.Protobuf.TestProtos { ...@@ -2031,15 +2162,24 @@ namespace Google.Protobuf.TestProtos {
return new TestDeprecatedFields(this); return new TestDeprecatedFields(this);
} }
public void Freeze() {
if (IsFrozen) {
return;
}
_frozen = true;
}
public const int DeprecatedInt32FieldNumber = 1; public const int DeprecatedInt32FieldNumber = 1;
private int deprecatedInt32_; private int deprecatedInt32_;
[global::System.ObsoleteAttribute()] [global::System.ObsoleteAttribute()]
public int DeprecatedInt32 { public int DeprecatedInt32 {
get { return deprecatedInt32_; } get { return deprecatedInt32_; }
set { deprecatedInt32_ = value; } set {
pb::Freezable.CheckMutable(this);
deprecatedInt32_ = value;
}
} }
public override bool Equals(object other) { public override bool Equals(object other) {
return Equals(other as TestDeprecatedFields); return Equals(other as TestDeprecatedFields);
} }
...@@ -2120,6 +2260,9 @@ namespace Google.Protobuf.TestProtos { ...@@ -2120,6 +2260,9 @@ namespace Google.Protobuf.TestProtos {
get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_ForeignMessage__FieldAccessorTable; } get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_ForeignMessage__FieldAccessorTable; }
} }
private bool _frozen = false;
public bool IsFrozen { get { return _frozen; } }
public ForeignMessage() { } public ForeignMessage() { }
public ForeignMessage(ForeignMessage other) { public ForeignMessage(ForeignMessage other) {
...@@ -2130,14 +2273,23 @@ namespace Google.Protobuf.TestProtos { ...@@ -2130,14 +2273,23 @@ namespace Google.Protobuf.TestProtos {
return new ForeignMessage(this); return new ForeignMessage(this);
} }
public void Freeze() {
if (IsFrozen) {
return;
}
_frozen = true;
}
public const int CFieldNumber = 1; public const int CFieldNumber = 1;
private int c_; private int c_;
public int C { public int C {
get { return c_; } get { return c_; }
set { c_ = value; } set {
pb::Freezable.CheckMutable(this);
c_ = value;
}
} }
public override bool Equals(object other) { public override bool Equals(object other) {
return Equals(other as ForeignMessage); return Equals(other as ForeignMessage);
} }
...@@ -2218,6 +2370,9 @@ namespace Google.Protobuf.TestProtos { ...@@ -2218,6 +2370,9 @@ namespace Google.Protobuf.TestProtos {
get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestReservedFields__FieldAccessorTable; } get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestReservedFields__FieldAccessorTable; }
} }
private bool _frozen = false;
public bool IsFrozen { get { return _frozen; } }
public TestReservedFields() { } public TestReservedFields() { }
public TestReservedFields(TestReservedFields other) { public TestReservedFields(TestReservedFields other) {
...@@ -2227,6 +2382,13 @@ namespace Google.Protobuf.TestProtos { ...@@ -2227,6 +2382,13 @@ namespace Google.Protobuf.TestProtos {
return new TestReservedFields(this); return new TestReservedFields(this);
} }
public void Freeze() {
if (IsFrozen) {
return;
}
_frozen = true;
}
public override bool Equals(object other) { public override bool Equals(object other) {
return Equals(other as TestReservedFields); return Equals(other as TestReservedFields);
} }
...@@ -2291,6 +2453,9 @@ namespace Google.Protobuf.TestProtos { ...@@ -2291,6 +2453,9 @@ namespace Google.Protobuf.TestProtos {
get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestForeignNested__FieldAccessorTable; } get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestForeignNested__FieldAccessorTable; }
} }
private bool _frozen = false;
public bool IsFrozen { get { return _frozen; } }
public TestForeignNested() { } public TestForeignNested() { }
public TestForeignNested(TestForeignNested other) { public TestForeignNested(TestForeignNested other) {
...@@ -2301,11 +2466,22 @@ namespace Google.Protobuf.TestProtos { ...@@ -2301,11 +2466,22 @@ namespace Google.Protobuf.TestProtos {
return new TestForeignNested(this); return new TestForeignNested(this);
} }
public void Freeze() {
if (IsFrozen) {
return;
}
_frozen = true;
if (foreignNested_ != null) ForeignNested.Freeze();
}
public const int ForeignNestedFieldNumber = 1; public const int ForeignNestedFieldNumber = 1;
private global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedMessage foreignNested_; private global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedMessage foreignNested_;
public global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedMessage ForeignNested { public global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedMessage ForeignNested {
get { return foreignNested_; } get { return foreignNested_; }
set { foreignNested_ = value; } set {
pb::Freezable.CheckMutable(this);
foreignNested_ = value;
}
} }
public override bool Equals(object other) { public override bool Equals(object other) {
...@@ -2319,7 +2495,8 @@ namespace Google.Protobuf.TestProtos { ...@@ -2319,7 +2495,8 @@ namespace Google.Protobuf.TestProtos {
if (ReferenceEquals(other, this)) { if (ReferenceEquals(other, this)) {
return true; return true;
} }
if (!object.Equals(ForeignNested, other.ForeignNested)) return false; return true; if (!object.Equals(ForeignNested, other.ForeignNested)) return false;
return true;
} }
public override int GetHashCode() { public override int GetHashCode() {
...@@ -2393,6 +2570,9 @@ namespace Google.Protobuf.TestProtos { ...@@ -2393,6 +2570,9 @@ namespace Google.Protobuf.TestProtos {
get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestReallyLargeTagNumber__FieldAccessorTable; } get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestReallyLargeTagNumber__FieldAccessorTable; }
} }
private bool _frozen = false;
public bool IsFrozen { get { return _frozen; } }
public TestReallyLargeTagNumber() { } public TestReallyLargeTagNumber() { }
public TestReallyLargeTagNumber(TestReallyLargeTagNumber other) { public TestReallyLargeTagNumber(TestReallyLargeTagNumber other) {
...@@ -2404,22 +2584,33 @@ namespace Google.Protobuf.TestProtos { ...@@ -2404,22 +2584,33 @@ namespace Google.Protobuf.TestProtos {
return new TestReallyLargeTagNumber(this); return new TestReallyLargeTagNumber(this);
} }
public void Freeze() {
if (IsFrozen) {
return;
}
_frozen = true;
}
public const int AFieldNumber = 1; public const int AFieldNumber = 1;
private int a_; private int a_;
public int A { public int A {
get { return a_; } get { return a_; }
set { a_ = value; } set {
pb::Freezable.CheckMutable(this);
a_ = value;
}
} }
public const int BbFieldNumber = 268435455; public const int BbFieldNumber = 268435455;
private int bb_; private int bb_;
public int Bb { public int Bb {
get { return bb_; } get { return bb_; }
set { bb_ = value; } set {
pb::Freezable.CheckMutable(this);
bb_ = value;
}
} }
public override bool Equals(object other) { public override bool Equals(object other) {
return Equals(other as TestReallyLargeTagNumber); return Equals(other as TestReallyLargeTagNumber);
} }
...@@ -2516,6 +2707,9 @@ namespace Google.Protobuf.TestProtos { ...@@ -2516,6 +2707,9 @@ namespace Google.Protobuf.TestProtos {
get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestRecursiveMessage__FieldAccessorTable; } get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestRecursiveMessage__FieldAccessorTable; }
} }
private bool _frozen = false;
public bool IsFrozen { get { return _frozen; } }
public TestRecursiveMessage() { } public TestRecursiveMessage() { }
public TestRecursiveMessage(TestRecursiveMessage other) { public TestRecursiveMessage(TestRecursiveMessage other) {
...@@ -2527,21 +2721,34 @@ namespace Google.Protobuf.TestProtos { ...@@ -2527,21 +2721,34 @@ namespace Google.Protobuf.TestProtos {
return new TestRecursiveMessage(this); return new TestRecursiveMessage(this);
} }
public void Freeze() {
if (IsFrozen) {
return;
}
_frozen = true;
if (a_ != null) A.Freeze();
}
public const int AFieldNumber = 1; public const int AFieldNumber = 1;
private global::Google.Protobuf.TestProtos.TestRecursiveMessage a_; private global::Google.Protobuf.TestProtos.TestRecursiveMessage a_;
public global::Google.Protobuf.TestProtos.TestRecursiveMessage A { public global::Google.Protobuf.TestProtos.TestRecursiveMessage A {
get { return a_; } get { return a_; }
set { a_ = value; } set {
pb::Freezable.CheckMutable(this);
a_ = value;
}
} }
public const int IFieldNumber = 2; public const int IFieldNumber = 2;
private int i_; private int i_;
public int I { public int I {
get { return i_; } get { return i_; }
set { i_ = value; } set {
pb::Freezable.CheckMutable(this);
i_ = value;
}
} }
public override bool Equals(object other) { public override bool Equals(object other) {
return Equals(other as TestRecursiveMessage); return Equals(other as TestRecursiveMessage);
} }
...@@ -2553,7 +2760,8 @@ namespace Google.Protobuf.TestProtos { ...@@ -2553,7 +2760,8 @@ namespace Google.Protobuf.TestProtos {
if (ReferenceEquals(other, this)) { if (ReferenceEquals(other, this)) {
return true; return true;
} }
if (!object.Equals(A, other.A)) return false;if (I != other.I) return false; if (!object.Equals(A, other.A)) return false;
if (I != other.I) return false;
return true; return true;
} }
...@@ -2643,6 +2851,9 @@ namespace Google.Protobuf.TestProtos { ...@@ -2643,6 +2851,9 @@ namespace Google.Protobuf.TestProtos {
get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestMutualRecursionA__FieldAccessorTable; } get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestMutualRecursionA__FieldAccessorTable; }
} }
private bool _frozen = false;
public bool IsFrozen { get { return _frozen; } }
public TestMutualRecursionA() { } public TestMutualRecursionA() { }
public TestMutualRecursionA(TestMutualRecursionA other) { public TestMutualRecursionA(TestMutualRecursionA other) {
...@@ -2653,11 +2864,22 @@ namespace Google.Protobuf.TestProtos { ...@@ -2653,11 +2864,22 @@ namespace Google.Protobuf.TestProtos {
return new TestMutualRecursionA(this); return new TestMutualRecursionA(this);
} }
public void Freeze() {
if (IsFrozen) {
return;
}
_frozen = true;
if (bb_ != null) Bb.Freeze();
}
public const int BbFieldNumber = 1; public const int BbFieldNumber = 1;
private global::Google.Protobuf.TestProtos.TestMutualRecursionB bb_; private global::Google.Protobuf.TestProtos.TestMutualRecursionB bb_;
public global::Google.Protobuf.TestProtos.TestMutualRecursionB Bb { public global::Google.Protobuf.TestProtos.TestMutualRecursionB Bb {
get { return bb_; } get { return bb_; }
set { bb_ = value; } set {
pb::Freezable.CheckMutable(this);
bb_ = value;
}
} }
public override bool Equals(object other) { public override bool Equals(object other) {
...@@ -2671,7 +2893,8 @@ namespace Google.Protobuf.TestProtos { ...@@ -2671,7 +2893,8 @@ namespace Google.Protobuf.TestProtos {
if (ReferenceEquals(other, this)) { if (ReferenceEquals(other, this)) {
return true; return true;
} }
if (!object.Equals(Bb, other.Bb)) return false; return true; if (!object.Equals(Bb, other.Bb)) return false;
return true;
} }
public override int GetHashCode() { public override int GetHashCode() {
...@@ -2745,6 +2968,9 @@ namespace Google.Protobuf.TestProtos { ...@@ -2745,6 +2968,9 @@ namespace Google.Protobuf.TestProtos {
get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestMutualRecursionB__FieldAccessorTable; } get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestMutualRecursionB__FieldAccessorTable; }
} }
private bool _frozen = false;
public bool IsFrozen { get { return _frozen; } }
public TestMutualRecursionB() { } public TestMutualRecursionB() { }
public TestMutualRecursionB(TestMutualRecursionB other) { public TestMutualRecursionB(TestMutualRecursionB other) {
...@@ -2756,21 +2982,34 @@ namespace Google.Protobuf.TestProtos { ...@@ -2756,21 +2982,34 @@ namespace Google.Protobuf.TestProtos {
return new TestMutualRecursionB(this); return new TestMutualRecursionB(this);
} }
public void Freeze() {
if (IsFrozen) {
return;
}
_frozen = true;
if (a_ != null) A.Freeze();
}
public const int AFieldNumber = 1; public const int AFieldNumber = 1;
private global::Google.Protobuf.TestProtos.TestMutualRecursionA a_; private global::Google.Protobuf.TestProtos.TestMutualRecursionA a_;
public global::Google.Protobuf.TestProtos.TestMutualRecursionA A { public global::Google.Protobuf.TestProtos.TestMutualRecursionA A {
get { return a_; } get { return a_; }
set { a_ = value; } set {
pb::Freezable.CheckMutable(this);
a_ = value;
}
} }
public const int OptionalInt32FieldNumber = 2; public const int OptionalInt32FieldNumber = 2;
private int optionalInt32_; private int optionalInt32_;
public int OptionalInt32 { public int OptionalInt32 {
get { return optionalInt32_; } get { return optionalInt32_; }
set { optionalInt32_ = value; } set {
pb::Freezable.CheckMutable(this);
optionalInt32_ = value;
}
} }
public override bool Equals(object other) { public override bool Equals(object other) {
return Equals(other as TestMutualRecursionB); return Equals(other as TestMutualRecursionB);
} }
...@@ -2782,7 +3021,8 @@ namespace Google.Protobuf.TestProtos { ...@@ -2782,7 +3021,8 @@ namespace Google.Protobuf.TestProtos {
if (ReferenceEquals(other, this)) { if (ReferenceEquals(other, this)) {
return true; return true;
} }
if (!object.Equals(A, other.A)) return false;if (OptionalInt32 != other.OptionalInt32) return false; if (!object.Equals(A, other.A)) return false;
if (OptionalInt32 != other.OptionalInt32) return false;
return true; return true;
} }
...@@ -2872,6 +3112,9 @@ namespace Google.Protobuf.TestProtos { ...@@ -2872,6 +3112,9 @@ namespace Google.Protobuf.TestProtos {
get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestCamelCaseFieldNames__FieldAccessorTable; } get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestCamelCaseFieldNames__FieldAccessorTable; }
} }
private bool _frozen = false;
public bool IsFrozen { get { return _frozen; } }
public TestCamelCaseFieldNames() { } public TestCamelCaseFieldNames() { }
public TestCamelCaseFieldNames(TestCamelCaseFieldNames other) { public TestCamelCaseFieldNames(TestCamelCaseFieldNames other) {
...@@ -2889,35 +3132,56 @@ namespace Google.Protobuf.TestProtos { ...@@ -2889,35 +3132,56 @@ namespace Google.Protobuf.TestProtos {
return new TestCamelCaseFieldNames(this); return new TestCamelCaseFieldNames(this);
} }
public void Freeze() {
if (IsFrozen) {
return;
}
_frozen = true;
if (messageField_ != null) MessageField.Freeze();
repeatedPrimitiveField_.Freeze();
repeatedStringField_.Freeze();
repeatedEnumField_.Freeze();
repeatedMessageField_.Freeze();
}
public const int PrimitiveFieldFieldNumber = 1; public const int PrimitiveFieldFieldNumber = 1;
private int primitiveField_; private int primitiveField_;
public int PrimitiveField { public int PrimitiveField {
get { return primitiveField_; } get { return primitiveField_; }
set { primitiveField_ = value; } set {
pb::Freezable.CheckMutable(this);
primitiveField_ = value;
}
} }
public const int StringFieldFieldNumber = 2; public const int StringFieldFieldNumber = 2;
private string stringField_ = ""; private string stringField_ = "";
public string StringField { public string StringField {
get { return stringField_; } get { return stringField_; }
set { stringField_ = value ?? ""; } set {
pb::Freezable.CheckMutable(this);
stringField_ = value ?? "";
}
} }
public const int EnumFieldFieldNumber = 3; public const int EnumFieldFieldNumber = 3;
private global::Google.Protobuf.TestProtos.ForeignEnum enumField_ = global::Google.Protobuf.TestProtos.ForeignEnum.FOREIGN_UNSPECIFIED; private global::Google.Protobuf.TestProtos.ForeignEnum enumField_ = global::Google.Protobuf.TestProtos.ForeignEnum.FOREIGN_UNSPECIFIED;
public global::Google.Protobuf.TestProtos.ForeignEnum EnumField { public global::Google.Protobuf.TestProtos.ForeignEnum EnumField {
get { return enumField_; } get { return enumField_; }
set { enumField_ = value; } set {
pb::Freezable.CheckMutable(this);
enumField_ = value;
}
} }
public const int MessageFieldFieldNumber = 4; public const int MessageFieldFieldNumber = 4;
private global::Google.Protobuf.TestProtos.ForeignMessage messageField_; private global::Google.Protobuf.TestProtos.ForeignMessage messageField_;
public global::Google.Protobuf.TestProtos.ForeignMessage MessageField { public global::Google.Protobuf.TestProtos.ForeignMessage MessageField {
get { return messageField_; } get { return messageField_; }
set { messageField_ = value; } set {
pb::Freezable.CheckMutable(this);
messageField_ = value;
}
} }
public const int RepeatedPrimitiveFieldFieldNumber = 7; public const int RepeatedPrimitiveFieldFieldNumber = 7;
...@@ -2958,7 +3222,8 @@ namespace Google.Protobuf.TestProtos { ...@@ -2958,7 +3222,8 @@ namespace Google.Protobuf.TestProtos {
if (PrimitiveField != other.PrimitiveField) return false; if (PrimitiveField != other.PrimitiveField) return false;
if (StringField != other.StringField) return false; if (StringField != other.StringField) return false;
if (EnumField != other.EnumField) return false; if (EnumField != other.EnumField) return false;
if (!object.Equals(MessageField, other.MessageField)) return false;if(!repeatedPrimitiveField_.Equals(other.repeatedPrimitiveField_)) return false; if (!object.Equals(MessageField, other.MessageField)) return false;
if(!repeatedPrimitiveField_.Equals(other.repeatedPrimitiveField_)) return false;
if(!repeatedStringField_.Equals(other.repeatedStringField_)) return false; if(!repeatedStringField_.Equals(other.repeatedStringField_)) return false;
if(!repeatedEnumField_.Equals(other.repeatedEnumField_)) return false; if(!repeatedEnumField_.Equals(other.repeatedEnumField_)) return false;
if(!repeatedMessageField_.Equals(other.repeatedMessageField_)) return false; if(!repeatedMessageField_.Equals(other.repeatedMessageField_)) return false;
...@@ -3151,6 +3416,9 @@ namespace Google.Protobuf.TestProtos { ...@@ -3151,6 +3416,9 @@ namespace Google.Protobuf.TestProtos {
get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestFieldOrderings__FieldAccessorTable; } get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestFieldOrderings__FieldAccessorTable; }
} }
private bool _frozen = false;
public bool IsFrozen { get { return _frozen; } }
public TestFieldOrderings() { } public TestFieldOrderings() { }
public TestFieldOrderings(TestFieldOrderings other) { public TestFieldOrderings(TestFieldOrderings other) {
...@@ -3164,35 +3432,52 @@ namespace Google.Protobuf.TestProtos { ...@@ -3164,35 +3432,52 @@ namespace Google.Protobuf.TestProtos {
return new TestFieldOrderings(this); return new TestFieldOrderings(this);
} }
public void Freeze() {
if (IsFrozen) {
return;
}
_frozen = true;
if (singleNestedMessage_ != null) SingleNestedMessage.Freeze();
}
public const int MyStringFieldNumber = 11; public const int MyStringFieldNumber = 11;
private string myString_ = ""; private string myString_ = "";
public string MyString { public string MyString {
get { return myString_; } get { return myString_; }
set { myString_ = value ?? ""; } set {
pb::Freezable.CheckMutable(this);
myString_ = value ?? "";
}
} }
public const int MyIntFieldNumber = 1; public const int MyIntFieldNumber = 1;
private long myInt_; private long myInt_;
public long MyInt { public long MyInt {
get { return myInt_; } get { return myInt_; }
set { myInt_ = value; } set {
pb::Freezable.CheckMutable(this);
myInt_ = value;
}
} }
public const int MyFloatFieldNumber = 101; public const int MyFloatFieldNumber = 101;
private float myFloat_; private float myFloat_;
public float MyFloat { public float MyFloat {
get { return myFloat_; } get { return myFloat_; }
set { myFloat_ = value; } set {
pb::Freezable.CheckMutable(this);
myFloat_ = value;
}
} }
public const int SingleNestedMessageFieldNumber = 200; public const int SingleNestedMessageFieldNumber = 200;
private global::Google.Protobuf.TestProtos.TestFieldOrderings.Types.NestedMessage singleNestedMessage_; private global::Google.Protobuf.TestProtos.TestFieldOrderings.Types.NestedMessage singleNestedMessage_;
public global::Google.Protobuf.TestProtos.TestFieldOrderings.Types.NestedMessage SingleNestedMessage { public global::Google.Protobuf.TestProtos.TestFieldOrderings.Types.NestedMessage SingleNestedMessage {
get { return singleNestedMessage_; } get { return singleNestedMessage_; }
set { singleNestedMessage_ = value; } set {
pb::Freezable.CheckMutable(this);
singleNestedMessage_ = value;
}
} }
public override bool Equals(object other) { public override bool Equals(object other) {
...@@ -3209,7 +3494,8 @@ namespace Google.Protobuf.TestProtos { ...@@ -3209,7 +3494,8 @@ namespace Google.Protobuf.TestProtos {
if (MyString != other.MyString) return false; if (MyString != other.MyString) return false;
if (MyInt != other.MyInt) return false; if (MyInt != other.MyInt) return false;
if (MyFloat != other.MyFloat) return false; if (MyFloat != other.MyFloat) return false;
if (!object.Equals(SingleNestedMessage, other.SingleNestedMessage)) return false; return true; if (!object.Equals(SingleNestedMessage, other.SingleNestedMessage)) return false;
return true;
} }
public override int GetHashCode() { public override int GetHashCode() {
...@@ -3329,6 +3615,9 @@ namespace Google.Protobuf.TestProtos { ...@@ -3329,6 +3615,9 @@ namespace Google.Protobuf.TestProtos {
get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestFieldOrderings_NestedMessage__FieldAccessorTable; } get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestFieldOrderings_NestedMessage__FieldAccessorTable; }
} }
private bool _frozen = false;
public bool IsFrozen { get { return _frozen; } }
public NestedMessage() { } public NestedMessage() { }
public NestedMessage(NestedMessage other) { public NestedMessage(NestedMessage other) {
...@@ -3340,22 +3629,33 @@ namespace Google.Protobuf.TestProtos { ...@@ -3340,22 +3629,33 @@ namespace Google.Protobuf.TestProtos {
return new NestedMessage(this); return new NestedMessage(this);
} }
public void Freeze() {
if (IsFrozen) {
return;
}
_frozen = true;
}
public const int OoFieldNumber = 2; public const int OoFieldNumber = 2;
private long oo_; private long oo_;
public long Oo { public long Oo {
get { return oo_; } get { return oo_; }
set { oo_ = value; } set {
pb::Freezable.CheckMutable(this);
oo_ = value;
}
} }
public const int BbFieldNumber = 1; public const int BbFieldNumber = 1;
private int bb_; private int bb_;
public int Bb { public int Bb {
get { return bb_; } get { return bb_; }
set { bb_ = value; } set {
pb::Freezable.CheckMutable(this);
bb_ = value;
}
} }
public override bool Equals(object other) { public override bool Equals(object other) {
return Equals(other as NestedMessage); return Equals(other as NestedMessage);
} }
...@@ -3457,6 +3757,9 @@ namespace Google.Protobuf.TestProtos { ...@@ -3457,6 +3757,9 @@ namespace Google.Protobuf.TestProtos {
get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_SparseEnumMessage__FieldAccessorTable; } get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_SparseEnumMessage__FieldAccessorTable; }
} }
private bool _frozen = false;
public bool IsFrozen { get { return _frozen; } }
public SparseEnumMessage() { } public SparseEnumMessage() { }
public SparseEnumMessage(SparseEnumMessage other) { public SparseEnumMessage(SparseEnumMessage other) {
...@@ -3467,14 +3770,23 @@ namespace Google.Protobuf.TestProtos { ...@@ -3467,14 +3770,23 @@ namespace Google.Protobuf.TestProtos {
return new SparseEnumMessage(this); return new SparseEnumMessage(this);
} }
public void Freeze() {
if (IsFrozen) {
return;
}
_frozen = true;
}
public const int SparseEnumFieldNumber = 1; public const int SparseEnumFieldNumber = 1;
private global::Google.Protobuf.TestProtos.TestSparseEnum sparseEnum_ = global::Google.Protobuf.TestProtos.TestSparseEnum.TEST_SPARSE_ENUM_UNSPECIFIED; private global::Google.Protobuf.TestProtos.TestSparseEnum sparseEnum_ = global::Google.Protobuf.TestProtos.TestSparseEnum.TEST_SPARSE_ENUM_UNSPECIFIED;
public global::Google.Protobuf.TestProtos.TestSparseEnum SparseEnum { public global::Google.Protobuf.TestProtos.TestSparseEnum SparseEnum {
get { return sparseEnum_; } get { return sparseEnum_; }
set { sparseEnum_ = value; } set {
pb::Freezable.CheckMutable(this);
sparseEnum_ = value;
}
} }
public override bool Equals(object other) { public override bool Equals(object other) {
return Equals(other as SparseEnumMessage); return Equals(other as SparseEnumMessage);
} }
...@@ -3555,6 +3867,9 @@ namespace Google.Protobuf.TestProtos { ...@@ -3555,6 +3867,9 @@ namespace Google.Protobuf.TestProtos {
get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_OneString__FieldAccessorTable; } get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_OneString__FieldAccessorTable; }
} }
private bool _frozen = false;
public bool IsFrozen { get { return _frozen; } }
public OneString() { } public OneString() { }
public OneString(OneString other) { public OneString(OneString other) {
...@@ -3565,14 +3880,23 @@ namespace Google.Protobuf.TestProtos { ...@@ -3565,14 +3880,23 @@ namespace Google.Protobuf.TestProtos {
return new OneString(this); return new OneString(this);
} }
public void Freeze() {
if (IsFrozen) {
return;
}
_frozen = true;
}
public const int DataFieldNumber = 1; public const int DataFieldNumber = 1;
private string data_ = ""; private string data_ = "";
public string Data { public string Data {
get { return data_; } get { return data_; }
set { data_ = value ?? ""; } set {
pb::Freezable.CheckMutable(this);
data_ = value ?? "";
}
} }
public override bool Equals(object other) { public override bool Equals(object other) {
return Equals(other as OneString); return Equals(other as OneString);
} }
...@@ -3653,6 +3977,9 @@ namespace Google.Protobuf.TestProtos { ...@@ -3653,6 +3977,9 @@ namespace Google.Protobuf.TestProtos {
get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_MoreString__FieldAccessorTable; } get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_MoreString__FieldAccessorTable; }
} }
private bool _frozen = false;
public bool IsFrozen { get { return _frozen; } }
public MoreString() { } public MoreString() { }
public MoreString(MoreString other) { public MoreString(MoreString other) {
...@@ -3663,6 +3990,14 @@ namespace Google.Protobuf.TestProtos { ...@@ -3663,6 +3990,14 @@ namespace Google.Protobuf.TestProtos {
return new MoreString(this); return new MoreString(this);
} }
public void Freeze() {
if (IsFrozen) {
return;
}
_frozen = true;
data_.Freeze();
}
public const int DataFieldNumber = 1; public const int DataFieldNumber = 1;
private readonly pbc::RepeatedField<string> data_ = new pbc::RepeatedField<string>(); private readonly pbc::RepeatedField<string> data_ = new pbc::RepeatedField<string>();
public pbc::RepeatedField<string> Data { public pbc::RepeatedField<string> Data {
...@@ -3751,6 +4086,9 @@ namespace Google.Protobuf.TestProtos { ...@@ -3751,6 +4086,9 @@ namespace Google.Protobuf.TestProtos {
get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_OneBytes__FieldAccessorTable; } get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_OneBytes__FieldAccessorTable; }
} }
private bool _frozen = false;
public bool IsFrozen { get { return _frozen; } }
public OneBytes() { } public OneBytes() { }
public OneBytes(OneBytes other) { public OneBytes(OneBytes other) {
...@@ -3761,14 +4099,23 @@ namespace Google.Protobuf.TestProtos { ...@@ -3761,14 +4099,23 @@ namespace Google.Protobuf.TestProtos {
return new OneBytes(this); return new OneBytes(this);
} }
public void Freeze() {
if (IsFrozen) {
return;
}
_frozen = true;
}
public const int DataFieldNumber = 1; public const int DataFieldNumber = 1;
private pb::ByteString data_ = pb::ByteString.Empty; private pb::ByteString data_ = pb::ByteString.Empty;
public pb::ByteString Data { public pb::ByteString Data {
get { return data_; } get { return data_; }
set { data_ = value ?? pb::ByteString.Empty; } set {
pb::Freezable.CheckMutable(this);
data_ = value ?? pb::ByteString.Empty;
}
} }
public override bool Equals(object other) { public override bool Equals(object other) {
return Equals(other as OneBytes); return Equals(other as OneBytes);
} }
...@@ -3849,6 +4196,9 @@ namespace Google.Protobuf.TestProtos { ...@@ -3849,6 +4196,9 @@ namespace Google.Protobuf.TestProtos {
get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_MoreBytes__FieldAccessorTable; } get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_MoreBytes__FieldAccessorTable; }
} }
private bool _frozen = false;
public bool IsFrozen { get { return _frozen; } }
public MoreBytes() { } public MoreBytes() { }
public MoreBytes(MoreBytes other) { public MoreBytes(MoreBytes other) {
...@@ -3859,14 +4209,23 @@ namespace Google.Protobuf.TestProtos { ...@@ -3859,14 +4209,23 @@ namespace Google.Protobuf.TestProtos {
return new MoreBytes(this); return new MoreBytes(this);
} }
public void Freeze() {
if (IsFrozen) {
return;
}
_frozen = true;
}
public const int DataFieldNumber = 1; public const int DataFieldNumber = 1;
private pb::ByteString data_ = pb::ByteString.Empty; private pb::ByteString data_ = pb::ByteString.Empty;
public pb::ByteString Data { public pb::ByteString Data {
get { return data_; } get { return data_; }
set { data_ = value ?? pb::ByteString.Empty; } set {
pb::Freezable.CheckMutable(this);
data_ = value ?? pb::ByteString.Empty;
}
} }
public override bool Equals(object other) { public override bool Equals(object other) {
return Equals(other as MoreBytes); return Equals(other as MoreBytes);
} }
...@@ -3947,6 +4306,9 @@ namespace Google.Protobuf.TestProtos { ...@@ -3947,6 +4306,9 @@ namespace Google.Protobuf.TestProtos {
get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_Int32Message__FieldAccessorTable; } get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_Int32Message__FieldAccessorTable; }
} }
private bool _frozen = false;
public bool IsFrozen { get { return _frozen; } }
public Int32Message() { } public Int32Message() { }
public Int32Message(Int32Message other) { public Int32Message(Int32Message other) {
...@@ -3957,14 +4319,23 @@ namespace Google.Protobuf.TestProtos { ...@@ -3957,14 +4319,23 @@ namespace Google.Protobuf.TestProtos {
return new Int32Message(this); return new Int32Message(this);
} }
public void Freeze() {
if (IsFrozen) {
return;
}
_frozen = true;
}
public const int DataFieldNumber = 1; public const int DataFieldNumber = 1;
private int data_; private int data_;
public int Data { public int Data {
get { return data_; } get { return data_; }
set { data_ = value; } set {
pb::Freezable.CheckMutable(this);
data_ = value;
}
} }
public override bool Equals(object other) { public override bool Equals(object other) {
return Equals(other as Int32Message); return Equals(other as Int32Message);
} }
...@@ -4045,6 +4416,9 @@ namespace Google.Protobuf.TestProtos { ...@@ -4045,6 +4416,9 @@ namespace Google.Protobuf.TestProtos {
get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_Uint32Message__FieldAccessorTable; } get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_Uint32Message__FieldAccessorTable; }
} }
private bool _frozen = false;
public bool IsFrozen { get { return _frozen; } }
public Uint32Message() { } public Uint32Message() { }
public Uint32Message(Uint32Message other) { public Uint32Message(Uint32Message other) {
...@@ -4055,14 +4429,23 @@ namespace Google.Protobuf.TestProtos { ...@@ -4055,14 +4429,23 @@ namespace Google.Protobuf.TestProtos {
return new Uint32Message(this); return new Uint32Message(this);
} }
public void Freeze() {
if (IsFrozen) {
return;
}
_frozen = true;
}
public const int DataFieldNumber = 1; public const int DataFieldNumber = 1;
private uint data_; private uint data_;
public uint Data { public uint Data {
get { return data_; } get { return data_; }
set { data_ = value; } set {
pb::Freezable.CheckMutable(this);
data_ = value;
}
} }
public override bool Equals(object other) { public override bool Equals(object other) {
return Equals(other as Uint32Message); return Equals(other as Uint32Message);
} }
...@@ -4143,6 +4526,9 @@ namespace Google.Protobuf.TestProtos { ...@@ -4143,6 +4526,9 @@ namespace Google.Protobuf.TestProtos {
get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_Int64Message__FieldAccessorTable; } get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_Int64Message__FieldAccessorTable; }
} }
private bool _frozen = false;
public bool IsFrozen { get { return _frozen; } }
public Int64Message() { } public Int64Message() { }
public Int64Message(Int64Message other) { public Int64Message(Int64Message other) {
...@@ -4153,14 +4539,23 @@ namespace Google.Protobuf.TestProtos { ...@@ -4153,14 +4539,23 @@ namespace Google.Protobuf.TestProtos {
return new Int64Message(this); return new Int64Message(this);
} }
public void Freeze() {
if (IsFrozen) {
return;
}
_frozen = true;
}
public const int DataFieldNumber = 1; public const int DataFieldNumber = 1;
private long data_; private long data_;
public long Data { public long Data {
get { return data_; } get { return data_; }
set { data_ = value; } set {
pb::Freezable.CheckMutable(this);
data_ = value;
}
} }
public override bool Equals(object other) { public override bool Equals(object other) {
return Equals(other as Int64Message); return Equals(other as Int64Message);
} }
...@@ -4241,6 +4636,9 @@ namespace Google.Protobuf.TestProtos { ...@@ -4241,6 +4636,9 @@ namespace Google.Protobuf.TestProtos {
get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_Uint64Message__FieldAccessorTable; } get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_Uint64Message__FieldAccessorTable; }
} }
private bool _frozen = false;
public bool IsFrozen { get { return _frozen; } }
public Uint64Message() { } public Uint64Message() { }
public Uint64Message(Uint64Message other) { public Uint64Message(Uint64Message other) {
...@@ -4251,14 +4649,23 @@ namespace Google.Protobuf.TestProtos { ...@@ -4251,14 +4649,23 @@ namespace Google.Protobuf.TestProtos {
return new Uint64Message(this); return new Uint64Message(this);
} }
public void Freeze() {
if (IsFrozen) {
return;
}
_frozen = true;
}
public const int DataFieldNumber = 1; public const int DataFieldNumber = 1;
private ulong data_; private ulong data_;
public ulong Data { public ulong Data {
get { return data_; } get { return data_; }
set { data_ = value; } set {
pb::Freezable.CheckMutable(this);
data_ = value;
}
} }
public override bool Equals(object other) { public override bool Equals(object other) {
return Equals(other as Uint64Message); return Equals(other as Uint64Message);
} }
...@@ -4339,6 +4746,9 @@ namespace Google.Protobuf.TestProtos { ...@@ -4339,6 +4746,9 @@ namespace Google.Protobuf.TestProtos {
get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_BoolMessage__FieldAccessorTable; } get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_BoolMessage__FieldAccessorTable; }
} }
private bool _frozen = false;
public bool IsFrozen { get { return _frozen; } }
public BoolMessage() { } public BoolMessage() { }
public BoolMessage(BoolMessage other) { public BoolMessage(BoolMessage other) {
...@@ -4349,14 +4759,23 @@ namespace Google.Protobuf.TestProtos { ...@@ -4349,14 +4759,23 @@ namespace Google.Protobuf.TestProtos {
return new BoolMessage(this); return new BoolMessage(this);
} }
public void Freeze() {
if (IsFrozen) {
return;
}
_frozen = true;
}
public const int DataFieldNumber = 1; public const int DataFieldNumber = 1;
private bool data_; private bool data_;
public bool Data { public bool Data {
get { return data_; } get { return data_; }
set { data_ = value; } set {
pb::Freezable.CheckMutable(this);
data_ = value;
}
} }
public override bool Equals(object other) { public override bool Equals(object other) {
return Equals(other as BoolMessage); return Equals(other as BoolMessage);
} }
...@@ -4437,6 +4856,9 @@ namespace Google.Protobuf.TestProtos { ...@@ -4437,6 +4856,9 @@ namespace Google.Protobuf.TestProtos {
get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestOneof__FieldAccessorTable; } get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestOneof__FieldAccessorTable; }
} }
private bool _frozen = false;
public bool IsFrozen { get { return _frozen; } }
public TestOneof() { } public TestOneof() { }
public TestOneof(TestOneof other) { public TestOneof(TestOneof other) {
...@@ -4458,10 +4880,19 @@ namespace Google.Protobuf.TestProtos { ...@@ -4458,10 +4880,19 @@ namespace Google.Protobuf.TestProtos {
return new TestOneof(this); return new TestOneof(this);
} }
public void Freeze() {
if (IsFrozen) {
return;
}
_frozen = true;
if (foo_ is IFreezable) ((IFreezable) foo_).Freeze();
}
public const int FooIntFieldNumber = 1; public const int FooIntFieldNumber = 1;
public int FooInt { public int FooInt {
get { return fooCase_ == FooOneofCase.FooInt ? (int) foo_ : 0; } get { return fooCase_ == FooOneofCase.FooInt ? (int) foo_ : 0; }
set { set {
pb::Freezable.CheckMutable(this);
foo_ = value; foo_ = value;
fooCase_ = FooOneofCase.FooInt; fooCase_ = FooOneofCase.FooInt;
} }
...@@ -4471,6 +4902,7 @@ namespace Google.Protobuf.TestProtos { ...@@ -4471,6 +4902,7 @@ namespace Google.Protobuf.TestProtos {
public string FooString { public string FooString {
get { return fooCase_ == FooOneofCase.FooString ? (string) foo_ : ""; } get { return fooCase_ == FooOneofCase.FooString ? (string) foo_ : ""; }
set { set {
pb::Freezable.CheckMutable(this);
foo_ = value ?? ""; foo_ = value ?? "";
fooCase_ = FooOneofCase.FooString; fooCase_ = FooOneofCase.FooString;
} }
...@@ -4480,6 +4912,7 @@ namespace Google.Protobuf.TestProtos { ...@@ -4480,6 +4912,7 @@ namespace Google.Protobuf.TestProtos {
public global::Google.Protobuf.TestProtos.TestAllTypes FooMessage { public global::Google.Protobuf.TestProtos.TestAllTypes FooMessage {
get { return fooCase_ == FooOneofCase.FooMessage ? (global::Google.Protobuf.TestProtos.TestAllTypes) foo_ : null; } get { return fooCase_ == FooOneofCase.FooMessage ? (global::Google.Protobuf.TestProtos.TestAllTypes) foo_ : null; }
set { set {
pb::Freezable.CheckMutable(this);
foo_ = value; foo_ = value;
fooCase_ = value == null ? FooOneofCase.None : FooOneofCase.FooMessage; fooCase_ = value == null ? FooOneofCase.None : FooOneofCase.FooMessage;
} }
...@@ -4498,6 +4931,7 @@ namespace Google.Protobuf.TestProtos { ...@@ -4498,6 +4931,7 @@ namespace Google.Protobuf.TestProtos {
} }
public void ClearFoo() { public void ClearFoo() {
pb::Freezable.CheckMutable(this);
fooCase_ = FooOneofCase.None; fooCase_ = FooOneofCase.None;
foo_ = null; foo_ = null;
} }
...@@ -4515,7 +4949,8 @@ namespace Google.Protobuf.TestProtos { ...@@ -4515,7 +4949,8 @@ namespace Google.Protobuf.TestProtos {
} }
if (FooInt != other.FooInt) return false; if (FooInt != other.FooInt) return false;
if (FooString != other.FooString) return false; if (FooString != other.FooString) return false;
if (!object.Equals(FooMessage, other.FooMessage)) return false; return true; if (!object.Equals(FooMessage, other.FooMessage)) return false;
return true;
} }
public override int GetHashCode() { public override int GetHashCode() {
...@@ -4621,6 +5056,9 @@ namespace Google.Protobuf.TestProtos { ...@@ -4621,6 +5056,9 @@ namespace Google.Protobuf.TestProtos {
get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestPackedTypes__FieldAccessorTable; } get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestPackedTypes__FieldAccessorTable; }
} }
private bool _frozen = false;
public bool IsFrozen { get { return _frozen; } }
public TestPackedTypes() { } public TestPackedTypes() { }
public TestPackedTypes(TestPackedTypes other) { public TestPackedTypes(TestPackedTypes other) {
...@@ -4644,6 +5082,27 @@ namespace Google.Protobuf.TestProtos { ...@@ -4644,6 +5082,27 @@ namespace Google.Protobuf.TestProtos {
return new TestPackedTypes(this); return new TestPackedTypes(this);
} }
public void Freeze() {
if (IsFrozen) {
return;
}
_frozen = true;
packedInt32_.Freeze();
packedInt64_.Freeze();
packedUint32_.Freeze();
packedUint64_.Freeze();
packedSint32_.Freeze();
packedSint64_.Freeze();
packedFixed32_.Freeze();
packedFixed64_.Freeze();
packedSfixed32_.Freeze();
packedSfixed64_.Freeze();
packedFloat_.Freeze();
packedDouble_.Freeze();
packedBool_.Freeze();
packedEnum_.Freeze();
}
public const int PackedInt32FieldNumber = 90; public const int PackedInt32FieldNumber = 90;
private readonly pbc::RepeatedField<int> packedInt32_ = new pbc::RepeatedField<int>(); private readonly pbc::RepeatedField<int> packedInt32_ = new pbc::RepeatedField<int>();
public pbc::RepeatedField<int> PackedInt32 { public pbc::RepeatedField<int> PackedInt32 {
...@@ -5058,6 +5517,9 @@ namespace Google.Protobuf.TestProtos { ...@@ -5058,6 +5517,9 @@ namespace Google.Protobuf.TestProtos {
get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestUnpackedTypes__FieldAccessorTable; } get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestUnpackedTypes__FieldAccessorTable; }
} }
private bool _frozen = false;
public bool IsFrozen { get { return _frozen; } }
public TestUnpackedTypes() { } public TestUnpackedTypes() { }
public TestUnpackedTypes(TestUnpackedTypes other) { public TestUnpackedTypes(TestUnpackedTypes other) {
...@@ -5081,6 +5543,27 @@ namespace Google.Protobuf.TestProtos { ...@@ -5081,6 +5543,27 @@ namespace Google.Protobuf.TestProtos {
return new TestUnpackedTypes(this); return new TestUnpackedTypes(this);
} }
public void Freeze() {
if (IsFrozen) {
return;
}
_frozen = true;
unpackedInt32_.Freeze();
unpackedInt64_.Freeze();
unpackedUint32_.Freeze();
unpackedUint64_.Freeze();
unpackedSint32_.Freeze();
unpackedSint64_.Freeze();
unpackedFixed32_.Freeze();
unpackedFixed64_.Freeze();
unpackedSfixed32_.Freeze();
unpackedSfixed64_.Freeze();
unpackedFloat_.Freeze();
unpackedDouble_.Freeze();
unpackedBool_.Freeze();
unpackedEnum_.Freeze();
}
public const int UnpackedInt32FieldNumber = 90; public const int UnpackedInt32FieldNumber = 90;
private readonly pbc::RepeatedField<int> unpackedInt32_ = new pbc::RepeatedField<int>(); private readonly pbc::RepeatedField<int> unpackedInt32_ = new pbc::RepeatedField<int>();
public pbc::RepeatedField<int> UnpackedInt32 { public pbc::RepeatedField<int> UnpackedInt32 {
...@@ -5481,6 +5964,9 @@ namespace Google.Protobuf.TestProtos { ...@@ -5481,6 +5964,9 @@ namespace Google.Protobuf.TestProtos {
get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestRepeatedScalarDifferentTagSizes__FieldAccessorTable; } get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestRepeatedScalarDifferentTagSizes__FieldAccessorTable; }
} }
private bool _frozen = false;
public bool IsFrozen { get { return _frozen; } }
public TestRepeatedScalarDifferentTagSizes() { } public TestRepeatedScalarDifferentTagSizes() { }
public TestRepeatedScalarDifferentTagSizes(TestRepeatedScalarDifferentTagSizes other) { public TestRepeatedScalarDifferentTagSizes(TestRepeatedScalarDifferentTagSizes other) {
...@@ -5496,6 +5982,19 @@ namespace Google.Protobuf.TestProtos { ...@@ -5496,6 +5982,19 @@ namespace Google.Protobuf.TestProtos {
return new TestRepeatedScalarDifferentTagSizes(this); return new TestRepeatedScalarDifferentTagSizes(this);
} }
public void Freeze() {
if (IsFrozen) {
return;
}
_frozen = true;
repeatedFixed32_.Freeze();
repeatedInt32_.Freeze();
repeatedFixed64_.Freeze();
repeatedInt64_.Freeze();
repeatedFloat_.Freeze();
repeatedUint64_.Freeze();
}
public const int RepeatedFixed32FieldNumber = 12; public const int RepeatedFixed32FieldNumber = 12;
private readonly pbc::RepeatedField<uint> repeatedFixed32_ = new pbc::RepeatedField<uint>(); private readonly pbc::RepeatedField<uint> repeatedFixed32_ = new pbc::RepeatedField<uint>();
public pbc::RepeatedField<uint> RepeatedFixed32 { public pbc::RepeatedField<uint> RepeatedFixed32 {
...@@ -5710,6 +6209,9 @@ namespace Google.Protobuf.TestProtos { ...@@ -5710,6 +6209,9 @@ namespace Google.Protobuf.TestProtos {
get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestCommentInjectionMessage__FieldAccessorTable; } get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestCommentInjectionMessage__FieldAccessorTable; }
} }
private bool _frozen = false;
public bool IsFrozen { get { return _frozen; } }
public TestCommentInjectionMessage() { } public TestCommentInjectionMessage() { }
public TestCommentInjectionMessage(TestCommentInjectionMessage other) { public TestCommentInjectionMessage(TestCommentInjectionMessage other) {
...@@ -5720,14 +6222,23 @@ namespace Google.Protobuf.TestProtos { ...@@ -5720,14 +6222,23 @@ namespace Google.Protobuf.TestProtos {
return new TestCommentInjectionMessage(this); return new TestCommentInjectionMessage(this);
} }
public void Freeze() {
if (IsFrozen) {
return;
}
_frozen = true;
}
public const int AFieldNumber = 1; public const int AFieldNumber = 1;
private string a_ = ""; private string a_ = "";
public string A { public string A {
get { return a_; } get { return a_; }
set { a_ = value ?? ""; } set {
pb::Freezable.CheckMutable(this);
a_ = value ?? "";
}
} }
public override bool Equals(object other) { public override bool Equals(object other) {
return Equals(other as TestCommentInjectionMessage); return Equals(other as TestCommentInjectionMessage);
} }
...@@ -5808,6 +6319,9 @@ namespace Google.Protobuf.TestProtos { ...@@ -5808,6 +6319,9 @@ namespace Google.Protobuf.TestProtos {
get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_FooRequest__FieldAccessorTable; } get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_FooRequest__FieldAccessorTable; }
} }
private bool _frozen = false;
public bool IsFrozen { get { return _frozen; } }
public FooRequest() { } public FooRequest() { }
public FooRequest(FooRequest other) { public FooRequest(FooRequest other) {
...@@ -5817,6 +6331,13 @@ namespace Google.Protobuf.TestProtos { ...@@ -5817,6 +6331,13 @@ namespace Google.Protobuf.TestProtos {
return new FooRequest(this); return new FooRequest(this);
} }
public void Freeze() {
if (IsFrozen) {
return;
}
_frozen = true;
}
public override bool Equals(object other) { public override bool Equals(object other) {
return Equals(other as FooRequest); return Equals(other as FooRequest);
} }
...@@ -5881,6 +6402,9 @@ namespace Google.Protobuf.TestProtos { ...@@ -5881,6 +6402,9 @@ namespace Google.Protobuf.TestProtos {
get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_FooResponse__FieldAccessorTable; } get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_FooResponse__FieldAccessorTable; }
} }
private bool _frozen = false;
public bool IsFrozen { get { return _frozen; } }
public FooResponse() { } public FooResponse() { }
public FooResponse(FooResponse other) { public FooResponse(FooResponse other) {
...@@ -5890,6 +6414,13 @@ namespace Google.Protobuf.TestProtos { ...@@ -5890,6 +6414,13 @@ namespace Google.Protobuf.TestProtos {
return new FooResponse(this); return new FooResponse(this);
} }
public void Freeze() {
if (IsFrozen) {
return;
}
_frozen = true;
}
public override bool Equals(object other) { public override bool Equals(object other) {
return Equals(other as FooResponse); return Equals(other as FooResponse);
} }
...@@ -5954,6 +6485,9 @@ namespace Google.Protobuf.TestProtos { ...@@ -5954,6 +6485,9 @@ namespace Google.Protobuf.TestProtos {
get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_FooClientMessage__FieldAccessorTable; } get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_FooClientMessage__FieldAccessorTable; }
} }
private bool _frozen = false;
public bool IsFrozen { get { return _frozen; } }
public FooClientMessage() { } public FooClientMessage() { }
public FooClientMessage(FooClientMessage other) { public FooClientMessage(FooClientMessage other) {
...@@ -5963,6 +6497,13 @@ namespace Google.Protobuf.TestProtos { ...@@ -5963,6 +6497,13 @@ namespace Google.Protobuf.TestProtos {
return new FooClientMessage(this); return new FooClientMessage(this);
} }
public void Freeze() {
if (IsFrozen) {
return;
}
_frozen = true;
}
public override bool Equals(object other) { public override bool Equals(object other) {
return Equals(other as FooClientMessage); return Equals(other as FooClientMessage);
} }
...@@ -6027,6 +6568,9 @@ namespace Google.Protobuf.TestProtos { ...@@ -6027,6 +6568,9 @@ namespace Google.Protobuf.TestProtos {
get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_FooServerMessage__FieldAccessorTable; } get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_FooServerMessage__FieldAccessorTable; }
} }
private bool _frozen = false;
public bool IsFrozen { get { return _frozen; } }
public FooServerMessage() { } public FooServerMessage() { }
public FooServerMessage(FooServerMessage other) { public FooServerMessage(FooServerMessage other) {
...@@ -6036,6 +6580,13 @@ namespace Google.Protobuf.TestProtos { ...@@ -6036,6 +6580,13 @@ namespace Google.Protobuf.TestProtos {
return new FooServerMessage(this); return new FooServerMessage(this);
} }
public void Freeze() {
if (IsFrozen) {
return;
}
_frozen = true;
}
public override bool Equals(object other) { public override bool Equals(object other) {
return Equals(other as FooServerMessage); return Equals(other as FooServerMessage);
} }
...@@ -6100,6 +6651,9 @@ namespace Google.Protobuf.TestProtos { ...@@ -6100,6 +6651,9 @@ namespace Google.Protobuf.TestProtos {
get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_BarRequest__FieldAccessorTable; } get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_BarRequest__FieldAccessorTable; }
} }
private bool _frozen = false;
public bool IsFrozen { get { return _frozen; } }
public BarRequest() { } public BarRequest() { }
public BarRequest(BarRequest other) { public BarRequest(BarRequest other) {
...@@ -6109,6 +6663,13 @@ namespace Google.Protobuf.TestProtos { ...@@ -6109,6 +6663,13 @@ namespace Google.Protobuf.TestProtos {
return new BarRequest(this); return new BarRequest(this);
} }
public void Freeze() {
if (IsFrozen) {
return;
}
_frozen = true;
}
public override bool Equals(object other) { public override bool Equals(object other) {
return Equals(other as BarRequest); return Equals(other as BarRequest);
} }
...@@ -6173,6 +6734,9 @@ namespace Google.Protobuf.TestProtos { ...@@ -6173,6 +6734,9 @@ namespace Google.Protobuf.TestProtos {
get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_BarResponse__FieldAccessorTable; } get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_BarResponse__FieldAccessorTable; }
} }
private bool _frozen = false;
public bool IsFrozen { get { return _frozen; } }
public BarResponse() { } public BarResponse() { }
public BarResponse(BarResponse other) { public BarResponse(BarResponse other) {
...@@ -6182,6 +6746,13 @@ namespace Google.Protobuf.TestProtos { ...@@ -6182,6 +6746,13 @@ namespace Google.Protobuf.TestProtos {
return new BarResponse(this); return new BarResponse(this);
} }
public void Freeze() {
if (IsFrozen) {
return;
}
_frozen = true;
}
public override bool Equals(object other) { public override bool Equals(object other) {
return Equals(other as BarResponse); return Equals(other as BarResponse);
} }
......
...@@ -4,10 +4,16 @@ using System.Collections.Generic; ...@@ -4,10 +4,16 @@ using System.Collections.Generic;
namespace Google.Protobuf.Collections namespace Google.Protobuf.Collections
{ {
public sealed class RepeatedField<T> : IList<T>, IEquatable<RepeatedField<T>> /// <summary>
/// The contents of a repeated field: essentially, a collection with some extra
/// restrictions (no null values) and capabilities (deep cloning and freezing).
/// </summary>
/// <typeparam name="T">The element type of the repeated field.</typeparam>
public sealed class RepeatedField<T> : IList<T>, IDeepCloneable<RepeatedField<T>>, IEquatable<RepeatedField<T>>, IFreezable
{ {
private static readonly T[] EmptyArray = new T[0]; private static readonly T[] EmptyArray = new T[0];
private bool frozen;
private const int MinArraySize = 8; private const int MinArraySize = 8;
private T[] array = EmptyArray; private T[] array = EmptyArray;
private int count = 0; private int count = 0;
...@@ -26,6 +32,7 @@ namespace Google.Protobuf.Collections ...@@ -26,6 +32,7 @@ namespace Google.Protobuf.Collections
public RepeatedField<T> Clone() public RepeatedField<T> Clone()
{ {
RepeatedField<T> clone = new RepeatedField<T>(); RepeatedField<T> clone = new RepeatedField<T>();
// Clone is implicitly *not* frozen, even if this object is.
if (array != EmptyArray) if (array != EmptyArray)
{ {
clone.array = (T[])array.Clone(); clone.array = (T[])array.Clone();
...@@ -42,6 +49,21 @@ namespace Google.Protobuf.Collections ...@@ -42,6 +49,21 @@ namespace Google.Protobuf.Collections
return clone; return clone;
} }
public bool IsFrozen { get { return frozen; } }
public void Freeze()
{
frozen = true;
IFreezable[] freezableArray = array as IFreezable[];
if (freezableArray != null)
{
for (int i = 0; i < count; i++)
{
freezableArray[i].Freeze();
}
}
}
private void EnsureSize(int size) private void EnsureSize(int size)
{ {
size = Math.Max(size, MinArraySize); size = Math.Max(size, MinArraySize);
...@@ -60,6 +82,7 @@ namespace Google.Protobuf.Collections ...@@ -60,6 +82,7 @@ namespace Google.Protobuf.Collections
{ {
throw new ArgumentNullException("item"); throw new ArgumentNullException("item");
} }
this.CheckMutable();
EnsureSize(count + 1); EnsureSize(count + 1);
array[count++] = item; array[count++] = item;
} }
...@@ -70,6 +93,7 @@ namespace Google.Protobuf.Collections ...@@ -70,6 +93,7 @@ namespace Google.Protobuf.Collections
/// <param name="readEnum"></param> /// <param name="readEnum"></param>
internal void AddInt32(int item) internal void AddInt32(int item)
{ {
this.CheckMutable();
EnsureSize(count + 1); EnsureSize(count + 1);
int[] castArray = (int[]) (object) array; int[] castArray = (int[]) (object) array;
castArray[count++] = item; castArray[count++] = item;
...@@ -77,6 +101,7 @@ namespace Google.Protobuf.Collections ...@@ -77,6 +101,7 @@ namespace Google.Protobuf.Collections
public void Clear() public void Clear()
{ {
this.CheckMutable();
array = EmptyArray; array = EmptyArray;
count = 0; count = 0;
} }
...@@ -93,6 +118,7 @@ namespace Google.Protobuf.Collections ...@@ -93,6 +118,7 @@ namespace Google.Protobuf.Collections
public bool Remove(T item) public bool Remove(T item)
{ {
this.CheckMutable();
int index = IndexOf(item); int index = IndexOf(item);
if (index == -1) if (index == -1)
{ {
...@@ -107,7 +133,7 @@ namespace Google.Protobuf.Collections ...@@ -107,7 +133,7 @@ namespace Google.Protobuf.Collections
public int Count { get { return count; } } public int Count { get { return count; } }
// TODO(jonskeet): If we implement freezing, make this reflect it. // TODO(jonskeet): If we implement freezing, make this reflect it.
public bool IsReadOnly { get { return false; } } public bool IsReadOnly { get { return IsFrozen; } }
public void Add(RepeatedField<T> values) public void Add(RepeatedField<T> values)
{ {
...@@ -115,6 +141,7 @@ namespace Google.Protobuf.Collections ...@@ -115,6 +141,7 @@ namespace Google.Protobuf.Collections
{ {
throw new ArgumentNullException("values"); throw new ArgumentNullException("values");
} }
this.CheckMutable();
EnsureSize(count + values.count); EnsureSize(count + values.count);
// We know that all the values will be valid, because it's a RepeatedField. // We know that all the values will be valid, because it's a RepeatedField.
Array.Copy(values.array, 0, array, count, values.count); Array.Copy(values.array, 0, array, count, values.count);
...@@ -127,6 +154,7 @@ namespace Google.Protobuf.Collections ...@@ -127,6 +154,7 @@ namespace Google.Protobuf.Collections
{ {
throw new ArgumentNullException("values"); throw new ArgumentNullException("values");
} }
this.CheckMutable();
// TODO: Check for ICollection and get the Count? // TODO: Check for ICollection and get the Count?
foreach (T item in values) foreach (T item in values)
{ {
...@@ -227,6 +255,7 @@ namespace Google.Protobuf.Collections ...@@ -227,6 +255,7 @@ namespace Google.Protobuf.Collections
{ {
throw new ArgumentOutOfRangeException("index"); throw new ArgumentOutOfRangeException("index");
} }
this.CheckMutable();
EnsureSize(count + 1); EnsureSize(count + 1);
Array.Copy(array, index, array, index + 1, count - index); Array.Copy(array, index, array, index + 1, count - index);
count++; count++;
...@@ -238,6 +267,7 @@ namespace Google.Protobuf.Collections ...@@ -238,6 +267,7 @@ namespace Google.Protobuf.Collections
{ {
throw new ArgumentOutOfRangeException("index"); throw new ArgumentOutOfRangeException("index");
} }
this.CheckMutable();
Array.Copy(array, index + 1, array, index, count - index - 1); Array.Copy(array, index + 1, array, index, count - index - 1);
count--; count--;
array[count] = default(T); array[count] = default(T);
...@@ -259,6 +289,7 @@ namespace Google.Protobuf.Collections ...@@ -259,6 +289,7 @@ namespace Google.Protobuf.Collections
{ {
throw new ArgumentOutOfRangeException("index"); throw new ArgumentOutOfRangeException("index");
} }
this.CheckMutable();
if (value == null) if (value == null)
{ {
throw new ArgumentNullException("value"); throw new ArgumentNullException("value");
......
...@@ -292,6 +292,9 @@ namespace Google.Protobuf.DescriptorProtos { ...@@ -292,6 +292,9 @@ namespace Google.Protobuf.DescriptorProtos {
get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_FileDescriptorSet__FieldAccessorTable; } get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_FileDescriptorSet__FieldAccessorTable; }
} }
private bool _frozen = false;
public bool IsFrozen { get { return _frozen; } }
public FileDescriptorSet() { } public FileDescriptorSet() { }
public FileDescriptorSet(FileDescriptorSet other) { public FileDescriptorSet(FileDescriptorSet other) {
...@@ -302,6 +305,14 @@ namespace Google.Protobuf.DescriptorProtos { ...@@ -302,6 +305,14 @@ namespace Google.Protobuf.DescriptorProtos {
return new FileDescriptorSet(this); return new FileDescriptorSet(this);
} }
public void Freeze() {
if (IsFrozen) {
return;
}
_frozen = true;
file_.Freeze();
}
public const int FileFieldNumber = 1; public const int FileFieldNumber = 1;
private readonly pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.FileDescriptorProto> file_ = new pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.FileDescriptorProto>(); private readonly pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.FileDescriptorProto> file_ = new pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.FileDescriptorProto>();
public pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.FileDescriptorProto> File { public pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.FileDescriptorProto> File {
...@@ -388,6 +399,9 @@ namespace Google.Protobuf.DescriptorProtos { ...@@ -388,6 +399,9 @@ namespace Google.Protobuf.DescriptorProtos {
get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_FileDescriptorProto__FieldAccessorTable; } get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_FileDescriptorProto__FieldAccessorTable; }
} }
private bool _frozen = false;
public bool IsFrozen { get { return _frozen; } }
public FileDescriptorProto() { } public FileDescriptorProto() { }
public FileDescriptorProto(FileDescriptorProto other) { public FileDescriptorProto(FileDescriptorProto other) {
...@@ -409,22 +423,42 @@ namespace Google.Protobuf.DescriptorProtos { ...@@ -409,22 +423,42 @@ namespace Google.Protobuf.DescriptorProtos {
return new FileDescriptorProto(this); return new FileDescriptorProto(this);
} }
public void Freeze() {
if (IsFrozen) {
return;
}
_frozen = true;
dependency_.Freeze();
publicDependency_.Freeze();
weakDependency_.Freeze();
messageType_.Freeze();
enumType_.Freeze();
service_.Freeze();
extension_.Freeze();
if (options_ != null) Options.Freeze();
if (sourceCodeInfo_ != null) SourceCodeInfo.Freeze();
}
public const int NameFieldNumber = 1; public const int NameFieldNumber = 1;
private string name_ = ""; private string name_ = "";
public string Name { public string Name {
get { return name_; } get { return name_; }
set { name_ = value ?? ""; } set {
pb::Freezable.CheckMutable(this);
name_ = value ?? "";
}
} }
public const int PackageFieldNumber = 2; public const int PackageFieldNumber = 2;
private string package_ = ""; private string package_ = "";
public string Package { public string Package {
get { return package_; } get { return package_; }
set { package_ = value ?? ""; } set {
pb::Freezable.CheckMutable(this);
package_ = value ?? "";
}
} }
public const int DependencyFieldNumber = 3; public const int DependencyFieldNumber = 3;
private readonly pbc::RepeatedField<string> dependency_ = new pbc::RepeatedField<string>(); private readonly pbc::RepeatedField<string> dependency_ = new pbc::RepeatedField<string>();
public pbc::RepeatedField<string> Dependency { public pbc::RepeatedField<string> Dependency {
...@@ -471,24 +505,32 @@ namespace Google.Protobuf.DescriptorProtos { ...@@ -471,24 +505,32 @@ namespace Google.Protobuf.DescriptorProtos {
private global::Google.Protobuf.DescriptorProtos.FileOptions options_; private global::Google.Protobuf.DescriptorProtos.FileOptions options_;
public global::Google.Protobuf.DescriptorProtos.FileOptions Options { public global::Google.Protobuf.DescriptorProtos.FileOptions Options {
get { return options_; } get { return options_; }
set { options_ = value; } set {
pb::Freezable.CheckMutable(this);
options_ = value;
}
} }
public const int SourceCodeInfoFieldNumber = 9; public const int SourceCodeInfoFieldNumber = 9;
private global::Google.Protobuf.DescriptorProtos.SourceCodeInfo sourceCodeInfo_; private global::Google.Protobuf.DescriptorProtos.SourceCodeInfo sourceCodeInfo_;
public global::Google.Protobuf.DescriptorProtos.SourceCodeInfo SourceCodeInfo { public global::Google.Protobuf.DescriptorProtos.SourceCodeInfo SourceCodeInfo {
get { return sourceCodeInfo_; } get { return sourceCodeInfo_; }
set { sourceCodeInfo_ = value; } set {
pb::Freezable.CheckMutable(this);
sourceCodeInfo_ = value;
}
} }
public const int SyntaxFieldNumber = 12; public const int SyntaxFieldNumber = 12;
private string syntax_ = ""; private string syntax_ = "";
public string Syntax { public string Syntax {
get { return syntax_; } get { return syntax_; }
set { syntax_ = value ?? ""; } set {
pb::Freezable.CheckMutable(this);
syntax_ = value ?? "";
}
} }
public override bool Equals(object other) { public override bool Equals(object other) {
return Equals(other as FileDescriptorProto); return Equals(other as FileDescriptorProto);
} }
...@@ -509,7 +551,9 @@ namespace Google.Protobuf.DescriptorProtos { ...@@ -509,7 +551,9 @@ namespace Google.Protobuf.DescriptorProtos {
if(!enumType_.Equals(other.enumType_)) return false; if(!enumType_.Equals(other.enumType_)) return false;
if(!service_.Equals(other.service_)) return false; if(!service_.Equals(other.service_)) return false;
if(!extension_.Equals(other.extension_)) return false; if(!extension_.Equals(other.extension_)) return false;
if (!object.Equals(Options, other.Options)) return false;if (!object.Equals(SourceCodeInfo, other.SourceCodeInfo)) return false;if (Syntax != other.Syntax) return false; if (!object.Equals(Options, other.Options)) return false;
if (!object.Equals(SourceCodeInfo, other.SourceCodeInfo)) return false;
if (Syntax != other.Syntax) return false;
return true; return true;
} }
...@@ -763,6 +807,9 @@ namespace Google.Protobuf.DescriptorProtos { ...@@ -763,6 +807,9 @@ namespace Google.Protobuf.DescriptorProtos {
get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_DescriptorProto__FieldAccessorTable; } get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_DescriptorProto__FieldAccessorTable; }
} }
private bool _frozen = false;
public bool IsFrozen { get { return _frozen; } }
public DescriptorProto() { } public DescriptorProto() { }
public DescriptorProto(DescriptorProto other) { public DescriptorProto(DescriptorProto other) {
...@@ -782,14 +829,32 @@ namespace Google.Protobuf.DescriptorProtos { ...@@ -782,14 +829,32 @@ namespace Google.Protobuf.DescriptorProtos {
return new DescriptorProto(this); return new DescriptorProto(this);
} }
public void Freeze() {
if (IsFrozen) {
return;
}
_frozen = true;
field_.Freeze();
extension_.Freeze();
nestedType_.Freeze();
enumType_.Freeze();
extensionRange_.Freeze();
oneofDecl_.Freeze();
if (options_ != null) Options.Freeze();
reservedRange_.Freeze();
reservedName_.Freeze();
}
public const int NameFieldNumber = 1; public const int NameFieldNumber = 1;
private string name_ = ""; private string name_ = "";
public string Name { public string Name {
get { return name_; } get { return name_; }
set { name_ = value ?? ""; } set {
pb::Freezable.CheckMutable(this);
name_ = value ?? "";
}
} }
public const int FieldFieldNumber = 2; public const int FieldFieldNumber = 2;
private readonly pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto> field_ = new pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto>(); private readonly pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto> field_ = new pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto>();
public pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto> Field { public pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto> Field {
...@@ -830,7 +895,10 @@ namespace Google.Protobuf.DescriptorProtos { ...@@ -830,7 +895,10 @@ namespace Google.Protobuf.DescriptorProtos {
private global::Google.Protobuf.DescriptorProtos.MessageOptions options_; private global::Google.Protobuf.DescriptorProtos.MessageOptions options_;
public global::Google.Protobuf.DescriptorProtos.MessageOptions Options { public global::Google.Protobuf.DescriptorProtos.MessageOptions Options {
get { return options_; } get { return options_; }
set { options_ = value; } set {
pb::Freezable.CheckMutable(this);
options_ = value;
}
} }
public const int ReservedRangeFieldNumber = 9; public const int ReservedRangeFieldNumber = 9;
...@@ -863,7 +931,8 @@ namespace Google.Protobuf.DescriptorProtos { ...@@ -863,7 +931,8 @@ namespace Google.Protobuf.DescriptorProtos {
if(!enumType_.Equals(other.enumType_)) return false; if(!enumType_.Equals(other.enumType_)) return false;
if(!extensionRange_.Equals(other.extensionRange_)) return false; if(!extensionRange_.Equals(other.extensionRange_)) return false;
if(!oneofDecl_.Equals(other.oneofDecl_)) return false; if(!oneofDecl_.Equals(other.oneofDecl_)) return false;
if (!object.Equals(Options, other.Options)) return false;if(!reservedRange_.Equals(other.reservedRange_)) return false; if (!object.Equals(Options, other.Options)) return false;
if(!reservedRange_.Equals(other.reservedRange_)) return false;
if(!reservedName_.Equals(other.reservedName_)) return false; if(!reservedName_.Equals(other.reservedName_)) return false;
return true; return true;
} }
...@@ -1077,6 +1146,9 @@ namespace Google.Protobuf.DescriptorProtos { ...@@ -1077,6 +1146,9 @@ namespace Google.Protobuf.DescriptorProtos {
get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_DescriptorProto_ExtensionRange__FieldAccessorTable; } get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_DescriptorProto_ExtensionRange__FieldAccessorTable; }
} }
private bool _frozen = false;
public bool IsFrozen { get { return _frozen; } }
public ExtensionRange() { } public ExtensionRange() { }
public ExtensionRange(ExtensionRange other) { public ExtensionRange(ExtensionRange other) {
...@@ -1088,22 +1160,33 @@ namespace Google.Protobuf.DescriptorProtos { ...@@ -1088,22 +1160,33 @@ namespace Google.Protobuf.DescriptorProtos {
return new ExtensionRange(this); return new ExtensionRange(this);
} }
public void Freeze() {
if (IsFrozen) {
return;
}
_frozen = true;
}
public const int StartFieldNumber = 1; public const int StartFieldNumber = 1;
private int start_; private int start_;
public int Start { public int Start {
get { return start_; } get { return start_; }
set { start_ = value; } set {
pb::Freezable.CheckMutable(this);
start_ = value;
}
} }
public const int EndFieldNumber = 2; public const int EndFieldNumber = 2;
private int end_; private int end_;
public int End { public int End {
get { return end_; } get { return end_; }
set { end_ = value; } set {
pb::Freezable.CheckMutable(this);
end_ = value;
}
} }
public override bool Equals(object other) { public override bool Equals(object other) {
return Equals(other as ExtensionRange); return Equals(other as ExtensionRange);
} }
...@@ -1200,6 +1283,9 @@ namespace Google.Protobuf.DescriptorProtos { ...@@ -1200,6 +1283,9 @@ namespace Google.Protobuf.DescriptorProtos {
get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_DescriptorProto_ReservedRange__FieldAccessorTable; } get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_DescriptorProto_ReservedRange__FieldAccessorTable; }
} }
private bool _frozen = false;
public bool IsFrozen { get { return _frozen; } }
public ReservedRange() { } public ReservedRange() { }
public ReservedRange(ReservedRange other) { public ReservedRange(ReservedRange other) {
...@@ -1211,22 +1297,33 @@ namespace Google.Protobuf.DescriptorProtos { ...@@ -1211,22 +1297,33 @@ namespace Google.Protobuf.DescriptorProtos {
return new ReservedRange(this); return new ReservedRange(this);
} }
public void Freeze() {
if (IsFrozen) {
return;
}
_frozen = true;
}
public const int StartFieldNumber = 1; public const int StartFieldNumber = 1;
private int start_; private int start_;
public int Start { public int Start {
get { return start_; } get { return start_; }
set { start_ = value; } set {
pb::Freezable.CheckMutable(this);
start_ = value;
}
} }
public const int EndFieldNumber = 2; public const int EndFieldNumber = 2;
private int end_; private int end_;
public int End { public int End {
get { return end_; } get { return end_; }
set { end_ = value; } set {
pb::Freezable.CheckMutable(this);
end_ = value;
}
} }
public override bool Equals(object other) { public override bool Equals(object other) {
return Equals(other as ReservedRange); return Equals(other as ReservedRange);
} }
...@@ -1328,6 +1425,9 @@ namespace Google.Protobuf.DescriptorProtos { ...@@ -1328,6 +1425,9 @@ namespace Google.Protobuf.DescriptorProtos {
get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_FieldDescriptorProto__FieldAccessorTable; } get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_FieldDescriptorProto__FieldAccessorTable; }
} }
private bool _frozen = false;
public bool IsFrozen { get { return _frozen; } }
public FieldDescriptorProto() { } public FieldDescriptorProto() { }
public FieldDescriptorProto(FieldDescriptorProto other) { public FieldDescriptorProto(FieldDescriptorProto other) {
...@@ -1346,75 +1446,102 @@ namespace Google.Protobuf.DescriptorProtos { ...@@ -1346,75 +1446,102 @@ namespace Google.Protobuf.DescriptorProtos {
return new FieldDescriptorProto(this); return new FieldDescriptorProto(this);
} }
public void Freeze() {
if (IsFrozen) {
return;
}
_frozen = true;
if (options_ != null) Options.Freeze();
}
public const int NameFieldNumber = 1; public const int NameFieldNumber = 1;
private string name_ = ""; private string name_ = "";
public string Name { public string Name {
get { return name_; } get { return name_; }
set { name_ = value ?? ""; } set {
pb::Freezable.CheckMutable(this);
name_ = value ?? "";
}
} }
public const int NumberFieldNumber = 3; public const int NumberFieldNumber = 3;
private int number_; private int number_;
public int Number { public int Number {
get { return number_; } get { return number_; }
set { number_ = value; } set {
pb::Freezable.CheckMutable(this);
number_ = value;
}
} }
public const int LabelFieldNumber = 4; public const int LabelFieldNumber = 4;
private global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Types.Label label_ = global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Types.Label.LABEL_OPTIONAL; private global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Types.Label label_ = global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Types.Label.LABEL_OPTIONAL;
public global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Types.Label Label { public global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Types.Label Label {
get { return label_; } get { return label_; }
set { label_ = value; } set {
pb::Freezable.CheckMutable(this);
label_ = value;
}
} }
public const int TypeFieldNumber = 5; public const int TypeFieldNumber = 5;
private global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Types.Type type_ = global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Types.Type.TYPE_DOUBLE; private global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Types.Type type_ = global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Types.Type.TYPE_DOUBLE;
public global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Types.Type Type { public global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Types.Type Type {
get { return type_; } get { return type_; }
set { type_ = value; } set {
pb::Freezable.CheckMutable(this);
type_ = value;
}
} }
public const int TypeNameFieldNumber = 6; public const int TypeNameFieldNumber = 6;
private string typeName_ = ""; private string typeName_ = "";
public string TypeName { public string TypeName {
get { return typeName_; } get { return typeName_; }
set { typeName_ = value ?? ""; } set {
pb::Freezable.CheckMutable(this);
typeName_ = value ?? "";
}
} }
public const int ExtendeeFieldNumber = 2; public const int ExtendeeFieldNumber = 2;
private string extendee_ = ""; private string extendee_ = "";
public string Extendee { public string Extendee {
get { return extendee_; } get { return extendee_; }
set { extendee_ = value ?? ""; } set {
pb::Freezable.CheckMutable(this);
extendee_ = value ?? "";
}
} }
public const int DefaultValueFieldNumber = 7; public const int DefaultValueFieldNumber = 7;
private string defaultValue_ = ""; private string defaultValue_ = "";
public string DefaultValue { public string DefaultValue {
get { return defaultValue_; } get { return defaultValue_; }
set { defaultValue_ = value ?? ""; } set {
pb::Freezable.CheckMutable(this);
defaultValue_ = value ?? "";
}
} }
public const int OneofIndexFieldNumber = 9; public const int OneofIndexFieldNumber = 9;
private int oneofIndex_; private int oneofIndex_;
public int OneofIndex { public int OneofIndex {
get { return oneofIndex_; } get { return oneofIndex_; }
set { oneofIndex_ = value; } set {
pb::Freezable.CheckMutable(this);
oneofIndex_ = value;
}
} }
public const int OptionsFieldNumber = 8; public const int OptionsFieldNumber = 8;
private global::Google.Protobuf.DescriptorProtos.FieldOptions options_; private global::Google.Protobuf.DescriptorProtos.FieldOptions options_;
public global::Google.Protobuf.DescriptorProtos.FieldOptions Options { public global::Google.Protobuf.DescriptorProtos.FieldOptions Options {
get { return options_; } get { return options_; }
set { options_ = value; } set {
pb::Freezable.CheckMutable(this);
options_ = value;
}
} }
public override bool Equals(object other) { public override bool Equals(object other) {
...@@ -1436,7 +1563,8 @@ namespace Google.Protobuf.DescriptorProtos { ...@@ -1436,7 +1563,8 @@ namespace Google.Protobuf.DescriptorProtos {
if (Extendee != other.Extendee) return false; if (Extendee != other.Extendee) return false;
if (DefaultValue != other.DefaultValue) return false; if (DefaultValue != other.DefaultValue) return false;
if (OneofIndex != other.OneofIndex) return false; if (OneofIndex != other.OneofIndex) return false;
if (!object.Equals(Options, other.Options)) return false; return true; if (!object.Equals(Options, other.Options)) return false;
return true;
} }
public override int GetHashCode() { public override int GetHashCode() {
...@@ -1663,6 +1791,9 @@ namespace Google.Protobuf.DescriptorProtos { ...@@ -1663,6 +1791,9 @@ namespace Google.Protobuf.DescriptorProtos {
get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_OneofDescriptorProto__FieldAccessorTable; } get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_OneofDescriptorProto__FieldAccessorTable; }
} }
private bool _frozen = false;
public bool IsFrozen { get { return _frozen; } }
public OneofDescriptorProto() { } public OneofDescriptorProto() { }
public OneofDescriptorProto(OneofDescriptorProto other) { public OneofDescriptorProto(OneofDescriptorProto other) {
...@@ -1673,14 +1804,23 @@ namespace Google.Protobuf.DescriptorProtos { ...@@ -1673,14 +1804,23 @@ namespace Google.Protobuf.DescriptorProtos {
return new OneofDescriptorProto(this); return new OneofDescriptorProto(this);
} }
public void Freeze() {
if (IsFrozen) {
return;
}
_frozen = true;
}
public const int NameFieldNumber = 1; public const int NameFieldNumber = 1;
private string name_ = ""; private string name_ = "";
public string Name { public string Name {
get { return name_; } get { return name_; }
set { name_ = value ?? ""; } set {
pb::Freezable.CheckMutable(this);
name_ = value ?? "";
}
} }
public override bool Equals(object other) { public override bool Equals(object other) {
return Equals(other as OneofDescriptorProto); return Equals(other as OneofDescriptorProto);
} }
...@@ -1761,6 +1901,9 @@ namespace Google.Protobuf.DescriptorProtos { ...@@ -1761,6 +1901,9 @@ namespace Google.Protobuf.DescriptorProtos {
get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_EnumDescriptorProto__FieldAccessorTable; } get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_EnumDescriptorProto__FieldAccessorTable; }
} }
private bool _frozen = false;
public bool IsFrozen { get { return _frozen; } }
public EnumDescriptorProto() { } public EnumDescriptorProto() { }
public EnumDescriptorProto(EnumDescriptorProto other) { public EnumDescriptorProto(EnumDescriptorProto other) {
...@@ -1773,14 +1916,25 @@ namespace Google.Protobuf.DescriptorProtos { ...@@ -1773,14 +1916,25 @@ namespace Google.Protobuf.DescriptorProtos {
return new EnumDescriptorProto(this); return new EnumDescriptorProto(this);
} }
public void Freeze() {
if (IsFrozen) {
return;
}
_frozen = true;
value_.Freeze();
if (options_ != null) Options.Freeze();
}
public const int NameFieldNumber = 1; public const int NameFieldNumber = 1;
private string name_ = ""; private string name_ = "";
public string Name { public string Name {
get { return name_; } get { return name_; }
set { name_ = value ?? ""; } set {
pb::Freezable.CheckMutable(this);
name_ = value ?? "";
}
} }
public const int ValueFieldNumber = 2; public const int ValueFieldNumber = 2;
private readonly pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.EnumValueDescriptorProto> value_ = new pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.EnumValueDescriptorProto>(); private readonly pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.EnumValueDescriptorProto> value_ = new pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.EnumValueDescriptorProto>();
public pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.EnumValueDescriptorProto> Value { public pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.EnumValueDescriptorProto> Value {
...@@ -1791,7 +1945,10 @@ namespace Google.Protobuf.DescriptorProtos { ...@@ -1791,7 +1945,10 @@ namespace Google.Protobuf.DescriptorProtos {
private global::Google.Protobuf.DescriptorProtos.EnumOptions options_; private global::Google.Protobuf.DescriptorProtos.EnumOptions options_;
public global::Google.Protobuf.DescriptorProtos.EnumOptions Options { public global::Google.Protobuf.DescriptorProtos.EnumOptions Options {
get { return options_; } get { return options_; }
set { options_ = value; } set {
pb::Freezable.CheckMutable(this);
options_ = value;
}
} }
public override bool Equals(object other) { public override bool Equals(object other) {
...@@ -1807,7 +1964,8 @@ namespace Google.Protobuf.DescriptorProtos { ...@@ -1807,7 +1964,8 @@ namespace Google.Protobuf.DescriptorProtos {
} }
if (Name != other.Name) return false; if (Name != other.Name) return false;
if(!value_.Equals(other.value_)) return false; if(!value_.Equals(other.value_)) return false;
if (!object.Equals(Options, other.Options)) return false; return true; if (!object.Equals(Options, other.Options)) return false;
return true;
} }
public override int GetHashCode() { public override int GetHashCode() {
...@@ -1911,6 +2069,9 @@ namespace Google.Protobuf.DescriptorProtos { ...@@ -1911,6 +2069,9 @@ namespace Google.Protobuf.DescriptorProtos {
get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_EnumValueDescriptorProto__FieldAccessorTable; } get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_EnumValueDescriptorProto__FieldAccessorTable; }
} }
private bool _frozen = false;
public bool IsFrozen { get { return _frozen; } }
public EnumValueDescriptorProto() { } public EnumValueDescriptorProto() { }
public EnumValueDescriptorProto(EnumValueDescriptorProto other) { public EnumValueDescriptorProto(EnumValueDescriptorProto other) {
...@@ -1923,27 +2084,42 @@ namespace Google.Protobuf.DescriptorProtos { ...@@ -1923,27 +2084,42 @@ namespace Google.Protobuf.DescriptorProtos {
return new EnumValueDescriptorProto(this); return new EnumValueDescriptorProto(this);
} }
public void Freeze() {
if (IsFrozen) {
return;
}
_frozen = true;
if (options_ != null) Options.Freeze();
}
public const int NameFieldNumber = 1; public const int NameFieldNumber = 1;
private string name_ = ""; private string name_ = "";
public string Name { public string Name {
get { return name_; } get { return name_; }
set { name_ = value ?? ""; } set {
pb::Freezable.CheckMutable(this);
name_ = value ?? "";
}
} }
public const int NumberFieldNumber = 2; public const int NumberFieldNumber = 2;
private int number_; private int number_;
public int Number { public int Number {
get { return number_; } get { return number_; }
set { number_ = value; } set {
pb::Freezable.CheckMutable(this);
number_ = value;
}
} }
public const int OptionsFieldNumber = 3; public const int OptionsFieldNumber = 3;
private global::Google.Protobuf.DescriptorProtos.EnumValueOptions options_; private global::Google.Protobuf.DescriptorProtos.EnumValueOptions options_;
public global::Google.Protobuf.DescriptorProtos.EnumValueOptions Options { public global::Google.Protobuf.DescriptorProtos.EnumValueOptions Options {
get { return options_; } get { return options_; }
set { options_ = value; } set {
pb::Freezable.CheckMutable(this);
options_ = value;
}
} }
public override bool Equals(object other) { public override bool Equals(object other) {
...@@ -1959,7 +2135,8 @@ namespace Google.Protobuf.DescriptorProtos { ...@@ -1959,7 +2135,8 @@ namespace Google.Protobuf.DescriptorProtos {
} }
if (Name != other.Name) return false; if (Name != other.Name) return false;
if (Number != other.Number) return false; if (Number != other.Number) return false;
if (!object.Equals(Options, other.Options)) return false; return true; if (!object.Equals(Options, other.Options)) return false;
return true;
} }
public override int GetHashCode() { public override int GetHashCode() {
...@@ -2063,6 +2240,9 @@ namespace Google.Protobuf.DescriptorProtos { ...@@ -2063,6 +2240,9 @@ namespace Google.Protobuf.DescriptorProtos {
get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_ServiceDescriptorProto__FieldAccessorTable; } get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_ServiceDescriptorProto__FieldAccessorTable; }
} }
private bool _frozen = false;
public bool IsFrozen { get { return _frozen; } }
public ServiceDescriptorProto() { } public ServiceDescriptorProto() { }
public ServiceDescriptorProto(ServiceDescriptorProto other) { public ServiceDescriptorProto(ServiceDescriptorProto other) {
...@@ -2075,14 +2255,25 @@ namespace Google.Protobuf.DescriptorProtos { ...@@ -2075,14 +2255,25 @@ namespace Google.Protobuf.DescriptorProtos {
return new ServiceDescriptorProto(this); return new ServiceDescriptorProto(this);
} }
public void Freeze() {
if (IsFrozen) {
return;
}
_frozen = true;
method_.Freeze();
if (options_ != null) Options.Freeze();
}
public const int NameFieldNumber = 1; public const int NameFieldNumber = 1;
private string name_ = ""; private string name_ = "";
public string Name { public string Name {
get { return name_; } get { return name_; }
set { name_ = value ?? ""; } set {
pb::Freezable.CheckMutable(this);
name_ = value ?? "";
}
} }
public const int MethodFieldNumber = 2; public const int MethodFieldNumber = 2;
private readonly pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.MethodDescriptorProto> method_ = new pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.MethodDescriptorProto>(); private readonly pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.MethodDescriptorProto> method_ = new pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.MethodDescriptorProto>();
public pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.MethodDescriptorProto> Method { public pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.MethodDescriptorProto> Method {
...@@ -2093,7 +2284,10 @@ namespace Google.Protobuf.DescriptorProtos { ...@@ -2093,7 +2284,10 @@ namespace Google.Protobuf.DescriptorProtos {
private global::Google.Protobuf.DescriptorProtos.ServiceOptions options_; private global::Google.Protobuf.DescriptorProtos.ServiceOptions options_;
public global::Google.Protobuf.DescriptorProtos.ServiceOptions Options { public global::Google.Protobuf.DescriptorProtos.ServiceOptions Options {
get { return options_; } get { return options_; }
set { options_ = value; } set {
pb::Freezable.CheckMutable(this);
options_ = value;
}
} }
public override bool Equals(object other) { public override bool Equals(object other) {
...@@ -2109,7 +2303,8 @@ namespace Google.Protobuf.DescriptorProtos { ...@@ -2109,7 +2303,8 @@ namespace Google.Protobuf.DescriptorProtos {
} }
if (Name != other.Name) return false; if (Name != other.Name) return false;
if(!method_.Equals(other.method_)) return false; if(!method_.Equals(other.method_)) return false;
if (!object.Equals(Options, other.Options)) return false; return true; if (!object.Equals(Options, other.Options)) return false;
return true;
} }
public override int GetHashCode() { public override int GetHashCode() {
...@@ -2213,6 +2408,9 @@ namespace Google.Protobuf.DescriptorProtos { ...@@ -2213,6 +2408,9 @@ namespace Google.Protobuf.DescriptorProtos {
get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_MethodDescriptorProto__FieldAccessorTable; } get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_MethodDescriptorProto__FieldAccessorTable; }
} }
private bool _frozen = false;
public bool IsFrozen { get { return _frozen; } }
public MethodDescriptorProto() { } public MethodDescriptorProto() { }
public MethodDescriptorProto(MethodDescriptorProto other) { public MethodDescriptorProto(MethodDescriptorProto other) {
...@@ -2228,53 +2426,74 @@ namespace Google.Protobuf.DescriptorProtos { ...@@ -2228,53 +2426,74 @@ namespace Google.Protobuf.DescriptorProtos {
return new MethodDescriptorProto(this); return new MethodDescriptorProto(this);
} }
public void Freeze() {
if (IsFrozen) {
return;
}
_frozen = true;
if (options_ != null) Options.Freeze();
}
public const int NameFieldNumber = 1; public const int NameFieldNumber = 1;
private string name_ = ""; private string name_ = "";
public string Name { public string Name {
get { return name_; } get { return name_; }
set { name_ = value ?? ""; } set {
pb::Freezable.CheckMutable(this);
name_ = value ?? "";
}
} }
public const int InputTypeFieldNumber = 2; public const int InputTypeFieldNumber = 2;
private string inputType_ = ""; private string inputType_ = "";
public string InputType { public string InputType {
get { return inputType_; } get { return inputType_; }
set { inputType_ = value ?? ""; } set {
pb::Freezable.CheckMutable(this);
inputType_ = value ?? "";
}
} }
public const int OutputTypeFieldNumber = 3; public const int OutputTypeFieldNumber = 3;
private string outputType_ = ""; private string outputType_ = "";
public string OutputType { public string OutputType {
get { return outputType_; } get { return outputType_; }
set { outputType_ = value ?? ""; } set {
pb::Freezable.CheckMutable(this);
outputType_ = value ?? "";
}
} }
public const int OptionsFieldNumber = 4; public const int OptionsFieldNumber = 4;
private global::Google.Protobuf.DescriptorProtos.MethodOptions options_; private global::Google.Protobuf.DescriptorProtos.MethodOptions options_;
public global::Google.Protobuf.DescriptorProtos.MethodOptions Options { public global::Google.Protobuf.DescriptorProtos.MethodOptions Options {
get { return options_; } get { return options_; }
set { options_ = value; } set {
pb::Freezable.CheckMutable(this);
options_ = value;
}
} }
public const int ClientStreamingFieldNumber = 5; public const int ClientStreamingFieldNumber = 5;
private bool clientStreaming_; private bool clientStreaming_;
public bool ClientStreaming { public bool ClientStreaming {
get { return clientStreaming_; } get { return clientStreaming_; }
set { clientStreaming_ = value; } set {
pb::Freezable.CheckMutable(this);
clientStreaming_ = value;
}
} }
public const int ServerStreamingFieldNumber = 6; public const int ServerStreamingFieldNumber = 6;
private bool serverStreaming_; private bool serverStreaming_;
public bool ServerStreaming { public bool ServerStreaming {
get { return serverStreaming_; } get { return serverStreaming_; }
set { serverStreaming_ = value; } set {
pb::Freezable.CheckMutable(this);
serverStreaming_ = value;
}
} }
public override bool Equals(object other) { public override bool Equals(object other) {
return Equals(other as MethodDescriptorProto); return Equals(other as MethodDescriptorProto);
} }
...@@ -2289,7 +2508,8 @@ namespace Google.Protobuf.DescriptorProtos { ...@@ -2289,7 +2508,8 @@ namespace Google.Protobuf.DescriptorProtos {
if (Name != other.Name) return false; if (Name != other.Name) return false;
if (InputType != other.InputType) return false; if (InputType != other.InputType) return false;
if (OutputType != other.OutputType) return false; if (OutputType != other.OutputType) return false;
if (!object.Equals(Options, other.Options)) return false;if (ClientStreaming != other.ClientStreaming) return false; if (!object.Equals(Options, other.Options)) return false;
if (ClientStreaming != other.ClientStreaming) return false;
if (ServerStreaming != other.ServerStreaming) return false; if (ServerStreaming != other.ServerStreaming) return false;
return true; return true;
} }
...@@ -2440,6 +2660,9 @@ namespace Google.Protobuf.DescriptorProtos { ...@@ -2440,6 +2660,9 @@ namespace Google.Protobuf.DescriptorProtos {
get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_FileOptions__FieldAccessorTable; } get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_FileOptions__FieldAccessorTable; }
} }
private bool _frozen = false;
public bool IsFrozen { get { return _frozen; } }
public FileOptions() { } public FileOptions() { }
public FileOptions(FileOptions other) { public FileOptions(FileOptions other) {
...@@ -2464,118 +2687,154 @@ namespace Google.Protobuf.DescriptorProtos { ...@@ -2464,118 +2687,154 @@ namespace Google.Protobuf.DescriptorProtos {
return new FileOptions(this); return new FileOptions(this);
} }
public void Freeze() {
if (IsFrozen) {
return;
}
_frozen = true;
uninterpretedOption_.Freeze();
}
public const int JavaPackageFieldNumber = 1; public const int JavaPackageFieldNumber = 1;
private string javaPackage_ = ""; private string javaPackage_ = "";
public string JavaPackage { public string JavaPackage {
get { return javaPackage_; } get { return javaPackage_; }
set { javaPackage_ = value ?? ""; } set {
pb::Freezable.CheckMutable(this);
javaPackage_ = value ?? "";
}
} }
public const int JavaOuterClassnameFieldNumber = 8; public const int JavaOuterClassnameFieldNumber = 8;
private string javaOuterClassname_ = ""; private string javaOuterClassname_ = "";
public string JavaOuterClassname { public string JavaOuterClassname {
get { return javaOuterClassname_; } get { return javaOuterClassname_; }
set { javaOuterClassname_ = value ?? ""; } set {
pb::Freezable.CheckMutable(this);
javaOuterClassname_ = value ?? "";
}
} }
public const int JavaMultipleFilesFieldNumber = 10; public const int JavaMultipleFilesFieldNumber = 10;
private bool javaMultipleFiles_; private bool javaMultipleFiles_;
public bool JavaMultipleFiles { public bool JavaMultipleFiles {
get { return javaMultipleFiles_; } get { return javaMultipleFiles_; }
set { javaMultipleFiles_ = value; } set {
pb::Freezable.CheckMutable(this);
javaMultipleFiles_ = value;
}
} }
public const int JavaGenerateEqualsAndHashFieldNumber = 20; public const int JavaGenerateEqualsAndHashFieldNumber = 20;
private bool javaGenerateEqualsAndHash_; private bool javaGenerateEqualsAndHash_;
public bool JavaGenerateEqualsAndHash { public bool JavaGenerateEqualsAndHash {
get { return javaGenerateEqualsAndHash_; } get { return javaGenerateEqualsAndHash_; }
set { javaGenerateEqualsAndHash_ = value; } set {
pb::Freezable.CheckMutable(this);
javaGenerateEqualsAndHash_ = value;
}
} }
public const int JavaStringCheckUtf8FieldNumber = 27; public const int JavaStringCheckUtf8FieldNumber = 27;
private bool javaStringCheckUtf8_; private bool javaStringCheckUtf8_;
public bool JavaStringCheckUtf8 { public bool JavaStringCheckUtf8 {
get { return javaStringCheckUtf8_; } get { return javaStringCheckUtf8_; }
set { javaStringCheckUtf8_ = value; } set {
pb::Freezable.CheckMutable(this);
javaStringCheckUtf8_ = value;
}
} }
public const int OptimizeForFieldNumber = 9; public const int OptimizeForFieldNumber = 9;
private global::Google.Protobuf.DescriptorProtos.FileOptions.Types.OptimizeMode optimizeFor_ = global::Google.Protobuf.DescriptorProtos.FileOptions.Types.OptimizeMode.SPEED; private global::Google.Protobuf.DescriptorProtos.FileOptions.Types.OptimizeMode optimizeFor_ = global::Google.Protobuf.DescriptorProtos.FileOptions.Types.OptimizeMode.SPEED;
public global::Google.Protobuf.DescriptorProtos.FileOptions.Types.OptimizeMode OptimizeFor { public global::Google.Protobuf.DescriptorProtos.FileOptions.Types.OptimizeMode OptimizeFor {
get { return optimizeFor_; } get { return optimizeFor_; }
set { optimizeFor_ = value; } set {
pb::Freezable.CheckMutable(this);
optimizeFor_ = value;
}
} }
public const int GoPackageFieldNumber = 11; public const int GoPackageFieldNumber = 11;
private string goPackage_ = ""; private string goPackage_ = "";
public string GoPackage { public string GoPackage {
get { return goPackage_; } get { return goPackage_; }
set { goPackage_ = value ?? ""; } set {
pb::Freezable.CheckMutable(this);
goPackage_ = value ?? "";
}
} }
public const int CcGenericServicesFieldNumber = 16; public const int CcGenericServicesFieldNumber = 16;
private bool ccGenericServices_; private bool ccGenericServices_;
public bool CcGenericServices { public bool CcGenericServices {
get { return ccGenericServices_; } get { return ccGenericServices_; }
set { ccGenericServices_ = value; } set {
pb::Freezable.CheckMutable(this);
ccGenericServices_ = value;
}
} }
public const int JavaGenericServicesFieldNumber = 17; public const int JavaGenericServicesFieldNumber = 17;
private bool javaGenericServices_; private bool javaGenericServices_;
public bool JavaGenericServices { public bool JavaGenericServices {
get { return javaGenericServices_; } get { return javaGenericServices_; }
set { javaGenericServices_ = value; } set {
pb::Freezable.CheckMutable(this);
javaGenericServices_ = value;
}
} }
public const int PyGenericServicesFieldNumber = 18; public const int PyGenericServicesFieldNumber = 18;
private bool pyGenericServices_; private bool pyGenericServices_;
public bool PyGenericServices { public bool PyGenericServices {
get { return pyGenericServices_; } get { return pyGenericServices_; }
set { pyGenericServices_ = value; } set {
pb::Freezable.CheckMutable(this);
pyGenericServices_ = value;
}
} }
public const int DeprecatedFieldNumber = 23; public const int DeprecatedFieldNumber = 23;
private bool deprecated_; private bool deprecated_;
public bool Deprecated { public bool Deprecated {
get { return deprecated_; } get { return deprecated_; }
set { deprecated_ = value; } set {
pb::Freezable.CheckMutable(this);
deprecated_ = value;
}
} }
public const int CcEnableArenasFieldNumber = 31; public const int CcEnableArenasFieldNumber = 31;
private bool ccEnableArenas_; private bool ccEnableArenas_;
public bool CcEnableArenas { public bool CcEnableArenas {
get { return ccEnableArenas_; } get { return ccEnableArenas_; }
set { ccEnableArenas_ = value; } set {
pb::Freezable.CheckMutable(this);
ccEnableArenas_ = value;
}
} }
public const int ObjcClassPrefixFieldNumber = 36; public const int ObjcClassPrefixFieldNumber = 36;
private string objcClassPrefix_ = ""; private string objcClassPrefix_ = "";
public string ObjcClassPrefix { public string ObjcClassPrefix {
get { return objcClassPrefix_; } get { return objcClassPrefix_; }
set { objcClassPrefix_ = value ?? ""; } set {
pb::Freezable.CheckMutable(this);
objcClassPrefix_ = value ?? "";
}
} }
public const int CsharpNamespaceFieldNumber = 37; public const int CsharpNamespaceFieldNumber = 37;
private string csharpNamespace_ = ""; private string csharpNamespace_ = "";
public string CsharpNamespace { public string CsharpNamespace {
get { return csharpNamespace_; } get { return csharpNamespace_; }
set { csharpNamespace_ = value ?? ""; } set {
pb::Freezable.CheckMutable(this);
csharpNamespace_ = value ?? "";
}
} }
public const int UninterpretedOptionFieldNumber = 999; public const int UninterpretedOptionFieldNumber = 999;
private readonly pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption> uninterpretedOption_ = new pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption>(); private readonly pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption> uninterpretedOption_ = new pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption>();
public pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption> UninterpretedOption { public pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption> UninterpretedOption {
...@@ -2898,6 +3157,9 @@ namespace Google.Protobuf.DescriptorProtos { ...@@ -2898,6 +3157,9 @@ namespace Google.Protobuf.DescriptorProtos {
get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_MessageOptions__FieldAccessorTable; } get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_MessageOptions__FieldAccessorTable; }
} }
private bool _frozen = false;
public bool IsFrozen { get { return _frozen; } }
public MessageOptions() { } public MessageOptions() { }
public MessageOptions(MessageOptions other) { public MessageOptions(MessageOptions other) {
...@@ -2912,38 +3174,54 @@ namespace Google.Protobuf.DescriptorProtos { ...@@ -2912,38 +3174,54 @@ namespace Google.Protobuf.DescriptorProtos {
return new MessageOptions(this); return new MessageOptions(this);
} }
public void Freeze() {
if (IsFrozen) {
return;
}
_frozen = true;
uninterpretedOption_.Freeze();
}
public const int MessageSetWireFormatFieldNumber = 1; public const int MessageSetWireFormatFieldNumber = 1;
private bool messageSetWireFormat_; private bool messageSetWireFormat_;
public bool MessageSetWireFormat { public bool MessageSetWireFormat {
get { return messageSetWireFormat_; } get { return messageSetWireFormat_; }
set { messageSetWireFormat_ = value; } set {
pb::Freezable.CheckMutable(this);
messageSetWireFormat_ = value;
}
} }
public const int NoStandardDescriptorAccessorFieldNumber = 2; public const int NoStandardDescriptorAccessorFieldNumber = 2;
private bool noStandardDescriptorAccessor_; private bool noStandardDescriptorAccessor_;
public bool NoStandardDescriptorAccessor { public bool NoStandardDescriptorAccessor {
get { return noStandardDescriptorAccessor_; } get { return noStandardDescriptorAccessor_; }
set { noStandardDescriptorAccessor_ = value; } set {
pb::Freezable.CheckMutable(this);
noStandardDescriptorAccessor_ = value;
}
} }
public const int DeprecatedFieldNumber = 3; public const int DeprecatedFieldNumber = 3;
private bool deprecated_; private bool deprecated_;
public bool Deprecated { public bool Deprecated {
get { return deprecated_; } get { return deprecated_; }
set { deprecated_ = value; } set {
pb::Freezable.CheckMutable(this);
deprecated_ = value;
}
} }
public const int MapEntryFieldNumber = 7; public const int MapEntryFieldNumber = 7;
private bool mapEntry_; private bool mapEntry_;
public bool MapEntry { public bool MapEntry {
get { return mapEntry_; } get { return mapEntry_; }
set { mapEntry_ = value; } set {
pb::Freezable.CheckMutable(this);
mapEntry_ = value;
}
} }
public const int UninterpretedOptionFieldNumber = 999; public const int UninterpretedOptionFieldNumber = 999;
private readonly pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption> uninterpretedOption_ = new pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption>(); private readonly pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption> uninterpretedOption_ = new pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption>();
public pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption> UninterpretedOption { public pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption> UninterpretedOption {
...@@ -3094,6 +3372,9 @@ namespace Google.Protobuf.DescriptorProtos { ...@@ -3094,6 +3372,9 @@ namespace Google.Protobuf.DescriptorProtos {
get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_FieldOptions__FieldAccessorTable; } get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_FieldOptions__FieldAccessorTable; }
} }
private bool _frozen = false;
public bool IsFrozen { get { return _frozen; } }
public FieldOptions() { } public FieldOptions() { }
public FieldOptions(FieldOptions other) { public FieldOptions(FieldOptions other) {
...@@ -3110,54 +3391,74 @@ namespace Google.Protobuf.DescriptorProtos { ...@@ -3110,54 +3391,74 @@ namespace Google.Protobuf.DescriptorProtos {
return new FieldOptions(this); return new FieldOptions(this);
} }
public void Freeze() {
if (IsFrozen) {
return;
}
_frozen = true;
uninterpretedOption_.Freeze();
}
public const int CtypeFieldNumber = 1; public const int CtypeFieldNumber = 1;
private global::Google.Protobuf.DescriptorProtos.FieldOptions.Types.CType ctype_ = global::Google.Protobuf.DescriptorProtos.FieldOptions.Types.CType.STRING; private global::Google.Protobuf.DescriptorProtos.FieldOptions.Types.CType ctype_ = global::Google.Protobuf.DescriptorProtos.FieldOptions.Types.CType.STRING;
public global::Google.Protobuf.DescriptorProtos.FieldOptions.Types.CType Ctype { public global::Google.Protobuf.DescriptorProtos.FieldOptions.Types.CType Ctype {
get { return ctype_; } get { return ctype_; }
set { ctype_ = value; } set {
pb::Freezable.CheckMutable(this);
ctype_ = value;
}
} }
public const int PackedFieldNumber = 2; public const int PackedFieldNumber = 2;
private bool packed_; private bool packed_;
public bool Packed { public bool Packed {
get { return packed_; } get { return packed_; }
set { packed_ = value; } set {
pb::Freezable.CheckMutable(this);
packed_ = value;
}
} }
public const int JstypeFieldNumber = 6; public const int JstypeFieldNumber = 6;
private global::Google.Protobuf.DescriptorProtos.FieldOptions.Types.JSType jstype_ = global::Google.Protobuf.DescriptorProtos.FieldOptions.Types.JSType.JS_NORMAL; private global::Google.Protobuf.DescriptorProtos.FieldOptions.Types.JSType jstype_ = global::Google.Protobuf.DescriptorProtos.FieldOptions.Types.JSType.JS_NORMAL;
public global::Google.Protobuf.DescriptorProtos.FieldOptions.Types.JSType Jstype { public global::Google.Protobuf.DescriptorProtos.FieldOptions.Types.JSType Jstype {
get { return jstype_; } get { return jstype_; }
set { jstype_ = value; } set {
pb::Freezable.CheckMutable(this);
jstype_ = value;
}
} }
public const int LazyFieldNumber = 5; public const int LazyFieldNumber = 5;
private bool lazy_; private bool lazy_;
public bool Lazy { public bool Lazy {
get { return lazy_; } get { return lazy_; }
set { lazy_ = value; } set {
pb::Freezable.CheckMutable(this);
lazy_ = value;
}
} }
public const int DeprecatedFieldNumber = 3; public const int DeprecatedFieldNumber = 3;
private bool deprecated_; private bool deprecated_;
public bool Deprecated { public bool Deprecated {
get { return deprecated_; } get { return deprecated_; }
set { deprecated_ = value; } set {
pb::Freezable.CheckMutable(this);
deprecated_ = value;
}
} }
public const int WeakFieldNumber = 10; public const int WeakFieldNumber = 10;
private bool weak_; private bool weak_;
public bool Weak { public bool Weak {
get { return weak_; } get { return weak_; }
set { weak_ = value; } set {
pb::Freezable.CheckMutable(this);
weak_ = value;
}
} }
public const int UninterpretedOptionFieldNumber = 999; public const int UninterpretedOptionFieldNumber = 999;
private readonly pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption> uninterpretedOption_ = new pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption>(); private readonly pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption> uninterpretedOption_ = new pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption>();
public pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption> UninterpretedOption { public pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption> UninterpretedOption {
...@@ -3358,6 +3659,9 @@ namespace Google.Protobuf.DescriptorProtos { ...@@ -3358,6 +3659,9 @@ namespace Google.Protobuf.DescriptorProtos {
get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_EnumOptions__FieldAccessorTable; } get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_EnumOptions__FieldAccessorTable; }
} }
private bool _frozen = false;
public bool IsFrozen { get { return _frozen; } }
public EnumOptions() { } public EnumOptions() { }
public EnumOptions(EnumOptions other) { public EnumOptions(EnumOptions other) {
...@@ -3370,22 +3674,34 @@ namespace Google.Protobuf.DescriptorProtos { ...@@ -3370,22 +3674,34 @@ namespace Google.Protobuf.DescriptorProtos {
return new EnumOptions(this); return new EnumOptions(this);
} }
public void Freeze() {
if (IsFrozen) {
return;
}
_frozen = true;
uninterpretedOption_.Freeze();
}
public const int AllowAliasFieldNumber = 2; public const int AllowAliasFieldNumber = 2;
private bool allowAlias_; private bool allowAlias_;
public bool AllowAlias { public bool AllowAlias {
get { return allowAlias_; } get { return allowAlias_; }
set { allowAlias_ = value; } set {
pb::Freezable.CheckMutable(this);
allowAlias_ = value;
}
} }
public const int DeprecatedFieldNumber = 3; public const int DeprecatedFieldNumber = 3;
private bool deprecated_; private bool deprecated_;
public bool Deprecated { public bool Deprecated {
get { return deprecated_; } get { return deprecated_; }
set { deprecated_ = value; } set {
pb::Freezable.CheckMutable(this);
deprecated_ = value;
}
} }
public const int UninterpretedOptionFieldNumber = 999; public const int UninterpretedOptionFieldNumber = 999;
private readonly pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption> uninterpretedOption_ = new pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption>(); private readonly pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption> uninterpretedOption_ = new pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption>();
public pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption> UninterpretedOption { public pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption> UninterpretedOption {
...@@ -3504,6 +3820,9 @@ namespace Google.Protobuf.DescriptorProtos { ...@@ -3504,6 +3820,9 @@ namespace Google.Protobuf.DescriptorProtos {
get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_EnumValueOptions__FieldAccessorTable; } get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_EnumValueOptions__FieldAccessorTable; }
} }
private bool _frozen = false;
public bool IsFrozen { get { return _frozen; } }
public EnumValueOptions() { } public EnumValueOptions() { }
public EnumValueOptions(EnumValueOptions other) { public EnumValueOptions(EnumValueOptions other) {
...@@ -3515,14 +3834,24 @@ namespace Google.Protobuf.DescriptorProtos { ...@@ -3515,14 +3834,24 @@ namespace Google.Protobuf.DescriptorProtos {
return new EnumValueOptions(this); return new EnumValueOptions(this);
} }
public void Freeze() {
if (IsFrozen) {
return;
}
_frozen = true;
uninterpretedOption_.Freeze();
}
public const int DeprecatedFieldNumber = 1; public const int DeprecatedFieldNumber = 1;
private bool deprecated_; private bool deprecated_;
public bool Deprecated { public bool Deprecated {
get { return deprecated_; } get { return deprecated_; }
set { deprecated_ = value; } set {
pb::Freezable.CheckMutable(this);
deprecated_ = value;
}
} }
public const int UninterpretedOptionFieldNumber = 999; public const int UninterpretedOptionFieldNumber = 999;
private readonly pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption> uninterpretedOption_ = new pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption>(); private readonly pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption> uninterpretedOption_ = new pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption>();
public pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption> UninterpretedOption { public pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption> UninterpretedOption {
...@@ -3625,6 +3954,9 @@ namespace Google.Protobuf.DescriptorProtos { ...@@ -3625,6 +3954,9 @@ namespace Google.Protobuf.DescriptorProtos {
get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_ServiceOptions__FieldAccessorTable; } get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_ServiceOptions__FieldAccessorTable; }
} }
private bool _frozen = false;
public bool IsFrozen { get { return _frozen; } }
public ServiceOptions() { } public ServiceOptions() { }
public ServiceOptions(ServiceOptions other) { public ServiceOptions(ServiceOptions other) {
...@@ -3636,14 +3968,24 @@ namespace Google.Protobuf.DescriptorProtos { ...@@ -3636,14 +3968,24 @@ namespace Google.Protobuf.DescriptorProtos {
return new ServiceOptions(this); return new ServiceOptions(this);
} }
public void Freeze() {
if (IsFrozen) {
return;
}
_frozen = true;
uninterpretedOption_.Freeze();
}
public const int DeprecatedFieldNumber = 33; public const int DeprecatedFieldNumber = 33;
private bool deprecated_; private bool deprecated_;
public bool Deprecated { public bool Deprecated {
get { return deprecated_; } get { return deprecated_; }
set { deprecated_ = value; } set {
pb::Freezable.CheckMutable(this);
deprecated_ = value;
}
} }
public const int UninterpretedOptionFieldNumber = 999; public const int UninterpretedOptionFieldNumber = 999;
private readonly pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption> uninterpretedOption_ = new pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption>(); private readonly pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption> uninterpretedOption_ = new pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption>();
public pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption> UninterpretedOption { public pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption> UninterpretedOption {
...@@ -3746,6 +4088,9 @@ namespace Google.Protobuf.DescriptorProtos { ...@@ -3746,6 +4088,9 @@ namespace Google.Protobuf.DescriptorProtos {
get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_MethodOptions__FieldAccessorTable; } get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_MethodOptions__FieldAccessorTable; }
} }
private bool _frozen = false;
public bool IsFrozen { get { return _frozen; } }
public MethodOptions() { } public MethodOptions() { }
public MethodOptions(MethodOptions other) { public MethodOptions(MethodOptions other) {
...@@ -3757,14 +4102,24 @@ namespace Google.Protobuf.DescriptorProtos { ...@@ -3757,14 +4102,24 @@ namespace Google.Protobuf.DescriptorProtos {
return new MethodOptions(this); return new MethodOptions(this);
} }
public void Freeze() {
if (IsFrozen) {
return;
}
_frozen = true;
uninterpretedOption_.Freeze();
}
public const int DeprecatedFieldNumber = 33; public const int DeprecatedFieldNumber = 33;
private bool deprecated_; private bool deprecated_;
public bool Deprecated { public bool Deprecated {
get { return deprecated_; } get { return deprecated_; }
set { deprecated_ = value; } set {
pb::Freezable.CheckMutable(this);
deprecated_ = value;
}
} }
public const int UninterpretedOptionFieldNumber = 999; public const int UninterpretedOptionFieldNumber = 999;
private readonly pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption> uninterpretedOption_ = new pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption>(); private readonly pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption> uninterpretedOption_ = new pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption>();
public pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption> UninterpretedOption { public pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption> UninterpretedOption {
...@@ -3867,6 +4222,9 @@ namespace Google.Protobuf.DescriptorProtos { ...@@ -3867,6 +4222,9 @@ namespace Google.Protobuf.DescriptorProtos {
get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_UninterpretedOption__FieldAccessorTable; } get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_UninterpretedOption__FieldAccessorTable; }
} }
private bool _frozen = false;
public bool IsFrozen { get { return _frozen; } }
public UninterpretedOption() { } public UninterpretedOption() { }
public UninterpretedOption(UninterpretedOption other) { public UninterpretedOption(UninterpretedOption other) {
...@@ -3883,6 +4241,14 @@ namespace Google.Protobuf.DescriptorProtos { ...@@ -3883,6 +4241,14 @@ namespace Google.Protobuf.DescriptorProtos {
return new UninterpretedOption(this); return new UninterpretedOption(this);
} }
public void Freeze() {
if (IsFrozen) {
return;
}
_frozen = true;
name_.Freeze();
}
public const int NameFieldNumber = 2; public const int NameFieldNumber = 2;
private readonly pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Types.NamePart> name_ = new pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Types.NamePart>(); private readonly pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Types.NamePart> name_ = new pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Types.NamePart>();
public pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Types.NamePart> Name { public pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Types.NamePart> Name {
...@@ -3893,50 +4259,62 @@ namespace Google.Protobuf.DescriptorProtos { ...@@ -3893,50 +4259,62 @@ namespace Google.Protobuf.DescriptorProtos {
private string identifierValue_ = ""; private string identifierValue_ = "";
public string IdentifierValue { public string IdentifierValue {
get { return identifierValue_; } get { return identifierValue_; }
set { identifierValue_ = value ?? ""; } set {
pb::Freezable.CheckMutable(this);
identifierValue_ = value ?? "";
}
} }
public const int PositiveIntValueFieldNumber = 4; public const int PositiveIntValueFieldNumber = 4;
private ulong positiveIntValue_; private ulong positiveIntValue_;
public ulong PositiveIntValue { public ulong PositiveIntValue {
get { return positiveIntValue_; } get { return positiveIntValue_; }
set { positiveIntValue_ = value; } set {
pb::Freezable.CheckMutable(this);
positiveIntValue_ = value;
}
} }
public const int NegativeIntValueFieldNumber = 5; public const int NegativeIntValueFieldNumber = 5;
private long negativeIntValue_; private long negativeIntValue_;
public long NegativeIntValue { public long NegativeIntValue {
get { return negativeIntValue_; } get { return negativeIntValue_; }
set { negativeIntValue_ = value; } set {
pb::Freezable.CheckMutable(this);
negativeIntValue_ = value;
}
} }
public const int DoubleValueFieldNumber = 6; public const int DoubleValueFieldNumber = 6;
private double doubleValue_; private double doubleValue_;
public double DoubleValue { public double DoubleValue {
get { return doubleValue_; } get { return doubleValue_; }
set { doubleValue_ = value; } set {
pb::Freezable.CheckMutable(this);
doubleValue_ = value;
}
} }
public const int StringValueFieldNumber = 7; public const int StringValueFieldNumber = 7;
private pb::ByteString stringValue_ = pb::ByteString.Empty; private pb::ByteString stringValue_ = pb::ByteString.Empty;
public pb::ByteString StringValue { public pb::ByteString StringValue {
get { return stringValue_; } get { return stringValue_; }
set { stringValue_ = value ?? pb::ByteString.Empty; } set {
pb::Freezable.CheckMutable(this);
stringValue_ = value ?? pb::ByteString.Empty;
}
} }
public const int AggregateValueFieldNumber = 8; public const int AggregateValueFieldNumber = 8;
private string aggregateValue_ = ""; private string aggregateValue_ = "";
public string AggregateValue { public string AggregateValue {
get { return aggregateValue_; } get { return aggregateValue_; }
set { aggregateValue_ = value ?? ""; } set {
pb::Freezable.CheckMutable(this);
aggregateValue_ = value ?? "";
}
} }
public override bool Equals(object other) { public override bool Equals(object other) {
return Equals(other as UninterpretedOption); return Equals(other as UninterpretedOption);
} }
...@@ -4114,6 +4492,9 @@ namespace Google.Protobuf.DescriptorProtos { ...@@ -4114,6 +4492,9 @@ namespace Google.Protobuf.DescriptorProtos {
get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_UninterpretedOption_NamePart__FieldAccessorTable; } get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_UninterpretedOption_NamePart__FieldAccessorTable; }
} }
private bool _frozen = false;
public bool IsFrozen { get { return _frozen; } }
public NamePart() { } public NamePart() { }
public NamePart(NamePart other) { public NamePart(NamePart other) {
...@@ -4125,22 +4506,33 @@ namespace Google.Protobuf.DescriptorProtos { ...@@ -4125,22 +4506,33 @@ namespace Google.Protobuf.DescriptorProtos {
return new NamePart(this); return new NamePart(this);
} }
public void Freeze() {
if (IsFrozen) {
return;
}
_frozen = true;
}
public const int NamePart_FieldNumber = 1; public const int NamePart_FieldNumber = 1;
private string namePart_ = ""; private string namePart_ = "";
public string NamePart_ { public string NamePart_ {
get { return namePart_; } get { return namePart_; }
set { namePart_ = value ?? ""; } set {
pb::Freezable.CheckMutable(this);
namePart_ = value ?? "";
}
} }
public const int IsExtensionFieldNumber = 2; public const int IsExtensionFieldNumber = 2;
private bool isExtension_; private bool isExtension_;
public bool IsExtension { public bool IsExtension {
get { return isExtension_; } get { return isExtension_; }
set { isExtension_ = value; } set {
pb::Freezable.CheckMutable(this);
isExtension_ = value;
}
} }
public override bool Equals(object other) { public override bool Equals(object other) {
return Equals(other as NamePart); return Equals(other as NamePart);
} }
...@@ -4242,6 +4634,9 @@ namespace Google.Protobuf.DescriptorProtos { ...@@ -4242,6 +4634,9 @@ namespace Google.Protobuf.DescriptorProtos {
get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_SourceCodeInfo__FieldAccessorTable; } get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_SourceCodeInfo__FieldAccessorTable; }
} }
private bool _frozen = false;
public bool IsFrozen { get { return _frozen; } }
public SourceCodeInfo() { } public SourceCodeInfo() { }
public SourceCodeInfo(SourceCodeInfo other) { public SourceCodeInfo(SourceCodeInfo other) {
...@@ -4252,6 +4647,14 @@ namespace Google.Protobuf.DescriptorProtos { ...@@ -4252,6 +4647,14 @@ namespace Google.Protobuf.DescriptorProtos {
return new SourceCodeInfo(this); return new SourceCodeInfo(this);
} }
public void Freeze() {
if (IsFrozen) {
return;
}
_frozen = true;
location_.Freeze();
}
public const int LocationFieldNumber = 1; public const int LocationFieldNumber = 1;
private readonly pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.SourceCodeInfo.Types.Location> location_ = new pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.SourceCodeInfo.Types.Location>(); private readonly pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.SourceCodeInfo.Types.Location> location_ = new pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.SourceCodeInfo.Types.Location>();
public pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.SourceCodeInfo.Types.Location> Location { public pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.SourceCodeInfo.Types.Location> Location {
...@@ -4339,6 +4742,9 @@ namespace Google.Protobuf.DescriptorProtos { ...@@ -4339,6 +4742,9 @@ namespace Google.Protobuf.DescriptorProtos {
get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_SourceCodeInfo_Location__FieldAccessorTable; } get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_SourceCodeInfo_Location__FieldAccessorTable; }
} }
private bool _frozen = false;
public bool IsFrozen { get { return _frozen; } }
public Location() { } public Location() { }
public Location(Location other) { public Location(Location other) {
...@@ -4353,6 +4759,16 @@ namespace Google.Protobuf.DescriptorProtos { ...@@ -4353,6 +4759,16 @@ namespace Google.Protobuf.DescriptorProtos {
return new Location(this); return new Location(this);
} }
public void Freeze() {
if (IsFrozen) {
return;
}
_frozen = true;
path_.Freeze();
span_.Freeze();
leadingDetachedComments_.Freeze();
}
public const int PathFieldNumber = 1; public const int PathFieldNumber = 1;
private readonly pbc::RepeatedField<int> path_ = new pbc::RepeatedField<int>(); private readonly pbc::RepeatedField<int> path_ = new pbc::RepeatedField<int>();
public pbc::RepeatedField<int> Path { public pbc::RepeatedField<int> Path {
...@@ -4369,18 +4785,22 @@ namespace Google.Protobuf.DescriptorProtos { ...@@ -4369,18 +4785,22 @@ namespace Google.Protobuf.DescriptorProtos {
private string leadingComments_ = ""; private string leadingComments_ = "";
public string LeadingComments { public string LeadingComments {
get { return leadingComments_; } get { return leadingComments_; }
set { leadingComments_ = value ?? ""; } set {
pb::Freezable.CheckMutable(this);
leadingComments_ = value ?? "";
}
} }
public const int TrailingCommentsFieldNumber = 4; public const int TrailingCommentsFieldNumber = 4;
private string trailingComments_ = ""; private string trailingComments_ = "";
public string TrailingComments { public string TrailingComments {
get { return trailingComments_; } get { return trailingComments_; }
set { trailingComments_ = value ?? ""; } set {
pb::Freezable.CheckMutable(this);
trailingComments_ = value ?? "";
}
} }
public const int LeadingDetachedCommentsFieldNumber = 6; public const int LeadingDetachedCommentsFieldNumber = 6;
private readonly pbc::RepeatedField<string> leadingDetachedComments_ = new pbc::RepeatedField<string>(); private readonly pbc::RepeatedField<string> leadingDetachedComments_ = new pbc::RepeatedField<string>();
public pbc::RepeatedField<string> LeadingDetachedComments { public pbc::RepeatedField<string> LeadingDetachedComments {
......
#region Copyright notice and license
// Protocol Buffers - Google's data interchange format
// Copyright 2015 Google Inc. All rights reserved.
// http://github.com/google/protobuf
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#endregion
using System;
namespace Google.Protobuf
{
/// <summary>
/// Extension methods for <see cref="IFreezable"/> types.
/// </summary>
public static class Freezable
{
/// <summary>
/// Throws an <see cref="InvalidOperationException"/> if <paramref name="target"/>
/// is frozen.
/// </summary>
/// <remarks>
/// This is a convenience methods that freezable types can call before all
/// mutations, to protect frozen objects.
/// </remarks>
public static void CheckMutable(this IFreezable target)
{
if (target.IsFrozen)
{
throw new InvalidOperationException("Attempt to mutate frozen object");
}
}
}
}
...@@ -41,6 +41,7 @@ namespace Google.Protobuf ...@@ -41,6 +41,7 @@ namespace Google.Protobuf
{ {
// TODO(jonskeet): Do we want a "weak" (non-generic) version of IReflectedMessage? // TODO(jonskeet): Do we want a "weak" (non-generic) version of IReflectedMessage?
// TODO(jonskeet): Split these interfaces into separate files when we're happy with them.
/// <summary> /// <summary>
/// Reflection support for a specific message type. message /// Reflection support for a specific message type. message
...@@ -85,7 +86,7 @@ namespace Google.Protobuf ...@@ -85,7 +86,7 @@ namespace Google.Protobuf
/// the implementation class. /// the implementation class.
/// </summary> /// </summary>
/// <typeparam name="T">The message type.</typeparam> /// <typeparam name="T">The message type.</typeparam>
public interface IMessage<T> : IMessage, IEquatable<T>, IDeepCloneable<T> where T : IMessage<T> public interface IMessage<T> : IMessage, IEquatable<T>, IDeepCloneable<T>, IFreezable where T : IMessage<T>
{ {
/// <summary> /// <summary>
/// Merges the given message into this one. /// Merges the given message into this one.
...@@ -102,6 +103,11 @@ namespace Google.Protobuf ...@@ -102,6 +103,11 @@ namespace Google.Protobuf
/// All generated messages implement this interface, but so do some non-message types. /// All generated messages implement this interface, but so do some non-message types.
/// Additionally, due to the type constraint on <c>T</c> in <see cref="IMessage{T}"/>, /// Additionally, due to the type constraint on <c>T</c> in <see cref="IMessage{T}"/>,
/// it is simpler to keep this as a separate interface. /// it is simpler to keep this as a separate interface.
/// </para>
/// <para>
/// Freezable types which implement this interface should always return a mutable clone,
/// even if the original object is frozen.
/// </para>
/// </remarks> /// </remarks>
/// <typeparam name="T">The type itself, returned by the <see cref="Clone"/> method.</typeparam> /// <typeparam name="T">The type itself, returned by the <see cref="Clone"/> method.</typeparam>
public interface IDeepCloneable<T> public interface IDeepCloneable<T>
...@@ -112,4 +118,32 @@ namespace Google.Protobuf ...@@ -112,4 +118,32 @@ namespace Google.Protobuf
/// <returns>A deep clone of this object.</returns> /// <returns>A deep clone of this object.</returns>
T Clone(); T Clone();
} }
/// <summary>
/// Provides a mechanism for freezing a message (or repeated field collection)
/// to make it immutable.
/// </summary>
/// <remarks>
/// Implementations are under no obligation to make this thread-safe: if a freezable
/// type instance is shared between threads before being frozen, and one thread then
/// freezes it, it is possible for other threads to make changes during the freezing
/// operation and also to observe stale values for mutated fields. Objects should be
/// frozen before being made available to other threads.
/// </remarks>
public interface IFreezable
{
/// <summary>
/// Freezes this object.
/// </summary>
/// <remarks>
/// If the object is already frozen, this method has no effect.
/// </remarks>
void Freeze();
/// <summary>
/// Returns whether or not this object is frozen (and therefore immutable).
/// </summary>
/// <value><c>true</c> if this object is frozen; <c>false</c> otherwise.</value>
bool IsFrozen { get; }
}
} }
...@@ -85,6 +85,7 @@ ...@@ -85,6 +85,7 @@
<Compile Include="Descriptors\PackageDescriptor.cs" /> <Compile Include="Descriptors\PackageDescriptor.cs" />
<Compile Include="Descriptors\ServiceDescriptor.cs" /> <Compile Include="Descriptors\ServiceDescriptor.cs" />
<Compile Include="FrameworkPortability.cs" /> <Compile Include="FrameworkPortability.cs" />
<Compile Include="Freezable.cs" />
<Compile Include="MessageExtensions.cs" /> <Compile Include="MessageExtensions.cs" />
<Compile Include="FieldAccess\FieldAccessorBase.cs" /> <Compile Include="FieldAccess\FieldAccessorBase.cs" />
<Compile Include="FieldAccess\ReflectionUtil.cs" /> <Compile Include="FieldAccess\ReflectionUtil.cs" />
......
...@@ -107,6 +107,11 @@ FieldGeneratorBase::FieldGeneratorBase(const FieldDescriptor* descriptor, ...@@ -107,6 +107,11 @@ FieldGeneratorBase::FieldGeneratorBase(const FieldDescriptor* descriptor,
FieldGeneratorBase::~FieldGeneratorBase() { FieldGeneratorBase::~FieldGeneratorBase() {
} }
void FieldGeneratorBase::GenerateFreezingCode(io::Printer* printer) {
// No-op: only message fields and repeated fields need
// special handling for freezing, so default to not generating any code.
}
void FieldGeneratorBase::AddDeprecatedFlag(io::Printer* printer) { void FieldGeneratorBase::AddDeprecatedFlag(io::Printer* printer) {
if (descriptor_->options().deprecated()) if (descriptor_->options().deprecated())
{ {
......
...@@ -48,6 +48,7 @@ class FieldGeneratorBase : public SourceGeneratorBase { ...@@ -48,6 +48,7 @@ class FieldGeneratorBase : public SourceGeneratorBase {
~FieldGeneratorBase(); ~FieldGeneratorBase();
virtual void GenerateCloningCode(io::Printer* printer) = 0; virtual void GenerateCloningCode(io::Printer* printer) = 0;
virtual void GenerateFreezingCode(io::Printer* printer);
virtual void GenerateMembers(io::Printer* printer) = 0; virtual void GenerateMembers(io::Printer* printer) = 0;
virtual void GenerateMergingCode(io::Printer* printer) = 0; virtual void GenerateMergingCode(io::Printer* printer) = 0;
virtual void GenerateParsingCode(io::Printer* printer) = 0; virtual void GenerateParsingCode(io::Printer* printer) = 0;
......
...@@ -211,7 +211,9 @@ void MessageGenerator::Generate(io::Printer* printer) { ...@@ -211,7 +211,9 @@ void MessageGenerator::Generate(io::Printer* printer) {
"public pb::FieldAccess.FieldAccessorTable<$class_name$> Fields {\n" "public pb::FieldAccess.FieldAccessorTable<$class_name$> Fields {\n"
" get { return $umbrella_class_name$.internal__$identifier$__FieldAccessorTable; }\n" " get { return $umbrella_class_name$.internal__$identifier$__FieldAccessorTable; }\n"
"}\n" "}\n"
"\n"); "\n"
"private bool _frozen = false;\n"
"public bool IsFrozen { get { return _frozen; } }\n\n");
// Parameterless constructor // Parameterless constructor
printer->Print( printer->Print(
...@@ -219,6 +221,7 @@ void MessageGenerator::Generate(io::Printer* printer) { ...@@ -219,6 +221,7 @@ void MessageGenerator::Generate(io::Printer* printer) {
"public $class_name$() { }\n\n"); "public $class_name$() { }\n\n");
GenerateCloningCode(printer); GenerateCloningCode(printer);
GenerateFreezingCode(printer);
// Fields/properties // Fields/properties
for (int i = 0; i < descriptor_->field_count(); i++) { for (int i = 0; i < descriptor_->field_count(); i++) {
...@@ -260,6 +263,7 @@ void MessageGenerator::Generate(io::Printer* printer) { ...@@ -260,6 +263,7 @@ void MessageGenerator::Generate(io::Printer* printer) {
" get { return $name$Case_; }\n" " get { return $name$Case_; }\n"
"}\n\n" "}\n\n"
"public void Clear$property_name$() {\n" "public void Clear$property_name$() {\n"
" pb::Freezable.CheckMutable(this);\n"
" $name$Case_ = $property_name$OneofCase.None;\n" " $name$Case_ = $property_name$OneofCase.None;\n"
" $name$_ = null;\n" " $name$_ = null;\n"
"}\n\n"); "}\n\n");
...@@ -346,6 +350,36 @@ void MessageGenerator::GenerateCloningCode(io::Printer* printer) { ...@@ -346,6 +350,36 @@ void MessageGenerator::GenerateCloningCode(io::Printer* printer) {
"}\n\n"); "}\n\n");
} }
void MessageGenerator::GenerateFreezingCode(io::Printer* printer) {
map<string, string> vars;
vars["class_name"] = class_name();
printer->Print(
"public void Freeze() {\n"
" if (IsFrozen) {\n"
" return;\n"
" }\n"
" _frozen = true;\n");
printer->Indent();
// Freeze non-oneof fields first (only messages and repeated fields will actually generate any code)
for (int i = 0; i < descriptor_->field_count(); i++) {
if (!descriptor_->field(i)->containing_oneof()) {
scoped_ptr<FieldGeneratorBase> generator(
CreateFieldGeneratorInternal(descriptor_->field(i)));
generator->GenerateFreezingCode(printer);
}
}
// For each oneof, if the value is freezable, freeze it. We don't actually need to know which type it was.
for (int i = 0; i < descriptor_->oneof_decl_count(); ++i) {
vars["name"] = UnderscoresToCamelCase(descriptor_->oneof_decl(i)->name(), false);
printer->Print(vars,
"if ($name$_ is IFreezable) ((IFreezable) $name$_).Freeze();\n");
}
printer->Outdent();
printer->Print("}\n\n");
}
void MessageGenerator::GenerateFrameworkMethods(io::Printer* printer) { void MessageGenerator::GenerateFrameworkMethods(io::Printer* printer) {
map<string, string> vars; map<string, string> vars;
vars["class_name"] = class_name(); vars["class_name"] = class_name();
......
...@@ -51,6 +51,7 @@ class MessageGenerator : public SourceGeneratorBase { ...@@ -51,6 +51,7 @@ class MessageGenerator : public SourceGeneratorBase {
~MessageGenerator(); ~MessageGenerator();
void GenerateCloningCode(io::Printer* printer); void GenerateCloningCode(io::Printer* printer);
void GenerateFreezingCode(io::Printer* printer);
void GenerateFrameworkMethods(io::Printer* printer); void GenerateFrameworkMethods(io::Printer* printer);
void GenerateStaticVariables(io::Printer* printer); void GenerateStaticVariables(io::Printer* printer);
void GenerateStaticVariableInitializers(io::Printer* printer); void GenerateStaticVariableInitializers(io::Printer* printer);
......
...@@ -66,7 +66,10 @@ void MessageFieldGenerator::GenerateMembers(io::Printer* printer) { ...@@ -66,7 +66,10 @@ void MessageFieldGenerator::GenerateMembers(io::Printer* printer) {
variables_, variables_,
"public $type_name$ $property_name$ {\n" "public $type_name$ $property_name$ {\n"
" get { return $name$_; }\n" " get { return $name$_; }\n"
" set { $name$_ = value; }\n" " set {\n"
" pb::Freezable.CheckMutable(this);\n"
" $name$_ = value;\n"
" }\n"
"}\n"); "}\n");
} }
...@@ -116,7 +119,7 @@ void MessageFieldGenerator::WriteHash(io::Printer* printer) { ...@@ -116,7 +119,7 @@ void MessageFieldGenerator::WriteHash(io::Printer* printer) {
void MessageFieldGenerator::WriteEquals(io::Printer* printer) { void MessageFieldGenerator::WriteEquals(io::Printer* printer) {
printer->Print( printer->Print(
variables_, variables_,
"if (!object.Equals($property_name$, other.$property_name$)) return false;"); "if (!object.Equals($property_name$, other.$property_name$)) return false;\n");
} }
void MessageFieldGenerator::WriteToString(io::Printer* printer) { void MessageFieldGenerator::WriteToString(io::Printer* printer) {
variables_["field_name"] = GetFieldName(descriptor_); variables_["field_name"] = GetFieldName(descriptor_);
...@@ -130,6 +133,11 @@ void MessageFieldGenerator::GenerateCloningCode(io::Printer* printer) { ...@@ -130,6 +133,11 @@ void MessageFieldGenerator::GenerateCloningCode(io::Printer* printer) {
"$property_name$ = other.$has_property_check$ ? other.$property_name$.Clone() : null;\n"); "$property_name$ = other.$has_property_check$ ? other.$property_name$.Clone() : null;\n");
} }
void MessageFieldGenerator::GenerateFreezingCode(io::Printer* printer) {
printer->Print(variables_,
"if ($has_property_check$) $property_name$.Freeze();\n");
}
MessageOneofFieldGenerator::MessageOneofFieldGenerator(const FieldDescriptor* descriptor, MessageOneofFieldGenerator::MessageOneofFieldGenerator(const FieldDescriptor* descriptor,
int fieldOrdinal) int fieldOrdinal)
: MessageFieldGenerator(descriptor, fieldOrdinal) { : MessageFieldGenerator(descriptor, fieldOrdinal) {
...@@ -147,6 +155,7 @@ void MessageOneofFieldGenerator::GenerateMembers(io::Printer* printer) { ...@@ -147,6 +155,7 @@ void MessageOneofFieldGenerator::GenerateMembers(io::Printer* printer) {
"public $type_name$ $property_name$ {\n" "public $type_name$ $property_name$ {\n"
" get { return $has_property_check$ ? ($type_name$) $oneof_name$_ : null; }\n" " get { return $has_property_check$ ? ($type_name$) $oneof_name$_ : null; }\n"
" set {\n" " set {\n"
" pb::Freezable.CheckMutable(this);\n"
" $oneof_name$_ = value;\n" " $oneof_name$_ = value;\n"
" $oneof_name$Case_ = value == null ? $oneof_property_name$OneofCase.None : $oneof_property_name$OneofCase.$property_name$;\n" " $oneof_name$Case_ = value == null ? $oneof_property_name$OneofCase.None : $oneof_property_name$OneofCase.$property_name$;\n"
" }\n" " }\n"
......
...@@ -47,6 +47,7 @@ class MessageFieldGenerator : public FieldGeneratorBase { ...@@ -47,6 +47,7 @@ class MessageFieldGenerator : public FieldGeneratorBase {
~MessageFieldGenerator(); ~MessageFieldGenerator();
virtual void GenerateCloningCode(io::Printer* printer); virtual void GenerateCloningCode(io::Printer* printer);
virtual void GenerateFreezingCode(io::Printer* printer);
virtual void GenerateMembers(io::Printer* printer); virtual void GenerateMembers(io::Printer* printer);
virtual void GenerateMergingCode(io::Printer* printer); virtual void GenerateMergingCode(io::Printer* printer);
virtual void GenerateParsingCode(io::Printer* printer); virtual void GenerateParsingCode(io::Printer* printer);
......
...@@ -72,17 +72,21 @@ void PrimitiveFieldGenerator::GenerateMembers(io::Printer* printer) { ...@@ -72,17 +72,21 @@ void PrimitiveFieldGenerator::GenerateMembers(io::Printer* printer) {
printer->Print( printer->Print(
variables_, variables_,
"public $type_name$ $property_name$ {\n" "public $type_name$ $property_name$ {\n"
" get { return $name$_; }\n"); " get { return $name$_; }\n"
" set {\n"
" pb::Freezable.CheckMutable(this);\n");
if (is_value_type) { if (is_value_type) {
printer->Print( printer->Print(
variables_, variables_,
" set { $name$_ = value; }\n"); " $name$_ = value;\n");
} else { } else {
printer->Print( printer->Print(
variables_, variables_,
" set { $name$_ = value ?? $default_value$; }\n"); " $name$_ = value ?? $default_value$;\n");
} }
printer->Print("}\n\n"); printer->Print(
" }\n"
"}\n");
} }
void PrimitiveFieldGenerator::GenerateMergingCode(io::Printer* printer) { void PrimitiveFieldGenerator::GenerateMergingCode(io::Printer* printer) {
...@@ -166,7 +170,8 @@ void PrimitiveOneofFieldGenerator::GenerateMembers(io::Printer* printer) { ...@@ -166,7 +170,8 @@ void PrimitiveOneofFieldGenerator::GenerateMembers(io::Printer* printer) {
variables_, variables_,
"public $type_name$ $property_name$ {\n" "public $type_name$ $property_name$ {\n"
" get { return $has_property_check$ ? ($type_name$) $oneof_name$_ : $default_value$; }\n" " get { return $has_property_check$ ? ($type_name$) $oneof_name$_ : $default_value$; }\n"
" set {\n"); " set {\n"
" pb::Freezable.CheckMutable(this);\n");
if (is_value_type) { if (is_value_type) {
printer->Print( printer->Print(
variables_, variables_,
......
...@@ -147,6 +147,11 @@ void RepeatedEnumFieldGenerator::GenerateCloningCode(io::Printer* printer) { ...@@ -147,6 +147,11 @@ void RepeatedEnumFieldGenerator::GenerateCloningCode(io::Printer* printer) {
"$name$_ = other.$name$_.Clone();\n"); "$name$_ = other.$name$_.Clone();\n");
} }
void RepeatedEnumFieldGenerator::GenerateFreezingCode(io::Printer* printer) {
printer->Print(variables_,
"$name$_.Freeze();\n");
}
} // namespace csharp } // namespace csharp
} // namespace compiler } // namespace compiler
} // namespace protobuf } // namespace protobuf
......
...@@ -49,6 +49,7 @@ class RepeatedEnumFieldGenerator : public FieldGeneratorBase { ...@@ -49,6 +49,7 @@ class RepeatedEnumFieldGenerator : public FieldGeneratorBase {
~RepeatedEnumFieldGenerator(); ~RepeatedEnumFieldGenerator();
virtual void GenerateCloningCode(io::Printer* printer); virtual void GenerateCloningCode(io::Printer* printer);
virtual void GenerateFreezingCode(io::Printer* printer);
virtual void GenerateMembers(io::Printer* printer); virtual void GenerateMembers(io::Printer* printer);
virtual void GenerateMergingCode(io::Printer* printer); virtual void GenerateMergingCode(io::Printer* printer);
virtual void GenerateParsingCode(io::Printer* printer); virtual void GenerateParsingCode(io::Printer* printer);
......
...@@ -123,6 +123,11 @@ void RepeatedMessageFieldGenerator::GenerateCloningCode(io::Printer* printer) { ...@@ -123,6 +123,11 @@ void RepeatedMessageFieldGenerator::GenerateCloningCode(io::Printer* printer) {
"$name$_ = other.$name$_.Clone();\n"); "$name$_ = other.$name$_.Clone();\n");
} }
void RepeatedMessageFieldGenerator::GenerateFreezingCode(io::Printer* printer) {
printer->Print(variables_,
"$name$_.Freeze();\n");
}
} // namespace csharp } // namespace csharp
} // namespace compiler } // namespace compiler
} // namespace protobuf } // namespace protobuf
......
...@@ -47,6 +47,7 @@ class RepeatedMessageFieldGenerator : public FieldGeneratorBase { ...@@ -47,6 +47,7 @@ class RepeatedMessageFieldGenerator : public FieldGeneratorBase {
~RepeatedMessageFieldGenerator(); ~RepeatedMessageFieldGenerator();
virtual void GenerateCloningCode(io::Printer* printer); virtual void GenerateCloningCode(io::Printer* printer);
virtual void GenerateFreezingCode(io::Printer* printer);
virtual void GenerateMembers(io::Printer* printer); virtual void GenerateMembers(io::Printer* printer);
virtual void GenerateMergingCode(io::Printer* printer); virtual void GenerateMergingCode(io::Printer* printer);
virtual void GenerateParsingCode(io::Printer* printer); virtual void GenerateParsingCode(io::Printer* printer);
......
...@@ -153,6 +153,11 @@ void RepeatedPrimitiveFieldGenerator::GenerateCloningCode(io::Printer* printer) ...@@ -153,6 +153,11 @@ void RepeatedPrimitiveFieldGenerator::GenerateCloningCode(io::Printer* printer)
"$name$_ = other.$name$_.Clone();\n"); "$name$_ = other.$name$_.Clone();\n");
} }
void RepeatedPrimitiveFieldGenerator::GenerateFreezingCode(io::Printer* printer) {
printer->Print(variables_,
"$name$_.Freeze();\n");
}
} // namespace csharp } // namespace csharp
} // namespace compiler } // namespace compiler
} // namespace protobuf } // namespace protobuf
......
...@@ -47,6 +47,7 @@ class RepeatedPrimitiveFieldGenerator : public FieldGeneratorBase { ...@@ -47,6 +47,7 @@ class RepeatedPrimitiveFieldGenerator : public FieldGeneratorBase {
~RepeatedPrimitiveFieldGenerator(); ~RepeatedPrimitiveFieldGenerator();
virtual void GenerateCloningCode(io::Printer* printer); virtual void GenerateCloningCode(io::Printer* printer);
virtual void GenerateFreezingCode(io::Printer* printer);
virtual void GenerateMembers(io::Printer* printer); virtual void GenerateMembers(io::Printer* printer);
virtual void GenerateMergingCode(io::Printer* printer); virtual void GenerateMergingCode(io::Printer* printer);
virtual void GenerateParsingCode(io::Printer* printer); virtual void GenerateParsingCode(io::Printer* printer);
......
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