aboutsummaryrefslogtreecommitdiff
path: root/csharp
diff options
context:
space:
mode:
authorJon Skeet <skeet@pobox.com>2008-08-21 21:57:58 +0100
committerJon Skeet <skeet@pobox.com>2008-08-21 21:57:58 +0100
commit0bf2ad145daf4ed7eb0f72c111b496d55233e0b9 (patch)
tree6c611fe5fb2b26aed50bcc2c4197d7ecc378a6b7 /csharp
parentad6903fe33ca0a79e7618a25e83de769438d18ce (diff)
downloadprotobuf-0bf2ad145daf4ed7eb0f72c111b496d55233e0b9.tar.gz
protobuf-0bf2ad145daf4ed7eb0f72c111b496d55233e0b9.tar.bz2
protobuf-0bf2ad145daf4ed7eb0f72c111b496d55233e0b9.zip
Implemented popsicle immutability for lists. Modified MessageStreamIterator to be singly generic.
Diffstat (limited to 'csharp')
-rw-r--r--csharp/ProtocolBuffers.Test/Collections/PopsicleListTest.cs64
-rw-r--r--csharp/ProtocolBuffers.Test/GeneratedMessageTest.cs47
-rw-r--r--csharp/ProtocolBuffers.Test/MessageStreamIteratorTest.cs2
-rw-r--r--csharp/ProtocolBuffers.Test/ProtocolBuffers.Test.csproj1
-rw-r--r--csharp/ProtocolBuffers.Test/TestProtos/MessageWithNoOuter.cs23
-rw-r--r--csharp/ProtocolBuffers.Test/TestProtos/UnitTestEmbedOptimizeForProtoFile.cs24
-rw-r--r--csharp/ProtocolBuffers.Test/TestProtos/UnitTestImportProtoFile.cs2
-rw-r--r--csharp/ProtocolBuffers.Test/TestProtos/UnitTestMessageSetProtoFile.cs34
-rw-r--r--csharp/ProtocolBuffers.Test/TestProtos/UnitTestOptimizeForProtoFile.cs2
-rw-r--r--csharp/ProtocolBuffers.Test/TestProtos/UnitTestProtoFile.cs630
-rw-r--r--csharp/ProtocolBuffers/Collections/PopsicleList.cs95
-rw-r--r--csharp/ProtocolBuffers/Delegates.cs28
-rw-r--r--csharp/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs315
-rw-r--r--csharp/ProtocolBuffers/FieldAccess/Delegates.cs26
-rw-r--r--csharp/ProtocolBuffers/MessageStreamIterator.cs148
-rw-r--r--csharp/ProtocolBuffers/ProtocolBuffers.csproj2
16 files changed, 580 insertions, 863 deletions
diff --git a/csharp/ProtocolBuffers.Test/Collections/PopsicleListTest.cs b/csharp/ProtocolBuffers.Test/Collections/PopsicleListTest.cs
new file mode 100644
index 00000000..6943672d
--- /dev/null
+++ b/csharp/ProtocolBuffers.Test/Collections/PopsicleListTest.cs
@@ -0,0 +1,64 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using NUnit.Framework;
+
+namespace Google.ProtocolBuffers.Collections {
+ [TestFixture]
+ public class PopsicleListTest {
+
+ [Test]
+ public void MutatingOperationsOnFrozenList() {
+ PopsicleList<string> list = new PopsicleList<string>();
+ list.MakeReadOnly();
+ AssertNotSupported(() => list.Add(""));
+ AssertNotSupported(() => list.Clear());
+ AssertNotSupported(() => list.Insert(0, ""));
+ AssertNotSupported(() => list.Remove(""));
+ AssertNotSupported(() => list.RemoveAt(0));
+ }
+
+ [Test]
+ public void NonMutatingOperationsOnFrozenList() {
+ PopsicleList<string> list = new PopsicleList<string>();
+ list.MakeReadOnly();
+ Assert.IsFalse(list.Contains(""));
+ Assert.AreEqual(0, list.Count);
+ list.CopyTo(new string[5], 0);
+ list.GetEnumerator();
+ Assert.AreEqual(-1, list.IndexOf(""));
+ Assert.IsTrue(list.IsReadOnly);
+ }
+
+ [Test]
+ public void MutatingOperationsOnFluidList() {
+ PopsicleList<string> list = new PopsicleList<string>();
+ list.Add("");
+ list.Clear();
+ list.Insert(0, "");
+ list.Remove("");
+ list.Add("x"); // Just to make the next call valid
+ list.RemoveAt(0);
+ }
+
+ [Test]
+ public void NonMutatingOperationsOnFluidList() {
+ PopsicleList<string> list = new PopsicleList<string>();
+ Assert.IsFalse(list.Contains(""));
+ Assert.AreEqual(0, list.Count);
+ list.CopyTo(new string[5], 0);
+ list.GetEnumerator();
+ Assert.AreEqual(-1, list.IndexOf(""));
+ Assert.IsFalse(list.IsReadOnly);
+ }
+
+ private static void AssertNotSupported(Action action) {
+ try {
+ action();
+ Assert.Fail("Expected NotSupportedException");
+ } catch (NotSupportedException) {
+ // Expected
+ }
+ }
+ }
+}
diff --git a/csharp/ProtocolBuffers.Test/GeneratedMessageTest.cs b/csharp/ProtocolBuffers.Test/GeneratedMessageTest.cs
index 9a08ed95..f51f9755 100644
--- a/csharp/ProtocolBuffers.Test/GeneratedMessageTest.cs
+++ b/csharp/ProtocolBuffers.Test/GeneratedMessageTest.cs
@@ -13,6 +13,8 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
+using System;
+using System.Collections.Generic;
using Google.ProtocolBuffers.Descriptors;
using Google.ProtocolBuffers.TestProtos;
using NUnit.Framework;
@@ -28,7 +30,50 @@ namespace Google.ProtocolBuffers {
reflectionTester = ReflectionTester.CreateTestAllTypesInstance();
extensionsReflectionTester = ReflectionTester.CreateTestAllExtensionsInstance();
}
-
+
+ [Test]
+ public void RepeatedAddPrimitiveBeforeBuild() {
+ TestAllTypes message = new TestAllTypes.Builder { RepeatedInt32List = { 1, 2, 3 } }.Build();
+ TestUtil.AssertEqual(new int[]{1, 2, 3}, message.RepeatedInt32List);
+ }
+
+ [Test]
+ public void AddPrimitiveFailsAfterBuild() {
+ TestAllTypes.Builder builder = new TestAllTypes.Builder();
+ IList<int> list = builder.RepeatedInt32List;
+ list.Add(1); // Fine
+ builder.Build();
+
+ try {
+ list.Add(2);
+ Assert.Fail("List should be frozen");
+ } catch (NotSupportedException) {
+ // Expected
+ }
+ }
+
+ [Test]
+ public void RepeatedAddMessageBeforeBuild() {
+ TestAllTypes message = new TestAllTypes.Builder {
+ RepeatedNestedMessageList = { new TestAllTypes.Types.NestedMessage.Builder { Bb = 10 }.Build() } }.Build();
+ Assert.AreEqual(1, message.RepeatedNestedMessageCount);
+ Assert.AreEqual(10, message.RepeatedNestedMessageList[0].Bb);
+ }
+
+ [Test]
+ public void AddMessageFailsAfterBuild() {
+ TestAllTypes.Builder builder = new TestAllTypes.Builder();
+ IList<TestAllTypes.Types.NestedMessage> list = builder.RepeatedNestedMessageList;
+ builder.Build();
+
+ try {
+ list.Add(new TestAllTypes.Types.NestedMessage.Builder { Bb = 10 }.Build());
+ Assert.Fail("List should be frozen");
+ } catch (NotSupportedException) {
+ // Expected
+ }
+ }
+
[Test]
public void DefaultInstance() {
Assert.AreSame(TestAllTypes.DefaultInstance, TestAllTypes.DefaultInstance.DefaultInstanceForType);
diff --git a/csharp/ProtocolBuffers.Test/MessageStreamIteratorTest.cs b/csharp/ProtocolBuffers.Test/MessageStreamIteratorTest.cs
index 063f06d5..0cccd4a7 100644
--- a/csharp/ProtocolBuffers.Test/MessageStreamIteratorTest.cs
+++ b/csharp/ProtocolBuffers.Test/MessageStreamIteratorTest.cs
@@ -11,7 +11,7 @@ namespace Google.ProtocolBuffers {
[Test]
public void ThreeMessagesInMemory() {
MemoryStream stream = new MemoryStream(MessageStreamWriterTest.ThreeMessageData);
- IEnumerable<NestedMessage> iterator = MessageStreamIterator.FromStreamProvider<NestedMessage>(() => stream);
+ IEnumerable<NestedMessage> iterator = MessageStreamIterator<NestedMessage>.FromStreamProvider(() => stream);
List<NestedMessage> messages = new List<NestedMessage>(iterator);
Assert.AreEqual(3, messages.Count);
diff --git a/csharp/ProtocolBuffers.Test/ProtocolBuffers.Test.csproj b/csharp/ProtocolBuffers.Test/ProtocolBuffers.Test.csproj
index 027a159f..99de695e 100644
--- a/csharp/ProtocolBuffers.Test/ProtocolBuffers.Test.csproj
+++ b/csharp/ProtocolBuffers.Test/ProtocolBuffers.Test.csproj
@@ -50,6 +50,7 @@
<Compile Include="ByteStringTest.cs" />
<Compile Include="CodedInputStreamTest.cs" />
<Compile Include="CodedOutputStreamTest.cs" />
+ <Compile Include="Collections\PopsicleListTest.cs" />
<Compile Include="DescriptorsTest.cs" />
<Compile Include="DynamicMessageTest.cs" />
<Compile Include="GeneratedMessageTest.cs" />
diff --git a/csharp/ProtocolBuffers.Test/TestProtos/MessageWithNoOuter.cs b/csharp/ProtocolBuffers.Test/TestProtos/MessageWithNoOuter.cs
index 6e44a0c9..64f09f86 100644
--- a/csharp/ProtocolBuffers.Test/TestProtos/MessageWithNoOuter.cs
+++ b/csharp/ProtocolBuffers.Test/TestProtos/MessageWithNoOuter.cs
@@ -7,7 +7,7 @@ using scg = global::System.Collections.Generic;
namespace Google.ProtocolBuffers.TestProtos {
public sealed partial class MessageWithNoOuter : pb::GeneratedMessage<MessageWithNoOuter, MessageWithNoOuter.Builder> {
- private static readonly MessageWithNoOuter defaultInstance = new MessageWithNoOuter();
+ private static readonly MessageWithNoOuter defaultInstance = new Builder().BuildPartial();
public static MessageWithNoOuter DefaultInstance {
get { return defaultInstance; }
}
@@ -35,7 +35,7 @@ namespace Google.ProtocolBuffers.TestProtos {
}
public sealed partial class NestedMessage : pb::GeneratedMessage<NestedMessage, NestedMessage.Builder> {
- private static readonly NestedMessage defaultInstance = new NestedMessage();
+ private static readonly NestedMessage defaultInstance = new Builder().BuildPartial();
public static NestedMessage DefaultInstance {
get { return defaultInstance; }
}
@@ -179,7 +179,7 @@ namespace Google.ProtocolBuffers.TestProtos {
}
// repeated .protobuf_unittest.TestAllTypes foreign = 2;
- private scg::IList<global::Google.ProtocolBuffers.TestProtos.TestAllTypes> foreign_ = pbc::Lists<global::Google.ProtocolBuffers.TestProtos.TestAllTypes>.Empty;
+ private pbc::PopsicleList<global::Google.ProtocolBuffers.TestProtos.TestAllTypes> foreign_ = new pbc::PopsicleList<global::Google.ProtocolBuffers.TestProtos.TestAllTypes>();
public scg::IList<global::Google.ProtocolBuffers.TestProtos.TestAllTypes> ForeignList {
get { return foreign_; }
}
@@ -278,9 +278,7 @@ namespace Google.ProtocolBuffers.TestProtos {
}
public override global::Google.ProtocolBuffers.TestProtos.MessageWithNoOuter BuildPartial() {
- if (result.foreign_ != pbc::Lists<global::Google.ProtocolBuffers.TestProtos.TestAllTypes>.Empty) {
- result.foreign_ = pbc::Lists<global::Google.ProtocolBuffers.TestProtos.TestAllTypes>.AsReadOnly(result.foreign_);
- }
+ result.foreign_.MakeReadOnly();
global::Google.ProtocolBuffers.TestProtos.MessageWithNoOuter returnMe = result;
result = null;
return returnMe;
@@ -324,7 +322,7 @@ namespace Google.ProtocolBuffers.TestProtos {
// repeated .protobuf_unittest.TestAllTypes foreign = 2;
public scg::IList<global::Google.ProtocolBuffers.TestProtos.TestAllTypes> ForeignList {
- get { return pbc::Lists.AsReadOnly(result.foreign_); }
+ get { return result.foreign_; }
}
public int ForeignCount {
get { return result.ForeignCount; }
@@ -341,28 +339,19 @@ namespace Google.ProtocolBuffers.TestProtos {
return this;
}
public Builder AddForeign(global::Google.ProtocolBuffers.TestProtos.TestAllTypes value) {
- if (result.foreign_ == pbc::Lists<global::Google.ProtocolBuffers.TestProtos.TestAllTypes>.Empty) {
- result.foreign_ = new scg::List<global::Google.ProtocolBuffers.TestProtos.TestAllTypes>();
- }
result.foreign_.Add(value);
return this;
}
public Builder AddForeign(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Builder builderForValue) {
- if (result.foreign_ == pbc::Lists<global::Google.ProtocolBuffers.TestProtos.TestAllTypes>.Empty) {
- result.foreign_ = new scg::List<global::Google.ProtocolBuffers.TestProtos.TestAllTypes>();
- }
result.foreign_.Add(builderForValue.Build());
return this;
}
public Builder AddRangeForeign(scg::IEnumerable<global::Google.ProtocolBuffers.TestProtos.TestAllTypes> values) {
- if (result.foreign_ == pbc::Lists<global::Google.ProtocolBuffers.TestProtos.TestAllTypes>.Empty) {
- result.foreign_ = new scg::List<global::Google.ProtocolBuffers.TestProtos.TestAllTypes>();
- }
base.AddRange(values, result.foreign_);
return this;
}
public Builder ClearForeign() {
- result.foreign_ = pbc::Lists<global::Google.ProtocolBuffers.TestProtos.TestAllTypes>.Empty;
+ result.foreign_.Clear();
return this;
}
diff --git a/csharp/ProtocolBuffers.Test/TestProtos/UnitTestEmbedOptimizeForProtoFile.cs b/csharp/ProtocolBuffers.Test/TestProtos/UnitTestEmbedOptimizeForProtoFile.cs
index cae05bf8..8f4f3076 100644
--- a/csharp/ProtocolBuffers.Test/TestProtos/UnitTestEmbedOptimizeForProtoFile.cs
+++ b/csharp/ProtocolBuffers.Test/TestProtos/UnitTestEmbedOptimizeForProtoFile.cs
@@ -55,7 +55,7 @@ namespace Google.ProtocolBuffers.TestProtos {
#region Messages
public sealed partial class TestEmbedOptimizedForSize : pb::GeneratedMessage<TestEmbedOptimizedForSize, TestEmbedOptimizedForSize.Builder> {
- private static readonly TestEmbedOptimizedForSize defaultInstance = new TestEmbedOptimizedForSize();
+ private static readonly TestEmbedOptimizedForSize defaultInstance = new Builder().BuildPartial();
public static TestEmbedOptimizedForSize DefaultInstance {
get { return defaultInstance; }
}
@@ -87,7 +87,7 @@ namespace Google.ProtocolBuffers.TestProtos {
}
// repeated .protobuf_unittest.TestOptimizedForSize repeated_message = 2;
- private scg::IList<global::Google.ProtocolBuffers.TestProtos.TestOptimizedForSize> repeatedMessage_ = pbc::Lists<global::Google.ProtocolBuffers.TestProtos.TestOptimizedForSize>.Empty;
+ private pbc::PopsicleList<global::Google.ProtocolBuffers.TestProtos.TestOptimizedForSize> repeatedMessage_ = new pbc::PopsicleList<global::Google.ProtocolBuffers.TestProtos.TestOptimizedForSize>();
public scg::IList<global::Google.ProtocolBuffers.TestProtos.TestOptimizedForSize> RepeatedMessageList {
get { return repeatedMessage_; }
}
@@ -211,9 +211,7 @@ namespace Google.ProtocolBuffers.TestProtos {
}
public override global::Google.ProtocolBuffers.TestProtos.TestEmbedOptimizedForSize BuildPartial() {
- if (result.repeatedMessage_ != pbc::Lists<global::Google.ProtocolBuffers.TestProtos.TestOptimizedForSize>.Empty) {
- result.repeatedMessage_ = pbc::Lists<global::Google.ProtocolBuffers.TestProtos.TestOptimizedForSize>.AsReadOnly(result.repeatedMessage_);
- }
+ result.repeatedMessage_.MakeReadOnly();
global::Google.ProtocolBuffers.TestProtos.TestEmbedOptimizedForSize returnMe = result;
result = null;
return returnMe;
@@ -234,9 +232,6 @@ namespace Google.ProtocolBuffers.TestProtos {
MergeOptionalMessage(other.OptionalMessage);
}
if (other.repeatedMessage_.Count != 0) {
- if (result.repeatedMessage_.Count == 0) {
- result.repeatedMessage_ = new scg::List<global::Google.ProtocolBuffers.TestProtos.TestOptimizedForSize>();
- }
base.AddRange(other.repeatedMessage_, result.repeatedMessage_);
}
this.MergeUnknownFields(other.UnknownFields);
@@ -321,7 +316,7 @@ namespace Google.ProtocolBuffers.TestProtos {
// repeated .protobuf_unittest.TestOptimizedForSize repeated_message = 2;
public scg::IList<global::Google.ProtocolBuffers.TestProtos.TestOptimizedForSize> RepeatedMessageList {
- get { return pbc::Lists.AsReadOnly(result.repeatedMessage_); }
+ get { return result.repeatedMessage_; }
}
public int RepeatedMessageCount {
get { return result.RepeatedMessageCount; }
@@ -338,28 +333,19 @@ namespace Google.ProtocolBuffers.TestProtos {
return this;
}
public Builder AddRepeatedMessage(global::Google.ProtocolBuffers.TestProtos.TestOptimizedForSize value) {
- if (result.repeatedMessage_ == pbc::Lists<global::Google.ProtocolBuffers.TestProtos.TestOptimizedForSize>.Empty) {
- result.repeatedMessage_ = new scg::List<global::Google.ProtocolBuffers.TestProtos.TestOptimizedForSize>();
- }
result.repeatedMessage_.Add(value);
return this;
}
public Builder AddRepeatedMessage(global::Google.ProtocolBuffers.TestProtos.TestOptimizedForSize.Builder builderForValue) {
- if (result.repeatedMessage_ == pbc::Lists<global::Google.ProtocolBuffers.TestProtos.TestOptimizedForSize>.Empty) {
- result.repeatedMessage_ = new scg::List<global::Google.ProtocolBuffers.TestProtos.TestOptimizedForSize>();
- }
result.repeatedMessage_.Add(builderForValue.Build());
return this;
}
public Builder AddRangeRepeatedMessage(scg::IEnumerable<global::Google.ProtocolBuffers.TestProtos.TestOptimizedForSize> values) {
- if (result.repeatedMessage_ == pbc::Lists<global::Google.ProtocolBuffers.TestProtos.TestOptimizedForSize>.Empty) {
- result.repeatedMessage_ = new scg::List<global::Google.ProtocolBuffers.TestProtos.TestOptimizedForSize>();
- }
base.AddRange(values, result.repeatedMessage_);
return this;
}
public Builder ClearRepeatedMessage() {
- result.repeatedMessage_ = pbc::Lists<global::Google.ProtocolBuffers.TestProtos.TestOptimizedForSize>.Empty;
+ result.repeatedMessage_.Clear();
return this;
}
}
diff --git a/csharp/ProtocolBuffers.Test/TestProtos/UnitTestImportProtoFile.cs b/csharp/ProtocolBuffers.Test/TestProtos/UnitTestImportProtoFile.cs
index 5713e1c9..7d8d1d0e 100644
--- a/csharp/ProtocolBuffers.Test/TestProtos/UnitTestImportProtoFile.cs
+++ b/csharp/ProtocolBuffers.Test/TestProtos/UnitTestImportProtoFile.cs
@@ -55,7 +55,7 @@ namespace Google.ProtocolBuffers.TestProtos {
#region Messages
public sealed partial class ImportMessage : pb::GeneratedMessage<ImportMessage, ImportMessage.Builder> {
- private static readonly ImportMessage defaultInstance = new ImportMessage();
+ private static readonly ImportMessage defaultInstance = new Builder().BuildPartial();
public static ImportMessage DefaultInstance {
get { return defaultInstance; }
}
diff --git a/csharp/ProtocolBuffers.Test/TestProtos/UnitTestMessageSetProtoFile.cs b/csharp/ProtocolBuffers.Test/TestProtos/UnitTestMessageSetProtoFile.cs
index b3b53adf..e03eac92 100644
--- a/csharp/ProtocolBuffers.Test/TestProtos/UnitTestMessageSetProtoFile.cs
+++ b/csharp/ProtocolBuffers.Test/TestProtos/UnitTestMessageSetProtoFile.cs
@@ -95,7 +95,7 @@ namespace Google.ProtocolBuffers.TestProtos {
#region Messages
public sealed partial class TestMessageSet : pb::ExtendableMessage<TestMessageSet, TestMessageSet.Builder> {
- private static readonly TestMessageSet defaultInstance = new TestMessageSet();
+ private static readonly TestMessageSet defaultInstance = new Builder().BuildPartial();
public static TestMessageSet DefaultInstance {
get { return defaultInstance; }
}
@@ -264,7 +264,7 @@ namespace Google.ProtocolBuffers.TestProtos {
}
public sealed partial class TestMessageSetContainer : pb::GeneratedMessage<TestMessageSetContainer, TestMessageSetContainer.Builder> {
- private static readonly TestMessageSetContainer defaultInstance = new TestMessageSetContainer();
+ private static readonly TestMessageSetContainer defaultInstance = new Builder().BuildPartial();
public static TestMessageSetContainer DefaultInstance {
get { return defaultInstance; }
}
@@ -495,7 +495,7 @@ namespace Google.ProtocolBuffers.TestProtos {
}
public sealed partial class TestMessageSetExtension1 : pb::GeneratedMessage<TestMessageSetExtension1, TestMessageSetExtension1.Builder> {
- private static readonly TestMessageSetExtension1 defaultInstance = new TestMessageSetExtension1();
+ private static readonly TestMessageSetExtension1 defaultInstance = new Builder().BuildPartial();
public static TestMessageSetExtension1 DefaultInstance {
get { return defaultInstance; }
}
@@ -709,7 +709,7 @@ namespace Google.ProtocolBuffers.TestProtos {
}
public sealed partial class TestMessageSetExtension2 : pb::GeneratedMessage<TestMessageSetExtension2, TestMessageSetExtension2.Builder> {
- private static readonly TestMessageSetExtension2 defaultInstance = new TestMessageSetExtension2();
+ private static readonly TestMessageSetExtension2 defaultInstance = new Builder().BuildPartial();
public static TestMessageSetExtension2 DefaultInstance {
get { return defaultInstance; }
}
@@ -923,7 +923,7 @@ namespace Google.ProtocolBuffers.TestProtos {
}
public sealed partial class RawMessageSet : pb::GeneratedMessage<RawMessageSet, RawMessageSet.Builder> {
- private static readonly RawMessageSet defaultInstance = new RawMessageSet();
+ private static readonly RawMessageSet defaultInstance = new Builder().BuildPartial();
public static RawMessageSet DefaultInstance {
get { return defaultInstance; }
}
@@ -947,7 +947,7 @@ namespace Google.ProtocolBuffers.TestProtos {
#region Nested types
public static class Types {
public sealed partial class Item : pb::GeneratedMessage<Item, Item.Builder> {
- private static readonly Item defaultInstance = new Item();
+ private static readonly Item defaultInstance = new Builder().BuildPartial();
public static Item DefaultInstance {
get { return defaultInstance; }
}
@@ -1201,7 +1201,7 @@ namespace Google.ProtocolBuffers.TestProtos {
#endregion
// repeated group Item = 1 {
- private scg::IList<global::Google.ProtocolBuffers.TestProtos.RawMessageSet.Types.Item> item_ = pbc::Lists<global::Google.ProtocolBuffers.TestProtos.RawMessageSet.Types.Item>.Empty;
+ private pbc::PopsicleList<global::Google.ProtocolBuffers.TestProtos.RawMessageSet.Types.Item> item_ = new pbc::PopsicleList<global::Google.ProtocolBuffers.TestProtos.RawMessageSet.Types.Item>();
public scg::IList<global::Google.ProtocolBuffers.TestProtos.RawMessageSet.Types.Item> ItemList {
get { return item_; }
}
@@ -1316,9 +1316,7 @@ namespace Google.ProtocolBuffers.TestProtos {
}
public override global::Google.ProtocolBuffers.TestProtos.RawMessageSet BuildPartial() {
- if (result.item_ != pbc::Lists<global::Google.ProtocolBuffers.TestProtos.RawMessageSet.Types.Item>.Empty) {
- result.item_ = pbc::Lists<global::Google.ProtocolBuffers.TestProtos.RawMessageSet.Types.Item>.AsReadOnly(result.item_);
- }
+ result.item_.MakeReadOnly();
global::Google.ProtocolBuffers.TestProtos.RawMessageSet returnMe = result;
result = null;
return returnMe;
@@ -1336,9 +1334,6 @@ namespace Google.ProtocolBuffers.TestProtos {
public override Builder MergeFrom(global::Google.ProtocolBuffers.TestProtos.RawMessageSet other) {
if (other == global::Google.ProtocolBuffers.TestProtos.RawMessageSet.DefaultInstance) return this;
if (other.item_.Count != 0) {
- if (result.item_.Count == 0) {
- result.item_ = new scg::List<global::Google.ProtocolBuffers.TestProtos.RawMessageSet.Types.Item>();
- }
base.AddRange(other.item_, result.item_);
}
this.MergeUnknownFields(other.UnknownFields);
@@ -1379,7 +1374,7 @@ namespace Google.ProtocolBuffers.TestProtos {
// repeated group Item = 1 {
public scg::IList<global::Google.ProtocolBuffers.TestProtos.RawMessageSet.Types.Item> ItemList {
- get { return pbc::Lists.AsReadOnly(result.item_); }
+ get { return result.item_; }
}
public int ItemCount {
get { return result.ItemCount; }
@@ -1396,28 +1391,19 @@ namespace Google.ProtocolBuffers.TestProtos {
return this;
}
public Builder AddItem(global::Google.ProtocolBuffers.TestProtos.RawMessageSet.Types.Item value) {
- if (result.item_ == pbc::Lists<global::Google.ProtocolBuffers.TestProtos.RawMessageSet.Types.Item>.Empty) {
- result.item_ = new scg::List<global::Google.ProtocolBuffers.TestProtos.RawMessageSet.Types.Item>();
- }
result.item_.Add(value);
return this;
}
public Builder AddItem(global::Google.ProtocolBuffers.TestProtos.RawMessageSet.Types.Item.Builder builderForValue) {
- if (result.item_ == pbc::Lists<global::Google.ProtocolBuffers.TestProtos.RawMessageSet.Types.Item>.Empty) {
- result.item_ = new scg::List<global::Google.ProtocolBuffers.TestProtos.RawMessageSet.Types.Item>();
- }
result.item_.Add(builderForValue.Build());
return this;
}
public Builder AddRangeItem(scg::IEnumerable<global::Google.ProtocolBuffers.TestProtos.RawMessageSet.Types.Item> values) {
- if (result.item_ == pbc::Lists<global::Google.ProtocolBuffers.TestProtos.RawMessageSet.Types.Item>.Empty) {
- result.item_ = new scg::List<global::Google.ProtocolBuffers.TestProtos.RawMessageSet.Types.Item>();
- }
base.AddRange(values, result.item_);
return this;
}
public Builder ClearItem() {
- result.item_ = pbc::Lists<global::Google.ProtocolBuffers.TestProtos.RawMessageSet.Types.Item>.Empty;
+ result.item_.Clear();
return this;
}
}
diff --git a/csharp/ProtocolBuffers.Test/TestProtos/UnitTestOptimizeForProtoFile.cs b/csharp/ProtocolBuffers.Test/TestProtos/UnitTestOptimizeForProtoFile.cs
index 52143f2c..de07d033 100644
--- a/csharp/ProtocolBuffers.Test/TestProtos/UnitTestOptimizeForProtoFile.cs
+++ b/csharp/ProtocolBuffers.Test/TestProtos/UnitTestOptimizeForProtoFile.cs
@@ -54,7 +54,7 @@ namespace Google.ProtocolBuffers.TestProtos {
#region Messages
public sealed partial class TestOptimizedForSize : pb::ExtendableMessage<TestOptimizedForSize, TestOptimizedForSize.Builder> {
- private static readonly TestOptimizedForSize defaultInstance = new TestOptimizedForSize();
+ private static readonly TestOptimizedForSize defaultInstance = new Builder().BuildPartial();
public static TestOptimizedForSize DefaultInstance {
get { return defaultInstance; }
}
diff --git a/csharp/ProtocolBuffers.Test/TestProtos/UnitTestProtoFile.cs b/csharp/ProtocolBuffers.Test/TestProtos/UnitTestProtoFile.cs
index 167f8718..a971832b 100644
--- a/csharp/ProtocolBuffers.Test/TestProtos/UnitTestProtoFile.cs
+++ b/csharp/ProtocolBuffers.Test/TestProtos/UnitTestProtoFile.cs
@@ -975,7 +975,7 @@ namespace Google.ProtocolBuffers.TestProtos {
#region Messages
public sealed partial class TestAllTypes : pb::GeneratedMessage<TestAllTypes, TestAllTypes.Builder> {
- private static readonly TestAllTypes defaultInstance = new TestAllTypes();
+ private static readonly TestAllTypes defaultInstance = new Builder().BuildPartial();
public static TestAllTypes DefaultInstance {
get { return defaultInstance; }
}
@@ -1005,7 +1005,7 @@ namespace Google.ProtocolBuffers.TestProtos {
}
public sealed partial class NestedMessage : pb::GeneratedMessage<NestedMessage, NestedMessage.Builder> {
- private static readonly NestedMessage defaultInstance = new NestedMessage();
+ private static readonly NestedMessage defaultInstance = new Builder().BuildPartial();
public static NestedMessage DefaultInstance {
get { return defaultInstance; }
}
@@ -1212,7 +1212,7 @@ namespace Google.ProtocolBuffers.TestProtos {
}
public sealed partial class OptionalGroup : pb::GeneratedMessage<OptionalGroup, OptionalGroup.Builder> {
- private static readonly OptionalGroup defaultInstance = new OptionalGroup();
+ private static readonly OptionalGroup defaultInstance = new Builder().BuildPartial();
public static OptionalGroup DefaultInstance {
get { return defaultInstance; }
}
@@ -1419,7 +1419,7 @@ namespace Google.ProtocolBuffers.TestProtos {
}
public sealed partial class RepeatedGroup : pb::GeneratedMessage<RepeatedGroup, RepeatedGroup.Builder> {
- private static readonly RepeatedGroup defaultInstance = new RepeatedGroup();
+ private static readonly RepeatedGroup defaultInstance = new Builder().BuildPartial();
public static RepeatedGroup DefaultInstance {
get { return defaultInstance; }
}
@@ -1863,9 +1863,9 @@ namespace Google.ProtocolBuffers.TestProtos {
}
// repeated int32 repeated_int32 = 31;
- private scg::IList<int> repeatedInt32_ = pbc::Lists<int>.Empty;
+ private pbc::PopsicleList<int> repeatedInt32_ = new pbc::PopsicleList<int>();
public scg::IList<int> RepeatedInt32List {
- get { return repeatedInt32_; }
+ get { return repeatedInt32_; }
}
public int RepeatedInt32Count {
get { return repeatedInt32_.Count; }
@@ -1875,9 +1875,9 @@ namespace Google.ProtocolBuffers.TestProtos {
}
// repeated int64 repeated_int64 = 32;
- private scg::IList<long> repeatedInt64_ = pbc::Lists<long>.Empty;
+ private pbc::PopsicleList<long> repeatedInt64_ = new pbc::PopsicleList<long>();
public scg::IList<long> RepeatedInt64List {
- get { return repeatedInt64_; }
+ get { return repeatedInt64_; }
}
public int RepeatedInt64Count {
get { return repeatedInt64_.Count; }
@@ -1887,9 +1887,9 @@ namespace Google.ProtocolBuffers.TestProtos {
}
// repeated uint32 repeated_uint32 = 33;
- private scg::IList<uint> repeatedUint32_ = pbc::Lists<uint>.Empty;
+ private pbc::PopsicleList<uint> repeatedUint32_ = new pbc::PopsicleList<uint>();
public scg::IList<uint> RepeatedUint32List {
- get { return repeatedUint32_; }
+ get { return repeatedUint32_; }
}
public int RepeatedUint32Count {
get { return repeatedUint32_.Count; }
@@ -1899,9 +1899,9 @@ namespace Google.ProtocolBuffers.TestProtos {
}
// repeated uint64 repeated_uint64 = 34;
- private scg::IList<ulong> repeatedUint64_ = pbc::Lists<ulong>.Empty;
+ private pbc::PopsicleList<ulong> repeatedUint64_ = new pbc::PopsicleList<ulong>();
public scg::IList<ulong> RepeatedUint64List {
- get { return repeatedUint64_; }
+ get { return repeatedUint64_; }
}
public int RepeatedUint64Count {
get { return repeatedUint64_.Count; }
@@ -1911,9 +1911,9 @@ namespace Google.ProtocolBuffers.TestProtos {
}
// repeated sint32 repeated_sint32 = 35;
- private scg::IList<int> repeatedSint32_ = pbc::Lists<int>.Empty;
+ private pbc::PopsicleList<int> repeatedSint32_ = new pbc::PopsicleList<int>();
public scg::IList<int> RepeatedSint32List {
- get { return repeatedSint32_; }
+ get { return repeatedSint32_; }
}
public int RepeatedSint32Count {
get { return repeatedSint32_.Count; }
@@ -1923,9 +1923,9 @@ namespace Google.ProtocolBuffers.TestProtos {
}
// repeated sint64 repeated_sint64 = 36;
- private scg::IList<long> repeatedSint64_ = pbc::Lists<long>.Empty;
+ private pbc::PopsicleList<long> repeatedSint64_ = new pbc::PopsicleList<long>();
public scg::IList<long> RepeatedSint64List {
- get { return repeatedSint64_; }
+ get { return repeatedSint64_; }
}
public int RepeatedSint64Count {
get { return repeatedSint64_.Count; }
@@ -1935,9 +1935,9 @@ namespace Google.ProtocolBuffers.TestProtos {
}
// repeated fixed32 repeated_fixed32 = 37;
- private scg::IList<uint> repeatedFixed32_ = pbc::Lists<uint>.Empty;
+ private pbc::PopsicleList<uint> repeatedFixed32_ = new pbc::PopsicleList<uint>();
public scg::IList<uint> RepeatedFixed32List {
- get { return repeatedFixed32_; }
+ get { return repeatedFixed32_; }
}
public int RepeatedFixed32Count {
get { return repeatedFixed32_.Count; }
@@ -1947,9 +1947,9 @@ namespace Google.ProtocolBuffers.TestProtos {
}
// repeated fixed64 repeated_fixed64 = 38;
- private scg::IList<ulong> repeatedFixed64_ = pbc::Lists<ulong>.Empty;
+ private pbc::PopsicleList<ulong> repeatedFixed64_ = new pbc::PopsicleList<ulong>();
public scg::IList<ulong> RepeatedFixed64List {
- get { return repeatedFixed64_; }
+ get { return repeatedFixed64_; }
}
public int RepeatedFixed64Count {
get { return repeatedFixed64_.Count; }
@@ -1959,9 +1959,9 @@ namespace Google.ProtocolBuffers.TestProtos {
}
// repeated sfixed32 repeated_sfixed32 = 39;
- private scg::IList<int> repeatedSfixed32_ = pbc::Lists<int>.Empty;
+ private pbc::PopsicleList<int> repeatedSfixed32_ = new pbc::PopsicleList<int>();
public scg::IList<int> RepeatedSfixed32List {
- get { return repeatedSfixed32_; }
+ get { return repeatedSfixed32_; }
}
public int RepeatedSfixed32Count {
get { return repeatedSfixed32_.Count; }
@@ -1971,9 +1971,9 @@ namespace Google.ProtocolBuffers.TestProtos {
}
// repeated sfixed64 repeated_sfixed64 = 40;
- private scg::IList<long> repeatedSfixed64_ = pbc::Lists<long>.Empty;
+ private pbc::PopsicleList<long> repeatedSfixed64_ = new pbc::PopsicleList<long>();
public scg::IList<long> RepeatedSfixed64List {
- get { return repeatedSfixed64_; }
+ get { return repeatedSfixed64_; }
}
public int RepeatedSfixed64Count {
get { return repeatedSfixed64_.Count; }
@@ -1983,9 +1983,9 @@ namespace Google.ProtocolBuffers.TestProtos {
}
// repeated float repeated_float = 41;
- private scg::IList<float> repeatedFloat_ = pbc::Lists<float>.Empty;
+ private pbc::PopsicleList<float> repeatedFloat_ = new pbc::PopsicleList<float>();
public scg::IList<float> RepeatedFloatList {
- get { return repeatedFloat_; }
+ get { return repeatedFloat_; }
}
public int RepeatedFloatCount {
get { return repeatedFloat_.Count; }
@@ -1995,9 +1995,9 @@ namespace Google.ProtocolBuffers.TestProtos {
}
// repeated double repeated_double = 42;
- private scg::IList<double> repeatedDouble_ = pbc::Lists<double>.Empty;
+ private pbc::PopsicleList<double> repeatedDouble_ = new pbc::PopsicleList<double>();
public scg::IList<double> RepeatedDoubleList {
- get { return repeatedDouble_; }
+ get { return repeatedDouble_; }
}
public int RepeatedDoubleCount {
get { return repeatedDouble_.Count; }
@@ -2007,9 +2007,9 @@ namespace Google.ProtocolBuffers.TestProtos {
}
// repeated bool repeated_bool = 43;
- private scg::IList<bool> repeatedBool_ = pbc::Lists<bool>.Empty;
+ private pbc::PopsicleList<bool> repeatedBool_ = new pbc::PopsicleList<bool>();
public scg::IList<bool> RepeatedBoolList {
- get { return repeatedBool_; }
+ get { return repeatedBool_; }
}
public int RepeatedBoolCount {
get { return repeatedBool_.Count; }
@@ -2019,9 +2019,9 @@ namespace Google.ProtocolBuffers.TestProtos {
}
// repeated string repeated_string = 44;
- private scg::IList<string> repeatedString_ = pbc::Lists<string>.Empty;
+ private pbc::PopsicleList<string> repeatedString_ = new pbc::PopsicleList<string>();
public scg::IList<string> RepeatedStringList {
- get { return repeatedString_; }
+ get { return repeatedString_; }
}
public int RepeatedStringCount {
get { return repeatedString_.Count; }
@@ -2031,9 +2031,9 @@ namespace Google.ProtocolBuffers.TestProtos {
}
// repeated bytes repeated_bytes = 45;
- private scg::IList<pb::ByteString> repeatedBytes_ = pbc::Lists<pb::ByteString>.Empty;
+ private pbc::PopsicleList<pb::ByteString> repeatedBytes_ = new pbc::PopsicleList<pb::ByteString>();
public scg::IList<pb::ByteString> RepeatedBytesList {
- get { return repeatedBytes_; }
+ get { return repeatedBytes_; }
}
public int RepeatedBytesCount {
get { return repeatedBytes_.Count; }
@@ -2043,7 +2043,7 @@ namespace Google.ProtocolBuffers.TestProtos {
}
// repeated group RepeatedGroup = 46 {
- private scg::IList<global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.RepeatedGroup> repeatedGroup_ = pbc::Lists<global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.RepeatedGroup>.Empty;
+ private pbc::PopsicleList<global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.RepeatedGroup> repeatedGroup_ = new pbc::PopsicleList<global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.RepeatedGroup>();
public scg::IList<global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.RepeatedGroup> RepeatedGroupList {
get { return repeatedGroup_; }
}
@@ -2055,7 +2055,7 @@ namespace Google.ProtocolBuffers.TestProtos {
}
// repeated .protobuf_unittest.TestAllTypes.NestedMessage repeated_nested_message = 48;
- private scg::IList<global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage> repeatedNestedMessage_ = pbc::Lists<global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage>.Empty;
+ private pbc::PopsicleList<global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage> repeatedNestedMessage_ = new pbc::PopsicleList<global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage>();
public scg::IList<global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage> RepeatedNestedMessageList {
get { return repeatedNestedMessage_; }
}
@@ -2067,7 +2067,7 @@ namespace Google.ProtocolBuffers.TestProtos {
}
// repeated .protobuf_unittest.ForeignMessage repeated_foreign_message = 49;
- private scg::IList<global::Google.ProtocolBuffers.TestProtos.ForeignMessage> repeatedForeignMessage_ = pbc::Lists<global::Google.ProtocolBuffers.TestProtos.ForeignMessage>.Empty;
+ private pbc::PopsicleList<global::Google.ProtocolBuffers.TestProtos.ForeignMessage> repeatedForeignMessage_ = new pbc::PopsicleList<global::Google.ProtocolBuffers.TestProtos.ForeignMessage>();
public scg::IList<global::Google.ProtocolBuffers.TestProtos.ForeignMessage> RepeatedForeignMessageList {
get { return repeatedForeignMessage_; }
}
@@ -2079,7 +2079,7 @@ namespace Google.ProtocolBuffers.TestProtos {
}
// repeated .protobuf_unittest_import.ImportMessage repeated_import_message = 50;
- private scg::IList<global::Google.ProtocolBuffers.TestProtos.ImportMessage> repeatedImportMessage_ = pbc::Lists<global::Google.ProtocolBuffers.TestProtos.ImportMessage>.Empty;
+ private pbc::PopsicleList<global::Google.ProtocolBuffers.TestProtos.ImportMessage> repeatedImportMessage_ = new pbc::PopsicleList<global::Google.ProtocolBuffers.TestProtos.ImportMessage>();
public scg::IList<global::Google.ProtocolBuffers.TestProtos.ImportMessage> RepeatedImportMessageList {
get { return repeatedImportMessage_; }
}
@@ -2127,9 +2127,9 @@ namespace Google.ProtocolBuffers.TestProtos {
}
// repeated string repeated_string_piece = 54 [ctype = STRING_PIECE];
- private scg::IList<string> repeatedStringPiece_ = pbc::Lists<string>.Empty;
+ private pbc::PopsicleList<string> repeatedStringPiece_ = new pbc::PopsicleList<string>();
public scg::IList<string> RepeatedStringPieceList {
- get { return repeatedStringPiece_; }
+ get { return repeatedStringPiece_; }
}
public int RepeatedStringPieceCount {
get { return repeatedStringPiece_.Count; }
@@ -2139,9 +2139,9 @@ namespace Google.ProtocolBuffers.TestProtos {
}
// repeated string repeated_cord = 55 [ctype = CORD];
- private scg::IList<string> repeatedCord_ = pbc::Lists<string>.Empty;
+ private pbc::PopsicleList<string> repeatedCord_ = new pbc::PopsicleList<string>();
public scg::IList<string> RepeatedCordList {
- get { return repeatedCord_; }
+ get { return repeatedCord_; }
}
public int RepeatedCordCount {
get { return repeatedCord_.Count; }
@@ -2873,38 +2873,30 @@ namespace Google.ProtocolBuffers.TestProtos {
}
public override global::Google.ProtocolBuffers.TestProtos.TestAllTypes BuildPartial() {
- result.repeatedInt32_ = pbc::Lists<int>.AsReadOnly(result.repeatedInt32_);
- result.repeatedInt64_ = pbc::Lists<long>.AsReadOnly(result.repeatedInt64_);
- result.repeatedUint32_ = pbc::Lists<uint>.AsReadOnly(result.repeatedUint32_);
- result.repeatedUint64_ = pbc::Lists<ulong>.AsReadOnly(result.repeatedUint64_);
- result.repeatedSint32_ = pbc::Lists<int>.AsReadOnly(result.repeatedSint32_);
- result.repeatedSint64_ = pbc::Lists<long>.AsReadOnly(result.repeatedSint64_);
- result.repeatedFixed32_ = pbc::Lists<uint>.AsReadOnly(result.repeatedFixed32_);
- result.repeatedFixed64_ = pbc::Lists<ulong>.AsReadOnly(result.repeatedFixed64_);
- result.repeatedSfixed32_ = pbc::Lists<int>.AsReadOnly(result.repeatedSfixed32_);
- result.repeatedSfixed64_ = pbc::Lists<long>.AsReadOnly(result.repeatedSfixed64_);
- result.repeatedFloat_ = pbc::Lists<float>.AsReadOnly(result.repeatedFloat_);
- result.repeatedDouble_ = pbc::Lists<double>.AsReadOnly(result.repeatedDouble_);
- result.repeatedBool_ = pbc::Lists<bool>.AsReadOnly(result.repeatedBool_);
- result.repeatedString_ = pbc::Lists<string>.AsReadOnly(result.repeatedString_);
- result.repeatedBytes_ = pbc::Lists<pb::ByteString>.AsReadOnly(result.repeatedBytes_);
- if (result.repeatedGroup_ != pbc::Lists<global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.RepeatedGroup>.Empty) {
- result.repeatedGroup_ = pbc::Lists<global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.RepeatedGroup>.AsReadOnly(result.repeatedGroup_);
- }
- if (result.repeatedNestedMessage_ != pbc::Lists<global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage>.Empty) {
- result.repeatedNestedMessage_ = pbc::Lists<global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage>.AsReadOnly(result.repeatedNestedMessage_);
- }
- if (result.repeatedForeignMessage_ != pbc::Lists<global::Google.ProtocolBuffers.TestProtos.ForeignMessage>.Empty) {
- result.repeatedForeignMessage_ = pbc::Lists<global::Google.ProtocolBuffers.TestProtos.ForeignMessage>.AsReadOnly(result.repeatedForeignMessage_);
- }
- if (result.repeatedImportMessage_ != pbc::Lists<global::Google.ProtocolBuffers.TestProtos.ImportMessage>.Empty) {
- result.repeatedImportMessage_ = pbc::Lists<global::Google.ProtocolBuffers.TestProtos.ImportMessage>.AsReadOnly(result.repeatedImportMessage_);
- }
+ result.repeatedInt32_.MakeReadOnly();
+ result.repeatedInt64_.MakeReadOnly();
+ result.repeatedUint32_.MakeReadOnly();
+ result.repeatedUint64_.MakeReadOnly();
+ result.repeatedSint32_.MakeReadOnly();
+ result.repeatedSint64_.MakeReadOnly();
+ result.repeatedFixed32_.MakeReadOnly();
+ result.repeatedFixed64_.MakeReadOnly();
+ result.repeatedSfixed32_.MakeReadOnly();
+ result.repeatedSfixed64_.MakeReadOnly();
+ result.repeatedFloat_.MakeReadOnly();
+ result.repeatedDouble_.MakeReadOnly();
+ result.repeatedBool_.MakeReadOnly();
+ result.repeatedString_.MakeReadOnly();
+ result.repeatedBytes_.MakeReadOnly();
+ result.repeatedGroup_.MakeReadOnly();
+ result.repeatedNestedMessage_.MakeReadOnly();
+ result.repeatedForeignMessage_.MakeReadOnly();
+ result.repeatedImportMessage_.MakeReadOnly();
result.repeatedNestedEnum_ = pbc::Lists.AsReadOnly(result.repeatedNestedEnum_);
result.repeatedForeignEnum_ = pbc::Lists.AsReadOnly(result.repeatedForeignEnum_);
result.repeatedImportEnum_ = pbc::Lists.AsReadOnly(result.repeatedImportEnum_);
- result.repeatedStringPiece_ = pbc::Lists<string>.AsReadOnly(result.repeatedStringPiece_);
- result.repeatedCord_ = pbc::Lists<string>.AsReadOnly(result.repeatedCord_);
+ result.repeatedStringPiece_.MakeReadOnly();
+ result.repeatedCord_.MakeReadOnly();
global::Google.ProtocolBuffers.TestProtos.TestAllTypes returnMe = result;
result = null;
return returnMe;
@@ -2994,117 +2986,60 @@ namespace Google.ProtocolBuffers.TestProtos {
OptionalCord = other.OptionalCord;
}
if (other.repeatedInt32_.Count != 0) {
- if (result.repeatedInt32_.Count == 0) {
- result.repeatedInt32_ = new scg::List<int>();
- }
base.AddRange(other.repeatedInt32_, result.repeatedInt32_);
}
if (other.repeatedInt64_.Count != 0) {
- if (result.repeatedInt64_.Count == 0) {
- result.repeatedInt64_ = new scg::List<long>();
- }
base.AddRange(other.repeatedInt64_, result.repeatedInt64_);
}
if (other.repeatedUint32_.Count != 0) {
- if (result.repeatedUint32_.Count == 0) {
- result.repeatedUint32_ = new scg::List<uint>();
- }
base.AddRange(other.repeatedUint32_, result.repeatedUint32_);
}
if (other.repeatedUint64_.Count != 0) {
- if (result.repeatedUint64_.Count == 0) {
- result.repeatedUint64_ = new scg::List<ulong>();
- }
base.AddRange(other.repeatedUint64_, result.repeatedUint64_);
}
if (other.repeatedSint32_.Count != 0) {
- if (result.repeatedSint32_.Count == 0) {
- result.repeatedSint32_ = new scg::List<int>();
- }
base.AddRange(other.repeatedSint32_, result.repeatedSint32_);
}
if (other.repeatedSint64_.Count != 0) {
- if (result.repeatedSint64_.Count == 0) {
- result.repeatedSint64_ = new scg::List<long>();
- }
base.AddRange(other.repeatedSint64_, result.repeatedSint64_);
}
if (other.repeatedFixed32_.Count != 0) {
- if (result.repeatedFixed32_.Count == 0) {
- result.repeatedFixed32_ = new scg::List<uint>();
- }
base.AddRange(other.repeatedFixed32_, result.repeatedFixed32_);
}
if (other.repeatedFixed64_.Count != 0) {
- if (result.repeatedFixed64_.Count == 0) {
- result.repeatedFixed64_ = new scg::List<ulong>();
- }
base.AddRange(other.repeatedFixed64_, result.repeatedFixed64_);
}
if (other.repeatedSfixed32_.Count != 0) {
- if (result.repeatedSfixed32_.Count == 0) {
- result.repeatedSfixed32_ = new scg::List<int>();
- }
base.AddRange(other.repeatedSfixed32_, result.repeatedSfixed32_);
}
if (other.repeatedSfixed64_.Count != 0) {
- if (result.repeatedSfixed64_.Count == 0) {
- result.repeatedSfixed64_ = new scg::List<long>();
- }
base.AddRange(other.repeatedSfixed64_, result.repeatedSfixed64_);
}
if (other.repeatedFloat_.Count != 0) {
- if (result.repeatedFloat_.Count == 0) {
- result.repeatedFloat_ = new scg::List<float>();
- }
base.AddRange(other.repeatedFloat_, result.repeatedFloat_);
}
if (other.repeatedDouble_.Count != 0) {
- if (result.repeatedDouble_.Count == 0) {
- result.repeatedDouble_ = new scg::List<double>();
- }
base.AddRange(other.repeatedDouble_, result.repeatedDouble_);
}
if (other.repeatedBool_.Count != 0) {
- if (result.repeatedBool_.Count == 0) {
- result.repeatedBool_ = new scg::List<bool>();
- }
base.AddRange(other.repeatedBool_, result.repeatedBool_);
}
if (other.repeatedString_.Count != 0) {
- if (result.repeatedString_.Count == 0) {
- result.repeatedString_ = new scg::List<string>();
- }
base.AddRange(other.repeatedString_, result.repeatedString_);
}
if (other.repeatedBytes_.Count != 0) {
- if (result.repeatedBytes_.Count == 0) {
- result.repeatedBytes_ = new scg::List<pb::ByteString>();
- }
base.AddRange(other.repeatedBytes_, result.repeatedBytes_);
}
if (other.repeatedGroup_.Count != 0) {
- if (result.repeatedGroup_.Count == 0) {
- result.repeatedGroup_ = new scg::List<global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.RepeatedGroup>();
- }
base.AddRange(other.repeatedGroup_, result.repeatedGroup_);
}
if (other.repeatedNestedMessage_.Count != 0) {
- if (result.repeatedNestedMessage_.Count == 0) {
- result.repeatedNestedMessage_ = new scg::List<global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage>();
- }
base.AddRange(other.repeatedNestedMessage_, result.repeatedNestedMessage_);
}
if (other.repeatedForeignMessage_.Count != 0) {
- if (result.repeatedForeignMessage_.Count == 0) {
- result.repeatedForeignMessage_ = new scg::List<global::Google.ProtocolBuffers.TestProtos.ForeignMessage>();
- }
base.AddRange(other.repeatedForeignMessage_, result.repeatedForeignMessage_);
}
if (other.repeatedImportMessage_.Count != 0) {
- if (result.repeatedImportMessage_.Count == 0) {
- result.repeatedImportMessage_ = new scg::List<global::Google.ProtocolBuffers.TestProtos.ImportMessage>();
- }
base.AddRange(other.repeatedImportMessage_, result.repeatedImportMessage_);
}
if (other.repeatedNestedEnum_.Count != 0) {
@@ -3126,15 +3061,9 @@ namespace Google.ProtocolBuffers.TestProtos {
base.AddRange(other.repeatedImportEnum_, result.repeatedImportEnum_);
}
if (other.repeatedStringPiece_.Count != 0) {
- if (result.repeatedStringPiece_.Count == 0) {
- result.repeatedStringPiece_ = new scg::List<string>();
- }
base.AddRange(other.repeatedStringPiece_, result.repeatedStringPiece_);
}
if (other.repeatedCord_.Count != 0) {
- if (result.repeatedCord_.Count == 0) {
- result.repeatedCord_ = new scg::List<string>();
- }
base.AddRange(other.repeatedCord_, result.repeatedCord_);
}
if (other.HasDefaultInt32) {
@@ -4097,7 +4026,7 @@ namespace Google.ProtocolBuffers.TestProtos {
// repeated int32 repeated_int32 = 31;
public scg::IList<int> RepeatedInt32List {
- get { return pbc::Lists<int>.AsReadOnly(result.repeatedInt32_); }
+ get { return result.repeatedInt32_; }
}
public int RepeatedInt32Count {
get { return result.RepeatedInt32Count; }
@@ -4110,27 +4039,21 @@ namespace Google.ProtocolBuffers.TestProtos {
return this;
}
public Builder AddRepeatedInt32(int value) {
- if (result.repeatedInt32_.Count == 0) {
- result.repeatedInt32_ = new scg::List<int>();
- }
result.repeatedInt32_.Add(value);
return this;
}
public Builder AddRangeRepeatedInt32(scg::IEnumerable<int> values) {
- if (result.repeatedInt32_.Count == 0) {
- result.repeatedInt32_ = new scg::List<int>();
- }
base.AddRange(values, result.repeatedInt32_);
return this;
}
public Builder ClearRepeatedInt32() {
- result.repeatedInt32_ = pbc::Lists<int>.Empty;
+ result.repeatedInt32_.Clear();
return this;
}
// repeated int64 repeated_int64 = 32;
public scg::IList<long> RepeatedInt64List {
- get { return pbc::Lists<long>.AsReadOnly(result.repeatedInt64_); }
+ get { return result.repeatedInt64_; }
}
public int RepeatedInt64Count {
get { return result.RepeatedInt64Count; }
@@ -4143,27 +4066,21 @@ namespace Google.ProtocolBuffers.TestProtos {
return this;
}
public Builder AddRepeatedInt64(long value) {
- if (result.repeatedInt64_.Count == 0) {
- result.repeatedInt64_ = new scg::List<long>();
- }
result.repeatedInt64_.Add(value);
return this;
}
public Builder AddRangeRepeatedInt64(scg::IEnumerable<long> values) {
- if (result.repeatedInt64_.Count == 0) {
- result.repeatedInt64_ = new scg::List<long>();
- }
base.AddRange(values, result.repeatedInt64_);
return this;
}
public Builder ClearRepeatedInt64() {
- result.repeatedInt64_ = pbc::Lists<long>.Empty;
+ result.repeatedInt64_.Clear();
return this;
}
// repeated uint32 repeated_uint32 = 33;
public scg::IList<uint> RepeatedUint32List {
- get { return pbc::Lists<uint>.AsReadOnly(result.repeatedUint32_); }
+ get { return result.repeatedUint32_; }
}
public int RepeatedUint32Count {
get { return result.RepeatedUint32Count; }
@@ -4176,27 +4093,21 @@ namespace Google.ProtocolBuffers.TestProtos {
return this;
}
public Builder AddRepeatedUint32(uint value) {
- if (result.repeatedUint32_.Count == 0) {
- result.repeatedUint32_ = new scg::List<uint>();
- }
result.repeatedUint32_.Add(value);
return this;
}
public Builder AddRangeRepeatedUint32(scg::IEnumerable<uint> values) {
- if (result.repeatedUint32_.Count == 0) {
- result.repeatedUint32_ = new scg::List<uint>();
- }
base.AddRange(values, result.repeatedUint32_);
return this;
}
public Builder ClearRepeatedUint32() {
- result.repeatedUint32_ = pbc::Lists<uint>.Empty;
+ result.repeatedUint32_.Clear();
return this;
}
// repeated uint64 repeated_uint64 = 34;
public scg::IList<ulong> RepeatedUint64List {
- get { return pbc::Lists<ulong>.AsReadOnly(result.repeatedUint64_); }
+ get { return result.repeatedUint64_; }
}
public int RepeatedUint64Count {
get { return result.RepeatedUint64Count; }
@@ -4209,27 +4120,21 @@ namespace Google.ProtocolBuffers.TestProtos {
return this;
}
public Builder AddRepeatedUint64(ulong value) {
- if (result.repeatedUint64_.Count == 0) {
- result.repeatedUint64_ = new scg::List<ulong>();
- }
result.repeatedUint64_.Add(value);
return this;
}
public Builder AddRangeRepeatedUint64(scg::IEnumerable<ulong> values) {
- if (result.repeatedUint64_.Count == 0) {
- result.repeatedUint64_ = new scg::List<ulong>();
- }
base.AddRange(values, result.repeatedUint64_);
return this;
}
public Builder ClearRepeatedUint64() {
- result.repeatedUint64_ = pbc::Lists<ulong>.Empty;
+ result.repeatedUint64_.Clear();
return this;
}
// repeated sint32 repeated_sint32 = 35;
public scg::IList<int> RepeatedSint32List {
- get { return pbc::Lists<int>.AsReadOnly(result.repeatedSint32_); }
+ get { return result.repeatedSint32_; }
}
public int RepeatedSint32Count {
get { return result.RepeatedSint32Count; }
@@ -4242,27 +4147,21 @@ namespace Google.ProtocolBuffers.TestProtos {
return this;
}
public Builder AddRepeatedSint32(int value) {
- if (result.repeatedSint32_.Count == 0) {
- result.repeatedSint32_ = new scg::List<int>();
- }
result.repeatedSint32_.Add(value);
return this;
}
public Builder AddRangeRepeatedSint32(scg::IEnumerable<int> values) {
- if (result.repeatedSint32_.Count == 0) {
- result.repeatedSint32_ = new scg::List<int>();
- }
base.AddRange(values, result.repeatedSint32_);
return this;
}
public Builder ClearRepeatedSint32() {
- result.repeatedSint32_ = pbc::Lists<int>.Empty;
+ result.repeatedSint32_.Clear();
return this;
}
// repeated sint64 repeated_sint64 = 36;
public scg::IList<long> RepeatedSint64List {
- get { return pbc::Lists<long>.AsReadOnly(result.repeatedSint64_); }
+ get { return result.repeatedSint64_; }
}
public int RepeatedSint64Count {
get { return result.RepeatedSint64Count; }
@@ -4275,27 +4174,21 @@ namespace Google.ProtocolBuffers.TestProtos {
return this;
}
public Builder AddRepeatedSint64(long value) {
- if (result.repeatedSint64_.Count == 0) {
- result.repeatedSint64_ = new scg::List<long>();
- }
result.repeatedSint64_.Add(value);
return this;
}
public Builder AddRangeRepeatedSint64(scg::IEnumerable<long> values) {
- if (result.repeatedSint64_.Count == 0) {
- result.repeatedSint64_ = new scg::List<long>();
- }
base.AddRange(values, result.repeatedSint64_);
return this;
}
public Builder ClearRepeatedSint64() {
- result.repeatedSint64_ = pbc::Lists<long>.Empty;
+ result.repeatedSint64_.Clear();
return this;
}
// repeated fixed32 repeated_fixed32 = 37;
public scg::IList<uint> RepeatedFixed32List {
- get { return pbc::Lists<uint>.AsReadOnly(result.repeatedFixed32_); }
+ get { return result.repeatedFixed32_; }
}
public int RepeatedFixed32Count {
get { return result.RepeatedFixed32Count; }
@@ -4308,27 +4201,21 @@ namespace Google.ProtocolBuffers.TestProtos {
return this;
}
public Builder AddRepeatedFixed32(uint value) {
- if (result.repeatedFixed32_.Count == 0) {
- result.repeatedFixed32_ = new scg::List<uint>();
- }
result.repeatedFixed32_.Add(value);
return this;
}
public Builder AddRangeRepeatedFixed32(scg::IEnumerable<uint> values) {
- if (result.repeatedFixed32_.Count == 0) {
- result.repeatedFixed32_ = new scg::List<uint>();
- }
base.AddRange(values, result.repeatedFixed32_);
return this;
}
public Builder ClearRepeatedFixed32() {
- result.repeatedFixed32_ = pbc::Lists<uint>.Empty;
+ result.repeatedFixed32_.Clear();
return this;
}
// repeated fixed64 repeated_fixed64 = 38;
public scg::IList<ulong> RepeatedFixed64List {
- get { return pbc::Lists<ulong>.AsReadOnly(result.repeatedFixed64_); }
+ get { return result.repeatedFixed64_; }
}
public int RepeatedFixed64Count {
get { return result.RepeatedFixed64Count; }
@@ -4341,27 +4228,21 @@ namespace Google.ProtocolBuffers.TestProtos {
return this;
}
public Builder AddRepeatedFixed64(ulong value) {
- if (result.repeatedFixed64_.Count == 0) {
- result.repeatedFixed64_ = new scg::List<ulong>();
- }
result.repeatedFixed64_.Add(value);
return this;
}
public Builder AddRangeRepeatedFixed64(scg::IEnumerable<ulong> values) {
- if (result.repeatedFixed64_.Count == 0) {
- result.repeatedFixed64_ = new scg::List<ulong>();
- }
base.AddRange(values, result.repeatedFixed64_);
return this;
}
public Builder ClearRepeatedFixed64() {
- result.repeatedFixed64_ = pbc::Lists<ulong>.Empty;
+ result.repeatedFixed64_.Clear();
return this;
}
// repeated sfixed32 repeated_sfixed32 = 39;
public scg::IList<int> RepeatedSfixed32List {
- get { return pbc::Lists<int>.AsReadOnly(result.repeatedSfixed32_); }
+ get { return result.repeatedSfixed32_; }
}
public int RepeatedSfixed32Count {
get { return result.RepeatedSfixed32Count; }
@@ -4374,27 +4255,21 @@ namespace Google.ProtocolBuffers.TestProtos {
return this;
}
public Builder AddRepeatedSfixed32(int value) {
- if (result.repeatedSfixed32_.Count == 0) {
- result.repeatedSfixed32_ = new scg::List<int>();
- }
result.repeatedSfixed32_.Add(value);
return this;
}
public Builder AddRangeRepeatedSfixed32(scg::IEnumerable<int> values) {
- if (result.repeatedSfixed32_.Count == 0) {
- result.repeatedSfixed32_ = new scg::List<int>();
- }
base.AddRange(values, result.repeatedSfixed32_);
return this;
}
public Builder ClearRepeatedSfixed32() {
- result.repeatedSfixed32_ = pbc::Lists<int>.Empty;
+ result.repeatedSfixed32_.Clear();
return this;
}
// repeated sfixed64 repeated_sfixed64 = 40;
public scg::IList<long> RepeatedSfixed64List {
- get { return pbc::Lists<long>.AsReadOnly(result.repeatedSfixed64_); }
+ get { return result.repeatedSfixed64_; }
}
public int RepeatedSfixed64Count {
get { return result.RepeatedSfixed64Count; }
@@ -4407,27 +4282,21 @@ namespace Google.ProtocolBuffers.TestProtos {
return this;
}
public Builder AddRepeatedSfixed64(long value) {
- if (result.repeatedSfixed64_.Count == 0) {
- result.repeatedSfixed64_ = new scg::List<long>();
- }
result.repeatedSfixed64_.Add(value);
return this;
}
public Builder AddRangeRepeatedSfixed64(scg::IEnumerable<long> values) {
- if (result.repeatedSfixed64_.Count == 0) {
- result.repeatedSfixed64_ = new scg::List<long>();
- }
base.AddRange(values, result.repeatedSfixed64_);
return this;
}
public Builder ClearRepeatedSfixed64() {
- result.repeatedSfixed64_ = pbc::Lists<long>.Empty;
+ result.repeatedSfixed64_.Clear();
return this;
}
// repeated float repeated_float = 41;
public scg::IList<float> RepeatedFloatList {
- get { return pbc::Lists<float>.AsReadOnly(result.repeatedFloat_); }
+ get { return result.repeatedFloat_; }
}
public int RepeatedFloatCount {
get { return result.RepeatedFloatCount; }
@@ -4440,27 +4309,21 @@ namespace Google.ProtocolBuffers.TestProtos {
return this;
}
public Builder AddRepeatedFloat(float value) {
- if (result.repeatedFloat_.Count == 0) {
- result.repeatedFloat_ = new scg::List<float>();
- }
result.repeatedFloat_.Add(value);
return this;
}
public Builder AddRangeRepeatedFloat(scg::IEnumerable<float> values) {
- if (result.repeatedFloat_.Count == 0) {
- result.repeatedFloat_ = new scg::List<float>();
- }
base.AddRange(values, result.repeatedFloat_);
return this;
}
public Builder ClearRepeatedFloat() {
- result.repeatedFloat_ = pbc::Lists<float>.Empty;
+ result.repeatedFloat_.Clear();
return this;
}
// repeated double repeated_double = 42;
public scg::IList<double> RepeatedDoubleList {
- get { return pbc::Lists<double>.AsReadOnly(result.repeatedDouble_); }
+ get { return result.repeatedDouble_; }
}
public int RepeatedDoubleCount {
get { return result.RepeatedDoubleCount; }
@@ -4473,27 +4336,21 @@ namespace Google.ProtocolBuffers.TestProtos {
return this;
}
public Builder AddRepeatedDouble(double value) {
- if (result.repeatedDouble_.Count == 0) {
- result.repeatedDouble_ = new scg::List<double>();
- }
result.repeatedDouble_.Add(value);
return this;
}
public Builder AddRangeRepeatedDouble(scg::IEnumerable<double> values) {
- if (result.repeatedDouble_.Count == 0) {
- result.repeatedDouble_ = new scg::List<double>();
- }
base.AddRange(values, result.repeatedDouble_);
return this;
}
public Builder ClearRepeatedDouble() {
- result.repeatedDouble_ = pbc::Lists<double>.Empty;
+ result.repeatedDouble_.Clear();
return this;
}
// repeated bool repeated_bool = 43;
public scg::IList<bool> RepeatedBoolList {
- get { return pbc::Lists<bool>.AsReadOnly(result.repeatedBool_); }
+ get { return result.repeatedBool_; }
}
public int RepeatedBoolCount {
get { return result.RepeatedBoolCount; }
@@ -4506,27 +4363,21 @@ namespace Google.ProtocolBuffers.TestProtos {
return this;
}
public Builder AddRepeatedBool(bool value) {
- if (result.repeatedBool_.Count == 0) {
- result.repeatedBool_ = new scg::List<bool>();
- }
result.repeatedBool_.Add(value);
return this;
}
public Builder AddRangeRepeatedBool(scg::IEnumerable<bool> values) {
- if (result.repeatedBool_.Count == 0) {
- result.repeatedBool_ = new scg::List<bool>();
- }
base.AddRange(values, result.repeatedBool_);
return this;
}
public Builder ClearRepeatedBool() {
- result.repeatedBool_ = pbc::Lists<bool>.Empty;
+ result.repeatedBool_.Clear();
return this;
}
// repeated string repeated_string = 44;
public scg::IList<string> RepeatedStringList {
- get { return pbc::Lists<string>.AsReadOnly(result.repeatedString_); }
+ get { return result.repeatedString_; }
}
public int RepeatedStringCount {
get { return result.RepeatedStringCount; }
@@ -4539,27 +4390,21 @@ namespace Google.ProtocolBuffers.TestProtos {
return this;
}
public Builder AddRepeatedString(string value) {
- if (result.repeatedString_.Count == 0) {
- result.repeatedString_ = new scg::List<string>();
- }
result.repeatedString_.Add(value);
return this;
}
public Builder AddRangeRepeatedString(scg::IEnumerable<string> values) {
- if (result.repeatedString_.Count == 0) {
- result.repeatedString_ = new scg::List<string>();
- }
base.AddRange(values, result.repeatedString_);
return this;
}
public Builder ClearRepeatedString() {
- result.repeatedString_ = pbc::Lists<string>.Empty;
+ result.repeatedString_.Clear();
return this;
}
// repeated bytes repeated_bytes = 45;
public scg::IList<pb::ByteString> RepeatedBytesList {
- get { return pbc::Lists<pb::ByteString>.AsReadOnly(result.repeatedBytes_); }
+ get { return result.repeatedBytes_; }
}
public int RepeatedBytesCount {
get { return result.RepeatedBytesCount; }
@@ -4572,27 +4417,21 @@ namespace Google.ProtocolBuffers.TestProtos {
return this;
}
public Builder AddRepeatedBytes(pb::ByteString value) {
- if (result.repeatedBytes_.Count == 0) {
- result.repeatedBytes_ = new scg::List<pb::ByteString>();
- }
result.repeatedBytes_.Add(value);
return this;
}
public Builder AddRangeRepeatedBytes(scg::IEnumerable<pb::ByteString> values) {
- if (result.repeatedBytes_.Count == 0) {
- result.repeatedBytes_ = new scg::List<pb::ByteString>();
- }
base.AddRange(values, result.repeatedBytes_);
return this;
}
public Builder ClearRepeatedBytes() {
- result.repeatedBytes_ = pbc::Lists<pb::ByteString>.Empty;
+ result.repeatedBytes_.Clear();
return this;
}
// repeated group RepeatedGroup = 46 {
public scg::IList<global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.RepeatedGroup> RepeatedGroupList {
- get { return pbc::Lists.AsReadOnly(result.repeatedGroup_); }
+ get { return result.repeatedGroup_; }
}
public int RepeatedGroupCount {
get { return result.RepeatedGroupCount; }
@@ -4609,34 +4448,25 @@ namespace Google.ProtocolBuffers.TestProtos {
return this;
}
public Builder AddRepeatedGroup(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.RepeatedGroup value) {
- if (result.repeatedGroup_ == pbc::Lists<global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.RepeatedGroup>.Empty) {
- result.repeatedGroup_ = new scg::List<global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.RepeatedGroup>();
- }
result.repeatedGroup_.Add(value);
return this;
}
public Builder AddRepeatedGroup(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.RepeatedGroup.Builder builderForValue) {
- if (result.repeatedGroup_ == pbc::Lists<global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.RepeatedGroup>.Empty) {
- result.repeatedGroup_ = new scg::List<global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.RepeatedGroup>();
- }
result.repeatedGroup_.Add(builderForValue.Build());
return this;
}
public Builder AddRangeRepeatedGroup(scg::IEnumerable<global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.RepeatedGroup> values) {
- if (result.repeatedGroup_ == pbc::Lists<global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.RepeatedGroup>.Empty) {
- result.repeatedGroup_ = new scg::List<global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.RepeatedGroup>();
- }
base.AddRange(values, result.repeatedGroup_);
return this;
}
public Builder ClearRepeatedGroup() {
- result.repeatedGroup_ = pbc::Lists<global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.RepeatedGroup>.Empty;
+ result.repeatedGroup_.Clear();
return this;
}
// repeated .protobuf_unittest.TestAllTypes.NestedMessage repeated_nested_message = 48;
public scg::IList<global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage> RepeatedNestedMessageList {
- get { return pbc::Lists.AsReadOnly(result.repeatedNestedMessage_); }
+ get { return result.repeatedNestedMessage_; }
}
public int RepeatedNestedMessageCount {
get { return result.RepeatedNestedMessageCount; }
@@ -4653,34 +4483,25 @@ namespace Google.ProtocolBuffers.TestProtos {
return this;
}
public Builder AddRepeatedNestedMessage(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage value) {
- if (result.repeatedNestedMessage_ == pbc::Lists<global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage>.Empty) {
- result.repeatedNestedMessage_ = new scg::List<global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage>();
- }
result.repeatedNestedMessage_.Add(value);
return this;
}
public Builder AddRepeatedNestedMessage(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage.Builder builderForValue) {
- if (result.repeatedNestedMessage_ == pbc::Lists<global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage>.Empty) {
- result.repeatedNestedMessage_ = new scg::List<global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage>();
- }
result.repeatedNestedMessage_.Add(builderForValue.Build());
return this;
}
public Builder AddRangeRepeatedNestedMessage(scg::IEnumerable<global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage> values) {
- if (result.repeatedNestedMessage_ == pbc::Lists<global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage>.Empty) {
- result.repeatedNestedMessage_ = new scg::List<global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage>();
- }
base.AddRange(values, result.repeatedNestedMessage_);
return this;
}
public Builder ClearRepeatedNestedMessage() {
- result.repeatedNestedMessage_ = pbc::Lists<global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage>.Empty;
+ result.repeatedNestedMessage_.Clear();
return this;
}
// repeated .protobuf_unittest.ForeignMessage repeated_foreign_message = 49;
public scg::IList<global::Google.ProtocolBuffers.TestProtos.ForeignMessage> RepeatedForeignMessageList {
- get { return pbc::Lists.AsReadOnly(result.repeatedForeignMessage_); }
+ get { return result.repeatedForeignMessage_; }
}
public int RepeatedForeignMessageCount {
get { return result.RepeatedForeignMessageCount; }
@@ -4697,34 +4518,25 @@ namespace Google.ProtocolBuffers.TestProtos {
return this;
}
public Builder AddRepeatedForeignMessage(global::Google.ProtocolBuffers.TestProtos.ForeignMessage value) {
- if (result.repeatedForeignMessage_ == pbc::Lists<global::Google.ProtocolBuffers.TestProtos.ForeignMessage>.Empty) {
- result.repeatedForeignMessage_ = new scg::List<global::Google.ProtocolBuffers.TestProtos.ForeignMessage>();
- }
result.repeatedForeignMessage_.Add(value);
return this;
}
public Builder AddRepeatedForeignMessage(global::Google.ProtocolBuffers.TestProtos.ForeignMessage.Builder builderForValue) {
- if (result.repeatedForeignMessage_ == pbc::Lists<global::Google.ProtocolBuffers.TestProtos.ForeignMessage>.Empty) {
- result.repeatedForeignMessage_ = new scg::List<global::Google.ProtocolBuffers.TestProtos.ForeignMessage>();
- }
result.repeatedForeignMessage_.Add(builderForValue.Build());
return this;
}
public Builder AddRangeRepeatedForeignMessage(scg::IEnumerable<global::Google.ProtocolBuffers.TestProtos.ForeignMessage> values) {
- if (result.repeatedForeignMessage_ == pbc::Lists<global::Google.ProtocolBuffers.TestProtos.ForeignMessage>.Empty) {
- result.repeatedForeignMessage_ = new scg::List<global::Google.ProtocolBuffers.TestProtos.ForeignMessage>();
- }
base.AddRange(values, result.repeatedForeignMessage_);
return this;
}
public Builder ClearRepeatedForeignMessage() {
- result.repeatedForeignMessage_ = pbc::Lists<global::Google.ProtocolBuffers.TestProtos.ForeignMessage>.Empty;
+ result.repeatedForeignMessage_.Clear();
return this;
}
// repeated .protobuf_unittest_import.ImportMessage repeated_import_message = 50;
public scg::IList<global::Google.ProtocolBuffers.TestProtos.ImportMessage> RepeatedImportMessageList {
- get { return pbc::Lists.AsReadOnly(result.repeatedImportMessage_); }
+ get { return result.repeatedImportMessage_; }
}
public int RepeatedImportMessageCount {
get { return result.RepeatedImportMessageCount; }
@@ -4741,28 +4553,19 @@ namespace Google.ProtocolBuffers.TestProtos {
return this;
}
public Builder AddRepeatedImportMessage(global::Google.ProtocolBuffers.TestProtos.ImportMessage value) {
- if (result.repeatedImportMessage_ == pbc::Lists<global::Google.ProtocolBuffers.TestProtos.ImportMessage>.Empty) {
- result.repeatedImportMessage_ = new scg::List<global::Google.ProtocolBuffers.TestProtos.ImportMessage>();
- }
result.repeatedImportMessage_.Add(value);
return this;
}
public Builder AddRepeatedImportMessage(global::Google.ProtocolBuffers.TestProtos.ImportMessage.Builder builderForValue) {
- if (result.repeatedImportMessage_ == pbc::Lists<global::Google.ProtocolBuffers.TestProtos.ImportMessage>.Empty) {
- result.repeatedImportMessage_ = new scg::List<global::Google.ProtocolBuffers.TestProtos.ImportMessage>();
- }
result.repeatedImportMessage_.Add(builderForValue.Build());
return this;
}
public Builder AddRangeRepeatedImportMessage(scg::IEnumerable<global::Google.ProtocolBuffers.TestProtos.ImportMessage> values) {
- if (result.repeatedImportMessage_ == pbc::Lists<global::Google.ProtocolBuffers.TestProtos.ImportMessage>.Empty) {
- result.repeatedImportMessage_ = new scg::List<global::Google.ProtocolBuffers.TestProtos.ImportMessage>();
- }
base.AddRange(values, result.repeatedImportMessage_);
return this;
}
public Builder ClearRepeatedImportMessage() {
- result.repeatedImportMessage_ = pbc::Lists<global::Google.ProtocolBuffers.TestProtos.ImportMessage>.Empty;
+ result.repeatedImportMessage_.Clear();
return this;
}
@@ -4867,7 +4670,7 @@ namespace Google.ProtocolBuffers.TestProtos {
// repeated string repeated_string_piece = 54 [ctype = STRING_PIECE];
public scg::IList<string> RepeatedStringPieceList {
- get { return pbc::Lists<string>.AsReadOnly(result.repeatedStringPiece_); }
+ get { return result.repeatedStringPiece_; }
}
public int RepeatedStringPieceCount {
get { return result.RepeatedStringPieceCount; }
@@ -4880,27 +4683,21 @@ namespace Google.ProtocolBuffers.TestProtos {
return this;
}
public Builder AddRepeatedStringPiece(string value) {
- if (result.repeatedStringPiece_.Count == 0) {
- result.repeatedStringPiece_ = new scg::List<string>();
- }
result.repeatedStringPiece_.Add(value);
return this;
}
public Builder AddRangeRepeatedStringPiece(scg::IEnumerable<string> values) {
- if (result.repeatedStringPiece_.Count == 0) {
- result.repeatedStringPiece_ = new scg::List<string>();
- }
base.AddRange(values, result.repeatedStringPiece_);
return this;
}
public Builder ClearRepeatedStringPiece() {
- result.repeatedStringPiece_ = pbc::Lists<string>.Empty;
+ result.repeatedStringPiece_.Clear();
return this;
}
// repeated string repeated_cord = 55 [ctype = CORD];
public scg::IList<string> RepeatedCordList {
- get { return pbc::Lists<string>.AsReadOnly(result.repeatedCord_); }
+ get { return result.repeatedCord_; }
}
public int RepeatedCordCount {
get { return result.RepeatedCordCount; }
@@ -4913,21 +4710,15 @@ namespace Google.ProtocolBuffers.TestProtos {
return this;
}
public Builder AddRepeatedCord(string value) {
- if (result.repeatedCord_.Count == 0) {
- result.repeatedCord_ = new scg::List<string>();
- }
result.repeatedCord_.Add(value);
return this;
}
public Builder AddRangeRepeatedCord(scg::IEnumerable<string> values) {
- if (result.repeatedCord_.Count == 0) {
- result.repeatedCord_ = new scg::List<string>();
- }
base.AddRange(values, result.repeatedCord_);
return this;
}
public Builder ClearRepeatedCord() {
- result.repeatedCord_ = pbc::Lists<string>.Empty;
+ result.repeatedCord_.Clear();
return this;
}
@@ -5314,7 +5105,7 @@ namespace Google.ProtocolBuffers.TestProtos {
}
public sealed partial class ForeignMessage : pb::GeneratedMessage<ForeignMessage, ForeignMessage.Builder> {
- private static readonly ForeignMessage defaultInstance = new ForeignMessage();
+ private static readonly ForeignMessage defaultInstance = new Builder().BuildPartial();
public static ForeignMessage DefaultInstance {
get { return defaultInstance; }
}
@@ -5521,7 +5312,7 @@ namespace Google.ProtocolBuffers.TestProtos {
}
public sealed partial class TestAllExtensions : pb::ExtendableMessage<TestAllExtensions, TestAllExtensions.Builder> {
- private static readonly TestAllExtensions defaultInstance = new TestAllExtensions();
+ private static readonly TestAllExtensions defaultInstance = new Builder().BuildPartial();
public static TestAllExtensions DefaultInstance {
get { return defaultInstance; }
}
@@ -5690,7 +5481,7 @@ namespace Google.ProtocolBuffers.TestProtos {
}
public sealed partial class OptionalGroup_extension : pb::GeneratedMessage<OptionalGroup_extension, OptionalGroup_extension.Builder> {
- private static readonly OptionalGroup_extension defaultInstance = new OptionalGroup_extension();
+ private static readonly OptionalGroup_extension defaultInstance = new Builder().BuildPartial();
public static OptionalGroup_extension DefaultInstance {
get { return defaultInstance; }
}
@@ -5897,7 +5688,7 @@ namespace Google.ProtocolBuffers.TestProtos {
}
public sealed partial class RepeatedGroup_extension : pb::GeneratedMessage<RepeatedGroup_extension, RepeatedGroup_extension.Builder> {
- private static readonly RepeatedGroup_extension defaultInstance = new RepeatedGroup_extension();
+ private static readonly RepeatedGroup_extension defaultInstance = new Builder().BuildPartial();
public static RepeatedGroup_extension DefaultInstance {
get { return defaultInstance; }
}
@@ -6104,7 +5895,7 @@ namespace Google.ProtocolBuffers.TestProtos {
}
public sealed partial class TestRequired : pb::GeneratedMessage<TestRequired, TestRequired.Builder> {
- private static readonly TestRequired defaultInstance = new TestRequired();
+ private static readonly TestRequired defaultInstance = new Builder().BuildPartial();
public static TestRequired DefaultInstance {
get { return defaultInstance; }
}
@@ -7668,7 +7459,7 @@ namespace Google.ProtocolBuffers.TestProtos {
}
public sealed partial class TestRequiredForeign : pb::GeneratedMessage<TestRequiredForeign, TestRequiredForeign.Builder> {
- private static readonly TestRequiredForeign defaultInstance = new TestRequiredForeign();
+ private static readonly TestRequiredForeign defaultInstance = new Builder().BuildPartial();
public static TestRequiredForeign DefaultInstance {
get { return defaultInstance; }
}
@@ -7700,7 +7491,7 @@ namespace Google.ProtocolBuffers.TestProtos {
}
// repeated .protobuf_unittest.TestRequired repeated_message = 2;
- private scg::IList<global::Google.ProtocolBuffers.TestProtos.TestRequired> repeatedMessage_ = pbc::Lists<global::Google.ProtocolBuffers.TestProtos.TestRequired>.Empty;
+ private pbc::PopsicleList<global::Google.ProtocolBuffers.TestProtos.TestRequired> repeatedMessage_ = new pbc::PopsicleList<global::Google.ProtocolBuffers.TestProtos.TestRequired>();
public scg::IList<global::Google.ProtocolBuffers.TestProtos.TestRequired> RepeatedMessageList {
get { return repeatedMessage_; }
}
@@ -7840,9 +7631,7 @@ namespace Google.ProtocolBuffers.TestProtos {
}
public override global::Google.ProtocolBuffers.TestProtos.TestRequiredForeign BuildPartial() {
- if (result.repeatedMessage_ != pbc::Lists<global::Google.ProtocolBuffers.TestProtos.TestRequired>.Empty) {
- result.repeatedMessage_ = pbc::Lists<global::Google.ProtocolBuffers.TestProtos.TestRequired>.AsReadOnly(result.repeatedMessage_);
- }
+ result.repeatedMessage_.MakeReadOnly();
global::Google.ProtocolBuffers.TestProtos.TestRequiredForeign returnMe = result;
result = null;
return returnMe;
@@ -7863,9 +7652,6 @@ namespace Google.ProtocolBuffers.TestProtos {
MergeOptionalMessage(other.OptionalMessage);
}
if (other.repeatedMessage_.Count != 0) {
- if (result.repeatedMessage_.Count == 0) {
- result.repeatedMessage_ = new scg::List<global::Google.ProtocolBuffers.TestProtos.TestRequired>();
- }
base.AddRange(other.repeatedMessage_, result.repeatedMessage_);
}
if (other.HasDummy) {
@@ -7957,7 +7743,7 @@ namespace Google.ProtocolBuffers.TestProtos {
// repeated .protobuf_unittest.TestRequired repeated_message = 2;
public scg::IList<global::Google.ProtocolBuffers.TestProtos.TestRequired> RepeatedMessageList {
- get { return pbc::Lists.AsReadOnly(result.repeatedMessage_); }
+ get { return result.repeatedMessage_; }
}
public int RepeatedMessageCount {
get { return result.RepeatedMessageCount; }
@@ -7974,28 +7760,19 @@ namespace Google.ProtocolBuffers.TestProtos {
return this;
}
public Builder AddRepeatedMessage(global::Google.ProtocolBuffers.TestProtos.TestRequired value) {
- if (result.repeatedMessage_ == pbc::Lists<global::Google.ProtocolBuffers.TestProtos.TestRequired>.Empty) {
- result.repeatedMessage_ = new scg::List<global::Google.ProtocolBuffers.TestProtos.TestRequired>();
- }
result.repeatedMessage_.Add(value);
return this;
}
public Builder AddRepeatedMessage(global::Google.ProtocolBuffers.TestProtos.TestRequired.Builder builderForValue) {
- if (result.repeatedMessage_ == pbc::Lists<global::Google.ProtocolBuffers.TestProtos.TestRequired>.Empty) {
- result.repeatedMessage_ = new scg::List<global::Google.ProtocolBuffers.TestProtos.TestRequired>();
- }
result.repeatedMessage_.Add(builderForValue.Build());
return this;
}
public Builder AddRangeRepeatedMessage(scg::IEnumerable<global::Google.ProtocolBuffers.TestProtos.TestRequired> values) {
- if (result.repeatedMessage_ == pbc::Lists<global::Google.ProtocolBuffers.TestProtos.TestRequired>.Empty) {
- result.repeatedMessage_ = new scg::List<global::Google.ProtocolBuffers.TestProtos.TestRequired>();
- }
base.AddRange(values, result.repeatedMessage_);
return this;
}
public Builder ClearRepeatedMessage() {
- result.repeatedMessage_ = pbc::Lists<global::Google.ProtocolBuffers.TestProtos.TestRequired>.Empty;
+ result.repeatedMessage_.Clear();
return this;
}
@@ -8021,7 +7798,7 @@ namespace Google.ProtocolBuffers.TestProtos {
}
public sealed partial class TestForeignNested : pb::GeneratedMessage<TestForeignNested, TestForeignNested.Builder> {
- private static readonly TestForeignNested defaultInstance = new TestForeignNested();
+ private static readonly TestForeignNested defaultInstance = new Builder().BuildPartial();
public static TestForeignNested DefaultInstance {
get { return defaultInstance; }
}
@@ -8249,7 +8026,7 @@ namespace Google.ProtocolBuffers.TestProtos {
}
public sealed partial class TestEmptyMessage : pb::GeneratedMessage<TestEmptyMessage, TestEmptyMessage.Builder> {
- private static readonly TestEmptyMessage defaultInstance = new TestEmptyMessage();
+ private static readonly TestEmptyMessage defaultInstance = new Builder().BuildPartial();
public static TestEmptyMessage DefaultInstance {
get { return defaultInstance; }
}
@@ -8414,7 +8191,7 @@ namespace Google.ProtocolBuffers.TestProtos {
}
public sealed partial class TestEmptyMessageWithExtensions : pb::ExtendableMessage<TestEmptyMessageWithExtensions, TestEmptyMessageWithExtensions.Builder> {
- private static readonly TestEmptyMessageWithExtensions defaultInstance = new TestEmptyMessageWithExtensions();
+ private static readonly TestEmptyMessageWithExtensions defaultInstance = new Builder().BuildPartial();
public static TestEmptyMessageWithExtensions DefaultInstance {
get { return defaultInstance; }
}
@@ -8583,7 +8360,7 @@ namespace Google.ProtocolBuffers.TestProtos {
}
public sealed partial class TestReallyLargeTagNumber : pb::GeneratedMessage<TestReallyLargeTagNumber, TestReallyLargeTagNumber.Builder> {
- private static readonly TestReallyLargeTagNumber defaultInstance = new TestReallyLargeTagNumber();
+ private static readonly TestReallyLargeTagNumber defaultInstance = new Builder().BuildPartial();
public static TestReallyLargeTagNumber DefaultInstance {
get { return defaultInstance; }
}
@@ -8832,7 +8609,7 @@ namespace Google.ProtocolBuffers.TestProtos {
}
public sealed partial class TestRecursiveMessage : pb::GeneratedMessage<TestRecursiveMessage, TestRecursiveMessage.Builder> {
- private static readonly TestRecursiveMessage defaultInstance = new TestRecursiveMessage();
+ private static readonly TestRecursiveMessage defaultInstance = new Builder().BuildPartial();
public static TestRecursiveMessage DefaultInstance {
get { return defaultInstance; }
}
@@ -9102,7 +8879,7 @@ namespace Google.ProtocolBuffers.TestProtos {
}
public sealed partial class TestMutualRecursionA : pb::GeneratedMessage<TestMutualRecursionA, TestMutualRecursionA.Builder> {
- private static readonly TestMutualRecursionA defaultInstance = new TestMutualRecursionA();
+ private static readonly TestMutualRecursionA defaultInstance = new Builder().BuildPartial();
public static TestMutualRecursionA DefaultInstance {
get { return defaultInstance; }
}
@@ -9330,7 +9107,7 @@ namespace Google.ProtocolBuffers.TestProtos {
}
public sealed partial class TestMutualRecursionB : pb::GeneratedMessage<TestMutualRecursionB, TestMutualRecursionB.Builder> {
- private static readonly TestMutualRecursionB defaultInstance = new TestMutualRecursionB();
+ private static readonly TestMutualRecursionB defaultInstance = new Builder().BuildPartial();
public static TestMutualRecursionB DefaultInstance {
get { return defaultInstance; }
}
@@ -9600,7 +9377,7 @@ namespace Google.ProtocolBuffers.TestProtos {
}
public sealed partial class TestDupFieldNumber : pb::GeneratedMessage<TestDupFieldNumber, TestDupFieldNumber.Builder> {
- private static readonly TestDupFieldNumber defaultInstance = new TestDupFieldNumber();
+ private static readonly TestDupFieldNumber defaultInstance = new Builder().BuildPartial();
public static TestDupFieldNumber DefaultInstance {
get { return defaultInstance; }
}
@@ -9624,7 +9401,7 @@ namespace Google.ProtocolBuffers.TestProtos {
#region Nested types
public static class Types {
public sealed partial class Foo : pb::GeneratedMessage<Foo, Foo.Builder> {
- private static readonly Foo defaultInstance = new Foo();
+ private static readonly Foo defaultInstance = new Builder().BuildPartial();
public static Foo DefaultInstance {
get { return defaultInstance; }
}
@@ -9831,7 +9608,7 @@ namespace Google.ProtocolBuffers.TestProtos {
}
public sealed partial class Bar : pb::GeneratedMessage<Bar, Bar.Builder> {
- private static readonly Bar defaultInstance = new Bar();
+ private static readonly Bar defaultInstance = new Builder().BuildPartial();
public static Bar DefaultInstance {
get { return defaultInstance; }
}
@@ -10352,7 +10129,7 @@ namespace Google.ProtocolBuffers.TestProtos {
}
public sealed partial class TestNestedMessageHasBits : pb::GeneratedMessage<TestNestedMessageHasBits, TestNestedMessageHasBits.Builder> {
- private static readonly TestNestedMessageHasBits defaultInstance = new TestNestedMessageHasBits();
+ private static readonly TestNestedMessageHasBits defaultInstance = new Builder().BuildPartial();
public static TestNestedMessageHasBits DefaultInstance {
get { return defaultInstance; }
}
@@ -10376,7 +10153,7 @@ namespace Google.ProtocolBuffers.TestProtos {
#region Nested types
public static class Types {
public sealed partial class NestedMessage : pb::GeneratedMessage<NestedMessage, NestedMessage.Builder> {
- private static readonly NestedMessage defaultInstance = new NestedMessage();
+ private static readonly NestedMessage defaultInstance = new Builder().BuildPartial();
public static NestedMessage DefaultInstance {
get { return defaultInstance; }
}
@@ -10398,9 +10175,9 @@ namespace Google.ProtocolBuffers.TestProtos {
}
// repeated int32 nestedmessage_repeated_int32 = 1;
- private scg::IList<int> nestedmessageRepeatedInt32_ = pbc::Lists<int>.Empty;
+ private pbc::PopsicleList<int> nestedmessageRepeatedInt32_ = new pbc::PopsicleList<int>();
public scg::IList<int> NestedmessageRepeatedInt32List {
- get { return nestedmessageRepeatedInt32_; }
+ get { return nestedmessageRepeatedInt32_; }
}
public int NestedmessageRepeatedInt32Count {
get { return nestedmessageRepeatedInt32_.Count; }
@@ -10410,7 +10187,7 @@ namespace Google.ProtocolBuffers.TestProtos {
}
// repeated .protobuf_unittest.ForeignMessage nestedmessage_repeated_foreignmessage = 2;
- private scg::IList<global::Google.ProtocolBuffers.TestProtos.ForeignMessage> nestedmessageRepeatedForeignmessage_ = pbc::Lists<global::Google.ProtocolBuffers.TestProtos.ForeignMessage>.Empty;
+ private pbc::PopsicleList<global::Google.ProtocolBuffers.TestProtos.ForeignMessage> nestedmessageRepeatedForeignmessage_ = new pbc::PopsicleList<global::Google.ProtocolBuffers.TestProtos.ForeignMessage>();
public scg::IList<global::Google.ProtocolBuffers.TestProtos.ForeignMessage> NestedmessageRepeatedForeignmessageList {
get { return nestedmessageRepeatedForeignmessage_; }
}
@@ -10529,10 +10306,8 @@ namespace Google.ProtocolBuffers.TestProtos {
}
public override global::Google.ProtocolBuffers.TestProtos.TestNestedMessageHasBits.Types.NestedMessage BuildPartial() {
- result.nestedmessageRepeatedInt32_ = pbc::Lists<int>.AsReadOnly(result.nestedmessageRepeatedInt32_);
- if (result.nestedmessageRepeatedForeignmessage_ != pbc::Lists<global::Google.ProtocolBuffers.TestProtos.ForeignMessage>.Empty) {
- result.nestedmessageRepeatedForeignmessage_ = pbc::Lists<global::Google.ProtocolBuffers.TestProtos.ForeignMessage>.AsReadOnly(result.nestedmessageRepeatedForeignmessage_);
- }
+ result.nestedmessageRepeatedInt32_.MakeReadOnly();
+ result.nestedmessageRepeatedForeignmessage_.MakeReadOnly();
global::Google.ProtocolBuffers.TestProtos.TestNestedMessageHasBits.Types.NestedMessage returnMe = result;
result = null;
return returnMe;
@@ -10550,15 +10325,9 @@ namespace Google.ProtocolBuffers.TestProtos {
public override Builder MergeFrom(global::Google.ProtocolBuffers.TestProtos.TestNestedMessageHasBits.Types.NestedMessage other) {
if (other == global::Google.ProtocolBuffers.TestProtos.TestNestedMessageHasBits.Types.NestedMessage.DefaultInstance) return this;
if (other.nestedmessageRepeatedInt32_.Count != 0) {
- if (result.nestedmessageRepeatedInt32_.Count == 0) {
- result.nestedmessageRepeatedInt32_ = new scg::List<int>();
- }
base.AddRange(other.nestedmessageRepeatedInt32_, result.nestedmessageRepeatedInt32_);
}
if (other.nestedmessageRepeatedForeignmessage_.Count != 0) {
- if (result.nestedmessageRepeatedForeignmessage_.Count == 0) {
- result.nestedmessageRepeatedForeignmessage_ = new scg::List<global::Google.ProtocolBuffers.TestProtos.ForeignMessage>();
- }
base.AddRange(other.nestedmessageRepeatedForeignmessage_, result.nestedmessageRepeatedForeignmessage_);
}
this.MergeUnknownFields(other.UnknownFields);
@@ -10603,7 +10372,7 @@ namespace Google.ProtocolBuffers.TestProtos {
// repeated int32 nestedmessage_repeated_int32 = 1;
public scg::IList<int> NestedmessageRepeatedInt32List {
- get { return pbc::Lists<int>.AsReadOnly(result.nestedmessageRepeatedInt32_); }
+ get { return result.nestedmessageRepeatedInt32_; }
}
public int NestedmessageRepeatedInt32Count {
get { return result.NestedmessageRepeatedInt32Count; }
@@ -10616,27 +10385,21 @@ namespace Google.ProtocolBuffers.TestProtos {
return this;
}
public Builder AddNestedmessageRepeatedInt32(int value) {
- if (result.nestedmessageRepeatedInt32_.Count == 0) {
- result.nestedmessageRepeatedInt32_ = new scg::List<int>();
- }
result.nestedmessageRepeatedInt32_.Add(value);
return this;
}
public Builder AddRangeNestedmessageRepeatedInt32(scg::IEnumerable<int> values) {
- if (result.nestedmessageRepeatedInt32_.Count == 0) {
- result.nestedmessageRepeatedInt32_ = new scg::List<int>();
- }
base.AddRange(values, result.nestedmessageRepeatedInt32_);
return this;
}
public Builder ClearNestedmessageRepeatedInt32() {
- result.nestedmessageRepeatedInt32_ = pbc::Lists<int>.Empty;
+ result.nestedmessageRepeatedInt32_.Clear();
return this;
}
// repeated .protobuf_unittest.ForeignMessage nestedmessage_repeated_foreignmessage = 2;
public scg::IList<global::Google.ProtocolBuffers.TestProtos.ForeignMessage> NestedmessageRepeatedForeignmessageList {
- get { return pbc::Lists.AsReadOnly(result.nestedmessageRepeatedForeignmessage_); }
+ get { return result.nestedmessageRepeatedForeignmessage_; }
}
public int NestedmessageRepeatedForeignmessageCount {
get { return result.NestedmessageRepeatedForeignmessageCount; }
@@ -10653,28 +10416,19 @@ namespace Google.ProtocolBuffers.TestProtos {
return this;
}
public Builder AddNestedmessageRepeatedForeignmessage(global::Google.ProtocolBuffers.TestProtos.ForeignMessage value) {
- if (result.nestedmessageRepeatedForeignmessage_ == pbc::Lists<global::Google.ProtocolBuffers.TestProtos.ForeignMessage>.Empty) {
- result.nestedmessageRepeatedForeignmessage_ = new scg::List<global::Google.ProtocolBuffers.TestProtos.ForeignMessage>();
- }
result.nestedmessageRepeatedForeignmessage_.Add(value);
return this;
}
public Builder AddNestedmessageRepeatedForeignmessage(global::Google.ProtocolBuffers.TestProtos.ForeignMessage.Builder builderForValue) {
- if (result.nestedmessageRepeatedForeignmessage_ == pbc::Lists<global::Google.ProtocolBuffers.TestProtos.ForeignMessage>.Empty) {
- result.nestedmessageRepeatedForeignmessage_ = new scg::List<global::Google.ProtocolBuffers.TestProtos.ForeignMessage>();
- }
result.nestedmessageRepeatedForeignmessage_.Add(builderForValue.Build());
return this;
}
public Builder AddRangeNestedmessageRepeatedForeignmessage(scg::IEnumerable<global::Google.ProtocolBuffers.TestProtos.ForeignMessage> values) {
- if (result.nestedmessageRepeatedForeignmessage_ == pbc::Lists<global::Google.ProtocolBuffers.TestProtos.ForeignMessage>.Empty) {
- result.nestedmessageRepeatedForeignmessage_ = new scg::List<global::Google.ProtocolBuffers.TestProtos.ForeignMessage>();
- }
base.AddRange(values, result.nestedmessageRepeatedForeignmessage_);
return this;
}
public Builder ClearNestedmessageRepeatedForeignmessage() {
- result.nestedmessageRepeatedForeignmessage_ = pbc::Lists<global::Google.ProtocolBuffers.TestProtos.ForeignMessage>.Empty;
+ result.nestedmessageRepeatedForeignmessage_.Clear();
return this;
}
}
@@ -10890,7 +10644,7 @@ namespace Google.ProtocolBuffers.TestProtos {
}
public sealed partial class TestCamelCaseFieldNames : pb::GeneratedMessage<TestCamelCaseFieldNames, TestCamelCaseFieldNames.Builder> {
- private static readonly TestCamelCaseFieldNames defaultInstance = new TestCamelCaseFieldNames();
+ private static readonly TestCamelCaseFieldNames defaultInstance = new Builder().BuildPartial();
public static TestCamelCaseFieldNames DefaultInstance {
get { return defaultInstance; }
}
@@ -10970,9 +10724,9 @@ namespace Google.ProtocolBuffers.TestProtos {
}
// repeated int32 RepeatedPrimitiveField = 7;
- private scg::IList<int> repeatedPrimitiveField_ = pbc::Lists<int>.Empty;
+ private pbc::PopsicleList<int> repeatedPrimitiveField_ = new pbc::PopsicleList<int>();
public scg::IList<int> RepeatedPrimitiveFieldList {
- get { return repeatedPrimitiveField_; }
+ get { return repeatedPrimitiveField_; }
}
public int RepeatedPrimitiveFieldCount {
get { return repeatedPrimitiveField_.Count; }
@@ -10982,9 +10736,9 @@ namespace Google.ProtocolBuffers.TestProtos {
}
// repeated string RepeatedStringField = 8;
- private scg::IList<string> repeatedStringField_ = pbc::Lists<string>.Empty;
+ private pbc::PopsicleList<string> repeatedStringField_ = new pbc::PopsicleList<string>();
public scg::IList<string> RepeatedStringFieldList {
- get { return repeatedStringField_; }
+ get { return repeatedStringField_; }
}
public int RepeatedStringFieldCount {
get { return repeatedStringField_.Count; }
@@ -11006,7 +10760,7 @@ namespace Google.ProtocolBuffers.TestProtos {
}
// repeated .protobuf_unittest.ForeignMessage RepeatedMessageField = 10;
- private scg::IList<global::Google.ProtocolBuffers.TestProtos.ForeignMessage> repeatedMessageField_ = pbc::Lists<global::Google.ProtocolBuffers.TestProtos.ForeignMessage>.Empty;
+ private pbc::PopsicleList<global::Google.ProtocolBuffers.TestProtos.ForeignMessage> repeatedMessageField_ = new pbc::PopsicleList<global::Google.ProtocolBuffers.TestProtos.ForeignMessage>();
public scg::IList<global::Google.ProtocolBuffers.TestProtos.ForeignMessage> RepeatedMessageFieldList {
get { return repeatedMessageField_; }
}
@@ -11018,9 +10772,9 @@ namespace Google.ProtocolBuffers.TestProtos {
}
// repeated string RepeatedStringPieceField = 11 [ctype = STRING_PIECE];
- private scg::IList<string> repeatedStringPieceField_ = pbc::Lists<string>.Empty;
+ private pbc::PopsicleList<string> repeatedStringPieceField_ = new pbc::PopsicleList<string>();
public scg::IList<string> RepeatedStringPieceFieldList {
- get { return repeatedStringPieceField_; }
+ get { return repeatedStringPieceField_; }
}
public int RepeatedStringPieceFieldCount {
get { return repeatedStringPieceField_.Count; }
@@ -11030,9 +10784,9 @@ namespace Google.ProtocolBuffers.TestProtos {
}
// repeated string RepeatedCordField = 12 [ctype = CORD];
- private scg::IList<string> repeatedCordField_ = pbc::Lists<string>.Empty;
+ private pbc::PopsicleList<string> repeatedCordField_ = new pbc::PopsicleList<string>();
public scg::IList<string> RepeatedCordFieldList {
- get { return repeatedCordField_; }
+ get { return repeatedCordField_; }
}
public int RepeatedCordFieldCount {
get { return repeatedCordField_.Count; }
@@ -11214,14 +10968,12 @@ namespace Google.ProtocolBuffers.TestProtos {
}
public override global::Google.ProtocolBuffers.TestProtos.TestCamelCaseFieldNames BuildPartial() {
- result.repeatedPrimitiveField_ = pbc::Lists<int>.AsReadOnly(result.repeatedPrimitiveField_);
- result.repeatedStringField_ = pbc::Lists<string>.AsReadOnly(result.repeatedStringField_);
+ result.repeatedPrimitiveField_.MakeReadOnly();
+ result.repeatedStringField_.MakeReadOnly();
result.repeatedEnumField_ = pbc::Lists.AsReadOnly(result.repeatedEnumField_);
- if (result.repeatedMessageField_ != pbc::Lists<global::Google.ProtocolBuffers.TestProtos.ForeignMessage>.Empty) {
- result.repeatedMessageField_ = pbc::Lists<global::Google.ProtocolBuffers.TestProtos.ForeignMessage>.AsReadOnly(result.repeatedMessageField_);
- }
- result.repeatedStringPieceField_ = pbc::Lists<string>.AsReadOnly(result.repeatedStringPieceField_);
- result.repeatedCordField_ = pbc::Lists<string>.AsReadOnly(result.repeatedCordField_);
+ result.repeatedMessageField_.MakeReadOnly();
+ result.repeatedStringPieceField_.MakeReadOnly();
+ result.repeatedCordField_.MakeReadOnly();
global::Google.ProtocolBuffers.TestProtos.TestCamelCaseFieldNames returnMe = result;
result = null;
return returnMe;
@@ -11257,15 +11009,9 @@ namespace Google.ProtocolBuffers.TestProtos {
CordField = other.CordField;
}
if (other.repeatedPrimitiveField_.Count != 0) {
- if (result.repeatedPrimitiveField_.Count == 0) {
- result.repeatedPrimitiveField_ = new scg::List<int>();
- }
base.AddRange(other.repeatedPrimitiveField_, result.repeatedPrimitiveField_);
}
if (other.repeatedStringField_.Count != 0) {
- if (result.repeatedStringField_.Count == 0) {
- result.repeatedStringField_ = new scg::List<string>();
- }
base.AddRange(other.repeatedStringField_, result.repeatedStringField_);
}
if (other.repeatedEnumField_.Count != 0) {
@@ -11275,21 +11021,12 @@ namespace Google.ProtocolBuffers.TestProtos {
base.AddRange(other.repeatedEnumField_, result.repeatedEnumField_);
}
if (other.repeatedMessageField_.Count != 0) {
- if (result.repeatedMessageField_.Count == 0) {
- result.repeatedMessageField_ = new scg::List<global::Google.ProtocolBuffers.TestProtos.ForeignMessage>();
- }
base.AddRange(other.repeatedMessageField_, result.repeatedMessageField_);
}
if (other.repeatedStringPieceField_.Count != 0) {
- if (result.repeatedStringPieceField_.Count == 0) {
- result.repeatedStringPieceField_ = new scg::List<string>();
- }
base.AddRange(other.repeatedStringPieceField_, result.repeatedStringPieceField_);
}
if (other.repeatedCordField_.Count != 0) {
- if (result.repeatedCordField_.Count == 0) {
- result.repeatedCordField_ = new scg::List<string>();
- }
base.AddRange(other.repeatedCordField_, result.repeatedCordField_);
}
this.MergeUnknownFields(other.UnknownFields);
@@ -11520,7 +11257,7 @@ namespace Google.ProtocolBuffers.TestProtos {
// repeated int32 RepeatedPrimitiveField = 7;
public scg::IList<int> RepeatedPrimitiveFieldList {
- get { return pbc::Lists<int>.AsReadOnly(result.repeatedPrimitiveField_); }
+ get { return result.repeatedPrimitiveField_; }
}
public int RepeatedPrimitiveFieldCount {
get { return result.RepeatedPrimitiveFieldCount; }
@@ -11533,27 +11270,21 @@ namespace Google.ProtocolBuffers.TestProtos {
return this;
}
public Builder AddRepeatedPrimitiveField(int value) {
- if (result.repeatedPrimitiveField_.Count == 0) {
- result.repeatedPrimitiveField_ = new scg::List<int>();
- }
result.repeatedPrimitiveField_.Add(value);
return this;
}
public Builder AddRangeRepeatedPrimitiveField(scg::IEnumerable<int> values) {
- if (result.repeatedPrimitiveField_.Count == 0) {
- result.repeatedPrimitiveField_ = new scg::List<int>();
- }
base.AddRange(values, result.repeatedPrimitiveField_);
return this;
}
public Builder ClearRepeatedPrimitiveField() {
- result.repeatedPrimitiveField_ = pbc::Lists<int>.Empty;
+ result.repeatedPrimitiveField_.Clear();
return this;
}
// repeated string RepeatedStringField = 8;
public scg::IList<string> RepeatedStringFieldList {
- get { return pbc::Lists<string>.AsReadOnly(result.repeatedStringField_); }
+ get { return result.repeatedStringField_; }
}
public int RepeatedStringFieldCount {
get { return result.RepeatedStringFieldCount; }
@@ -11566,21 +11297,15 @@ namespace Google.ProtocolBuffers.TestProtos {
return this;
}
public Builder AddRepeatedStringField(string value) {
- if (result.repeatedStringField_.Count == 0) {
- result.repeatedStringField_ = new scg::List<string>();
- }
result.repeatedStringField_.Add(value);
return this;
}
public Builder AddRangeRepeatedStringField(scg::IEnumerable<string> values) {
- if (result.repeatedStringField_.Count == 0) {
- result.repeatedStringField_ = new scg::List<string>();
- }
base.AddRange(values, result.repeatedStringField_);
return this;
}
public Builder ClearRepeatedStringField() {
- result.repeatedStringField_ = pbc::Lists<string>.Empty;
+ result.repeatedStringField_.Clear();
return this;
}
@@ -11619,7 +11344,7 @@ namespace Google.ProtocolBuffers.TestProtos {
// repeated .protobuf_unittest.ForeignMessage RepeatedMessageField = 10;
public scg::IList<global::Google.ProtocolBuffers.TestProtos.ForeignMessage> RepeatedMessageFieldList {
- get { return pbc::Lists.AsReadOnly(result.repeatedMessageField_); }
+ get { return result.repeatedMessageField_; }
}
public int RepeatedMessageFieldCount {
get { return result.RepeatedMessageFieldCount; }
@@ -11636,34 +11361,25 @@ namespace Google.ProtocolBuffers.TestProtos {
return this;
}
public Builder AddRepeatedMessageField(global::Google.ProtocolBuffers.TestProtos.ForeignMessage value) {
- if (result.repeatedMessageField_ == pbc::Lists<global::Google.ProtocolBuffers.TestProtos.ForeignMessage>.Empty) {
- result.repeatedMessageField_ = new scg::List<global::Google.ProtocolBuffers.TestProtos.ForeignMessage>();
- }
result.repeatedMessageField_.Add(value);
return this;
}
public Builder AddRepeatedMessageField(global::Google.ProtocolBuffers.TestProtos.ForeignMessage.Builder builderForValue) {
- if (result.repeatedMessageField_ == pbc::Lists<global::Google.ProtocolBuffers.TestProtos.ForeignMessage>.Empty) {
- result.repeatedMessageField_ = new scg::List<global::Google.ProtocolBuffers.TestProtos.ForeignMessage>();
- }
result.repeatedMessageField_.Add(builderForValue.Build());
return this;
}
public Builder AddRangeRepeatedMessageField(scg::IEnumerable<global::Google.ProtocolBuffers.TestProtos.ForeignMessage> values) {
- if (result.repeatedMessageField_ == pbc::Lists<global::Google.ProtocolBuffers.TestProtos.ForeignMessage>.Empty) {
- result.repeatedMessageField_ = new scg::List<global::Google.ProtocolBuffers.TestProtos.ForeignMessage>();
- }
base.AddRange(values, result.repeatedMessageField_);
return this;
}
public Builder ClearRepeatedMessageField() {
- result.repeatedMessageField_ = pbc::Lists<global::Google.ProtocolBuffers.TestProtos.ForeignMessage>.Empty;
+ result.repeatedMessageField_.Clear();
return this;
}
// repeated string RepeatedStringPieceField = 11 [ctype = STRING_PIECE];
public scg::IList<string> RepeatedStringPieceFieldList {
- get { return pbc::Lists<string>.AsReadOnly(result.repeatedStringPieceField_); }
+ get { return result.repeatedStringPieceField_; }
}
public int RepeatedStringPieceFieldCount {
get { return result.RepeatedStringPieceFieldCount; }
@@ -11676,27 +11392,21 @@ namespace Google.ProtocolBuffers.TestProtos {
return this;
}
public Builder AddRepeatedStringPieceField(string value) {
- if (result.repeatedStringPieceField_.Count == 0) {
- result.repeatedStringPieceField_ = new scg::List<string>();
- }
result.repeatedStringPieceField_.Add(value);
return this;
}
public Builder AddRangeRepeatedStringPieceField(scg::IEnumerable<string> values) {
- if (result.repeatedStringPieceField_.Count == 0) {
- result.repeatedStringPieceField_ = new scg::List<string>();
- }
base.AddRange(values, result.repeatedStringPieceField_);
return this;
}
public Builder ClearRepeatedStringPieceField() {
- result.repeatedStringPieceField_ = pbc::Lists<string>.Empty;
+ result.repeatedStringPieceField_.Clear();
return this;
}
// repeated string RepeatedCordField = 12 [ctype = CORD];
public scg::IList<string> RepeatedCordFieldList {
- get { return pbc::Lists<string>.AsReadOnly(result.repeatedCordField_); }
+ get { return result.repeatedCordField_; }
}
public int RepeatedCordFieldCount {
get { return result.RepeatedCordFieldCount; }
@@ -11709,28 +11419,22 @@ namespace Google.ProtocolBuffers.TestProtos {
return this;
}
public Builder AddRepeatedCordField(string value) {
- if (result.repeatedCordField_.Count == 0) {
- result.repeatedCordField_ = new scg::List<string>();
- }
result.repeatedCordField_.Add(value);
return this;
}
public Builder AddRangeRepeatedCordField(scg::IEnumerable<string> values) {
- if (result.repeatedCordField_.Count == 0) {
- result.repeatedCordField_ = new scg::List<string>();
- }
base.AddRange(values, result.repeatedCordField_);
return this;
}
public Builder ClearRepeatedCordField() {
- result.repeatedCordField_ = pbc::Lists<string>.Empty;
+ result.repeatedCordField_.Clear();
return this;
}
}
}
public sealed partial class TestFieldOrderings : pb::ExtendableMessage<TestFieldOrderings, TestFieldOrderings.Builder> {
- private static readonly TestFieldOrderings defaultInstance = new TestFieldOrderings();
+ private static readonly TestFieldOrderings defaultInstance = new Builder().BuildPartial();
public static TestFieldOrderings DefaultInstance {
get { return defaultInstance; }
}
@@ -12026,7 +11730,7 @@ namespace Google.ProtocolBuffers.TestProtos {
}
public sealed partial class TestExtremeDefaultValues : pb::GeneratedMessage<TestExtremeDefaultValues, TestExtremeDefaultValues.Builder> {
- private static readonly TestExtremeDefaultValues defaultInstance = new TestExtremeDefaultValues();
+ private static readonly TestExtremeDefaultValues defaultInstance = new Builder().BuildPartial();
public static TestExtremeDefaultValues DefaultInstance {
get { return defaultInstance; }
}
@@ -12443,7 +12147,7 @@ namespace Google.ProtocolBuffers.TestProtos {
}
public sealed partial class FooRequest : pb::GeneratedMessage<FooRequest, FooRequest.Builder> {
- private static readonly FooRequest defaultInstance = new FooRequest();
+ private static readonly FooRequest defaultInstance = new Builder().BuildPartial();
public static FooRequest DefaultInstance {
get { return defaultInstance; }
}
@@ -12608,7 +12312,7 @@ namespace Google.ProtocolBuffers.TestProtos {
}
public sealed partial class FooResponse : pb::GeneratedMessage<FooResponse, FooResponse.Builder> {
- private static readonly FooResponse defaultInstance = new FooResponse();
+ private static readonly FooResponse defaultInstance = new Builder().BuildPartial();
public static FooResponse DefaultInstance {
get { return defaultInstance; }
}
@@ -12773,7 +12477,7 @@ namespace Google.ProtocolBuffers.TestProtos {
}
public sealed partial class BarRequest : pb::GeneratedMessage<BarRequest, BarRequest.Builder> {
- private static readonly BarRequest defaultInstance = new BarRequest();
+ private static readonly BarRequest defaultInstance = new Builder().BuildPartial();
public static BarRequest DefaultInstance {
get { return defaultInstance; }
}
@@ -12938,7 +12642,7 @@ namespace Google.ProtocolBuffers.TestProtos {
}
public sealed partial class BarResponse : pb::GeneratedMessage<BarResponse, BarResponse.Builder> {
- private static readonly BarResponse defaultInstance = new BarResponse();
+ private static readonly BarResponse defaultInstance = new Builder().BuildPartial();
public static BarResponse DefaultInstance {
get { return defaultInstance; }
}
diff --git a/csharp/ProtocolBuffers/Collections/PopsicleList.cs b/csharp/ProtocolBuffers/Collections/PopsicleList.cs
new file mode 100644
index 00000000..4efe13d0
--- /dev/null
+++ b/csharp/ProtocolBuffers/Collections/PopsicleList.cs
@@ -0,0 +1,95 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Collections;
+
+namespace Google.ProtocolBuffers.Collections {
+ /// <summary>
+ /// Proxies calls to a <see cref="List{T}" />, but allows the list
+ /// to be made read-only (with the <see cref="MakeReadOnly" /> method),
+ /// after which any modifying methods throw <see cref="NotSupportedException" />.
+ /// </summary>
+ public sealed class PopsicleList<T> : IList<T> {
+
+ private readonly List<T> items = new List<T>();
+ private bool readOnly = false;
+
+ /// <summary>
+ /// Makes this list read-only ("freezes the popsicle"). From this
+ /// point on, mutating methods (Clear, Add etc) will throw a
+ /// NotSupportedException. There is no way of "defrosting" the list afterwards.
+ /// </summary>
+ public void MakeReadOnly() {
+ readOnly = true;
+ }
+
+ public int IndexOf(T item) {
+ return items.IndexOf(item);
+ }
+
+ public void Insert(int index, T item) {
+ ValidateModification();
+ items.Insert(index, item);
+ }
+
+ public void RemoveAt(int index) {
+ ValidateModification();
+ items.RemoveAt(index);
+ }
+
+ public T this[int index] {
+ get {
+ return items[index];
+ }
+ set {
+ ValidateModification();
+ items[index] = value;
+ }
+ }
+
+ public void Add(T item) {
+ ValidateModification();
+ items.Add(item);
+ }
+
+ public void Clear() {
+ ValidateModification();
+ items.Clear();
+ }
+
+ public bool Contains(T item) {
+ return items.Contains(item);
+ }
+
+ public void CopyTo(T[] array, int arrayIndex) {
+ items.CopyTo(array, arrayIndex);
+ }
+
+ public int Count {
+ get { return items.Count; }
+ }
+
+ public bool IsReadOnly {
+ get { return readOnly; }
+ }
+
+ public bool Remove(T item) {
+ ValidateModification();
+ return items.Remove(item);
+ }
+
+ public IEnumerator<T> GetEnumerator() {
+ return items.GetEnumerator();
+ }
+
+ IEnumerator IEnumerable.GetEnumerator() {
+ return GetEnumerator();
+ }
+
+ private void ValidateModification() {
+ if (readOnly) {
+ throw new NotSupportedException("List is read-only");
+ }
+ }
+ }
+}
diff --git a/csharp/ProtocolBuffers/Delegates.cs b/csharp/ProtocolBuffers/Delegates.cs
index 2aa440b1..08774019 100644
--- a/csharp/ProtocolBuffers/Delegates.cs
+++ b/csharp/ProtocolBuffers/Delegates.cs
@@ -1,8 +1,32 @@
-using System.IO;
-namespace Google.ProtocolBuffers {
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc.
+// http://code.google.com/p/protobuf/
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+using System.IO;
+namespace Google.ProtocolBuffers {
/// <summary>
/// Delegate to return a stream when asked, used by MessageStreamIterator.
/// </summary>
public delegate Stream StreamProvider();
+
+ // These delegate declarations mirror the ones in .NET 3.5 for the sake of familiarity.
+ internal delegate TResult Func<TResult>();
+ internal delegate TResult Func<T, TResult>(T arg);
+ internal delegate TResult Func<T1, T2, TResult>(T1 arg1, T2 arg2);
+ internal delegate TResult Func<T1, T2, T3, TResult>(T1 arg1, T2 arg2, T3 arg3);
+ internal delegate TResult Func<T1, T2, T3, T4, TResult>(T1 arg1, T2 arg2, T3 arg3, T4 arg4);
+ internal delegate void Action();
+ internal delegate void Action<T1, T2>(T1 arg1, T2 arg2);
}
diff --git a/csharp/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs b/csharp/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs
index e42c36f3..488b0c60 100644
--- a/csharp/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs
+++ b/csharp/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs
@@ -255,7 +255,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
#region Messages
public sealed partial class FileDescriptorSet : pb::GeneratedMessage<FileDescriptorSet, FileDescriptorSet.Builder> {
- private static readonly FileDescriptorSet defaultInstance = new FileDescriptorSet();
+ private static readonly FileDescriptorSet defaultInstance = new Builder().BuildPartial();
public static FileDescriptorSet DefaultInstance {
get { return defaultInstance; }
}
@@ -277,7 +277,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
}
// repeated .google.protobuf.FileDescriptorProto file = 1;
- private scg::IList<global::Google.ProtocolBuffers.DescriptorProtos.FileDescriptorProto> file_ = pbc::Lists<global::Google.ProtocolBuffers.DescriptorProtos.FileDescriptorProto>.Empty;
+ private pbc::PopsicleList<global::Google.ProtocolBuffers.DescriptorProtos.FileDescriptorProto> file_ = new pbc::PopsicleList<global::Google.ProtocolBuffers.DescriptorProtos.FileDescriptorProto>();
public scg::IList<global::Google.ProtocolBuffers.DescriptorProtos.FileDescriptorProto> FileList {
get { return file_; }
}
@@ -389,9 +389,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
}
public override global::Google.ProtocolBuffers.DescriptorProtos.FileDescriptorSet BuildPartial() {
- if (result.file_ != pbc::Lists<global::Google.ProtocolBuffers.DescriptorProtos.FileDescriptorProto>.Empty) {
- result.file_ = pbc::Lists<global::Google.ProtocolBuffers.DescriptorProtos.FileDescriptorProto>.AsReadOnly(result.file_);
- }
+ result.file_.MakeReadOnly();
global::Google.ProtocolBuffers.DescriptorProtos.FileDescriptorSet returnMe = result;
result = null;
return returnMe;
@@ -409,9 +407,6 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
public override Builder MergeFrom(global::Google.ProtocolBuffers.DescriptorProtos.FileDescriptorSet other) {
if (other == global::Google.ProtocolBuffers.DescriptorProtos.FileDescriptorSet.DefaultInstance) return this;
if (other.file_.Count != 0) {
- if (result.file_.Count == 0) {
- result.file_ = new scg::List<global::Google.ProtocolBuffers.DescriptorProtos.FileDescriptorProto>();
- }
base.AddRange(other.file_, result.file_);
}
this.MergeUnknownFields(other.UnknownFields);
@@ -452,7 +447,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
// repeated .google.protobuf.FileDescriptorProto file = 1;
public scg::IList<global::Google.ProtocolBuffers.DescriptorProtos.FileDescriptorProto> FileList {
- get { return pbc::Lists.AsReadOnly(result.file_); }
+ get { return result.file_; }
}
public int FileCount {
get { return result.FileCount; }
@@ -469,35 +464,26 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
return this;
}
public Builder AddFile(global::Google.ProtocolBuffers.DescriptorProtos.FileDescriptorProto value) {
- if (result.file_ == pbc::Lists<global::Google.ProtocolBuffers.DescriptorProtos.FileDescriptorProto>.Empty) {
- result.file_ = new scg::List<global::Google.ProtocolBuffers.DescriptorProtos.FileDescriptorProto>();
- }
result.file_.Add(value);
return this;
}
public Builder AddFile(global::Google.ProtocolBuffers.DescriptorProtos.FileDescriptorProto.Builder builderForValue) {
- if (result.file_ == pbc::Lists<global::Google.ProtocolBuffers.DescriptorProtos.FileDescriptorProto>.Empty) {
- result.file_ = new scg::List<global::Google.ProtocolBuffers.DescriptorProtos.FileDescriptorProto>();
- }
result.file_.Add(builderForValue.Build());
return this;
}
public Builder AddRangeFile(scg::IEnumerable<global::Google.ProtocolBuffers.DescriptorProtos.FileDescriptorProto> values) {
- if (result.file_ == pbc::Lists<global::Google.ProtocolBuffers.DescriptorProtos.FileDescriptorProto>.Empty) {
- result.file_ = new scg::List<global::Google.ProtocolBuffers.DescriptorProtos.FileDescriptorProto>();
- }
base.AddRange(values, result.file_);
return this;
}
public Builder ClearFile() {
- result.file_ = pbc::Lists<global::Google.ProtocolBuffers.DescriptorProtos.FileDescriptorProto>.Empty;
+ result.file_.Clear();
return this;
}
}
}
public sealed partial class FileDescriptorProto : pb::GeneratedMessage<FileDescriptorProto, FileDescriptorProto.Builder> {
- private static readonly FileDescriptorProto defaultInstance = new FileDescriptorProto();
+ private static readonly FileDescriptorProto defaultInstance = new Builder().BuildPartial();
public static FileDescriptorProto DefaultInstance {
get { return defaultInstance; }
}
@@ -539,9 +525,9 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
}
// repeated string dependency = 3;
- private scg::IList<string> dependency_ = pbc::Lists<string>.Empty;
+ private pbc::PopsicleList<string> dependency_ = new pbc::PopsicleList<string>();
public scg::IList<string> DependencyList {
- get { return dependency_; }
+ get { return dependency_; }
}
public int DependencyCount {
get { return dependency_.Count; }
@@ -551,7 +537,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
}
// repeated .google.protobuf.DescriptorProto message_type = 4;
- private scg::IList<global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto> messageType_ = pbc::Lists<global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto>.Empty;
+ private pbc::PopsicleList<global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto> messageType_ = new pbc::PopsicleList<global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto>();
public scg::IList<global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto> MessageTypeList {
get { return messageType_; }
}
@@ -563,7 +549,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
}
// repeated .google.protobuf.EnumDescriptorProto enum_type = 5;
- private scg::IList<global::Google.ProtocolBuffers.DescriptorProtos.EnumDescriptorProto> enumType_ = pbc::Lists<global::Google.ProtocolBuffers.DescriptorProtos.EnumDescriptorProto>.Empty;
+ private pbc::PopsicleList<global::Google.ProtocolBuffers.DescriptorProtos.EnumDescriptorProto> enumType_ = new pbc::PopsicleList<global::Google.ProtocolBuffers.DescriptorProtos.EnumDescriptorProto>();
public scg::IList<global::Google.ProtocolBuffers.DescriptorProtos.EnumDescriptorProto> EnumTypeList {
get { return enumType_; }
}
@@ -575,7 +561,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
}
// repeated .google.protobuf.ServiceDescriptorProto service = 6;
- private scg::IList<global::Google.ProtocolBuffers.DescriptorProtos.ServiceDescriptorProto> service_ = pbc::Lists<global::Google.ProtocolBuffers.DescriptorProtos.ServiceDescriptorProto>.Empty;
+ private pbc::PopsicleList<global::Google.ProtocolBuffers.DescriptorProtos.ServiceDescriptorProto> service_ = new pbc::PopsicleList<global::Google.ProtocolBuffers.DescriptorProtos.ServiceDescriptorProto>();
public scg::IList<global::Google.ProtocolBuffers.DescriptorProtos.ServiceDescriptorProto> ServiceList {
get { return service_; }
}
@@ -587,7 +573,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
}
// repeated .google.protobuf.FieldDescriptorProto extension = 7;
- private scg::IList<global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto> extension_ = pbc::Lists<global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto>.Empty;
+ private pbc::PopsicleList<global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto> extension_ = new pbc::PopsicleList<global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto>();
public scg::IList<global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto> ExtensionList {
get { return extension_; }
}
@@ -752,19 +738,11 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
}
public override global::Google.ProtocolBuffers.DescriptorProtos.FileDescriptorProto BuildPartial() {
- result.dependency_ = pbc::Lists<string>.AsReadOnly(result.dependency_);
- if (result.messageType_ != pbc::Lists<global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto>.Empty) {
- result.messageType_ = pbc::Lists<global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto>.AsReadOnly(result.messageType_);
- }
- if (result.enumType_ != pbc::Lists<global::Google.ProtocolBuffers.DescriptorProtos.EnumDescriptorProto>.Empty) {
- result.enumType_ = pbc::Lists<global::Google.ProtocolBuffers.DescriptorProtos.EnumDescriptorProto>.AsReadOnly(result.enumType_);
- }
- if (result.service_ != pbc::Lists<global::Google.ProtocolBuffers.DescriptorProtos.ServiceDescriptorProto>.Empty) {
- result.service_ = pbc::Lists<global::Google.ProtocolBuffers.DescriptorProtos.ServiceDescriptorProto>.AsReadOnly(result.service_);
- }
- if (result.extension_ != pbc::Lists<global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto>.Empty) {
- result.extension_ = pbc::Lists<global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto>.AsReadOnly(result.extension_);
- }
+ result.dependency_.MakeReadOnly();
+ result.messageType_.MakeReadOnly();
+ result.enumType_.MakeReadOnly();
+ result.service_.MakeReadOnly();
+ result.extension_.MakeReadOnly();
global::Google.ProtocolBuffers.DescriptorProtos.FileDescriptorProto returnMe = result;
result = null;
return returnMe;
@@ -788,33 +766,18 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
Package = other.Package;
}
if (other.dependency_.Count != 0) {
- if (result.dependency_.Count == 0) {
- result.dependency_ = new scg::List<string>();
- }
base.AddRange(other.dependency_, result.dependency_);
}
if (other.messageType_.Count != 0) {
- if (result.messageType_.Count == 0) {
- result.messageType_ = new scg::List<global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto>();
- }
base.AddRange(other.messageType_, result.messageType_);
}
if (other.enumType_.Count != 0) {
- if (result.enumType_.Count == 0) {
- result.enumType_ = new scg::List<global::Google.ProtocolBuffers.DescriptorProtos.EnumDescriptorProto>();
- }
base.AddRange(other.enumType_, result.enumType_);
}
if (other.service_.Count != 0) {
- if (result.service_.Count == 0) {
- result.service_ = new scg::List<global::Google.ProtocolBuffers.DescriptorProtos.ServiceDescriptorProto>();
- }
base.AddRange(other.service_, result.service_);
}
if (other.extension_.Count != 0) {
- if (result.extension_.Count == 0) {
- result.extension_ = new scg::List<global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto>();
- }
base.AddRange(other.extension_, result.extension_);
}
if (other.HasOptions) {
@@ -935,7 +898,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
// repeated string dependency = 3;
public scg::IList<string> DependencyList {
- get { return pbc::Lists<string>.AsReadOnly(result.dependency_); }
+ get { return result.dependency_; }
}
public int DependencyCount {
get { return result.DependencyCount; }
@@ -948,27 +911,21 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
return this;
}
public Builder AddDependency(string value) {
- if (result.dependency_.Count == 0) {
- result.dependency_ = new scg::List<string>();
- }
result.dependency_.Add(value);
return this;
}
public Builder AddRangeDependency(scg::IEnumerable<string> values) {
- if (result.dependency_.Count == 0) {
- result.dependency_ = new scg::List<string>();
- }
base.AddRange(values, result.dependency_);
return this;
}
public Builder ClearDependency() {
- result.dependency_ = pbc::Lists<string>.Empty;
+ result.dependency_.Clear();
return this;
}
// repeated .google.protobuf.DescriptorProto message_type = 4;
public scg::IList<global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto> MessageTypeList {
- get { return pbc::Lists.AsReadOnly(result.messageType_); }
+ get { return result.messageType_; }
}
public int MessageTypeCount {
get { return result.MessageTypeCount; }
@@ -985,34 +942,25 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
return this;
}
public Builder AddMessageType(global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto value) {
- if (result.messageType_ == pbc::Lists<global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto>.Empty) {
- result.messageType_ = new scg::List<global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto>();
- }
result.messageType_.Add(value);
return this;
}
public Builder AddMessageType(global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto.Builder builderForValue) {
- if (result.messageType_ == pbc::Lists<global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto>.Empty) {
- result.messageType_ = new scg::List<global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto>();
- }
result.messageType_.Add(builderForValue.Build());
return this;
}
public Builder AddRangeMessageType(scg::IEnumerable<global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto> values) {
- if (result.messageType_ == pbc::Lists<global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto>.Empty) {
- result.messageType_ = new scg::List<global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto>();
- }
base.AddRange(values, result.messageType_);
return this;
}
public Builder ClearMessageType() {
- result.messageType_ = pbc::Lists<global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto>.Empty;
+ result.messageType_.Clear();
return this;
}
// repeated .google.protobuf.EnumDescriptorProto enum_type = 5;
public scg::IList<global::Google.ProtocolBuffers.DescriptorProtos.EnumDescriptorProto> EnumTypeList {
- get { return pbc::Lists.AsReadOnly(result.enumType_); }
+ get { return result.enumType_; }
}
public int EnumTypeCount {
get { return result.EnumTypeCount; }
@@ -1029,34 +977,25 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
return this;
}
public Builder AddEnumType(global::Google.ProtocolBuffers.DescriptorProtos.EnumDescriptorProto value) {
- if (result.enumType_ == pbc::Lists<global::Google.ProtocolBuffers.DescriptorProtos.EnumDescriptorProto>.Empty) {
- result.enumType_ = new scg::List<global::Google.ProtocolBuffers.DescriptorProtos.EnumDescriptorProto>();
- }
result.enumType_.Add(value);
return this;
}
public Builder AddEnumType(global::Google.ProtocolBuffers.DescriptorProtos.EnumDescriptorProto.Builder builderForValue) {
- if (result.enumType_ == pbc::Lists<global::Google.ProtocolBuffers.DescriptorProtos.EnumDescriptorProto>.Empty) {
- result.enumType_ = new scg::List<global::Google.ProtocolBuffers.DescriptorProtos.EnumDescriptorProto>();
- }
result.enumType_.Add(builderForValue.Build());
return this;
}
public Builder AddRangeEnumType(scg::IEnumerable<global::Google.ProtocolBuffers.DescriptorProtos.EnumDescriptorProto> values) {
- if (result.enumType_ == pbc::Lists<global::Google.ProtocolBuffers.DescriptorProtos.EnumDescriptorProto>.Empty) {
- result.enumType_ = new scg::List<global::Google.ProtocolBuffers.DescriptorProtos.EnumDescriptorProto>();
- }
base.AddRange(values, result.enumType_);
return this;
}
public Builder ClearEnumType() {
- result.enumType_ = pbc::Lists<global::Google.ProtocolBuffers.DescriptorProtos.EnumDescriptorProto>.Empty;
+ result.enumType_.Clear();
return this;
}
// repeated .google.protobuf.ServiceDescriptorProto service = 6;
public scg::IList<global::Google.ProtocolBuffers.DescriptorProtos.ServiceDescriptorProto> ServiceList {
- get { return pbc::Lists.AsReadOnly(result.service_); }
+ get { return result.service_; }
}
public int ServiceCount {
get { return result.ServiceCount; }
@@ -1073,34 +1012,25 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
return this;
}
public Builder AddService(global::Google.ProtocolBuffers.DescriptorProtos.ServiceDescriptorProto value) {
- if (result.service_ == pbc::Lists<global::Google.ProtocolBuffers.DescriptorProtos.ServiceDescriptorProto>.Empty) {
- result.service_ = new scg::List<global::Google.ProtocolBuffers.DescriptorProtos.ServiceDescriptorProto>();
- }
result.service_.Add(value);
return this;
}
public Builder AddService(global::Google.ProtocolBuffers.DescriptorProtos.ServiceDescriptorProto.Builder builderForValue) {
- if (result.service_ == pbc::Lists<global::Google.ProtocolBuffers.DescriptorProtos.ServiceDescriptorProto>.Empty) {
- result.service_ = new scg::List<global::Google.ProtocolBuffers.DescriptorProtos.ServiceDescriptorProto>();
- }
result.service_.Add(builderForValue.Build());
return this;
}
public Builder AddRangeService(scg::IEnumerable<global::Google.ProtocolBuffers.DescriptorProtos.ServiceDescriptorProto> values) {
- if (result.service_ == pbc::Lists<global::Google.ProtocolBuffers.DescriptorProtos.ServiceDescriptorProto>.Empty) {
- result.service_ = new scg::List<global::Google.ProtocolBuffers.DescriptorProtos.ServiceDescriptorProto>();
- }
base.AddRange(values, result.service_);
return this;
}
public Builder ClearService() {
- result.service_ = pbc::Lists<global::Google.ProtocolBuffers.DescriptorProtos.ServiceDescriptorProto>.Empty;
+ result.service_.Clear();
return this;
}
// repeated .google.protobuf.FieldDescriptorProto extension = 7;
public scg::IList<global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto> ExtensionList {
- get { return pbc::Lists.AsReadOnly(result.extension_); }
+ get { return result.extension_; }
}
public int ExtensionCount {
get { return result.ExtensionCount; }
@@ -1117,28 +1047,19 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
return this;
}
public Builder AddExtension(global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto value) {
- if (result.extension_ == pbc::Lists<global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto>.Empty) {
- result.extension_ = new scg::List<global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto>();
- }
result.extension_.Add(value);
return this;
}
public Builder AddExtension(global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto.Builder builderForValue) {
- if (result.extension_ == pbc::Lists<global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto>.Empty) {
- result.extension_ = new scg::List<global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto>();
- }
result.extension_.Add(builderForValue.Build());
return this;
}
public Builder AddRangeExtension(scg::IEnumerable<global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto> values) {
- if (result.extension_ == pbc::Lists<global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto>.Empty) {
- result.extension_ = new scg::List<global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto>();
- }
base.AddRange(values, result.extension_);
return this;
}
public Builder ClearExtension() {
- result.extension_ = pbc::Lists<global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto>.Empty;
+ result.extension_.Clear();
return this;
}
@@ -1180,7 +1101,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
}
public sealed partial class DescriptorProto : pb::GeneratedMessage<DescriptorProto, DescriptorProto.Builder> {
- private static readonly DescriptorProto defaultInstance = new DescriptorProto();
+ private static readonly DescriptorProto defaultInstance = new Builder().BuildPartial();
public static DescriptorProto DefaultInstance {
get { return defaultInstance; }
}
@@ -1204,7 +1125,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
#region Nested types
public static class Types {
public sealed partial class ExtensionRange : pb::GeneratedMessage<ExtensionRange, ExtensionRange.Builder> {
- private static readonly ExtensionRange defaultInstance = new ExtensionRange();
+ private static readonly ExtensionRange defaultInstance = new Builder().BuildPartial();
public static ExtensionRange DefaultInstance {
get { return defaultInstance; }
}
@@ -1466,7 +1387,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
}
// repeated .google.protobuf.FieldDescriptorProto field = 2;
- private scg::IList<global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto> field_ = pbc::Lists<global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto>.Empty;
+ private pbc::PopsicleList<global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto> field_ = new pbc::PopsicleList<global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto>();
public scg::IList<global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto> FieldList {
get { return field_; }
}
@@ -1478,7 +1399,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
}
// repeated .google.protobuf.FieldDescriptorProto extension = 6;
- private scg::IList<global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto> extension_ = pbc::Lists<global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto>.Empty;
+ private pbc::PopsicleList<global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto> extension_ = new pbc::PopsicleList<global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto>();
public scg::IList<global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto> ExtensionList {
get { return extension_; }
}
@@ -1490,7 +1411,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
}
// repeated .google.protobuf.DescriptorProto nested_type = 3;
- private scg::IList<global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto> nestedType_ = pbc::Lists<global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto>.Empty;
+ private pbc::PopsicleList<global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto> nestedType_ = new pbc::PopsicleList<global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto>();
public scg::IList<global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto> NestedTypeList {
get { return nestedType_; }
}
@@ -1502,7 +1423,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
}
// repeated .google.protobuf.EnumDescriptorProto enum_type = 4;
- private scg::IList<global::Google.ProtocolBuffers.DescriptorProtos.EnumDescriptorProto> enumType_ = pbc::Lists<global::Google.ProtocolBuffers.DescriptorProtos.EnumDescriptorProto>.Empty;
+ private pbc::PopsicleList<global::Google.ProtocolBuffers.DescriptorProtos.EnumDescriptorProto> enumType_ = new pbc::PopsicleList<global::Google.ProtocolBuffers.DescriptorProtos.EnumDescriptorProto>();
public scg::IList<global::Google.ProtocolBuffers.DescriptorProtos.EnumDescriptorProto> EnumTypeList {
get { return enumType_; }
}
@@ -1514,7 +1435,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
}
// repeated .google.protobuf.DescriptorProto.ExtensionRange extension_range = 5;
- private scg::IList<global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto.Types.ExtensionRange> extensionRange_ = pbc::Lists<global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto.Types.ExtensionRange>.Empty;
+ private pbc::PopsicleList<global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto.Types.ExtensionRange> extensionRange_ = new pbc::PopsicleList<global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto.Types.ExtensionRange>();
public scg::IList<global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto.Types.ExtensionRange> ExtensionRangeList {
get { return extensionRange_; }
}
@@ -1672,21 +1593,11 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
}
public override global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto BuildPartial() {
- if (result.field_ != pbc::Lists<global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto>.Empty) {
- result.field_ = pbc::Lists<global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto>.AsReadOnly(result.field_);
- }
- if (result.extension_ != pbc::Lists<global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto>.Empty) {
- result.extension_ = pbc::Lists<global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto>.AsReadOnly(result.extension_);
- }
- if (result.nestedType_ != pbc::Lists<global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto>.Empty) {
- result.nestedType_ = pbc::Lists<global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto>.AsReadOnly(result.nestedType_);
- }
- if (result.enumType_ != pbc::Lists<global::Google.ProtocolBuffers.DescriptorProtos.EnumDescriptorProto>.Empty) {
- result.enumType_ = pbc::Lists<global::Google.ProtocolBuffers.DescriptorProtos.EnumDescriptorProto>.AsReadOnly(result.enumType_);
- }
- if (result.extensionRange_ != pbc::Lists<global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto.Types.ExtensionRange>.Empty) {
- result.extensionRange_ = pbc::Lists<global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto.Types.ExtensionRange>.AsReadOnly(result.extensionRange_);
- }
+ result.field_.MakeReadOnly();
+ result.extension_.MakeReadOnly();
+ result.nestedType_.MakeReadOnly();
+ result.enumType_.MakeReadOnly();
+ result.extensionRange_.MakeReadOnly();
global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto returnMe = result;
result = null;
return returnMe;
@@ -1707,33 +1618,18 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
Name = other.Name;
}
if (other.field_.Count != 0) {
- if (result.field_.Count == 0) {
- result.field_ = new scg::List<global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto>();
- }
base.AddRange(other.field_, result.field_);
}
if (other.extension_.Count != 0) {
- if (result.extension_.Count == 0) {
- result.extension_ = new scg::List<global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto>();
- }
base.AddRange(other.extension_, result.extension_);
}
if (other.nestedType_.Count != 0) {
- if (result.nestedType_.Count == 0) {
- result.nestedType_ = new scg::List<global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto>();
- }
base.AddRange(other.nestedType_, result.nestedType_);
}
if (other.enumType_.Count != 0) {
- if (result.enumType_.Count == 0) {
- result.enumType_ = new scg::List<global::Google.ProtocolBuffers.DescriptorProtos.EnumDescriptorProto>();
- }
base.AddRange(other.enumType_, result.enumType_);
}
if (other.extensionRange_.Count != 0) {
- if (result.extensionRange_.Count == 0) {
- result.extensionRange_ = new scg::List<global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto.Types.ExtensionRange>();
- }
base.AddRange(other.extensionRange_, result.extensionRange_);
}
if (other.HasOptions) {
@@ -1833,7 +1729,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
// repeated .google.protobuf.FieldDescriptorProto field = 2;
public scg::IList<global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto> FieldList {
- get { return pbc::Lists.AsReadOnly(result.field_); }
+ get { return result.field_; }
}
public int FieldCount {
get { return result.FieldCount; }
@@ -1850,34 +1746,25 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
return this;
}
public Builder AddField(global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto value) {
- if (result.field_ == pbc::Lists<global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto>.Empty) {
- result.field_ = new scg::List<global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto>();
- }
result.field_.Add(value);
return this;
}
public Builder AddField(global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto.Builder builderForValue) {
- if (result.field_ == pbc::Lists<global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto>.Empty) {
- result.field_ = new scg::List<global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto>();
- }
result.field_.Add(builderForValue.Build());
return this;
}
public Builder AddRangeField(scg::IEnumerable<global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto> values) {
- if (result.field_ == pbc::Lists<global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto>.Empty) {
- result.field_ = new scg::List<global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto>();
- }
base.AddRange(values, result.field_);
return this;
}
public Builder ClearField() {
- result.field_ = pbc::Lists<global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto>.Empty;
+ result.field_.Clear();
return this;
}
// repeated .google.protobuf.FieldDescriptorProto extension = 6;
public scg::IList<global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto> ExtensionList {
- get { return pbc::Lists.AsReadOnly(result.extension_); }
+ get { return result.extension_; }
}
public int ExtensionCount {
get { return result.ExtensionCount; }
@@ -1894,34 +1781,25 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
return this;
}
public Builder AddExtension(global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto value) {
- if (result.extension_ == pbc::Lists<global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto>.Empty) {
- result.extension_ = new scg::List<global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto>();
- }
result.extension_.Add(value);
return this;
}
public Builder AddExtension(global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto.Builder builderForValue) {
- if (result.extension_ == pbc::Lists<global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto>.Empty) {
- result.extension_ = new scg::List<global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto>();
- }
result.extension_.Add(builderForValue.Build());
return this;
}
public Builder AddRangeExtension(scg::IEnumerable<global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto> values) {
- if (result.extension_ == pbc::Lists<global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto>.Empty) {
- result.extension_ = new scg::List<global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto>();
- }
base.AddRange(values, result.extension_);
return this;
}
public Builder ClearExtension() {
- result.extension_ = pbc::Lists<global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto>.Empty;
+ result.extension_.Clear();
return this;
}
// repeated .google.protobuf.DescriptorProto nested_type = 3;
public scg::IList<global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto> NestedTypeList {
- get { return pbc::Lists.AsReadOnly(result.nestedType_); }
+ get { return result.nestedType_; }
}
public int NestedTypeCount {
get { return result.NestedTypeCount; }
@@ -1938,34 +1816,25 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
return this;
}
public Builder AddNestedType(global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto value) {
- if (result.nestedType_ == pbc::Lists<global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto>.Empty) {
- result.nestedType_ = new scg::List<global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto>();
- }
result.nestedType_.Add(value);
return this;
}
public Builder AddNestedType(global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto.Builder builderForValue) {
- if (result.nestedType_ == pbc::Lists<global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto>.Empty) {
- result.nestedType_ = new scg::List<global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto>();
- }
result.nestedType_.Add(builderForValue.Build());
return this;
}
public Builder AddRangeNestedType(scg::IEnumerable<global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto> values) {
- if (result.nestedType_ == pbc::Lists<global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto>.Empty) {
- result.nestedType_ = new scg::List<global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto>();
- }
base.AddRange(values, result.nestedType_);
return this;
}
public Builder ClearNestedType() {
- result.nestedType_ = pbc::Lists<global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto>.Empty;
+ result.nestedType_.Clear();
return this;
}
// repeated .google.protobuf.EnumDescriptorProto enum_type = 4;
public scg::IList<global::Google.ProtocolBuffers.DescriptorProtos.EnumDescriptorProto> EnumTypeList {
- get { return pbc::Lists.AsReadOnly(result.enumType_); }
+ get { return result.enumType_; }
}
public int EnumTypeCount {
get { return result.EnumTypeCount; }
@@ -1982,34 +1851,25 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
return this;
}
public Builder AddEnumType(global::Google.ProtocolBuffers.DescriptorProtos.EnumDescriptorProto value) {
- if (result.enumType_ == pbc::Lists<global::Google.ProtocolBuffers.DescriptorProtos.EnumDescriptorProto>.Empty) {
- result.enumType_ = new scg::List<global::Google.ProtocolBuffers.DescriptorProtos.EnumDescriptorProto>();
- }
result.enumType_.Add(value);
return this;
}
public Builder AddEnumType(global::Google.ProtocolBuffers.DescriptorProtos.EnumDescriptorProto.Builder builderForValue) {
- if (result.enumType_ == pbc::Lists<global::Google.ProtocolBuffers.DescriptorProtos.EnumDescriptorProto>.Empty) {
- result.enumType_ = new scg::List<global::Google.ProtocolBuffers.DescriptorProtos.EnumDescriptorProto>();
- }
result.enumType_.Add(builderForValue.Build());
return this;
}
public Builder AddRangeEnumType(scg::IEnumerable<global::Google.ProtocolBuffers.DescriptorProtos.EnumDescriptorProto> values) {
- if (result.enumType_ == pbc::Lists<global::Google.ProtocolBuffers.DescriptorProtos.EnumDescriptorProto>.Empty) {
- result.enumType_ = new scg::List<global::Google.ProtocolBuffers.DescriptorProtos.EnumDescriptorProto>();
- }
base.AddRange(values, result.enumType_);
return this;
}
public Builder ClearEnumType() {
- result.enumType_ = pbc::Lists<global::Google.ProtocolBuffers.DescriptorProtos.EnumDescriptorProto>.Empty;
+ result.enumType_.Clear();
return this;
}
// repeated .google.protobuf.DescriptorProto.ExtensionRange extension_range = 5;
public scg::IList<global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto.Types.ExtensionRange> ExtensionRangeList {
- get { return pbc::Lists.AsReadOnly(result.extensionRange_); }
+ get { return result.extensionRange_; }
}
public int ExtensionRangeCount {
get { return result.ExtensionRangeCount; }
@@ -2026,28 +1886,19 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
return this;
}
public Builder AddExtensionRange(global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto.Types.ExtensionRange value) {
- if (result.extensionRange_ == pbc::Lists<global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto.Types.ExtensionRange>.Empty) {
- result.extensionRange_ = new scg::List<global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto.Types.ExtensionRange>();
- }
result.extensionRange_.Add(value);
return this;
}
public Builder AddExtensionRange(global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto.Types.ExtensionRange.Builder builderForValue) {
- if (result.extensionRange_ == pbc::Lists<global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto.Types.ExtensionRange>.Empty) {
- result.extensionRange_ = new scg::List<global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto.Types.ExtensionRange>();
- }
result.extensionRange_.Add(builderForValue.Build());
return this;
}
public Builder AddRangeExtensionRange(scg::IEnumerable<global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto.Types.ExtensionRange> values) {
- if (result.extensionRange_ == pbc::Lists<global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto.Types.ExtensionRange>.Empty) {
- result.extensionRange_ = new scg::List<global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto.Types.ExtensionRange>();
- }
base.AddRange(values, result.extensionRange_);
return this;
}
public Builder ClearExtensionRange() {
- result.extensionRange_ = pbc::Lists<global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto.Types.ExtensionRange>.Empty;
+ result.extensionRange_.Clear();
return this;
}
@@ -2089,7 +1940,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
}
public sealed partial class FieldDescriptorProto : pb::GeneratedMessage<FieldDescriptorProto, FieldDescriptorProto.Builder> {
- private static readonly FieldDescriptorProto defaultInstance = new FieldDescriptorProto();
+ private static readonly FieldDescriptorProto defaultInstance = new Builder().BuildPartial();
public static FieldDescriptorProto DefaultInstance {
get { return defaultInstance; }
}
@@ -2651,7 +2502,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
}
public sealed partial class EnumDescriptorProto : pb::GeneratedMessage<EnumDescriptorProto, EnumDescriptorProto.Builder> {
- private static readonly EnumDescriptorProto defaultInstance = new EnumDescriptorProto();
+ private static readonly EnumDescriptorProto defaultInstance = new Builder().BuildPartial();
public static EnumDescriptorProto DefaultInstance {
get { return defaultInstance; }
}
@@ -2683,7 +2534,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
}
// repeated .google.protobuf.EnumValueDescriptorProto value = 2;
- private scg::IList<global::Google.ProtocolBuffers.DescriptorProtos.EnumValueDescriptorProto> value_ = pbc::Lists<global::Google.ProtocolBuffers.DescriptorProtos.EnumValueDescriptorProto>.Empty;
+ private pbc::PopsicleList<global::Google.ProtocolBuffers.DescriptorProtos.EnumValueDescriptorProto> value_ = new pbc::PopsicleList<global::Google.ProtocolBuffers.DescriptorProtos.EnumValueDescriptorProto>();
public scg::IList<global::Google.ProtocolBuffers.DescriptorProtos.EnumValueDescriptorProto> ValueList {
get { return value_; }
}
@@ -2817,9 +2668,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
}
public override global::Google.ProtocolBuffers.DescriptorProtos.EnumDescriptorProto BuildPartial() {
- if (result.value_ != pbc::Lists<global::Google.ProtocolBuffers.DescriptorProtos.EnumValueDescriptorProto>.Empty) {
- result.value_ = pbc::Lists<global::Google.ProtocolBuffers.DescriptorProtos.EnumValueDescriptorProto>.AsReadOnly(result.value_);
- }
+ result.value_.MakeReadOnly();
global::Google.ProtocolBuffers.DescriptorProtos.EnumDescriptorProto returnMe = result;
result = null;
return returnMe;
@@ -2840,9 +2689,6 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
Name = other.Name;
}
if (other.value_.Count != 0) {
- if (result.value_.Count == 0) {
- result.value_ = new scg::List<global::Google.ProtocolBuffers.DescriptorProtos.EnumValueDescriptorProto>();
- }
base.AddRange(other.value_, result.value_);
}
if (other.HasOptions) {
@@ -2918,7 +2764,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
// repeated .google.protobuf.EnumValueDescriptorProto value = 2;
public scg::IList<global::Google.ProtocolBuffers.DescriptorProtos.EnumValueDescriptorProto> ValueList {
- get { return pbc::Lists.AsReadOnly(result.value_); }
+ get { return result.value_; }
}
public int ValueCount {
get { return result.ValueCount; }
@@ -2935,28 +2781,19 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
return this;
}
public Builder AddValue(global::Google.ProtocolBuffers.DescriptorProtos.EnumValueDescriptorProto value) {
- if (result.value_ == pbc::Lists<global::Google.ProtocolBuffers.DescriptorProtos.EnumValueDescriptorProto>.Empty) {
- result.value_ = new scg::List<global::Google.ProtocolBuffers.DescriptorProtos.EnumValueDescriptorProto>();
- }
result.value_.Add(value);
return this;
}
public Builder AddValue(global::Google.ProtocolBuffers.DescriptorProtos.EnumValueDescriptorProto.Builder builderForValue) {
- if (result.value_ == pbc::Lists<global::Google.ProtocolBuffers.DescriptorProtos.EnumValueDescriptorProto>.Empty) {
- result.value_ = new scg::List<global::Google.ProtocolBuffers.DescriptorProtos.EnumValueDescriptorProto>();
- }
result.value_.Add(builderForValue.Build());
return this;
}
public Builder AddRangeValue(scg::IEnumerable<global::Google.ProtocolBuffers.DescriptorProtos.EnumValueDescriptorProto> values) {
- if (result.value_ == pbc::Lists<global::Google.ProtocolBuffers.DescriptorProtos.EnumValueDescriptorProto>.Empty) {
- result.value_ = new scg::List<global::Google.ProtocolBuffers.DescriptorProtos.EnumValueDescriptorProto>();
- }
base.AddRange(values, result.value_);
return this;
}
public Builder ClearValue() {
- result.value_ = pbc::Lists<global::Google.ProtocolBuffers.DescriptorProtos.EnumValueDescriptorProto>.Empty;
+ result.value_.Clear();
return this;
}
@@ -2998,7 +2835,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
}
public sealed partial class EnumValueDescriptorProto : pb::GeneratedMessage<EnumValueDescriptorProto, EnumValueDescriptorProto.Builder> {
- private static readonly EnumValueDescriptorProto defaultInstance = new EnumValueDescriptorProto();
+ private static readonly EnumValueDescriptorProto defaultInstance = new Builder().BuildPartial();
public static EnumValueDescriptorProto DefaultInstance {
get { return defaultInstance; }
}
@@ -3310,7 +3147,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
}
public sealed partial class ServiceDescriptorProto : pb::GeneratedMessage<ServiceDescriptorProto, ServiceDescriptorProto.Builder> {
- private static readonly ServiceDescriptorProto defaultInstance = new ServiceDescriptorProto();
+ private static readonly ServiceDescriptorProto defaultInstance = new Builder().BuildPartial();
public static ServiceDescriptorProto DefaultInstance {
get { return defaultInstance; }
}
@@ -3342,7 +3179,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
}
// repeated .google.protobuf.MethodDescriptorProto method = 2;
- private scg::IList<global::Google.ProtocolBuffers.DescriptorProtos.MethodDescriptorProto> method_ = pbc::Lists<global::Google.ProtocolBuffers.DescriptorProtos.MethodDescriptorProto>.Empty;
+ private pbc::PopsicleList<global::Google.ProtocolBuffers.DescriptorProtos.MethodDescriptorProto> method_ = new pbc::PopsicleList<global::Google.ProtocolBuffers.DescriptorProtos.MethodDescriptorProto>();
public scg::IList<global::Google.ProtocolBuffers.DescriptorProtos.MethodDescriptorProto> MethodList {
get { return method_; }
}
@@ -3476,9 +3313,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
}
public override global::Google.ProtocolBuffers.DescriptorProtos.ServiceDescriptorProto BuildPartial() {
- if (result.method_ != pbc::Lists<global::Google.ProtocolBuffers.DescriptorProtos.MethodDescriptorProto>.Empty) {
- result.method_ = pbc::Lists<global::Google.ProtocolBuffers.DescriptorProtos.MethodDescriptorProto>.AsReadOnly(result.method_);
- }
+ result.method_.MakeReadOnly();
global::Google.ProtocolBuffers.DescriptorProtos.ServiceDescriptorProto returnMe = result;
result = null;
return returnMe;
@@ -3499,9 +3334,6 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
Name = other.Name;
}
if (other.method_.Count != 0) {
- if (result.method_.Count == 0) {
- result.method_ = new scg::List<global::Google.ProtocolBuffers.DescriptorProtos.MethodDescriptorProto>();
- }
base.AddRange(other.method_, result.method_);
}
if (other.HasOptions) {
@@ -3577,7 +3409,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
// repeated .google.protobuf.MethodDescriptorProto method = 2;
public scg::IList<global::Google.ProtocolBuffers.DescriptorProtos.MethodDescriptorProto> MethodList {
- get { return pbc::Lists.AsReadOnly(result.method_); }
+ get { return result.method_; }
}
public int MethodCount {
get { return result.MethodCount; }
@@ -3594,28 +3426,19 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
return this;
}
public Builder AddMethod(global::Google.ProtocolBuffers.DescriptorProtos.MethodDescriptorProto value) {
- if (result.method_ == pbc::Lists<global::Google.ProtocolBuffers.DescriptorProtos.MethodDescriptorProto>.Empty) {
- result.method_ = new scg::List<global::Google.ProtocolBuffers.DescriptorProtos.MethodDescriptorProto>();
- }
result.method_.Add(value);
return this;
}
public Builder AddMethod(global::Google.ProtocolBuffers.DescriptorProtos.MethodDescriptorProto.Builder builderForValue) {
- if (result.method_ == pbc::Lists<global::Google.ProtocolBuffers.DescriptorProtos.MethodDescriptorProto>.Empty) {
- result.method_ = new scg::List<global::Google.ProtocolBuffers.DescriptorProtos.MethodDescriptorProto>();
- }
result.method_.Add(builderForValue.Build());
return this;
}
public Builder AddRangeMethod(scg::IEnumerable<global::Google.ProtocolBuffers.DescriptorProtos.MethodDescriptorProto> values) {
- if (result.method_ == pbc::Lists<global::Google.ProtocolBuffers.DescriptorProtos.MethodDescriptorProto>.Empty) {
- result.method_ = new scg::List<global::Google.ProtocolBuffers.DescriptorProtos.MethodDescriptorProto>();
- }
base.AddRange(values, result.method_);
return this;
}
public Builder ClearMethod() {
- result.method_ = pbc::Lists<global::Google.ProtocolBuffers.DescriptorProtos.MethodDescriptorProto>.Empty;
+ result.method_.Clear();
return this;
}
@@ -3657,7 +3480,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
}
public sealed partial class MethodDescriptorProto : pb::GeneratedMessage<MethodDescriptorProto, MethodDescriptorProto.Builder> {
- private static readonly MethodDescriptorProto defaultInstance = new MethodDescriptorProto();
+ private static readonly MethodDescriptorProto defaultInstance = new Builder().BuildPartial();
public static MethodDescriptorProto DefaultInstance {
get { return defaultInstance; }
}
@@ -4011,7 +3834,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
}
public sealed partial class FileOptions : pb::GeneratedMessage<FileOptions, FileOptions.Builder> {
- private static readonly FileOptions defaultInstance = new FileOptions();
+ private static readonly FileOptions defaultInstance = new Builder().BuildPartial();
public static FileOptions DefaultInstance {
get { return defaultInstance; }
}
@@ -4568,7 +4391,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
}
public sealed partial class MessageOptions : pb::GeneratedMessage<MessageOptions, MessageOptions.Builder> {
- private static readonly MessageOptions defaultInstance = new MessageOptions();
+ private static readonly MessageOptions defaultInstance = new Builder().BuildPartial();
public static MessageOptions DefaultInstance {
get { return defaultInstance; }
}
@@ -4775,7 +4598,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
}
public sealed partial class FieldOptions : pb::GeneratedMessage<FieldOptions, FieldOptions.Builder> {
- private static readonly FieldOptions defaultInstance = new FieldOptions();
+ private static readonly FieldOptions defaultInstance = new Builder().BuildPartial();
public static FieldOptions DefaultInstance {
get { return defaultInstance; }
}
@@ -5038,7 +4861,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
}
public sealed partial class EnumOptions : pb::GeneratedMessage<EnumOptions, EnumOptions.Builder> {
- private static readonly EnumOptions defaultInstance = new EnumOptions();
+ private static readonly EnumOptions defaultInstance = new Builder().BuildPartial();
public static EnumOptions DefaultInstance {
get { return defaultInstance; }
}
@@ -5203,7 +5026,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
}
public sealed partial class EnumValueOptions : pb::GeneratedMessage<EnumValueOptions, EnumValueOptions.Builder> {
- private static readonly EnumValueOptions defaultInstance = new EnumValueOptions();
+ private static readonly EnumValueOptions defaultInstance = new Builder().BuildPartial();
public static EnumValueOptions DefaultInstance {
get { return defaultInstance; }
}
@@ -5368,7 +5191,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
}
public sealed partial class ServiceOptions : pb::GeneratedMessage<ServiceOptions, ServiceOptions.Builder> {
- private static readonly ServiceOptions defaultInstance = new ServiceOptions();
+ private static readonly ServiceOptions defaultInstance = new Builder().BuildPartial();
public static ServiceOptions DefaultInstance {
get { return defaultInstance; }
}
@@ -5533,7 +5356,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
}
public sealed partial class MethodOptions : pb::GeneratedMessage<MethodOptions, MethodOptions.Builder> {
- private static readonly MethodOptions defaultInstance = new MethodOptions();
+ private static readonly MethodOptions defaultInstance = new Builder().BuildPartial();
public static MethodOptions DefaultInstance {
get { return defaultInstance; }
}
diff --git a/csharp/ProtocolBuffers/FieldAccess/Delegates.cs b/csharp/ProtocolBuffers/FieldAccess/Delegates.cs
deleted file mode 100644
index 972961c6..00000000
--- a/csharp/ProtocolBuffers/FieldAccess/Delegates.cs
+++ /dev/null
@@ -1,26 +0,0 @@
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc.
-// http://code.google.com/p/protobuf/
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-namespace Google.ProtocolBuffers.FieldAccess {
-
- // These delegate declarations mirror the ones in .NET 3.5 for the sake of familiarity.
- internal delegate TResult Func<TResult>();
- internal delegate TResult Func<T, TResult>(T arg);
- internal delegate TResult Func<T1, T2, TResult>(T1 arg1, T2 arg2);
- internal delegate TResult Func<T1, T2, T3, TResult>(T1 arg1, T2 arg2, T3 arg3);
- internal delegate TResult Func<T1, T2, T3, T4, TResult>(T1 arg1, T2 arg2, T3 arg3, T4 arg4);
- internal delegate void Action<T1, T2>(T1 arg1, T2 arg2);
-}
diff --git a/csharp/ProtocolBuffers/MessageStreamIterator.cs b/csharp/ProtocolBuffers/MessageStreamIterator.cs
index 4944e5ce..61dbf840 100644
--- a/csharp/ProtocolBuffers/MessageStreamIterator.cs
+++ b/csharp/ProtocolBuffers/MessageStreamIterator.cs
@@ -8,25 +8,67 @@ using System.Reflection;
namespace Google.ProtocolBuffers {
/// <summary>
- /// Helper class to create MessageStreamIterators without explicitly specifying
- /// the builder type. The concrete builder type is determined by reflection, based
- /// on the message type. The reflection step looks for a <c>CreateBuilder</c> method
- /// in the message type which is public and static, and uses the return type of that
- /// method as the builder type. This will work for all generated messages, whether
- /// optimised for size or speed. It won't work for dynamic messages.
- ///
- /// TODO(jonskeet): This also won't work for non-public protos :(
- /// Pass in delegate to create a builder?
+ /// Iterates over data created using a <see cref="MessageStreamWriter{T}" />.
+ /// Unlike MessageStreamWriter, this class is not usually constructed directly with
+ /// a stream; instead it is provided with a way of opening a stream when iteration
+ /// is started. The stream is closed when the iteration is completed or the enumerator
+ /// is disposed. (This occurs naturally when using <c>foreach</c>.)
/// </summary>
- public static class MessageStreamIterator {
+ public class MessageStreamIterator<TMessage> : IEnumerable<TMessage>
+ where TMessage : IMessage<TMessage> {
+
+ private readonly StreamProvider streamProvider;
+ private readonly ExtensionRegistry extensionRegistry;
+
+ /// <summary>
+ /// Delegate created via reflection trickery (once per type) to create a builder
+ /// and read a message from a CodedInputStream with it. Note that unlike in Java,
+ /// there's one static field per constructed type.
+ /// </summary>
+ private static readonly Func<CodedInputStream, ExtensionRegistry, TMessage> messageReader = BuildMessageReader();
+
+ /// <summary>
+ /// Any exception (within reason) thrown within messageReader is caught and rethrown in the constructor.
+ /// This makes life a lot simpler for the caller.
+ /// </summary>
+ private static Exception typeInitializationException;
+
+ /// <summary>
+ /// Creates the delegate later used to read messages. This is only called once per type, but to
+ /// avoid exceptions occurring at confusing times, if this fails it will set typeInitializationException
+ /// to the appropriate error and return null.
+ /// </summary>
+ private static Func<CodedInputStream, ExtensionRegistry, TMessage> BuildMessageReader() {
+ try {
+ Type builderType = FindBuilderType();
+
+ // Yes, it's redundant to find this again, but it's only the once...
+ MethodInfo createBuilderMethod = typeof(TMessage).GetMethod("CreateBuilder", Type.EmptyTypes);
+ Delegate builderBuilder = Delegate.CreateDelegate(
+ typeof(Func<>).MakeGenericType(builderType), null, createBuilderMethod);
- public static IEnumerable<TMessage> FromFile<TMessage>(string file)
- where TMessage : IMessage<TMessage> {
- return FromStreamProvider<TMessage>(() => File.OpenRead(file));
+ MethodInfo buildMethod = typeof(MessageStreamIterator<TMessage>)
+ .GetMethod("BuildImpl", BindingFlags.Static | BindingFlags.NonPublic)
+ .MakeGenericMethod(typeof(TMessage), builderType);
+
+ return (Func<CodedInputStream, ExtensionRegistry, TMessage>)Delegate.CreateDelegate(
+ typeof(Func<CodedInputStream, ExtensionRegistry, TMessage>), builderBuilder, buildMethod);
+ } catch (ArgumentException e) {
+ typeInitializationException = e;
+ } catch (InvalidOperationException e) {
+ typeInitializationException = e;
+ } catch (InvalidCastException e) {
+ // Can't see why this would happen, but best to know about it.
+ typeInitializationException = e;
+ }
+ return null;
}
- public static IEnumerable<TMessage> FromStreamProvider<TMessage>(StreamProvider streamProvider)
- where TMessage : IMessage<TMessage> {
+ /// <summary>
+ /// Works out the builder type for TMessage, or throws an ArgumentException to explain why it can't.
+ /// This will check
+ /// </summary>
+ private static Type FindBuilderType() {
MethodInfo createBuilderMethod = typeof(TMessage).GetMethod("CreateBuilder", Type.EmptyTypes);
if (createBuilderMethod == null) {
throw new ArgumentException("Message type " + typeof(TMessage).FullName + " has no CreateBuilder method.");
@@ -35,68 +77,57 @@ namespace Google.ProtocolBuffers {
throw new ArgumentException("CreateBuilder method in " + typeof(TMessage).FullName + " has void return type");
}
Type builderType = createBuilderMethod.ReturnType;
- if (builderType.GetConstructor(Type.EmptyTypes) == null) {
- throw new ArgumentException("Builder type " + builderType.FullName + " has no public parameterless constructor.");
- }
Type messageInterface = typeof(IMessage<,>).MakeGenericType(typeof(TMessage), builderType);
Type builderInterface = typeof(IBuilder<,>).MakeGenericType(typeof(TMessage), builderType);
- if (Array.IndexOf(typeof (TMessage).GetInterfaces(), messageInterface) == -1) {
+ if (Array.IndexOf(typeof(TMessage).GetInterfaces(), messageInterface) == -1) {
throw new ArgumentException("Message type " + typeof(TMessage) + " doesn't implement " + messageInterface.FullName);
}
if (Array.IndexOf(builderType.GetInterfaces(), builderInterface) == -1) {
throw new ArgumentException("Builder type " + typeof(TMessage) + " doesn't implement " + builderInterface.FullName);
}
- Type iteratorType = typeof(MessageStreamIterator<,>).MakeGenericType(typeof(TMessage), builderType);
- MethodInfo factoryMethod = iteratorType.GetMethod("FromStreamProvider", new Type[] { typeof(StreamProvider) });
- return (IEnumerable<TMessage>) factoryMethod.Invoke(null, new object[] { streamProvider });
+ return builderType;
}
- }
- /// <summary>
- /// Iterates over data created using a <see cref="MessageStreamWriter{T}" />.
- /// Unlike MessageStreamWriter, this class is not usually constructed directly with
- /// a stream; instead it is provided with a way of opening a stream when iteration
- /// is started. The stream is closed when the iteration is completed or the enumerator
- /// is disposed. (This occurs naturally when using <c>foreach</c>.)
- /// This type is generic in both the message type and the builder type; if only the
- /// iteration is required (i.e. just <see cref="IEnumerable{T}" />) then the static
- /// generic methods in the nongeneric class are more appropriate.
- /// </summary>
- public sealed class MessageStreamIterator<TMessage, TBuilder> : IEnumerable<TMessage>
- where TMessage : IMessage<TMessage, TBuilder>
- where TBuilder : IBuilder<TMessage, TBuilder>, new() {
-
- private readonly StreamProvider streamProvider;
- private readonly ExtensionRegistry extensionRegistry;
+ /// <summary>
+ /// Method we'll use to build messageReader, with the first parameter fixed to TMessage.CreateBuilder. Note that we
+ /// have to introduce another type parameter (TMessage2) as we can't constrain TMessage for just a single method
+ /// (and we can't do it at the type level because we don't know TBuilder). However, by constraining TMessage2
+ /// to not only implement IMessage appropriately but also to derive from TMessage2, we can avoid doing a cast
+ /// for every message; the implicit reference conversion will be fine. In practice, TMessage2 and TMessage will
+ /// be the same type when we construct the generic method by reflection.
+ /// </summary>
+ private static TMessage BuildImpl<TMessage2, TBuilder>(Func<TBuilder> builderBuilder, CodedInputStream input, ExtensionRegistry registry)
+ where TBuilder : IBuilder<TMessage2, TBuilder>
+ where TMessage2 : TMessage, IMessage<TMessage2, TBuilder> {
+ TBuilder builder = builderBuilder();
+ input.ReadMessage(builder, registry);
+ return builder.Build();
+ }
+
private static readonly uint ExpectedTag = WireFormat.MakeTag(1, WireFormat.WireType.LengthDelimited);
private MessageStreamIterator(StreamProvider streamProvider, ExtensionRegistry extensionRegistry) {
+ if (messageReader == null) {
+ throw typeInitializationException;
+ }
this.streamProvider = streamProvider;
this.extensionRegistry = extensionRegistry;
}
/// <summary>
- /// Creates an instance which opens the specified file when it begins
- /// iterating. No extension registry is used when reading messages.
+ /// Creates a new instance which uses the same stream provider as this one,
+ /// but the specified extension registry.
/// </summary>
- public static MessageStreamIterator<TMessage, TBuilder> FromFile(string file) {
- return new MessageStreamIterator<TMessage, TBuilder>(() => File.OpenRead(file), ExtensionRegistry.Empty);
+ public MessageStreamIterator<TMessage> WithExtensionRegistry(ExtensionRegistry newRegistry) {
+ return new MessageStreamIterator<TMessage>(streamProvider, newRegistry);
}
- /// <summary>
- /// Creates an instance which calls the given delegate when it begins
- /// iterating. No extension registry is used when reading messages.
- /// </summary>
- public static MessageStreamIterator<TMessage, TBuilder> FromStreamProvider(StreamProvider streamProvider) {
- return new MessageStreamIterator<TMessage, TBuilder>(streamProvider, ExtensionRegistry.Empty);
+ public static MessageStreamIterator<TMessage> FromFile(string file) {
+ return new MessageStreamIterator<TMessage>(() => File.OpenRead(file), ExtensionRegistry.Empty);
}
- /// <summary>
- /// Creates a new instance which uses the same stream provider as this one,
- /// but the specified extension registry.
- /// </summary>
- public MessageStreamIterator<TMessage, TBuilder> WithExtensionRegistry(ExtensionRegistry newRegistry) {
- return new MessageStreamIterator<TMessage, TBuilder>(streamProvider, newRegistry);
+ public static MessageStreamIterator<TMessage> FromStreamProvider(StreamProvider streamProvider) {
+ return new MessageStreamIterator<TMessage>(streamProvider, ExtensionRegistry.Empty);
}
public IEnumerator<TMessage> GetEnumerator() {
@@ -107,16 +138,11 @@ namespace Google.ProtocolBuffers {
if (tag != ExpectedTag) {
throw InvalidProtocolBufferException.InvalidMessageStreamTag();
}
- TBuilder builder = new TBuilder();
- input.ReadMessage(builder, extensionRegistry);
- yield return builder.Build();
+ yield return messageReader(input, extensionRegistry);
}
}
}
- /// <summary>
- /// Explicit implementation of nongeneric IEnumerable interface.
- /// </summary>
IEnumerator IEnumerable.GetEnumerator() {
return GetEnumerator();
}
diff --git a/csharp/ProtocolBuffers/ProtocolBuffers.csproj b/csharp/ProtocolBuffers/ProtocolBuffers.csproj
index 25f7cdbb..70a4691d 100644
--- a/csharp/ProtocolBuffers/ProtocolBuffers.csproj
+++ b/csharp/ProtocolBuffers/ProtocolBuffers.csproj
@@ -41,6 +41,7 @@
<Compile Include="AbstractBuilder.cs" />
<Compile Include="AbstractMessage.cs" />
<Compile Include="ByteString.cs" />
+ <Compile Include="Collections\PopsicleList.cs" />
<Compile Include="Delegates.cs" />
<Compile Include="CodedInputStream.cs" />
<Compile Include="CodedOutputStream.cs" />
@@ -72,7 +73,6 @@
<Compile Include="ExtendableMessage.cs" />
<Compile Include="ExtensionInfo.cs" />
<Compile Include="ExtensionRegistry.cs" />
- <Compile Include="FieldAccess\Delegates.cs" />
<Compile Include="FieldAccess\ReflectionUtil.cs" />
<Compile Include="FieldAccess\SingleEnumAccessor.cs" />
<Compile Include="FieldAccess\SingleMessageAccessor.cs" />