diff options
Diffstat (limited to 'csharp/src')
56 files changed, 8942 insertions, 8785 deletions
diff --git a/csharp/src/AddressBook/Addressbook.cs b/csharp/src/AddressBook/Addressbook.cs index 5f4a5139..494ee9eb 100644 --- a/csharp/src/AddressBook/Addressbook.cs +++ b/csharp/src/AddressBook/Addressbook.cs @@ -5,7 +5,7 @@ using pb = global::Google.Protobuf; using pbc = global::Google.Protobuf.Collections; -using pbd = global::Google.Protobuf.Descriptors; +using pbr = global::Google.Protobuf.Reflection; using scg = global::System.Collections.Generic; namespace Google.Protobuf.Examples.AddressBook { @@ -13,15 +13,15 @@ namespace Google.Protobuf.Examples.AddressBook { public static partial class Addressbook { #region Static variables - internal static pb::FieldAccess.FieldAccessorTable internal__static_tutorial_Person__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_tutorial_Person_PhoneNumber__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_tutorial_AddressBook__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_tutorial_Person__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_tutorial_Person_PhoneNumber__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_tutorial_AddressBook__FieldAccessorTable; #endregion #region Descriptor - public static pbd::FileDescriptor Descriptor { + public static pbr::FileDescriptor Descriptor { get { return descriptor; } } - private static pbd::FileDescriptor descriptor; + private static pbr::FileDescriptor descriptor; static Addressbook() { byte[] descriptorData = global::System.Convert.FromBase64String( @@ -35,18 +35,18 @@ namespace Google.Protobuf.Examples.AddressBook { "ASADKAsyEC50dXRvcmlhbC5QZXJzb25CUAoUY29tLmV4YW1wbGUudHV0b3Jp", "YWxCEUFkZHJlc3NCb29rUHJvdG9zqgIkR29vZ2xlLlByb3RvYnVmLkV4YW1w", "bGVzLkFkZHJlc3NCb29rYgZwcm90bzM=")); - descriptor = pbd::FileDescriptor.InternalBuildGeneratedFileFrom(descriptorData, - new pbd::FileDescriptor[] { + descriptor = pbr::FileDescriptor.InternalBuildGeneratedFileFrom(descriptorData, + new pbr::FileDescriptor[] { }); internal__static_tutorial_Person__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.Examples.AddressBook.Person), descriptor.MessageTypes[0], - new string[] { "Name", "Id", "Email", "Phone", }); + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.Examples.AddressBook.Person), descriptor.MessageTypes[0], + new string[] { "Name", "Id", "Email", "Phone", }, new string[] { }); internal__static_tutorial_Person_PhoneNumber__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneNumber), descriptor.MessageTypes[0].NestedTypes[0], - new string[] { "Number", "Type", }); + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneNumber), descriptor.MessageTypes[0].NestedTypes[0], + new string[] { "Number", "Type", }, new string[] { }); internal__static_tutorial_AddressBook__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.Examples.AddressBook.AddressBook), descriptor.MessageTypes[1], - new string[] { "Person", }); + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.Examples.AddressBook.AddressBook), descriptor.MessageTypes[1], + new string[] { "Person", }, new string[] { }); } #endregion @@ -59,11 +59,11 @@ namespace Google.Protobuf.Examples.AddressBook { private static readonly string[] _fieldNames = new string[] { "email", "id", "name", "phone" }; private static readonly uint[] _fieldTags = new uint[] { 26, 16, 10, 34 }; - public static pbd::MessageDescriptor Descriptor { + public static pbr::MessageDescriptor Descriptor { get { return global::Google.Protobuf.Examples.AddressBook.Addressbook.Descriptor.MessageTypes[0]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { get { return global::Google.Protobuf.Examples.AddressBook.Addressbook.internal__static_tutorial_Person__FieldAccessorTable; } } @@ -160,6 +160,10 @@ namespace Google.Protobuf.Examples.AddressBook { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (Name.Length != 0) { output.WriteRawTag(10); @@ -254,11 +258,11 @@ namespace Google.Protobuf.Examples.AddressBook { private static readonly string[] _fieldNames = new string[] { "number", "type" }; private static readonly uint[] _fieldTags = new uint[] { 10, 16 }; - public static pbd::MessageDescriptor Descriptor { + public static pbr::MessageDescriptor Descriptor { get { return global::Google.Protobuf.Examples.AddressBook.Person.Descriptor.NestedTypes[0]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { get { return global::Google.Protobuf.Examples.AddressBook.Addressbook.internal__static_tutorial_Person_PhoneNumber__FieldAccessorTable; } } @@ -330,6 +334,10 @@ namespace Google.Protobuf.Examples.AddressBook { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (Number.Length != 0) { output.WriteRawTag(10); @@ -401,11 +409,11 @@ namespace Google.Protobuf.Examples.AddressBook { private static readonly string[] _fieldNames = new string[] { "person" }; private static readonly uint[] _fieldTags = new uint[] { 10 }; - public static pbd::MessageDescriptor Descriptor { + public static pbr::MessageDescriptor Descriptor { get { return global::Google.Protobuf.Examples.AddressBook.Addressbook.Descriptor.MessageTypes[1]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { get { return global::Google.Protobuf.Examples.AddressBook.Addressbook.internal__static_tutorial_AddressBook__FieldAccessorTable; } } @@ -463,6 +471,10 @@ namespace Google.Protobuf.Examples.AddressBook { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { person_.WriteTo(output, _repeated_person_codec); } diff --git a/csharp/src/ProtocolBuffers.Test/Collections/RepeatedFieldTest.cs b/csharp/src/ProtocolBuffers.Test/Collections/RepeatedFieldTest.cs index 6eff8683..25be7731 100644 --- a/csharp/src/ProtocolBuffers.Test/Collections/RepeatedFieldTest.cs +++ b/csharp/src/ProtocolBuffers.Test/Collections/RepeatedFieldTest.cs @@ -241,18 +241,12 @@ namespace Google.Protobuf.Collections var list = new RepeatedField<string> { "first", "second" }; using (var enumerator = list.GetEnumerator()) { - Assert.Throws<InvalidOperationException>(() => enumerator.Current.GetHashCode()); Assert.IsTrue(enumerator.MoveNext()); Assert.AreEqual("first", enumerator.Current); Assert.IsTrue(enumerator.MoveNext()); Assert.AreEqual("second", enumerator.Current); Assert.IsFalse(enumerator.MoveNext()); - Assert.Throws<InvalidOperationException>(() => enumerator.Current.GetHashCode()); Assert.IsFalse(enumerator.MoveNext()); - enumerator.Reset(); - Assert.Throws<InvalidOperationException>(() => enumerator.Current.GetHashCode()); - Assert.IsTrue(enumerator.MoveNext()); - Assert.AreEqual("first", enumerator.Current); } } diff --git a/csharp/src/ProtocolBuffers.Test/GeneratedMessageTest.cs b/csharp/src/ProtocolBuffers.Test/GeneratedMessageTest.cs index 8cee9820..acb20b15 100644 --- a/csharp/src/ProtocolBuffers.Test/GeneratedMessageTest.cs +++ b/csharp/src/ProtocolBuffers.Test/GeneratedMessageTest.cs @@ -604,7 +604,7 @@ namespace Google.Protobuf public void Reflection_GetValue()
{
var message = SampleMessages.CreateFullTestAllTypes();
- var fields = message.Fields;
+ var fields = ((IReflectedMessage) message).Fields;
Assert.AreEqual(message.SingleBool, fields[TestAllTypes.SingleBoolFieldNumber].GetValue(message));
Assert.AreEqual(message.SingleBytes, fields[TestAllTypes.SingleBytesFieldNumber].GetValue(message));
Assert.AreEqual(message.SingleDouble, fields[TestAllTypes.SingleDoubleFieldNumber].GetValue(message));
@@ -639,7 +639,8 @@ namespace Google.Protobuf // Just a single map field, for the same reason
var mapMessage = new TestMap { MapStringString = { { "key1", "value1" }, { "key2", "value2" } } };
- var dictionary = (IDictionary)mapMessage.Fields[TestMap.MapStringStringFieldNumber].GetValue(mapMessage);
+ fields = ((IReflectedMessage) mapMessage).Fields;
+ var dictionary = (IDictionary) fields[TestMap.MapStringStringFieldNumber].GetValue(mapMessage);
Assert.AreEqual(mapMessage.MapStringString, dictionary);
Assert.AreEqual("value1", dictionary["key1"]);
}
@@ -647,7 +648,7 @@ namespace Google.Protobuf [Test]
public void Reflection_Clear()
{
- var message = SampleMessages.CreateFullTestAllTypes();
+ IReflectedMessage message = SampleMessages.CreateFullTestAllTypes();
var fields = message.Fields;
fields[TestAllTypes.SingleBoolFieldNumber].Clear(message);
fields[TestAllTypes.SingleInt32FieldNumber].Clear(message);
@@ -672,7 +673,8 @@ namespace Google.Protobuf // Separately, maps.
var mapMessage = new TestMap { MapStringString = { { "key1", "value1" }, { "key2", "value2" } } };
- mapMessage.Fields[TestMap.MapStringStringFieldNumber].Clear(mapMessage);
+ fields = ((IReflectedMessage) mapMessage).Fields;
+ fields[TestMap.MapStringStringFieldNumber].Clear(mapMessage);
Assert.AreEqual(0, mapMessage.MapStringString.Count);
}
@@ -680,7 +682,7 @@ namespace Google.Protobuf public void Reflection_SetValue_SingleFields()
{
// Just a sample (primitives, messages, enums, strings, byte strings)
- var message = SampleMessages.CreateFullTestAllTypes();
+ IReflectedMessage message = SampleMessages.CreateFullTestAllTypes();
var fields = message.Fields;
fields[TestAllTypes.SingleBoolFieldNumber].SetValue(message, false);
fields[TestAllTypes.SingleInt32FieldNumber].SetValue(message, 500);
@@ -707,7 +709,7 @@ namespace Google.Protobuf [Test]
public void Reflection_SetValue_SingleFields_WrongType()
{
- var message = SampleMessages.CreateFullTestAllTypes();
+ IReflectedMessage message = SampleMessages.CreateFullTestAllTypes();
var fields = message.Fields;
Assert.Throws<InvalidCastException>(() => fields[TestAllTypes.SingleBoolFieldNumber].SetValue(message, "This isn't a bool"));
}
@@ -715,7 +717,7 @@ namespace Google.Protobuf [Test]
public void Reflection_SetValue_MapFields()
{
- var message = new TestMap();
+ IReflectedMessage message = new TestMap();
var fields = message.Fields;
Assert.Throws<InvalidOperationException>(() => fields[TestMap.MapStringStringFieldNumber].SetValue(message, new Dictionary<string, string>()));
}
@@ -723,7 +725,7 @@ namespace Google.Protobuf [Test]
public void Reflection_SetValue_RepeatedFields()
{
- var message = SampleMessages.CreateFullTestAllTypes();
+ IReflectedMessage message = SampleMessages.CreateFullTestAllTypes();
var fields = message.Fields;
Assert.Throws<InvalidOperationException>(() => fields[TestAllTypes.RepeatedDoubleFieldNumber].SetValue(message, new double[10]));
}
@@ -731,8 +733,28 @@ namespace Google.Protobuf [Test]
public void Reflection_GetValue_IncorrectType()
{
- var message = SampleMessages.CreateFullTestAllTypes();
+ IReflectedMessage message = SampleMessages.CreateFullTestAllTypes();
Assert.Throws<InvalidCastException>(() => message.Fields[TestAllTypes.SingleBoolFieldNumber].GetValue(new TestMap()));
}
+
+ [Test]
+ public void Reflection_Oneof()
+ {
+ var message = new TestAllTypes();
+ var fields = ((IReflectedMessage) message).Fields;
+ Assert.AreEqual(1, fields.Oneofs.Count);
+ var oneof = fields.Oneofs[0];
+ Assert.AreEqual("oneof_field", oneof.Descriptor.Name);
+ Assert.IsNull(oneof.GetCaseFieldDescriptor(message));
+
+ message.OneofString = "foo";
+ Assert.AreSame(fields[TestAllTypes.OneofStringFieldNumber].Descriptor, oneof.GetCaseFieldDescriptor(message));
+
+ message.OneofUint32 = 10;
+ Assert.AreSame(fields[TestAllTypes.OneofUint32FieldNumber].Descriptor, oneof.GetCaseFieldDescriptor(message));
+
+ oneof.Clear(message);
+ Assert.AreEqual(TestAllTypes.OneofFieldOneofCase.None, message.OneofFieldCase);
+ }
}
}
diff --git a/csharp/src/ProtocolBuffers.Test/IssuesTest.cs b/csharp/src/ProtocolBuffers.Test/IssuesTest.cs index d2248158..b5ad34ae 100644 --- a/csharp/src/ProtocolBuffers.Test/IssuesTest.cs +++ b/csharp/src/ProtocolBuffers.Test/IssuesTest.cs @@ -30,7 +30,7 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#endregion
-using Google.Protobuf.Descriptors;
+using Google.Protobuf.Reflection;
using UnitTest.Issues.TestProtos;
using NUnit.Framework;
diff --git a/csharp/src/ProtocolBuffers.Test/JsonFormatterTest.cs b/csharp/src/ProtocolBuffers.Test/JsonFormatterTest.cs new file mode 100644 index 00000000..5441bf47 --- /dev/null +++ b/csharp/src/ProtocolBuffers.Test/JsonFormatterTest.cs @@ -0,0 +1,261 @@ +#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Google.Protobuf.TestProtos; +using NUnit.Framework; + +namespace Google.Protobuf +{ + public class JsonFormatterTest + { + [Test] + public void DefaultValues_WhenOmitted() + { + var formatter = new JsonFormatter(new JsonFormatter.Settings(formatDefaultValues: false)); + + Assert.AreEqual("{ }", formatter.Format(new ForeignMessage())); + Assert.AreEqual("{ }", formatter.Format(new TestAllTypes())); + Assert.AreEqual("{ }", formatter.Format(new TestMap())); + } + + [Test] + public void DefaultValues_WhenIncluded() + { + var formatter = new JsonFormatter(new JsonFormatter.Settings(formatDefaultValues: true)); + Assert.AreEqual("{ \"c\": 0 }", formatter.Format(new ForeignMessage())); + } + + [Test] + public void AllSingleFields() + { + var message = new TestAllTypes + { + SingleBool = true, + SingleBytes = ByteString.CopyFrom(1, 2, 3, 4), + SingleDouble = 23.5, + SingleFixed32 = 23, + SingleFixed64 = 1234567890123, + SingleFloat = 12.25f, + SingleForeignEnum = ForeignEnum.FOREIGN_BAR, + SingleForeignMessage = new ForeignMessage { C = 10 }, + SingleImportEnum = ImportEnum.IMPORT_BAZ, + SingleImportMessage = new ImportMessage { D = 20 }, + SingleInt32 = 100, + SingleInt64 = 3210987654321, + SingleNestedEnum = TestAllTypes.Types.NestedEnum.FOO, + SingleNestedMessage = new TestAllTypes.Types.NestedMessage { Bb = 35 }, + SinglePublicImportMessage = new PublicImportMessage { E = 54 }, + SingleSfixed32 = -123, + SingleSfixed64 = -12345678901234, + SingleSint32 = -456, + SingleSint64 = -12345678901235, + SingleString = "test\twith\ttabs", + SingleUint32 = uint.MaxValue, + SingleUint64 = ulong.MaxValue, + }; + var actualText = JsonFormatter.Default.Format(message); + + // Fields in declaration order, which matches numeric order. + var expectedText = "{ " + + "\"singleInt32\": 100, " + + "\"singleInt64\": \"3210987654321\", " + + "\"singleUint32\": 4294967295, " + + "\"singleUint64\": \"18446744073709551615\", " + + "\"singleSint32\": -456, " + + "\"singleSint64\": \"-12345678901235\", " + + "\"singleFixed32\": 23, " + + "\"singleFixed64\": \"1234567890123\", " + + "\"singleSfixed32\": -123, " + + "\"singleSfixed64\": \"-12345678901234\", " + + "\"singleFloat\": 12.25, " + + "\"singleDouble\": 23.5, " + + "\"singleBool\": true, " + + "\"singleString\": \"test\\twith\\ttabs\", " + + "\"singleBytes\": \"AQIDBA==\", " + + "\"singleNestedMessage\": { \"bb\": 35 }, " + + "\"singleForeignMessage\": { \"c\": 10 }, " + + "\"singleImportMessage\": { \"d\": 20 }, " + + "\"singleNestedEnum\": \"FOO\", " + + "\"singleForeignEnum\": \"FOREIGN_BAR\", " + + "\"singleImportEnum\": \"IMPORT_BAZ\", " + + "\"singlePublicImportMessage\": { \"e\": 54 }" + + " }"; + Assert.AreEqual(expectedText, actualText); + } + + [Test] + public void RepeatedField() + { + Assert.AreEqual("{ \"repeatedInt32\": [ 1, 2, 3, 4, 5 ] }", + JsonFormatter.Default.Format(new TestAllTypes { RepeatedInt32 = { 1, 2, 3, 4, 5 } })); + } + + [Test] + public void MapField_StringString() + { + Assert.AreEqual("{ \"mapStringString\": { \"with spaces\": \"bar\", \"a\": \"b\" } }", + JsonFormatter.Default.Format(new TestMap { MapStringString = { { "with spaces", "bar" }, { "a", "b" } } })); + } + + [Test] + public void MapField_Int32Int32() + { + // The keys are quoted, but the values aren't. + Assert.AreEqual("{ \"mapInt32Int32\": { \"0\": 1, \"2\": 3 } }", + JsonFormatter.Default.Format(new TestMap { MapInt32Int32 = { { 0, 1 }, { 2, 3 } } })); + } + + [Test] + public void MapField_BoolBool() + { + // The keys are quoted, but the values aren't. + Assert.AreEqual("{ \"mapBoolBool\": { \"false\": true, \"true\": false } }", + JsonFormatter.Default.Format(new TestMap { MapBoolBool = { { false, true }, { true, false } } })); + } + + [TestCase(1.0, "1")] + [TestCase(double.NaN, "\"NaN\"")] + [TestCase(double.PositiveInfinity, "\"Infinity\"")] + [TestCase(double.NegativeInfinity, "\"-Infinity\"")] + public void DoubleRepresentations(double value, string expectedValueText) + { + var message = new TestAllTypes { SingleDouble = value }; + string actualText = JsonFormatter.Default.Format(message); + string expectedText = "{ \"singleDouble\": " + expectedValueText + " }"; + Assert.AreEqual(expectedText, actualText); + } + + [Test] + public void UnknownEnumValueOmitted_SingleField() + { + var message = new TestAllTypes { SingleForeignEnum = (ForeignEnum) 100 }; + Assert.AreEqual("{ }", JsonFormatter.Default.Format(message)); + } + + [Test] + public void UnknownEnumValueOmitted_RepeatedField() + { + var message = new TestAllTypes { RepeatedForeignEnum = { ForeignEnum.FOREIGN_BAZ, (ForeignEnum) 100, ForeignEnum.FOREIGN_FOO } }; + Assert.AreEqual("{ \"repeatedForeignEnum\": [ \"FOREIGN_BAZ\", \"FOREIGN_FOO\" ] }", JsonFormatter.Default.Format(message)); + } + + [Test] + public void UnknownEnumValueOmitted_MapField() + { + // This matches the C++ behaviour. + var message = new TestMap { MapInt32Enum = { { 1, MapEnum.MAP_ENUM_FOO }, { 2, (MapEnum) 100 }, { 3, MapEnum.MAP_ENUM_BAR } } }; + Assert.AreEqual("{ \"mapInt32Enum\": { \"1\": \"MAP_ENUM_FOO\", \"3\": \"MAP_ENUM_BAR\" } }", JsonFormatter.Default.Format(message)); + } + + [Test] + public void UnknownEnumValueOmitted_RepeatedField_AllEntriesUnknown() + { + // *Maybe* we should hold off on writing the "[" until we find that we've got at least one value to write... + // but this is what happens at the moment, and it doesn't seem too awful. + var message = new TestAllTypes { RepeatedForeignEnum = { (ForeignEnum) 200, (ForeignEnum) 100 } }; + Assert.AreEqual("{ \"repeatedForeignEnum\": [ ] }", JsonFormatter.Default.Format(message)); + } + + [Test] + public void NullValueForMessage() + { + var message = new TestMap { MapInt32ForeignMessage = { { 10, null } } }; + Assert.AreEqual("{ \"mapInt32ForeignMessage\": { \"10\": null } }", JsonFormatter.Default.Format(message)); + } + + [Test] + [TestCase("a\u17b4b", "a\\u17b4b")] // Explicit + [TestCase("a\u0601b", "a\\u0601b")] // Ranged + [TestCase("a\u0605b", "a\u0605b")] // Passthrough (note lack of double backslash...) + public void SimpleNonAscii(string text, string encoded) + { + var message = new TestAllTypes { SingleString = text }; + Assert.AreEqual("{ \"singleString\": \"" + encoded + "\" }", JsonFormatter.Default.Format(message)); + } + + [Test] + public void SurrogatePairEscaping() + { + var message = new TestAllTypes { SingleString = "a\uD801\uDC01b" }; + Assert.AreEqual("{ \"singleString\": \"a\\ud801\\udc01b\" }", JsonFormatter.Default.Format(message)); + } + + [Test] + public void InvalidSurrogatePairsFail() + { + // Note: don't use TestCase for these, as the strings can't be reliably represented + // See http://codeblog.jonskeet.uk/2014/11/07/when-is-a-string-not-a-string/ + + // Lone low surrogate + var message = new TestAllTypes { SingleString = "a\uDC01b" }; + Assert.Throws<ArgumentException>(() => JsonFormatter.Default.Format(message)); + + // Lone high surrogate + message = new TestAllTypes { SingleString = "a\uD801b" }; + Assert.Throws<ArgumentException>(() => JsonFormatter.Default.Format(message)); + } + + [Test] + [TestCase("foo_bar", "fooBar")] + [TestCase("bananaBanana", "bananaBanana")] + [TestCase("BANANABanana", "bananaBanana")] + public void ToCamelCase(string original, string expected) + { + Assert.AreEqual(expected, JsonFormatter.ToCamelCase(original)); + } + + [Test] + [TestCase(null, "{ }")] + [TestCase("x", "{ \"fooString\": \"x\" }")] + [TestCase("", "{ \"fooString\": \"\" }")] + [TestCase(null, "{ }")] + public void Oneof(string fooStringValue, string expectedJson) + { + var message = new TestOneof(); + if (fooStringValue != null) + { + message.FooString = fooStringValue; + } + + // We should get the same result both with and without "format default values". + var formatter = new JsonFormatter(new JsonFormatter.Settings(false)); + Assert.AreEqual(expectedJson, formatter.Format(message)); + formatter = new JsonFormatter(new JsonFormatter.Settings(true)); + Assert.AreEqual(expectedJson, formatter.Format(message)); + } + } +} diff --git a/csharp/src/ProtocolBuffers.Test/ProtocolBuffers.Test.csproj b/csharp/src/ProtocolBuffers.Test/ProtocolBuffers.Test.csproj index b02abe70..45c75bae 100644 --- a/csharp/src/ProtocolBuffers.Test/ProtocolBuffers.Test.csproj +++ b/csharp/src/ProtocolBuffers.Test/ProtocolBuffers.Test.csproj @@ -80,6 +80,8 @@ <Compile Include="GeneratedMessageTest.cs" />
<Compile Include="Collections\MapFieldTest.cs" />
<Compile Include="Collections\RepeatedFieldTest.cs" />
+ <Compile Include="JsonFormatterTest.cs" />
+ <Compile Include="Reflection\DescriptorsTest.cs" />
<Compile Include="SampleEnum.cs" />
<Compile Include="SampleMessages.cs" />
<Compile Include="TestProtos\MapUnittestProto3.cs" />
@@ -88,7 +90,6 @@ <Compile Include="TestProtos\UnittestIssues.cs" />
<Compile Include="TestProtos\UnittestProto3.cs" />
<Compile Include="DeprecatedMemberTest.cs" />
- <Compile Include="DescriptorsTest.cs" />
<Compile Include="IssuesTest.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="TestCornerCases.cs" />
diff --git a/csharp/src/ProtocolBuffers.Test/DescriptorsTest.cs b/csharp/src/ProtocolBuffers.Test/Reflection/DescriptorsTest.cs index d5c622bc..0db01a5e 100644 --- a/csharp/src/ProtocolBuffers.Test/DescriptorsTest.cs +++ b/csharp/src/ProtocolBuffers.Test/Reflection/DescriptorsTest.cs @@ -1,225 +1,223 @@ -#region Copyright notice and license
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc. All rights reserved.
-// https://developers.google.com/protocol-buffers/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#endregion
-
-using System.Linq;
-using Google.Protobuf.DescriptorProtos;
-using Google.Protobuf.Descriptors;
-using Google.Protobuf.TestProtos;
-using NUnit.Framework;
-
-namespace Google.Protobuf
-{
- /// <summary>
- /// Tests for descriptors. (Not in its own namespace or broken up into individual classes as the
- /// size doesn't warrant it. On the other hand, this makes me feel a bit dirty...)
- /// </summary>
- public class DescriptorsTest
- {
- [Test]
- public void FileDescriptor()
- {
- FileDescriptor file = UnittestProto3.Descriptor;
-
- Assert.AreEqual("google/protobuf/unittest_proto3.proto", file.Name);
- Assert.AreEqual("protobuf_unittest", file.Package);
-
- Assert.AreEqual("UnittestProto", file.Proto.Options.JavaOuterClassname);
- Assert.AreEqual("google/protobuf/unittest_proto3.proto", file.Proto.Name);
-
- // unittest.proto doesn't have any public imports, but unittest_import.proto does.
- Assert.AreEqual(0, file.PublicDependencies.Count);
- Assert.AreEqual(1, UnittestImportProto3.Descriptor.PublicDependencies.Count);
- Assert.AreEqual(UnittestImportPublicProto3.Descriptor, UnittestImportProto3.Descriptor.PublicDependencies[0]);
-
- Assert.AreEqual(1, file.Dependencies.Count);
- Assert.AreEqual(UnittestImportProto3.Descriptor, file.Dependencies[0]);
-
- MessageDescriptor messageType = TestAllTypes.Descriptor;
- Assert.AreEqual(messageType, file.MessageTypes[0]);
- Assert.AreEqual(messageType, file.FindTypeByName<MessageDescriptor>("TestAllTypes"));
- Assert.Null(file.FindTypeByName<MessageDescriptor>("NoSuchType"));
- Assert.Null(file.FindTypeByName<MessageDescriptor>("protobuf_unittest.TestAllTypes"));
- for (int i = 0; i < file.MessageTypes.Count; i++)
- {
- Assert.AreEqual(i, file.MessageTypes[i].Index);
- }
-
- Assert.AreEqual(file.EnumTypes[0], file.FindTypeByName<EnumDescriptor>("ForeignEnum"));
- Assert.Null(file.FindTypeByName<EnumDescriptor>("NoSuchType"));
- Assert.Null(file.FindTypeByName<EnumDescriptor>("protobuf_unittest.ForeignEnum"));
- Assert.AreEqual(1, UnittestImportProto3.Descriptor.EnumTypes.Count);
- Assert.AreEqual("ImportEnum", UnittestImportProto3.Descriptor.EnumTypes[0].Name);
- for (int i = 0; i < file.EnumTypes.Count; i++)
- {
- Assert.AreEqual(i, file.EnumTypes[i].Index);
- }
- }
-
- [Test]
- public void MessageDescriptor()
- {
- MessageDescriptor messageType = TestAllTypes.Descriptor;
- MessageDescriptor nestedType = TestAllTypes.Types.NestedMessage.Descriptor;
-
- Assert.AreEqual("TestAllTypes", messageType.Name);
- Assert.AreEqual("protobuf_unittest.TestAllTypes", messageType.FullName);
- Assert.AreEqual(UnittestProto3.Descriptor, messageType.File);
- Assert.IsNull(messageType.ContainingType);
- Assert.IsNull(messageType.Proto.Options);
-
- Assert.AreEqual("TestAllTypes", messageType.Name);
-
- Assert.AreEqual("NestedMessage", nestedType.Name);
- Assert.AreEqual("protobuf_unittest.TestAllTypes.NestedMessage", nestedType.FullName);
- Assert.AreEqual(UnittestProto3.Descriptor, nestedType.File);
- Assert.AreEqual(messageType, nestedType.ContainingType);
-
- FieldDescriptor field = messageType.Fields[0];
- Assert.AreEqual("single_int32", field.Name);
- Assert.AreEqual(field, messageType.FindDescriptor<FieldDescriptor>("single_int32"));
- Assert.Null(messageType.FindDescriptor<FieldDescriptor>("no_such_field"));
- Assert.AreEqual(field, messageType.FindFieldByNumber(1));
- Assert.Null(messageType.FindFieldByNumber(571283));
- for (int i = 0; i < messageType.Fields.Count; i++)
- {
- Assert.AreEqual(i, messageType.Fields[i].Index);
- }
-
- Assert.AreEqual(nestedType, messageType.NestedTypes[0]);
- Assert.AreEqual(nestedType, messageType.FindDescriptor<MessageDescriptor>("NestedMessage"));
- Assert.Null(messageType.FindDescriptor<MessageDescriptor>("NoSuchType"));
- for (int i = 0; i < messageType.NestedTypes.Count; i++)
- {
- Assert.AreEqual(i, messageType.NestedTypes[i].Index);
- }
-
- Assert.AreEqual(messageType.EnumTypes[0], messageType.FindDescriptor<EnumDescriptor>("NestedEnum"));
- Assert.Null(messageType.FindDescriptor<EnumDescriptor>("NoSuchType"));
- for (int i = 0; i < messageType.EnumTypes.Count; i++)
- {
- Assert.AreEqual(i, messageType.EnumTypes[i].Index);
- }
- }
-
- [Test]
- public void FieldDescriptor()
- {
- MessageDescriptor messageType = TestAllTypes.Descriptor;
- FieldDescriptor primitiveField = messageType.FindDescriptor<FieldDescriptor>("single_int32");
- FieldDescriptor enumField = messageType.FindDescriptor<FieldDescriptor>("single_nested_enum");
- FieldDescriptor messageField = messageType.FindDescriptor<FieldDescriptor>("single_foreign_message");
-
- Assert.AreEqual("single_int32", primitiveField.Name);
- Assert.AreEqual("protobuf_unittest.TestAllTypes.single_int32",
- primitiveField.FullName);
- Assert.AreEqual(1, primitiveField.FieldNumber);
- Assert.AreEqual(messageType, primitiveField.ContainingType);
- Assert.AreEqual(UnittestProto3.Descriptor, primitiveField.File);
- Assert.AreEqual(FieldType.Int32, primitiveField.FieldType);
- Assert.IsNull(primitiveField.Proto.Options);
-
- Assert.AreEqual("single_nested_enum", enumField.Name);
- Assert.AreEqual(FieldType.Enum, enumField.FieldType);
- // Assert.AreEqual(TestAllTypes.Types.NestedEnum.DescriptorProtoFile, enumField.EnumType);
-
- Assert.AreEqual("single_foreign_message", messageField.Name);
- Assert.AreEqual(FieldType.Message, messageField.FieldType);
- Assert.AreEqual(ForeignMessage.Descriptor, messageField.MessageType);
- }
-
- [Test]
- public void FieldDescriptorLabel()
- {
- FieldDescriptor singleField =
- TestAllTypes.Descriptor.FindDescriptor<FieldDescriptor>("single_int32");
- FieldDescriptor repeatedField =
- TestAllTypes.Descriptor.FindDescriptor<FieldDescriptor>("repeated_int32");
-
- Assert.IsFalse(singleField.IsRepeated);
- Assert.IsTrue(repeatedField.IsRepeated);
- }
-
- [Test]
- public void EnumDescriptor()
- {
- // Note: this test is a bit different to the Java version because there's no static way of getting to the descriptor
- EnumDescriptor enumType = UnittestProto3.Descriptor.FindTypeByName<EnumDescriptor>("ForeignEnum");
- EnumDescriptor nestedType = TestAllTypes.Descriptor.FindDescriptor<EnumDescriptor>("NestedEnum");
-
- Assert.AreEqual("ForeignEnum", enumType.Name);
- Assert.AreEqual("protobuf_unittest.ForeignEnum", enumType.FullName);
- Assert.AreEqual(UnittestProto3.Descriptor, enumType.File);
- Assert.Null(enumType.ContainingType);
- Assert.Null(enumType.Proto.Options);
-
- Assert.AreEqual("NestedEnum", nestedType.Name);
- Assert.AreEqual("protobuf_unittest.TestAllTypes.NestedEnum",
- nestedType.FullName);
- Assert.AreEqual(UnittestProto3.Descriptor, nestedType.File);
- Assert.AreEqual(TestAllTypes.Descriptor, nestedType.ContainingType);
-
- EnumValueDescriptor value = enumType.FindValueByName("FOREIGN_FOO");
- Assert.AreEqual(value, enumType.Values[1]);
- Assert.AreEqual("FOREIGN_FOO", value.Name);
- Assert.AreEqual(4, value.Number);
- Assert.AreEqual((int) ForeignEnum.FOREIGN_FOO, value.Number);
- Assert.AreEqual(value, enumType.FindValueByNumber(4));
- Assert.Null(enumType.FindValueByName("NO_SUCH_VALUE"));
- for (int i = 0; i < enumType.Values.Count; i++)
- {
- Assert.AreEqual(i, enumType.Values[i].Index);
- }
- }
-
- [Test]
- public void OneofDescriptor()
- {
- OneofDescriptor descriptor = TestAllTypes.Descriptor.FindDescriptor<OneofDescriptor>("oneof_field");
- Assert.AreEqual("oneof_field", descriptor.Name);
- Assert.AreEqual("protobuf_unittest.TestAllTypes.oneof_field", descriptor.FullName);
-
- var expectedFields = new[] {
- TestAllTypes.OneofBytesFieldNumber,
- TestAllTypes.OneofNestedMessageFieldNumber,
- TestAllTypes.OneofStringFieldNumber,
- TestAllTypes.OneofUint32FieldNumber }
- .Select(fieldNumber => TestAllTypes.Descriptor.FindFieldByNumber(fieldNumber))
- .ToList();
- foreach (var field in expectedFields)
- {
- Assert.AreSame(descriptor, field.ContainingOneof);
- }
-
- CollectionAssert.AreEquivalent(expectedFields, descriptor.Fields);
- }
- }
+#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +using System.Linq; +using Google.Protobuf.TestProtos; +using NUnit.Framework; + +namespace Google.Protobuf.Reflection +{ + /// <summary> + /// Tests for descriptors. (Not in its own namespace or broken up into individual classes as the + /// size doesn't warrant it. On the other hand, this makes me feel a bit dirty...) + /// </summary> + public class DescriptorsTest + { + [Test] + public void FileDescriptor() + { + FileDescriptor file = UnittestProto3.Descriptor; + + Assert.AreEqual("google/protobuf/unittest_proto3.proto", file.Name); + Assert.AreEqual("protobuf_unittest", file.Package); + + Assert.AreEqual("UnittestProto", file.Proto.Options.JavaOuterClassname); + Assert.AreEqual("google/protobuf/unittest_proto3.proto", file.Proto.Name); + + // unittest.proto doesn't have any public imports, but unittest_import.proto does. + Assert.AreEqual(0, file.PublicDependencies.Count); + Assert.AreEqual(1, UnittestImportProto3.Descriptor.PublicDependencies.Count); + Assert.AreEqual(UnittestImportPublicProto3.Descriptor, UnittestImportProto3.Descriptor.PublicDependencies[0]); + + Assert.AreEqual(1, file.Dependencies.Count); + Assert.AreEqual(UnittestImportProto3.Descriptor, file.Dependencies[0]); + + MessageDescriptor messageType = TestAllTypes.Descriptor; + Assert.AreEqual(messageType, file.MessageTypes[0]); + Assert.AreEqual(messageType, file.FindTypeByName<MessageDescriptor>("TestAllTypes")); + Assert.Null(file.FindTypeByName<MessageDescriptor>("NoSuchType")); + Assert.Null(file.FindTypeByName<MessageDescriptor>("protobuf_unittest.TestAllTypes")); + for (int i = 0; i < file.MessageTypes.Count; i++) + { + Assert.AreEqual(i, file.MessageTypes[i].Index); + } + + Assert.AreEqual(file.EnumTypes[0], file.FindTypeByName<EnumDescriptor>("ForeignEnum")); + Assert.Null(file.FindTypeByName<EnumDescriptor>("NoSuchType")); + Assert.Null(file.FindTypeByName<EnumDescriptor>("protobuf_unittest.ForeignEnum")); + Assert.AreEqual(1, UnittestImportProto3.Descriptor.EnumTypes.Count); + Assert.AreEqual("ImportEnum", UnittestImportProto3.Descriptor.EnumTypes[0].Name); + for (int i = 0; i < file.EnumTypes.Count; i++) + { + Assert.AreEqual(i, file.EnumTypes[i].Index); + } + } + + [Test] + public void MessageDescriptor() + { + MessageDescriptor messageType = TestAllTypes.Descriptor; + MessageDescriptor nestedType = TestAllTypes.Types.NestedMessage.Descriptor; + + Assert.AreEqual("TestAllTypes", messageType.Name); + Assert.AreEqual("protobuf_unittest.TestAllTypes", messageType.FullName); + Assert.AreEqual(UnittestProto3.Descriptor, messageType.File); + Assert.IsNull(messageType.ContainingType); + Assert.IsNull(messageType.Proto.Options); + + Assert.AreEqual("TestAllTypes", messageType.Name); + + Assert.AreEqual("NestedMessage", nestedType.Name); + Assert.AreEqual("protobuf_unittest.TestAllTypes.NestedMessage", nestedType.FullName); + Assert.AreEqual(UnittestProto3.Descriptor, nestedType.File); + Assert.AreEqual(messageType, nestedType.ContainingType); + + FieldDescriptor field = messageType.Fields[0]; + Assert.AreEqual("single_int32", field.Name); + Assert.AreEqual(field, messageType.FindDescriptor<FieldDescriptor>("single_int32")); + Assert.Null(messageType.FindDescriptor<FieldDescriptor>("no_such_field")); + Assert.AreEqual(field, messageType.FindFieldByNumber(1)); + Assert.Null(messageType.FindFieldByNumber(571283)); + for (int i = 0; i < messageType.Fields.Count; i++) + { + Assert.AreEqual(i, messageType.Fields[i].Index); + } + + Assert.AreEqual(nestedType, messageType.NestedTypes[0]); + Assert.AreEqual(nestedType, messageType.FindDescriptor<MessageDescriptor>("NestedMessage")); + Assert.Null(messageType.FindDescriptor<MessageDescriptor>("NoSuchType")); + for (int i = 0; i < messageType.NestedTypes.Count; i++) + { + Assert.AreEqual(i, messageType.NestedTypes[i].Index); + } + + Assert.AreEqual(messageType.EnumTypes[0], messageType.FindDescriptor<EnumDescriptor>("NestedEnum")); + Assert.Null(messageType.FindDescriptor<EnumDescriptor>("NoSuchType")); + for (int i = 0; i < messageType.EnumTypes.Count; i++) + { + Assert.AreEqual(i, messageType.EnumTypes[i].Index); + } + } + + [Test] + public void FieldDescriptor() + { + MessageDescriptor messageType = TestAllTypes.Descriptor; + FieldDescriptor primitiveField = messageType.FindDescriptor<FieldDescriptor>("single_int32"); + FieldDescriptor enumField = messageType.FindDescriptor<FieldDescriptor>("single_nested_enum"); + FieldDescriptor messageField = messageType.FindDescriptor<FieldDescriptor>("single_foreign_message"); + + Assert.AreEqual("single_int32", primitiveField.Name); + Assert.AreEqual("protobuf_unittest.TestAllTypes.single_int32", + primitiveField.FullName); + Assert.AreEqual(1, primitiveField.FieldNumber); + Assert.AreEqual(messageType, primitiveField.ContainingType); + Assert.AreEqual(UnittestProto3.Descriptor, primitiveField.File); + Assert.AreEqual(FieldType.Int32, primitiveField.FieldType); + Assert.IsNull(primitiveField.Proto.Options); + + Assert.AreEqual("single_nested_enum", enumField.Name); + Assert.AreEqual(FieldType.Enum, enumField.FieldType); + // Assert.AreEqual(TestAllTypes.Types.NestedEnum.DescriptorProtoFile, enumField.EnumType); + + Assert.AreEqual("single_foreign_message", messageField.Name); + Assert.AreEqual(FieldType.Message, messageField.FieldType); + Assert.AreEqual(ForeignMessage.Descriptor, messageField.MessageType); + } + + [Test] + public void FieldDescriptorLabel() + { + FieldDescriptor singleField = + TestAllTypes.Descriptor.FindDescriptor<FieldDescriptor>("single_int32"); + FieldDescriptor repeatedField = + TestAllTypes.Descriptor.FindDescriptor<FieldDescriptor>("repeated_int32"); + + Assert.IsFalse(singleField.IsRepeated); + Assert.IsTrue(repeatedField.IsRepeated); + } + + [Test] + public void EnumDescriptor() + { + // Note: this test is a bit different to the Java version because there's no static way of getting to the descriptor + EnumDescriptor enumType = UnittestProto3.Descriptor.FindTypeByName<EnumDescriptor>("ForeignEnum"); + EnumDescriptor nestedType = TestAllTypes.Descriptor.FindDescriptor<EnumDescriptor>("NestedEnum"); + + Assert.AreEqual("ForeignEnum", enumType.Name); + Assert.AreEqual("protobuf_unittest.ForeignEnum", enumType.FullName); + Assert.AreEqual(UnittestProto3.Descriptor, enumType.File); + Assert.Null(enumType.ContainingType); + Assert.Null(enumType.Proto.Options); + + Assert.AreEqual("NestedEnum", nestedType.Name); + Assert.AreEqual("protobuf_unittest.TestAllTypes.NestedEnum", + nestedType.FullName); + Assert.AreEqual(UnittestProto3.Descriptor, nestedType.File); + Assert.AreEqual(TestAllTypes.Descriptor, nestedType.ContainingType); + + EnumValueDescriptor value = enumType.FindValueByName("FOREIGN_FOO"); + Assert.AreEqual(value, enumType.Values[1]); + Assert.AreEqual("FOREIGN_FOO", value.Name); + Assert.AreEqual(4, value.Number); + Assert.AreEqual((int) ForeignEnum.FOREIGN_FOO, value.Number); + Assert.AreEqual(value, enumType.FindValueByNumber(4)); + Assert.Null(enumType.FindValueByName("NO_SUCH_VALUE")); + for (int i = 0; i < enumType.Values.Count; i++) + { + Assert.AreEqual(i, enumType.Values[i].Index); + } + } + + [Test] + public void OneofDescriptor() + { + OneofDescriptor descriptor = TestAllTypes.Descriptor.FindDescriptor<OneofDescriptor>("oneof_field"); + Assert.AreEqual("oneof_field", descriptor.Name); + Assert.AreEqual("protobuf_unittest.TestAllTypes.oneof_field", descriptor.FullName); + + var expectedFields = new[] { + TestAllTypes.OneofBytesFieldNumber, + TestAllTypes.OneofNestedMessageFieldNumber, + TestAllTypes.OneofStringFieldNumber, + TestAllTypes.OneofUint32FieldNumber } + .Select(fieldNumber => TestAllTypes.Descriptor.FindFieldByNumber(fieldNumber)) + .ToList(); + foreach (var field in expectedFields) + { + Assert.AreSame(descriptor, field.ContainingOneof); + } + + CollectionAssert.AreEquivalent(expectedFields, descriptor.Fields); + } + } }
\ No newline at end of file diff --git a/csharp/src/ProtocolBuffers.Test/TestProtos/MapUnittestProto3.cs b/csharp/src/ProtocolBuffers.Test/TestProtos/MapUnittestProto3.cs index 55434c53..5f6eae0c 100644 --- a/csharp/src/ProtocolBuffers.Test/TestProtos/MapUnittestProto3.cs +++ b/csharp/src/ProtocolBuffers.Test/TestProtos/MapUnittestProto3.cs @@ -5,7 +5,7 @@ using pb = global::Google.Protobuf; using pbc = global::Google.Protobuf.Collections; -using pbd = global::Google.Protobuf.Descriptors; +using pbr = global::Google.Protobuf.Reflection; using scg = global::System.Collections.Generic; namespace Google.Protobuf.TestProtos { @@ -13,56 +13,19 @@ namespace Google.Protobuf.TestProtos { public static partial class MapUnittestProto3 { #region Static variables - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestMap__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestMap_MapInt32Int32Entry__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestMap_MapInt64Int64Entry__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestMap_MapUint32Uint32Entry__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestMap_MapUint64Uint64Entry__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestMap_MapSint32Sint32Entry__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestMap_MapSint64Sint64Entry__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestMap_MapFixed32Fixed32Entry__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestMap_MapFixed64Fixed64Entry__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestMap_MapSfixed32Sfixed32Entry__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestMap_MapSfixed64Sfixed64Entry__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestMap_MapInt32FloatEntry__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestMap_MapInt32DoubleEntry__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestMap_MapBoolBoolEntry__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestMap_MapStringStringEntry__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestMap_MapInt32BytesEntry__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestMap_MapInt32EnumEntry__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestMap_MapInt32ForeignMessageEntry__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestMapSubmessage__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestMessageMap__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestMessageMap_MapInt32MessageEntry__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestSameTypeMap__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestSameTypeMap_Map1Entry__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestSameTypeMap_Map2Entry__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestArenaMap__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestArenaMap_MapInt32Int32Entry__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestArenaMap_MapInt64Int64Entry__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestArenaMap_MapUint32Uint32Entry__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestArenaMap_MapUint64Uint64Entry__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestArenaMap_MapSint32Sint32Entry__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestArenaMap_MapSint64Sint64Entry__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestArenaMap_MapFixed32Fixed32Entry__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestArenaMap_MapFixed64Fixed64Entry__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestArenaMap_MapSfixed32Sfixed32Entry__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestArenaMap_MapSfixed64Sfixed64Entry__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestArenaMap_MapInt32FloatEntry__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestArenaMap_MapInt32DoubleEntry__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestArenaMap_MapBoolBoolEntry__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestArenaMap_MapInt32EnumEntry__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestArenaMap_MapInt32ForeignMessageEntry__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_MessageContainingEnumCalledType__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_MessageContainingEnumCalledType_TypeEntry__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_MessageContainingMapCalledEntry__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_MessageContainingMapCalledEntry_EntryEntry__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_protobuf_unittest_TestMap__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_protobuf_unittest_TestMapSubmessage__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_protobuf_unittest_TestMessageMap__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_protobuf_unittest_TestSameTypeMap__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_protobuf_unittest_TestArenaMap__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_protobuf_unittest_MessageContainingEnumCalledType__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_protobuf_unittest_MessageContainingMapCalledEntry__FieldAccessorTable; #endregion #region Descriptor - public static pbd::FileDescriptor Descriptor { + public static pbr::FileDescriptor Descriptor { get { return descriptor; } } - private static pbd::FileDescriptor descriptor; + private static pbr::FileDescriptor descriptor; static MapUnittestProto3() { byte[] descriptorData = global::System.Convert.FromBase64String( @@ -191,142 +154,31 @@ namespace Google.Protobuf.TestProtos { "dmFsdWUYAiABKAU6AjgBKj8KB01hcEVudW0SEAoMTUFQX0VOVU1fRk9PEAAS", "EAoMTUFQX0VOVU1fQkFSEAESEAoMTUFQX0VOVU1fQkFaEAJCIPgBAaoCGkdv", "b2dsZS5Qcm90b2J1Zi5UZXN0UHJvdG9zYgZwcm90bzM=")); - descriptor = pbd::FileDescriptor.InternalBuildGeneratedFileFrom(descriptorData, - new pbd::FileDescriptor[] { + descriptor = pbr::FileDescriptor.InternalBuildGeneratedFileFrom(descriptorData, + new pbr::FileDescriptor[] { global::Google.Protobuf.TestProtos.UnittestProto3.Descriptor, }); internal__static_protobuf_unittest_TestMap__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestMap), descriptor.MessageTypes[0], - new string[] { "MapInt32Int32", "MapInt64Int64", "MapUint32Uint32", "MapUint64Uint64", "MapSint32Sint32", "MapSint64Sint64", "MapFixed32Fixed32", "MapFixed64Fixed64", "MapSfixed32Sfixed32", "MapSfixed64Sfixed64", "MapInt32Float", "MapInt32Double", "MapBoolBool", "MapStringString", "MapInt32Bytes", "MapInt32Enum", "MapInt32ForeignMessage", }); - internal__static_protobuf_unittest_TestMap_MapInt32Int32Entry__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestMap.Types.MapInt32Int32Entry), descriptor.MessageTypes[0].NestedTypes[0], - new string[] { "Key", "Value", }); - internal__static_protobuf_unittest_TestMap_MapInt64Int64Entry__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestMap.Types.MapInt64Int64Entry), descriptor.MessageTypes[0].NestedTypes[1], - new string[] { "Key", "Value", }); - internal__static_protobuf_unittest_TestMap_MapUint32Uint32Entry__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestMap.Types.MapUint32Uint32Entry), descriptor.MessageTypes[0].NestedTypes[2], - new string[] { "Key", "Value", }); - internal__static_protobuf_unittest_TestMap_MapUint64Uint64Entry__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestMap.Types.MapUint64Uint64Entry), descriptor.MessageTypes[0].NestedTypes[3], - new string[] { "Key", "Value", }); - internal__static_protobuf_unittest_TestMap_MapSint32Sint32Entry__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestMap.Types.MapSint32Sint32Entry), descriptor.MessageTypes[0].NestedTypes[4], - new string[] { "Key", "Value", }); - internal__static_protobuf_unittest_TestMap_MapSint64Sint64Entry__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestMap.Types.MapSint64Sint64Entry), descriptor.MessageTypes[0].NestedTypes[5], - new string[] { "Key", "Value", }); - internal__static_protobuf_unittest_TestMap_MapFixed32Fixed32Entry__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestMap.Types.MapFixed32Fixed32Entry), descriptor.MessageTypes[0].NestedTypes[6], - new string[] { "Key", "Value", }); - internal__static_protobuf_unittest_TestMap_MapFixed64Fixed64Entry__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestMap.Types.MapFixed64Fixed64Entry), descriptor.MessageTypes[0].NestedTypes[7], - new string[] { "Key", "Value", }); - internal__static_protobuf_unittest_TestMap_MapSfixed32Sfixed32Entry__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestMap.Types.MapSfixed32Sfixed32Entry), descriptor.MessageTypes[0].NestedTypes[8], - new string[] { "Key", "Value", }); - internal__static_protobuf_unittest_TestMap_MapSfixed64Sfixed64Entry__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestMap.Types.MapSfixed64Sfixed64Entry), descriptor.MessageTypes[0].NestedTypes[9], - new string[] { "Key", "Value", }); - internal__static_protobuf_unittest_TestMap_MapInt32FloatEntry__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestMap.Types.MapInt32FloatEntry), descriptor.MessageTypes[0].NestedTypes[10], - new string[] { "Key", "Value", }); - internal__static_protobuf_unittest_TestMap_MapInt32DoubleEntry__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestMap.Types.MapInt32DoubleEntry), descriptor.MessageTypes[0].NestedTypes[11], - new string[] { "Key", "Value", }); - internal__static_protobuf_unittest_TestMap_MapBoolBoolEntry__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestMap.Types.MapBoolBoolEntry), descriptor.MessageTypes[0].NestedTypes[12], - new string[] { "Key", "Value", }); - internal__static_protobuf_unittest_TestMap_MapStringStringEntry__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestMap.Types.MapStringStringEntry), descriptor.MessageTypes[0].NestedTypes[13], - new string[] { "Key", "Value", }); - internal__static_protobuf_unittest_TestMap_MapInt32BytesEntry__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestMap.Types.MapInt32BytesEntry), descriptor.MessageTypes[0].NestedTypes[14], - new string[] { "Key", "Value", }); - internal__static_protobuf_unittest_TestMap_MapInt32EnumEntry__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestMap.Types.MapInt32EnumEntry), descriptor.MessageTypes[0].NestedTypes[15], - new string[] { "Key", "Value", }); - internal__static_protobuf_unittest_TestMap_MapInt32ForeignMessageEntry__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestMap.Types.MapInt32ForeignMessageEntry), descriptor.MessageTypes[0].NestedTypes[16], - new string[] { "Key", "Value", }); + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestMap), descriptor.MessageTypes[0], + new string[] { "MapInt32Int32", "MapInt64Int64", "MapUint32Uint32", "MapUint64Uint64", "MapSint32Sint32", "MapSint64Sint64", "MapFixed32Fixed32", "MapFixed64Fixed64", "MapSfixed32Sfixed32", "MapSfixed64Sfixed64", "MapInt32Float", "MapInt32Double", "MapBoolBool", "MapStringString", "MapInt32Bytes", "MapInt32Enum", "MapInt32ForeignMessage", }, new string[] { }); internal__static_protobuf_unittest_TestMapSubmessage__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestMapSubmessage), descriptor.MessageTypes[1], - new string[] { "TestMap", }); + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestMapSubmessage), descriptor.MessageTypes[1], + new string[] { "TestMap", }, new string[] { }); internal__static_protobuf_unittest_TestMessageMap__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestMessageMap), descriptor.MessageTypes[2], - new string[] { "MapInt32Message", }); - internal__static_protobuf_unittest_TestMessageMap_MapInt32MessageEntry__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestMessageMap.Types.MapInt32MessageEntry), descriptor.MessageTypes[2].NestedTypes[0], - new string[] { "Key", "Value", }); + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestMessageMap), descriptor.MessageTypes[2], + new string[] { "MapInt32Message", }, new string[] { }); internal__static_protobuf_unittest_TestSameTypeMap__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestSameTypeMap), descriptor.MessageTypes[3], - new string[] { "Map1", "Map2", }); - internal__static_protobuf_unittest_TestSameTypeMap_Map1Entry__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestSameTypeMap.Types.Map1Entry), descriptor.MessageTypes[3].NestedTypes[0], - new string[] { "Key", "Value", }); - internal__static_protobuf_unittest_TestSameTypeMap_Map2Entry__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestSameTypeMap.Types.Map2Entry), descriptor.MessageTypes[3].NestedTypes[1], - new string[] { "Key", "Value", }); + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestSameTypeMap), descriptor.MessageTypes[3], + new string[] { "Map1", "Map2", }, new string[] { }); internal__static_protobuf_unittest_TestArenaMap__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestArenaMap), descriptor.MessageTypes[4], - new string[] { "MapInt32Int32", "MapInt64Int64", "MapUint32Uint32", "MapUint64Uint64", "MapSint32Sint32", "MapSint64Sint64", "MapFixed32Fixed32", "MapFixed64Fixed64", "MapSfixed32Sfixed32", "MapSfixed64Sfixed64", "MapInt32Float", "MapInt32Double", "MapBoolBool", "MapInt32Enum", "MapInt32ForeignMessage", }); - internal__static_protobuf_unittest_TestArenaMap_MapInt32Int32Entry__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestArenaMap.Types.MapInt32Int32Entry), descriptor.MessageTypes[4].NestedTypes[0], - new string[] { "Key", "Value", }); - internal__static_protobuf_unittest_TestArenaMap_MapInt64Int64Entry__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestArenaMap.Types.MapInt64Int64Entry), descriptor.MessageTypes[4].NestedTypes[1], - new string[] { "Key", "Value", }); - internal__static_protobuf_unittest_TestArenaMap_MapUint32Uint32Entry__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestArenaMap.Types.MapUint32Uint32Entry), descriptor.MessageTypes[4].NestedTypes[2], - new string[] { "Key", "Value", }); - internal__static_protobuf_unittest_TestArenaMap_MapUint64Uint64Entry__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestArenaMap.Types.MapUint64Uint64Entry), descriptor.MessageTypes[4].NestedTypes[3], - new string[] { "Key", "Value", }); - internal__static_protobuf_unittest_TestArenaMap_MapSint32Sint32Entry__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestArenaMap.Types.MapSint32Sint32Entry), descriptor.MessageTypes[4].NestedTypes[4], - new string[] { "Key", "Value", }); - internal__static_protobuf_unittest_TestArenaMap_MapSint64Sint64Entry__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestArenaMap.Types.MapSint64Sint64Entry), descriptor.MessageTypes[4].NestedTypes[5], - new string[] { "Key", "Value", }); - internal__static_protobuf_unittest_TestArenaMap_MapFixed32Fixed32Entry__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestArenaMap.Types.MapFixed32Fixed32Entry), descriptor.MessageTypes[4].NestedTypes[6], - new string[] { "Key", "Value", }); - internal__static_protobuf_unittest_TestArenaMap_MapFixed64Fixed64Entry__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestArenaMap.Types.MapFixed64Fixed64Entry), descriptor.MessageTypes[4].NestedTypes[7], - new string[] { "Key", "Value", }); - internal__static_protobuf_unittest_TestArenaMap_MapSfixed32Sfixed32Entry__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestArenaMap.Types.MapSfixed32Sfixed32Entry), descriptor.MessageTypes[4].NestedTypes[8], - new string[] { "Key", "Value", }); - internal__static_protobuf_unittest_TestArenaMap_MapSfixed64Sfixed64Entry__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestArenaMap.Types.MapSfixed64Sfixed64Entry), descriptor.MessageTypes[4].NestedTypes[9], - new string[] { "Key", "Value", }); - internal__static_protobuf_unittest_TestArenaMap_MapInt32FloatEntry__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestArenaMap.Types.MapInt32FloatEntry), descriptor.MessageTypes[4].NestedTypes[10], - new string[] { "Key", "Value", }); - internal__static_protobuf_unittest_TestArenaMap_MapInt32DoubleEntry__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestArenaMap.Types.MapInt32DoubleEntry), descriptor.MessageTypes[4].NestedTypes[11], - new string[] { "Key", "Value", }); - internal__static_protobuf_unittest_TestArenaMap_MapBoolBoolEntry__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestArenaMap.Types.MapBoolBoolEntry), descriptor.MessageTypes[4].NestedTypes[12], - new string[] { "Key", "Value", }); - internal__static_protobuf_unittest_TestArenaMap_MapInt32EnumEntry__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestArenaMap.Types.MapInt32EnumEntry), descriptor.MessageTypes[4].NestedTypes[13], - new string[] { "Key", "Value", }); - internal__static_protobuf_unittest_TestArenaMap_MapInt32ForeignMessageEntry__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestArenaMap.Types.MapInt32ForeignMessageEntry), descriptor.MessageTypes[4].NestedTypes[14], - new string[] { "Key", "Value", }); + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestArenaMap), descriptor.MessageTypes[4], + new string[] { "MapInt32Int32", "MapInt64Int64", "MapUint32Uint32", "MapUint64Uint64", "MapSint32Sint32", "MapSint64Sint64", "MapFixed32Fixed32", "MapFixed64Fixed64", "MapSfixed32Sfixed32", "MapSfixed64Sfixed64", "MapInt32Float", "MapInt32Double", "MapBoolBool", "MapInt32Enum", "MapInt32ForeignMessage", }, new string[] { }); internal__static_protobuf_unittest_MessageContainingEnumCalledType__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.MessageContainingEnumCalledType), descriptor.MessageTypes[5], - new string[] { "Type", }); - internal__static_protobuf_unittest_MessageContainingEnumCalledType_TypeEntry__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.MessageContainingEnumCalledType.Types.TypeEntry), descriptor.MessageTypes[5].NestedTypes[0], - new string[] { "Key", "Value", }); + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.MessageContainingEnumCalledType), descriptor.MessageTypes[5], + new string[] { "Type", }, new string[] { }); internal__static_protobuf_unittest_MessageContainingMapCalledEntry__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.MessageContainingMapCalledEntry), descriptor.MessageTypes[6], - new string[] { "Entry", }); - internal__static_protobuf_unittest_MessageContainingMapCalledEntry_EntryEntry__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.MessageContainingMapCalledEntry.Types.EntryEntry), descriptor.MessageTypes[6].NestedTypes[0], - new string[] { "Key", "Value", }); + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.MessageContainingMapCalledEntry), descriptor.MessageTypes[6], + new string[] { "Entry", }, new string[] { }); } #endregion @@ -348,11 +200,11 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "map_bool_bool", "map_fixed32_fixed32", "map_fixed64_fixed64", "map_int32_bytes", "map_int32_double", "map_int32_enum", "map_int32_float", "map_int32_foreign_message", "map_int32_int32", "map_int64_int64", "map_sfixed32_sfixed32", "map_sfixed64_sfixed64", "map_sint32_sint32", "map_sint64_sint64", "map_string_string", "map_uint32_uint32", "map_uint64_uint64" }; private static readonly uint[] _fieldTags = new uint[] { 106, 58, 66, 122, 98, 130, 90, 138, 10, 18, 74, 82, 42, 50, 114, 26, 34 }; - public static pbd::MessageDescriptor Descriptor { + public static pbr::MessageDescriptor Descriptor { get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.Descriptor.MessageTypes[0]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestMap__FieldAccessorTable; } } @@ -602,6 +454,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { mapInt32Int32_.WriteTo(output, _map_mapInt32Int32_codec); mapInt64Int64_.WriteTo(output, _map_mapInt64Int64_codec); @@ -750,2433 +606,6 @@ namespace Google.Protobuf.TestProtos { } } - #region Nested types - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public static partial class Types { - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class MapInt32Int32Entry : pb::IMessage<MapInt32Int32Entry> { - private static readonly pb::MessageParser<MapInt32Int32Entry> _parser = new pb::MessageParser<MapInt32Int32Entry>(() => new MapInt32Int32Entry()); - public static pb::MessageParser<MapInt32Int32Entry> Parser { get { return _parser; } } - - private static readonly string[] _fieldNames = new string[] { "key", "value" }; - private static readonly uint[] _fieldTags = new uint[] { 8, 16 }; - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.TestMap.Descriptor.NestedTypes[0]; } - } - - public pb::FieldAccess.FieldAccessorTable Fields { - get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestMap_MapInt32Int32Entry__FieldAccessorTable; } - } - - private bool _frozen = false; - public bool IsFrozen { get { return _frozen; } } - - public MapInt32Int32Entry() { - OnConstruction(); - } - - partial void OnConstruction(); - - public MapInt32Int32Entry(MapInt32Int32Entry other) : this() { - key_ = other.key_; - value_ = other.value_; - } - - public MapInt32Int32Entry Clone() { - return new MapInt32Int32Entry(this); - } - - public void Freeze() { - if (IsFrozen) { - return; - } - _frozen = true; - } - - public const int KeyFieldNumber = 1; - private int key_; - public int Key { - get { return key_; } - set { - pb::Freezable.CheckMutable(this); - key_ = value; - } - } - - public const int ValueFieldNumber = 2; - private int value_; - public int Value { - get { return value_; } - set { - pb::Freezable.CheckMutable(this); - value_ = value; - } - } - - public override bool Equals(object other) { - return Equals(other as MapInt32Int32Entry); - } - - public bool Equals(MapInt32Int32Entry other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (Key != other.Key) return false; - if (Value != other.Value) return false; - return true; - } - - public override int GetHashCode() { - int hash = 1; - if (Key != 0) hash ^= Key.GetHashCode(); - if (Value != 0) hash ^= Value.GetHashCode(); - return hash; - } - - public void WriteTo(pb::CodedOutputStream output) { - if (Key != 0) { - output.WriteRawTag(8); - output.WriteInt32(Key); - } - if (Value != 0) { - output.WriteRawTag(16); - output.WriteInt32(Value); - } - } - - public int CalculateSize() { - int size = 0; - if (Key != 0) { - size += 1 + pb::CodedOutputStream.ComputeInt32Size(Key); - } - if (Value != 0) { - size += 1 + pb::CodedOutputStream.ComputeInt32Size(Value); - } - return size; - } - - public void MergeFrom(MapInt32Int32Entry other) { - if (other == null) { - return; - } - if (other.Key != 0) { - Key = other.Key; - } - if (other.Value != 0) { - Value = other.Value; - } - } - - public void MergeFrom(pb::CodedInputStream input) { - uint tag; - while (input.ReadTag(out tag)) { - switch(tag) { - case 0: - throw pb::InvalidProtocolBufferException.InvalidTag(); - default: - if (pb::WireFormat.IsEndGroupTag(tag)) { - return; - } - break; - case 8: { - Key = input.ReadInt32(); - break; - } - case 16: { - Value = input.ReadInt32(); - break; - } - } - } - } - - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class MapInt64Int64Entry : pb::IMessage<MapInt64Int64Entry> { - private static readonly pb::MessageParser<MapInt64Int64Entry> _parser = new pb::MessageParser<MapInt64Int64Entry>(() => new MapInt64Int64Entry()); - public static pb::MessageParser<MapInt64Int64Entry> Parser { get { return _parser; } } - - private static readonly string[] _fieldNames = new string[] { "key", "value" }; - private static readonly uint[] _fieldTags = new uint[] { 8, 16 }; - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.TestMap.Descriptor.NestedTypes[1]; } - } - - public pb::FieldAccess.FieldAccessorTable Fields { - get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestMap_MapInt64Int64Entry__FieldAccessorTable; } - } - - private bool _frozen = false; - public bool IsFrozen { get { return _frozen; } } - - public MapInt64Int64Entry() { - OnConstruction(); - } - - partial void OnConstruction(); - - public MapInt64Int64Entry(MapInt64Int64Entry other) : this() { - key_ = other.key_; - value_ = other.value_; - } - - public MapInt64Int64Entry Clone() { - return new MapInt64Int64Entry(this); - } - - public void Freeze() { - if (IsFrozen) { - return; - } - _frozen = true; - } - - public const int KeyFieldNumber = 1; - private long key_; - public long Key { - get { return key_; } - set { - pb::Freezable.CheckMutable(this); - key_ = value; - } - } - - public const int ValueFieldNumber = 2; - private long value_; - public long Value { - get { return value_; } - set { - pb::Freezable.CheckMutable(this); - value_ = value; - } - } - - public override bool Equals(object other) { - return Equals(other as MapInt64Int64Entry); - } - - public bool Equals(MapInt64Int64Entry other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (Key != other.Key) return false; - if (Value != other.Value) return false; - return true; - } - - public override int GetHashCode() { - int hash = 1; - if (Key != 0L) hash ^= Key.GetHashCode(); - if (Value != 0L) hash ^= Value.GetHashCode(); - return hash; - } - - public void WriteTo(pb::CodedOutputStream output) { - if (Key != 0L) { - output.WriteRawTag(8); - output.WriteInt64(Key); - } - if (Value != 0L) { - output.WriteRawTag(16); - output.WriteInt64(Value); - } - } - - public int CalculateSize() { - int size = 0; - if (Key != 0L) { - size += 1 + pb::CodedOutputStream.ComputeInt64Size(Key); - } - if (Value != 0L) { - size += 1 + pb::CodedOutputStream.ComputeInt64Size(Value); - } - return size; - } - - public void MergeFrom(MapInt64Int64Entry other) { - if (other == null) { - return; - } - if (other.Key != 0L) { - Key = other.Key; - } - if (other.Value != 0L) { - Value = other.Value; - } - } - - public void MergeFrom(pb::CodedInputStream input) { - uint tag; - while (input.ReadTag(out tag)) { - switch(tag) { - case 0: - throw pb::InvalidProtocolBufferException.InvalidTag(); - default: - if (pb::WireFormat.IsEndGroupTag(tag)) { - return; - } - break; - case 8: { - Key = input.ReadInt64(); - break; - } - case 16: { - Value = input.ReadInt64(); - break; - } - } - } - } - - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class MapUint32Uint32Entry : pb::IMessage<MapUint32Uint32Entry> { - private static readonly pb::MessageParser<MapUint32Uint32Entry> _parser = new pb::MessageParser<MapUint32Uint32Entry>(() => new MapUint32Uint32Entry()); - public static pb::MessageParser<MapUint32Uint32Entry> Parser { get { return _parser; } } - - private static readonly string[] _fieldNames = new string[] { "key", "value" }; - private static readonly uint[] _fieldTags = new uint[] { 8, 16 }; - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.TestMap.Descriptor.NestedTypes[2]; } - } - - public pb::FieldAccess.FieldAccessorTable Fields { - get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestMap_MapUint32Uint32Entry__FieldAccessorTable; } - } - - private bool _frozen = false; - public bool IsFrozen { get { return _frozen; } } - - public MapUint32Uint32Entry() { - OnConstruction(); - } - - partial void OnConstruction(); - - public MapUint32Uint32Entry(MapUint32Uint32Entry other) : this() { - key_ = other.key_; - value_ = other.value_; - } - - public MapUint32Uint32Entry Clone() { - return new MapUint32Uint32Entry(this); - } - - public void Freeze() { - if (IsFrozen) { - return; - } - _frozen = true; - } - - public const int KeyFieldNumber = 1; - private uint key_; - public uint Key { - get { return key_; } - set { - pb::Freezable.CheckMutable(this); - key_ = value; - } - } - - public const int ValueFieldNumber = 2; - private uint value_; - public uint Value { - get { return value_; } - set { - pb::Freezable.CheckMutable(this); - value_ = value; - } - } - - public override bool Equals(object other) { - return Equals(other as MapUint32Uint32Entry); - } - - public bool Equals(MapUint32Uint32Entry other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (Key != other.Key) return false; - if (Value != other.Value) return false; - return true; - } - - public override int GetHashCode() { - int hash = 1; - if (Key != 0) hash ^= Key.GetHashCode(); - if (Value != 0) hash ^= Value.GetHashCode(); - return hash; - } - - public void WriteTo(pb::CodedOutputStream output) { - if (Key != 0) { - output.WriteRawTag(8); - output.WriteUInt32(Key); - } - if (Value != 0) { - output.WriteRawTag(16); - output.WriteUInt32(Value); - } - } - - public int CalculateSize() { - int size = 0; - if (Key != 0) { - size += 1 + pb::CodedOutputStream.ComputeUInt32Size(Key); - } - if (Value != 0) { - size += 1 + pb::CodedOutputStream.ComputeUInt32Size(Value); - } - return size; - } - - public void MergeFrom(MapUint32Uint32Entry other) { - if (other == null) { - return; - } - if (other.Key != 0) { - Key = other.Key; - } - if (other.Value != 0) { - Value = other.Value; - } - } - - public void MergeFrom(pb::CodedInputStream input) { - uint tag; - while (input.ReadTag(out tag)) { - switch(tag) { - case 0: - throw pb::InvalidProtocolBufferException.InvalidTag(); - default: - if (pb::WireFormat.IsEndGroupTag(tag)) { - return; - } - break; - case 8: { - Key = input.ReadUInt32(); - break; - } - case 16: { - Value = input.ReadUInt32(); - break; - } - } - } - } - - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class MapUint64Uint64Entry : pb::IMessage<MapUint64Uint64Entry> { - private static readonly pb::MessageParser<MapUint64Uint64Entry> _parser = new pb::MessageParser<MapUint64Uint64Entry>(() => new MapUint64Uint64Entry()); - public static pb::MessageParser<MapUint64Uint64Entry> Parser { get { return _parser; } } - - private static readonly string[] _fieldNames = new string[] { "key", "value" }; - private static readonly uint[] _fieldTags = new uint[] { 8, 16 }; - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.TestMap.Descriptor.NestedTypes[3]; } - } - - public pb::FieldAccess.FieldAccessorTable Fields { - get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestMap_MapUint64Uint64Entry__FieldAccessorTable; } - } - - private bool _frozen = false; - public bool IsFrozen { get { return _frozen; } } - - public MapUint64Uint64Entry() { - OnConstruction(); - } - - partial void OnConstruction(); - - public MapUint64Uint64Entry(MapUint64Uint64Entry other) : this() { - key_ = other.key_; - value_ = other.value_; - } - - public MapUint64Uint64Entry Clone() { - return new MapUint64Uint64Entry(this); - } - - public void Freeze() { - if (IsFrozen) { - return; - } - _frozen = true; - } - - public const int KeyFieldNumber = 1; - private ulong key_; - public ulong Key { - get { return key_; } - set { - pb::Freezable.CheckMutable(this); - key_ = value; - } - } - - public const int ValueFieldNumber = 2; - private ulong value_; - public ulong Value { - get { return value_; } - set { - pb::Freezable.CheckMutable(this); - value_ = value; - } - } - - public override bool Equals(object other) { - return Equals(other as MapUint64Uint64Entry); - } - - public bool Equals(MapUint64Uint64Entry other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (Key != other.Key) return false; - if (Value != other.Value) return false; - return true; - } - - public override int GetHashCode() { - int hash = 1; - if (Key != 0UL) hash ^= Key.GetHashCode(); - if (Value != 0UL) hash ^= Value.GetHashCode(); - return hash; - } - - public void WriteTo(pb::CodedOutputStream output) { - if (Key != 0UL) { - output.WriteRawTag(8); - output.WriteUInt64(Key); - } - if (Value != 0UL) { - output.WriteRawTag(16); - output.WriteUInt64(Value); - } - } - - public int CalculateSize() { - int size = 0; - if (Key != 0UL) { - size += 1 + pb::CodedOutputStream.ComputeUInt64Size(Key); - } - if (Value != 0UL) { - size += 1 + pb::CodedOutputStream.ComputeUInt64Size(Value); - } - return size; - } - - public void MergeFrom(MapUint64Uint64Entry other) { - if (other == null) { - return; - } - if (other.Key != 0UL) { - Key = other.Key; - } - if (other.Value != 0UL) { - Value = other.Value; - } - } - - public void MergeFrom(pb::CodedInputStream input) { - uint tag; - while (input.ReadTag(out tag)) { - switch(tag) { - case 0: - throw pb::InvalidProtocolBufferException.InvalidTag(); - default: - if (pb::WireFormat.IsEndGroupTag(tag)) { - return; - } - break; - case 8: { - Key = input.ReadUInt64(); - break; - } - case 16: { - Value = input.ReadUInt64(); - break; - } - } - } - } - - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class MapSint32Sint32Entry : pb::IMessage<MapSint32Sint32Entry> { - private static readonly pb::MessageParser<MapSint32Sint32Entry> _parser = new pb::MessageParser<MapSint32Sint32Entry>(() => new MapSint32Sint32Entry()); - public static pb::MessageParser<MapSint32Sint32Entry> Parser { get { return _parser; } } - - private static readonly string[] _fieldNames = new string[] { "key", "value" }; - private static readonly uint[] _fieldTags = new uint[] { 8, 16 }; - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.TestMap.Descriptor.NestedTypes[4]; } - } - - public pb::FieldAccess.FieldAccessorTable Fields { - get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestMap_MapSint32Sint32Entry__FieldAccessorTable; } - } - - private bool _frozen = false; - public bool IsFrozen { get { return _frozen; } } - - public MapSint32Sint32Entry() { - OnConstruction(); - } - - partial void OnConstruction(); - - public MapSint32Sint32Entry(MapSint32Sint32Entry other) : this() { - key_ = other.key_; - value_ = other.value_; - } - - public MapSint32Sint32Entry Clone() { - return new MapSint32Sint32Entry(this); - } - - public void Freeze() { - if (IsFrozen) { - return; - } - _frozen = true; - } - - public const int KeyFieldNumber = 1; - private int key_; - public int Key { - get { return key_; } - set { - pb::Freezable.CheckMutable(this); - key_ = value; - } - } - - public const int ValueFieldNumber = 2; - private int value_; - public int Value { - get { return value_; } - set { - pb::Freezable.CheckMutable(this); - value_ = value; - } - } - - public override bool Equals(object other) { - return Equals(other as MapSint32Sint32Entry); - } - - public bool Equals(MapSint32Sint32Entry other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (Key != other.Key) return false; - if (Value != other.Value) return false; - return true; - } - - public override int GetHashCode() { - int hash = 1; - if (Key != 0) hash ^= Key.GetHashCode(); - if (Value != 0) hash ^= Value.GetHashCode(); - return hash; - } - - public void WriteTo(pb::CodedOutputStream output) { - if (Key != 0) { - output.WriteRawTag(8); - output.WriteSInt32(Key); - } - if (Value != 0) { - output.WriteRawTag(16); - output.WriteSInt32(Value); - } - } - - public int CalculateSize() { - int size = 0; - if (Key != 0) { - size += 1 + pb::CodedOutputStream.ComputeSInt32Size(Key); - } - if (Value != 0) { - size += 1 + pb::CodedOutputStream.ComputeSInt32Size(Value); - } - return size; - } - - public void MergeFrom(MapSint32Sint32Entry other) { - if (other == null) { - return; - } - if (other.Key != 0) { - Key = other.Key; - } - if (other.Value != 0) { - Value = other.Value; - } - } - - public void MergeFrom(pb::CodedInputStream input) { - uint tag; - while (input.ReadTag(out tag)) { - switch(tag) { - case 0: - throw pb::InvalidProtocolBufferException.InvalidTag(); - default: - if (pb::WireFormat.IsEndGroupTag(tag)) { - return; - } - break; - case 8: { - Key = input.ReadSInt32(); - break; - } - case 16: { - Value = input.ReadSInt32(); - break; - } - } - } - } - - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class MapSint64Sint64Entry : pb::IMessage<MapSint64Sint64Entry> { - private static readonly pb::MessageParser<MapSint64Sint64Entry> _parser = new pb::MessageParser<MapSint64Sint64Entry>(() => new MapSint64Sint64Entry()); - public static pb::MessageParser<MapSint64Sint64Entry> Parser { get { return _parser; } } - - private static readonly string[] _fieldNames = new string[] { "key", "value" }; - private static readonly uint[] _fieldTags = new uint[] { 8, 16 }; - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.TestMap.Descriptor.NestedTypes[5]; } - } - - public pb::FieldAccess.FieldAccessorTable Fields { - get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestMap_MapSint64Sint64Entry__FieldAccessorTable; } - } - - private bool _frozen = false; - public bool IsFrozen { get { return _frozen; } } - - public MapSint64Sint64Entry() { - OnConstruction(); - } - - partial void OnConstruction(); - - public MapSint64Sint64Entry(MapSint64Sint64Entry other) : this() { - key_ = other.key_; - value_ = other.value_; - } - - public MapSint64Sint64Entry Clone() { - return new MapSint64Sint64Entry(this); - } - - public void Freeze() { - if (IsFrozen) { - return; - } - _frozen = true; - } - - public const int KeyFieldNumber = 1; - private long key_; - public long Key { - get { return key_; } - set { - pb::Freezable.CheckMutable(this); - key_ = value; - } - } - - public const int ValueFieldNumber = 2; - private long value_; - public long Value { - get { return value_; } - set { - pb::Freezable.CheckMutable(this); - value_ = value; - } - } - - public override bool Equals(object other) { - return Equals(other as MapSint64Sint64Entry); - } - - public bool Equals(MapSint64Sint64Entry other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (Key != other.Key) return false; - if (Value != other.Value) return false; - return true; - } - - public override int GetHashCode() { - int hash = 1; - if (Key != 0L) hash ^= Key.GetHashCode(); - if (Value != 0L) hash ^= Value.GetHashCode(); - return hash; - } - - public void WriteTo(pb::CodedOutputStream output) { - if (Key != 0L) { - output.WriteRawTag(8); - output.WriteSInt64(Key); - } - if (Value != 0L) { - output.WriteRawTag(16); - output.WriteSInt64(Value); - } - } - - public int CalculateSize() { - int size = 0; - if (Key != 0L) { - size += 1 + pb::CodedOutputStream.ComputeSInt64Size(Key); - } - if (Value != 0L) { - size += 1 + pb::CodedOutputStream.ComputeSInt64Size(Value); - } - return size; - } - - public void MergeFrom(MapSint64Sint64Entry other) { - if (other == null) { - return; - } - if (other.Key != 0L) { - Key = other.Key; - } - if (other.Value != 0L) { - Value = other.Value; - } - } - - public void MergeFrom(pb::CodedInputStream input) { - uint tag; - while (input.ReadTag(out tag)) { - switch(tag) { - case 0: - throw pb::InvalidProtocolBufferException.InvalidTag(); - default: - if (pb::WireFormat.IsEndGroupTag(tag)) { - return; - } - break; - case 8: { - Key = input.ReadSInt64(); - break; - } - case 16: { - Value = input.ReadSInt64(); - break; - } - } - } - } - - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class MapFixed32Fixed32Entry : pb::IMessage<MapFixed32Fixed32Entry> { - private static readonly pb::MessageParser<MapFixed32Fixed32Entry> _parser = new pb::MessageParser<MapFixed32Fixed32Entry>(() => new MapFixed32Fixed32Entry()); - public static pb::MessageParser<MapFixed32Fixed32Entry> Parser { get { return _parser; } } - - private static readonly string[] _fieldNames = new string[] { "key", "value" }; - private static readonly uint[] _fieldTags = new uint[] { 13, 21 }; - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.TestMap.Descriptor.NestedTypes[6]; } - } - - public pb::FieldAccess.FieldAccessorTable Fields { - get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestMap_MapFixed32Fixed32Entry__FieldAccessorTable; } - } - - private bool _frozen = false; - public bool IsFrozen { get { return _frozen; } } - - public MapFixed32Fixed32Entry() { - OnConstruction(); - } - - partial void OnConstruction(); - - public MapFixed32Fixed32Entry(MapFixed32Fixed32Entry other) : this() { - key_ = other.key_; - value_ = other.value_; - } - - public MapFixed32Fixed32Entry Clone() { - return new MapFixed32Fixed32Entry(this); - } - - public void Freeze() { - if (IsFrozen) { - return; - } - _frozen = true; - } - - public const int KeyFieldNumber = 1; - private uint key_; - public uint Key { - get { return key_; } - set { - pb::Freezable.CheckMutable(this); - key_ = value; - } - } - - public const int ValueFieldNumber = 2; - private uint value_; - public uint Value { - get { return value_; } - set { - pb::Freezable.CheckMutable(this); - value_ = value; - } - } - - public override bool Equals(object other) { - return Equals(other as MapFixed32Fixed32Entry); - } - - public bool Equals(MapFixed32Fixed32Entry other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (Key != other.Key) return false; - if (Value != other.Value) return false; - return true; - } - - public override int GetHashCode() { - int hash = 1; - if (Key != 0) hash ^= Key.GetHashCode(); - if (Value != 0) hash ^= Value.GetHashCode(); - return hash; - } - - public void WriteTo(pb::CodedOutputStream output) { - if (Key != 0) { - output.WriteRawTag(13); - output.WriteFixed32(Key); - } - if (Value != 0) { - output.WriteRawTag(21); - output.WriteFixed32(Value); - } - } - - public int CalculateSize() { - int size = 0; - if (Key != 0) { - size += 1 + 4; - } - if (Value != 0) { - size += 1 + 4; - } - return size; - } - - public void MergeFrom(MapFixed32Fixed32Entry other) { - if (other == null) { - return; - } - if (other.Key != 0) { - Key = other.Key; - } - if (other.Value != 0) { - Value = other.Value; - } - } - - public void MergeFrom(pb::CodedInputStream input) { - uint tag; - while (input.ReadTag(out tag)) { - switch(tag) { - case 0: - throw pb::InvalidProtocolBufferException.InvalidTag(); - default: - if (pb::WireFormat.IsEndGroupTag(tag)) { - return; - } - break; - case 13: { - Key = input.ReadFixed32(); - break; - } - case 21: { - Value = input.ReadFixed32(); - break; - } - } - } - } - - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class MapFixed64Fixed64Entry : pb::IMessage<MapFixed64Fixed64Entry> { - private static readonly pb::MessageParser<MapFixed64Fixed64Entry> _parser = new pb::MessageParser<MapFixed64Fixed64Entry>(() => new MapFixed64Fixed64Entry()); - public static pb::MessageParser<MapFixed64Fixed64Entry> Parser { get { return _parser; } } - - private static readonly string[] _fieldNames = new string[] { "key", "value" }; - private static readonly uint[] _fieldTags = new uint[] { 9, 17 }; - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.TestMap.Descriptor.NestedTypes[7]; } - } - - public pb::FieldAccess.FieldAccessorTable Fields { - get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestMap_MapFixed64Fixed64Entry__FieldAccessorTable; } - } - - private bool _frozen = false; - public bool IsFrozen { get { return _frozen; } } - - public MapFixed64Fixed64Entry() { - OnConstruction(); - } - - partial void OnConstruction(); - - public MapFixed64Fixed64Entry(MapFixed64Fixed64Entry other) : this() { - key_ = other.key_; - value_ = other.value_; - } - - public MapFixed64Fixed64Entry Clone() { - return new MapFixed64Fixed64Entry(this); - } - - public void Freeze() { - if (IsFrozen) { - return; - } - _frozen = true; - } - - public const int KeyFieldNumber = 1; - private ulong key_; - public ulong Key { - get { return key_; } - set { - pb::Freezable.CheckMutable(this); - key_ = value; - } - } - - public const int ValueFieldNumber = 2; - private ulong value_; - public ulong Value { - get { return value_; } - set { - pb::Freezable.CheckMutable(this); - value_ = value; - } - } - - public override bool Equals(object other) { - return Equals(other as MapFixed64Fixed64Entry); - } - - public bool Equals(MapFixed64Fixed64Entry other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (Key != other.Key) return false; - if (Value != other.Value) return false; - return true; - } - - public override int GetHashCode() { - int hash = 1; - if (Key != 0UL) hash ^= Key.GetHashCode(); - if (Value != 0UL) hash ^= Value.GetHashCode(); - return hash; - } - - public void WriteTo(pb::CodedOutputStream output) { - if (Key != 0UL) { - output.WriteRawTag(9); - output.WriteFixed64(Key); - } - if (Value != 0UL) { - output.WriteRawTag(17); - output.WriteFixed64(Value); - } - } - - public int CalculateSize() { - int size = 0; - if (Key != 0UL) { - size += 1 + 8; - } - if (Value != 0UL) { - size += 1 + 8; - } - return size; - } - - public void MergeFrom(MapFixed64Fixed64Entry other) { - if (other == null) { - return; - } - if (other.Key != 0UL) { - Key = other.Key; - } - if (other.Value != 0UL) { - Value = other.Value; - } - } - - public void MergeFrom(pb::CodedInputStream input) { - uint tag; - while (input.ReadTag(out tag)) { - switch(tag) { - case 0: - throw pb::InvalidProtocolBufferException.InvalidTag(); - default: - if (pb::WireFormat.IsEndGroupTag(tag)) { - return; - } - break; - case 9: { - Key = input.ReadFixed64(); - break; - } - case 17: { - Value = input.ReadFixed64(); - break; - } - } - } - } - - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class MapSfixed32Sfixed32Entry : pb::IMessage<MapSfixed32Sfixed32Entry> { - private static readonly pb::MessageParser<MapSfixed32Sfixed32Entry> _parser = new pb::MessageParser<MapSfixed32Sfixed32Entry>(() => new MapSfixed32Sfixed32Entry()); - public static pb::MessageParser<MapSfixed32Sfixed32Entry> Parser { get { return _parser; } } - - private static readonly string[] _fieldNames = new string[] { "key", "value" }; - private static readonly uint[] _fieldTags = new uint[] { 13, 21 }; - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.TestMap.Descriptor.NestedTypes[8]; } - } - - public pb::FieldAccess.FieldAccessorTable Fields { - get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestMap_MapSfixed32Sfixed32Entry__FieldAccessorTable; } - } - - private bool _frozen = false; - public bool IsFrozen { get { return _frozen; } } - - public MapSfixed32Sfixed32Entry() { - OnConstruction(); - } - - partial void OnConstruction(); - - public MapSfixed32Sfixed32Entry(MapSfixed32Sfixed32Entry other) : this() { - key_ = other.key_; - value_ = other.value_; - } - - public MapSfixed32Sfixed32Entry Clone() { - return new MapSfixed32Sfixed32Entry(this); - } - - public void Freeze() { - if (IsFrozen) { - return; - } - _frozen = true; - } - - public const int KeyFieldNumber = 1; - private int key_; - public int Key { - get { return key_; } - set { - pb::Freezable.CheckMutable(this); - key_ = value; - } - } - - public const int ValueFieldNumber = 2; - private int value_; - public int Value { - get { return value_; } - set { - pb::Freezable.CheckMutable(this); - value_ = value; - } - } - - public override bool Equals(object other) { - return Equals(other as MapSfixed32Sfixed32Entry); - } - - public bool Equals(MapSfixed32Sfixed32Entry other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (Key != other.Key) return false; - if (Value != other.Value) return false; - return true; - } - - public override int GetHashCode() { - int hash = 1; - if (Key != 0) hash ^= Key.GetHashCode(); - if (Value != 0) hash ^= Value.GetHashCode(); - return hash; - } - - public void WriteTo(pb::CodedOutputStream output) { - if (Key != 0) { - output.WriteRawTag(13); - output.WriteSFixed32(Key); - } - if (Value != 0) { - output.WriteRawTag(21); - output.WriteSFixed32(Value); - } - } - - public int CalculateSize() { - int size = 0; - if (Key != 0) { - size += 1 + 4; - } - if (Value != 0) { - size += 1 + 4; - } - return size; - } - - public void MergeFrom(MapSfixed32Sfixed32Entry other) { - if (other == null) { - return; - } - if (other.Key != 0) { - Key = other.Key; - } - if (other.Value != 0) { - Value = other.Value; - } - } - - public void MergeFrom(pb::CodedInputStream input) { - uint tag; - while (input.ReadTag(out tag)) { - switch(tag) { - case 0: - throw pb::InvalidProtocolBufferException.InvalidTag(); - default: - if (pb::WireFormat.IsEndGroupTag(tag)) { - return; - } - break; - case 13: { - Key = input.ReadSFixed32(); - break; - } - case 21: { - Value = input.ReadSFixed32(); - break; - } - } - } - } - - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class MapSfixed64Sfixed64Entry : pb::IMessage<MapSfixed64Sfixed64Entry> { - private static readonly pb::MessageParser<MapSfixed64Sfixed64Entry> _parser = new pb::MessageParser<MapSfixed64Sfixed64Entry>(() => new MapSfixed64Sfixed64Entry()); - public static pb::MessageParser<MapSfixed64Sfixed64Entry> Parser { get { return _parser; } } - - private static readonly string[] _fieldNames = new string[] { "key", "value" }; - private static readonly uint[] _fieldTags = new uint[] { 9, 17 }; - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.TestMap.Descriptor.NestedTypes[9]; } - } - - public pb::FieldAccess.FieldAccessorTable Fields { - get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestMap_MapSfixed64Sfixed64Entry__FieldAccessorTable; } - } - - private bool _frozen = false; - public bool IsFrozen { get { return _frozen; } } - - public MapSfixed64Sfixed64Entry() { - OnConstruction(); - } - - partial void OnConstruction(); - - public MapSfixed64Sfixed64Entry(MapSfixed64Sfixed64Entry other) : this() { - key_ = other.key_; - value_ = other.value_; - } - - public MapSfixed64Sfixed64Entry Clone() { - return new MapSfixed64Sfixed64Entry(this); - } - - public void Freeze() { - if (IsFrozen) { - return; - } - _frozen = true; - } - - public const int KeyFieldNumber = 1; - private long key_; - public long Key { - get { return key_; } - set { - pb::Freezable.CheckMutable(this); - key_ = value; - } - } - - public const int ValueFieldNumber = 2; - private long value_; - public long Value { - get { return value_; } - set { - pb::Freezable.CheckMutable(this); - value_ = value; - } - } - - public override bool Equals(object other) { - return Equals(other as MapSfixed64Sfixed64Entry); - } - - public bool Equals(MapSfixed64Sfixed64Entry other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (Key != other.Key) return false; - if (Value != other.Value) return false; - return true; - } - - public override int GetHashCode() { - int hash = 1; - if (Key != 0L) hash ^= Key.GetHashCode(); - if (Value != 0L) hash ^= Value.GetHashCode(); - return hash; - } - - public void WriteTo(pb::CodedOutputStream output) { - if (Key != 0L) { - output.WriteRawTag(9); - output.WriteSFixed64(Key); - } - if (Value != 0L) { - output.WriteRawTag(17); - output.WriteSFixed64(Value); - } - } - - public int CalculateSize() { - int size = 0; - if (Key != 0L) { - size += 1 + 8; - } - if (Value != 0L) { - size += 1 + 8; - } - return size; - } - - public void MergeFrom(MapSfixed64Sfixed64Entry other) { - if (other == null) { - return; - } - if (other.Key != 0L) { - Key = other.Key; - } - if (other.Value != 0L) { - Value = other.Value; - } - } - - public void MergeFrom(pb::CodedInputStream input) { - uint tag; - while (input.ReadTag(out tag)) { - switch(tag) { - case 0: - throw pb::InvalidProtocolBufferException.InvalidTag(); - default: - if (pb::WireFormat.IsEndGroupTag(tag)) { - return; - } - break; - case 9: { - Key = input.ReadSFixed64(); - break; - } - case 17: { - Value = input.ReadSFixed64(); - break; - } - } - } - } - - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class MapInt32FloatEntry : pb::IMessage<MapInt32FloatEntry> { - private static readonly pb::MessageParser<MapInt32FloatEntry> _parser = new pb::MessageParser<MapInt32FloatEntry>(() => new MapInt32FloatEntry()); - public static pb::MessageParser<MapInt32FloatEntry> Parser { get { return _parser; } } - - private static readonly string[] _fieldNames = new string[] { "key", "value" }; - private static readonly uint[] _fieldTags = new uint[] { 8, 21 }; - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.TestMap.Descriptor.NestedTypes[10]; } - } - - public pb::FieldAccess.FieldAccessorTable Fields { - get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestMap_MapInt32FloatEntry__FieldAccessorTable; } - } - - private bool _frozen = false; - public bool IsFrozen { get { return _frozen; } } - - public MapInt32FloatEntry() { - OnConstruction(); - } - - partial void OnConstruction(); - - public MapInt32FloatEntry(MapInt32FloatEntry other) : this() { - key_ = other.key_; - value_ = other.value_; - } - - public MapInt32FloatEntry Clone() { - return new MapInt32FloatEntry(this); - } - - public void Freeze() { - if (IsFrozen) { - return; - } - _frozen = true; - } - - public const int KeyFieldNumber = 1; - private int key_; - public int Key { - get { return key_; } - set { - pb::Freezable.CheckMutable(this); - key_ = value; - } - } - - public const int ValueFieldNumber = 2; - private float value_; - public float Value { - get { return value_; } - set { - pb::Freezable.CheckMutable(this); - value_ = value; - } - } - - public override bool Equals(object other) { - return Equals(other as MapInt32FloatEntry); - } - - public bool Equals(MapInt32FloatEntry other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (Key != other.Key) return false; - if (Value != other.Value) return false; - return true; - } - - public override int GetHashCode() { - int hash = 1; - if (Key != 0) hash ^= Key.GetHashCode(); - if (Value != 0F) hash ^= Value.GetHashCode(); - return hash; - } - - public void WriteTo(pb::CodedOutputStream output) { - if (Key != 0) { - output.WriteRawTag(8); - output.WriteInt32(Key); - } - if (Value != 0F) { - output.WriteRawTag(21); - output.WriteFloat(Value); - } - } - - public int CalculateSize() { - int size = 0; - if (Key != 0) { - size += 1 + pb::CodedOutputStream.ComputeInt32Size(Key); - } - if (Value != 0F) { - size += 1 + 4; - } - return size; - } - - public void MergeFrom(MapInt32FloatEntry other) { - if (other == null) { - return; - } - if (other.Key != 0) { - Key = other.Key; - } - if (other.Value != 0F) { - Value = other.Value; - } - } - - public void MergeFrom(pb::CodedInputStream input) { - uint tag; - while (input.ReadTag(out tag)) { - switch(tag) { - case 0: - throw pb::InvalidProtocolBufferException.InvalidTag(); - default: - if (pb::WireFormat.IsEndGroupTag(tag)) { - return; - } - break; - case 8: { - Key = input.ReadInt32(); - break; - } - case 21: { - Value = input.ReadFloat(); - break; - } - } - } - } - - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class MapInt32DoubleEntry : pb::IMessage<MapInt32DoubleEntry> { - private static readonly pb::MessageParser<MapInt32DoubleEntry> _parser = new pb::MessageParser<MapInt32DoubleEntry>(() => new MapInt32DoubleEntry()); - public static pb::MessageParser<MapInt32DoubleEntry> Parser { get { return _parser; } } - - private static readonly string[] _fieldNames = new string[] { "key", "value" }; - private static readonly uint[] _fieldTags = new uint[] { 8, 17 }; - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.TestMap.Descriptor.NestedTypes[11]; } - } - - public pb::FieldAccess.FieldAccessorTable Fields { - get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestMap_MapInt32DoubleEntry__FieldAccessorTable; } - } - - private bool _frozen = false; - public bool IsFrozen { get { return _frozen; } } - - public MapInt32DoubleEntry() { - OnConstruction(); - } - - partial void OnConstruction(); - - public MapInt32DoubleEntry(MapInt32DoubleEntry other) : this() { - key_ = other.key_; - value_ = other.value_; - } - - public MapInt32DoubleEntry Clone() { - return new MapInt32DoubleEntry(this); - } - - public void Freeze() { - if (IsFrozen) { - return; - } - _frozen = true; - } - - public const int KeyFieldNumber = 1; - private int key_; - public int Key { - get { return key_; } - set { - pb::Freezable.CheckMutable(this); - key_ = value; - } - } - - public const int ValueFieldNumber = 2; - private double value_; - public double Value { - get { return value_; } - set { - pb::Freezable.CheckMutable(this); - value_ = value; - } - } - - public override bool Equals(object other) { - return Equals(other as MapInt32DoubleEntry); - } - - public bool Equals(MapInt32DoubleEntry other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (Key != other.Key) return false; - if (Value != other.Value) return false; - return true; - } - - public override int GetHashCode() { - int hash = 1; - if (Key != 0) hash ^= Key.GetHashCode(); - if (Value != 0D) hash ^= Value.GetHashCode(); - return hash; - } - - public void WriteTo(pb::CodedOutputStream output) { - if (Key != 0) { - output.WriteRawTag(8); - output.WriteInt32(Key); - } - if (Value != 0D) { - output.WriteRawTag(17); - output.WriteDouble(Value); - } - } - - public int CalculateSize() { - int size = 0; - if (Key != 0) { - size += 1 + pb::CodedOutputStream.ComputeInt32Size(Key); - } - if (Value != 0D) { - size += 1 + 8; - } - return size; - } - - public void MergeFrom(MapInt32DoubleEntry other) { - if (other == null) { - return; - } - if (other.Key != 0) { - Key = other.Key; - } - if (other.Value != 0D) { - Value = other.Value; - } - } - - public void MergeFrom(pb::CodedInputStream input) { - uint tag; - while (input.ReadTag(out tag)) { - switch(tag) { - case 0: - throw pb::InvalidProtocolBufferException.InvalidTag(); - default: - if (pb::WireFormat.IsEndGroupTag(tag)) { - return; - } - break; - case 8: { - Key = input.ReadInt32(); - break; - } - case 17: { - Value = input.ReadDouble(); - break; - } - } - } - } - - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class MapBoolBoolEntry : pb::IMessage<MapBoolBoolEntry> { - private static readonly pb::MessageParser<MapBoolBoolEntry> _parser = new pb::MessageParser<MapBoolBoolEntry>(() => new MapBoolBoolEntry()); - public static pb::MessageParser<MapBoolBoolEntry> Parser { get { return _parser; } } - - private static readonly string[] _fieldNames = new string[] { "key", "value" }; - private static readonly uint[] _fieldTags = new uint[] { 8, 16 }; - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.TestMap.Descriptor.NestedTypes[12]; } - } - - public pb::FieldAccess.FieldAccessorTable Fields { - get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestMap_MapBoolBoolEntry__FieldAccessorTable; } - } - - private bool _frozen = false; - public bool IsFrozen { get { return _frozen; } } - - public MapBoolBoolEntry() { - OnConstruction(); - } - - partial void OnConstruction(); - - public MapBoolBoolEntry(MapBoolBoolEntry other) : this() { - key_ = other.key_; - value_ = other.value_; - } - - public MapBoolBoolEntry Clone() { - return new MapBoolBoolEntry(this); - } - - public void Freeze() { - if (IsFrozen) { - return; - } - _frozen = true; - } - - public const int KeyFieldNumber = 1; - private bool key_; - public bool Key { - get { return key_; } - set { - pb::Freezable.CheckMutable(this); - key_ = value; - } - } - - public const int ValueFieldNumber = 2; - private bool value_; - public bool Value { - get { return value_; } - set { - pb::Freezable.CheckMutable(this); - value_ = value; - } - } - - public override bool Equals(object other) { - return Equals(other as MapBoolBoolEntry); - } - - public bool Equals(MapBoolBoolEntry other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (Key != other.Key) return false; - if (Value != other.Value) return false; - return true; - } - - public override int GetHashCode() { - int hash = 1; - if (Key != false) hash ^= Key.GetHashCode(); - if (Value != false) hash ^= Value.GetHashCode(); - return hash; - } - - public void WriteTo(pb::CodedOutputStream output) { - if (Key != false) { - output.WriteRawTag(8); - output.WriteBool(Key); - } - if (Value != false) { - output.WriteRawTag(16); - output.WriteBool(Value); - } - } - - public int CalculateSize() { - int size = 0; - if (Key != false) { - size += 1 + 1; - } - if (Value != false) { - size += 1 + 1; - } - return size; - } - - public void MergeFrom(MapBoolBoolEntry other) { - if (other == null) { - return; - } - if (other.Key != false) { - Key = other.Key; - } - if (other.Value != false) { - Value = other.Value; - } - } - - public void MergeFrom(pb::CodedInputStream input) { - uint tag; - while (input.ReadTag(out tag)) { - switch(tag) { - case 0: - throw pb::InvalidProtocolBufferException.InvalidTag(); - default: - if (pb::WireFormat.IsEndGroupTag(tag)) { - return; - } - break; - case 8: { - Key = input.ReadBool(); - break; - } - case 16: { - Value = input.ReadBool(); - break; - } - } - } - } - - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class MapStringStringEntry : pb::IMessage<MapStringStringEntry> { - private static readonly pb::MessageParser<MapStringStringEntry> _parser = new pb::MessageParser<MapStringStringEntry>(() => new MapStringStringEntry()); - public static pb::MessageParser<MapStringStringEntry> Parser { get { return _parser; } } - - private static readonly string[] _fieldNames = new string[] { "key", "value" }; - private static readonly uint[] _fieldTags = new uint[] { 10, 18 }; - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.TestMap.Descriptor.NestedTypes[13]; } - } - - public pb::FieldAccess.FieldAccessorTable Fields { - get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestMap_MapStringStringEntry__FieldAccessorTable; } - } - - private bool _frozen = false; - public bool IsFrozen { get { return _frozen; } } - - public MapStringStringEntry() { - OnConstruction(); - } - - partial void OnConstruction(); - - public MapStringStringEntry(MapStringStringEntry other) : this() { - key_ = other.key_; - value_ = other.value_; - } - - public MapStringStringEntry Clone() { - return new MapStringStringEntry(this); - } - - public void Freeze() { - if (IsFrozen) { - return; - } - _frozen = true; - } - - public const int KeyFieldNumber = 1; - private string key_ = ""; - public string Key { - get { return key_; } - set { - pb::Freezable.CheckMutable(this); - key_ = value ?? ""; - } - } - - public const int ValueFieldNumber = 2; - private string value_ = ""; - public string Value { - get { return value_; } - set { - pb::Freezable.CheckMutable(this); - value_ = value ?? ""; - } - } - - public override bool Equals(object other) { - return Equals(other as MapStringStringEntry); - } - - public bool Equals(MapStringStringEntry other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (Key != other.Key) return false; - if (Value != other.Value) return false; - return true; - } - - public override int GetHashCode() { - int hash = 1; - if (Key.Length != 0) hash ^= Key.GetHashCode(); - if (Value.Length != 0) hash ^= Value.GetHashCode(); - return hash; - } - - public void WriteTo(pb::CodedOutputStream output) { - if (Key.Length != 0) { - output.WriteRawTag(10); - output.WriteString(Key); - } - if (Value.Length != 0) { - output.WriteRawTag(18); - output.WriteString(Value); - } - } - - public int CalculateSize() { - int size = 0; - if (Key.Length != 0) { - size += 1 + pb::CodedOutputStream.ComputeStringSize(Key); - } - if (Value.Length != 0) { - size += 1 + pb::CodedOutputStream.ComputeStringSize(Value); - } - return size; - } - - public void MergeFrom(MapStringStringEntry other) { - if (other == null) { - return; - } - if (other.Key.Length != 0) { - Key = other.Key; - } - if (other.Value.Length != 0) { - Value = other.Value; - } - } - - public void MergeFrom(pb::CodedInputStream input) { - uint tag; - while (input.ReadTag(out tag)) { - switch(tag) { - case 0: - throw pb::InvalidProtocolBufferException.InvalidTag(); - default: - if (pb::WireFormat.IsEndGroupTag(tag)) { - return; - } - break; - case 10: { - Key = input.ReadString(); - break; - } - case 18: { - Value = input.ReadString(); - break; - } - } - } - } - - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class MapInt32BytesEntry : pb::IMessage<MapInt32BytesEntry> { - private static readonly pb::MessageParser<MapInt32BytesEntry> _parser = new pb::MessageParser<MapInt32BytesEntry>(() => new MapInt32BytesEntry()); - public static pb::MessageParser<MapInt32BytesEntry> Parser { get { return _parser; } } - - private static readonly string[] _fieldNames = new string[] { "key", "value" }; - private static readonly uint[] _fieldTags = new uint[] { 8, 18 }; - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.TestMap.Descriptor.NestedTypes[14]; } - } - - public pb::FieldAccess.FieldAccessorTable Fields { - get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestMap_MapInt32BytesEntry__FieldAccessorTable; } - } - - private bool _frozen = false; - public bool IsFrozen { get { return _frozen; } } - - public MapInt32BytesEntry() { - OnConstruction(); - } - - partial void OnConstruction(); - - public MapInt32BytesEntry(MapInt32BytesEntry other) : this() { - key_ = other.key_; - value_ = other.value_; - } - - public MapInt32BytesEntry Clone() { - return new MapInt32BytesEntry(this); - } - - public void Freeze() { - if (IsFrozen) { - return; - } - _frozen = true; - } - - public const int KeyFieldNumber = 1; - private int key_; - public int Key { - get { return key_; } - set { - pb::Freezable.CheckMutable(this); - key_ = value; - } - } - - public const int ValueFieldNumber = 2; - private pb::ByteString value_ = pb::ByteString.Empty; - public pb::ByteString Value { - get { return value_; } - set { - pb::Freezable.CheckMutable(this); - value_ = value ?? pb::ByteString.Empty; - } - } - - public override bool Equals(object other) { - return Equals(other as MapInt32BytesEntry); - } - - public bool Equals(MapInt32BytesEntry other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (Key != other.Key) return false; - if (Value != other.Value) return false; - return true; - } - - public override int GetHashCode() { - int hash = 1; - if (Key != 0) hash ^= Key.GetHashCode(); - if (Value.Length != 0) hash ^= Value.GetHashCode(); - return hash; - } - - public void WriteTo(pb::CodedOutputStream output) { - if (Key != 0) { - output.WriteRawTag(8); - output.WriteInt32(Key); - } - if (Value.Length != 0) { - output.WriteRawTag(18); - output.WriteBytes(Value); - } - } - - public int CalculateSize() { - int size = 0; - if (Key != 0) { - size += 1 + pb::CodedOutputStream.ComputeInt32Size(Key); - } - if (Value.Length != 0) { - size += 1 + pb::CodedOutputStream.ComputeBytesSize(Value); - } - return size; - } - - public void MergeFrom(MapInt32BytesEntry other) { - if (other == null) { - return; - } - if (other.Key != 0) { - Key = other.Key; - } - if (other.Value.Length != 0) { - Value = other.Value; - } - } - - public void MergeFrom(pb::CodedInputStream input) { - uint tag; - while (input.ReadTag(out tag)) { - switch(tag) { - case 0: - throw pb::InvalidProtocolBufferException.InvalidTag(); - default: - if (pb::WireFormat.IsEndGroupTag(tag)) { - return; - } - break; - case 8: { - Key = input.ReadInt32(); - break; - } - case 18: { - Value = input.ReadBytes(); - break; - } - } - } - } - - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class MapInt32EnumEntry : pb::IMessage<MapInt32EnumEntry> { - private static readonly pb::MessageParser<MapInt32EnumEntry> _parser = new pb::MessageParser<MapInt32EnumEntry>(() => new MapInt32EnumEntry()); - public static pb::MessageParser<MapInt32EnumEntry> Parser { get { return _parser; } } - - private static readonly string[] _fieldNames = new string[] { "key", "value" }; - private static readonly uint[] _fieldTags = new uint[] { 8, 16 }; - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.TestMap.Descriptor.NestedTypes[15]; } - } - - public pb::FieldAccess.FieldAccessorTable Fields { - get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestMap_MapInt32EnumEntry__FieldAccessorTable; } - } - - private bool _frozen = false; - public bool IsFrozen { get { return _frozen; } } - - public MapInt32EnumEntry() { - OnConstruction(); - } - - partial void OnConstruction(); - - public MapInt32EnumEntry(MapInt32EnumEntry other) : this() { - key_ = other.key_; - value_ = other.value_; - } - - public MapInt32EnumEntry Clone() { - return new MapInt32EnumEntry(this); - } - - public void Freeze() { - if (IsFrozen) { - return; - } - _frozen = true; - } - - public const int KeyFieldNumber = 1; - private int key_; - public int Key { - get { return key_; } - set { - pb::Freezable.CheckMutable(this); - key_ = value; - } - } - - public const int ValueFieldNumber = 2; - private global::Google.Protobuf.TestProtos.MapEnum value_ = global::Google.Protobuf.TestProtos.MapEnum.MAP_ENUM_FOO; - public global::Google.Protobuf.TestProtos.MapEnum Value { - get { return value_; } - set { - pb::Freezable.CheckMutable(this); - value_ = value; - } - } - - public override bool Equals(object other) { - return Equals(other as MapInt32EnumEntry); - } - - public bool Equals(MapInt32EnumEntry other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (Key != other.Key) return false; - if (Value != other.Value) return false; - return true; - } - - public override int GetHashCode() { - int hash = 1; - if (Key != 0) hash ^= Key.GetHashCode(); - if (Value != global::Google.Protobuf.TestProtos.MapEnum.MAP_ENUM_FOO) hash ^= Value.GetHashCode(); - return hash; - } - - public void WriteTo(pb::CodedOutputStream output) { - if (Key != 0) { - output.WriteRawTag(8); - output.WriteInt32(Key); - } - if (Value != global::Google.Protobuf.TestProtos.MapEnum.MAP_ENUM_FOO) { - output.WriteRawTag(16); - output.WriteEnum((int) Value); - } - } - - public int CalculateSize() { - int size = 0; - if (Key != 0) { - size += 1 + pb::CodedOutputStream.ComputeInt32Size(Key); - } - if (Value != global::Google.Protobuf.TestProtos.MapEnum.MAP_ENUM_FOO) { - size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Value); - } - return size; - } - - public void MergeFrom(MapInt32EnumEntry other) { - if (other == null) { - return; - } - if (other.Key != 0) { - Key = other.Key; - } - if (other.Value != global::Google.Protobuf.TestProtos.MapEnum.MAP_ENUM_FOO) { - Value = other.Value; - } - } - - public void MergeFrom(pb::CodedInputStream input) { - uint tag; - while (input.ReadTag(out tag)) { - switch(tag) { - case 0: - throw pb::InvalidProtocolBufferException.InvalidTag(); - default: - if (pb::WireFormat.IsEndGroupTag(tag)) { - return; - } - break; - case 8: { - Key = input.ReadInt32(); - break; - } - case 16: { - value_ = (global::Google.Protobuf.TestProtos.MapEnum) input.ReadEnum(); - break; - } - } - } - } - - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class MapInt32ForeignMessageEntry : pb::IMessage<MapInt32ForeignMessageEntry> { - private static readonly pb::MessageParser<MapInt32ForeignMessageEntry> _parser = new pb::MessageParser<MapInt32ForeignMessageEntry>(() => new MapInt32ForeignMessageEntry()); - public static pb::MessageParser<MapInt32ForeignMessageEntry> Parser { get { return _parser; } } - - private static readonly string[] _fieldNames = new string[] { "key", "value" }; - private static readonly uint[] _fieldTags = new uint[] { 8, 18 }; - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.TestMap.Descriptor.NestedTypes[16]; } - } - - public pb::FieldAccess.FieldAccessorTable Fields { - get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestMap_MapInt32ForeignMessageEntry__FieldAccessorTable; } - } - - private bool _frozen = false; - public bool IsFrozen { get { return _frozen; } } - - public MapInt32ForeignMessageEntry() { - OnConstruction(); - } - - partial void OnConstruction(); - - public MapInt32ForeignMessageEntry(MapInt32ForeignMessageEntry other) : this() { - key_ = other.key_; - Value = other.value_ != null ? other.Value.Clone() : null; - } - - public MapInt32ForeignMessageEntry Clone() { - return new MapInt32ForeignMessageEntry(this); - } - - public void Freeze() { - if (IsFrozen) { - return; - } - _frozen = true; - if (value_ != null) Value.Freeze(); - } - - public const int KeyFieldNumber = 1; - private int key_; - public int Key { - get { return key_; } - set { - pb::Freezable.CheckMutable(this); - key_ = value; - } - } - - public const int ValueFieldNumber = 2; - private global::Google.Protobuf.TestProtos.ForeignMessage value_; - public global::Google.Protobuf.TestProtos.ForeignMessage Value { - get { return value_; } - set { - pb::Freezable.CheckMutable(this); - value_ = value; - } - } - - public override bool Equals(object other) { - return Equals(other as MapInt32ForeignMessageEntry); - } - - public bool Equals(MapInt32ForeignMessageEntry other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (Key != other.Key) return false; - if (!object.Equals(Value, other.Value)) return false; - return true; - } - - public override int GetHashCode() { - int hash = 1; - if (Key != 0) hash ^= Key.GetHashCode(); - if (value_ != null) hash ^= Value.GetHashCode(); - return hash; - } - - public void WriteTo(pb::CodedOutputStream output) { - if (Key != 0) { - output.WriteRawTag(8); - output.WriteInt32(Key); - } - if (value_ != null) { - output.WriteRawTag(18); - output.WriteMessage(Value); - } - } - - public int CalculateSize() { - int size = 0; - if (Key != 0) { - size += 1 + pb::CodedOutputStream.ComputeInt32Size(Key); - } - if (value_ != null) { - size += 1 + pb::CodedOutputStream.ComputeMessageSize(Value); - } - return size; - } - - public void MergeFrom(MapInt32ForeignMessageEntry other) { - if (other == null) { - return; - } - if (other.Key != 0) { - Key = other.Key; - } - if (other.value_ != null) { - if (value_ == null) { - value_ = new global::Google.Protobuf.TestProtos.ForeignMessage(); - } - Value.MergeFrom(other.Value); - } - } - - public void MergeFrom(pb::CodedInputStream input) { - uint tag; - while (input.ReadTag(out tag)) { - switch(tag) { - case 0: - throw pb::InvalidProtocolBufferException.InvalidTag(); - default: - if (pb::WireFormat.IsEndGroupTag(tag)) { - return; - } - break; - case 8: { - Key = input.ReadInt32(); - break; - } - case 18: { - if (value_ == null) { - value_ = new global::Google.Protobuf.TestProtos.ForeignMessage(); - } - input.ReadMessage(value_); - break; - } - } - } - } - - } - - } - #endregion - } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] @@ -3186,11 +615,11 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "test_map" }; private static readonly uint[] _fieldTags = new uint[] { 10 }; - public static pbd::MessageDescriptor Descriptor { + public static pbr::MessageDescriptor Descriptor { get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.Descriptor.MessageTypes[1]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestMapSubmessage__FieldAccessorTable; } } @@ -3250,6 +679,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (testMap_ != null) { output.WriteRawTag(10); @@ -3308,11 +741,11 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "map_int32_message" }; private static readonly uint[] _fieldTags = new uint[] { 10 }; - public static pbd::MessageDescriptor Descriptor { + public static pbr::MessageDescriptor Descriptor { get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.Descriptor.MessageTypes[2]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestMessageMap__FieldAccessorTable; } } @@ -3370,6 +803,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { mapInt32Message_.WriteTo(output, _map_mapInt32Message_codec); } @@ -3406,161 +843,6 @@ namespace Google.Protobuf.TestProtos { } } - #region Nested types - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public static partial class Types { - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class MapInt32MessageEntry : pb::IMessage<MapInt32MessageEntry> { - private static readonly pb::MessageParser<MapInt32MessageEntry> _parser = new pb::MessageParser<MapInt32MessageEntry>(() => new MapInt32MessageEntry()); - public static pb::MessageParser<MapInt32MessageEntry> Parser { get { return _parser; } } - - private static readonly string[] _fieldNames = new string[] { "key", "value" }; - private static readonly uint[] _fieldTags = new uint[] { 8, 18 }; - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.TestMessageMap.Descriptor.NestedTypes[0]; } - } - - public pb::FieldAccess.FieldAccessorTable Fields { - get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestMessageMap_MapInt32MessageEntry__FieldAccessorTable; } - } - - private bool _frozen = false; - public bool IsFrozen { get { return _frozen; } } - - public MapInt32MessageEntry() { - OnConstruction(); - } - - partial void OnConstruction(); - - public MapInt32MessageEntry(MapInt32MessageEntry other) : this() { - key_ = other.key_; - Value = other.value_ != null ? other.Value.Clone() : null; - } - - public MapInt32MessageEntry Clone() { - return new MapInt32MessageEntry(this); - } - - public void Freeze() { - if (IsFrozen) { - return; - } - _frozen = true; - if (value_ != null) Value.Freeze(); - } - - public const int KeyFieldNumber = 1; - private int key_; - public int Key { - get { return key_; } - set { - pb::Freezable.CheckMutable(this); - key_ = value; - } - } - - public const int ValueFieldNumber = 2; - private global::Google.Protobuf.TestProtos.TestAllTypes value_; - public global::Google.Protobuf.TestProtos.TestAllTypes Value { - get { return value_; } - set { - pb::Freezable.CheckMutable(this); - value_ = value; - } - } - - public override bool Equals(object other) { - return Equals(other as MapInt32MessageEntry); - } - - public bool Equals(MapInt32MessageEntry other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (Key != other.Key) return false; - if (!object.Equals(Value, other.Value)) return false; - return true; - } - - public override int GetHashCode() { - int hash = 1; - if (Key != 0) hash ^= Key.GetHashCode(); - if (value_ != null) hash ^= Value.GetHashCode(); - return hash; - } - - public void WriteTo(pb::CodedOutputStream output) { - if (Key != 0) { - output.WriteRawTag(8); - output.WriteInt32(Key); - } - if (value_ != null) { - output.WriteRawTag(18); - output.WriteMessage(Value); - } - } - - public int CalculateSize() { - int size = 0; - if (Key != 0) { - size += 1 + pb::CodedOutputStream.ComputeInt32Size(Key); - } - if (value_ != null) { - size += 1 + pb::CodedOutputStream.ComputeMessageSize(Value); - } - return size; - } - - public void MergeFrom(MapInt32MessageEntry other) { - if (other == null) { - return; - } - if (other.Key != 0) { - Key = other.Key; - } - if (other.value_ != null) { - if (value_ == null) { - value_ = new global::Google.Protobuf.TestProtos.TestAllTypes(); - } - Value.MergeFrom(other.Value); - } - } - - public void MergeFrom(pb::CodedInputStream input) { - uint tag; - while (input.ReadTag(out tag)) { - switch(tag) { - case 0: - throw pb::InvalidProtocolBufferException.InvalidTag(); - default: - if (pb::WireFormat.IsEndGroupTag(tag)) { - return; - } - break; - case 8: { - Key = input.ReadInt32(); - break; - } - case 18: { - if (value_ == null) { - value_ = new global::Google.Protobuf.TestProtos.TestAllTypes(); - } - input.ReadMessage(value_); - break; - } - } - } - } - - } - - } - #endregion - } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] @@ -3570,11 +852,11 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "map1", "map2" }; private static readonly uint[] _fieldTags = new uint[] { 10, 18 }; - public static pbd::MessageDescriptor Descriptor { + public static pbr::MessageDescriptor Descriptor { get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.Descriptor.MessageTypes[3]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestSameTypeMap__FieldAccessorTable; } } @@ -3644,6 +926,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { map1_.WriteTo(output, _map_map1_codec); map2_.WriteTo(output, _map_map2_codec); @@ -3687,296 +973,6 @@ namespace Google.Protobuf.TestProtos { } } - #region Nested types - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public static partial class Types { - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Map1Entry : pb::IMessage<Map1Entry> { - private static readonly pb::MessageParser<Map1Entry> _parser = new pb::MessageParser<Map1Entry>(() => new Map1Entry()); - public static pb::MessageParser<Map1Entry> Parser { get { return _parser; } } - - private static readonly string[] _fieldNames = new string[] { "key", "value" }; - private static readonly uint[] _fieldTags = new uint[] { 8, 16 }; - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.TestSameTypeMap.Descriptor.NestedTypes[0]; } - } - - public pb::FieldAccess.FieldAccessorTable Fields { - get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestSameTypeMap_Map1Entry__FieldAccessorTable; } - } - - private bool _frozen = false; - public bool IsFrozen { get { return _frozen; } } - - public Map1Entry() { - OnConstruction(); - } - - partial void OnConstruction(); - - public Map1Entry(Map1Entry other) : this() { - key_ = other.key_; - value_ = other.value_; - } - - public Map1Entry Clone() { - return new Map1Entry(this); - } - - public void Freeze() { - if (IsFrozen) { - return; - } - _frozen = true; - } - - public const int KeyFieldNumber = 1; - private int key_; - public int Key { - get { return key_; } - set { - pb::Freezable.CheckMutable(this); - key_ = value; - } - } - - public const int ValueFieldNumber = 2; - private int value_; - public int Value { - get { return value_; } - set { - pb::Freezable.CheckMutable(this); - value_ = value; - } - } - - public override bool Equals(object other) { - return Equals(other as Map1Entry); - } - - public bool Equals(Map1Entry other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (Key != other.Key) return false; - if (Value != other.Value) return false; - return true; - } - - public override int GetHashCode() { - int hash = 1; - if (Key != 0) hash ^= Key.GetHashCode(); - if (Value != 0) hash ^= Value.GetHashCode(); - return hash; - } - - public void WriteTo(pb::CodedOutputStream output) { - if (Key != 0) { - output.WriteRawTag(8); - output.WriteInt32(Key); - } - if (Value != 0) { - output.WriteRawTag(16); - output.WriteInt32(Value); - } - } - - public int CalculateSize() { - int size = 0; - if (Key != 0) { - size += 1 + pb::CodedOutputStream.ComputeInt32Size(Key); - } - if (Value != 0) { - size += 1 + pb::CodedOutputStream.ComputeInt32Size(Value); - } - return size; - } - - public void MergeFrom(Map1Entry other) { - if (other == null) { - return; - } - if (other.Key != 0) { - Key = other.Key; - } - if (other.Value != 0) { - Value = other.Value; - } - } - - public void MergeFrom(pb::CodedInputStream input) { - uint tag; - while (input.ReadTag(out tag)) { - switch(tag) { - case 0: - throw pb::InvalidProtocolBufferException.InvalidTag(); - default: - if (pb::WireFormat.IsEndGroupTag(tag)) { - return; - } - break; - case 8: { - Key = input.ReadInt32(); - break; - } - case 16: { - Value = input.ReadInt32(); - break; - } - } - } - } - - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Map2Entry : pb::IMessage<Map2Entry> { - private static readonly pb::MessageParser<Map2Entry> _parser = new pb::MessageParser<Map2Entry>(() => new Map2Entry()); - public static pb::MessageParser<Map2Entry> Parser { get { return _parser; } } - - private static readonly string[] _fieldNames = new string[] { "key", "value" }; - private static readonly uint[] _fieldTags = new uint[] { 8, 16 }; - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.TestSameTypeMap.Descriptor.NestedTypes[1]; } - } - - public pb::FieldAccess.FieldAccessorTable Fields { - get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestSameTypeMap_Map2Entry__FieldAccessorTable; } - } - - private bool _frozen = false; - public bool IsFrozen { get { return _frozen; } } - - public Map2Entry() { - OnConstruction(); - } - - partial void OnConstruction(); - - public Map2Entry(Map2Entry other) : this() { - key_ = other.key_; - value_ = other.value_; - } - - public Map2Entry Clone() { - return new Map2Entry(this); - } - - public void Freeze() { - if (IsFrozen) { - return; - } - _frozen = true; - } - - public const int KeyFieldNumber = 1; - private int key_; - public int Key { - get { return key_; } - set { - pb::Freezable.CheckMutable(this); - key_ = value; - } - } - - public const int ValueFieldNumber = 2; - private int value_; - public int Value { - get { return value_; } - set { - pb::Freezable.CheckMutable(this); - value_ = value; - } - } - - public override bool Equals(object other) { - return Equals(other as Map2Entry); - } - - public bool Equals(Map2Entry other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (Key != other.Key) return false; - if (Value != other.Value) return false; - return true; - } - - public override int GetHashCode() { - int hash = 1; - if (Key != 0) hash ^= Key.GetHashCode(); - if (Value != 0) hash ^= Value.GetHashCode(); - return hash; - } - - public void WriteTo(pb::CodedOutputStream output) { - if (Key != 0) { - output.WriteRawTag(8); - output.WriteInt32(Key); - } - if (Value != 0) { - output.WriteRawTag(16); - output.WriteInt32(Value); - } - } - - public int CalculateSize() { - int size = 0; - if (Key != 0) { - size += 1 + pb::CodedOutputStream.ComputeInt32Size(Key); - } - if (Value != 0) { - size += 1 + pb::CodedOutputStream.ComputeInt32Size(Value); - } - return size; - } - - public void MergeFrom(Map2Entry other) { - if (other == null) { - return; - } - if (other.Key != 0) { - Key = other.Key; - } - if (other.Value != 0) { - Value = other.Value; - } - } - - public void MergeFrom(pb::CodedInputStream input) { - uint tag; - while (input.ReadTag(out tag)) { - switch(tag) { - case 0: - throw pb::InvalidProtocolBufferException.InvalidTag(); - default: - if (pb::WireFormat.IsEndGroupTag(tag)) { - return; - } - break; - case 8: { - Key = input.ReadInt32(); - break; - } - case 16: { - Value = input.ReadInt32(); - break; - } - } - } - } - - } - - } - #endregion - } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] @@ -3986,11 +982,11 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "map_bool_bool", "map_fixed32_fixed32", "map_fixed64_fixed64", "map_int32_double", "map_int32_enum", "map_int32_float", "map_int32_foreign_message", "map_int32_int32", "map_int64_int64", "map_sfixed32_sfixed32", "map_sfixed64_sfixed64", "map_sint32_sint32", "map_sint64_sint64", "map_uint32_uint32", "map_uint64_uint64" }; private static readonly uint[] _fieldTags = new uint[] { 106, 58, 66, 98, 114, 90, 122, 10, 18, 74, 82, 42, 50, 26, 34 }; - public static pbd::MessageDescriptor Descriptor { + public static pbr::MessageDescriptor Descriptor { get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.Descriptor.MessageTypes[4]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestArenaMap__FieldAccessorTable; } } @@ -4216,6 +1212,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { mapInt32Int32_.WriteTo(output, _map_mapInt32Int32_codec); mapInt64Int64_.WriteTo(output, _map_mapInt64Int64_codec); @@ -4350,2149 +1350,6 @@ namespace Google.Protobuf.TestProtos { } } - #region Nested types - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public static partial class Types { - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class MapInt32Int32Entry : pb::IMessage<MapInt32Int32Entry> { - private static readonly pb::MessageParser<MapInt32Int32Entry> _parser = new pb::MessageParser<MapInt32Int32Entry>(() => new MapInt32Int32Entry()); - public static pb::MessageParser<MapInt32Int32Entry> Parser { get { return _parser; } } - - private static readonly string[] _fieldNames = new string[] { "key", "value" }; - private static readonly uint[] _fieldTags = new uint[] { 8, 16 }; - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.TestArenaMap.Descriptor.NestedTypes[0]; } - } - - public pb::FieldAccess.FieldAccessorTable Fields { - get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestArenaMap_MapInt32Int32Entry__FieldAccessorTable; } - } - - private bool _frozen = false; - public bool IsFrozen { get { return _frozen; } } - - public MapInt32Int32Entry() { - OnConstruction(); - } - - partial void OnConstruction(); - - public MapInt32Int32Entry(MapInt32Int32Entry other) : this() { - key_ = other.key_; - value_ = other.value_; - } - - public MapInt32Int32Entry Clone() { - return new MapInt32Int32Entry(this); - } - - public void Freeze() { - if (IsFrozen) { - return; - } - _frozen = true; - } - - public const int KeyFieldNumber = 1; - private int key_; - public int Key { - get { return key_; } - set { - pb::Freezable.CheckMutable(this); - key_ = value; - } - } - - public const int ValueFieldNumber = 2; - private int value_; - public int Value { - get { return value_; } - set { - pb::Freezable.CheckMutable(this); - value_ = value; - } - } - - public override bool Equals(object other) { - return Equals(other as MapInt32Int32Entry); - } - - public bool Equals(MapInt32Int32Entry other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (Key != other.Key) return false; - if (Value != other.Value) return false; - return true; - } - - public override int GetHashCode() { - int hash = 1; - if (Key != 0) hash ^= Key.GetHashCode(); - if (Value != 0) hash ^= Value.GetHashCode(); - return hash; - } - - public void WriteTo(pb::CodedOutputStream output) { - if (Key != 0) { - output.WriteRawTag(8); - output.WriteInt32(Key); - } - if (Value != 0) { - output.WriteRawTag(16); - output.WriteInt32(Value); - } - } - - public int CalculateSize() { - int size = 0; - if (Key != 0) { - size += 1 + pb::CodedOutputStream.ComputeInt32Size(Key); - } - if (Value != 0) { - size += 1 + pb::CodedOutputStream.ComputeInt32Size(Value); - } - return size; - } - - public void MergeFrom(MapInt32Int32Entry other) { - if (other == null) { - return; - } - if (other.Key != 0) { - Key = other.Key; - } - if (other.Value != 0) { - Value = other.Value; - } - } - - public void MergeFrom(pb::CodedInputStream input) { - uint tag; - while (input.ReadTag(out tag)) { - switch(tag) { - case 0: - throw pb::InvalidProtocolBufferException.InvalidTag(); - default: - if (pb::WireFormat.IsEndGroupTag(tag)) { - return; - } - break; - case 8: { - Key = input.ReadInt32(); - break; - } - case 16: { - Value = input.ReadInt32(); - break; - } - } - } - } - - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class MapInt64Int64Entry : pb::IMessage<MapInt64Int64Entry> { - private static readonly pb::MessageParser<MapInt64Int64Entry> _parser = new pb::MessageParser<MapInt64Int64Entry>(() => new MapInt64Int64Entry()); - public static pb::MessageParser<MapInt64Int64Entry> Parser { get { return _parser; } } - - private static readonly string[] _fieldNames = new string[] { "key", "value" }; - private static readonly uint[] _fieldTags = new uint[] { 8, 16 }; - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.TestArenaMap.Descriptor.NestedTypes[1]; } - } - - public pb::FieldAccess.FieldAccessorTable Fields { - get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestArenaMap_MapInt64Int64Entry__FieldAccessorTable; } - } - - private bool _frozen = false; - public bool IsFrozen { get { return _frozen; } } - - public MapInt64Int64Entry() { - OnConstruction(); - } - - partial void OnConstruction(); - - public MapInt64Int64Entry(MapInt64Int64Entry other) : this() { - key_ = other.key_; - value_ = other.value_; - } - - public MapInt64Int64Entry Clone() { - return new MapInt64Int64Entry(this); - } - - public void Freeze() { - if (IsFrozen) { - return; - } - _frozen = true; - } - - public const int KeyFieldNumber = 1; - private long key_; - public long Key { - get { return key_; } - set { - pb::Freezable.CheckMutable(this); - key_ = value; - } - } - - public const int ValueFieldNumber = 2; - private long value_; - public long Value { - get { return value_; } - set { - pb::Freezable.CheckMutable(this); - value_ = value; - } - } - - public override bool Equals(object other) { - return Equals(other as MapInt64Int64Entry); - } - - public bool Equals(MapInt64Int64Entry other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (Key != other.Key) return false; - if (Value != other.Value) return false; - return true; - } - - public override int GetHashCode() { - int hash = 1; - if (Key != 0L) hash ^= Key.GetHashCode(); - if (Value != 0L) hash ^= Value.GetHashCode(); - return hash; - } - - public void WriteTo(pb::CodedOutputStream output) { - if (Key != 0L) { - output.WriteRawTag(8); - output.WriteInt64(Key); - } - if (Value != 0L) { - output.WriteRawTag(16); - output.WriteInt64(Value); - } - } - - public int CalculateSize() { - int size = 0; - if (Key != 0L) { - size += 1 + pb::CodedOutputStream.ComputeInt64Size(Key); - } - if (Value != 0L) { - size += 1 + pb::CodedOutputStream.ComputeInt64Size(Value); - } - return size; - } - - public void MergeFrom(MapInt64Int64Entry other) { - if (other == null) { - return; - } - if (other.Key != 0L) { - Key = other.Key; - } - if (other.Value != 0L) { - Value = other.Value; - } - } - - public void MergeFrom(pb::CodedInputStream input) { - uint tag; - while (input.ReadTag(out tag)) { - switch(tag) { - case 0: - throw pb::InvalidProtocolBufferException.InvalidTag(); - default: - if (pb::WireFormat.IsEndGroupTag(tag)) { - return; - } - break; - case 8: { - Key = input.ReadInt64(); - break; - } - case 16: { - Value = input.ReadInt64(); - break; - } - } - } - } - - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class MapUint32Uint32Entry : pb::IMessage<MapUint32Uint32Entry> { - private static readonly pb::MessageParser<MapUint32Uint32Entry> _parser = new pb::MessageParser<MapUint32Uint32Entry>(() => new MapUint32Uint32Entry()); - public static pb::MessageParser<MapUint32Uint32Entry> Parser { get { return _parser; } } - - private static readonly string[] _fieldNames = new string[] { "key", "value" }; - private static readonly uint[] _fieldTags = new uint[] { 8, 16 }; - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.TestArenaMap.Descriptor.NestedTypes[2]; } - } - - public pb::FieldAccess.FieldAccessorTable Fields { - get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestArenaMap_MapUint32Uint32Entry__FieldAccessorTable; } - } - - private bool _frozen = false; - public bool IsFrozen { get { return _frozen; } } - - public MapUint32Uint32Entry() { - OnConstruction(); - } - - partial void OnConstruction(); - - public MapUint32Uint32Entry(MapUint32Uint32Entry other) : this() { - key_ = other.key_; - value_ = other.value_; - } - - public MapUint32Uint32Entry Clone() { - return new MapUint32Uint32Entry(this); - } - - public void Freeze() { - if (IsFrozen) { - return; - } - _frozen = true; - } - - public const int KeyFieldNumber = 1; - private uint key_; - public uint Key { - get { return key_; } - set { - pb::Freezable.CheckMutable(this); - key_ = value; - } - } - - public const int ValueFieldNumber = 2; - private uint value_; - public uint Value { - get { return value_; } - set { - pb::Freezable.CheckMutable(this); - value_ = value; - } - } - - public override bool Equals(object other) { - return Equals(other as MapUint32Uint32Entry); - } - - public bool Equals(MapUint32Uint32Entry other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (Key != other.Key) return false; - if (Value != other.Value) return false; - return true; - } - - public override int GetHashCode() { - int hash = 1; - if (Key != 0) hash ^= Key.GetHashCode(); - if (Value != 0) hash ^= Value.GetHashCode(); - return hash; - } - - public void WriteTo(pb::CodedOutputStream output) { - if (Key != 0) { - output.WriteRawTag(8); - output.WriteUInt32(Key); - } - if (Value != 0) { - output.WriteRawTag(16); - output.WriteUInt32(Value); - } - } - - public int CalculateSize() { - int size = 0; - if (Key != 0) { - size += 1 + pb::CodedOutputStream.ComputeUInt32Size(Key); - } - if (Value != 0) { - size += 1 + pb::CodedOutputStream.ComputeUInt32Size(Value); - } - return size; - } - - public void MergeFrom(MapUint32Uint32Entry other) { - if (other == null) { - return; - } - if (other.Key != 0) { - Key = other.Key; - } - if (other.Value != 0) { - Value = other.Value; - } - } - - public void MergeFrom(pb::CodedInputStream input) { - uint tag; - while (input.ReadTag(out tag)) { - switch(tag) { - case 0: - throw pb::InvalidProtocolBufferException.InvalidTag(); - default: - if (pb::WireFormat.IsEndGroupTag(tag)) { - return; - } - break; - case 8: { - Key = input.ReadUInt32(); - break; - } - case 16: { - Value = input.ReadUInt32(); - break; - } - } - } - } - - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class MapUint64Uint64Entry : pb::IMessage<MapUint64Uint64Entry> { - private static readonly pb::MessageParser<MapUint64Uint64Entry> _parser = new pb::MessageParser<MapUint64Uint64Entry>(() => new MapUint64Uint64Entry()); - public static pb::MessageParser<MapUint64Uint64Entry> Parser { get { return _parser; } } - - private static readonly string[] _fieldNames = new string[] { "key", "value" }; - private static readonly uint[] _fieldTags = new uint[] { 8, 16 }; - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.TestArenaMap.Descriptor.NestedTypes[3]; } - } - - public pb::FieldAccess.FieldAccessorTable Fields { - get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestArenaMap_MapUint64Uint64Entry__FieldAccessorTable; } - } - - private bool _frozen = false; - public bool IsFrozen { get { return _frozen; } } - - public MapUint64Uint64Entry() { - OnConstruction(); - } - - partial void OnConstruction(); - - public MapUint64Uint64Entry(MapUint64Uint64Entry other) : this() { - key_ = other.key_; - value_ = other.value_; - } - - public MapUint64Uint64Entry Clone() { - return new MapUint64Uint64Entry(this); - } - - public void Freeze() { - if (IsFrozen) { - return; - } - _frozen = true; - } - - public const int KeyFieldNumber = 1; - private ulong key_; - public ulong Key { - get { return key_; } - set { - pb::Freezable.CheckMutable(this); - key_ = value; - } - } - - public const int ValueFieldNumber = 2; - private ulong value_; - public ulong Value { - get { return value_; } - set { - pb::Freezable.CheckMutable(this); - value_ = value; - } - } - - public override bool Equals(object other) { - return Equals(other as MapUint64Uint64Entry); - } - - public bool Equals(MapUint64Uint64Entry other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (Key != other.Key) return false; - if (Value != other.Value) return false; - return true; - } - - public override int GetHashCode() { - int hash = 1; - if (Key != 0UL) hash ^= Key.GetHashCode(); - if (Value != 0UL) hash ^= Value.GetHashCode(); - return hash; - } - - public void WriteTo(pb::CodedOutputStream output) { - if (Key != 0UL) { - output.WriteRawTag(8); - output.WriteUInt64(Key); - } - if (Value != 0UL) { - output.WriteRawTag(16); - output.WriteUInt64(Value); - } - } - - public int CalculateSize() { - int size = 0; - if (Key != 0UL) { - size += 1 + pb::CodedOutputStream.ComputeUInt64Size(Key); - } - if (Value != 0UL) { - size += 1 + pb::CodedOutputStream.ComputeUInt64Size(Value); - } - return size; - } - - public void MergeFrom(MapUint64Uint64Entry other) { - if (other == null) { - return; - } - if (other.Key != 0UL) { - Key = other.Key; - } - if (other.Value != 0UL) { - Value = other.Value; - } - } - - public void MergeFrom(pb::CodedInputStream input) { - uint tag; - while (input.ReadTag(out tag)) { - switch(tag) { - case 0: - throw pb::InvalidProtocolBufferException.InvalidTag(); - default: - if (pb::WireFormat.IsEndGroupTag(tag)) { - return; - } - break; - case 8: { - Key = input.ReadUInt64(); - break; - } - case 16: { - Value = input.ReadUInt64(); - break; - } - } - } - } - - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class MapSint32Sint32Entry : pb::IMessage<MapSint32Sint32Entry> { - private static readonly pb::MessageParser<MapSint32Sint32Entry> _parser = new pb::MessageParser<MapSint32Sint32Entry>(() => new MapSint32Sint32Entry()); - public static pb::MessageParser<MapSint32Sint32Entry> Parser { get { return _parser; } } - - private static readonly string[] _fieldNames = new string[] { "key", "value" }; - private static readonly uint[] _fieldTags = new uint[] { 8, 16 }; - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.TestArenaMap.Descriptor.NestedTypes[4]; } - } - - public pb::FieldAccess.FieldAccessorTable Fields { - get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestArenaMap_MapSint32Sint32Entry__FieldAccessorTable; } - } - - private bool _frozen = false; - public bool IsFrozen { get { return _frozen; } } - - public MapSint32Sint32Entry() { - OnConstruction(); - } - - partial void OnConstruction(); - - public MapSint32Sint32Entry(MapSint32Sint32Entry other) : this() { - key_ = other.key_; - value_ = other.value_; - } - - public MapSint32Sint32Entry Clone() { - return new MapSint32Sint32Entry(this); - } - - public void Freeze() { - if (IsFrozen) { - return; - } - _frozen = true; - } - - public const int KeyFieldNumber = 1; - private int key_; - public int Key { - get { return key_; } - set { - pb::Freezable.CheckMutable(this); - key_ = value; - } - } - - public const int ValueFieldNumber = 2; - private int value_; - public int Value { - get { return value_; } - set { - pb::Freezable.CheckMutable(this); - value_ = value; - } - } - - public override bool Equals(object other) { - return Equals(other as MapSint32Sint32Entry); - } - - public bool Equals(MapSint32Sint32Entry other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (Key != other.Key) return false; - if (Value != other.Value) return false; - return true; - } - - public override int GetHashCode() { - int hash = 1; - if (Key != 0) hash ^= Key.GetHashCode(); - if (Value != 0) hash ^= Value.GetHashCode(); - return hash; - } - - public void WriteTo(pb::CodedOutputStream output) { - if (Key != 0) { - output.WriteRawTag(8); - output.WriteSInt32(Key); - } - if (Value != 0) { - output.WriteRawTag(16); - output.WriteSInt32(Value); - } - } - - public int CalculateSize() { - int size = 0; - if (Key != 0) { - size += 1 + pb::CodedOutputStream.ComputeSInt32Size(Key); - } - if (Value != 0) { - size += 1 + pb::CodedOutputStream.ComputeSInt32Size(Value); - } - return size; - } - - public void MergeFrom(MapSint32Sint32Entry other) { - if (other == null) { - return; - } - if (other.Key != 0) { - Key = other.Key; - } - if (other.Value != 0) { - Value = other.Value; - } - } - - public void MergeFrom(pb::CodedInputStream input) { - uint tag; - while (input.ReadTag(out tag)) { - switch(tag) { - case 0: - throw pb::InvalidProtocolBufferException.InvalidTag(); - default: - if (pb::WireFormat.IsEndGroupTag(tag)) { - return; - } - break; - case 8: { - Key = input.ReadSInt32(); - break; - } - case 16: { - Value = input.ReadSInt32(); - break; - } - } - } - } - - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class MapSint64Sint64Entry : pb::IMessage<MapSint64Sint64Entry> { - private static readonly pb::MessageParser<MapSint64Sint64Entry> _parser = new pb::MessageParser<MapSint64Sint64Entry>(() => new MapSint64Sint64Entry()); - public static pb::MessageParser<MapSint64Sint64Entry> Parser { get { return _parser; } } - - private static readonly string[] _fieldNames = new string[] { "key", "value" }; - private static readonly uint[] _fieldTags = new uint[] { 8, 16 }; - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.TestArenaMap.Descriptor.NestedTypes[5]; } - } - - public pb::FieldAccess.FieldAccessorTable Fields { - get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestArenaMap_MapSint64Sint64Entry__FieldAccessorTable; } - } - - private bool _frozen = false; - public bool IsFrozen { get { return _frozen; } } - - public MapSint64Sint64Entry() { - OnConstruction(); - } - - partial void OnConstruction(); - - public MapSint64Sint64Entry(MapSint64Sint64Entry other) : this() { - key_ = other.key_; - value_ = other.value_; - } - - public MapSint64Sint64Entry Clone() { - return new MapSint64Sint64Entry(this); - } - - public void Freeze() { - if (IsFrozen) { - return; - } - _frozen = true; - } - - public const int KeyFieldNumber = 1; - private long key_; - public long Key { - get { return key_; } - set { - pb::Freezable.CheckMutable(this); - key_ = value; - } - } - - public const int ValueFieldNumber = 2; - private long value_; - public long Value { - get { return value_; } - set { - pb::Freezable.CheckMutable(this); - value_ = value; - } - } - - public override bool Equals(object other) { - return Equals(other as MapSint64Sint64Entry); - } - - public bool Equals(MapSint64Sint64Entry other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (Key != other.Key) return false; - if (Value != other.Value) return false; - return true; - } - - public override int GetHashCode() { - int hash = 1; - if (Key != 0L) hash ^= Key.GetHashCode(); - if (Value != 0L) hash ^= Value.GetHashCode(); - return hash; - } - - public void WriteTo(pb::CodedOutputStream output) { - if (Key != 0L) { - output.WriteRawTag(8); - output.WriteSInt64(Key); - } - if (Value != 0L) { - output.WriteRawTag(16); - output.WriteSInt64(Value); - } - } - - public int CalculateSize() { - int size = 0; - if (Key != 0L) { - size += 1 + pb::CodedOutputStream.ComputeSInt64Size(Key); - } - if (Value != 0L) { - size += 1 + pb::CodedOutputStream.ComputeSInt64Size(Value); - } - return size; - } - - public void MergeFrom(MapSint64Sint64Entry other) { - if (other == null) { - return; - } - if (other.Key != 0L) { - Key = other.Key; - } - if (other.Value != 0L) { - Value = other.Value; - } - } - - public void MergeFrom(pb::CodedInputStream input) { - uint tag; - while (input.ReadTag(out tag)) { - switch(tag) { - case 0: - throw pb::InvalidProtocolBufferException.InvalidTag(); - default: - if (pb::WireFormat.IsEndGroupTag(tag)) { - return; - } - break; - case 8: { - Key = input.ReadSInt64(); - break; - } - case 16: { - Value = input.ReadSInt64(); - break; - } - } - } - } - - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class MapFixed32Fixed32Entry : pb::IMessage<MapFixed32Fixed32Entry> { - private static readonly pb::MessageParser<MapFixed32Fixed32Entry> _parser = new pb::MessageParser<MapFixed32Fixed32Entry>(() => new MapFixed32Fixed32Entry()); - public static pb::MessageParser<MapFixed32Fixed32Entry> Parser { get { return _parser; } } - - private static readonly string[] _fieldNames = new string[] { "key", "value" }; - private static readonly uint[] _fieldTags = new uint[] { 13, 21 }; - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.TestArenaMap.Descriptor.NestedTypes[6]; } - } - - public pb::FieldAccess.FieldAccessorTable Fields { - get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestArenaMap_MapFixed32Fixed32Entry__FieldAccessorTable; } - } - - private bool _frozen = false; - public bool IsFrozen { get { return _frozen; } } - - public MapFixed32Fixed32Entry() { - OnConstruction(); - } - - partial void OnConstruction(); - - public MapFixed32Fixed32Entry(MapFixed32Fixed32Entry other) : this() { - key_ = other.key_; - value_ = other.value_; - } - - public MapFixed32Fixed32Entry Clone() { - return new MapFixed32Fixed32Entry(this); - } - - public void Freeze() { - if (IsFrozen) { - return; - } - _frozen = true; - } - - public const int KeyFieldNumber = 1; - private uint key_; - public uint Key { - get { return key_; } - set { - pb::Freezable.CheckMutable(this); - key_ = value; - } - } - - public const int ValueFieldNumber = 2; - private uint value_; - public uint Value { - get { return value_; } - set { - pb::Freezable.CheckMutable(this); - value_ = value; - } - } - - public override bool Equals(object other) { - return Equals(other as MapFixed32Fixed32Entry); - } - - public bool Equals(MapFixed32Fixed32Entry other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (Key != other.Key) return false; - if (Value != other.Value) return false; - return true; - } - - public override int GetHashCode() { - int hash = 1; - if (Key != 0) hash ^= Key.GetHashCode(); - if (Value != 0) hash ^= Value.GetHashCode(); - return hash; - } - - public void WriteTo(pb::CodedOutputStream output) { - if (Key != 0) { - output.WriteRawTag(13); - output.WriteFixed32(Key); - } - if (Value != 0) { - output.WriteRawTag(21); - output.WriteFixed32(Value); - } - } - - public int CalculateSize() { - int size = 0; - if (Key != 0) { - size += 1 + 4; - } - if (Value != 0) { - size += 1 + 4; - } - return size; - } - - public void MergeFrom(MapFixed32Fixed32Entry other) { - if (other == null) { - return; - } - if (other.Key != 0) { - Key = other.Key; - } - if (other.Value != 0) { - Value = other.Value; - } - } - - public void MergeFrom(pb::CodedInputStream input) { - uint tag; - while (input.ReadTag(out tag)) { - switch(tag) { - case 0: - throw pb::InvalidProtocolBufferException.InvalidTag(); - default: - if (pb::WireFormat.IsEndGroupTag(tag)) { - return; - } - break; - case 13: { - Key = input.ReadFixed32(); - break; - } - case 21: { - Value = input.ReadFixed32(); - break; - } - } - } - } - - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class MapFixed64Fixed64Entry : pb::IMessage<MapFixed64Fixed64Entry> { - private static readonly pb::MessageParser<MapFixed64Fixed64Entry> _parser = new pb::MessageParser<MapFixed64Fixed64Entry>(() => new MapFixed64Fixed64Entry()); - public static pb::MessageParser<MapFixed64Fixed64Entry> Parser { get { return _parser; } } - - private static readonly string[] _fieldNames = new string[] { "key", "value" }; - private static readonly uint[] _fieldTags = new uint[] { 9, 17 }; - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.TestArenaMap.Descriptor.NestedTypes[7]; } - } - - public pb::FieldAccess.FieldAccessorTable Fields { - get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestArenaMap_MapFixed64Fixed64Entry__FieldAccessorTable; } - } - - private bool _frozen = false; - public bool IsFrozen { get { return _frozen; } } - - public MapFixed64Fixed64Entry() { - OnConstruction(); - } - - partial void OnConstruction(); - - public MapFixed64Fixed64Entry(MapFixed64Fixed64Entry other) : this() { - key_ = other.key_; - value_ = other.value_; - } - - public MapFixed64Fixed64Entry Clone() { - return new MapFixed64Fixed64Entry(this); - } - - public void Freeze() { - if (IsFrozen) { - return; - } - _frozen = true; - } - - public const int KeyFieldNumber = 1; - private ulong key_; - public ulong Key { - get { return key_; } - set { - pb::Freezable.CheckMutable(this); - key_ = value; - } - } - - public const int ValueFieldNumber = 2; - private ulong value_; - public ulong Value { - get { return value_; } - set { - pb::Freezable.CheckMutable(this); - value_ = value; - } - } - - public override bool Equals(object other) { - return Equals(other as MapFixed64Fixed64Entry); - } - - public bool Equals(MapFixed64Fixed64Entry other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (Key != other.Key) return false; - if (Value != other.Value) return false; - return true; - } - - public override int GetHashCode() { - int hash = 1; - if (Key != 0UL) hash ^= Key.GetHashCode(); - if (Value != 0UL) hash ^= Value.GetHashCode(); - return hash; - } - - public void WriteTo(pb::CodedOutputStream output) { - if (Key != 0UL) { - output.WriteRawTag(9); - output.WriteFixed64(Key); - } - if (Value != 0UL) { - output.WriteRawTag(17); - output.WriteFixed64(Value); - } - } - - public int CalculateSize() { - int size = 0; - if (Key != 0UL) { - size += 1 + 8; - } - if (Value != 0UL) { - size += 1 + 8; - } - return size; - } - - public void MergeFrom(MapFixed64Fixed64Entry other) { - if (other == null) { - return; - } - if (other.Key != 0UL) { - Key = other.Key; - } - if (other.Value != 0UL) { - Value = other.Value; - } - } - - public void MergeFrom(pb::CodedInputStream input) { - uint tag; - while (input.ReadTag(out tag)) { - switch(tag) { - case 0: - throw pb::InvalidProtocolBufferException.InvalidTag(); - default: - if (pb::WireFormat.IsEndGroupTag(tag)) { - return; - } - break; - case 9: { - Key = input.ReadFixed64(); - break; - } - case 17: { - Value = input.ReadFixed64(); - break; - } - } - } - } - - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class MapSfixed32Sfixed32Entry : pb::IMessage<MapSfixed32Sfixed32Entry> { - private static readonly pb::MessageParser<MapSfixed32Sfixed32Entry> _parser = new pb::MessageParser<MapSfixed32Sfixed32Entry>(() => new MapSfixed32Sfixed32Entry()); - public static pb::MessageParser<MapSfixed32Sfixed32Entry> Parser { get { return _parser; } } - - private static readonly string[] _fieldNames = new string[] { "key", "value" }; - private static readonly uint[] _fieldTags = new uint[] { 13, 21 }; - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.TestArenaMap.Descriptor.NestedTypes[8]; } - } - - public pb::FieldAccess.FieldAccessorTable Fields { - get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestArenaMap_MapSfixed32Sfixed32Entry__FieldAccessorTable; } - } - - private bool _frozen = false; - public bool IsFrozen { get { return _frozen; } } - - public MapSfixed32Sfixed32Entry() { - OnConstruction(); - } - - partial void OnConstruction(); - - public MapSfixed32Sfixed32Entry(MapSfixed32Sfixed32Entry other) : this() { - key_ = other.key_; - value_ = other.value_; - } - - public MapSfixed32Sfixed32Entry Clone() { - return new MapSfixed32Sfixed32Entry(this); - } - - public void Freeze() { - if (IsFrozen) { - return; - } - _frozen = true; - } - - public const int KeyFieldNumber = 1; - private int key_; - public int Key { - get { return key_; } - set { - pb::Freezable.CheckMutable(this); - key_ = value; - } - } - - public const int ValueFieldNumber = 2; - private int value_; - public int Value { - get { return value_; } - set { - pb::Freezable.CheckMutable(this); - value_ = value; - } - } - - public override bool Equals(object other) { - return Equals(other as MapSfixed32Sfixed32Entry); - } - - public bool Equals(MapSfixed32Sfixed32Entry other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (Key != other.Key) return false; - if (Value != other.Value) return false; - return true; - } - - public override int GetHashCode() { - int hash = 1; - if (Key != 0) hash ^= Key.GetHashCode(); - if (Value != 0) hash ^= Value.GetHashCode(); - return hash; - } - - public void WriteTo(pb::CodedOutputStream output) { - if (Key != 0) { - output.WriteRawTag(13); - output.WriteSFixed32(Key); - } - if (Value != 0) { - output.WriteRawTag(21); - output.WriteSFixed32(Value); - } - } - - public int CalculateSize() { - int size = 0; - if (Key != 0) { - size += 1 + 4; - } - if (Value != 0) { - size += 1 + 4; - } - return size; - } - - public void MergeFrom(MapSfixed32Sfixed32Entry other) { - if (other == null) { - return; - } - if (other.Key != 0) { - Key = other.Key; - } - if (other.Value != 0) { - Value = other.Value; - } - } - - public void MergeFrom(pb::CodedInputStream input) { - uint tag; - while (input.ReadTag(out tag)) { - switch(tag) { - case 0: - throw pb::InvalidProtocolBufferException.InvalidTag(); - default: - if (pb::WireFormat.IsEndGroupTag(tag)) { - return; - } - break; - case 13: { - Key = input.ReadSFixed32(); - break; - } - case 21: { - Value = input.ReadSFixed32(); - break; - } - } - } - } - - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class MapSfixed64Sfixed64Entry : pb::IMessage<MapSfixed64Sfixed64Entry> { - private static readonly pb::MessageParser<MapSfixed64Sfixed64Entry> _parser = new pb::MessageParser<MapSfixed64Sfixed64Entry>(() => new MapSfixed64Sfixed64Entry()); - public static pb::MessageParser<MapSfixed64Sfixed64Entry> Parser { get { return _parser; } } - - private static readonly string[] _fieldNames = new string[] { "key", "value" }; - private static readonly uint[] _fieldTags = new uint[] { 9, 17 }; - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.TestArenaMap.Descriptor.NestedTypes[9]; } - } - - public pb::FieldAccess.FieldAccessorTable Fields { - get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestArenaMap_MapSfixed64Sfixed64Entry__FieldAccessorTable; } - } - - private bool _frozen = false; - public bool IsFrozen { get { return _frozen; } } - - public MapSfixed64Sfixed64Entry() { - OnConstruction(); - } - - partial void OnConstruction(); - - public MapSfixed64Sfixed64Entry(MapSfixed64Sfixed64Entry other) : this() { - key_ = other.key_; - value_ = other.value_; - } - - public MapSfixed64Sfixed64Entry Clone() { - return new MapSfixed64Sfixed64Entry(this); - } - - public void Freeze() { - if (IsFrozen) { - return; - } - _frozen = true; - } - - public const int KeyFieldNumber = 1; - private long key_; - public long Key { - get { return key_; } - set { - pb::Freezable.CheckMutable(this); - key_ = value; - } - } - - public const int ValueFieldNumber = 2; - private long value_; - public long Value { - get { return value_; } - set { - pb::Freezable.CheckMutable(this); - value_ = value; - } - } - - public override bool Equals(object other) { - return Equals(other as MapSfixed64Sfixed64Entry); - } - - public bool Equals(MapSfixed64Sfixed64Entry other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (Key != other.Key) return false; - if (Value != other.Value) return false; - return true; - } - - public override int GetHashCode() { - int hash = 1; - if (Key != 0L) hash ^= Key.GetHashCode(); - if (Value != 0L) hash ^= Value.GetHashCode(); - return hash; - } - - public void WriteTo(pb::CodedOutputStream output) { - if (Key != 0L) { - output.WriteRawTag(9); - output.WriteSFixed64(Key); - } - if (Value != 0L) { - output.WriteRawTag(17); - output.WriteSFixed64(Value); - } - } - - public int CalculateSize() { - int size = 0; - if (Key != 0L) { - size += 1 + 8; - } - if (Value != 0L) { - size += 1 + 8; - } - return size; - } - - public void MergeFrom(MapSfixed64Sfixed64Entry other) { - if (other == null) { - return; - } - if (other.Key != 0L) { - Key = other.Key; - } - if (other.Value != 0L) { - Value = other.Value; - } - } - - public void MergeFrom(pb::CodedInputStream input) { - uint tag; - while (input.ReadTag(out tag)) { - switch(tag) { - case 0: - throw pb::InvalidProtocolBufferException.InvalidTag(); - default: - if (pb::WireFormat.IsEndGroupTag(tag)) { - return; - } - break; - case 9: { - Key = input.ReadSFixed64(); - break; - } - case 17: { - Value = input.ReadSFixed64(); - break; - } - } - } - } - - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class MapInt32FloatEntry : pb::IMessage<MapInt32FloatEntry> { - private static readonly pb::MessageParser<MapInt32FloatEntry> _parser = new pb::MessageParser<MapInt32FloatEntry>(() => new MapInt32FloatEntry()); - public static pb::MessageParser<MapInt32FloatEntry> Parser { get { return _parser; } } - - private static readonly string[] _fieldNames = new string[] { "key", "value" }; - private static readonly uint[] _fieldTags = new uint[] { 8, 21 }; - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.TestArenaMap.Descriptor.NestedTypes[10]; } - } - - public pb::FieldAccess.FieldAccessorTable Fields { - get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestArenaMap_MapInt32FloatEntry__FieldAccessorTable; } - } - - private bool _frozen = false; - public bool IsFrozen { get { return _frozen; } } - - public MapInt32FloatEntry() { - OnConstruction(); - } - - partial void OnConstruction(); - - public MapInt32FloatEntry(MapInt32FloatEntry other) : this() { - key_ = other.key_; - value_ = other.value_; - } - - public MapInt32FloatEntry Clone() { - return new MapInt32FloatEntry(this); - } - - public void Freeze() { - if (IsFrozen) { - return; - } - _frozen = true; - } - - public const int KeyFieldNumber = 1; - private int key_; - public int Key { - get { return key_; } - set { - pb::Freezable.CheckMutable(this); - key_ = value; - } - } - - public const int ValueFieldNumber = 2; - private float value_; - public float Value { - get { return value_; } - set { - pb::Freezable.CheckMutable(this); - value_ = value; - } - } - - public override bool Equals(object other) { - return Equals(other as MapInt32FloatEntry); - } - - public bool Equals(MapInt32FloatEntry other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (Key != other.Key) return false; - if (Value != other.Value) return false; - return true; - } - - public override int GetHashCode() { - int hash = 1; - if (Key != 0) hash ^= Key.GetHashCode(); - if (Value != 0F) hash ^= Value.GetHashCode(); - return hash; - } - - public void WriteTo(pb::CodedOutputStream output) { - if (Key != 0) { - output.WriteRawTag(8); - output.WriteInt32(Key); - } - if (Value != 0F) { - output.WriteRawTag(21); - output.WriteFloat(Value); - } - } - - public int CalculateSize() { - int size = 0; - if (Key != 0) { - size += 1 + pb::CodedOutputStream.ComputeInt32Size(Key); - } - if (Value != 0F) { - size += 1 + 4; - } - return size; - } - - public void MergeFrom(MapInt32FloatEntry other) { - if (other == null) { - return; - } - if (other.Key != 0) { - Key = other.Key; - } - if (other.Value != 0F) { - Value = other.Value; - } - } - - public void MergeFrom(pb::CodedInputStream input) { - uint tag; - while (input.ReadTag(out tag)) { - switch(tag) { - case 0: - throw pb::InvalidProtocolBufferException.InvalidTag(); - default: - if (pb::WireFormat.IsEndGroupTag(tag)) { - return; - } - break; - case 8: { - Key = input.ReadInt32(); - break; - } - case 21: { - Value = input.ReadFloat(); - break; - } - } - } - } - - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class MapInt32DoubleEntry : pb::IMessage<MapInt32DoubleEntry> { - private static readonly pb::MessageParser<MapInt32DoubleEntry> _parser = new pb::MessageParser<MapInt32DoubleEntry>(() => new MapInt32DoubleEntry()); - public static pb::MessageParser<MapInt32DoubleEntry> Parser { get { return _parser; } } - - private static readonly string[] _fieldNames = new string[] { "key", "value" }; - private static readonly uint[] _fieldTags = new uint[] { 8, 17 }; - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.TestArenaMap.Descriptor.NestedTypes[11]; } - } - - public pb::FieldAccess.FieldAccessorTable Fields { - get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestArenaMap_MapInt32DoubleEntry__FieldAccessorTable; } - } - - private bool _frozen = false; - public bool IsFrozen { get { return _frozen; } } - - public MapInt32DoubleEntry() { - OnConstruction(); - } - - partial void OnConstruction(); - - public MapInt32DoubleEntry(MapInt32DoubleEntry other) : this() { - key_ = other.key_; - value_ = other.value_; - } - - public MapInt32DoubleEntry Clone() { - return new MapInt32DoubleEntry(this); - } - - public void Freeze() { - if (IsFrozen) { - return; - } - _frozen = true; - } - - public const int KeyFieldNumber = 1; - private int key_; - public int Key { - get { return key_; } - set { - pb::Freezable.CheckMutable(this); - key_ = value; - } - } - - public const int ValueFieldNumber = 2; - private double value_; - public double Value { - get { return value_; } - set { - pb::Freezable.CheckMutable(this); - value_ = value; - } - } - - public override bool Equals(object other) { - return Equals(other as MapInt32DoubleEntry); - } - - public bool Equals(MapInt32DoubleEntry other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (Key != other.Key) return false; - if (Value != other.Value) return false; - return true; - } - - public override int GetHashCode() { - int hash = 1; - if (Key != 0) hash ^= Key.GetHashCode(); - if (Value != 0D) hash ^= Value.GetHashCode(); - return hash; - } - - public void WriteTo(pb::CodedOutputStream output) { - if (Key != 0) { - output.WriteRawTag(8); - output.WriteInt32(Key); - } - if (Value != 0D) { - output.WriteRawTag(17); - output.WriteDouble(Value); - } - } - - public int CalculateSize() { - int size = 0; - if (Key != 0) { - size += 1 + pb::CodedOutputStream.ComputeInt32Size(Key); - } - if (Value != 0D) { - size += 1 + 8; - } - return size; - } - - public void MergeFrom(MapInt32DoubleEntry other) { - if (other == null) { - return; - } - if (other.Key != 0) { - Key = other.Key; - } - if (other.Value != 0D) { - Value = other.Value; - } - } - - public void MergeFrom(pb::CodedInputStream input) { - uint tag; - while (input.ReadTag(out tag)) { - switch(tag) { - case 0: - throw pb::InvalidProtocolBufferException.InvalidTag(); - default: - if (pb::WireFormat.IsEndGroupTag(tag)) { - return; - } - break; - case 8: { - Key = input.ReadInt32(); - break; - } - case 17: { - Value = input.ReadDouble(); - break; - } - } - } - } - - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class MapBoolBoolEntry : pb::IMessage<MapBoolBoolEntry> { - private static readonly pb::MessageParser<MapBoolBoolEntry> _parser = new pb::MessageParser<MapBoolBoolEntry>(() => new MapBoolBoolEntry()); - public static pb::MessageParser<MapBoolBoolEntry> Parser { get { return _parser; } } - - private static readonly string[] _fieldNames = new string[] { "key", "value" }; - private static readonly uint[] _fieldTags = new uint[] { 8, 16 }; - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.TestArenaMap.Descriptor.NestedTypes[12]; } - } - - public pb::FieldAccess.FieldAccessorTable Fields { - get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestArenaMap_MapBoolBoolEntry__FieldAccessorTable; } - } - - private bool _frozen = false; - public bool IsFrozen { get { return _frozen; } } - - public MapBoolBoolEntry() { - OnConstruction(); - } - - partial void OnConstruction(); - - public MapBoolBoolEntry(MapBoolBoolEntry other) : this() { - key_ = other.key_; - value_ = other.value_; - } - - public MapBoolBoolEntry Clone() { - return new MapBoolBoolEntry(this); - } - - public void Freeze() { - if (IsFrozen) { - return; - } - _frozen = true; - } - - public const int KeyFieldNumber = 1; - private bool key_; - public bool Key { - get { return key_; } - set { - pb::Freezable.CheckMutable(this); - key_ = value; - } - } - - public const int ValueFieldNumber = 2; - private bool value_; - public bool Value { - get { return value_; } - set { - pb::Freezable.CheckMutable(this); - value_ = value; - } - } - - public override bool Equals(object other) { - return Equals(other as MapBoolBoolEntry); - } - - public bool Equals(MapBoolBoolEntry other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (Key != other.Key) return false; - if (Value != other.Value) return false; - return true; - } - - public override int GetHashCode() { - int hash = 1; - if (Key != false) hash ^= Key.GetHashCode(); - if (Value != false) hash ^= Value.GetHashCode(); - return hash; - } - - public void WriteTo(pb::CodedOutputStream output) { - if (Key != false) { - output.WriteRawTag(8); - output.WriteBool(Key); - } - if (Value != false) { - output.WriteRawTag(16); - output.WriteBool(Value); - } - } - - public int CalculateSize() { - int size = 0; - if (Key != false) { - size += 1 + 1; - } - if (Value != false) { - size += 1 + 1; - } - return size; - } - - public void MergeFrom(MapBoolBoolEntry other) { - if (other == null) { - return; - } - if (other.Key != false) { - Key = other.Key; - } - if (other.Value != false) { - Value = other.Value; - } - } - - public void MergeFrom(pb::CodedInputStream input) { - uint tag; - while (input.ReadTag(out tag)) { - switch(tag) { - case 0: - throw pb::InvalidProtocolBufferException.InvalidTag(); - default: - if (pb::WireFormat.IsEndGroupTag(tag)) { - return; - } - break; - case 8: { - Key = input.ReadBool(); - break; - } - case 16: { - Value = input.ReadBool(); - break; - } - } - } - } - - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class MapInt32EnumEntry : pb::IMessage<MapInt32EnumEntry> { - private static readonly pb::MessageParser<MapInt32EnumEntry> _parser = new pb::MessageParser<MapInt32EnumEntry>(() => new MapInt32EnumEntry()); - public static pb::MessageParser<MapInt32EnumEntry> Parser { get { return _parser; } } - - private static readonly string[] _fieldNames = new string[] { "key", "value" }; - private static readonly uint[] _fieldTags = new uint[] { 8, 16 }; - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.TestArenaMap.Descriptor.NestedTypes[13]; } - } - - public pb::FieldAccess.FieldAccessorTable Fields { - get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestArenaMap_MapInt32EnumEntry__FieldAccessorTable; } - } - - private bool _frozen = false; - public bool IsFrozen { get { return _frozen; } } - - public MapInt32EnumEntry() { - OnConstruction(); - } - - partial void OnConstruction(); - - public MapInt32EnumEntry(MapInt32EnumEntry other) : this() { - key_ = other.key_; - value_ = other.value_; - } - - public MapInt32EnumEntry Clone() { - return new MapInt32EnumEntry(this); - } - - public void Freeze() { - if (IsFrozen) { - return; - } - _frozen = true; - } - - public const int KeyFieldNumber = 1; - private int key_; - public int Key { - get { return key_; } - set { - pb::Freezable.CheckMutable(this); - key_ = value; - } - } - - public const int ValueFieldNumber = 2; - private global::Google.Protobuf.TestProtos.MapEnum value_ = global::Google.Protobuf.TestProtos.MapEnum.MAP_ENUM_FOO; - public global::Google.Protobuf.TestProtos.MapEnum Value { - get { return value_; } - set { - pb::Freezable.CheckMutable(this); - value_ = value; - } - } - - public override bool Equals(object other) { - return Equals(other as MapInt32EnumEntry); - } - - public bool Equals(MapInt32EnumEntry other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (Key != other.Key) return false; - if (Value != other.Value) return false; - return true; - } - - public override int GetHashCode() { - int hash = 1; - if (Key != 0) hash ^= Key.GetHashCode(); - if (Value != global::Google.Protobuf.TestProtos.MapEnum.MAP_ENUM_FOO) hash ^= Value.GetHashCode(); - return hash; - } - - public void WriteTo(pb::CodedOutputStream output) { - if (Key != 0) { - output.WriteRawTag(8); - output.WriteInt32(Key); - } - if (Value != global::Google.Protobuf.TestProtos.MapEnum.MAP_ENUM_FOO) { - output.WriteRawTag(16); - output.WriteEnum((int) Value); - } - } - - public int CalculateSize() { - int size = 0; - if (Key != 0) { - size += 1 + pb::CodedOutputStream.ComputeInt32Size(Key); - } - if (Value != global::Google.Protobuf.TestProtos.MapEnum.MAP_ENUM_FOO) { - size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Value); - } - return size; - } - - public void MergeFrom(MapInt32EnumEntry other) { - if (other == null) { - return; - } - if (other.Key != 0) { - Key = other.Key; - } - if (other.Value != global::Google.Protobuf.TestProtos.MapEnum.MAP_ENUM_FOO) { - Value = other.Value; - } - } - - public void MergeFrom(pb::CodedInputStream input) { - uint tag; - while (input.ReadTag(out tag)) { - switch(tag) { - case 0: - throw pb::InvalidProtocolBufferException.InvalidTag(); - default: - if (pb::WireFormat.IsEndGroupTag(tag)) { - return; - } - break; - case 8: { - Key = input.ReadInt32(); - break; - } - case 16: { - value_ = (global::Google.Protobuf.TestProtos.MapEnum) input.ReadEnum(); - break; - } - } - } - } - - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class MapInt32ForeignMessageEntry : pb::IMessage<MapInt32ForeignMessageEntry> { - private static readonly pb::MessageParser<MapInt32ForeignMessageEntry> _parser = new pb::MessageParser<MapInt32ForeignMessageEntry>(() => new MapInt32ForeignMessageEntry()); - public static pb::MessageParser<MapInt32ForeignMessageEntry> Parser { get { return _parser; } } - - private static readonly string[] _fieldNames = new string[] { "key", "value" }; - private static readonly uint[] _fieldTags = new uint[] { 8, 18 }; - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.TestArenaMap.Descriptor.NestedTypes[14]; } - } - - public pb::FieldAccess.FieldAccessorTable Fields { - get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestArenaMap_MapInt32ForeignMessageEntry__FieldAccessorTable; } - } - - private bool _frozen = false; - public bool IsFrozen { get { return _frozen; } } - - public MapInt32ForeignMessageEntry() { - OnConstruction(); - } - - partial void OnConstruction(); - - public MapInt32ForeignMessageEntry(MapInt32ForeignMessageEntry other) : this() { - key_ = other.key_; - Value = other.value_ != null ? other.Value.Clone() : null; - } - - public MapInt32ForeignMessageEntry Clone() { - return new MapInt32ForeignMessageEntry(this); - } - - public void Freeze() { - if (IsFrozen) { - return; - } - _frozen = true; - if (value_ != null) Value.Freeze(); - } - - public const int KeyFieldNumber = 1; - private int key_; - public int Key { - get { return key_; } - set { - pb::Freezable.CheckMutable(this); - key_ = value; - } - } - - public const int ValueFieldNumber = 2; - private global::Google.Protobuf.TestProtos.ForeignMessage value_; - public global::Google.Protobuf.TestProtos.ForeignMessage Value { - get { return value_; } - set { - pb::Freezable.CheckMutable(this); - value_ = value; - } - } - - public override bool Equals(object other) { - return Equals(other as MapInt32ForeignMessageEntry); - } - - public bool Equals(MapInt32ForeignMessageEntry other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (Key != other.Key) return false; - if (!object.Equals(Value, other.Value)) return false; - return true; - } - - public override int GetHashCode() { - int hash = 1; - if (Key != 0) hash ^= Key.GetHashCode(); - if (value_ != null) hash ^= Value.GetHashCode(); - return hash; - } - - public void WriteTo(pb::CodedOutputStream output) { - if (Key != 0) { - output.WriteRawTag(8); - output.WriteInt32(Key); - } - if (value_ != null) { - output.WriteRawTag(18); - output.WriteMessage(Value); - } - } - - public int CalculateSize() { - int size = 0; - if (Key != 0) { - size += 1 + pb::CodedOutputStream.ComputeInt32Size(Key); - } - if (value_ != null) { - size += 1 + pb::CodedOutputStream.ComputeMessageSize(Value); - } - return size; - } - - public void MergeFrom(MapInt32ForeignMessageEntry other) { - if (other == null) { - return; - } - if (other.Key != 0) { - Key = other.Key; - } - if (other.value_ != null) { - if (value_ == null) { - value_ = new global::Google.Protobuf.TestProtos.ForeignMessage(); - } - Value.MergeFrom(other.Value); - } - } - - public void MergeFrom(pb::CodedInputStream input) { - uint tag; - while (input.ReadTag(out tag)) { - switch(tag) { - case 0: - throw pb::InvalidProtocolBufferException.InvalidTag(); - default: - if (pb::WireFormat.IsEndGroupTag(tag)) { - return; - } - break; - case 8: { - Key = input.ReadInt32(); - break; - } - case 18: { - if (value_ == null) { - value_ = new global::Google.Protobuf.TestProtos.ForeignMessage(); - } - input.ReadMessage(value_); - break; - } - } - } - } - - } - - } - #endregion - } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] @@ -6502,11 +1359,11 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "type" }; private static readonly uint[] _fieldTags = new uint[] { 10 }; - public static pbd::MessageDescriptor Descriptor { + public static pbr::MessageDescriptor Descriptor { get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.Descriptor.MessageTypes[5]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_MessageContainingEnumCalledType__FieldAccessorTable; } } @@ -6564,6 +1421,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { type_.WriteTo(output, _map_type_codec); } @@ -6607,155 +1468,6 @@ namespace Google.Protobuf.TestProtos { TYPE_FOO = 0, } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TypeEntry : pb::IMessage<TypeEntry> { - private static readonly pb::MessageParser<TypeEntry> _parser = new pb::MessageParser<TypeEntry>(() => new TypeEntry()); - public static pb::MessageParser<TypeEntry> Parser { get { return _parser; } } - - private static readonly string[] _fieldNames = new string[] { "key", "value" }; - private static readonly uint[] _fieldTags = new uint[] { 8, 18 }; - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.MessageContainingEnumCalledType.Descriptor.NestedTypes[0]; } - } - - public pb::FieldAccess.FieldAccessorTable Fields { - get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_MessageContainingEnumCalledType_TypeEntry__FieldAccessorTable; } - } - - private bool _frozen = false; - public bool IsFrozen { get { return _frozen; } } - - public TypeEntry() { - OnConstruction(); - } - - partial void OnConstruction(); - - public TypeEntry(TypeEntry other) : this() { - key_ = other.key_; - Value = other.value_ != null ? other.Value.Clone() : null; - } - - public TypeEntry Clone() { - return new TypeEntry(this); - } - - public void Freeze() { - if (IsFrozen) { - return; - } - _frozen = true; - if (value_ != null) Value.Freeze(); - } - - public const int KeyFieldNumber = 1; - private int key_; - public int Key { - get { return key_; } - set { - pb::Freezable.CheckMutable(this); - key_ = value; - } - } - - public const int ValueFieldNumber = 2; - private global::Google.Protobuf.TestProtos.MessageContainingEnumCalledType value_; - public global::Google.Protobuf.TestProtos.MessageContainingEnumCalledType Value { - get { return value_; } - set { - pb::Freezable.CheckMutable(this); - value_ = value; - } - } - - public override bool Equals(object other) { - return Equals(other as TypeEntry); - } - - public bool Equals(TypeEntry other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (Key != other.Key) return false; - if (!object.Equals(Value, other.Value)) return false; - return true; - } - - public override int GetHashCode() { - int hash = 1; - if (Key != 0) hash ^= Key.GetHashCode(); - if (value_ != null) hash ^= Value.GetHashCode(); - return hash; - } - - public void WriteTo(pb::CodedOutputStream output) { - if (Key != 0) { - output.WriteRawTag(8); - output.WriteInt32(Key); - } - if (value_ != null) { - output.WriteRawTag(18); - output.WriteMessage(Value); - } - } - - public int CalculateSize() { - int size = 0; - if (Key != 0) { - size += 1 + pb::CodedOutputStream.ComputeInt32Size(Key); - } - if (value_ != null) { - size += 1 + pb::CodedOutputStream.ComputeMessageSize(Value); - } - return size; - } - - public void MergeFrom(TypeEntry other) { - if (other == null) { - return; - } - if (other.Key != 0) { - Key = other.Key; - } - if (other.value_ != null) { - if (value_ == null) { - value_ = new global::Google.Protobuf.TestProtos.MessageContainingEnumCalledType(); - } - Value.MergeFrom(other.Value); - } - } - - public void MergeFrom(pb::CodedInputStream input) { - uint tag; - while (input.ReadTag(out tag)) { - switch(tag) { - case 0: - throw pb::InvalidProtocolBufferException.InvalidTag(); - default: - if (pb::WireFormat.IsEndGroupTag(tag)) { - return; - } - break; - case 8: { - Key = input.ReadInt32(); - break; - } - case 18: { - if (value_ == null) { - value_ = new global::Google.Protobuf.TestProtos.MessageContainingEnumCalledType(); - } - input.ReadMessage(value_); - break; - } - } - } - } - - } - } #endregion @@ -6768,11 +1480,11 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "entry" }; private static readonly uint[] _fieldTags = new uint[] { 10 }; - public static pbd::MessageDescriptor Descriptor { + public static pbr::MessageDescriptor Descriptor { get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.Descriptor.MessageTypes[6]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_MessageContainingMapCalledEntry__FieldAccessorTable; } } @@ -6830,6 +1542,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { entry_.WriteTo(output, _map_entry_codec); } @@ -6866,154 +1582,6 @@ namespace Google.Protobuf.TestProtos { } } - #region Nested types - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public static partial class Types { - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class EntryEntry : pb::IMessage<EntryEntry> { - private static readonly pb::MessageParser<EntryEntry> _parser = new pb::MessageParser<EntryEntry>(() => new EntryEntry()); - public static pb::MessageParser<EntryEntry> Parser { get { return _parser; } } - - private static readonly string[] _fieldNames = new string[] { "key", "value" }; - private static readonly uint[] _fieldTags = new uint[] { 8, 16 }; - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.MessageContainingMapCalledEntry.Descriptor.NestedTypes[0]; } - } - - public pb::FieldAccess.FieldAccessorTable Fields { - get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_MessageContainingMapCalledEntry_EntryEntry__FieldAccessorTable; } - } - - private bool _frozen = false; - public bool IsFrozen { get { return _frozen; } } - - public EntryEntry() { - OnConstruction(); - } - - partial void OnConstruction(); - - public EntryEntry(EntryEntry other) : this() { - key_ = other.key_; - value_ = other.value_; - } - - public EntryEntry Clone() { - return new EntryEntry(this); - } - - public void Freeze() { - if (IsFrozen) { - return; - } - _frozen = true; - } - - public const int KeyFieldNumber = 1; - private int key_; - public int Key { - get { return key_; } - set { - pb::Freezable.CheckMutable(this); - key_ = value; - } - } - - public const int ValueFieldNumber = 2; - private int value_; - public int Value { - get { return value_; } - set { - pb::Freezable.CheckMutable(this); - value_ = value; - } - } - - public override bool Equals(object other) { - return Equals(other as EntryEntry); - } - - public bool Equals(EntryEntry other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (Key != other.Key) return false; - if (Value != other.Value) return false; - return true; - } - - public override int GetHashCode() { - int hash = 1; - if (Key != 0) hash ^= Key.GetHashCode(); - if (Value != 0) hash ^= Value.GetHashCode(); - return hash; - } - - public void WriteTo(pb::CodedOutputStream output) { - if (Key != 0) { - output.WriteRawTag(8); - output.WriteInt32(Key); - } - if (Value != 0) { - output.WriteRawTag(16); - output.WriteInt32(Value); - } - } - - public int CalculateSize() { - int size = 0; - if (Key != 0) { - size += 1 + pb::CodedOutputStream.ComputeInt32Size(Key); - } - if (Value != 0) { - size += 1 + pb::CodedOutputStream.ComputeInt32Size(Value); - } - return size; - } - - public void MergeFrom(EntryEntry other) { - if (other == null) { - return; - } - if (other.Key != 0) { - Key = other.Key; - } - if (other.Value != 0) { - Value = other.Value; - } - } - - public void MergeFrom(pb::CodedInputStream input) { - uint tag; - while (input.ReadTag(out tag)) { - switch(tag) { - case 0: - throw pb::InvalidProtocolBufferException.InvalidTag(); - default: - if (pb::WireFormat.IsEndGroupTag(tag)) { - return; - } - break; - case 8: { - Key = input.ReadInt32(); - break; - } - case 16: { - Value = input.ReadInt32(); - break; - } - } - } - } - - } - - } - #endregion - } #endregion diff --git a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestImportProto3.cs b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestImportProto3.cs index d30f22db..3875a4c3 100644 --- a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestImportProto3.cs +++ b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestImportProto3.cs @@ -5,7 +5,7 @@ using pb = global::Google.Protobuf; using pbc = global::Google.Protobuf.Collections; -using pbd = global::Google.Protobuf.Descriptors; +using pbr = global::Google.Protobuf.Reflection; using scg = global::System.Collections.Generic; namespace Google.Protobuf.TestProtos { @@ -13,13 +13,13 @@ namespace Google.Protobuf.TestProtos { public static partial class UnittestImportProto3 { #region Static variables - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_import_ImportMessage__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_protobuf_unittest_import_ImportMessage__FieldAccessorTable; #endregion #region Descriptor - public static pbd::FileDescriptor Descriptor { + public static pbr::FileDescriptor Descriptor { get { return descriptor; } } - private static pbd::FileDescriptor descriptor; + private static pbr::FileDescriptor descriptor; static UnittestImportProto3() { byte[] descriptorData = global::System.Convert.FromBase64String( @@ -32,13 +32,13 @@ namespace Google.Protobuf.TestProtos { "UhAIEg4KCklNUE9SVF9CQVoQCUI8Chhjb20uZ29vZ2xlLnByb3RvYnVmLnRl", "c3RIAfgBAaoCGkdvb2dsZS5Qcm90b2J1Zi5UZXN0UHJvdG9zUABiBnByb3Rv", "Mw==")); - descriptor = pbd::FileDescriptor.InternalBuildGeneratedFileFrom(descriptorData, - new pbd::FileDescriptor[] { + descriptor = pbr::FileDescriptor.InternalBuildGeneratedFileFrom(descriptorData, + new pbr::FileDescriptor[] { global::Google.Protobuf.TestProtos.UnittestImportPublicProto3.Descriptor, }); internal__static_protobuf_unittest_import_ImportMessage__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.ImportMessage), descriptor.MessageTypes[0], - new string[] { "D", }); + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.ImportMessage), descriptor.MessageTypes[0], + new string[] { "D", }, new string[] { }); } #endregion @@ -61,11 +61,11 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "d" }; private static readonly uint[] _fieldTags = new uint[] { 8 }; - public static pbd::MessageDescriptor Descriptor { + public static pbr::MessageDescriptor Descriptor { get { return global::Google.Protobuf.TestProtos.UnittestImportProto3.Descriptor.MessageTypes[0]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { get { return global::Google.Protobuf.TestProtos.UnittestImportProto3.internal__static_protobuf_unittest_import_ImportMessage__FieldAccessorTable; } } @@ -124,6 +124,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (D != 0) { output.WriteRawTag(8); diff --git a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestImportPublicProto3.cs b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestImportPublicProto3.cs index 5aa03a64..048ae5e9 100644 --- a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestImportPublicProto3.cs +++ b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestImportPublicProto3.cs @@ -5,7 +5,7 @@ using pb = global::Google.Protobuf; using pbc = global::Google.Protobuf.Collections; -using pbd = global::Google.Protobuf.Descriptors; +using pbr = global::Google.Protobuf.Reflection; using scg = global::System.Collections.Generic; namespace Google.Protobuf.TestProtos { @@ -13,13 +13,13 @@ namespace Google.Protobuf.TestProtos { public static partial class UnittestImportPublicProto3 { #region Static variables - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_import_PublicImportMessage__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_protobuf_unittest_import_PublicImportMessage__FieldAccessorTable; #endregion #region Descriptor - public static pbd::FileDescriptor Descriptor { + public static pbr::FileDescriptor Descriptor { get { return descriptor; } } - private static pbd::FileDescriptor descriptor; + private static pbr::FileDescriptor descriptor; static UnittestImportPublicProto3() { byte[] descriptorData = global::System.Convert.FromBase64String( @@ -28,12 +28,12 @@ namespace Google.Protobuf.TestProtos { "bzMucHJvdG8SGHByb3RvYnVmX3VuaXR0ZXN0X2ltcG9ydCIgChNQdWJsaWNJ", "bXBvcnRNZXNzYWdlEgkKAWUYASABKAVCNwoYY29tLmdvb2dsZS5wcm90b2J1", "Zi50ZXN0qgIaR29vZ2xlLlByb3RvYnVmLlRlc3RQcm90b3NiBnByb3RvMw==")); - descriptor = pbd::FileDescriptor.InternalBuildGeneratedFileFrom(descriptorData, - new pbd::FileDescriptor[] { + descriptor = pbr::FileDescriptor.InternalBuildGeneratedFileFrom(descriptorData, + new pbr::FileDescriptor[] { }); internal__static_protobuf_unittest_import_PublicImportMessage__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.PublicImportMessage), descriptor.MessageTypes[0], - new string[] { "E", }); + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.PublicImportMessage), descriptor.MessageTypes[0], + new string[] { "E", }, new string[] { }); } #endregion @@ -46,11 +46,11 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "e" }; private static readonly uint[] _fieldTags = new uint[] { 8 }; - public static pbd::MessageDescriptor Descriptor { + public static pbr::MessageDescriptor Descriptor { get { return global::Google.Protobuf.TestProtos.UnittestImportPublicProto3.Descriptor.MessageTypes[0]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { get { return global::Google.Protobuf.TestProtos.UnittestImportPublicProto3.internal__static_protobuf_unittest_import_PublicImportMessage__FieldAccessorTable; } } @@ -109,6 +109,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (E != 0) { output.WriteRawTag(8); diff --git a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestIssues.cs b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestIssues.cs index 0e409c8b..c68c67fb 100644 --- a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestIssues.cs +++ b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestIssues.cs @@ -5,7 +5,7 @@ using pb = global::Google.Protobuf; using pbc = global::Google.Protobuf.Collections; -using pbd = global::Google.Protobuf.Descriptors; +using pbr = global::Google.Protobuf.Reflection; using scg = global::System.Collections.Generic; namespace UnitTest.Issues.TestProtos { @@ -13,19 +13,19 @@ namespace UnitTest.Issues.TestProtos { public static partial class UnittestIssues { #region Static variables - internal static pb::FieldAccess.FieldAccessorTable internal__static_unittest_issues_Issue307__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_unittest_issues_Issue307_NestedOnce__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_unittest_issues_Issue307_NestedOnce_NestedTwice__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_unittest_issues_NegativeEnumMessage__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_unittest_issues_DeprecatedChild__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_unittest_issues_DeprecatedFieldsMessage__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_unittest_issues_ItemField__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_unittest_issues_Issue307__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_unittest_issues_Issue307_NestedOnce__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_unittest_issues_Issue307_NestedOnce_NestedTwice__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_unittest_issues_NegativeEnumMessage__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_unittest_issues_DeprecatedChild__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_unittest_issues_DeprecatedFieldsMessage__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_unittest_issues_ItemField__FieldAccessorTable; #endregion #region Descriptor - public static pbd::FileDescriptor Descriptor { + public static pbr::FileDescriptor Descriptor { get { return descriptor; } } - private static pbd::FileDescriptor descriptor; + private static pbr::FileDescriptor descriptor; static UnittestIssues() { byte[] descriptorData = global::System.Convert.FromBase64String( @@ -48,30 +48,30 @@ namespace UnitTest.Issues.TestProtos { "EPv//////////wESFQoITWludXNPbmUQ////////////ASouCg5EZXByZWNh", "dGVkRW51bRITCg9ERVBSRUNBVEVEX1pFUk8QABIHCgNvbmUQAUIfSAGqAhpV", "bml0VGVzdC5Jc3N1ZXMuVGVzdFByb3Rvc2IGcHJvdG8z")); - descriptor = pbd::FileDescriptor.InternalBuildGeneratedFileFrom(descriptorData, - new pbd::FileDescriptor[] { + descriptor = pbr::FileDescriptor.InternalBuildGeneratedFileFrom(descriptorData, + new pbr::FileDescriptor[] { }); internal__static_unittest_issues_Issue307__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::UnitTest.Issues.TestProtos.Issue307), descriptor.MessageTypes[0], - new string[] { }); + new pbr::FieldAccessorTable(typeof(global::UnitTest.Issues.TestProtos.Issue307), descriptor.MessageTypes[0], + new string[] { }, new string[] { }); internal__static_unittest_issues_Issue307_NestedOnce__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::UnitTest.Issues.TestProtos.Issue307.Types.NestedOnce), descriptor.MessageTypes[0].NestedTypes[0], - new string[] { }); + new pbr::FieldAccessorTable(typeof(global::UnitTest.Issues.TestProtos.Issue307.Types.NestedOnce), descriptor.MessageTypes[0].NestedTypes[0], + new string[] { }, new string[] { }); internal__static_unittest_issues_Issue307_NestedOnce_NestedTwice__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::UnitTest.Issues.TestProtos.Issue307.Types.NestedOnce.Types.NestedTwice), descriptor.MessageTypes[0].NestedTypes[0].NestedTypes[0], - new string[] { }); + new pbr::FieldAccessorTable(typeof(global::UnitTest.Issues.TestProtos.Issue307.Types.NestedOnce.Types.NestedTwice), descriptor.MessageTypes[0].NestedTypes[0].NestedTypes[0], + new string[] { }, new string[] { }); internal__static_unittest_issues_NegativeEnumMessage__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::UnitTest.Issues.TestProtos.NegativeEnumMessage), descriptor.MessageTypes[1], - new string[] { "Value", "Values", "PackedValues", }); + new pbr::FieldAccessorTable(typeof(global::UnitTest.Issues.TestProtos.NegativeEnumMessage), descriptor.MessageTypes[1], + new string[] { "Value", "Values", "PackedValues", }, new string[] { }); internal__static_unittest_issues_DeprecatedChild__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::UnitTest.Issues.TestProtos.DeprecatedChild), descriptor.MessageTypes[2], - new string[] { }); + new pbr::FieldAccessorTable(typeof(global::UnitTest.Issues.TestProtos.DeprecatedChild), descriptor.MessageTypes[2], + new string[] { }, new string[] { }); internal__static_unittest_issues_DeprecatedFieldsMessage__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::UnitTest.Issues.TestProtos.DeprecatedFieldsMessage), descriptor.MessageTypes[3], - new string[] { "PrimitiveValue", "PrimitiveArray", "MessageValue", "MessageArray", "EnumValue", "EnumArray", }); + new pbr::FieldAccessorTable(typeof(global::UnitTest.Issues.TestProtos.DeprecatedFieldsMessage), descriptor.MessageTypes[3], + new string[] { "PrimitiveValue", "PrimitiveArray", "MessageValue", "MessageArray", "EnumValue", "EnumArray", }, new string[] { }); internal__static_unittest_issues_ItemField__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::UnitTest.Issues.TestProtos.ItemField), descriptor.MessageTypes[4], - new string[] { "Item", }); + new pbr::FieldAccessorTable(typeof(global::UnitTest.Issues.TestProtos.ItemField), descriptor.MessageTypes[4], + new string[] { "Item", }, new string[] { }); } #endregion @@ -98,11 +98,11 @@ namespace UnitTest.Issues.TestProtos { private static readonly string[] _fieldNames = new string[] { }; private static readonly uint[] _fieldTags = new uint[] { }; - public static pbd::MessageDescriptor Descriptor { + public static pbr::MessageDescriptor Descriptor { get { return global::UnitTest.Issues.TestProtos.UnittestIssues.Descriptor.MessageTypes[0]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { get { return global::UnitTest.Issues.TestProtos.UnittestIssues.internal__static_unittest_issues_Issue307__FieldAccessorTable; } } @@ -148,6 +148,10 @@ namespace UnitTest.Issues.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { } @@ -187,11 +191,11 @@ namespace UnitTest.Issues.TestProtos { private static readonly string[] _fieldNames = new string[] { }; private static readonly uint[] _fieldTags = new uint[] { }; - public static pbd::MessageDescriptor Descriptor { + public static pbr::MessageDescriptor Descriptor { get { return global::UnitTest.Issues.TestProtos.Issue307.Descriptor.NestedTypes[0]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { get { return global::UnitTest.Issues.TestProtos.UnittestIssues.internal__static_unittest_issues_Issue307_NestedOnce__FieldAccessorTable; } } @@ -237,6 +241,10 @@ namespace UnitTest.Issues.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { } @@ -276,11 +284,11 @@ namespace UnitTest.Issues.TestProtos { private static readonly string[] _fieldNames = new string[] { }; private static readonly uint[] _fieldTags = new uint[] { }; - public static pbd::MessageDescriptor Descriptor { + public static pbr::MessageDescriptor Descriptor { get { return global::UnitTest.Issues.TestProtos.Issue307.Types.NestedOnce.Descriptor.NestedTypes[0]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { get { return global::UnitTest.Issues.TestProtos.UnittestIssues.internal__static_unittest_issues_Issue307_NestedOnce_NestedTwice__FieldAccessorTable; } } @@ -326,6 +334,10 @@ namespace UnitTest.Issues.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { } @@ -374,11 +386,11 @@ namespace UnitTest.Issues.TestProtos { private static readonly string[] _fieldNames = new string[] { "packed_values", "value", "values" }; private static readonly uint[] _fieldTags = new uint[] { 26, 8, 16 }; - public static pbd::MessageDescriptor Descriptor { + public static pbr::MessageDescriptor Descriptor { get { return global::UnitTest.Issues.TestProtos.UnittestIssues.Descriptor.MessageTypes[1]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { get { return global::UnitTest.Issues.TestProtos.UnittestIssues.internal__static_unittest_issues_NegativeEnumMessage__FieldAccessorTable; } } @@ -459,6 +471,10 @@ namespace UnitTest.Issues.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (Value != global::UnitTest.Issues.TestProtos.NegativeEnum.NEGATIVE_ENUM_ZERO) { output.WriteRawTag(8); @@ -527,11 +543,11 @@ namespace UnitTest.Issues.TestProtos { private static readonly string[] _fieldNames = new string[] { }; private static readonly uint[] _fieldTags = new uint[] { }; - public static pbd::MessageDescriptor Descriptor { + public static pbr::MessageDescriptor Descriptor { get { return global::UnitTest.Issues.TestProtos.UnittestIssues.Descriptor.MessageTypes[2]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { get { return global::UnitTest.Issues.TestProtos.UnittestIssues.internal__static_unittest_issues_DeprecatedChild__FieldAccessorTable; } } @@ -577,6 +593,10 @@ namespace UnitTest.Issues.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { } @@ -615,11 +635,11 @@ namespace UnitTest.Issues.TestProtos { private static readonly string[] _fieldNames = new string[] { "EnumArray", "EnumValue", "MessageArray", "MessageValue", "PrimitiveArray", "PrimitiveValue" }; private static readonly uint[] _fieldTags = new uint[] { 50, 40, 34, 26, 18, 8 }; - public static pbd::MessageDescriptor Descriptor { + public static pbr::MessageDescriptor Descriptor { get { return global::UnitTest.Issues.TestProtos.UnittestIssues.Descriptor.MessageTypes[3]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { get { return global::UnitTest.Issues.TestProtos.UnittestIssues.internal__static_unittest_issues_DeprecatedFieldsMessage__FieldAccessorTable; } } @@ -746,6 +766,10 @@ namespace UnitTest.Issues.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (PrimitiveValue != 0) { output.WriteRawTag(8); @@ -855,11 +879,11 @@ namespace UnitTest.Issues.TestProtos { private static readonly string[] _fieldNames = new string[] { "item" }; private static readonly uint[] _fieldTags = new uint[] { 8 }; - public static pbd::MessageDescriptor Descriptor { + public static pbr::MessageDescriptor Descriptor { get { return global::UnitTest.Issues.TestProtos.UnittestIssues.Descriptor.MessageTypes[4]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { get { return global::UnitTest.Issues.TestProtos.UnittestIssues.internal__static_unittest_issues_ItemField__FieldAccessorTable; } } @@ -918,6 +942,10 @@ namespace UnitTest.Issues.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (Item != 0) { output.WriteRawTag(8); diff --git a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestProto3.cs b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestProto3.cs index d2437bf4..67c42708 100644 --- a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestProto3.cs +++ b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestProto3.cs @@ -5,7 +5,7 @@ using pb = global::Google.Protobuf; using pbc = global::Google.Protobuf.Collections; -using pbd = global::Google.Protobuf.Descriptors; +using pbr = global::Google.Protobuf.Reflection; using scg = global::System.Collections.Generic; namespace Google.Protobuf.TestProtos { @@ -13,47 +13,47 @@ namespace Google.Protobuf.TestProtos { public static partial class UnittestProto3 { #region Static variables - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestAllTypes__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestAllTypes_NestedMessage__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_NestedTestAllTypes__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestDeprecatedFields__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_ForeignMessage__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestReservedFields__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestForeignNested__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestReallyLargeTagNumber__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestRecursiveMessage__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestMutualRecursionA__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestMutualRecursionB__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestCamelCaseFieldNames__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestFieldOrderings__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestFieldOrderings_NestedMessage__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_SparseEnumMessage__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_OneString__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_MoreString__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_OneBytes__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_MoreBytes__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_Int32Message__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_Uint32Message__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_Int64Message__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_Uint64Message__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_BoolMessage__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestOneof__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestPackedTypes__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestUnpackedTypes__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestRepeatedScalarDifferentTagSizes__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestCommentInjectionMessage__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_FooRequest__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_FooResponse__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_FooClientMessage__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_FooServerMessage__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_BarRequest__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_BarResponse__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_protobuf_unittest_TestAllTypes__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_protobuf_unittest_TestAllTypes_NestedMessage__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_protobuf_unittest_NestedTestAllTypes__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_protobuf_unittest_TestDeprecatedFields__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_protobuf_unittest_ForeignMessage__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_protobuf_unittest_TestReservedFields__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_protobuf_unittest_TestForeignNested__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_protobuf_unittest_TestReallyLargeTagNumber__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_protobuf_unittest_TestRecursiveMessage__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_protobuf_unittest_TestMutualRecursionA__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_protobuf_unittest_TestMutualRecursionB__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_protobuf_unittest_TestCamelCaseFieldNames__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_protobuf_unittest_TestFieldOrderings__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_protobuf_unittest_TestFieldOrderings_NestedMessage__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_protobuf_unittest_SparseEnumMessage__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_protobuf_unittest_OneString__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_protobuf_unittest_MoreString__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_protobuf_unittest_OneBytes__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_protobuf_unittest_MoreBytes__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_protobuf_unittest_Int32Message__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_protobuf_unittest_Uint32Message__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_protobuf_unittest_Int64Message__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_protobuf_unittest_Uint64Message__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_protobuf_unittest_BoolMessage__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_protobuf_unittest_TestOneof__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_protobuf_unittest_TestPackedTypes__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_protobuf_unittest_TestUnpackedTypes__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_protobuf_unittest_TestRepeatedScalarDifferentTagSizes__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_protobuf_unittest_TestCommentInjectionMessage__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_protobuf_unittest_FooRequest__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_protobuf_unittest_FooResponse__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_protobuf_unittest_FooClientMessage__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_protobuf_unittest_FooServerMessage__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_protobuf_unittest_BarRequest__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_protobuf_unittest_BarResponse__FieldAccessorTable; #endregion #region Descriptor - public static pbd::FileDescriptor Descriptor { + public static pbr::FileDescriptor Descriptor { get { return descriptor; } } - private static pbd::FileDescriptor descriptor; + private static pbr::FileDescriptor descriptor; static UnittestProto3() { byte[] descriptorData = global::System.Convert.FromBase64String( @@ -185,115 +185,115 @@ namespace Google.Protobuf.TestProtos { "HS5wcm90b2J1Zl91bml0dGVzdC5CYXJSZXF1ZXN0Gh4ucHJvdG9idWZfdW5p", "dHRlc3QuQmFyUmVzcG9uc2VCOkINVW5pdHRlc3RQcm90b0gBgAEBiAEBkAEB", "+AEBqgIaR29vZ2xlLlByb3RvYnVmLlRlc3RQcm90b3NiBnByb3RvMw==")); - descriptor = pbd::FileDescriptor.InternalBuildGeneratedFileFrom(descriptorData, - new pbd::FileDescriptor[] { + descriptor = pbr::FileDescriptor.InternalBuildGeneratedFileFrom(descriptorData, + new pbr::FileDescriptor[] { global::Google.Protobuf.TestProtos.UnittestImportProto3.Descriptor, }); internal__static_protobuf_unittest_TestAllTypes__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestAllTypes), descriptor.MessageTypes[0], - new string[] { "SingleInt32", "SingleInt64", "SingleUint32", "SingleUint64", "SingleSint32", "SingleSint64", "SingleFixed32", "SingleFixed64", "SingleSfixed32", "SingleSfixed64", "SingleFloat", "SingleDouble", "SingleBool", "SingleString", "SingleBytes", "SingleNestedMessage", "SingleForeignMessage", "SingleImportMessage", "SingleNestedEnum", "SingleForeignEnum", "SingleImportEnum", "SinglePublicImportMessage", "RepeatedInt32", "RepeatedInt64", "RepeatedUint32", "RepeatedUint64", "RepeatedSint32", "RepeatedSint64", "RepeatedFixed32", "RepeatedFixed64", "RepeatedSfixed32", "RepeatedSfixed64", "RepeatedFloat", "RepeatedDouble", "RepeatedBool", "RepeatedString", "RepeatedBytes", "RepeatedNestedMessage", "RepeatedForeignMessage", "RepeatedImportMessage", "RepeatedNestedEnum", "RepeatedForeignEnum", "RepeatedImportEnum", "RepeatedPublicImportMessage", "OneofUint32", "OneofNestedMessage", "OneofString", "OneofBytes", "OneofField", }); + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestAllTypes), descriptor.MessageTypes[0], + new string[] { "SingleInt32", "SingleInt64", "SingleUint32", "SingleUint64", "SingleSint32", "SingleSint64", "SingleFixed32", "SingleFixed64", "SingleSfixed32", "SingleSfixed64", "SingleFloat", "SingleDouble", "SingleBool", "SingleString", "SingleBytes", "SingleNestedMessage", "SingleForeignMessage", "SingleImportMessage", "SingleNestedEnum", "SingleForeignEnum", "SingleImportEnum", "SinglePublicImportMessage", "RepeatedInt32", "RepeatedInt64", "RepeatedUint32", "RepeatedUint64", "RepeatedSint32", "RepeatedSint64", "RepeatedFixed32", "RepeatedFixed64", "RepeatedSfixed32", "RepeatedSfixed64", "RepeatedFloat", "RepeatedDouble", "RepeatedBool", "RepeatedString", "RepeatedBytes", "RepeatedNestedMessage", "RepeatedForeignMessage", "RepeatedImportMessage", "RepeatedNestedEnum", "RepeatedForeignEnum", "RepeatedImportEnum", "RepeatedPublicImportMessage", "OneofUint32", "OneofNestedMessage", "OneofString", "OneofBytes", }, new string[] { "OneofField", }); internal__static_protobuf_unittest_TestAllTypes_NestedMessage__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedMessage), descriptor.MessageTypes[0].NestedTypes[0], - new string[] { "Bb", }); + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedMessage), descriptor.MessageTypes[0].NestedTypes[0], + new string[] { "Bb", }, new string[] { }); internal__static_protobuf_unittest_NestedTestAllTypes__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.NestedTestAllTypes), descriptor.MessageTypes[1], - new string[] { "Child", "Payload", "RepeatedChild", }); + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.NestedTestAllTypes), descriptor.MessageTypes[1], + new string[] { "Child", "Payload", "RepeatedChild", }, new string[] { }); internal__static_protobuf_unittest_TestDeprecatedFields__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestDeprecatedFields), descriptor.MessageTypes[2], - new string[] { "DeprecatedInt32", }); + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestDeprecatedFields), descriptor.MessageTypes[2], + new string[] { "DeprecatedInt32", }, new string[] { }); internal__static_protobuf_unittest_ForeignMessage__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.ForeignMessage), descriptor.MessageTypes[3], - new string[] { "C", }); + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.ForeignMessage), descriptor.MessageTypes[3], + new string[] { "C", }, new string[] { }); internal__static_protobuf_unittest_TestReservedFields__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestReservedFields), descriptor.MessageTypes[4], - new string[] { }); + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestReservedFields), descriptor.MessageTypes[4], + new string[] { }, new string[] { }); internal__static_protobuf_unittest_TestForeignNested__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestForeignNested), descriptor.MessageTypes[5], - new string[] { "ForeignNested", }); + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestForeignNested), descriptor.MessageTypes[5], + new string[] { "ForeignNested", }, new string[] { }); internal__static_protobuf_unittest_TestReallyLargeTagNumber__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestReallyLargeTagNumber), descriptor.MessageTypes[6], - new string[] { "A", "Bb", }); + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestReallyLargeTagNumber), descriptor.MessageTypes[6], + new string[] { "A", "Bb", }, new string[] { }); internal__static_protobuf_unittest_TestRecursiveMessage__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestRecursiveMessage), descriptor.MessageTypes[7], - new string[] { "A", "I", }); + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestRecursiveMessage), descriptor.MessageTypes[7], + new string[] { "A", "I", }, new string[] { }); internal__static_protobuf_unittest_TestMutualRecursionA__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestMutualRecursionA), descriptor.MessageTypes[8], - new string[] { "Bb", }); + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestMutualRecursionA), descriptor.MessageTypes[8], + new string[] { "Bb", }, new string[] { }); internal__static_protobuf_unittest_TestMutualRecursionB__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestMutualRecursionB), descriptor.MessageTypes[9], - new string[] { "A", "OptionalInt32", }); + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestMutualRecursionB), descriptor.MessageTypes[9], + new string[] { "A", "OptionalInt32", }, new string[] { }); internal__static_protobuf_unittest_TestCamelCaseFieldNames__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestCamelCaseFieldNames), descriptor.MessageTypes[10], - new string[] { "PrimitiveField", "StringField", "EnumField", "MessageField", "RepeatedPrimitiveField", "RepeatedStringField", "RepeatedEnumField", "RepeatedMessageField", }); + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestCamelCaseFieldNames), descriptor.MessageTypes[10], + new string[] { "PrimitiveField", "StringField", "EnumField", "MessageField", "RepeatedPrimitiveField", "RepeatedStringField", "RepeatedEnumField", "RepeatedMessageField", }, new string[] { }); internal__static_protobuf_unittest_TestFieldOrderings__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestFieldOrderings), descriptor.MessageTypes[11], - new string[] { "MyString", "MyInt", "MyFloat", "SingleNestedMessage", }); + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestFieldOrderings), descriptor.MessageTypes[11], + new string[] { "MyString", "MyInt", "MyFloat", "SingleNestedMessage", }, new string[] { }); internal__static_protobuf_unittest_TestFieldOrderings_NestedMessage__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestFieldOrderings.Types.NestedMessage), descriptor.MessageTypes[11].NestedTypes[0], - new string[] { "Oo", "Bb", }); + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestFieldOrderings.Types.NestedMessage), descriptor.MessageTypes[11].NestedTypes[0], + new string[] { "Oo", "Bb", }, new string[] { }); internal__static_protobuf_unittest_SparseEnumMessage__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.SparseEnumMessage), descriptor.MessageTypes[12], - new string[] { "SparseEnum", }); + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.SparseEnumMessage), descriptor.MessageTypes[12], + new string[] { "SparseEnum", }, new string[] { }); internal__static_protobuf_unittest_OneString__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.OneString), descriptor.MessageTypes[13], - new string[] { "Data", }); + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.OneString), descriptor.MessageTypes[13], + new string[] { "Data", }, new string[] { }); internal__static_protobuf_unittest_MoreString__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.MoreString), descriptor.MessageTypes[14], - new string[] { "Data", }); + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.MoreString), descriptor.MessageTypes[14], + new string[] { "Data", }, new string[] { }); internal__static_protobuf_unittest_OneBytes__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.OneBytes), descriptor.MessageTypes[15], - new string[] { "Data", }); + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.OneBytes), descriptor.MessageTypes[15], + new string[] { "Data", }, new string[] { }); internal__static_protobuf_unittest_MoreBytes__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.MoreBytes), descriptor.MessageTypes[16], - new string[] { "Data", }); + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.MoreBytes), descriptor.MessageTypes[16], + new string[] { "Data", }, new string[] { }); internal__static_protobuf_unittest_Int32Message__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.Int32Message), descriptor.MessageTypes[17], - new string[] { "Data", }); + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.Int32Message), descriptor.MessageTypes[17], + new string[] { "Data", }, new string[] { }); internal__static_protobuf_unittest_Uint32Message__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.Uint32Message), descriptor.MessageTypes[18], - new string[] { "Data", }); + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.Uint32Message), descriptor.MessageTypes[18], + new string[] { "Data", }, new string[] { }); internal__static_protobuf_unittest_Int64Message__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.Int64Message), descriptor.MessageTypes[19], - new string[] { "Data", }); + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.Int64Message), descriptor.MessageTypes[19], + new string[] { "Data", }, new string[] { }); internal__static_protobuf_unittest_Uint64Message__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.Uint64Message), descriptor.MessageTypes[20], - new string[] { "Data", }); + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.Uint64Message), descriptor.MessageTypes[20], + new string[] { "Data", }, new string[] { }); internal__static_protobuf_unittest_BoolMessage__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.BoolMessage), descriptor.MessageTypes[21], - new string[] { "Data", }); + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.BoolMessage), descriptor.MessageTypes[21], + new string[] { "Data", }, new string[] { }); internal__static_protobuf_unittest_TestOneof__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestOneof), descriptor.MessageTypes[22], - new string[] { "FooInt", "FooString", "FooMessage", "Foo", }); + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestOneof), descriptor.MessageTypes[22], + new string[] { "FooInt", "FooString", "FooMessage", }, new string[] { "Foo", }); internal__static_protobuf_unittest_TestPackedTypes__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestPackedTypes), descriptor.MessageTypes[23], - new string[] { "PackedInt32", "PackedInt64", "PackedUint32", "PackedUint64", "PackedSint32", "PackedSint64", "PackedFixed32", "PackedFixed64", "PackedSfixed32", "PackedSfixed64", "PackedFloat", "PackedDouble", "PackedBool", "PackedEnum", }); + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestPackedTypes), descriptor.MessageTypes[23], + new string[] { "PackedInt32", "PackedInt64", "PackedUint32", "PackedUint64", "PackedSint32", "PackedSint64", "PackedFixed32", "PackedFixed64", "PackedSfixed32", "PackedSfixed64", "PackedFloat", "PackedDouble", "PackedBool", "PackedEnum", }, new string[] { }); internal__static_protobuf_unittest_TestUnpackedTypes__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestUnpackedTypes), descriptor.MessageTypes[24], - new string[] { "UnpackedInt32", "UnpackedInt64", "UnpackedUint32", "UnpackedUint64", "UnpackedSint32", "UnpackedSint64", "UnpackedFixed32", "UnpackedFixed64", "UnpackedSfixed32", "UnpackedSfixed64", "UnpackedFloat", "UnpackedDouble", "UnpackedBool", "UnpackedEnum", }); + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestUnpackedTypes), descriptor.MessageTypes[24], + new string[] { "UnpackedInt32", "UnpackedInt64", "UnpackedUint32", "UnpackedUint64", "UnpackedSint32", "UnpackedSint64", "UnpackedFixed32", "UnpackedFixed64", "UnpackedSfixed32", "UnpackedSfixed64", "UnpackedFloat", "UnpackedDouble", "UnpackedBool", "UnpackedEnum", }, new string[] { }); internal__static_protobuf_unittest_TestRepeatedScalarDifferentTagSizes__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestRepeatedScalarDifferentTagSizes), descriptor.MessageTypes[25], - new string[] { "RepeatedFixed32", "RepeatedInt32", "RepeatedFixed64", "RepeatedInt64", "RepeatedFloat", "RepeatedUint64", }); + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestRepeatedScalarDifferentTagSizes), descriptor.MessageTypes[25], + new string[] { "RepeatedFixed32", "RepeatedInt32", "RepeatedFixed64", "RepeatedInt64", "RepeatedFloat", "RepeatedUint64", }, new string[] { }); internal__static_protobuf_unittest_TestCommentInjectionMessage__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestCommentInjectionMessage), descriptor.MessageTypes[26], - new string[] { "A", }); + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestCommentInjectionMessage), descriptor.MessageTypes[26], + new string[] { "A", }, new string[] { }); internal__static_protobuf_unittest_FooRequest__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.FooRequest), descriptor.MessageTypes[27], - new string[] { }); + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.FooRequest), descriptor.MessageTypes[27], + new string[] { }, new string[] { }); internal__static_protobuf_unittest_FooResponse__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.FooResponse), descriptor.MessageTypes[28], - new string[] { }); + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.FooResponse), descriptor.MessageTypes[28], + new string[] { }, new string[] { }); internal__static_protobuf_unittest_FooClientMessage__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.FooClientMessage), descriptor.MessageTypes[29], - new string[] { }); + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.FooClientMessage), descriptor.MessageTypes[29], + new string[] { }, new string[] { }); internal__static_protobuf_unittest_FooServerMessage__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.FooServerMessage), descriptor.MessageTypes[30], - new string[] { }); + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.FooServerMessage), descriptor.MessageTypes[30], + new string[] { }, new string[] { }); internal__static_protobuf_unittest_BarRequest__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.BarRequest), descriptor.MessageTypes[31], - new string[] { }); + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.BarRequest), descriptor.MessageTypes[31], + new string[] { }, new string[] { }); internal__static_protobuf_unittest_BarResponse__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.BarResponse), descriptor.MessageTypes[32], - new string[] { }); + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.BarResponse), descriptor.MessageTypes[32], + new string[] { }, new string[] { }); } #endregion @@ -335,11 +335,11 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "oneof_bytes", "oneof_nested_message", "oneof_string", "oneof_uint32", "repeated_bool", "repeated_bytes", "repeated_double", "repeated_fixed32", "repeated_fixed64", "repeated_float", "repeated_foreign_enum", "repeated_foreign_message", "repeated_import_enum", "repeated_import_message", "repeated_int32", "repeated_int64", "repeated_nested_enum", "repeated_nested_message", "repeated_public_import_message", "repeated_sfixed32", "repeated_sfixed64", "repeated_sint32", "repeated_sint64", "repeated_string", "repeated_uint32", "repeated_uint64", "single_bool", "single_bytes", "single_double", "single_fixed32", "single_fixed64", "single_float", "single_foreign_enum", "single_foreign_message", "single_import_enum", "single_import_message", "single_int32", "single_int64", "single_nested_enum", "single_nested_message", "single_public_import_message", "single_sfixed32", "single_sfixed64", "single_sint32", "single_sint64", "single_string", "single_uint32", "single_uint64" }; private static readonly uint[] _fieldTags = new uint[] { 914, 898, 906, 888, 346, 362, 338, 298, 306, 330, 418, 394, 426, 402, 250, 258, 410, 386, 434, 314, 322, 282, 290, 354, 266, 274, 104, 122, 97, 61, 65, 93, 176, 154, 184, 162, 8, 16, 168, 146, 210, 77, 81, 40, 48, 114, 24, 32 }; - public static pbd::MessageDescriptor Descriptor { + public static pbr::MessageDescriptor Descriptor { get { return global::Google.Protobuf.TestProtos.UnittestProto3.Descriptor.MessageTypes[0]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestAllTypes__FieldAccessorTable; } } @@ -1019,6 +1019,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (SingleInt32 != 0) { output.WriteRawTag(8); @@ -1632,11 +1636,11 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "bb" }; private static readonly uint[] _fieldTags = new uint[] { 8 }; - public static pbd::MessageDescriptor Descriptor { + public static pbr::MessageDescriptor Descriptor { get { return global::Google.Protobuf.TestProtos.TestAllTypes.Descriptor.NestedTypes[0]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestAllTypes_NestedMessage__FieldAccessorTable; } } @@ -1695,6 +1699,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (Bb != 0) { output.WriteRawTag(8); @@ -1752,11 +1760,11 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "child", "payload", "repeated_child" }; private static readonly uint[] _fieldTags = new uint[] { 10, 18, 26 }; - public static pbd::MessageDescriptor Descriptor { + public static pbr::MessageDescriptor Descriptor { get { return global::Google.Protobuf.TestProtos.UnittestProto3.Descriptor.MessageTypes[1]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_NestedTestAllTypes__FieldAccessorTable; } } @@ -1842,6 +1850,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (child_ != null) { output.WriteRawTag(10); @@ -1927,11 +1939,11 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "deprecated_int32" }; private static readonly uint[] _fieldTags = new uint[] { 8 }; - public static pbd::MessageDescriptor Descriptor { + public static pbr::MessageDescriptor Descriptor { get { return global::Google.Protobuf.TestProtos.UnittestProto3.Descriptor.MessageTypes[2]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestDeprecatedFields__FieldAccessorTable; } } @@ -1991,6 +2003,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (DeprecatedInt32 != 0) { output.WriteRawTag(8); @@ -2043,11 +2059,11 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "c" }; private static readonly uint[] _fieldTags = new uint[] { 8 }; - public static pbd::MessageDescriptor Descriptor { + public static pbr::MessageDescriptor Descriptor { get { return global::Google.Protobuf.TestProtos.UnittestProto3.Descriptor.MessageTypes[3]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_ForeignMessage__FieldAccessorTable; } } @@ -2106,6 +2122,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (C != 0) { output.WriteRawTag(8); @@ -2158,11 +2178,11 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { }; private static readonly uint[] _fieldTags = new uint[] { }; - public static pbd::MessageDescriptor Descriptor { + public static pbr::MessageDescriptor Descriptor { get { return global::Google.Protobuf.TestProtos.UnittestProto3.Descriptor.MessageTypes[4]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestReservedFields__FieldAccessorTable; } } @@ -2208,6 +2228,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { } @@ -2246,11 +2270,11 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "foreign_nested" }; private static readonly uint[] _fieldTags = new uint[] { 10 }; - public static pbd::MessageDescriptor Descriptor { + public static pbr::MessageDescriptor Descriptor { get { return global::Google.Protobuf.TestProtos.UnittestProto3.Descriptor.MessageTypes[5]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestForeignNested__FieldAccessorTable; } } @@ -2310,6 +2334,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (foreignNested_ != null) { output.WriteRawTag(10); @@ -2368,11 +2396,11 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "a", "bb" }; private static readonly uint[] _fieldTags = new uint[] { 8, 2147483640 }; - public static pbd::MessageDescriptor Descriptor { + public static pbr::MessageDescriptor Descriptor { get { return global::Google.Protobuf.TestProtos.UnittestProto3.Descriptor.MessageTypes[6]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestReallyLargeTagNumber__FieldAccessorTable; } } @@ -2444,6 +2472,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (A != 0) { output.WriteRawTag(8); @@ -2510,11 +2542,11 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "a", "i" }; private static readonly uint[] _fieldTags = new uint[] { 10, 16 }; - public static pbd::MessageDescriptor Descriptor { + public static pbr::MessageDescriptor Descriptor { get { return global::Google.Protobuf.TestProtos.UnittestProto3.Descriptor.MessageTypes[7]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestRecursiveMessage__FieldAccessorTable; } } @@ -2587,6 +2619,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (a_ != null) { output.WriteRawTag(10); @@ -2659,11 +2695,11 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "bb" }; private static readonly uint[] _fieldTags = new uint[] { 10 }; - public static pbd::MessageDescriptor Descriptor { + public static pbr::MessageDescriptor Descriptor { get { return global::Google.Protobuf.TestProtos.UnittestProto3.Descriptor.MessageTypes[8]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestMutualRecursionA__FieldAccessorTable; } } @@ -2723,6 +2759,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (bb_ != null) { output.WriteRawTag(10); @@ -2781,11 +2821,11 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "a", "optional_int32" }; private static readonly uint[] _fieldTags = new uint[] { 10, 16 }; - public static pbd::MessageDescriptor Descriptor { + public static pbr::MessageDescriptor Descriptor { get { return global::Google.Protobuf.TestProtos.UnittestProto3.Descriptor.MessageTypes[9]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestMutualRecursionB__FieldAccessorTable; } } @@ -2858,6 +2898,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (a_ != null) { output.WriteRawTag(10); @@ -2930,11 +2974,11 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "EnumField", "MessageField", "PrimitiveField", "RepeatedEnumField", "RepeatedMessageField", "RepeatedPrimitiveField", "RepeatedStringField", "StringField" }; private static readonly uint[] _fieldTags = new uint[] { 24, 34, 8, 74, 82, 58, 66, 18 }; - public static pbd::MessageDescriptor Descriptor { + public static pbr::MessageDescriptor Descriptor { get { return global::Google.Protobuf.TestProtos.UnittestProto3.Descriptor.MessageTypes[10]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestCamelCaseFieldNames__FieldAccessorTable; } } @@ -3080,6 +3124,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (PrimitiveField != 0) { output.WriteRawTag(8); @@ -3210,11 +3258,11 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "my_float", "my_int", "my_string", "single_nested_message" }; private static readonly uint[] _fieldTags = new uint[] { 813, 8, 90, 1602 }; - public static pbd::MessageDescriptor Descriptor { + public static pbr::MessageDescriptor Descriptor { get { return global::Google.Protobuf.TestProtos.UnittestProto3.Descriptor.MessageTypes[11]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestFieldOrderings__FieldAccessorTable; } } @@ -3313,6 +3361,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (MyInt != 0L) { output.WriteRawTag(8); @@ -3414,11 +3466,11 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "bb", "oo" }; private static readonly uint[] _fieldTags = new uint[] { 8, 16 }; - public static pbd::MessageDescriptor Descriptor { + public static pbr::MessageDescriptor Descriptor { get { return global::Google.Protobuf.TestProtos.TestFieldOrderings.Descriptor.NestedTypes[0]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestFieldOrderings_NestedMessage__FieldAccessorTable; } } @@ -3490,6 +3542,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (Bb != 0) { output.WriteRawTag(8); @@ -3561,11 +3617,11 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "sparse_enum" }; private static readonly uint[] _fieldTags = new uint[] { 8 }; - public static pbd::MessageDescriptor Descriptor { + public static pbr::MessageDescriptor Descriptor { get { return global::Google.Protobuf.TestProtos.UnittestProto3.Descriptor.MessageTypes[12]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_SparseEnumMessage__FieldAccessorTable; } } @@ -3624,6 +3680,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (SparseEnum != global::Google.Protobuf.TestProtos.TestSparseEnum.TEST_SPARSE_ENUM_UNSPECIFIED) { output.WriteRawTag(8); @@ -3676,11 +3736,11 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "data" }; private static readonly uint[] _fieldTags = new uint[] { 10 }; - public static pbd::MessageDescriptor Descriptor { + public static pbr::MessageDescriptor Descriptor { get { return global::Google.Protobuf.TestProtos.UnittestProto3.Descriptor.MessageTypes[13]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_OneString__FieldAccessorTable; } } @@ -3739,6 +3799,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (Data.Length != 0) { output.WriteRawTag(10); @@ -3791,11 +3855,11 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "data" }; private static readonly uint[] _fieldTags = new uint[] { 10 }; - public static pbd::MessageDescriptor Descriptor { + public static pbr::MessageDescriptor Descriptor { get { return global::Google.Protobuf.TestProtos.UnittestProto3.Descriptor.MessageTypes[14]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_MoreString__FieldAccessorTable; } } @@ -3853,6 +3917,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { data_.WriteTo(output, _repeated_data_codec); } @@ -3898,11 +3966,11 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "data" }; private static readonly uint[] _fieldTags = new uint[] { 10 }; - public static pbd::MessageDescriptor Descriptor { + public static pbr::MessageDescriptor Descriptor { get { return global::Google.Protobuf.TestProtos.UnittestProto3.Descriptor.MessageTypes[15]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_OneBytes__FieldAccessorTable; } } @@ -3961,6 +4029,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (Data.Length != 0) { output.WriteRawTag(10); @@ -4013,11 +4085,11 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "data" }; private static readonly uint[] _fieldTags = new uint[] { 10 }; - public static pbd::MessageDescriptor Descriptor { + public static pbr::MessageDescriptor Descriptor { get { return global::Google.Protobuf.TestProtos.UnittestProto3.Descriptor.MessageTypes[16]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_MoreBytes__FieldAccessorTable; } } @@ -4076,6 +4148,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (Data.Length != 0) { output.WriteRawTag(10); @@ -4128,11 +4204,11 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "data" }; private static readonly uint[] _fieldTags = new uint[] { 8 }; - public static pbd::MessageDescriptor Descriptor { + public static pbr::MessageDescriptor Descriptor { get { return global::Google.Protobuf.TestProtos.UnittestProto3.Descriptor.MessageTypes[17]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_Int32Message__FieldAccessorTable; } } @@ -4191,6 +4267,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (Data != 0) { output.WriteRawTag(8); @@ -4243,11 +4323,11 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "data" }; private static readonly uint[] _fieldTags = new uint[] { 8 }; - public static pbd::MessageDescriptor Descriptor { + public static pbr::MessageDescriptor Descriptor { get { return global::Google.Protobuf.TestProtos.UnittestProto3.Descriptor.MessageTypes[18]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_Uint32Message__FieldAccessorTable; } } @@ -4306,6 +4386,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (Data != 0) { output.WriteRawTag(8); @@ -4358,11 +4442,11 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "data" }; private static readonly uint[] _fieldTags = new uint[] { 8 }; - public static pbd::MessageDescriptor Descriptor { + public static pbr::MessageDescriptor Descriptor { get { return global::Google.Protobuf.TestProtos.UnittestProto3.Descriptor.MessageTypes[19]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_Int64Message__FieldAccessorTable; } } @@ -4421,6 +4505,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (Data != 0L) { output.WriteRawTag(8); @@ -4473,11 +4561,11 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "data" }; private static readonly uint[] _fieldTags = new uint[] { 8 }; - public static pbd::MessageDescriptor Descriptor { + public static pbr::MessageDescriptor Descriptor { get { return global::Google.Protobuf.TestProtos.UnittestProto3.Descriptor.MessageTypes[20]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_Uint64Message__FieldAccessorTable; } } @@ -4536,6 +4624,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (Data != 0UL) { output.WriteRawTag(8); @@ -4588,11 +4680,11 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "data" }; private static readonly uint[] _fieldTags = new uint[] { 8 }; - public static pbd::MessageDescriptor Descriptor { + public static pbr::MessageDescriptor Descriptor { get { return global::Google.Protobuf.TestProtos.UnittestProto3.Descriptor.MessageTypes[21]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_BoolMessage__FieldAccessorTable; } } @@ -4651,6 +4743,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (Data != false) { output.WriteRawTag(8); @@ -4703,11 +4799,11 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "foo_int", "foo_message", "foo_string" }; private static readonly uint[] _fieldTags = new uint[] { 8, 26, 18 }; - public static pbd::MessageDescriptor Descriptor { + public static pbr::MessageDescriptor Descriptor { get { return global::Google.Protobuf.TestProtos.UnittestProto3.Descriptor.MessageTypes[22]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestOneof__FieldAccessorTable; } } @@ -4820,6 +4916,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (fooCase_ == FooOneofCase.FooInt) { output.WriteRawTag(8); @@ -4908,11 +5008,11 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "packed_bool", "packed_double", "packed_enum", "packed_fixed32", "packed_fixed64", "packed_float", "packed_int32", "packed_int64", "packed_sfixed32", "packed_sfixed64", "packed_sint32", "packed_sint64", "packed_uint32", "packed_uint64" }; private static readonly uint[] _fieldTags = new uint[] { 818, 810, 826, 770, 778, 802, 722, 730, 786, 794, 754, 762, 738, 746 }; - public static pbd::MessageDescriptor Descriptor { + public static pbr::MessageDescriptor Descriptor { get { return global::Google.Protobuf.TestProtos.UnittestProto3.Descriptor.MessageTypes[23]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestPackedTypes__FieldAccessorTable; } } @@ -5125,6 +5225,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { packedInt32_.WriteTo(output, _repeated_packedInt32_codec); packedInt64_.WriteTo(output, _repeated_packedInt64_codec); @@ -5275,11 +5379,11 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "unpacked_bool", "unpacked_double", "unpacked_enum", "unpacked_fixed32", "unpacked_fixed64", "unpacked_float", "unpacked_int32", "unpacked_int64", "unpacked_sfixed32", "unpacked_sfixed64", "unpacked_sint32", "unpacked_sint64", "unpacked_uint32", "unpacked_uint64" }; private static readonly uint[] _fieldTags = new uint[] { 816, 809, 824, 773, 777, 805, 720, 728, 789, 793, 752, 760, 736, 744 }; - public static pbd::MessageDescriptor Descriptor { + public static pbr::MessageDescriptor Descriptor { get { return global::Google.Protobuf.TestProtos.UnittestProto3.Descriptor.MessageTypes[24]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestUnpackedTypes__FieldAccessorTable; } } @@ -5492,6 +5596,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { unpackedInt32_.WriteTo(output, _repeated_unpackedInt32_codec); unpackedInt64_.WriteTo(output, _repeated_unpackedInt64_codec); @@ -5642,11 +5750,11 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "repeated_fixed32", "repeated_fixed64", "repeated_float", "repeated_int32", "repeated_int64", "repeated_uint64" }; private static readonly uint[] _fieldTags = new uint[] { 98, 16370, 2097138, 106, 16378, 2097146 }; - public static pbd::MessageDescriptor Descriptor { + public static pbr::MessageDescriptor Descriptor { get { return global::Google.Protobuf.TestProtos.UnittestProto3.Descriptor.MessageTypes[25]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestRepeatedScalarDifferentTagSizes__FieldAccessorTable; } } @@ -5764,6 +5872,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { repeatedFixed32_.WriteTo(output, _repeated_repeatedFixed32_codec); repeatedInt32_.WriteTo(output, _repeated_repeatedInt32_codec); @@ -5850,11 +5962,11 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "a" }; private static readonly uint[] _fieldTags = new uint[] { 10 }; - public static pbd::MessageDescriptor Descriptor { + public static pbr::MessageDescriptor Descriptor { get { return global::Google.Protobuf.TestProtos.UnittestProto3.Descriptor.MessageTypes[26]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestCommentInjectionMessage__FieldAccessorTable; } } @@ -5913,6 +6025,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (A.Length != 0) { output.WriteRawTag(10); @@ -5965,11 +6081,11 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { }; private static readonly uint[] _fieldTags = new uint[] { }; - public static pbd::MessageDescriptor Descriptor { + public static pbr::MessageDescriptor Descriptor { get { return global::Google.Protobuf.TestProtos.UnittestProto3.Descriptor.MessageTypes[27]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_FooRequest__FieldAccessorTable; } } @@ -6015,6 +6131,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { } @@ -6053,11 +6173,11 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { }; private static readonly uint[] _fieldTags = new uint[] { }; - public static pbd::MessageDescriptor Descriptor { + public static pbr::MessageDescriptor Descriptor { get { return global::Google.Protobuf.TestProtos.UnittestProto3.Descriptor.MessageTypes[28]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_FooResponse__FieldAccessorTable; } } @@ -6103,6 +6223,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { } @@ -6141,11 +6265,11 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { }; private static readonly uint[] _fieldTags = new uint[] { }; - public static pbd::MessageDescriptor Descriptor { + public static pbr::MessageDescriptor Descriptor { get { return global::Google.Protobuf.TestProtos.UnittestProto3.Descriptor.MessageTypes[29]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_FooClientMessage__FieldAccessorTable; } } @@ -6191,6 +6315,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { } @@ -6229,11 +6357,11 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { }; private static readonly uint[] _fieldTags = new uint[] { }; - public static pbd::MessageDescriptor Descriptor { + public static pbr::MessageDescriptor Descriptor { get { return global::Google.Protobuf.TestProtos.UnittestProto3.Descriptor.MessageTypes[30]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_FooServerMessage__FieldAccessorTable; } } @@ -6279,6 +6407,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { } @@ -6317,11 +6449,11 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { }; private static readonly uint[] _fieldTags = new uint[] { }; - public static pbd::MessageDescriptor Descriptor { + public static pbr::MessageDescriptor Descriptor { get { return global::Google.Protobuf.TestProtos.UnittestProto3.Descriptor.MessageTypes[31]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_BarRequest__FieldAccessorTable; } } @@ -6367,6 +6499,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { } @@ -6405,11 +6541,11 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { }; private static readonly uint[] _fieldTags = new uint[] { }; - public static pbd::MessageDescriptor Descriptor { + public static pbr::MessageDescriptor Descriptor { get { return global::Google.Protobuf.TestProtos.UnittestProto3.Descriptor.MessageTypes[32]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_BarResponse__FieldAccessorTable; } } @@ -6455,6 +6591,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { } diff --git a/csharp/src/ProtocolBuffers/ByteString.cs b/csharp/src/ProtocolBuffers/ByteString.cs index d5b7aee9..738f020e 100644 --- a/csharp/src/ProtocolBuffers/ByteString.cs +++ b/csharp/src/ProtocolBuffers/ByteString.cs @@ -134,6 +134,8 @@ namespace Google.Protobuf /// Constructs a ByteString from the given array. The contents
/// are copied, so further modifications to the array will not
/// be reflected in the returned ByteString.
+ /// This method can also be invoked in <c>ByteString.CopyFrom(0xaa, 0xbb, ...)</c> form
+ /// which is primarily useful for testing.
/// </summary>
public static ByteString CopyFrom(params byte[] bytes)
{
diff --git a/csharp/src/ProtocolBuffers/Collections/RepeatedField.cs b/csharp/src/ProtocolBuffers/Collections/RepeatedField.cs index b6b52cb9..8375ae0b 100644 --- a/csharp/src/ProtocolBuffers/Collections/RepeatedField.cs +++ b/csharp/src/ProtocolBuffers/Collections/RepeatedField.cs @@ -44,9 +44,9 @@ namespace Google.Protobuf.Collections public sealed class RepeatedField<T> : IList<T>, IList, IDeepCloneable<RepeatedField<T>>, IEquatable<RepeatedField<T>>, IFreezable { private static readonly T[] EmptyArray = new T[0]; + private const int MinArraySize = 8; private bool frozen; - private const int MinArraySize = 8; private T[] array = EmptyArray; private int count = 0; @@ -259,7 +259,6 @@ namespace Google.Protobuf.Collections public int Count { get { return count; } } - // TODO(jonskeet): If we implement freezing, make this reflect it. public bool IsReadOnly { get { return IsFrozen; } } public void Add(RepeatedField<T> values) @@ -289,14 +288,12 @@ namespace Google.Protobuf.Collections } } - public RepeatedField<T>.Enumerator GetEnumerator() - { - return new Enumerator(this); - } - - IEnumerator<T> IEnumerable<T>.GetEnumerator() + public IEnumerator<T> GetEnumerator() { - return GetEnumerator(); + for (int i = 0; i < count; i++) + { + yield return array[i]; + } } public override bool Equals(object obj) @@ -468,55 +465,6 @@ namespace Google.Protobuf.Collections } Remove((T)value); } - #endregion - - public struct Enumerator : IEnumerator<T> - { - private int index; - private readonly RepeatedField<T> field; - - public Enumerator(RepeatedField<T> field) - { - this.field = field; - this.index = -1; - } - - public bool MoveNext() - { - if (index + 1 >= field.Count) - { - index = field.Count; - return false; - } - index++; - return true; - } - - public void Reset() - { - index = -1; - } - - public T Current - { - get - { - if (index == -1 || index >= field.count) - { - throw new InvalidOperationException(); - } - return field.array[index]; - } - } - - object IEnumerator.Current - { - get { return Current; } - } - - public void Dispose() - { - } - } + #endregion } } diff --git a/csharp/src/ProtocolBuffers/FrameworkPortability.cs b/csharp/src/ProtocolBuffers/FrameworkPortability.cs index f3da5333..082eb2e1 100644 --- a/csharp/src/ProtocolBuffers/FrameworkPortability.cs +++ b/csharp/src/ProtocolBuffers/FrameworkPortability.cs @@ -40,6 +40,7 @@ namespace Google.Protobuf /// </summary>
internal static class FrameworkPortability
{
+ // TODO(jtattermusch): is this still a thing?
// The value of RegexOptions.Compiled is 8. We can test for the presence at
// execution time using Enum.IsDefined, so a single build will do the right thing
// on each platform.
diff --git a/csharp/src/ProtocolBuffers/Google.Protobuf.nuspec b/csharp/src/ProtocolBuffers/Google.Protobuf.nuspec new file mode 100644 index 00000000..9b5e1c83 --- /dev/null +++ b/csharp/src/ProtocolBuffers/Google.Protobuf.nuspec @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="utf-8"?> +<package> + <metadata> + <id>Google.Protobuf</id> + <title>Google Protocol Buffers C#</title> + <summary>C# runtime library for Protocol Buffers - Google's data interchange format.</summary> + <description>See project site for more info.</description> + <version>3.0.0-beta*</version> + <authors>Google Inc.</authors> + <owners>protobuf-packages</owners> + <licenseUrl>https://github.com/google/protobuf/blob/master/LICENSE</licenseUrl> + <projectUrl>https://github.com/google/protobuf</projectUrl> + <requireLicenseAcceptance>false</requireLicenseAcceptance> + <releaseNotes>Experimental version of C# Protocol Buffers</releaseNotes> + <copyright>Copyright 2015, Google Inc.</copyright> + <tags>Protocol Buffers Binary Serialization Format Google proto proto3</tags> + </metadata> + <files> + <file src="bin/Release/Google.Protobuf.dll" target="lib/portable-net45+win8+wp8+wpa81" /> + <file src="bin/Release/Google.Protobuf.pdb" target="lib/portable-net45+win8+wp8+wpa81" /> + <file src="bin/Release/Google.Protobuf.xml" target="lib/portable-net45+win8+wp8+wpa81" /> + <file src="**\*.cs" target="src" /> + </files> +</package> diff --git a/csharp/src/ProtocolBuffers/IMessage.cs b/csharp/src/ProtocolBuffers/IMessage.cs index ad44668c..8c4a4aaf 100644 --- a/csharp/src/ProtocolBuffers/IMessage.cs +++ b/csharp/src/ProtocolBuffers/IMessage.cs @@ -31,7 +31,7 @@ #endregion
using System;
-using Google.Protobuf.FieldAccess;
+using Google.Protobuf.Reflection;
namespace Google.Protobuf
{
@@ -40,9 +40,9 @@ namespace Google.Protobuf // TODO(jonskeet): Split these interfaces into separate files when we're happy with them.
/// <summary>
- /// Reflection support for a specific message type.
+ /// Reflection support for accessing field values.
/// </summary>
- public interface IReflectedMessage
+ public interface IReflectedMessage : IMessage
{
FieldAccessorTable Fields { get; }
// TODO(jonskeet): Descriptor? Or a single property which has "all you need for reflection"?
@@ -81,7 +81,7 @@ namespace Google.Protobuf /// the implementation class.
/// </summary>
/// <typeparam name="T">The message type.</typeparam>
- public interface IMessage<T> : IMessage, IEquatable<T>, IDeepCloneable<T>, IFreezable where T : IMessage<T>
+ public interface IMessage<T> : IReflectedMessage, IEquatable<T>, IDeepCloneable<T>, IFreezable where T : IMessage<T>
{
/// <summary>
/// Merges the given message into this one.
diff --git a/csharp/src/ProtocolBuffers/InvalidProtocolBufferException.cs b/csharp/src/ProtocolBuffers/InvalidProtocolBufferException.cs index 87b283f2..4f89347d 100644 --- a/csharp/src/ProtocolBuffers/InvalidProtocolBufferException.cs +++ b/csharp/src/ProtocolBuffers/InvalidProtocolBufferException.cs @@ -79,12 +79,6 @@ namespace Google.Protobuf "Protocol message end-group tag did not match expected tag.");
}
- internal static InvalidProtocolBufferException InvalidWireType()
- {
- return new InvalidProtocolBufferException(
- "Protocol message tag had invalid wire type.");
- }
-
internal static InvalidProtocolBufferException RecursionLimitExceeded()
{
return new InvalidProtocolBufferException(
diff --git a/csharp/src/ProtocolBuffers/JsonFormatter.cs b/csharp/src/ProtocolBuffers/JsonFormatter.cs new file mode 100644 index 00000000..dacc7221 --- /dev/null +++ b/csharp/src/ProtocolBuffers/JsonFormatter.cs @@ -0,0 +1,578 @@ +#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2015 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +using System; +using System.Collections; +using System.Globalization; +using System.Text; +using Google.Protobuf.Reflection; + +namespace Google.Protobuf +{ + /// <summary> + /// Reflection-based converter from messages to JSON. + /// </summary> + /// <remarks> + /// <para> + /// Instances of this class are thread-safe, with no mutable state. + /// </para> + /// <para> + /// This is a simple start to get JSON formatting working. As it's reflection-based, + /// it's not as quick as baking calls into generated messages - but is a simpler implementation. + /// (This code is generally not heavily optimized.) + /// </para> + /// </remarks> + public sealed class JsonFormatter + { + private static JsonFormatter defaultInstance = new JsonFormatter(Settings.Default); + + /// <summary> + /// Returns a formatter using the default settings. + /// </summary> + public static JsonFormatter Default { get { return defaultInstance; } } + + /// <summary> + /// The JSON representation of the first 160 characters of Unicode. + /// Empty strings are replaced by the static constructor. + /// </summary> + private static readonly string[] CommonRepresentations = { + // C0 (ASCII and derivatives) control characters + "\\u0000", "\\u0001", "\\u0002", "\\u0003", // 0x00 + "\\u0004", "\\u0005", "\\u0006", "\\u0007", + "\\b", "\\t", "\\n", "\\u000b", + "\\f", "\\r", "\\u000e", "\\u000f", + "\\u0010", "\\u0011", "\\u0012", "\\u0013", // 0x10 + "\\u0014", "\\u0015", "\\u0016", "\\u0017", + "\\u0018", "\\u0019", "\\u001a", "\\u001b", + "\\u001c", "\\u001d", "\\u001e", "\\u001f", + // Escaping of " and \ are required by www.json.org string definition. + // Escaping of < and > are required for HTML security. + "", "", "\\\"", "", "", "", "", "", // 0x20 + "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", // 0x30 + "", "", "", "", "\\u003c", "", "\\u003e", "", + "", "", "", "", "", "", "", "", // 0x40 + "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", // 0x50 + "", "", "", "", "\\\\", "", "", "", + "", "", "", "", "", "", "", "", // 0x60 + "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", // 0x70 + "", "", "", "", "", "", "", "\\u007f", + // C1 (ISO 8859 and Unicode) extended control characters + "\\u0080", "\\u0081", "\\u0082", "\\u0083", // 0x80 + "\\u0084", "\\u0085", "\\u0086", "\\u0087", + "\\u0088", "\\u0089", "\\u008a", "\\u008b", + "\\u008c", "\\u008d", "\\u008e", "\\u008f", + "\\u0090", "\\u0091", "\\u0092", "\\u0093", // 0x90 + "\\u0094", "\\u0095", "\\u0096", "\\u0097", + "\\u0098", "\\u0099", "\\u009a", "\\u009b", + "\\u009c", "\\u009d", "\\u009e", "\\u009f" + }; + + static JsonFormatter() + { + for (int i = 0; i < CommonRepresentations.Length; i++) + { + if (CommonRepresentations[i] == "") + { + CommonRepresentations[i] = ((char) i).ToString(); + } + } + } + + private readonly Settings settings; + + public JsonFormatter(Settings settings) + { + this.settings = settings; + } + + public string Format(IReflectedMessage message) + { + ThrowHelper.ThrowIfNull(message, "message"); + StringBuilder builder = new StringBuilder(); + WriteMessage(builder, message); + return builder.ToString(); + } + + private void WriteMessage(StringBuilder builder, IReflectedMessage message) + { + if (message == null) + { + WriteNull(builder); + return; + } + builder.Append("{ "); + var fields = message.Fields; + bool first = true; + // First non-oneof fields + foreach (var accessor in fields.Accessors) + { + var descriptor = accessor.Descriptor; + // Oneofs are written later + // TODO: Change to write out fields in order, interleaving oneofs appropriately (as per binary format) + if (descriptor.ContainingOneof != null) + { + continue; + } + // Omit default values unless we're asked to format them + object value = accessor.GetValue(message); + if (!settings.FormatDefaultValues && IsDefaultValue(accessor, value)) + { + continue; + } + // Omit awkward (single) values such as unknown enum values + if (!descriptor.IsRepeated && !descriptor.IsMap && !CanWriteSingleValue(accessor.Descriptor, value)) + { + continue; + } + + // Okay, all tests complete: let's write the field value... + if (!first) + { + builder.Append(", "); + } + WriteString(builder, ToCamelCase(accessor.Descriptor.Name)); + builder.Append(": "); + WriteValue(builder, accessor, value); + first = false; + } + + // Now oneofs + foreach (var accessor in fields.Oneofs) + { + var fieldDescriptor = accessor.GetCaseFieldDescriptor(message); + if (fieldDescriptor == null) + { + continue; + } + var fieldAccessor = fields[fieldDescriptor.FieldNumber]; + object value = fieldAccessor.GetValue(message); + // Omit awkward (single) values such as unknown enum values + if (!fieldDescriptor.IsRepeated && !fieldDescriptor.IsMap && !CanWriteSingleValue(fieldDescriptor, value)) + { + continue; + } + + if (!first) + { + builder.Append(", "); + } + WriteString(builder, ToCamelCase(fieldDescriptor.Name)); + builder.Append(": "); + WriteValue(builder, fieldAccessor, value); + first = false; + } + builder.Append(first ? "}" : " }"); + } + + // Converted from src/google/protobuf/util/internal/utility.cc ToCamelCase + internal static string ToCamelCase(string input) + { + bool capitalizeNext = false; + bool wasCap = true; + bool isCap = false; + bool firstWord = true; + StringBuilder result = new StringBuilder(input.Length); + + for (int i = 0; i < input.Length; i++, wasCap = isCap) + { + isCap = char.IsUpper(input[i]); + if (input[i] == '_') + { + capitalizeNext = true; + if (result.Length != 0) + { + firstWord = false; + } + continue; + } + else if (firstWord) + { + // Consider when the current character B is capitalized, + // first word ends when: + // 1) following a lowercase: "...aB..." + // 2) followed by a lowercase: "...ABc..." + if (result.Length != 0 && isCap && + (!wasCap || (i + 1 < input.Length && char.IsLower(input[i + 1])))) + { + firstWord = false; + } + else + { + result.Append(char.ToLowerInvariant(input[i])); + continue; + } + } + else if (capitalizeNext) + { + capitalizeNext = false; + if (char.IsLower(input[i])) + { + result.Append(char.ToUpperInvariant(input[i])); + continue; + } + } + result.Append(input[i]); + } + return result.ToString(); + } + + private static void WriteNull(StringBuilder builder) + { + builder.Append("null"); + } + + private static bool IsDefaultValue(IFieldAccessor accessor, object value) + { + if (accessor.Descriptor.IsMap) + { + IDictionary dictionary = (IDictionary) value; + return dictionary.Count == 0; + } + if (accessor.Descriptor.IsRepeated) + { + IList list = (IList) value; + return list.Count == 0; + } + switch (accessor.Descriptor.FieldType) + { + case FieldType.Bool: + return (bool) value == false; + case FieldType.Bytes: + return (ByteString) value == ByteString.Empty; + case FieldType.String: + return (string) value == ""; + case FieldType.Double: + return (double) value == 0.0; + case FieldType.SInt32: + case FieldType.Int32: + case FieldType.SFixed32: + case FieldType.Enum: + return (int) value == 0; + case FieldType.Fixed32: + case FieldType.UInt32: + return (uint) value == 0; + case FieldType.Fixed64: + case FieldType.UInt64: + return (ulong) value == 0; + case FieldType.SFixed64: + case FieldType.Int64: + case FieldType.SInt64: + return (long) value == 0; + case FieldType.Float: + return (float) value == 0f; + case FieldType.Message: + case FieldType.Group: // Never expect to get this, but... + return value == null; + default: + throw new ArgumentException("Invalid field type"); + } + } + + private void WriteValue(StringBuilder builder, IFieldAccessor accessor, object value) + { + if (accessor.Descriptor.IsMap) + { + WriteDictionary(builder, accessor, (IDictionary) value); + } + else if (accessor.Descriptor.IsRepeated) + { + WriteList(builder, accessor, (IList) value); + } + else + { + WriteSingleValue(builder, accessor.Descriptor, value); + } + } + + private void WriteSingleValue(StringBuilder builder, FieldDescriptor descriptor, object value) + { + switch (descriptor.FieldType) + { + case FieldType.Bool: + builder.Append((bool) value ? "true" : "false"); + break; + case FieldType.Bytes: + // Nothing in Base64 needs escaping + builder.Append('"'); + builder.Append(((ByteString) value).ToBase64()); + builder.Append('"'); + break; + case FieldType.String: + WriteString(builder, (string) value); + break; + case FieldType.Fixed32: + case FieldType.UInt32: + case FieldType.SInt32: + case FieldType.Int32: + case FieldType.SFixed32: + { + IFormattable formattable = (IFormattable) value; + builder.Append(formattable.ToString("d", CultureInfo.InvariantCulture)); + break; + } + case FieldType.Enum: + EnumValueDescriptor enumValue = descriptor.EnumType.FindValueByNumber((int) value); + // We will already have validated that this is a known value. + WriteString(builder, enumValue.Name); + break; + case FieldType.Fixed64: + case FieldType.UInt64: + case FieldType.SFixed64: + case FieldType.Int64: + case FieldType.SInt64: + { + builder.Append('"'); + IFormattable formattable = (IFormattable) value; + builder.Append(formattable.ToString("d", CultureInfo.InvariantCulture)); + builder.Append('"'); + break; + } + case FieldType.Double: + case FieldType.Float: + string text = ((IFormattable) value).ToString("r", CultureInfo.InvariantCulture); + if (text == "NaN" || text == "Infinity" || text == "-Infinity") + { + builder.Append('"'); + builder.Append(text); + builder.Append('"'); + } + else + { + builder.Append(text); + } + break; + case FieldType.Message: + case FieldType.Group: // Never expect to get this, but... + WriteMessage(builder, (IReflectedMessage) value); + break; + default: + throw new ArgumentException("Invalid field type: " + descriptor.FieldType); + } + } + + private void WriteList(StringBuilder builder, IFieldAccessor accessor, IList list) + { + builder.Append("[ "); + bool first = true; + foreach (var value in list) + { + if (!CanWriteSingleValue(accessor.Descriptor, value)) + { + continue; + } + if (!first) + { + builder.Append(", "); + } + WriteSingleValue(builder, accessor.Descriptor, value); + first = false; + } + builder.Append(first ? "]" : " ]"); + } + + private void WriteDictionary(StringBuilder builder, IFieldAccessor accessor, IDictionary dictionary) + { + builder.Append("{ "); + bool first = true; + FieldDescriptor keyType = accessor.Descriptor.MessageType.FindFieldByNumber(1); + FieldDescriptor valueType = accessor.Descriptor.MessageType.FindFieldByNumber(2); + // This will box each pair. Could use IDictionaryEnumerator, but that's ugly in terms of disposal. + foreach (DictionaryEntry pair in dictionary) + { + if (!CanWriteSingleValue(valueType, pair.Value)) + { + continue; + } + if (!first) + { + builder.Append(", "); + } + string keyText; + switch (keyType.FieldType) + { + case FieldType.String: + keyText = (string) pair.Key; + break; + case FieldType.Bool: + keyText = (bool) pair.Key ? "true" : "false"; + break; + case FieldType.Fixed32: + case FieldType.Fixed64: + case FieldType.SFixed32: + case FieldType.SFixed64: + case FieldType.Int32: + case FieldType.Int64: + case FieldType.SInt32: + case FieldType.SInt64: + case FieldType.UInt32: + case FieldType.UInt64: + keyText = ((IFormattable) pair.Key).ToString("d", CultureInfo.InvariantCulture); + break; + default: + throw new ArgumentException("Invalid key type: " + keyType.FieldType); + } + WriteString(builder, keyText); + builder.Append(": "); + WriteSingleValue(builder, valueType, pair.Value); + first = false; + } + builder.Append(first ? "}" : " }"); + } + + /// <summary> + /// Returns whether or not a singular value can be represented in JSON. + /// Currently only relevant for enums, where unknown values can't be represented. + /// For repeated/map fields, this always returns true. + /// </summary> + private bool CanWriteSingleValue(FieldDescriptor descriptor, object value) + { + if (descriptor.FieldType == FieldType.Enum) + { + EnumValueDescriptor enumValue = descriptor.EnumType.FindValueByNumber((int) value); + return enumValue != null; + } + return true; + } + + /// <summary> + /// Writes a string (including leading and trailing double quotes) to a builder, escaping as required. + /// </summary> + /// <remarks> + /// Other than surrogate pair handling, this code is mostly taken from src/google/protobuf/util/internal/json_escaping.cc. + /// </remarks> + private void WriteString(StringBuilder builder, string text) + { + builder.Append('"'); + for (int i = 0; i < text.Length; i++) + { + char c = text[i]; + if (c < 0xa0) + { + builder.Append(CommonRepresentations[c]); + continue; + } + if (char.IsHighSurrogate(c)) + { + // Encountered first part of a surrogate pair. + // Check that we have the whole pair, and encode both parts as hex. + i++; + if (i == text.Length || !char.IsLowSurrogate(text[i])) + { + throw new ArgumentException("String contains low surrogate not followed by high surrogate"); + } + HexEncodeUtf16CodeUnit(builder, c); + HexEncodeUtf16CodeUnit(builder, text[i]); + continue; + } + else if (char.IsLowSurrogate(c)) + { + throw new ArgumentException("String contains high surrogate not preceded by low surrogate"); + } + switch ((uint) c) + { + // These are not required by json spec + // but used to prevent security bugs in javascript. + case 0xfeff: // Zero width no-break space + case 0xfff9: // Interlinear annotation anchor + case 0xfffa: // Interlinear annotation separator + case 0xfffb: // Interlinear annotation terminator + + case 0x00ad: // Soft-hyphen + case 0x06dd: // Arabic end of ayah + case 0x070f: // Syriac abbreviation mark + case 0x17b4: // Khmer vowel inherent Aq + case 0x17b5: // Khmer vowel inherent Aa + HexEncodeUtf16CodeUnit(builder, c); + break; + + default: + if ((c >= 0x0600 && c <= 0x0603) || // Arabic signs + (c >= 0x200b && c <= 0x200f) || // Zero width etc. + (c >= 0x2028 && c <= 0x202e) || // Separators etc. + (c >= 0x2060 && c <= 0x2064) || // Invisible etc. + (c >= 0x206a && c <= 0x206f)) + { + HexEncodeUtf16CodeUnit(builder, c); + } + else + { + // No handling of surrogates here - that's done earlier + builder.Append(c); + } + break; + } + } + builder.Append('"'); + } + + private const string Hex = "0123456789abcdef"; + private static void HexEncodeUtf16CodeUnit(StringBuilder builder, char c) + { + uint utf16 = c; + builder.Append("\\u"); + builder.Append(Hex[(c >> 12) & 0xf]); + builder.Append(Hex[(c >> 8) & 0xf]); + builder.Append(Hex[(c >> 4) & 0xf]); + builder.Append(Hex[(c >> 0) & 0xf]); + } + + /// <summary> + /// Settings controlling JSON formatting. + /// </summary> + public sealed class Settings + { + private static readonly Settings defaultInstance = new Settings(false); + + /// <summary> + /// Default settings, as used by <see cref="JsonFormatter.Default"/> + /// </summary> + public static Settings Default { get { return defaultInstance; } } + + private readonly bool formatDefaultValues; + + + /// <summary> + /// Whether fields whose values are the default for the field type (e.g. 0 for integers) + /// should be formatted (true) or omitted (false). + /// </summary> + public bool FormatDefaultValues { get { return formatDefaultValues; } } + + public Settings(bool formatDefaultValues) + { + this.formatDefaultValues = formatDefaultValues; + } + } + } +} diff --git a/csharp/src/ProtocolBuffers/ProtocolBuffers.csproj b/csharp/src/ProtocolBuffers/ProtocolBuffers.csproj index aa4adcc0..402d6612 100644 --- a/csharp/src/ProtocolBuffers/ProtocolBuffers.csproj +++ b/csharp/src/ProtocolBuffers/ProtocolBuffers.csproj @@ -60,43 +60,57 @@ <Compile Include="Collections\MapField.cs" />
<Compile Include="Collections\ReadOnlyDictionary.cs" />
<Compile Include="Collections\RepeatedField.cs" />
- <Compile Include="DescriptorProtos\DescriptorProtoFile.cs" />
- <Compile Include="DescriptorProtos\PartialClasses.cs" />
- <Compile Include="Descriptors\DescriptorBase.cs" />
- <Compile Include="Descriptors\DescriptorPool.cs" />
- <Compile Include="Descriptors\DescriptorUtil.cs" />
- <Compile Include="Descriptors\DescriptorValidationException.cs" />
- <Compile Include="Descriptors\EnumDescriptor.cs" />
- <Compile Include="Descriptors\EnumValueDescriptor.cs" />
- <Compile Include="Descriptors\FieldDescriptor.cs" />
- <Compile Include="Descriptors\FieldType.cs" />
- <Compile Include="Descriptors\FileDescriptor.cs" />
- <Compile Include="Descriptors\OneofDescriptor.cs" />
- <Compile Include="Descriptors\IDescriptor.cs" />
- <Compile Include="Descriptors\MessageDescriptor.cs" />
- <Compile Include="Descriptors\MethodDescriptor.cs" />
- <Compile Include="Descriptors\PackageDescriptor.cs" />
- <Compile Include="Descriptors\ServiceDescriptor.cs" />
- <Compile Include="FieldAccess\MapFieldAccessor.cs" />
<Compile Include="FieldCodec.cs" />
<Compile Include="FrameworkPortability.cs" />
<Compile Include="Freezable.cs" />
+ <Compile Include="JsonFormatter.cs" />
<Compile Include="MessageExtensions.cs" />
- <Compile Include="FieldAccess\FieldAccessorBase.cs" />
- <Compile Include="FieldAccess\ReflectionUtil.cs" />
- <Compile Include="FieldAccess\RepeatedFieldAccessor.cs" />
- <Compile Include="FieldAccess\SingleFieldAccessor.cs" />
- <Compile Include="FieldAccess\IFieldAccessor.cs" />
- <Compile Include="FieldAccess\FieldAccessorTable.cs" />
- <Compile Include="FieldAccess\OneofAccessor.cs" />
<Compile Include="IMessage.cs" />
<Compile Include="InvalidProtocolBufferException.cs" />
<Compile Include="LimitedInputStream.cs" />
<Compile Include="MessageParser.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="Reflection\DescriptorBase.cs" />
+ <Compile Include="Reflection\DescriptorPool.cs" />
+ <Compile Include="Reflection\DescriptorProtoFile.cs" />
+ <Compile Include="Reflection\DescriptorUtil.cs" />
+ <Compile Include="Reflection\DescriptorValidationException.cs" />
+ <Compile Include="Reflection\EnumDescriptor.cs" />
+ <Compile Include="Reflection\EnumValueDescriptor.cs" />
+ <Compile Include="Reflection\FieldAccessorBase.cs" />
+ <Compile Include="Reflection\FieldAccessorTable.cs" />
+ <Compile Include="Reflection\FieldDescriptor.cs" />
+ <Compile Include="Reflection\FieldType.cs" />
+ <Compile Include="Reflection\FileDescriptor.cs" />
+ <Compile Include="Reflection\IDescriptor.cs" />
+ <Compile Include="Reflection\IFieldAccessor.cs" />
+ <Compile Include="Reflection\MapFieldAccessor.cs" />
+ <Compile Include="Reflection\MessageDescriptor.cs" />
+ <Compile Include="Reflection\MethodDescriptor.cs" />
+ <Compile Include="Reflection\OneofAccessor.cs" />
+ <Compile Include="Reflection\OneofDescriptor.cs" />
+ <Compile Include="Reflection\PackageDescriptor.cs" />
+ <Compile Include="Reflection\PartialClasses.cs" />
+ <Compile Include="Reflection\ReflectionUtil.cs" />
+ <Compile Include="Reflection\RepeatedFieldAccessor.cs" />
+ <Compile Include="Reflection\ServiceDescriptor.cs" />
+ <Compile Include="Reflection\SingleFieldAccessor.cs" />
<Compile Include="ThrowHelper.cs" />
+ <Compile Include="WellKnownTypes\Any.cs" />
+ <Compile Include="WellKnownTypes\Api.cs" />
+ <Compile Include="WellKnownTypes\Duration.cs" />
+ <Compile Include="WellKnownTypes\Empty.cs" />
+ <Compile Include="WellKnownTypes\FieldMask.cs" />
+ <Compile Include="WellKnownTypes\SourceContext.cs" />
+ <Compile Include="WellKnownTypes\Struct.cs" />
+ <Compile Include="WellKnownTypes\Timestamp.cs" />
+ <Compile Include="WellKnownTypes\Type.cs" />
+ <Compile Include="WellKnownTypes\Wrappers.cs" />
<Compile Include="WireFormat.cs" />
</ItemGroup>
+ <ItemGroup>
+ <None Include="Google.Protobuf.nuspec" />
+ </ItemGroup>
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
diff --git a/csharp/src/ProtocolBuffers/Descriptors/DescriptorBase.cs b/csharp/src/ProtocolBuffers/Reflection/DescriptorBase.cs index 0eb71215..0300cd58 100644 --- a/csharp/src/ProtocolBuffers/Descriptors/DescriptorBase.cs +++ b/csharp/src/ProtocolBuffers/Reflection/DescriptorBase.cs @@ -1,84 +1,82 @@ -#region Copyright notice and license
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc. All rights reserved.
-// https://developers.google.com/protocol-buffers/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#endregion
-
-using Google.Protobuf.DescriptorProtos;
-
-namespace Google.Protobuf.Descriptors
-{
- /// <summary>
- /// Base class for nearly all descriptors, providing common functionality.
- /// </summary>
- public abstract class DescriptorBase : IDescriptor
- {
- private readonly FileDescriptor file;
- private readonly string fullName;
- private readonly int index;
-
- internal DescriptorBase(FileDescriptor file, string fullName, int index)
- {
- this.file = file;
- this.fullName = fullName;
- this.index = index;
- }
-
- /// <value>
- /// The index of this descriptor within its parent descriptor.
- /// </value>
- /// <remarks>
- /// This returns the index of this descriptor within its parent, for
- /// this descriptor's type. (There can be duplicate values for different
- /// types, e.g. one enum type with index 0 and one message type with index 0.)
- /// </remarks>
- public int Index
- {
- get { return index; }
- }
-
- public abstract string Name { get; }
-
- /// <summary>
- /// The fully qualified name of the descriptor's target.
- /// </summary>
- public string FullName
- {
- get { return fullName; }
- }
-
- /// <value>
- /// The file this descriptor was declared in.
- /// </value>
- public FileDescriptor File
- {
- get { return file; }
- }
- }
+#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +namespace Google.Protobuf.Reflection +{ + /// <summary> + /// Base class for nearly all descriptors, providing common functionality. + /// </summary> + public abstract class DescriptorBase : IDescriptor + { + private readonly FileDescriptor file; + private readonly string fullName; + private readonly int index; + + internal DescriptorBase(FileDescriptor file, string fullName, int index) + { + this.file = file; + this.fullName = fullName; + this.index = index; + } + + /// <value> + /// The index of this descriptor within its parent descriptor. + /// </value> + /// <remarks> + /// This returns the index of this descriptor within its parent, for + /// this descriptor's type. (There can be duplicate values for different + /// types, e.g. one enum type with index 0 and one message type with index 0.) + /// </remarks> + public int Index + { + get { return index; } + } + + public abstract string Name { get; } + + /// <summary> + /// The fully qualified name of the descriptor's target. + /// </summary> + public string FullName + { + get { return fullName; } + } + + /// <value> + /// The file this descriptor was declared in. + /// </value> + public FileDescriptor File + { + get { return file; } + } + } }
\ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/Descriptors/DescriptorPool.cs b/csharp/src/ProtocolBuffers/Reflection/DescriptorPool.cs index b07af060..157ea400 100644 --- a/csharp/src/ProtocolBuffers/Descriptors/DescriptorPool.cs +++ b/csharp/src/ProtocolBuffers/Reflection/DescriptorPool.cs @@ -1,365 +1,365 @@ -#region Copyright notice and license
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc. All rights reserved.
-// https://developers.google.com/protocol-buffers/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#endregion
-
-using System;
-using System.Collections.Generic;
-using System.Text;
-using System.Text.RegularExpressions;
-
-namespace Google.Protobuf.Descriptors
-{
- /// <summary>
- /// Contains lookup tables containing all the descriptors defined in a particular file.
- /// </summary>
- internal sealed class DescriptorPool
- {
- private readonly IDictionary<string, IDescriptor> descriptorsByName =
- new Dictionary<string, IDescriptor>();
-
- private readonly IDictionary<DescriptorIntPair, FieldDescriptor> fieldsByNumber =
- new Dictionary<DescriptorIntPair, FieldDescriptor>();
-
- private readonly IDictionary<DescriptorIntPair, EnumValueDescriptor> enumValuesByNumber =
- new Dictionary<DescriptorIntPair, EnumValueDescriptor>();
-
- private readonly HashSet<FileDescriptor> dependencies;
-
- internal DescriptorPool(FileDescriptor[] dependencyFiles)
- {
- dependencies = new HashSet<FileDescriptor>();
- for (int i = 0; i < dependencyFiles.Length; i++)
- {
- dependencies.Add(dependencyFiles[i]);
- ImportPublicDependencies(dependencyFiles[i]);
- }
-
- foreach (FileDescriptor dependency in dependencyFiles)
- {
- AddPackage(dependency.Package, dependency);
- }
- }
-
- private void ImportPublicDependencies(FileDescriptor file)
- {
- foreach (FileDescriptor dependency in file.PublicDependencies)
- {
- if (dependencies.Add(dependency))
- {
- ImportPublicDependencies(dependency);
- }
- }
- }
-
- /// <summary>
- /// Finds a symbol of the given name within the pool.
- /// </summary>
- /// <typeparam name="T">The type of symbol to look for</typeparam>
- /// <param name="fullName">Fully-qualified name to look up</param>
- /// <returns>The symbol with the given name and type,
- /// or null if the symbol doesn't exist or has the wrong type</returns>
- internal T FindSymbol<T>(string fullName) where T : class
- {
- IDescriptor result;
- descriptorsByName.TryGetValue(fullName, out result);
- T descriptor = result as T;
- if (descriptor != null)
- {
- return descriptor;
- }
-
- foreach (FileDescriptor dependency in dependencies)
- {
- dependency.DescriptorPool.descriptorsByName.TryGetValue(fullName, out result);
- descriptor = result as T;
- if (descriptor != null)
- {
- return descriptor;
- }
- }
-
- return null;
- }
-
- /// <summary>
- /// Adds a package to the symbol tables. If a package by the same name
- /// already exists, that is fine, but if some other kind of symbol
- /// exists under the same name, an exception is thrown. If the package
- /// has multiple components, this also adds the parent package(s).
- /// </summary>
- internal void AddPackage(string fullName, FileDescriptor file)
- {
- int dotpos = fullName.LastIndexOf('.');
- String name;
- if (dotpos != -1)
- {
- AddPackage(fullName.Substring(0, dotpos), file);
- name = fullName.Substring(dotpos + 1);
- }
- else
- {
- name = fullName;
- }
-
- IDescriptor old;
- if (descriptorsByName.TryGetValue(fullName, out old))
- {
- if (!(old is PackageDescriptor))
- {
- throw new DescriptorValidationException(file,
- "\"" + name +
- "\" is already defined (as something other than a " +
- "package) in file \"" + old.File.Name + "\".");
- }
- }
- descriptorsByName[fullName] = new PackageDescriptor(name, fullName, file);
- }
-
- /// <summary>
- /// Adds a symbol to the symbol table.
- /// </summary>
- /// <exception cref="DescriptorValidationException">The symbol already existed
- /// in the symbol table.</exception>
- internal void AddSymbol(IDescriptor descriptor)
- {
- ValidateSymbolName(descriptor);
- String fullName = descriptor.FullName;
-
- IDescriptor old;
- if (descriptorsByName.TryGetValue(fullName, out old))
- {
- int dotPos = fullName.LastIndexOf('.');
- string message;
- if (descriptor.File == old.File)
- {
- if (dotPos == -1)
- {
- message = "\"" + fullName + "\" is already defined.";
- }
- else
- {
- message = "\"" + fullName.Substring(dotPos + 1) + "\" is already defined in \"" +
- fullName.Substring(0, dotPos) + "\".";
- }
- }
- else
- {
- message = "\"" + fullName + "\" is already defined in file \"" + old.File.Name + "\".";
- }
- throw new DescriptorValidationException(descriptor, message);
- }
- descriptorsByName[fullName] = descriptor;
- }
-
- private static readonly Regex ValidationRegex = new Regex("^[_A-Za-z][_A-Za-z0-9]*$",
- FrameworkPortability.CompiledRegexWhereAvailable);
-
- /// <summary>
- /// Verifies that the descriptor's name is valid (i.e. it contains
- /// only letters, digits and underscores, and does not start with a digit).
- /// </summary>
- /// <param name="descriptor"></param>
- private static void ValidateSymbolName(IDescriptor descriptor)
- {
- if (descriptor.Name == "")
- {
- throw new DescriptorValidationException(descriptor, "Missing name.");
- }
- if (!ValidationRegex.IsMatch(descriptor.Name))
- {
- throw new DescriptorValidationException(descriptor,
- "\"" + descriptor.Name + "\" is not a valid identifier.");
- }
- }
-
- /// <summary>
- /// Returns the field with the given number in the given descriptor,
- /// or null if it can't be found.
- /// </summary>
- internal FieldDescriptor FindFieldByNumber(MessageDescriptor messageDescriptor, int number)
- {
- FieldDescriptor ret;
- fieldsByNumber.TryGetValue(new DescriptorIntPair(messageDescriptor, number), out ret);
- return ret;
- }
-
- internal EnumValueDescriptor FindEnumValueByNumber(EnumDescriptor enumDescriptor, int number)
- {
- EnumValueDescriptor ret;
- enumValuesByNumber.TryGetValue(new DescriptorIntPair(enumDescriptor, number), out ret);
- return ret;
- }
-
- /// <summary>
- /// Adds a field to the fieldsByNumber table.
- /// </summary>
- /// <exception cref="DescriptorValidationException">A field with the same
- /// containing type and number already exists.</exception>
- internal void AddFieldByNumber(FieldDescriptor field)
- {
- DescriptorIntPair key = new DescriptorIntPair(field.ContainingType, field.FieldNumber);
- FieldDescriptor old;
- if (fieldsByNumber.TryGetValue(key, out old))
- {
- throw new DescriptorValidationException(field, "Field number " + field.FieldNumber +
- "has already been used in \"" +
- field.ContainingType.FullName +
- "\" by field \"" + old.Name + "\".");
- }
- fieldsByNumber[key] = field;
- }
-
- /// <summary>
- /// Adds an enum value to the enumValuesByNumber table. If an enum value
- /// with the same type and number already exists, this method does nothing.
- /// (This is allowed; the first value defined with the number takes precedence.)
- /// </summary>
- internal void AddEnumValueByNumber(EnumValueDescriptor enumValue)
- {
- DescriptorIntPair key = new DescriptorIntPair(enumValue.EnumDescriptor, enumValue.Number);
- if (!enumValuesByNumber.ContainsKey(key))
- {
- enumValuesByNumber[key] = enumValue;
- }
- }
-
- /// <summary>
- /// Looks up a descriptor by name, relative to some other descriptor.
- /// The name may be fully-qualified (with a leading '.'), partially-qualified,
- /// or unqualified. C++-like name lookup semantics are used to search for the
- /// matching descriptor.
- /// </summary>
- internal IDescriptor LookupSymbol(string name, IDescriptor relativeTo)
- {
- // TODO(jonskeet): This could be optimized in a number of ways.
-
- IDescriptor result;
- if (name.StartsWith("."))
- {
- // Fully-qualified name.
- result = FindSymbol<IDescriptor>(name.Substring(1));
- }
- else
- {
- // If "name" is a compound identifier, we want to search for the
- // first component of it, then search within it for the rest.
- int firstPartLength = name.IndexOf('.');
- string firstPart = firstPartLength == -1 ? name : name.Substring(0, firstPartLength);
-
- // We will search each parent scope of "relativeTo" looking for the
- // symbol.
- StringBuilder scopeToTry = new StringBuilder(relativeTo.FullName);
-
- while (true)
- {
- // Chop off the last component of the scope.
-
- // TODO(jonskeet): Make this more efficient. May not be worth using StringBuilder at all
- int dotpos = scopeToTry.ToString().LastIndexOf(".");
- if (dotpos == -1)
- {
- result = FindSymbol<IDescriptor>(name);
- break;
- }
- else
- {
- scopeToTry.Length = dotpos + 1;
-
- // Append firstPart and try to find.
- scopeToTry.Append(firstPart);
- result = FindSymbol<IDescriptor>(scopeToTry.ToString());
-
- if (result != null)
- {
- if (firstPartLength != -1)
- {
- // We only found the first part of the symbol. Now look for
- // the whole thing. If this fails, we *don't* want to keep
- // searching parent scopes.
- scopeToTry.Length = dotpos + 1;
- scopeToTry.Append(name);
- result = FindSymbol<IDescriptor>(scopeToTry.ToString());
- }
- break;
- }
-
- // Not found. Remove the name so we can try again.
- scopeToTry.Length = dotpos;
- }
- }
- }
-
- if (result == null)
- {
- throw new DescriptorValidationException(relativeTo, "\"" + name + "\" is not defined.");
- }
- else
- {
- return result;
- }
- }
-
- /// <summary>
- /// Struct used to hold the keys for the fieldByNumber table.
- /// </summary>
- private struct DescriptorIntPair : IEquatable<DescriptorIntPair>
- {
- private readonly int number;
- private readonly IDescriptor descriptor;
-
- internal DescriptorIntPair(IDescriptor descriptor, int number)
- {
- this.number = number;
- this.descriptor = descriptor;
- }
-
- public bool Equals(DescriptorIntPair other)
- {
- return descriptor == other.descriptor
- && number == other.number;
- }
-
- public override bool Equals(object obj)
- {
- if (obj is DescriptorIntPair)
- {
- return Equals((DescriptorIntPair) obj);
- }
- return false;
- }
-
- public override int GetHashCode()
- {
- return descriptor.GetHashCode()*((1 << 16) - 1) + number;
- }
- }
- }
+#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +using System; +using System.Collections.Generic; +using System.Text; +using System.Text.RegularExpressions; + +namespace Google.Protobuf.Reflection +{ + /// <summary> + /// Contains lookup tables containing all the descriptors defined in a particular file. + /// </summary> + internal sealed class DescriptorPool + { + private readonly IDictionary<string, IDescriptor> descriptorsByName = + new Dictionary<string, IDescriptor>(); + + private readonly IDictionary<DescriptorIntPair, FieldDescriptor> fieldsByNumber = + new Dictionary<DescriptorIntPair, FieldDescriptor>(); + + private readonly IDictionary<DescriptorIntPair, EnumValueDescriptor> enumValuesByNumber = + new Dictionary<DescriptorIntPair, EnumValueDescriptor>(); + + private readonly HashSet<FileDescriptor> dependencies; + + internal DescriptorPool(FileDescriptor[] dependencyFiles) + { + dependencies = new HashSet<FileDescriptor>(); + for (int i = 0; i < dependencyFiles.Length; i++) + { + dependencies.Add(dependencyFiles[i]); + ImportPublicDependencies(dependencyFiles[i]); + } + + foreach (FileDescriptor dependency in dependencyFiles) + { + AddPackage(dependency.Package, dependency); + } + } + + private void ImportPublicDependencies(FileDescriptor file) + { + foreach (FileDescriptor dependency in file.PublicDependencies) + { + if (dependencies.Add(dependency)) + { + ImportPublicDependencies(dependency); + } + } + } + + /// <summary> + /// Finds a symbol of the given name within the pool. + /// </summary> + /// <typeparam name="T">The type of symbol to look for</typeparam> + /// <param name="fullName">Fully-qualified name to look up</param> + /// <returns>The symbol with the given name and type, + /// or null if the symbol doesn't exist or has the wrong type</returns> + internal T FindSymbol<T>(string fullName) where T : class + { + IDescriptor result; + descriptorsByName.TryGetValue(fullName, out result); + T descriptor = result as T; + if (descriptor != null) + { + return descriptor; + } + + foreach (FileDescriptor dependency in dependencies) + { + dependency.DescriptorPool.descriptorsByName.TryGetValue(fullName, out result); + descriptor = result as T; + if (descriptor != null) + { + return descriptor; + } + } + + return null; + } + + /// <summary> + /// Adds a package to the symbol tables. If a package by the same name + /// already exists, that is fine, but if some other kind of symbol + /// exists under the same name, an exception is thrown. If the package + /// has multiple components, this also adds the parent package(s). + /// </summary> + internal void AddPackage(string fullName, FileDescriptor file) + { + int dotpos = fullName.LastIndexOf('.'); + String name; + if (dotpos != -1) + { + AddPackage(fullName.Substring(0, dotpos), file); + name = fullName.Substring(dotpos + 1); + } + else + { + name = fullName; + } + + IDescriptor old; + if (descriptorsByName.TryGetValue(fullName, out old)) + { + if (!(old is PackageDescriptor)) + { + throw new DescriptorValidationException(file, + "\"" + name + + "\" is already defined (as something other than a " + + "package) in file \"" + old.File.Name + "\"."); + } + } + descriptorsByName[fullName] = new PackageDescriptor(name, fullName, file); + } + + /// <summary> + /// Adds a symbol to the symbol table. + /// </summary> + /// <exception cref="DescriptorValidationException">The symbol already existed + /// in the symbol table.</exception> + internal void AddSymbol(IDescriptor descriptor) + { + ValidateSymbolName(descriptor); + String fullName = descriptor.FullName; + + IDescriptor old; + if (descriptorsByName.TryGetValue(fullName, out old)) + { + int dotPos = fullName.LastIndexOf('.'); + string message; + if (descriptor.File == old.File) + { + if (dotPos == -1) + { + message = "\"" + fullName + "\" is already defined."; + } + else + { + message = "\"" + fullName.Substring(dotPos + 1) + "\" is already defined in \"" + + fullName.Substring(0, dotPos) + "\"."; + } + } + else + { + message = "\"" + fullName + "\" is already defined in file \"" + old.File.Name + "\"."; + } + throw new DescriptorValidationException(descriptor, message); + } + descriptorsByName[fullName] = descriptor; + } + + private static readonly Regex ValidationRegex = new Regex("^[_A-Za-z][_A-Za-z0-9]*$", + FrameworkPortability.CompiledRegexWhereAvailable); + + /// <summary> + /// Verifies that the descriptor's name is valid (i.e. it contains + /// only letters, digits and underscores, and does not start with a digit). + /// </summary> + /// <param name="descriptor"></param> + private static void ValidateSymbolName(IDescriptor descriptor) + { + if (descriptor.Name == "") + { + throw new DescriptorValidationException(descriptor, "Missing name."); + } + if (!ValidationRegex.IsMatch(descriptor.Name)) + { + throw new DescriptorValidationException(descriptor, + "\"" + descriptor.Name + "\" is not a valid identifier."); + } + } + + /// <summary> + /// Returns the field with the given number in the given descriptor, + /// or null if it can't be found. + /// </summary> + internal FieldDescriptor FindFieldByNumber(MessageDescriptor messageDescriptor, int number) + { + FieldDescriptor ret; + fieldsByNumber.TryGetValue(new DescriptorIntPair(messageDescriptor, number), out ret); + return ret; + } + + internal EnumValueDescriptor FindEnumValueByNumber(EnumDescriptor enumDescriptor, int number) + { + EnumValueDescriptor ret; + enumValuesByNumber.TryGetValue(new DescriptorIntPair(enumDescriptor, number), out ret); + return ret; + } + + /// <summary> + /// Adds a field to the fieldsByNumber table. + /// </summary> + /// <exception cref="DescriptorValidationException">A field with the same + /// containing type and number already exists.</exception> + internal void AddFieldByNumber(FieldDescriptor field) + { + DescriptorIntPair key = new DescriptorIntPair(field.ContainingType, field.FieldNumber); + FieldDescriptor old; + if (fieldsByNumber.TryGetValue(key, out old)) + { + throw new DescriptorValidationException(field, "Field number " + field.FieldNumber + + "has already been used in \"" + + field.ContainingType.FullName + + "\" by field \"" + old.Name + "\"."); + } + fieldsByNumber[key] = field; + } + + /// <summary> + /// Adds an enum value to the enumValuesByNumber table. If an enum value + /// with the same type and number already exists, this method does nothing. + /// (This is allowed; the first value defined with the number takes precedence.) + /// </summary> + internal void AddEnumValueByNumber(EnumValueDescriptor enumValue) + { + DescriptorIntPair key = new DescriptorIntPair(enumValue.EnumDescriptor, enumValue.Number); + if (!enumValuesByNumber.ContainsKey(key)) + { + enumValuesByNumber[key] = enumValue; + } + } + + /// <summary> + /// Looks up a descriptor by name, relative to some other descriptor. + /// The name may be fully-qualified (with a leading '.'), partially-qualified, + /// or unqualified. C++-like name lookup semantics are used to search for the + /// matching descriptor. + /// </summary> + internal IDescriptor LookupSymbol(string name, IDescriptor relativeTo) + { + // TODO(jonskeet): This could be optimized in a number of ways. + + IDescriptor result; + if (name.StartsWith(".")) + { + // Fully-qualified name. + result = FindSymbol<IDescriptor>(name.Substring(1)); + } + else + { + // If "name" is a compound identifier, we want to search for the + // first component of it, then search within it for the rest. + int firstPartLength = name.IndexOf('.'); + string firstPart = firstPartLength == -1 ? name : name.Substring(0, firstPartLength); + + // We will search each parent scope of "relativeTo" looking for the + // symbol. + StringBuilder scopeToTry = new StringBuilder(relativeTo.FullName); + + while (true) + { + // Chop off the last component of the scope. + + // TODO(jonskeet): Make this more efficient. May not be worth using StringBuilder at all + int dotpos = scopeToTry.ToString().LastIndexOf("."); + if (dotpos == -1) + { + result = FindSymbol<IDescriptor>(name); + break; + } + else + { + scopeToTry.Length = dotpos + 1; + + // Append firstPart and try to find. + scopeToTry.Append(firstPart); + result = FindSymbol<IDescriptor>(scopeToTry.ToString()); + + if (result != null) + { + if (firstPartLength != -1) + { + // We only found the first part of the symbol. Now look for + // the whole thing. If this fails, we *don't* want to keep + // searching parent scopes. + scopeToTry.Length = dotpos + 1; + scopeToTry.Append(name); + result = FindSymbol<IDescriptor>(scopeToTry.ToString()); + } + break; + } + + // Not found. Remove the name so we can try again. + scopeToTry.Length = dotpos; + } + } + } + + if (result == null) + { + throw new DescriptorValidationException(relativeTo, "\"" + name + "\" is not defined."); + } + else + { + return result; + } + } + + /// <summary> + /// Struct used to hold the keys for the fieldByNumber table. + /// </summary> + private struct DescriptorIntPair : IEquatable<DescriptorIntPair> + { + private readonly int number; + private readonly IDescriptor descriptor; + + internal DescriptorIntPair(IDescriptor descriptor, int number) + { + this.number = number; + this.descriptor = descriptor; + } + + public bool Equals(DescriptorIntPair other) + { + return descriptor == other.descriptor + && number == other.number; + } + + public override bool Equals(object obj) + { + if (obj is DescriptorIntPair) + { + return Equals((DescriptorIntPair) obj); + } + return false; + } + + public override int GetHashCode() + { + return descriptor.GetHashCode()*((1 << 16) - 1) + number; + } + } + } }
\ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs b/csharp/src/ProtocolBuffers/Reflection/DescriptorProtoFile.cs index c87b367a..c87969b9 100644 --- a/csharp/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs +++ b/csharp/src/ProtocolBuffers/Reflection/DescriptorProtoFile.cs @@ -5,42 +5,42 @@ using pb = global::Google.Protobuf; using pbc = global::Google.Protobuf.Collections; -using pbd = global::Google.Protobuf.Descriptors; +using pbr = global::Google.Protobuf.Reflection; using scg = global::System.Collections.Generic; -namespace Google.Protobuf.DescriptorProtos { +namespace Google.Protobuf.Reflection { [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] internal static partial class DescriptorProtoFile { #region Static variables - internal static pb::FieldAccess.FieldAccessorTable internal__static_google_protobuf_FileDescriptorSet__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_google_protobuf_FileDescriptorProto__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_google_protobuf_DescriptorProto__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_google_protobuf_DescriptorProto_ExtensionRange__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_google_protobuf_DescriptorProto_ReservedRange__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_google_protobuf_FieldDescriptorProto__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_google_protobuf_OneofDescriptorProto__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_google_protobuf_EnumDescriptorProto__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_google_protobuf_EnumValueDescriptorProto__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_google_protobuf_ServiceDescriptorProto__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_google_protobuf_MethodDescriptorProto__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_google_protobuf_FileOptions__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_google_protobuf_MessageOptions__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_google_protobuf_FieldOptions__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_google_protobuf_EnumOptions__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_google_protobuf_EnumValueOptions__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_google_protobuf_ServiceOptions__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_google_protobuf_MethodOptions__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_google_protobuf_UninterpretedOption__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_google_protobuf_UninterpretedOption_NamePart__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_google_protobuf_SourceCodeInfo__FieldAccessorTable; - internal static pb::FieldAccess.FieldAccessorTable internal__static_google_protobuf_SourceCodeInfo_Location__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_google_protobuf_FileDescriptorSet__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_google_protobuf_FileDescriptorProto__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_google_protobuf_DescriptorProto__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_google_protobuf_DescriptorProto_ExtensionRange__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_google_protobuf_DescriptorProto_ReservedRange__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_google_protobuf_FieldDescriptorProto__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_google_protobuf_OneofDescriptorProto__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_google_protobuf_EnumDescriptorProto__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_google_protobuf_EnumValueDescriptorProto__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_google_protobuf_ServiceDescriptorProto__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_google_protobuf_MethodDescriptorProto__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_google_protobuf_FileOptions__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_google_protobuf_MessageOptions__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_google_protobuf_FieldOptions__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_google_protobuf_EnumOptions__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_google_protobuf_EnumValueOptions__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_google_protobuf_ServiceOptions__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_google_protobuf_MethodOptions__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_google_protobuf_UninterpretedOption__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_google_protobuf_UninterpretedOption_NamePart__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_google_protobuf_SourceCodeInfo__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_google_protobuf_SourceCodeInfo_Location__FieldAccessorTable; #endregion #region Descriptor - public static pbd::FileDescriptor Descriptor { + public static pbr::FileDescriptor Descriptor { get { return descriptor; } } - private static pbd::FileDescriptor descriptor; + private static pbr::FileDescriptor descriptor; static DescriptorProtoFile() { byte[] descriptorData = global::System.Convert.FromBase64String( @@ -153,78 +153,78 @@ namespace Google.Protobuf.DescriptorProtos { "LkxvY2F0aW9uGoYBCghMb2NhdGlvbhIQCgRwYXRoGAEgAygFQgIQARIQCgRz", "cGFuGAIgAygFQgIQARIYChBsZWFkaW5nX2NvbW1lbnRzGAMgASgJEhkKEXRy", "YWlsaW5nX2NvbW1lbnRzGAQgASgJEiEKGWxlYWRpbmdfZGV0YWNoZWRfY29t", - "bWVudHMYBiADKAlCXgoTY29tLmdvb2dsZS5wcm90b2J1ZkIQRGVzY3JpcHRv", - "clByb3Rvc0gBWgpkZXNjcmlwdG9yogIDR1BCqgIgR29vZ2xlLlByb3RvYnVm", - "LkRlc2NyaXB0b3JQcm90b3M=")); - descriptor = pbd::FileDescriptor.InternalBuildGeneratedFileFrom(descriptorData, - new pbd::FileDescriptor[] { + "bWVudHMYBiADKAlCWAoTY29tLmdvb2dsZS5wcm90b2J1ZkIQRGVzY3JpcHRv", + "clByb3Rvc0gBWgpkZXNjcmlwdG9yogIDR1BCqgIaR29vZ2xlLlByb3RvYnVm", + "LlJlZmxlY3Rpb24=")); + descriptor = pbr::FileDescriptor.InternalBuildGeneratedFileFrom(descriptorData, + new pbr::FileDescriptor[] { }); internal__static_google_protobuf_FileDescriptorSet__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.DescriptorProtos.FileDescriptorSet), descriptor.MessageTypes[0], - new string[] { "File", }); + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.Reflection.FileDescriptorSet), descriptor.MessageTypes[0], + new string[] { "File", }, new string[] { }); internal__static_google_protobuf_FileDescriptorProto__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.DescriptorProtos.FileDescriptorProto), descriptor.MessageTypes[1], - new string[] { "Name", "Package", "Dependency", "PublicDependency", "WeakDependency", "MessageType", "EnumType", "Service", "Extension", "Options", "SourceCodeInfo", "Syntax", }); + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.Reflection.FileDescriptorProto), descriptor.MessageTypes[1], + new string[] { "Name", "Package", "Dependency", "PublicDependency", "WeakDependency", "MessageType", "EnumType", "Service", "Extension", "Options", "SourceCodeInfo", "Syntax", }, new string[] { }); internal__static_google_protobuf_DescriptorProto__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.DescriptorProtos.DescriptorProto), descriptor.MessageTypes[2], - new string[] { "Name", "Field", "Extension", "NestedType", "EnumType", "ExtensionRange", "OneofDecl", "Options", "ReservedRange", "ReservedName", }); + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.Reflection.DescriptorProto), descriptor.MessageTypes[2], + new string[] { "Name", "Field", "Extension", "NestedType", "EnumType", "ExtensionRange", "OneofDecl", "Options", "ReservedRange", "ReservedName", }, new string[] { }); internal__static_google_protobuf_DescriptorProto_ExtensionRange__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.DescriptorProtos.DescriptorProto.Types.ExtensionRange), descriptor.MessageTypes[2].NestedTypes[0], - new string[] { "Start", "End", }); + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.Reflection.DescriptorProto.Types.ExtensionRange), descriptor.MessageTypes[2].NestedTypes[0], + new string[] { "Start", "End", }, new string[] { }); internal__static_google_protobuf_DescriptorProto_ReservedRange__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.DescriptorProtos.DescriptorProto.Types.ReservedRange), descriptor.MessageTypes[2].NestedTypes[1], - new string[] { "Start", "End", }); + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.Reflection.DescriptorProto.Types.ReservedRange), descriptor.MessageTypes[2].NestedTypes[1], + new string[] { "Start", "End", }, new string[] { }); internal__static_google_protobuf_FieldDescriptorProto__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto), descriptor.MessageTypes[3], - new string[] { "Name", "Number", "Label", "Type", "TypeName", "Extendee", "DefaultValue", "OneofIndex", "Options", }); + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.Reflection.FieldDescriptorProto), descriptor.MessageTypes[3], + new string[] { "Name", "Number", "Label", "Type", "TypeName", "Extendee", "DefaultValue", "OneofIndex", "Options", }, new string[] { }); internal__static_google_protobuf_OneofDescriptorProto__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.DescriptorProtos.OneofDescriptorProto), descriptor.MessageTypes[4], - new string[] { "Name", }); + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.Reflection.OneofDescriptorProto), descriptor.MessageTypes[4], + new string[] { "Name", }, new string[] { }); internal__static_google_protobuf_EnumDescriptorProto__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.DescriptorProtos.EnumDescriptorProto), descriptor.MessageTypes[5], - new string[] { "Name", "Value", "Options", }); + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.Reflection.EnumDescriptorProto), descriptor.MessageTypes[5], + new string[] { "Name", "Value", "Options", }, new string[] { }); internal__static_google_protobuf_EnumValueDescriptorProto__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.DescriptorProtos.EnumValueDescriptorProto), descriptor.MessageTypes[6], - new string[] { "Name", "Number", "Options", }); + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.Reflection.EnumValueDescriptorProto), descriptor.MessageTypes[6], + new string[] { "Name", "Number", "Options", }, new string[] { }); internal__static_google_protobuf_ServiceDescriptorProto__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.DescriptorProtos.ServiceDescriptorProto), descriptor.MessageTypes[7], - new string[] { "Name", "Method", "Options", }); + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.Reflection.ServiceDescriptorProto), descriptor.MessageTypes[7], + new string[] { "Name", "Method", "Options", }, new string[] { }); internal__static_google_protobuf_MethodDescriptorProto__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.DescriptorProtos.MethodDescriptorProto), descriptor.MessageTypes[8], - new string[] { "Name", "InputType", "OutputType", "Options", "ClientStreaming", "ServerStreaming", }); + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.Reflection.MethodDescriptorProto), descriptor.MessageTypes[8], + new string[] { "Name", "InputType", "OutputType", "Options", "ClientStreaming", "ServerStreaming", }, new string[] { }); internal__static_google_protobuf_FileOptions__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.DescriptorProtos.FileOptions), descriptor.MessageTypes[9], - new string[] { "JavaPackage", "JavaOuterClassname", "JavaMultipleFiles", "JavaGenerateEqualsAndHash", "JavaStringCheckUtf8", "OptimizeFor", "GoPackage", "CcGenericServices", "JavaGenericServices", "PyGenericServices", "Deprecated", "CcEnableArenas", "ObjcClassPrefix", "CsharpNamespace", "UninterpretedOption", }); + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.Reflection.FileOptions), descriptor.MessageTypes[9], + new string[] { "JavaPackage", "JavaOuterClassname", "JavaMultipleFiles", "JavaGenerateEqualsAndHash", "JavaStringCheckUtf8", "OptimizeFor", "GoPackage", "CcGenericServices", "JavaGenericServices", "PyGenericServices", "Deprecated", "CcEnableArenas", "ObjcClassPrefix", "CsharpNamespace", "UninterpretedOption", }, new string[] { }); internal__static_google_protobuf_MessageOptions__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.DescriptorProtos.MessageOptions), descriptor.MessageTypes[10], - new string[] { "MessageSetWireFormat", "NoStandardDescriptorAccessor", "Deprecated", "MapEntry", "UninterpretedOption", }); + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.Reflection.MessageOptions), descriptor.MessageTypes[10], + new string[] { "MessageSetWireFormat", "NoStandardDescriptorAccessor", "Deprecated", "MapEntry", "UninterpretedOption", }, new string[] { }); internal__static_google_protobuf_FieldOptions__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.DescriptorProtos.FieldOptions), descriptor.MessageTypes[11], - new string[] { "Ctype", "Packed", "Jstype", "Lazy", "Deprecated", "Weak", "UninterpretedOption", }); + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.Reflection.FieldOptions), descriptor.MessageTypes[11], + new string[] { "Ctype", "Packed", "Jstype", "Lazy", "Deprecated", "Weak", "UninterpretedOption", }, new string[] { }); internal__static_google_protobuf_EnumOptions__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.DescriptorProtos.EnumOptions), descriptor.MessageTypes[12], - new string[] { "AllowAlias", "Deprecated", "UninterpretedOption", }); + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.Reflection.EnumOptions), descriptor.MessageTypes[12], + new string[] { "AllowAlias", "Deprecated", "UninterpretedOption", }, new string[] { }); internal__static_google_protobuf_EnumValueOptions__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.DescriptorProtos.EnumValueOptions), descriptor.MessageTypes[13], - new string[] { "Deprecated", "UninterpretedOption", }); + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.Reflection.EnumValueOptions), descriptor.MessageTypes[13], + new string[] { "Deprecated", "UninterpretedOption", }, new string[] { }); internal__static_google_protobuf_ServiceOptions__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.DescriptorProtos.ServiceOptions), descriptor.MessageTypes[14], - new string[] { "Deprecated", "UninterpretedOption", }); + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.Reflection.ServiceOptions), descriptor.MessageTypes[14], + new string[] { "Deprecated", "UninterpretedOption", }, new string[] { }); internal__static_google_protobuf_MethodOptions__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.DescriptorProtos.MethodOptions), descriptor.MessageTypes[15], - new string[] { "Deprecated", "UninterpretedOption", }); + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.Reflection.MethodOptions), descriptor.MessageTypes[15], + new string[] { "Deprecated", "UninterpretedOption", }, new string[] { }); internal__static_google_protobuf_UninterpretedOption__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.DescriptorProtos.UninterpretedOption), descriptor.MessageTypes[16], - new string[] { "Name", "IdentifierValue", "PositiveIntValue", "NegativeIntValue", "DoubleValue", "StringValue", "AggregateValue", }); + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.Reflection.UninterpretedOption), descriptor.MessageTypes[16], + new string[] { "Name", "IdentifierValue", "PositiveIntValue", "NegativeIntValue", "DoubleValue", "StringValue", "AggregateValue", }, new string[] { }); internal__static_google_protobuf_UninterpretedOption_NamePart__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Types.NamePart), descriptor.MessageTypes[16].NestedTypes[0], - new string[] { "NamePart_", "IsExtension", }); + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.Reflection.UninterpretedOption.Types.NamePart), descriptor.MessageTypes[16].NestedTypes[0], + new string[] { "NamePart_", "IsExtension", }, new string[] { }); internal__static_google_protobuf_SourceCodeInfo__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.DescriptorProtos.SourceCodeInfo), descriptor.MessageTypes[17], - new string[] { "Location", }); + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.Reflection.SourceCodeInfo), descriptor.MessageTypes[17], + new string[] { "Location", }, new string[] { }); internal__static_google_protobuf_SourceCodeInfo_Location__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.DescriptorProtos.SourceCodeInfo.Types.Location), descriptor.MessageTypes[17].NestedTypes[0], - new string[] { "Path", "Span", "LeadingComments", "TrailingComments", "LeadingDetachedComments", }); + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.Reflection.SourceCodeInfo.Types.Location), descriptor.MessageTypes[17].NestedTypes[0], + new string[] { "Path", "Span", "LeadingComments", "TrailingComments", "LeadingDetachedComments", }, new string[] { }); } #endregion @@ -237,12 +237,12 @@ namespace Google.Protobuf.DescriptorProtos { private static readonly string[] _fieldNames = new string[] { "file" }; private static readonly uint[] _fieldTags = new uint[] { 10 }; - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.Descriptor.MessageTypes[0]; } + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.Descriptor.MessageTypes[0]; } } - public pb::FieldAccess.FieldAccessorTable Fields { - get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_FileDescriptorSet__FieldAccessorTable; } + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.internal__static_google_protobuf_FileDescriptorSet__FieldAccessorTable; } } private bool _frozen = false; @@ -271,10 +271,10 @@ namespace Google.Protobuf.DescriptorProtos { } public const int FileFieldNumber = 1; - private static readonly pb::FieldCodec<global::Google.Protobuf.DescriptorProtos.FileDescriptorProto> _repeated_file_codec - = pb::FieldCodec.ForMessage(10, global::Google.Protobuf.DescriptorProtos.FileDescriptorProto.Parser); - private readonly pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.FileDescriptorProto> file_ = new pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.FileDescriptorProto>(); - internal pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.FileDescriptorProto> File { + private static readonly pb::FieldCodec<global::Google.Protobuf.Reflection.FileDescriptorProto> _repeated_file_codec + = pb::FieldCodec.ForMessage(10, global::Google.Protobuf.Reflection.FileDescriptorProto.Parser); + private readonly pbc::RepeatedField<global::Google.Protobuf.Reflection.FileDescriptorProto> file_ = new pbc::RepeatedField<global::Google.Protobuf.Reflection.FileDescriptorProto>(); + internal pbc::RepeatedField<global::Google.Protobuf.Reflection.FileDescriptorProto> File { get { return file_; } } @@ -299,6 +299,10 @@ namespace Google.Protobuf.DescriptorProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { file_.WriteTo(output, _repeated_file_codec); } @@ -344,12 +348,12 @@ namespace Google.Protobuf.DescriptorProtos { private static readonly string[] _fieldNames = new string[] { "dependency", "enum_type", "extension", "message_type", "name", "options", "package", "public_dependency", "service", "source_code_info", "syntax", "weak_dependency" }; private static readonly uint[] _fieldTags = new uint[] { 26, 42, 58, 34, 10, 66, 18, 80, 50, 74, 98, 88 }; - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.Descriptor.MessageTypes[1]; } + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.Descriptor.MessageTypes[1]; } } - public pb::FieldAccess.FieldAccessorTable Fields { - get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_FileDescriptorProto__FieldAccessorTable; } + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.internal__static_google_protobuf_FileDescriptorProto__FieldAccessorTable; } } private bool _frozen = false; @@ -441,40 +445,40 @@ namespace Google.Protobuf.DescriptorProtos { } public const int MessageTypeFieldNumber = 4; - private static readonly pb::FieldCodec<global::Google.Protobuf.DescriptorProtos.DescriptorProto> _repeated_messageType_codec - = pb::FieldCodec.ForMessage(34, global::Google.Protobuf.DescriptorProtos.DescriptorProto.Parser); - private readonly pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.DescriptorProto> messageType_ = new pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.DescriptorProto>(); - internal pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.DescriptorProto> MessageType { + private static readonly pb::FieldCodec<global::Google.Protobuf.Reflection.DescriptorProto> _repeated_messageType_codec + = pb::FieldCodec.ForMessage(34, global::Google.Protobuf.Reflection.DescriptorProto.Parser); + private readonly pbc::RepeatedField<global::Google.Protobuf.Reflection.DescriptorProto> messageType_ = new pbc::RepeatedField<global::Google.Protobuf.Reflection.DescriptorProto>(); + internal pbc::RepeatedField<global::Google.Protobuf.Reflection.DescriptorProto> MessageType { get { return messageType_; } } public const int EnumTypeFieldNumber = 5; - private static readonly pb::FieldCodec<global::Google.Protobuf.DescriptorProtos.EnumDescriptorProto> _repeated_enumType_codec - = pb::FieldCodec.ForMessage(42, global::Google.Protobuf.DescriptorProtos.EnumDescriptorProto.Parser); - private readonly pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.EnumDescriptorProto> enumType_ = new pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.EnumDescriptorProto>(); - internal pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.EnumDescriptorProto> EnumType { + private static readonly pb::FieldCodec<global::Google.Protobuf.Reflection.EnumDescriptorProto> _repeated_enumType_codec + = pb::FieldCodec.ForMessage(42, global::Google.Protobuf.Reflection.EnumDescriptorProto.Parser); + private readonly pbc::RepeatedField<global::Google.Protobuf.Reflection.EnumDescriptorProto> enumType_ = new pbc::RepeatedField<global::Google.Protobuf.Reflection.EnumDescriptorProto>(); + internal pbc::RepeatedField<global::Google.Protobuf.Reflection.EnumDescriptorProto> EnumType { get { return enumType_; } } public const int ServiceFieldNumber = 6; - private static readonly pb::FieldCodec<global::Google.Protobuf.DescriptorProtos.ServiceDescriptorProto> _repeated_service_codec - = pb::FieldCodec.ForMessage(50, global::Google.Protobuf.DescriptorProtos.ServiceDescriptorProto.Parser); - private readonly pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.ServiceDescriptorProto> service_ = new pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.ServiceDescriptorProto>(); - internal pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.ServiceDescriptorProto> Service { + private static readonly pb::FieldCodec<global::Google.Protobuf.Reflection.ServiceDescriptorProto> _repeated_service_codec + = pb::FieldCodec.ForMessage(50, global::Google.Protobuf.Reflection.ServiceDescriptorProto.Parser); + private readonly pbc::RepeatedField<global::Google.Protobuf.Reflection.ServiceDescriptorProto> service_ = new pbc::RepeatedField<global::Google.Protobuf.Reflection.ServiceDescriptorProto>(); + internal pbc::RepeatedField<global::Google.Protobuf.Reflection.ServiceDescriptorProto> Service { get { return service_; } } public const int ExtensionFieldNumber = 7; - private static readonly pb::FieldCodec<global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto> _repeated_extension_codec - = pb::FieldCodec.ForMessage(58, global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Parser); - private readonly pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto> extension_ = new pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto>(); - internal pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto> Extension { + private static readonly pb::FieldCodec<global::Google.Protobuf.Reflection.FieldDescriptorProto> _repeated_extension_codec + = pb::FieldCodec.ForMessage(58, global::Google.Protobuf.Reflection.FieldDescriptorProto.Parser); + private readonly pbc::RepeatedField<global::Google.Protobuf.Reflection.FieldDescriptorProto> extension_ = new pbc::RepeatedField<global::Google.Protobuf.Reflection.FieldDescriptorProto>(); + internal pbc::RepeatedField<global::Google.Protobuf.Reflection.FieldDescriptorProto> Extension { get { return extension_; } } public const int OptionsFieldNumber = 8; - private global::Google.Protobuf.DescriptorProtos.FileOptions options_; - internal global::Google.Protobuf.DescriptorProtos.FileOptions Options { + private global::Google.Protobuf.Reflection.FileOptions options_; + internal global::Google.Protobuf.Reflection.FileOptions Options { get { return options_; } set { pb::Freezable.CheckMutable(this); @@ -483,8 +487,8 @@ namespace Google.Protobuf.DescriptorProtos { } public const int SourceCodeInfoFieldNumber = 9; - private global::Google.Protobuf.DescriptorProtos.SourceCodeInfo sourceCodeInfo_; - internal global::Google.Protobuf.DescriptorProtos.SourceCodeInfo SourceCodeInfo { + private global::Google.Protobuf.Reflection.SourceCodeInfo sourceCodeInfo_; + internal global::Google.Protobuf.Reflection.SourceCodeInfo SourceCodeInfo { get { return sourceCodeInfo_; } set { pb::Freezable.CheckMutable(this); @@ -545,6 +549,10 @@ namespace Google.Protobuf.DescriptorProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (Name.Length != 0) { output.WriteRawTag(10); @@ -621,13 +629,13 @@ namespace Google.Protobuf.DescriptorProtos { extension_.Add(other.extension_); if (other.options_ != null) { if (options_ == null) { - options_ = new global::Google.Protobuf.DescriptorProtos.FileOptions(); + options_ = new global::Google.Protobuf.Reflection.FileOptions(); } Options.MergeFrom(other.Options); } if (other.sourceCodeInfo_ != null) { if (sourceCodeInfo_ == null) { - sourceCodeInfo_ = new global::Google.Protobuf.DescriptorProtos.SourceCodeInfo(); + sourceCodeInfo_ = new global::Google.Protobuf.Reflection.SourceCodeInfo(); } SourceCodeInfo.MergeFrom(other.SourceCodeInfo); } @@ -677,14 +685,14 @@ namespace Google.Protobuf.DescriptorProtos { } case 66: { if (options_ == null) { - options_ = new global::Google.Protobuf.DescriptorProtos.FileOptions(); + options_ = new global::Google.Protobuf.Reflection.FileOptions(); } input.ReadMessage(options_); break; } case 74: { if (sourceCodeInfo_ == null) { - sourceCodeInfo_ = new global::Google.Protobuf.DescriptorProtos.SourceCodeInfo(); + sourceCodeInfo_ = new global::Google.Protobuf.Reflection.SourceCodeInfo(); } input.ReadMessage(sourceCodeInfo_); break; @@ -716,12 +724,12 @@ namespace Google.Protobuf.DescriptorProtos { private static readonly string[] _fieldNames = new string[] { "enum_type", "extension", "extension_range", "field", "name", "nested_type", "oneof_decl", "options", "reserved_name", "reserved_range" }; private static readonly uint[] _fieldTags = new uint[] { 34, 50, 42, 18, 10, 26, 66, 58, 82, 74 }; - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.Descriptor.MessageTypes[2]; } + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.Descriptor.MessageTypes[2]; } } - public pb::FieldAccess.FieldAccessorTable Fields { - get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_DescriptorProto__FieldAccessorTable; } + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.internal__static_google_protobuf_DescriptorProto__FieldAccessorTable; } } private bool _frozen = false; @@ -777,56 +785,56 @@ namespace Google.Protobuf.DescriptorProtos { } public const int FieldFieldNumber = 2; - private static readonly pb::FieldCodec<global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto> _repeated_field_codec - = pb::FieldCodec.ForMessage(18, global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Parser); - private readonly pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto> field_ = new pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto>(); - internal pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto> Field { + private static readonly pb::FieldCodec<global::Google.Protobuf.Reflection.FieldDescriptorProto> _repeated_field_codec + = pb::FieldCodec.ForMessage(18, global::Google.Protobuf.Reflection.FieldDescriptorProto.Parser); + private readonly pbc::RepeatedField<global::Google.Protobuf.Reflection.FieldDescriptorProto> field_ = new pbc::RepeatedField<global::Google.Protobuf.Reflection.FieldDescriptorProto>(); + internal pbc::RepeatedField<global::Google.Protobuf.Reflection.FieldDescriptorProto> Field { get { return field_; } } public const int ExtensionFieldNumber = 6; - private static readonly pb::FieldCodec<global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto> _repeated_extension_codec - = pb::FieldCodec.ForMessage(50, global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Parser); - private readonly pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto> extension_ = new pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto>(); - internal pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto> Extension { + private static readonly pb::FieldCodec<global::Google.Protobuf.Reflection.FieldDescriptorProto> _repeated_extension_codec + = pb::FieldCodec.ForMessage(50, global::Google.Protobuf.Reflection.FieldDescriptorProto.Parser); + private readonly pbc::RepeatedField<global::Google.Protobuf.Reflection.FieldDescriptorProto> extension_ = new pbc::RepeatedField<global::Google.Protobuf.Reflection.FieldDescriptorProto>(); + internal pbc::RepeatedField<global::Google.Protobuf.Reflection.FieldDescriptorProto> Extension { get { return extension_; } } public const int NestedTypeFieldNumber = 3; - private static readonly pb::FieldCodec<global::Google.Protobuf.DescriptorProtos.DescriptorProto> _repeated_nestedType_codec - = pb::FieldCodec.ForMessage(26, global::Google.Protobuf.DescriptorProtos.DescriptorProto.Parser); - private readonly pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.DescriptorProto> nestedType_ = new pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.DescriptorProto>(); - internal pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.DescriptorProto> NestedType { + private static readonly pb::FieldCodec<global::Google.Protobuf.Reflection.DescriptorProto> _repeated_nestedType_codec + = pb::FieldCodec.ForMessage(26, global::Google.Protobuf.Reflection.DescriptorProto.Parser); + private readonly pbc::RepeatedField<global::Google.Protobuf.Reflection.DescriptorProto> nestedType_ = new pbc::RepeatedField<global::Google.Protobuf.Reflection.DescriptorProto>(); + internal pbc::RepeatedField<global::Google.Protobuf.Reflection.DescriptorProto> NestedType { get { return nestedType_; } } public const int EnumTypeFieldNumber = 4; - private static readonly pb::FieldCodec<global::Google.Protobuf.DescriptorProtos.EnumDescriptorProto> _repeated_enumType_codec - = pb::FieldCodec.ForMessage(34, global::Google.Protobuf.DescriptorProtos.EnumDescriptorProto.Parser); - private readonly pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.EnumDescriptorProto> enumType_ = new pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.EnumDescriptorProto>(); - internal pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.EnumDescriptorProto> EnumType { + private static readonly pb::FieldCodec<global::Google.Protobuf.Reflection.EnumDescriptorProto> _repeated_enumType_codec + = pb::FieldCodec.ForMessage(34, global::Google.Protobuf.Reflection.EnumDescriptorProto.Parser); + private readonly pbc::RepeatedField<global::Google.Protobuf.Reflection.EnumDescriptorProto> enumType_ = new pbc::RepeatedField<global::Google.Protobuf.Reflection.EnumDescriptorProto>(); + internal pbc::RepeatedField<global::Google.Protobuf.Reflection.EnumDescriptorProto> EnumType { get { return enumType_; } } public const int ExtensionRangeFieldNumber = 5; - private static readonly pb::FieldCodec<global::Google.Protobuf.DescriptorProtos.DescriptorProto.Types.ExtensionRange> _repeated_extensionRange_codec - = pb::FieldCodec.ForMessage(42, global::Google.Protobuf.DescriptorProtos.DescriptorProto.Types.ExtensionRange.Parser); - private readonly pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.DescriptorProto.Types.ExtensionRange> extensionRange_ = new pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.DescriptorProto.Types.ExtensionRange>(); - internal pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.DescriptorProto.Types.ExtensionRange> ExtensionRange { + private static readonly pb::FieldCodec<global::Google.Protobuf.Reflection.DescriptorProto.Types.ExtensionRange> _repeated_extensionRange_codec + = pb::FieldCodec.ForMessage(42, global::Google.Protobuf.Reflection.DescriptorProto.Types.ExtensionRange.Parser); + private readonly pbc::RepeatedField<global::Google.Protobuf.Reflection.DescriptorProto.Types.ExtensionRange> extensionRange_ = new pbc::RepeatedField<global::Google.Protobuf.Reflection.DescriptorProto.Types.ExtensionRange>(); + internal pbc::RepeatedField<global::Google.Protobuf.Reflection.DescriptorProto.Types.ExtensionRange> ExtensionRange { get { return extensionRange_; } } public const int OneofDeclFieldNumber = 8; - private static readonly pb::FieldCodec<global::Google.Protobuf.DescriptorProtos.OneofDescriptorProto> _repeated_oneofDecl_codec - = pb::FieldCodec.ForMessage(66, global::Google.Protobuf.DescriptorProtos.OneofDescriptorProto.Parser); - private readonly pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.OneofDescriptorProto> oneofDecl_ = new pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.OneofDescriptorProto>(); - internal pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.OneofDescriptorProto> OneofDecl { + private static readonly pb::FieldCodec<global::Google.Protobuf.Reflection.OneofDescriptorProto> _repeated_oneofDecl_codec + = pb::FieldCodec.ForMessage(66, global::Google.Protobuf.Reflection.OneofDescriptorProto.Parser); + private readonly pbc::RepeatedField<global::Google.Protobuf.Reflection.OneofDescriptorProto> oneofDecl_ = new pbc::RepeatedField<global::Google.Protobuf.Reflection.OneofDescriptorProto>(); + internal pbc::RepeatedField<global::Google.Protobuf.Reflection.OneofDescriptorProto> OneofDecl { get { return oneofDecl_; } } public const int OptionsFieldNumber = 7; - private global::Google.Protobuf.DescriptorProtos.MessageOptions options_; - internal global::Google.Protobuf.DescriptorProtos.MessageOptions Options { + private global::Google.Protobuf.Reflection.MessageOptions options_; + internal global::Google.Protobuf.Reflection.MessageOptions Options { get { return options_; } set { pb::Freezable.CheckMutable(this); @@ -835,10 +843,10 @@ namespace Google.Protobuf.DescriptorProtos { } public const int ReservedRangeFieldNumber = 9; - private static readonly pb::FieldCodec<global::Google.Protobuf.DescriptorProtos.DescriptorProto.Types.ReservedRange> _repeated_reservedRange_codec - = pb::FieldCodec.ForMessage(74, global::Google.Protobuf.DescriptorProtos.DescriptorProto.Types.ReservedRange.Parser); - private readonly pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.DescriptorProto.Types.ReservedRange> reservedRange_ = new pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.DescriptorProto.Types.ReservedRange>(); - internal pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.DescriptorProto.Types.ReservedRange> ReservedRange { + private static readonly pb::FieldCodec<global::Google.Protobuf.Reflection.DescriptorProto.Types.ReservedRange> _repeated_reservedRange_codec + = pb::FieldCodec.ForMessage(74, global::Google.Protobuf.Reflection.DescriptorProto.Types.ReservedRange.Parser); + private readonly pbc::RepeatedField<global::Google.Protobuf.Reflection.DescriptorProto.Types.ReservedRange> reservedRange_ = new pbc::RepeatedField<global::Google.Protobuf.Reflection.DescriptorProto.Types.ReservedRange>(); + internal pbc::RepeatedField<global::Google.Protobuf.Reflection.DescriptorProto.Types.ReservedRange> ReservedRange { get { return reservedRange_; } } @@ -889,6 +897,10 @@ namespace Google.Protobuf.DescriptorProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (Name.Length != 0) { output.WriteRawTag(10); @@ -942,7 +954,7 @@ namespace Google.Protobuf.DescriptorProtos { oneofDecl_.Add(other.oneofDecl_); if (other.options_ != null) { if (options_ == null) { - options_ = new global::Google.Protobuf.DescriptorProtos.MessageOptions(); + options_ = new global::Google.Protobuf.Reflection.MessageOptions(); } Options.MergeFrom(other.Options); } @@ -987,7 +999,7 @@ namespace Google.Protobuf.DescriptorProtos { } case 58: { if (options_ == null) { - options_ = new global::Google.Protobuf.DescriptorProtos.MessageOptions(); + options_ = new global::Google.Protobuf.Reflection.MessageOptions(); } input.ReadMessage(options_); break; @@ -1018,12 +1030,12 @@ namespace Google.Protobuf.DescriptorProtos { private static readonly string[] _fieldNames = new string[] { "end", "start" }; private static readonly uint[] _fieldTags = new uint[] { 16, 8 }; - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.DescriptorProtos.DescriptorProto.Descriptor.NestedTypes[0]; } + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.Reflection.DescriptorProto.Descriptor.NestedTypes[0]; } } - public pb::FieldAccess.FieldAccessorTable Fields { - get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_DescriptorProto_ExtensionRange__FieldAccessorTable; } + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.internal__static_google_protobuf_DescriptorProto_ExtensionRange__FieldAccessorTable; } } private bool _frozen = false; @@ -1094,6 +1106,10 @@ namespace Google.Protobuf.DescriptorProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (Start != 0) { output.WriteRawTag(8); @@ -1160,12 +1176,12 @@ namespace Google.Protobuf.DescriptorProtos { private static readonly string[] _fieldNames = new string[] { "end", "start" }; private static readonly uint[] _fieldTags = new uint[] { 16, 8 }; - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.DescriptorProtos.DescriptorProto.Descriptor.NestedTypes[1]; } + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.Reflection.DescriptorProto.Descriptor.NestedTypes[1]; } } - public pb::FieldAccess.FieldAccessorTable Fields { - get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_DescriptorProto_ReservedRange__FieldAccessorTable; } + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.internal__static_google_protobuf_DescriptorProto_ReservedRange__FieldAccessorTable; } } private bool _frozen = false; @@ -1236,6 +1252,10 @@ namespace Google.Protobuf.DescriptorProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (Start != 0) { output.WriteRawTag(8); @@ -1307,12 +1327,12 @@ namespace Google.Protobuf.DescriptorProtos { private static readonly string[] _fieldNames = new string[] { "default_value", "extendee", "label", "name", "number", "oneof_index", "options", "type", "type_name" }; private static readonly uint[] _fieldTags = new uint[] { 58, 18, 32, 10, 24, 72, 66, 40, 50 }; - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.Descriptor.MessageTypes[3]; } + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.Descriptor.MessageTypes[3]; } } - public pb::FieldAccess.FieldAccessorTable Fields { - get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_FieldDescriptorProto__FieldAccessorTable; } + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.internal__static_google_protobuf_FieldDescriptorProto__FieldAccessorTable; } } private bool _frozen = false; @@ -1369,8 +1389,8 @@ namespace Google.Protobuf.DescriptorProtos { } public const int LabelFieldNumber = 4; - private global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Types.Label label_ = global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Types.Label.LABEL_OPTIONAL; - internal global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Types.Label Label { + private global::Google.Protobuf.Reflection.FieldDescriptorProto.Types.Label label_ = global::Google.Protobuf.Reflection.FieldDescriptorProto.Types.Label.LABEL_OPTIONAL; + internal global::Google.Protobuf.Reflection.FieldDescriptorProto.Types.Label Label { get { return label_; } set { pb::Freezable.CheckMutable(this); @@ -1379,8 +1399,8 @@ namespace Google.Protobuf.DescriptorProtos { } public const int TypeFieldNumber = 5; - private global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Types.Type type_ = global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Types.Type.TYPE_DOUBLE; - internal global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Types.Type Type { + private global::Google.Protobuf.Reflection.FieldDescriptorProto.Types.Type type_ = global::Google.Protobuf.Reflection.FieldDescriptorProto.Types.Type.TYPE_DOUBLE; + internal global::Google.Protobuf.Reflection.FieldDescriptorProto.Types.Type Type { get { return type_; } set { pb::Freezable.CheckMutable(this); @@ -1429,8 +1449,8 @@ namespace Google.Protobuf.DescriptorProtos { } public const int OptionsFieldNumber = 8; - private global::Google.Protobuf.DescriptorProtos.FieldOptions options_; - internal global::Google.Protobuf.DescriptorProtos.FieldOptions Options { + private global::Google.Protobuf.Reflection.FieldOptions options_; + internal global::Google.Protobuf.Reflection.FieldOptions Options { get { return options_; } set { pb::Freezable.CheckMutable(this); @@ -1465,8 +1485,8 @@ namespace Google.Protobuf.DescriptorProtos { int hash = 1; if (Name.Length != 0) hash ^= Name.GetHashCode(); if (Number != 0) hash ^= Number.GetHashCode(); - if (Label != global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Types.Label.LABEL_OPTIONAL) hash ^= Label.GetHashCode(); - if (Type != global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Types.Type.TYPE_DOUBLE) hash ^= Type.GetHashCode(); + if (Label != global::Google.Protobuf.Reflection.FieldDescriptorProto.Types.Label.LABEL_OPTIONAL) hash ^= Label.GetHashCode(); + if (Type != global::Google.Protobuf.Reflection.FieldDescriptorProto.Types.Type.TYPE_DOUBLE) hash ^= Type.GetHashCode(); if (TypeName.Length != 0) hash ^= TypeName.GetHashCode(); if (Extendee.Length != 0) hash ^= Extendee.GetHashCode(); if (DefaultValue.Length != 0) hash ^= DefaultValue.GetHashCode(); @@ -1475,6 +1495,10 @@ namespace Google.Protobuf.DescriptorProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (Name.Length != 0) { output.WriteRawTag(10); @@ -1488,11 +1512,11 @@ namespace Google.Protobuf.DescriptorProtos { output.WriteRawTag(24); output.WriteInt32(Number); } - if (Label != global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Types.Label.LABEL_OPTIONAL) { + if (Label != global::Google.Protobuf.Reflection.FieldDescriptorProto.Types.Label.LABEL_OPTIONAL) { output.WriteRawTag(32); output.WriteEnum((int) Label); } - if (Type != global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Types.Type.TYPE_DOUBLE) { + if (Type != global::Google.Protobuf.Reflection.FieldDescriptorProto.Types.Type.TYPE_DOUBLE) { output.WriteRawTag(40); output.WriteEnum((int) Type); } @@ -1522,10 +1546,10 @@ namespace Google.Protobuf.DescriptorProtos { if (Number != 0) { size += 1 + pb::CodedOutputStream.ComputeInt32Size(Number); } - if (Label != global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Types.Label.LABEL_OPTIONAL) { + if (Label != global::Google.Protobuf.Reflection.FieldDescriptorProto.Types.Label.LABEL_OPTIONAL) { size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Label); } - if (Type != global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Types.Type.TYPE_DOUBLE) { + if (Type != global::Google.Protobuf.Reflection.FieldDescriptorProto.Types.Type.TYPE_DOUBLE) { size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Type); } if (TypeName.Length != 0) { @@ -1556,10 +1580,10 @@ namespace Google.Protobuf.DescriptorProtos { if (other.Number != 0) { Number = other.Number; } - if (other.Label != global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Types.Label.LABEL_OPTIONAL) { + if (other.Label != global::Google.Protobuf.Reflection.FieldDescriptorProto.Types.Label.LABEL_OPTIONAL) { Label = other.Label; } - if (other.Type != global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Types.Type.TYPE_DOUBLE) { + if (other.Type != global::Google.Protobuf.Reflection.FieldDescriptorProto.Types.Type.TYPE_DOUBLE) { Type = other.Type; } if (other.TypeName.Length != 0) { @@ -1576,7 +1600,7 @@ namespace Google.Protobuf.DescriptorProtos { } if (other.options_ != null) { if (options_ == null) { - options_ = new global::Google.Protobuf.DescriptorProtos.FieldOptions(); + options_ = new global::Google.Protobuf.Reflection.FieldOptions(); } Options.MergeFrom(other.Options); } @@ -1606,11 +1630,11 @@ namespace Google.Protobuf.DescriptorProtos { break; } case 32: { - label_ = (global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Types.Label) input.ReadEnum(); + label_ = (global::Google.Protobuf.Reflection.FieldDescriptorProto.Types.Label) input.ReadEnum(); break; } case 40: { - type_ = (global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Types.Type) input.ReadEnum(); + type_ = (global::Google.Protobuf.Reflection.FieldDescriptorProto.Types.Type) input.ReadEnum(); break; } case 50: { @@ -1623,7 +1647,7 @@ namespace Google.Protobuf.DescriptorProtos { } case 66: { if (options_ == null) { - options_ = new global::Google.Protobuf.DescriptorProtos.FieldOptions(); + options_ = new global::Google.Protobuf.Reflection.FieldOptions(); } input.ReadMessage(options_); break; @@ -1678,12 +1702,12 @@ namespace Google.Protobuf.DescriptorProtos { private static readonly string[] _fieldNames = new string[] { "name" }; private static readonly uint[] _fieldTags = new uint[] { 10 }; - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.Descriptor.MessageTypes[4]; } + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.Descriptor.MessageTypes[4]; } } - public pb::FieldAccess.FieldAccessorTable Fields { - get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_OneofDescriptorProto__FieldAccessorTable; } + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.internal__static_google_protobuf_OneofDescriptorProto__FieldAccessorTable; } } private bool _frozen = false; @@ -1741,6 +1765,10 @@ namespace Google.Protobuf.DescriptorProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (Name.Length != 0) { output.WriteRawTag(10); @@ -1793,12 +1821,12 @@ namespace Google.Protobuf.DescriptorProtos { private static readonly string[] _fieldNames = new string[] { "name", "options", "value" }; private static readonly uint[] _fieldTags = new uint[] { 10, 26, 18 }; - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.Descriptor.MessageTypes[5]; } + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.Descriptor.MessageTypes[5]; } } - public pb::FieldAccess.FieldAccessorTable Fields { - get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_EnumDescriptorProto__FieldAccessorTable; } + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.internal__static_google_protobuf_EnumDescriptorProto__FieldAccessorTable; } } private bool _frozen = false; @@ -1840,16 +1868,16 @@ namespace Google.Protobuf.DescriptorProtos { } public const int ValueFieldNumber = 2; - private static readonly pb::FieldCodec<global::Google.Protobuf.DescriptorProtos.EnumValueDescriptorProto> _repeated_value_codec - = pb::FieldCodec.ForMessage(18, global::Google.Protobuf.DescriptorProtos.EnumValueDescriptorProto.Parser); - private readonly pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.EnumValueDescriptorProto> value_ = new pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.EnumValueDescriptorProto>(); - internal pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.EnumValueDescriptorProto> Value { + private static readonly pb::FieldCodec<global::Google.Protobuf.Reflection.EnumValueDescriptorProto> _repeated_value_codec + = pb::FieldCodec.ForMessage(18, global::Google.Protobuf.Reflection.EnumValueDescriptorProto.Parser); + private readonly pbc::RepeatedField<global::Google.Protobuf.Reflection.EnumValueDescriptorProto> value_ = new pbc::RepeatedField<global::Google.Protobuf.Reflection.EnumValueDescriptorProto>(); + internal pbc::RepeatedField<global::Google.Protobuf.Reflection.EnumValueDescriptorProto> Value { get { return value_; } } public const int OptionsFieldNumber = 3; - private global::Google.Protobuf.DescriptorProtos.EnumOptions options_; - internal global::Google.Protobuf.DescriptorProtos.EnumOptions Options { + private global::Google.Protobuf.Reflection.EnumOptions options_; + internal global::Google.Protobuf.Reflection.EnumOptions Options { get { return options_; } set { pb::Freezable.CheckMutable(this); @@ -1882,6 +1910,10 @@ namespace Google.Protobuf.DescriptorProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (Name.Length != 0) { output.WriteRawTag(10); @@ -1916,7 +1948,7 @@ namespace Google.Protobuf.DescriptorProtos { value_.Add(other.value_); if (other.options_ != null) { if (options_ == null) { - options_ = new global::Google.Protobuf.DescriptorProtos.EnumOptions(); + options_ = new global::Google.Protobuf.Reflection.EnumOptions(); } Options.MergeFrom(other.Options); } @@ -1943,7 +1975,7 @@ namespace Google.Protobuf.DescriptorProtos { } case 26: { if (options_ == null) { - options_ = new global::Google.Protobuf.DescriptorProtos.EnumOptions(); + options_ = new global::Google.Protobuf.Reflection.EnumOptions(); } input.ReadMessage(options_); break; @@ -1961,12 +1993,12 @@ namespace Google.Protobuf.DescriptorProtos { private static readonly string[] _fieldNames = new string[] { "name", "number", "options" }; private static readonly uint[] _fieldTags = new uint[] { 10, 16, 26 }; - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.Descriptor.MessageTypes[6]; } + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.Descriptor.MessageTypes[6]; } } - public pb::FieldAccess.FieldAccessorTable Fields { - get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_EnumValueDescriptorProto__FieldAccessorTable; } + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.internal__static_google_protobuf_EnumValueDescriptorProto__FieldAccessorTable; } } private bool _frozen = false; @@ -2017,8 +2049,8 @@ namespace Google.Protobuf.DescriptorProtos { } public const int OptionsFieldNumber = 3; - private global::Google.Protobuf.DescriptorProtos.EnumValueOptions options_; - internal global::Google.Protobuf.DescriptorProtos.EnumValueOptions Options { + private global::Google.Protobuf.Reflection.EnumValueOptions options_; + internal global::Google.Protobuf.Reflection.EnumValueOptions Options { get { return options_; } set { pb::Freezable.CheckMutable(this); @@ -2051,6 +2083,10 @@ namespace Google.Protobuf.DescriptorProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (Name.Length != 0) { output.WriteRawTag(10); @@ -2092,7 +2128,7 @@ namespace Google.Protobuf.DescriptorProtos { } if (other.options_ != null) { if (options_ == null) { - options_ = new global::Google.Protobuf.DescriptorProtos.EnumValueOptions(); + options_ = new global::Google.Protobuf.Reflection.EnumValueOptions(); } Options.MergeFrom(other.Options); } @@ -2119,7 +2155,7 @@ namespace Google.Protobuf.DescriptorProtos { } case 26: { if (options_ == null) { - options_ = new global::Google.Protobuf.DescriptorProtos.EnumValueOptions(); + options_ = new global::Google.Protobuf.Reflection.EnumValueOptions(); } input.ReadMessage(options_); break; @@ -2137,12 +2173,12 @@ namespace Google.Protobuf.DescriptorProtos { private static readonly string[] _fieldNames = new string[] { "method", "name", "options" }; private static readonly uint[] _fieldTags = new uint[] { 18, 10, 26 }; - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.Descriptor.MessageTypes[7]; } + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.Descriptor.MessageTypes[7]; } } - public pb::FieldAccess.FieldAccessorTable Fields { - get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_ServiceDescriptorProto__FieldAccessorTable; } + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.internal__static_google_protobuf_ServiceDescriptorProto__FieldAccessorTable; } } private bool _frozen = false; @@ -2184,16 +2220,16 @@ namespace Google.Protobuf.DescriptorProtos { } public const int MethodFieldNumber = 2; - private static readonly pb::FieldCodec<global::Google.Protobuf.DescriptorProtos.MethodDescriptorProto> _repeated_method_codec - = pb::FieldCodec.ForMessage(18, global::Google.Protobuf.DescriptorProtos.MethodDescriptorProto.Parser); - private readonly pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.MethodDescriptorProto> method_ = new pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.MethodDescriptorProto>(); - internal pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.MethodDescriptorProto> Method { + private static readonly pb::FieldCodec<global::Google.Protobuf.Reflection.MethodDescriptorProto> _repeated_method_codec + = pb::FieldCodec.ForMessage(18, global::Google.Protobuf.Reflection.MethodDescriptorProto.Parser); + private readonly pbc::RepeatedField<global::Google.Protobuf.Reflection.MethodDescriptorProto> method_ = new pbc::RepeatedField<global::Google.Protobuf.Reflection.MethodDescriptorProto>(); + internal pbc::RepeatedField<global::Google.Protobuf.Reflection.MethodDescriptorProto> Method { get { return method_; } } public const int OptionsFieldNumber = 3; - private global::Google.Protobuf.DescriptorProtos.ServiceOptions options_; - internal global::Google.Protobuf.DescriptorProtos.ServiceOptions Options { + private global::Google.Protobuf.Reflection.ServiceOptions options_; + internal global::Google.Protobuf.Reflection.ServiceOptions Options { get { return options_; } set { pb::Freezable.CheckMutable(this); @@ -2226,6 +2262,10 @@ namespace Google.Protobuf.DescriptorProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (Name.Length != 0) { output.WriteRawTag(10); @@ -2260,7 +2300,7 @@ namespace Google.Protobuf.DescriptorProtos { method_.Add(other.method_); if (other.options_ != null) { if (options_ == null) { - options_ = new global::Google.Protobuf.DescriptorProtos.ServiceOptions(); + options_ = new global::Google.Protobuf.Reflection.ServiceOptions(); } Options.MergeFrom(other.Options); } @@ -2287,7 +2327,7 @@ namespace Google.Protobuf.DescriptorProtos { } case 26: { if (options_ == null) { - options_ = new global::Google.Protobuf.DescriptorProtos.ServiceOptions(); + options_ = new global::Google.Protobuf.Reflection.ServiceOptions(); } input.ReadMessage(options_); break; @@ -2305,12 +2345,12 @@ namespace Google.Protobuf.DescriptorProtos { private static readonly string[] _fieldNames = new string[] { "client_streaming", "input_type", "name", "options", "output_type", "server_streaming" }; private static readonly uint[] _fieldTags = new uint[] { 40, 18, 10, 34, 26, 48 }; - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.Descriptor.MessageTypes[8]; } + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.Descriptor.MessageTypes[8]; } } - public pb::FieldAccess.FieldAccessorTable Fields { - get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_MethodDescriptorProto__FieldAccessorTable; } + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.internal__static_google_protobuf_MethodDescriptorProto__FieldAccessorTable; } } private bool _frozen = false; @@ -2374,8 +2414,8 @@ namespace Google.Protobuf.DescriptorProtos { } public const int OptionsFieldNumber = 4; - private global::Google.Protobuf.DescriptorProtos.MethodOptions options_; - internal global::Google.Protobuf.DescriptorProtos.MethodOptions Options { + private global::Google.Protobuf.Reflection.MethodOptions options_; + internal global::Google.Protobuf.Reflection.MethodOptions Options { get { return options_; } set { pb::Freezable.CheckMutable(this); @@ -2434,6 +2474,10 @@ namespace Google.Protobuf.DescriptorProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (Name.Length != 0) { output.WriteRawTag(10); @@ -2499,7 +2543,7 @@ namespace Google.Protobuf.DescriptorProtos { } if (other.options_ != null) { if (options_ == null) { - options_ = new global::Google.Protobuf.DescriptorProtos.MethodOptions(); + options_ = new global::Google.Protobuf.Reflection.MethodOptions(); } Options.MergeFrom(other.Options); } @@ -2536,7 +2580,7 @@ namespace Google.Protobuf.DescriptorProtos { } case 34: { if (options_ == null) { - options_ = new global::Google.Protobuf.DescriptorProtos.MethodOptions(); + options_ = new global::Google.Protobuf.Reflection.MethodOptions(); } input.ReadMessage(options_); break; @@ -2562,12 +2606,12 @@ namespace Google.Protobuf.DescriptorProtos { private static readonly string[] _fieldNames = new string[] { "cc_enable_arenas", "cc_generic_services", "csharp_namespace", "deprecated", "go_package", "java_generate_equals_and_hash", "java_generic_services", "java_multiple_files", "java_outer_classname", "java_package", "java_string_check_utf8", "objc_class_prefix", "optimize_for", "py_generic_services", "uninterpreted_option" }; private static readonly uint[] _fieldTags = new uint[] { 248, 128, 298, 184, 90, 160, 136, 80, 66, 10, 216, 290, 72, 144, 7994 }; - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.Descriptor.MessageTypes[9]; } + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.Descriptor.MessageTypes[9]; } } - public pb::FieldAccess.FieldAccessorTable Fields { - get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_FileOptions__FieldAccessorTable; } + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.internal__static_google_protobuf_FileOptions__FieldAccessorTable; } } private bool _frozen = false; @@ -2660,8 +2704,8 @@ namespace Google.Protobuf.DescriptorProtos { } public const int OptimizeForFieldNumber = 9; - private global::Google.Protobuf.DescriptorProtos.FileOptions.Types.OptimizeMode optimizeFor_ = global::Google.Protobuf.DescriptorProtos.FileOptions.Types.OptimizeMode.SPEED; - internal global::Google.Protobuf.DescriptorProtos.FileOptions.Types.OptimizeMode OptimizeFor { + private global::Google.Protobuf.Reflection.FileOptions.Types.OptimizeMode optimizeFor_ = global::Google.Protobuf.Reflection.FileOptions.Types.OptimizeMode.SPEED; + internal global::Google.Protobuf.Reflection.FileOptions.Types.OptimizeMode OptimizeFor { get { return optimizeFor_; } set { pb::Freezable.CheckMutable(this); @@ -2750,10 +2794,10 @@ namespace Google.Protobuf.DescriptorProtos { } public const int UninterpretedOptionFieldNumber = 999; - private static readonly pb::FieldCodec<global::Google.Protobuf.DescriptorProtos.UninterpretedOption> _repeated_uninterpretedOption_codec - = pb::FieldCodec.ForMessage(7994, global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Parser); - private readonly pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption> uninterpretedOption_ = new pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption>(); - internal pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption> UninterpretedOption { + private static readonly pb::FieldCodec<global::Google.Protobuf.Reflection.UninterpretedOption> _repeated_uninterpretedOption_codec + = pb::FieldCodec.ForMessage(7994, global::Google.Protobuf.Reflection.UninterpretedOption.Parser); + private readonly pbc::RepeatedField<global::Google.Protobuf.Reflection.UninterpretedOption> uninterpretedOption_ = new pbc::RepeatedField<global::Google.Protobuf.Reflection.UninterpretedOption>(); + internal pbc::RepeatedField<global::Google.Protobuf.Reflection.UninterpretedOption> UninterpretedOption { get { return uninterpretedOption_; } } @@ -2793,7 +2837,7 @@ namespace Google.Protobuf.DescriptorProtos { if (JavaMultipleFiles != false) hash ^= JavaMultipleFiles.GetHashCode(); if (JavaGenerateEqualsAndHash != false) hash ^= JavaGenerateEqualsAndHash.GetHashCode(); if (JavaStringCheckUtf8 != false) hash ^= JavaStringCheckUtf8.GetHashCode(); - if (OptimizeFor != global::Google.Protobuf.DescriptorProtos.FileOptions.Types.OptimizeMode.SPEED) hash ^= OptimizeFor.GetHashCode(); + if (OptimizeFor != global::Google.Protobuf.Reflection.FileOptions.Types.OptimizeMode.SPEED) hash ^= OptimizeFor.GetHashCode(); if (GoPackage.Length != 0) hash ^= GoPackage.GetHashCode(); if (CcGenericServices != false) hash ^= CcGenericServices.GetHashCode(); if (JavaGenericServices != false) hash ^= JavaGenericServices.GetHashCode(); @@ -2806,6 +2850,10 @@ namespace Google.Protobuf.DescriptorProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (JavaPackage.Length != 0) { output.WriteRawTag(10); @@ -2815,7 +2863,7 @@ namespace Google.Protobuf.DescriptorProtos { output.WriteRawTag(66); output.WriteString(JavaOuterClassname); } - if (OptimizeFor != global::Google.Protobuf.DescriptorProtos.FileOptions.Types.OptimizeMode.SPEED) { + if (OptimizeFor != global::Google.Protobuf.Reflection.FileOptions.Types.OptimizeMode.SPEED) { output.WriteRawTag(72); output.WriteEnum((int) OptimizeFor); } @@ -2883,7 +2931,7 @@ namespace Google.Protobuf.DescriptorProtos { if (JavaStringCheckUtf8 != false) { size += 2 + 1; } - if (OptimizeFor != global::Google.Protobuf.DescriptorProtos.FileOptions.Types.OptimizeMode.SPEED) { + if (OptimizeFor != global::Google.Protobuf.Reflection.FileOptions.Types.OptimizeMode.SPEED) { size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) OptimizeFor); } if (GoPackage.Length != 0) { @@ -2933,7 +2981,7 @@ namespace Google.Protobuf.DescriptorProtos { if (other.JavaStringCheckUtf8 != false) { JavaStringCheckUtf8 = other.JavaStringCheckUtf8; } - if (other.OptimizeFor != global::Google.Protobuf.DescriptorProtos.FileOptions.Types.OptimizeMode.SPEED) { + if (other.OptimizeFor != global::Google.Protobuf.Reflection.FileOptions.Types.OptimizeMode.SPEED) { OptimizeFor = other.OptimizeFor; } if (other.GoPackage.Length != 0) { @@ -2983,7 +3031,7 @@ namespace Google.Protobuf.DescriptorProtos { break; } case 72: { - optimizeFor_ = (global::Google.Protobuf.DescriptorProtos.FileOptions.Types.OptimizeMode) input.ReadEnum(); + optimizeFor_ = (global::Google.Protobuf.Reflection.FileOptions.Types.OptimizeMode) input.ReadEnum(); break; } case 80: { @@ -3059,12 +3107,12 @@ namespace Google.Protobuf.DescriptorProtos { private static readonly string[] _fieldNames = new string[] { "deprecated", "map_entry", "message_set_wire_format", "no_standard_descriptor_accessor", "uninterpreted_option" }; private static readonly uint[] _fieldTags = new uint[] { 24, 56, 8, 16, 7994 }; - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.Descriptor.MessageTypes[10]; } + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.Descriptor.MessageTypes[10]; } } - public pb::FieldAccess.FieldAccessorTable Fields { - get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_MessageOptions__FieldAccessorTable; } + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.internal__static_google_protobuf_MessageOptions__FieldAccessorTable; } } private bool _frozen = false; @@ -3137,10 +3185,10 @@ namespace Google.Protobuf.DescriptorProtos { } public const int UninterpretedOptionFieldNumber = 999; - private static readonly pb::FieldCodec<global::Google.Protobuf.DescriptorProtos.UninterpretedOption> _repeated_uninterpretedOption_codec - = pb::FieldCodec.ForMessage(7994, global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Parser); - private readonly pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption> uninterpretedOption_ = new pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption>(); - internal pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption> UninterpretedOption { + private static readonly pb::FieldCodec<global::Google.Protobuf.Reflection.UninterpretedOption> _repeated_uninterpretedOption_codec + = pb::FieldCodec.ForMessage(7994, global::Google.Protobuf.Reflection.UninterpretedOption.Parser); + private readonly pbc::RepeatedField<global::Google.Protobuf.Reflection.UninterpretedOption> uninterpretedOption_ = new pbc::RepeatedField<global::Google.Protobuf.Reflection.UninterpretedOption>(); + internal pbc::RepeatedField<global::Google.Protobuf.Reflection.UninterpretedOption> UninterpretedOption { get { return uninterpretedOption_; } } @@ -3173,6 +3221,10 @@ namespace Google.Protobuf.DescriptorProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (MessageSetWireFormat != false) { output.WriteRawTag(8); @@ -3274,12 +3326,12 @@ namespace Google.Protobuf.DescriptorProtos { private static readonly string[] _fieldNames = new string[] { "ctype", "deprecated", "jstype", "lazy", "packed", "uninterpreted_option", "weak" }; private static readonly uint[] _fieldTags = new uint[] { 8, 24, 48, 40, 16, 7994, 80 }; - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.Descriptor.MessageTypes[11]; } + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.Descriptor.MessageTypes[11]; } } - public pb::FieldAccess.FieldAccessorTable Fields { - get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_FieldOptions__FieldAccessorTable; } + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.internal__static_google_protobuf_FieldOptions__FieldAccessorTable; } } private bool _frozen = false; @@ -3314,8 +3366,8 @@ namespace Google.Protobuf.DescriptorProtos { } public const int CtypeFieldNumber = 1; - private global::Google.Protobuf.DescriptorProtos.FieldOptions.Types.CType ctype_ = global::Google.Protobuf.DescriptorProtos.FieldOptions.Types.CType.STRING; - internal global::Google.Protobuf.DescriptorProtos.FieldOptions.Types.CType Ctype { + private global::Google.Protobuf.Reflection.FieldOptions.Types.CType ctype_ = global::Google.Protobuf.Reflection.FieldOptions.Types.CType.STRING; + internal global::Google.Protobuf.Reflection.FieldOptions.Types.CType Ctype { get { return ctype_; } set { pb::Freezable.CheckMutable(this); @@ -3334,8 +3386,8 @@ namespace Google.Protobuf.DescriptorProtos { } public const int JstypeFieldNumber = 6; - private global::Google.Protobuf.DescriptorProtos.FieldOptions.Types.JSType jstype_ = global::Google.Protobuf.DescriptorProtos.FieldOptions.Types.JSType.JS_NORMAL; - internal global::Google.Protobuf.DescriptorProtos.FieldOptions.Types.JSType Jstype { + private global::Google.Protobuf.Reflection.FieldOptions.Types.JSType jstype_ = global::Google.Protobuf.Reflection.FieldOptions.Types.JSType.JS_NORMAL; + internal global::Google.Protobuf.Reflection.FieldOptions.Types.JSType Jstype { get { return jstype_; } set { pb::Freezable.CheckMutable(this); @@ -3374,10 +3426,10 @@ namespace Google.Protobuf.DescriptorProtos { } public const int UninterpretedOptionFieldNumber = 999; - private static readonly pb::FieldCodec<global::Google.Protobuf.DescriptorProtos.UninterpretedOption> _repeated_uninterpretedOption_codec - = pb::FieldCodec.ForMessage(7994, global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Parser); - private readonly pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption> uninterpretedOption_ = new pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption>(); - internal pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption> UninterpretedOption { + private static readonly pb::FieldCodec<global::Google.Protobuf.Reflection.UninterpretedOption> _repeated_uninterpretedOption_codec + = pb::FieldCodec.ForMessage(7994, global::Google.Protobuf.Reflection.UninterpretedOption.Parser); + private readonly pbc::RepeatedField<global::Google.Protobuf.Reflection.UninterpretedOption> uninterpretedOption_ = new pbc::RepeatedField<global::Google.Protobuf.Reflection.UninterpretedOption>(); + internal pbc::RepeatedField<global::Google.Protobuf.Reflection.UninterpretedOption> UninterpretedOption { get { return uninterpretedOption_; } } @@ -3404,9 +3456,9 @@ namespace Google.Protobuf.DescriptorProtos { public override int GetHashCode() { int hash = 1; - if (Ctype != global::Google.Protobuf.DescriptorProtos.FieldOptions.Types.CType.STRING) hash ^= Ctype.GetHashCode(); + if (Ctype != global::Google.Protobuf.Reflection.FieldOptions.Types.CType.STRING) hash ^= Ctype.GetHashCode(); if (Packed != false) hash ^= Packed.GetHashCode(); - if (Jstype != global::Google.Protobuf.DescriptorProtos.FieldOptions.Types.JSType.JS_NORMAL) hash ^= Jstype.GetHashCode(); + if (Jstype != global::Google.Protobuf.Reflection.FieldOptions.Types.JSType.JS_NORMAL) hash ^= Jstype.GetHashCode(); if (Lazy != false) hash ^= Lazy.GetHashCode(); if (Deprecated != false) hash ^= Deprecated.GetHashCode(); if (Weak != false) hash ^= Weak.GetHashCode(); @@ -3414,8 +3466,12 @@ namespace Google.Protobuf.DescriptorProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { - if (Ctype != global::Google.Protobuf.DescriptorProtos.FieldOptions.Types.CType.STRING) { + if (Ctype != global::Google.Protobuf.Reflection.FieldOptions.Types.CType.STRING) { output.WriteRawTag(8); output.WriteEnum((int) Ctype); } @@ -3431,7 +3487,7 @@ namespace Google.Protobuf.DescriptorProtos { output.WriteRawTag(40); output.WriteBool(Lazy); } - if (Jstype != global::Google.Protobuf.DescriptorProtos.FieldOptions.Types.JSType.JS_NORMAL) { + if (Jstype != global::Google.Protobuf.Reflection.FieldOptions.Types.JSType.JS_NORMAL) { output.WriteRawTag(48); output.WriteEnum((int) Jstype); } @@ -3444,13 +3500,13 @@ namespace Google.Protobuf.DescriptorProtos { public int CalculateSize() { int size = 0; - if (Ctype != global::Google.Protobuf.DescriptorProtos.FieldOptions.Types.CType.STRING) { + if (Ctype != global::Google.Protobuf.Reflection.FieldOptions.Types.CType.STRING) { size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Ctype); } if (Packed != false) { size += 1 + 1; } - if (Jstype != global::Google.Protobuf.DescriptorProtos.FieldOptions.Types.JSType.JS_NORMAL) { + if (Jstype != global::Google.Protobuf.Reflection.FieldOptions.Types.JSType.JS_NORMAL) { size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Jstype); } if (Lazy != false) { @@ -3470,13 +3526,13 @@ namespace Google.Protobuf.DescriptorProtos { if (other == null) { return; } - if (other.Ctype != global::Google.Protobuf.DescriptorProtos.FieldOptions.Types.CType.STRING) { + if (other.Ctype != global::Google.Protobuf.Reflection.FieldOptions.Types.CType.STRING) { Ctype = other.Ctype; } if (other.Packed != false) { Packed = other.Packed; } - if (other.Jstype != global::Google.Protobuf.DescriptorProtos.FieldOptions.Types.JSType.JS_NORMAL) { + if (other.Jstype != global::Google.Protobuf.Reflection.FieldOptions.Types.JSType.JS_NORMAL) { Jstype = other.Jstype; } if (other.Lazy != false) { @@ -3503,7 +3559,7 @@ namespace Google.Protobuf.DescriptorProtos { } break; case 8: { - ctype_ = (global::Google.Protobuf.DescriptorProtos.FieldOptions.Types.CType) input.ReadEnum(); + ctype_ = (global::Google.Protobuf.Reflection.FieldOptions.Types.CType) input.ReadEnum(); break; } case 16: { @@ -3519,7 +3575,7 @@ namespace Google.Protobuf.DescriptorProtos { break; } case 48: { - jstype_ = (global::Google.Protobuf.DescriptorProtos.FieldOptions.Types.JSType) input.ReadEnum(); + jstype_ = (global::Google.Protobuf.Reflection.FieldOptions.Types.JSType) input.ReadEnum(); break; } case 80: { @@ -3561,12 +3617,12 @@ namespace Google.Protobuf.DescriptorProtos { private static readonly string[] _fieldNames = new string[] { "allow_alias", "deprecated", "uninterpreted_option" }; private static readonly uint[] _fieldTags = new uint[] { 16, 24, 7994 }; - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.Descriptor.MessageTypes[12]; } + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.Descriptor.MessageTypes[12]; } } - public pb::FieldAccess.FieldAccessorTable Fields { - get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_EnumOptions__FieldAccessorTable; } + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.internal__static_google_protobuf_EnumOptions__FieldAccessorTable; } } private bool _frozen = false; @@ -3617,10 +3673,10 @@ namespace Google.Protobuf.DescriptorProtos { } public const int UninterpretedOptionFieldNumber = 999; - private static readonly pb::FieldCodec<global::Google.Protobuf.DescriptorProtos.UninterpretedOption> _repeated_uninterpretedOption_codec - = pb::FieldCodec.ForMessage(7994, global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Parser); - private readonly pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption> uninterpretedOption_ = new pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption>(); - internal pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption> UninterpretedOption { + private static readonly pb::FieldCodec<global::Google.Protobuf.Reflection.UninterpretedOption> _repeated_uninterpretedOption_codec + = pb::FieldCodec.ForMessage(7994, global::Google.Protobuf.Reflection.UninterpretedOption.Parser); + private readonly pbc::RepeatedField<global::Google.Protobuf.Reflection.UninterpretedOption> uninterpretedOption_ = new pbc::RepeatedField<global::Google.Protobuf.Reflection.UninterpretedOption>(); + internal pbc::RepeatedField<global::Google.Protobuf.Reflection.UninterpretedOption> UninterpretedOption { get { return uninterpretedOption_; } } @@ -3649,6 +3705,10 @@ namespace Google.Protobuf.DescriptorProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (AllowAlias != false) { output.WriteRawTag(16); @@ -3722,12 +3782,12 @@ namespace Google.Protobuf.DescriptorProtos { private static readonly string[] _fieldNames = new string[] { "deprecated", "uninterpreted_option" }; private static readonly uint[] _fieldTags = new uint[] { 8, 7994 }; - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.Descriptor.MessageTypes[13]; } + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.Descriptor.MessageTypes[13]; } } - public pb::FieldAccess.FieldAccessorTable Fields { - get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_EnumValueOptions__FieldAccessorTable; } + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.internal__static_google_protobuf_EnumValueOptions__FieldAccessorTable; } } private bool _frozen = false; @@ -3767,10 +3827,10 @@ namespace Google.Protobuf.DescriptorProtos { } public const int UninterpretedOptionFieldNumber = 999; - private static readonly pb::FieldCodec<global::Google.Protobuf.DescriptorProtos.UninterpretedOption> _repeated_uninterpretedOption_codec - = pb::FieldCodec.ForMessage(7994, global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Parser); - private readonly pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption> uninterpretedOption_ = new pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption>(); - internal pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption> UninterpretedOption { + private static readonly pb::FieldCodec<global::Google.Protobuf.Reflection.UninterpretedOption> _repeated_uninterpretedOption_codec + = pb::FieldCodec.ForMessage(7994, global::Google.Protobuf.Reflection.UninterpretedOption.Parser); + private readonly pbc::RepeatedField<global::Google.Protobuf.Reflection.UninterpretedOption> uninterpretedOption_ = new pbc::RepeatedField<global::Google.Protobuf.Reflection.UninterpretedOption>(); + internal pbc::RepeatedField<global::Google.Protobuf.Reflection.UninterpretedOption> UninterpretedOption { get { return uninterpretedOption_; } } @@ -3797,6 +3857,10 @@ namespace Google.Protobuf.DescriptorProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (Deprecated != false) { output.WriteRawTag(8); @@ -3856,12 +3920,12 @@ namespace Google.Protobuf.DescriptorProtos { private static readonly string[] _fieldNames = new string[] { "deprecated", "uninterpreted_option" }; private static readonly uint[] _fieldTags = new uint[] { 264, 7994 }; - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.Descriptor.MessageTypes[14]; } + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.Descriptor.MessageTypes[14]; } } - public pb::FieldAccess.FieldAccessorTable Fields { - get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_ServiceOptions__FieldAccessorTable; } + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.internal__static_google_protobuf_ServiceOptions__FieldAccessorTable; } } private bool _frozen = false; @@ -3901,10 +3965,10 @@ namespace Google.Protobuf.DescriptorProtos { } public const int UninterpretedOptionFieldNumber = 999; - private static readonly pb::FieldCodec<global::Google.Protobuf.DescriptorProtos.UninterpretedOption> _repeated_uninterpretedOption_codec - = pb::FieldCodec.ForMessage(7994, global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Parser); - private readonly pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption> uninterpretedOption_ = new pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption>(); - internal pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption> UninterpretedOption { + private static readonly pb::FieldCodec<global::Google.Protobuf.Reflection.UninterpretedOption> _repeated_uninterpretedOption_codec + = pb::FieldCodec.ForMessage(7994, global::Google.Protobuf.Reflection.UninterpretedOption.Parser); + private readonly pbc::RepeatedField<global::Google.Protobuf.Reflection.UninterpretedOption> uninterpretedOption_ = new pbc::RepeatedField<global::Google.Protobuf.Reflection.UninterpretedOption>(); + internal pbc::RepeatedField<global::Google.Protobuf.Reflection.UninterpretedOption> UninterpretedOption { get { return uninterpretedOption_; } } @@ -3931,6 +3995,10 @@ namespace Google.Protobuf.DescriptorProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (Deprecated != false) { output.WriteRawTag(136, 2); @@ -3990,12 +4058,12 @@ namespace Google.Protobuf.DescriptorProtos { private static readonly string[] _fieldNames = new string[] { "deprecated", "uninterpreted_option" }; private static readonly uint[] _fieldTags = new uint[] { 264, 7994 }; - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.Descriptor.MessageTypes[15]; } + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.Descriptor.MessageTypes[15]; } } - public pb::FieldAccess.FieldAccessorTable Fields { - get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_MethodOptions__FieldAccessorTable; } + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.internal__static_google_protobuf_MethodOptions__FieldAccessorTable; } } private bool _frozen = false; @@ -4035,10 +4103,10 @@ namespace Google.Protobuf.DescriptorProtos { } public const int UninterpretedOptionFieldNumber = 999; - private static readonly pb::FieldCodec<global::Google.Protobuf.DescriptorProtos.UninterpretedOption> _repeated_uninterpretedOption_codec - = pb::FieldCodec.ForMessage(7994, global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Parser); - private readonly pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption> uninterpretedOption_ = new pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption>(); - internal pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption> UninterpretedOption { + private static readonly pb::FieldCodec<global::Google.Protobuf.Reflection.UninterpretedOption> _repeated_uninterpretedOption_codec + = pb::FieldCodec.ForMessage(7994, global::Google.Protobuf.Reflection.UninterpretedOption.Parser); + private readonly pbc::RepeatedField<global::Google.Protobuf.Reflection.UninterpretedOption> uninterpretedOption_ = new pbc::RepeatedField<global::Google.Protobuf.Reflection.UninterpretedOption>(); + internal pbc::RepeatedField<global::Google.Protobuf.Reflection.UninterpretedOption> UninterpretedOption { get { return uninterpretedOption_; } } @@ -4065,6 +4133,10 @@ namespace Google.Protobuf.DescriptorProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (Deprecated != false) { output.WriteRawTag(136, 2); @@ -4124,12 +4196,12 @@ namespace Google.Protobuf.DescriptorProtos { private static readonly string[] _fieldNames = new string[] { "aggregate_value", "double_value", "identifier_value", "name", "negative_int_value", "positive_int_value", "string_value" }; private static readonly uint[] _fieldTags = new uint[] { 66, 49, 26, 18, 40, 32, 58 }; - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.Descriptor.MessageTypes[16]; } + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.Descriptor.MessageTypes[16]; } } - public pb::FieldAccess.FieldAccessorTable Fields { - get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_UninterpretedOption__FieldAccessorTable; } + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.internal__static_google_protobuf_UninterpretedOption__FieldAccessorTable; } } private bool _frozen = false; @@ -4164,10 +4236,10 @@ namespace Google.Protobuf.DescriptorProtos { } public const int NameFieldNumber = 2; - private static readonly pb::FieldCodec<global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Types.NamePart> _repeated_name_codec - = pb::FieldCodec.ForMessage(18, global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Types.NamePart.Parser); - private readonly pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Types.NamePart> name_ = new pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Types.NamePart>(); - internal pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Types.NamePart> Name { + private static readonly pb::FieldCodec<global::Google.Protobuf.Reflection.UninterpretedOption.Types.NamePart> _repeated_name_codec + = pb::FieldCodec.ForMessage(18, global::Google.Protobuf.Reflection.UninterpretedOption.Types.NamePart.Parser); + private readonly pbc::RepeatedField<global::Google.Protobuf.Reflection.UninterpretedOption.Types.NamePart> name_ = new pbc::RepeatedField<global::Google.Protobuf.Reflection.UninterpretedOption.Types.NamePart>(); + internal pbc::RepeatedField<global::Google.Protobuf.Reflection.UninterpretedOption.Types.NamePart> Name { get { return name_; } } @@ -4264,6 +4336,10 @@ namespace Google.Protobuf.DescriptorProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { name_.WriteTo(output, _repeated_name_codec); if (IdentifierValue.Length != 0) { @@ -4394,12 +4470,12 @@ namespace Google.Protobuf.DescriptorProtos { private static readonly string[] _fieldNames = new string[] { "is_extension", "name_part" }; private static readonly uint[] _fieldTags = new uint[] { 16, 10 }; - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Descriptor.NestedTypes[0]; } + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.Reflection.UninterpretedOption.Descriptor.NestedTypes[0]; } } - public pb::FieldAccess.FieldAccessorTable Fields { - get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_UninterpretedOption_NamePart__FieldAccessorTable; } + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.internal__static_google_protobuf_UninterpretedOption_NamePart__FieldAccessorTable; } } private bool _frozen = false; @@ -4470,6 +4546,10 @@ namespace Google.Protobuf.DescriptorProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (NamePart_.Length != 0) { output.WriteRawTag(10); @@ -4541,12 +4621,12 @@ namespace Google.Protobuf.DescriptorProtos { private static readonly string[] _fieldNames = new string[] { "location" }; private static readonly uint[] _fieldTags = new uint[] { 10 }; - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.Descriptor.MessageTypes[17]; } + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.Descriptor.MessageTypes[17]; } } - public pb::FieldAccess.FieldAccessorTable Fields { - get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_SourceCodeInfo__FieldAccessorTable; } + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.internal__static_google_protobuf_SourceCodeInfo__FieldAccessorTable; } } private bool _frozen = false; @@ -4575,10 +4655,10 @@ namespace Google.Protobuf.DescriptorProtos { } public const int LocationFieldNumber = 1; - private static readonly pb::FieldCodec<global::Google.Protobuf.DescriptorProtos.SourceCodeInfo.Types.Location> _repeated_location_codec - = pb::FieldCodec.ForMessage(10, global::Google.Protobuf.DescriptorProtos.SourceCodeInfo.Types.Location.Parser); - private readonly pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.SourceCodeInfo.Types.Location> location_ = new pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.SourceCodeInfo.Types.Location>(); - internal pbc::RepeatedField<global::Google.Protobuf.DescriptorProtos.SourceCodeInfo.Types.Location> Location { + private static readonly pb::FieldCodec<global::Google.Protobuf.Reflection.SourceCodeInfo.Types.Location> _repeated_location_codec + = pb::FieldCodec.ForMessage(10, global::Google.Protobuf.Reflection.SourceCodeInfo.Types.Location.Parser); + private readonly pbc::RepeatedField<global::Google.Protobuf.Reflection.SourceCodeInfo.Types.Location> location_ = new pbc::RepeatedField<global::Google.Protobuf.Reflection.SourceCodeInfo.Types.Location>(); + internal pbc::RepeatedField<global::Google.Protobuf.Reflection.SourceCodeInfo.Types.Location> Location { get { return location_; } } @@ -4603,6 +4683,10 @@ namespace Google.Protobuf.DescriptorProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { location_.WriteTo(output, _repeated_location_codec); } @@ -4649,12 +4733,12 @@ namespace Google.Protobuf.DescriptorProtos { private static readonly string[] _fieldNames = new string[] { "leading_comments", "leading_detached_comments", "path", "span", "trailing_comments" }; private static readonly uint[] _fieldTags = new uint[] { 26, 50, 10, 18, 34 }; - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.DescriptorProtos.SourceCodeInfo.Descriptor.NestedTypes[0]; } + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.Reflection.SourceCodeInfo.Descriptor.NestedTypes[0]; } } - public pb::FieldAccess.FieldAccessorTable Fields { - get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_SourceCodeInfo_Location__FieldAccessorTable; } + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.internal__static_google_protobuf_SourceCodeInfo_Location__FieldAccessorTable; } } private bool _frozen = false; @@ -4761,6 +4845,10 @@ namespace Google.Protobuf.DescriptorProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { path_.WriteTo(output, _repeated_path_codec); span_.WriteTo(output, _repeated_span_codec); diff --git a/csharp/src/ProtocolBuffers/Descriptors/DescriptorUtil.cs b/csharp/src/ProtocolBuffers/Reflection/DescriptorUtil.cs index eb4ced60..af31dfb1 100644 --- a/csharp/src/ProtocolBuffers/Descriptors/DescriptorUtil.cs +++ b/csharp/src/ProtocolBuffers/Reflection/DescriptorUtil.cs @@ -1,65 +1,65 @@ -#region Copyright notice and license
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc. All rights reserved.
-// https://developers.google.com/protocol-buffers/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#endregion
-
-using System.Collections.Generic;
-using System.Collections.ObjectModel;
-
-namespace Google.Protobuf.Descriptors
-{
- /// <summary>
- /// Internal class containing utility methods when working with descriptors.
- /// </summary>
- internal static class DescriptorUtil
- {
- /// <summary>
- /// Equivalent to Func[TInput, int, TOutput] but usable in .NET 2.0. Only used to convert
- /// arrays.
- /// </summary>
- internal delegate TOutput IndexedConverter<TInput, TOutput>(TInput element, int index);
-
- /// <summary>
- /// Converts the given array into a read-only list, applying the specified conversion to
- /// each input element.
- /// </summary>
- internal static IList<TOutput> ConvertAndMakeReadOnly<TInput, TOutput>(IList<TInput> input,
- IndexedConverter<TInput, TOutput>
- converter)
- {
- TOutput[] array = new TOutput[input.Count];
- for (int i = 0; i < array.Length; i++)
- {
- array[i] = converter(input[i], i);
- }
- return new ReadOnlyCollection<TOutput>(array);
- }
- }
+#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +using System.Collections.Generic; +using System.Collections.ObjectModel; + +namespace Google.Protobuf.Reflection +{ + /// <summary> + /// Internal class containing utility methods when working with descriptors. + /// </summary> + internal static class DescriptorUtil + { + /// <summary> + /// Equivalent to Func[TInput, int, TOutput] but usable in .NET 2.0. Only used to convert + /// arrays. + /// </summary> + internal delegate TOutput IndexedConverter<TInput, TOutput>(TInput element, int index); + + /// <summary> + /// Converts the given array into a read-only list, applying the specified conversion to + /// each input element. + /// </summary> + internal static IList<TOutput> ConvertAndMakeReadOnly<TInput, TOutput>(IList<TInput> input, + IndexedConverter<TInput, TOutput> + converter) + { + TOutput[] array = new TOutput[input.Count]; + for (int i = 0; i < array.Length; i++) + { + array[i] = converter(input[i], i); + } + return new ReadOnlyCollection<TOutput>(array); + } + } }
\ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/Descriptors/DescriptorValidationException.cs b/csharp/src/ProtocolBuffers/Reflection/DescriptorValidationException.cs index 855eda61..143671db 100644 --- a/csharp/src/ProtocolBuffers/Descriptors/DescriptorValidationException.cs +++ b/csharp/src/ProtocolBuffers/Reflection/DescriptorValidationException.cs @@ -1,80 +1,80 @@ -#region Copyright notice and license
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc. All rights reserved.
-// https://developers.google.com/protocol-buffers/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#endregion
-
-using System;
-
-namespace Google.Protobuf.Descriptors
-{
- /// <summary>
- /// Thrown when building descriptors fails because the source DescriptorProtos
- /// are not valid.
- /// </summary>
- public sealed class DescriptorValidationException : Exception
- {
- private readonly String name;
- private readonly string description;
-
- /// <value>
- /// The full name of the descriptor where the error occurred.
- /// </value>
- public String ProblemSymbolName
- {
- get { return name; }
- }
-
- /// <value>
- /// A human-readable description of the error. (The Message property
- /// is made up of the descriptor's name and this description.)
- /// </value>
- public string Description
- {
- get { return description; }
- }
-
- internal DescriptorValidationException(IDescriptor problemDescriptor, string description) :
- base(problemDescriptor.FullName + ": " + description)
- {
- // Note that problemDescriptor may be partially uninitialized, so we
- // don't want to expose it directly to the user. So, we only provide
- // the name and the original proto.
- name = problemDescriptor.FullName;
- this.description = description;
- }
-
- internal DescriptorValidationException(IDescriptor problemDescriptor, string description, Exception cause) :
- base(problemDescriptor.FullName + ": " + description, cause)
- {
- name = problemDescriptor.FullName;
- this.description = description;
- }
- }
+#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +using System; + +namespace Google.Protobuf.Reflection +{ + /// <summary> + /// Thrown when building descriptors fails because the source DescriptorProtos + /// are not valid. + /// </summary> + public sealed class DescriptorValidationException : Exception + { + private readonly String name; + private readonly string description; + + /// <value> + /// The full name of the descriptor where the error occurred. + /// </value> + public String ProblemSymbolName + { + get { return name; } + } + + /// <value> + /// A human-readable description of the error. (The Message property + /// is made up of the descriptor's name and this description.) + /// </value> + public string Description + { + get { return description; } + } + + internal DescriptorValidationException(IDescriptor problemDescriptor, string description) : + base(problemDescriptor.FullName + ": " + description) + { + // Note that problemDescriptor may be partially uninitialized, so we + // don't want to expose it directly to the user. So, we only provide + // the name and the original proto. + name = problemDescriptor.FullName; + this.description = description; + } + + internal DescriptorValidationException(IDescriptor problemDescriptor, string description, Exception cause) : + base(problemDescriptor.FullName + ": " + description, cause) + { + name = problemDescriptor.FullName; + this.description = description; + } + } }
\ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/Descriptors/EnumDescriptor.cs b/csharp/src/ProtocolBuffers/Reflection/EnumDescriptor.cs index a6db5268..bf8f8c83 100644 --- a/csharp/src/ProtocolBuffers/Descriptors/EnumDescriptor.cs +++ b/csharp/src/ProtocolBuffers/Reflection/EnumDescriptor.cs @@ -1,108 +1,108 @@ -#region Copyright notice and license
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc. All rights reserved.
-// https://developers.google.com/protocol-buffers/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#endregion
-
-using System.Collections.Generic;
-using Google.Protobuf.DescriptorProtos;
-
-namespace Google.Protobuf.Descriptors
-{
- /// <summary>
- /// Descriptor for an enum type in a .proto file.
- /// </summary>
- public sealed class EnumDescriptor : DescriptorBase
- {
- private readonly EnumDescriptorProto proto;
- private readonly MessageDescriptor containingType;
- private readonly IList<EnumValueDescriptor> values;
-
- internal EnumDescriptor(EnumDescriptorProto proto, FileDescriptor file, MessageDescriptor parent, int index)
- : base(file, file.ComputeFullName(parent, proto.Name), index)
- {
- this.proto = proto;
- containingType = parent;
-
- if (proto.Value.Count == 0)
- {
- // We cannot allow enums with no values because this would mean there
- // would be no valid default value for fields of this type.
- throw new DescriptorValidationException(this, "Enums must contain at least one value.");
- }
-
- values = DescriptorUtil.ConvertAndMakeReadOnly(proto.Value,
- (value, i) => new EnumValueDescriptor(value, file, this, i));
-
- File.DescriptorPool.AddSymbol(this);
- }
-
- internal EnumDescriptorProto Proto { get { return proto; } }
-
- /// <summary>
- /// The brief name of the descriptor's target.
- /// </summary>
- public override string Name { get { return proto.Name; } }
-
- /// <value>
- /// If this is a nested type, get the outer descriptor, otherwise null.
- /// </value>
- public MessageDescriptor ContainingType
- {
- get { return containingType; }
- }
-
- /// <value>
- /// An unmodifiable list of defined value descriptors for this enum.
- /// </value>
- public IList<EnumValueDescriptor> Values
- {
- get { return values; }
- }
-
- /// <summary>
- /// Finds an enum value by number. If multiple enum values have the
- /// same number, this returns the first defined value with that number.
- /// </summary>
- public EnumValueDescriptor FindValueByNumber(int number)
- {
- return File.DescriptorPool.FindEnumValueByNumber(this, number);
- }
-
- /// <summary>
- /// Finds an enum value by name.
- /// </summary>
- /// <param name="name">The unqualified name of the value (e.g. "FOO").</param>
- /// <returns>The value's descriptor, or null if not found.</returns>
- public EnumValueDescriptor FindValueByName(string name)
- {
- return File.DescriptorPool.FindSymbol<EnumValueDescriptor>(FullName + "." + name);
- }
- }
+#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +using System.Collections.Generic; + +namespace Google.Protobuf.Reflection +{ + /// <summary> + /// Descriptor for an enum type in a .proto file. + /// </summary> + public sealed class EnumDescriptor : DescriptorBase + { + private readonly EnumDescriptorProto proto; + private readonly MessageDescriptor containingType; + private readonly IList<EnumValueDescriptor> values; + + internal EnumDescriptor(EnumDescriptorProto proto, FileDescriptor file, MessageDescriptor parent, int index) + : base(file, file.ComputeFullName(parent, proto.Name), index) + { + this.proto = proto; + containingType = parent; + + if (proto.Value.Count == 0) + { + // We cannot allow enums with no values because this would mean there + // would be no valid default value for fields of this type. + throw new DescriptorValidationException(this, "Enums must contain at least one value."); + } + + values = DescriptorUtil.ConvertAndMakeReadOnly(proto.Value, + (value, i) => new EnumValueDescriptor(value, file, this, i)); + + File.DescriptorPool.AddSymbol(this); + } + + internal EnumDescriptorProto Proto { get { return proto; } } + + /// <summary> + /// The brief name of the descriptor's target. + /// </summary> + public override string Name { get { return proto.Name; } } + + /// <value> + /// If this is a nested type, get the outer descriptor, otherwise null. + /// </value> + public MessageDescriptor ContainingType + { + get { return containingType; } + } + + /// <value> + /// An unmodifiable list of defined value descriptors for this enum. + /// </value> + public IList<EnumValueDescriptor> Values + { + get { return values; } + } + + /// <summary> + /// Finds an enum value by number. If multiple enum values have the + /// same number, this returns the first defined value with that number. + /// If there is no value for the given number, this returns <c>null</c>. + /// </summary> + public EnumValueDescriptor FindValueByNumber(int number) + { + return File.DescriptorPool.FindEnumValueByNumber(this, number); + } + + /// <summary> + /// Finds an enum value by name. + /// </summary> + /// <param name="name">The unqualified name of the value (e.g. "FOO").</param> + /// <returns>The value's descriptor, or null if not found.</returns> + public EnumValueDescriptor FindValueByName(string name) + { + return File.DescriptorPool.FindSymbol<EnumValueDescriptor>(FullName + "." + name); + } + } }
\ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/Descriptors/EnumValueDescriptor.cs b/csharp/src/ProtocolBuffers/Reflection/EnumValueDescriptor.cs index e609b1f8..29833c4a 100644 --- a/csharp/src/ProtocolBuffers/Descriptors/EnumValueDescriptor.cs +++ b/csharp/src/ProtocolBuffers/Reflection/EnumValueDescriptor.cs @@ -1,63 +1,61 @@ -#region Copyright notice and license
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc. All rights reserved.
-// https://developers.google.com/protocol-buffers/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#endregion
-
-using Google.Protobuf.DescriptorProtos;
-
-namespace Google.Protobuf.Descriptors
-{
- /// <summary>
- /// Descriptor for a single enum value within an enum in a .proto file.
- /// </summary>
- public sealed class EnumValueDescriptor : DescriptorBase
- {
- private readonly EnumDescriptor enumDescriptor;
- private readonly EnumValueDescriptorProto proto;
-
- internal EnumValueDescriptor(EnumValueDescriptorProto proto, FileDescriptor file,
- EnumDescriptor parent, int index)
- : base(file, parent.FullName + "." + proto.Name, index)
- {
- this.proto = proto;
- enumDescriptor = parent;
- file.DescriptorPool.AddSymbol(this);
- file.DescriptorPool.AddEnumValueByNumber(this);
- }
-
- internal EnumValueDescriptorProto Proto { get { return proto; } }
-
- public override string Name { get { return proto.Name; } }
-
- public int Number { get { return Proto.Number; } }
-
- public EnumDescriptor EnumDescriptor { get { return enumDescriptor; } }
- }
+#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +namespace Google.Protobuf.Reflection +{ + /// <summary> + /// Descriptor for a single enum value within an enum in a .proto file. + /// </summary> + public sealed class EnumValueDescriptor : DescriptorBase + { + private readonly EnumDescriptor enumDescriptor; + private readonly EnumValueDescriptorProto proto; + + internal EnumValueDescriptor(EnumValueDescriptorProto proto, FileDescriptor file, + EnumDescriptor parent, int index) + : base(file, parent.FullName + "." + proto.Name, index) + { + this.proto = proto; + enumDescriptor = parent; + file.DescriptorPool.AddSymbol(this); + file.DescriptorPool.AddEnumValueByNumber(this); + } + + internal EnumValueDescriptorProto Proto { get { return proto; } } + + public override string Name { get { return proto.Name; } } + + public int Number { get { return Proto.Number; } } + + public EnumDescriptor EnumDescriptor { get { return enumDescriptor; } } + } }
\ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/FieldAccess/FieldAccessorBase.cs b/csharp/src/ProtocolBuffers/Reflection/FieldAccessorBase.cs index 2a3e5b8b..39a63b47 100644 --- a/csharp/src/ProtocolBuffers/FieldAccess/FieldAccessorBase.cs +++ b/csharp/src/ProtocolBuffers/Reflection/FieldAccessorBase.cs @@ -32,9 +32,8 @@ using System; using System.Reflection; -using Google.Protobuf.Descriptors; -namespace Google.Protobuf.FieldAccess +namespace Google.Protobuf.Reflection { /// <summary> /// Base class for field accessors. diff --git a/csharp/src/ProtocolBuffers/FieldAccess/FieldAccessorTable.cs b/csharp/src/ProtocolBuffers/Reflection/FieldAccessorTable.cs index 57ea9c87..24fcbc64 100644 --- a/csharp/src/ProtocolBuffers/FieldAccess/FieldAccessorTable.cs +++ b/csharp/src/ProtocolBuffers/Reflection/FieldAccessorTable.cs @@ -1,99 +1,97 @@ -#region Copyright notice and license
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc. All rights reserved.
-// https://developers.google.com/protocol-buffers/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#endregion
-
-using System;
-using System.Collections.ObjectModel;
-using Google.Protobuf.Descriptors;
-
-namespace Google.Protobuf.FieldAccess
-{
- /// <summary>
- /// Provides access to fields in generated messages via reflection.
- /// </summary>
- public sealed class FieldAccessorTable
- {
- private readonly ReadOnlyCollection<IFieldAccessor> accessors;
- private readonly MessageDescriptor descriptor;
-
- /// <summary>
- /// Constructs a FieldAccessorTable for a particular message class.
- /// Only one FieldAccessorTable should be constructed per class.
- /// </summary>
- /// <param name="type">The CLR type for the message.</param>
- /// <param name="descriptor">The type's descriptor</param>
- /// <param name="propertyNames">The Pascal-case names of all the field-based properties in the message.</param>
- public FieldAccessorTable(Type type, MessageDescriptor descriptor, string[] propertyNames)
- {
- this.descriptor = descriptor;
- var accessorsArray = new IFieldAccessor[descriptor.Fields.Count];
- for (int i = 0; i < accessorsArray.Length; i++)
- {
- var field = descriptor.Fields[i];
- var name = propertyNames[i];
- accessorsArray[i] =
- field.IsMap ? new MapFieldAccessor(type, name, field)
- : field.IsRepeated ? new RepeatedFieldAccessor(type, name, field)
- : (IFieldAccessor) new SingleFieldAccessor(type, name, field);
- }
- accessors = new ReadOnlyCollection<IFieldAccessor>(accessorsArray);
- // TODO(jonskeet): Oneof support
- }
-
- // TODO: Validate the name here... should possibly make this type a more "general reflection access" type,
- // bearing in mind the oneof parts to come as well.
- /// <summary>
- /// Returns all of the field accessors for the message type.
- /// </summary>
- public ReadOnlyCollection<IFieldAccessor> Accessors { get { return accessors; } }
-
- public IFieldAccessor this[int fieldNumber]
- {
- get
- {
- FieldDescriptor field = descriptor.FindFieldByNumber(fieldNumber);
- return accessors[field.Index];
- }
- }
-
- internal IFieldAccessor this[FieldDescriptor field]
- {
- get
- {
- if (field.ContainingType != descriptor)
- {
- throw new ArgumentException("FieldDescriptor does not match message type.");
- }
- return accessors[field.Index];
- }
- }
- }
+#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +using System; +using System.Collections.ObjectModel; + +namespace Google.Protobuf.Reflection +{ + /// <summary> + /// Provides access to fields in generated messages via reflection. + /// </summary> + public sealed class FieldAccessorTable + { + private readonly ReadOnlyCollection<IFieldAccessor> accessors; + private readonly ReadOnlyCollection<OneofAccessor> oneofs; + private readonly MessageDescriptor descriptor; + + /// <summary> + /// Constructs a FieldAccessorTable for a particular message class. + /// Only one FieldAccessorTable should be constructed per class. + /// </summary> + /// <param name="type">The CLR type for the message.</param> + /// <param name="descriptor">The type's descriptor</param> + /// <param name="propertyNames">The Pascal-case names of all the field-based properties in the message.</param> + public FieldAccessorTable(Type type, MessageDescriptor descriptor, string[] propertyNames, string[] oneofPropertyNames) + { + this.descriptor = descriptor; + var accessorsArray = new IFieldAccessor[descriptor.Fields.Count]; + for (int i = 0; i < accessorsArray.Length; i++) + { + var field = descriptor.Fields[i]; + var name = propertyNames[i]; + accessorsArray[i] = + field.IsMap ? new MapFieldAccessor(type, name, field) + : field.IsRepeated ? new RepeatedFieldAccessor(type, name, field) + : (IFieldAccessor) new SingleFieldAccessor(type, name, field); + } + accessors = new ReadOnlyCollection<IFieldAccessor>(accessorsArray); + var oneofsArray = new OneofAccessor[descriptor.Oneofs.Count]; + for (int i = 0; i < oneofsArray.Length; i++) + { + var oneof = descriptor.Oneofs[i]; + oneofsArray[i] = new OneofAccessor(type, oneofPropertyNames[i], oneof); + } + oneofs = new ReadOnlyCollection<OneofAccessor>(oneofsArray); + } + + // TODO: Validate the name here... should possibly make this type a more "general reflection access" type, + // bearing in mind the oneof parts to come as well. + /// <summary> + /// Returns all of the field accessors for the message type. + /// </summary> + public ReadOnlyCollection<IFieldAccessor> Accessors { get { return accessors; } } + + public ReadOnlyCollection<OneofAccessor> Oneofs { get { return oneofs; } } + + // TODO: Review this, as it's easy to get confused between FieldNumber and Index. + // Currently only used to get an accessor related to a oneof... maybe just make that simpler? + public IFieldAccessor this[int fieldNumber] + { + get + { + FieldDescriptor field = descriptor.FindFieldByNumber(fieldNumber); + return accessors[field.Index]; + } + } + } }
\ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/Descriptors/FieldDescriptor.cs b/csharp/src/ProtocolBuffers/Reflection/FieldDescriptor.cs index 7af69bbb..3d9d0d75 100644 --- a/csharp/src/ProtocolBuffers/Descriptors/FieldDescriptor.cs +++ b/csharp/src/ProtocolBuffers/Reflection/FieldDescriptor.cs @@ -1,293 +1,292 @@ -#region Copyright notice and license
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc. All rights reserved.
-// https://developers.google.com/protocol-buffers/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#endregion
-
-using System;
-using Google.Protobuf.DescriptorProtos;
-
-namespace Google.Protobuf.Descriptors
-{
- /// <summary>
- /// Descriptor for a field or extension within a message in a .proto file.
- /// </summary>
- public sealed class FieldDescriptor : DescriptorBase, IComparable<FieldDescriptor>
- {
- private readonly FieldDescriptorProto proto;
- private EnumDescriptor enumType;
- private MessageDescriptor messageType;
- private readonly MessageDescriptor containingType;
- private readonly OneofDescriptor containingOneof;
- private FieldType fieldType;
-
- internal FieldDescriptor(FieldDescriptorProto proto, FileDescriptor file,
- MessageDescriptor parent, int index)
- : base(file, file.ComputeFullName(parent, proto.Name), index)
- {
- this.proto = proto;
- if (proto.Type != 0)
- {
- fieldType = GetFieldTypeFromProtoType(proto.Type);
- }
-
- if (FieldNumber <= 0)
- {
- throw new DescriptorValidationException(this,
- "Field numbers must be positive integers.");
- }
- containingType = parent;
- // OneofIndex "defaults" to -1 due to a hack in FieldDescriptor.OnConstruction.
- if (proto.OneofIndex != -1)
- {
- if (proto.OneofIndex < 0 || proto.OneofIndex >= parent.Proto.OneofDecl.Count)
- {
- throw new DescriptorValidationException(this,
- "FieldDescriptorProto.oneof_index is out of range for type " + parent.Name);
- }
- containingOneof = parent.Oneofs[proto.OneofIndex];
- }
-
- file.DescriptorPool.AddSymbol(this);
- }
-
- /// <summary>
- /// The brief name of the descriptor's target.
- /// </summary>
- public override string Name { get { return proto.Name; } }
-
- internal FieldDescriptorProto Proto { get { return proto; } }
-
- /// <summary>
- /// Maps a field type as included in the .proto file to a FieldType.
- /// </summary>
- private static FieldType GetFieldTypeFromProtoType(FieldDescriptorProto.Types.Type type)
- {
- switch (type)
- {
- case FieldDescriptorProto.Types.Type.TYPE_DOUBLE:
- return FieldType.Double;
- case FieldDescriptorProto.Types.Type.TYPE_FLOAT:
- return FieldType.Float;
- case FieldDescriptorProto.Types.Type.TYPE_INT64:
- return FieldType.Int64;
- case FieldDescriptorProto.Types.Type.TYPE_UINT64:
- return FieldType.UInt64;
- case FieldDescriptorProto.Types.Type.TYPE_INT32:
- return FieldType.Int32;
- case FieldDescriptorProto.Types.Type.TYPE_FIXED64:
- return FieldType.Fixed64;
- case FieldDescriptorProto.Types.Type.TYPE_FIXED32:
- return FieldType.Fixed32;
- case FieldDescriptorProto.Types.Type.TYPE_BOOL:
- return FieldType.Bool;
- case FieldDescriptorProto.Types.Type.TYPE_STRING:
- return FieldType.String;
- case FieldDescriptorProto.Types.Type.TYPE_GROUP:
- return FieldType.Group;
- case FieldDescriptorProto.Types.Type.TYPE_MESSAGE:
- return FieldType.Message;
- case FieldDescriptorProto.Types.Type.TYPE_BYTES:
- return FieldType.Bytes;
- case FieldDescriptorProto.Types.Type.TYPE_UINT32:
- return FieldType.UInt32;
- case FieldDescriptorProto.Types.Type.TYPE_ENUM:
- return FieldType.Enum;
- case FieldDescriptorProto.Types.Type.TYPE_SFIXED32:
- return FieldType.SFixed32;
- case FieldDescriptorProto.Types.Type.TYPE_SFIXED64:
- return FieldType.SFixed64;
- case FieldDescriptorProto.Types.Type.TYPE_SINT32:
- return FieldType.SInt32;
- case FieldDescriptorProto.Types.Type.TYPE_SINT64:
- return FieldType.SInt64;
- default:
- throw new ArgumentException("Invalid type specified");
- }
- }
-
- public bool IsRepeated
- {
- get { return Proto.Label == FieldDescriptorProto.Types.Label.LABEL_REPEATED; }
- }
-
- public bool IsMap
- {
- get { return fieldType == FieldType.Message && messageType.Proto.Options != null && messageType.Proto.Options.MapEntry; }
- }
-
- public bool IsPacked
- {
- get { return Proto.Options != null && Proto.Options.Packed; }
- }
-
- /// <summary>
- /// Get the field's containing type. For extensions, this is the type being
- /// extended, not the location where the extension was defined. See
- /// <see cref="ExtensionScope" />.
- /// </summary>
- public MessageDescriptor ContainingType
- {
- get { return containingType; }
- }
-
- public OneofDescriptor ContainingOneof
- {
- get { return containingOneof; }
- }
-
- public FieldType FieldType
- {
- get { return fieldType; }
- }
-
- public int FieldNumber
- {
- get { return Proto.Number; }
- }
-
- /// <summary>
- /// Compares this descriptor with another one, ordering in "canonical" order
- /// which simply means ascending order by field number. <paramref name="other"/>
- /// must be a field of the same type, i.e. the <see cref="ContainingType"/> of
- /// both fields must be the same.
- /// </summary>
- public int CompareTo(FieldDescriptor other)
- {
- if (other.containingType != containingType)
- {
- throw new ArgumentException("FieldDescriptors can only be compared to other FieldDescriptors " +
- "for fields of the same message type.");
- }
- return FieldNumber - other.FieldNumber;
- }
-
- /// <summary>
- /// For enum fields, returns the field's type.
- /// </summary>
- public EnumDescriptor EnumType
- {
- get
- {
- if (fieldType != FieldType.Enum)
- {
- throw new InvalidOperationException("EnumType is only valid for enum fields.");
- }
- return enumType;
- }
- }
-
- /// <summary>
- /// For embedded message and group fields, returns the field's type.
- /// </summary>
- public MessageDescriptor MessageType
- {
- get
- {
- if (fieldType != FieldType.Message)
- {
- throw new InvalidOperationException("MessageType is only valid for enum fields.");
- }
- return messageType;
- }
- }
-
- /// <summary>
- /// Look up and cross-link all field types etc.
- /// </summary>
- internal void CrossLink()
- {
- if (Proto.TypeName != "")
- {
- IDescriptor typeDescriptor =
- File.DescriptorPool.LookupSymbol(Proto.TypeName, this);
-
- if (Proto.Type != 0)
- {
- // Choose field type based on symbol.
- if (typeDescriptor is MessageDescriptor)
- {
- fieldType = FieldType.Message;
- }
- else if (typeDescriptor is EnumDescriptor)
- {
- fieldType = FieldType.Enum;
- }
- else
- {
- throw new DescriptorValidationException(this, "\"" + Proto.TypeName + "\" is not a type.");
- }
- }
-
- if (fieldType == FieldType.Message)
- {
- if (!(typeDescriptor is MessageDescriptor))
- {
- throw new DescriptorValidationException(this,
- "\"" + Proto.TypeName + "\" is not a message type.");
- }
- messageType = (MessageDescriptor) typeDescriptor;
-
- if (Proto.DefaultValue != "")
- {
- throw new DescriptorValidationException(this, "Messages can't have default values.");
- }
- }
- else if (fieldType == FieldType.Enum)
- {
- if (!(typeDescriptor is EnumDescriptor))
- {
- throw new DescriptorValidationException(this, "\"" + Proto.TypeName + "\" is not an enum type.");
- }
- enumType = (EnumDescriptor) typeDescriptor;
- }
- else
- {
- throw new DescriptorValidationException(this, "Field with primitive type has type_name.");
- }
- }
- else
- {
- if (fieldType == FieldType.Message || fieldType == FieldType.Enum)
- {
- throw new DescriptorValidationException(this, "Field with message or enum type missing type_name.");
- }
- }
-
- // Note: no attempt to perform any default value parsing
-
- File.DescriptorPool.AddFieldByNumber(this);
-
- if (containingType != null && containingType.Proto.Options != null && containingType.Proto.Options.MessageSetWireFormat)
- {
- throw new DescriptorValidationException(this, "MessageSet format is not supported.");
- }
- }
- }
+#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +using System; + +namespace Google.Protobuf.Reflection +{ + /// <summary> + /// Descriptor for a field or extension within a message in a .proto file. + /// </summary> + public sealed class FieldDescriptor : DescriptorBase, IComparable<FieldDescriptor> + { + private readonly FieldDescriptorProto proto; + private EnumDescriptor enumType; + private MessageDescriptor messageType; + private readonly MessageDescriptor containingType; + private readonly OneofDescriptor containingOneof; + private FieldType fieldType; + + internal FieldDescriptor(FieldDescriptorProto proto, FileDescriptor file, + MessageDescriptor parent, int index) + : base(file, file.ComputeFullName(parent, proto.Name), index) + { + this.proto = proto; + if (proto.Type != 0) + { + fieldType = GetFieldTypeFromProtoType(proto.Type); + } + + if (FieldNumber <= 0) + { + throw new DescriptorValidationException(this, + "Field numbers must be positive integers."); + } + containingType = parent; + // OneofIndex "defaults" to -1 due to a hack in FieldDescriptor.OnConstruction. + if (proto.OneofIndex != -1) + { + if (proto.OneofIndex < 0 || proto.OneofIndex >= parent.Proto.OneofDecl.Count) + { + throw new DescriptorValidationException(this, + "FieldDescriptorProto.oneof_index is out of range for type " + parent.Name); + } + containingOneof = parent.Oneofs[proto.OneofIndex]; + } + + file.DescriptorPool.AddSymbol(this); + } + + /// <summary> + /// The brief name of the descriptor's target. + /// </summary> + public override string Name { get { return proto.Name; } } + + internal FieldDescriptorProto Proto { get { return proto; } } + + /// <summary> + /// Maps a field type as included in the .proto file to a FieldType. + /// </summary> + private static FieldType GetFieldTypeFromProtoType(FieldDescriptorProto.Types.Type type) + { + switch (type) + { + case FieldDescriptorProto.Types.Type.TYPE_DOUBLE: + return FieldType.Double; + case FieldDescriptorProto.Types.Type.TYPE_FLOAT: + return FieldType.Float; + case FieldDescriptorProto.Types.Type.TYPE_INT64: + return FieldType.Int64; + case FieldDescriptorProto.Types.Type.TYPE_UINT64: + return FieldType.UInt64; + case FieldDescriptorProto.Types.Type.TYPE_INT32: + return FieldType.Int32; + case FieldDescriptorProto.Types.Type.TYPE_FIXED64: + return FieldType.Fixed64; + case FieldDescriptorProto.Types.Type.TYPE_FIXED32: + return FieldType.Fixed32; + case FieldDescriptorProto.Types.Type.TYPE_BOOL: + return FieldType.Bool; + case FieldDescriptorProto.Types.Type.TYPE_STRING: + return FieldType.String; + case FieldDescriptorProto.Types.Type.TYPE_GROUP: + return FieldType.Group; + case FieldDescriptorProto.Types.Type.TYPE_MESSAGE: + return FieldType.Message; + case FieldDescriptorProto.Types.Type.TYPE_BYTES: + return FieldType.Bytes; + case FieldDescriptorProto.Types.Type.TYPE_UINT32: + return FieldType.UInt32; + case FieldDescriptorProto.Types.Type.TYPE_ENUM: + return FieldType.Enum; + case FieldDescriptorProto.Types.Type.TYPE_SFIXED32: + return FieldType.SFixed32; + case FieldDescriptorProto.Types.Type.TYPE_SFIXED64: + return FieldType.SFixed64; + case FieldDescriptorProto.Types.Type.TYPE_SINT32: + return FieldType.SInt32; + case FieldDescriptorProto.Types.Type.TYPE_SINT64: + return FieldType.SInt64; + default: + throw new ArgumentException("Invalid type specified"); + } + } + + public bool IsRepeated + { + get { return Proto.Label == FieldDescriptorProto.Types.Label.LABEL_REPEATED; } + } + + public bool IsMap + { + get { return fieldType == FieldType.Message && messageType.Proto.Options != null && messageType.Proto.Options.MapEntry; } + } + + public bool IsPacked + { + get { return Proto.Options != null && Proto.Options.Packed; } + } + + /// <summary> + /// Get the field's containing type. For extensions, this is the type being + /// extended, not the location where the extension was defined. See + /// <see cref="ExtensionScope" />. + /// </summary> + public MessageDescriptor ContainingType + { + get { return containingType; } + } + + public OneofDescriptor ContainingOneof + { + get { return containingOneof; } + } + + public FieldType FieldType + { + get { return fieldType; } + } + + public int FieldNumber + { + get { return Proto.Number; } + } + + /// <summary> + /// Compares this descriptor with another one, ordering in "canonical" order + /// which simply means ascending order by field number. <paramref name="other"/> + /// must be a field of the same type, i.e. the <see cref="ContainingType"/> of + /// both fields must be the same. + /// </summary> + public int CompareTo(FieldDescriptor other) + { + if (other.containingType != containingType) + { + throw new ArgumentException("FieldDescriptors can only be compared to other FieldDescriptors " + + "for fields of the same message type."); + } + return FieldNumber - other.FieldNumber; + } + + /// <summary> + /// For enum fields, returns the field's type. + /// </summary> + public EnumDescriptor EnumType + { + get + { + if (fieldType != FieldType.Enum) + { + throw new InvalidOperationException("EnumType is only valid for enum fields."); + } + return enumType; + } + } + + /// <summary> + /// For embedded message and group fields, returns the field's type. + /// </summary> + public MessageDescriptor MessageType + { + get + { + if (fieldType != FieldType.Message) + { + throw new InvalidOperationException("MessageType is only valid for enum fields."); + } + return messageType; + } + } + + /// <summary> + /// Look up and cross-link all field types etc. + /// </summary> + internal void CrossLink() + { + if (Proto.TypeName != "") + { + IDescriptor typeDescriptor = + File.DescriptorPool.LookupSymbol(Proto.TypeName, this); + + if (Proto.Type != 0) + { + // Choose field type based on symbol. + if (typeDescriptor is MessageDescriptor) + { + fieldType = FieldType.Message; + } + else if (typeDescriptor is EnumDescriptor) + { + fieldType = FieldType.Enum; + } + else + { + throw new DescriptorValidationException(this, "\"" + Proto.TypeName + "\" is not a type."); + } + } + + if (fieldType == FieldType.Message) + { + if (!(typeDescriptor is MessageDescriptor)) + { + throw new DescriptorValidationException(this, + "\"" + Proto.TypeName + "\" is not a message type."); + } + messageType = (MessageDescriptor) typeDescriptor; + + if (Proto.DefaultValue != "") + { + throw new DescriptorValidationException(this, "Messages can't have default values."); + } + } + else if (fieldType == FieldType.Enum) + { + if (!(typeDescriptor is EnumDescriptor)) + { + throw new DescriptorValidationException(this, "\"" + Proto.TypeName + "\" is not an enum type."); + } + enumType = (EnumDescriptor) typeDescriptor; + } + else + { + throw new DescriptorValidationException(this, "Field with primitive type has type_name."); + } + } + else + { + if (fieldType == FieldType.Message || fieldType == FieldType.Enum) + { + throw new DescriptorValidationException(this, "Field with message or enum type missing type_name."); + } + } + + // Note: no attempt to perform any default value parsing + + File.DescriptorPool.AddFieldByNumber(this); + + if (containingType != null && containingType.Proto.Options != null && containingType.Proto.Options.MessageSetWireFormat) + { + throw new DescriptorValidationException(this, "MessageSet format is not supported."); + } + } + } }
\ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/Descriptors/FieldType.cs b/csharp/src/ProtocolBuffers/Reflection/FieldType.cs index 69851464..41fa702d 100644 --- a/csharp/src/ProtocolBuffers/Descriptors/FieldType.cs +++ b/csharp/src/ProtocolBuffers/Reflection/FieldType.cs @@ -1,60 +1,60 @@ -#region Copyright notice and license
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc. All rights reserved.
-// https://developers.google.com/protocol-buffers/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#endregion
-
-namespace Google.Protobuf.Descriptors
-{
- /// <summary>
- /// Enumeration of all the possible field types. The odd formatting is to make it very clear
- /// which attribute applies to which value, while maintaining a compact format.
- /// </summary>
- public enum FieldType
- {
- Double,
- Float,
- Int64,
- UInt64,
- Int32,
- Fixed64,
- Fixed32,
- Bool,
- String,
- Group,
- Message,
- Bytes,
- UInt32,
- SFixed32,
- SFixed64,
- SInt32,
- SInt64,
- Enum
- }
+#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +namespace Google.Protobuf.Reflection +{ + /// <summary> + /// Enumeration of all the possible field types. The odd formatting is to make it very clear + /// which attribute applies to which value, while maintaining a compact format. + /// </summary> + public enum FieldType + { + Double, + Float, + Int64, + UInt64, + Int32, + Fixed64, + Fixed32, + Bool, + String, + Group, + Message, + Bytes, + UInt32, + SFixed32, + SFixed64, + SInt32, + SInt64, + Enum + } }
\ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/Descriptors/FileDescriptor.cs b/csharp/src/ProtocolBuffers/Reflection/FileDescriptor.cs index 9d0bdfd3..db393480 100644 --- a/csharp/src/ProtocolBuffers/Descriptors/FileDescriptor.cs +++ b/csharp/src/ProtocolBuffers/Reflection/FileDescriptor.cs @@ -1,354 +1,352 @@ -#region Copyright notice and license
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc. All rights reserved.
-// https://developers.google.com/protocol-buffers/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#endregion
-
-using System;
-using System.Collections.Generic;
-using System.Collections.ObjectModel;
-using Google.Protobuf.DescriptorProtos;
-using FileOptions = Google.Protobuf.DescriptorProtos.FileOptions;
-
-namespace Google.Protobuf.Descriptors
-{
- /// <summary>
- /// Describes a .proto file, including everything defined within.
- /// IDescriptor is implemented such that the File property returns this descriptor,
- /// and the FullName is the same as the Name.
- /// </summary>
- public sealed class FileDescriptor : IDescriptor
- {
- private readonly FileDescriptorProto proto;
- private readonly IList<MessageDescriptor> messageTypes;
- private readonly IList<EnumDescriptor> enumTypes;
- private readonly IList<ServiceDescriptor> services;
- private readonly IList<FileDescriptor> dependencies;
- private readonly IList<FileDescriptor> publicDependencies;
- private readonly DescriptorPool pool;
-
- public enum ProtoSyntax
- {
- Proto2,
- Proto3
- }
-
- public ProtoSyntax Syntax
- {
- get { return proto.Syntax == "proto3" ? ProtoSyntax.Proto3 : ProtoSyntax.Proto2; }
- }
-
- private FileDescriptor(FileDescriptorProto proto, FileDescriptor[] dependencies, DescriptorPool pool, bool allowUnknownDependencies)
- {
- this.pool = pool;
- this.proto = proto;
- this.dependencies = new ReadOnlyCollection<FileDescriptor>((FileDescriptor[]) dependencies.Clone());
-
- publicDependencies = DeterminePublicDependencies(this, proto, dependencies, allowUnknownDependencies);
-
- pool.AddPackage(Package, this);
-
- messageTypes = DescriptorUtil.ConvertAndMakeReadOnly(proto.MessageType,
- (message, index) =>
- new MessageDescriptor(message, this, null, index));
-
- enumTypes = DescriptorUtil.ConvertAndMakeReadOnly(proto.EnumType,
- (enumType, index) =>
- new EnumDescriptor(enumType, this, null, index));
-
- services = DescriptorUtil.ConvertAndMakeReadOnly(proto.Service,
- (service, index) =>
- new ServiceDescriptor(service, this, index));
- }
-
- /// <summary>
- /// Computes the full name of a descriptor within this file, with an optional parent message.
- /// </summary>
- internal string ComputeFullName(MessageDescriptor parent, string name)
- {
- if (parent != null)
- {
- return parent.FullName + "." + name;
- }
- if (Package.Length > 0)
- {
- return Package + "." + name;
- }
- return name;
- }
-
- /// <summary>
- /// Extracts public dependencies from direct dependencies. This is a static method despite its
- /// first parameter, as the value we're in the middle of constructing is only used for exceptions.
- /// </summary>
- private static IList<FileDescriptor> DeterminePublicDependencies(FileDescriptor @this, FileDescriptorProto proto, FileDescriptor[] dependencies, bool allowUnknownDependencies)
- {
- var nameToFileMap = new Dictionary<string, FileDescriptor>();
- foreach (var file in dependencies)
- {
- nameToFileMap[file.Name] = file;
- }
- var publicDependencies = new List<FileDescriptor>();
- for (int i = 0; i < proto.PublicDependency.Count; i++)
- {
- int index = proto.PublicDependency[i];
- if (index < 0 || index >= proto.Dependency.Count)
- {
- throw new DescriptorValidationException(@this, "Invalid public dependency index.");
- }
- string name = proto.Dependency[index];
- FileDescriptor file = nameToFileMap[name];
- if (file == null)
- {
- if (!allowUnknownDependencies)
- {
- throw new DescriptorValidationException(@this, "Invalid public dependency: " + name);
- }
- // Ignore unknown dependencies.
- }
- else
- {
- publicDependencies.Add(file);
- }
- }
- return new ReadOnlyCollection<FileDescriptor>(publicDependencies);
- }
-
- /// <value>
- /// The descriptor in its protocol message representation.
- /// </value>
- internal FileDescriptorProto Proto
- {
- get { return proto; }
- }
-
- /// <value>
- /// The file name.
- /// </value>
- public string Name
- {
- get { return proto.Name; }
- }
-
- /// <summary>
- /// The package as declared in the .proto file. This may or may not
- /// be equivalent to the .NET namespace of the generated classes.
- /// </summary>
- public string Package
- {
- get { return proto.Package; }
- }
-
- /// <value>
- /// Unmodifiable list of top-level message types declared in this file.
- /// </value>
- public IList<MessageDescriptor> MessageTypes
- {
- get { return messageTypes; }
- }
-
- /// <value>
- /// Unmodifiable list of top-level enum types declared in this file.
- /// </value>
- public IList<EnumDescriptor> EnumTypes
- {
- get { return enumTypes; }
- }
-
- /// <value>
- /// Unmodifiable list of top-level services declared in this file.
- /// </value>
- public IList<ServiceDescriptor> Services
- {
- get { return services; }
- }
-
- /// <value>
- /// Unmodifiable list of this file's dependencies (imports).
- /// </value>
- public IList<FileDescriptor> Dependencies
- {
- get { return dependencies; }
- }
-
- /// <value>
- /// Unmodifiable list of this file's public dependencies (public imports).
- /// </value>
- public IList<FileDescriptor> PublicDependencies
- {
- get { return publicDependencies; }
- }
-
- /// <value>
- /// Implementation of IDescriptor.FullName - just returns the same as Name.
- /// </value>
- string IDescriptor.FullName
- {
- get { return Name; }
- }
-
- /// <value>
- /// Implementation of IDescriptor.File - just returns this descriptor.
- /// </value>
- FileDescriptor IDescriptor.File
- {
- get { return this; }
- }
-
- /// <value>
- /// Pool containing symbol descriptors.
- /// </value>
- internal DescriptorPool DescriptorPool
- {
- get { return pool; }
- }
-
- /// <summary>
- /// Finds a type (message, enum, service or extension) in the file by name. Does not find nested types.
- /// </summary>
- /// <param name="name">The unqualified type name to look for.</param>
- /// <typeparam name="T">The type of descriptor to look for (or ITypeDescriptor for any)</typeparam>
- /// <returns>The type's descriptor, or null if not found.</returns>
- public T FindTypeByName<T>(String name)
- where T : class, IDescriptor
- {
- // Don't allow looking up nested types. This will make optimization
- // easier later.
- if (name.IndexOf('.') != -1)
- {
- return null;
- }
- if (Package.Length > 0)
- {
- name = Package + "." + name;
- }
- T result = pool.FindSymbol<T>(name);
- if (result != null && result.File == this)
- {
- return result;
- }
- return null;
- }
-
- /// <summary>
- /// Builds a FileDescriptor from its protocol buffer representation.
- /// </summary>
- /// <param name="proto">The protocol message form of the FileDescriptor.</param>
- /// <param name="dependencies">FileDescriptors corresponding to all of the
- /// file's dependencies, in the exact order listed in the .proto file. May be null,
- /// in which case it is treated as an empty array.</param>
- /// <param name="allowUnknownDependencies">Whether unknown dependencies are ignored (true) or cause an exception to be thrown (false).</param>
- /// <exception cref="DescriptorValidationException">If <paramref name="proto"/> is not
- /// a valid descriptor. This can occur for a number of reasons, such as a field
- /// having an undefined type or because two messages were defined with the same name.</exception>
- private static FileDescriptor BuildFrom(FileDescriptorProto proto, FileDescriptor[] dependencies, bool allowUnknownDependencies)
- {
- // Building descriptors involves two steps: translating and linking.
- // In the translation step (implemented by FileDescriptor's
- // constructor), we build an object tree mirroring the
- // FileDescriptorProto's tree and put all of the descriptors into the
- // DescriptorPool's lookup tables. In the linking step, we look up all
- // type references in the DescriptorPool, so that, for example, a
- // FieldDescriptor for an embedded message contains a pointer directly
- // to the Descriptor for that message's type. We also detect undefined
- // types in the linking step.
- if (dependencies == null)
- {
- dependencies = new FileDescriptor[0];
- }
-
- DescriptorPool pool = new DescriptorPool(dependencies);
- FileDescriptor result = new FileDescriptor(proto, dependencies, pool, allowUnknownDependencies);
-
- // TODO(jonskeet): Reinstate these checks, or get rid of them entirely. They aren't in the Java code,
- // and fail for the CustomOptions test right now. (We get "descriptor.proto" vs "google/protobuf/descriptor.proto".)
- //if (dependencies.Length != proto.DependencyCount)
- //{
- // throw new DescriptorValidationException(result,
- // "Dependencies passed to FileDescriptor.BuildFrom() don't match " +
- // "those listed in the FileDescriptorProto.");
- //}
- //for (int i = 0; i < proto.DependencyCount; i++)
- //{
- // if (dependencies[i].Name != proto.DependencyList[i])
- // {
- // throw new DescriptorValidationException(result,
- // "Dependencies passed to FileDescriptor.BuildFrom() don't match " +
- // "those listed in the FileDescriptorProto.");
- // }
- //}
-
- result.CrossLink();
- return result;
- }
-
- private void CrossLink()
- {
- foreach (MessageDescriptor message in messageTypes)
- {
- message.CrossLink();
- }
-
- foreach (ServiceDescriptor service in services)
- {
- service.CrossLink();
- }
- }
-
- public static FileDescriptor InternalBuildGeneratedFileFrom(byte[] descriptorData,
- FileDescriptor[] dependencies)
- {
- FileDescriptorProto proto;
- try
- {
- proto = FileDescriptorProto.Parser.ParseFrom(descriptorData);
- }
- catch (InvalidProtocolBufferException e)
- {
- throw new ArgumentException("Failed to parse protocol buffer descriptor for generated code.", e);
- }
-
- try
- {
- // When building descriptors for generated code, we allow unknown
- // dependencies by default.
- return BuildFrom(proto, dependencies, true);
- }
- catch (DescriptorValidationException e)
- {
- throw new ArgumentException("Invalid embedded descriptor for \"" + proto.Name + "\".", e);
- }
- }
-
- public override string ToString()
- {
- return "FileDescriptor for " + proto.Name;
- }
- }
+#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; + +namespace Google.Protobuf.Reflection +{ + /// <summary> + /// Describes a .proto file, including everything defined within. + /// IDescriptor is implemented such that the File property returns this descriptor, + /// and the FullName is the same as the Name. + /// </summary> + public sealed class FileDescriptor : IDescriptor + { + private readonly FileDescriptorProto proto; + private readonly IList<MessageDescriptor> messageTypes; + private readonly IList<EnumDescriptor> enumTypes; + private readonly IList<ServiceDescriptor> services; + private readonly IList<FileDescriptor> dependencies; + private readonly IList<FileDescriptor> publicDependencies; + private readonly DescriptorPool pool; + + public enum ProtoSyntax + { + Proto2, + Proto3 + } + + public ProtoSyntax Syntax + { + get { return proto.Syntax == "proto3" ? ProtoSyntax.Proto3 : ProtoSyntax.Proto2; } + } + + private FileDescriptor(FileDescriptorProto proto, FileDescriptor[] dependencies, DescriptorPool pool, bool allowUnknownDependencies) + { + this.pool = pool; + this.proto = proto; + this.dependencies = new ReadOnlyCollection<FileDescriptor>((FileDescriptor[]) dependencies.Clone()); + + publicDependencies = DeterminePublicDependencies(this, proto, dependencies, allowUnknownDependencies); + + pool.AddPackage(Package, this); + + messageTypes = DescriptorUtil.ConvertAndMakeReadOnly(proto.MessageType, + (message, index) => + new MessageDescriptor(message, this, null, index)); + + enumTypes = DescriptorUtil.ConvertAndMakeReadOnly(proto.EnumType, + (enumType, index) => + new EnumDescriptor(enumType, this, null, index)); + + services = DescriptorUtil.ConvertAndMakeReadOnly(proto.Service, + (service, index) => + new ServiceDescriptor(service, this, index)); + } + + /// <summary> + /// Computes the full name of a descriptor within this file, with an optional parent message. + /// </summary> + internal string ComputeFullName(MessageDescriptor parent, string name) + { + if (parent != null) + { + return parent.FullName + "." + name; + } + if (Package.Length > 0) + { + return Package + "." + name; + } + return name; + } + + /// <summary> + /// Extracts public dependencies from direct dependencies. This is a static method despite its + /// first parameter, as the value we're in the middle of constructing is only used for exceptions. + /// </summary> + private static IList<FileDescriptor> DeterminePublicDependencies(FileDescriptor @this, FileDescriptorProto proto, FileDescriptor[] dependencies, bool allowUnknownDependencies) + { + var nameToFileMap = new Dictionary<string, FileDescriptor>(); + foreach (var file in dependencies) + { + nameToFileMap[file.Name] = file; + } + var publicDependencies = new List<FileDescriptor>(); + for (int i = 0; i < proto.PublicDependency.Count; i++) + { + int index = proto.PublicDependency[i]; + if (index < 0 || index >= proto.Dependency.Count) + { + throw new DescriptorValidationException(@this, "Invalid public dependency index."); + } + string name = proto.Dependency[index]; + FileDescriptor file = nameToFileMap[name]; + if (file == null) + { + if (!allowUnknownDependencies) + { + throw new DescriptorValidationException(@this, "Invalid public dependency: " + name); + } + // Ignore unknown dependencies. + } + else + { + publicDependencies.Add(file); + } + } + return new ReadOnlyCollection<FileDescriptor>(publicDependencies); + } + + /// <value> + /// The descriptor in its protocol message representation. + /// </value> + internal FileDescriptorProto Proto + { + get { return proto; } + } + + /// <value> + /// The file name. + /// </value> + public string Name + { + get { return proto.Name; } + } + + /// <summary> + /// The package as declared in the .proto file. This may or may not + /// be equivalent to the .NET namespace of the generated classes. + /// </summary> + public string Package + { + get { return proto.Package; } + } + + /// <value> + /// Unmodifiable list of top-level message types declared in this file. + /// </value> + public IList<MessageDescriptor> MessageTypes + { + get { return messageTypes; } + } + + /// <value> + /// Unmodifiable list of top-level enum types declared in this file. + /// </value> + public IList<EnumDescriptor> EnumTypes + { + get { return enumTypes; } + } + + /// <value> + /// Unmodifiable list of top-level services declared in this file. + /// </value> + public IList<ServiceDescriptor> Services + { + get { return services; } + } + + /// <value> + /// Unmodifiable list of this file's dependencies (imports). + /// </value> + public IList<FileDescriptor> Dependencies + { + get { return dependencies; } + } + + /// <value> + /// Unmodifiable list of this file's public dependencies (public imports). + /// </value> + public IList<FileDescriptor> PublicDependencies + { + get { return publicDependencies; } + } + + /// <value> + /// Implementation of IDescriptor.FullName - just returns the same as Name. + /// </value> + string IDescriptor.FullName + { + get { return Name; } + } + + /// <value> + /// Implementation of IDescriptor.File - just returns this descriptor. + /// </value> + FileDescriptor IDescriptor.File + { + get { return this; } + } + + /// <value> + /// Pool containing symbol descriptors. + /// </value> + internal DescriptorPool DescriptorPool + { + get { return pool; } + } + + /// <summary> + /// Finds a type (message, enum, service or extension) in the file by name. Does not find nested types. + /// </summary> + /// <param name="name">The unqualified type name to look for.</param> + /// <typeparam name="T">The type of descriptor to look for (or ITypeDescriptor for any)</typeparam> + /// <returns>The type's descriptor, or null if not found.</returns> + public T FindTypeByName<T>(String name) + where T : class, IDescriptor + { + // Don't allow looking up nested types. This will make optimization + // easier later. + if (name.IndexOf('.') != -1) + { + return null; + } + if (Package.Length > 0) + { + name = Package + "." + name; + } + T result = pool.FindSymbol<T>(name); + if (result != null && result.File == this) + { + return result; + } + return null; + } + + /// <summary> + /// Builds a FileDescriptor from its protocol buffer representation. + /// </summary> + /// <param name="proto">The protocol message form of the FileDescriptor.</param> + /// <param name="dependencies">FileDescriptors corresponding to all of the + /// file's dependencies, in the exact order listed in the .proto file. May be null, + /// in which case it is treated as an empty array.</param> + /// <param name="allowUnknownDependencies">Whether unknown dependencies are ignored (true) or cause an exception to be thrown (false).</param> + /// <exception cref="DescriptorValidationException">If <paramref name="proto"/> is not + /// a valid descriptor. This can occur for a number of reasons, such as a field + /// having an undefined type or because two messages were defined with the same name.</exception> + private static FileDescriptor BuildFrom(FileDescriptorProto proto, FileDescriptor[] dependencies, bool allowUnknownDependencies) + { + // Building descriptors involves two steps: translating and linking. + // In the translation step (implemented by FileDescriptor's + // constructor), we build an object tree mirroring the + // FileDescriptorProto's tree and put all of the descriptors into the + // DescriptorPool's lookup tables. In the linking step, we look up all + // type references in the DescriptorPool, so that, for example, a + // FieldDescriptor for an embedded message contains a pointer directly + // to the Descriptor for that message's type. We also detect undefined + // types in the linking step. + if (dependencies == null) + { + dependencies = new FileDescriptor[0]; + } + + DescriptorPool pool = new DescriptorPool(dependencies); + FileDescriptor result = new FileDescriptor(proto, dependencies, pool, allowUnknownDependencies); + + // TODO(jonskeet): Reinstate these checks, or get rid of them entirely. They aren't in the Java code, + // and fail for the CustomOptions test right now. (We get "descriptor.proto" vs "google/protobuf/descriptor.proto".) + //if (dependencies.Length != proto.DependencyCount) + //{ + // throw new DescriptorValidationException(result, + // "Dependencies passed to FileDescriptor.BuildFrom() don't match " + + // "those listed in the FileDescriptorProto."); + //} + //for (int i = 0; i < proto.DependencyCount; i++) + //{ + // if (dependencies[i].Name != proto.DependencyList[i]) + // { + // throw new DescriptorValidationException(result, + // "Dependencies passed to FileDescriptor.BuildFrom() don't match " + + // "those listed in the FileDescriptorProto."); + // } + //} + + result.CrossLink(); + return result; + } + + private void CrossLink() + { + foreach (MessageDescriptor message in messageTypes) + { + message.CrossLink(); + } + + foreach (ServiceDescriptor service in services) + { + service.CrossLink(); + } + } + + public static FileDescriptor InternalBuildGeneratedFileFrom(byte[] descriptorData, + FileDescriptor[] dependencies) + { + FileDescriptorProto proto; + try + { + proto = FileDescriptorProto.Parser.ParseFrom(descriptorData); + } + catch (InvalidProtocolBufferException e) + { + throw new ArgumentException("Failed to parse protocol buffer descriptor for generated code.", e); + } + + try + { + // When building descriptors for generated code, we allow unknown + // dependencies by default. + return BuildFrom(proto, dependencies, true); + } + catch (DescriptorValidationException e) + { + throw new ArgumentException("Invalid embedded descriptor for \"" + proto.Name + "\".", e); + } + } + + public override string ToString() + { + return "FileDescriptor for " + proto.Name; + } + } }
\ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/Descriptors/IDescriptor.cs b/csharp/src/ProtocolBuffers/Reflection/IDescriptor.cs index 92c6d463..6506db1b 100644 --- a/csharp/src/ProtocolBuffers/Descriptors/IDescriptor.cs +++ b/csharp/src/ProtocolBuffers/Reflection/IDescriptor.cs @@ -1,44 +1,44 @@ -#region Copyright notice and license
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc. All rights reserved.
-// https://developers.google.com/protocol-buffers/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#endregion
-
-namespace Google.Protobuf.Descriptors
-{
- /// <summary>
- /// Interface implemented by all descriptor types.
- /// </summary>
- public interface IDescriptor
- {
- string Name { get; }
- string FullName { get; }
- FileDescriptor File { get; }
- }
+#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +namespace Google.Protobuf.Reflection +{ + /// <summary> + /// Interface implemented by all descriptor types. + /// </summary> + public interface IDescriptor + { + string Name { get; } + string FullName { get; } + FileDescriptor File { get; } + } }
\ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/FieldAccess/IFieldAccessor.cs b/csharp/src/ProtocolBuffers/Reflection/IFieldAccessor.cs index 77e7146d..3f4f05f4 100644 --- a/csharp/src/ProtocolBuffers/FieldAccess/IFieldAccessor.cs +++ b/csharp/src/ProtocolBuffers/Reflection/IFieldAccessor.cs @@ -1,70 +1,70 @@ -#region Copyright notice and license
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc. All rights reserved.
-// https://developers.google.com/protocol-buffers/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#endregion
-
-using Google.Protobuf.Descriptors;
-
-namespace Google.Protobuf.FieldAccess
-{
- /// <summary>
- /// Allows fields to be reflectively accessed.
- /// </summary>
- public interface IFieldAccessor
- {
- /// <summary>
- /// Returns the descriptor associated with this field.
- /// </summary>
- FieldDescriptor Descriptor { get; }
-
- /// <summary>
- /// Clears the field in the specified message. (For repeated fields,
- /// this clears the list.)
- /// </summary>
- void Clear(object message);
-
- /// <summary>
- /// Fetches the field value. For repeated values, this will be an
- /// <see cref="IList"/> implementation. For map values, this will be an
- /// <see cref="IDictionary"/> implementation.
- /// </summary>
- object GetValue(object message);
-
- /// <summary>
- /// Mutator for single "simple" fields only.
- /// </summary>
- /// <remarks>
- /// Repeated fields are mutated by fetching the value and manipulating it as a list.
- /// Map fields are mutated by fetching the value and manipulating it as a dictionary.
- /// </remarks>
- /// <exception cref="InvalidOperationException">The field is not a "simple" field, or the message is frozen.</exception>
- void SetValue(object message, object value);
- }
+#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +namespace Google.Protobuf.Reflection +{ + /// <summary> + /// Allows fields to be reflectively accessed. + /// </summary> + public interface IFieldAccessor + { + /// <summary> + /// Returns the descriptor associated with this field. + /// </summary> + FieldDescriptor Descriptor { get; } + + // TODO: Should the argument type for these messages be IReflectedMessage? + + /// <summary> + /// Clears the field in the specified message. (For repeated fields, + /// this clears the list.) + /// </summary> + void Clear(object message); + + /// <summary> + /// Fetches the field value. For repeated values, this will be an + /// <see cref="IList"/> implementation. For map values, this will be an + /// <see cref="IDictionary"/> implementation. + /// </summary> + object GetValue(object message); + + /// <summary> + /// Mutator for single "simple" fields only. + /// </summary> + /// <remarks> + /// Repeated fields are mutated by fetching the value and manipulating it as a list. + /// Map fields are mutated by fetching the value and manipulating it as a dictionary. + /// </remarks> + /// <exception cref="InvalidOperationException">The field is not a "simple" field, or the message is frozen.</exception> + void SetValue(object message, object value); + } }
\ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/FieldAccess/MapFieldAccessor.cs b/csharp/src/ProtocolBuffers/Reflection/MapFieldAccessor.cs index 100dbb37..317fbd8d 100644 --- a/csharp/src/ProtocolBuffers/FieldAccess/MapFieldAccessor.cs +++ b/csharp/src/ProtocolBuffers/Reflection/MapFieldAccessor.cs @@ -32,9 +32,8 @@ using System; using System.Collections; -using Google.Protobuf.Descriptors; -namespace Google.Protobuf.FieldAccess +namespace Google.Protobuf.Reflection { /// <summary> /// Accessor for map fields. diff --git a/csharp/src/ProtocolBuffers/Descriptors/MessageDescriptor.cs b/csharp/src/ProtocolBuffers/Reflection/MessageDescriptor.cs index e65e8bb0..b6351d36 100644 --- a/csharp/src/ProtocolBuffers/Descriptors/MessageDescriptor.cs +++ b/csharp/src/ProtocolBuffers/Reflection/MessageDescriptor.cs @@ -1,173 +1,172 @@ -#region Copyright notice and license
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc. All rights reserved.
-// https://developers.google.com/protocol-buffers/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#endregion
-
-using System;
-using System.Collections.Generic;
-using Google.Protobuf.DescriptorProtos;
-
-namespace Google.Protobuf.Descriptors
-{
- /// <summary>
- /// Describes a message type.
- /// </summary>
- public sealed class MessageDescriptor : DescriptorBase
- {
- private readonly DescriptorProto proto;
- private readonly MessageDescriptor containingType;
- private readonly IList<MessageDescriptor> nestedTypes;
- private readonly IList<EnumDescriptor> enumTypes;
- private readonly IList<FieldDescriptor> fields;
- private readonly IList<OneofDescriptor> oneofs;
-
- internal MessageDescriptor(DescriptorProto proto, FileDescriptor file, MessageDescriptor parent, int typeIndex)
- : base(file, file.ComputeFullName(parent, proto.Name), typeIndex)
- {
- this.proto = proto;
- containingType = parent;
-
- oneofs = DescriptorUtil.ConvertAndMakeReadOnly(proto.OneofDecl,
- (oneof, index) =>
- new OneofDescriptor(oneof, file, this, index));
-
- nestedTypes = DescriptorUtil.ConvertAndMakeReadOnly(proto.NestedType,
- (type, index) =>
- new MessageDescriptor(type, file, this, index));
-
- enumTypes = DescriptorUtil.ConvertAndMakeReadOnly(proto.EnumType,
- (type, index) =>
- new EnumDescriptor(type, file, this, index));
-
- // TODO(jonskeet): Sort fields first?
- fields = DescriptorUtil.ConvertAndMakeReadOnly(proto.Field,
- (field, index) =>
- new FieldDescriptor(field, file, this, index));
- file.DescriptorPool.AddSymbol(this);
- }
-
- /// <summary>
- /// The brief name of the descriptor's target.
- /// </summary>
- public override string Name { get { return proto.Name; } }
-
- internal DescriptorProto Proto { get { return proto; } }
-
- /// <value>
- /// If this is a nested type, get the outer descriptor, otherwise null.
- /// </value>
- public MessageDescriptor ContainingType
- {
- get { return containingType; }
- }
-
- /// <value>
- /// An unmodifiable list of this message type's fields.
- /// </value>
- public IList<FieldDescriptor> Fields
- {
- get { return fields; }
- }
-
- /// <value>
- /// An unmodifiable list of this message type's nested types.
- /// </value>
- public IList<MessageDescriptor> NestedTypes
- {
- get { return nestedTypes; }
- }
-
- /// <value>
- /// An unmodifiable list of this message type's enum types.
- /// </value>
- public IList<EnumDescriptor> EnumTypes
- {
- get { return enumTypes; }
- }
-
- public IList<OneofDescriptor> Oneofs
- {
- get { return oneofs; }
- }
-
- /// <summary>
- /// Finds a field by field name.
- /// </summary>
- /// <param name="name">The unqualified name of the field (e.g. "foo").</param>
- /// <returns>The field's descriptor, or null if not found.</returns>
- public FieldDescriptor FindFieldByName(String name)
- {
- return File.DescriptorPool.FindSymbol<FieldDescriptor>(FullName + "." + name);
- }
-
- /// <summary>
- /// Finds a field by field number.
- /// </summary>
- /// <param name="number">The field number within this message type.</param>
- /// <returns>The field's descriptor, or null if not found.</returns>
- public FieldDescriptor FindFieldByNumber(int number)
- {
- return File.DescriptorPool.FindFieldByNumber(this, number);
- }
-
- /// <summary>
- /// Finds a nested descriptor by name. The is valid for fields, nested
- /// message types, oneofs and enums.
- /// </summary>
- /// <param name="name">The unqualified name of the descriptor, e.g. "Foo"</param>
- /// <returns>The descriptor, or null if not found.</returns>
- public T FindDescriptor<T>(string name)
- where T : class, IDescriptor
- {
- return File.DescriptorPool.FindSymbol<T>(FullName + "." + name);
- }
-
- /// <summary>
- /// Looks up and cross-links all fields and nested types.
- /// </summary>
- internal void CrossLink()
- {
- foreach (MessageDescriptor message in nestedTypes)
- {
- message.CrossLink();
- }
-
- foreach (FieldDescriptor field in fields)
- {
- field.CrossLink();
- }
-
- foreach (OneofDescriptor oneof in oneofs)
- {
- oneof.CrossLink();
- }
- }
- }
+#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +using System; +using System.Collections.Generic; + +namespace Google.Protobuf.Reflection +{ + /// <summary> + /// Describes a message type. + /// </summary> + public sealed class MessageDescriptor : DescriptorBase + { + private readonly DescriptorProto proto; + private readonly MessageDescriptor containingType; + private readonly IList<MessageDescriptor> nestedTypes; + private readonly IList<EnumDescriptor> enumTypes; + private readonly IList<FieldDescriptor> fields; + private readonly IList<OneofDescriptor> oneofs; + + internal MessageDescriptor(DescriptorProto proto, FileDescriptor file, MessageDescriptor parent, int typeIndex) + : base(file, file.ComputeFullName(parent, proto.Name), typeIndex) + { + this.proto = proto; + containingType = parent; + + oneofs = DescriptorUtil.ConvertAndMakeReadOnly(proto.OneofDecl, + (oneof, index) => + new OneofDescriptor(oneof, file, this, index)); + + nestedTypes = DescriptorUtil.ConvertAndMakeReadOnly(proto.NestedType, + (type, index) => + new MessageDescriptor(type, file, this, index)); + + enumTypes = DescriptorUtil.ConvertAndMakeReadOnly(proto.EnumType, + (type, index) => + new EnumDescriptor(type, file, this, index)); + + // TODO(jonskeet): Sort fields first? + fields = DescriptorUtil.ConvertAndMakeReadOnly(proto.Field, + (field, index) => + new FieldDescriptor(field, file, this, index)); + file.DescriptorPool.AddSymbol(this); + } + + /// <summary> + /// The brief name of the descriptor's target. + /// </summary> + public override string Name { get { return proto.Name; } } + + internal DescriptorProto Proto { get { return proto; } } + + /// <value> + /// If this is a nested type, get the outer descriptor, otherwise null. + /// </value> + public MessageDescriptor ContainingType + { + get { return containingType; } + } + + /// <value> + /// An unmodifiable list of this message type's fields. + /// </value> + public IList<FieldDescriptor> Fields + { + get { return fields; } + } + + /// <value> + /// An unmodifiable list of this message type's nested types. + /// </value> + public IList<MessageDescriptor> NestedTypes + { + get { return nestedTypes; } + } + + /// <value> + /// An unmodifiable list of this message type's enum types. + /// </value> + public IList<EnumDescriptor> EnumTypes + { + get { return enumTypes; } + } + + public IList<OneofDescriptor> Oneofs + { + get { return oneofs; } + } + + /// <summary> + /// Finds a field by field name. + /// </summary> + /// <param name="name">The unqualified name of the field (e.g. "foo").</param> + /// <returns>The field's descriptor, or null if not found.</returns> + public FieldDescriptor FindFieldByName(String name) + { + return File.DescriptorPool.FindSymbol<FieldDescriptor>(FullName + "." + name); + } + + /// <summary> + /// Finds a field by field number. + /// </summary> + /// <param name="number">The field number within this message type.</param> + /// <returns>The field's descriptor, or null if not found.</returns> + public FieldDescriptor FindFieldByNumber(int number) + { + return File.DescriptorPool.FindFieldByNumber(this, number); + } + + /// <summary> + /// Finds a nested descriptor by name. The is valid for fields, nested + /// message types, oneofs and enums. + /// </summary> + /// <param name="name">The unqualified name of the descriptor, e.g. "Foo"</param> + /// <returns>The descriptor, or null if not found.</returns> + public T FindDescriptor<T>(string name) + where T : class, IDescriptor + { + return File.DescriptorPool.FindSymbol<T>(FullName + "." + name); + } + + /// <summary> + /// Looks up and cross-links all fields and nested types. + /// </summary> + internal void CrossLink() + { + foreach (MessageDescriptor message in nestedTypes) + { + message.CrossLink(); + } + + foreach (FieldDescriptor field in fields) + { + field.CrossLink(); + } + + foreach (OneofDescriptor oneof in oneofs) + { + oneof.CrossLink(); + } + } + } }
\ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/Descriptors/MethodDescriptor.cs b/csharp/src/ProtocolBuffers/Reflection/MethodDescriptor.cs index 7d4a6f4f..0c9c6949 100644 --- a/csharp/src/ProtocolBuffers/Descriptors/MethodDescriptor.cs +++ b/csharp/src/ProtocolBuffers/Reflection/MethodDescriptor.cs @@ -1,95 +1,93 @@ -#region Copyright notice and license
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc. All rights reserved.
-// https://developers.google.com/protocol-buffers/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#endregion
-
-using Google.Protobuf.DescriptorProtos;
-
-namespace Google.Protobuf.Descriptors
-{
- /// <summary>
- /// Describes a single method in a service.
- /// </summary>
- public sealed class MethodDescriptor : DescriptorBase
- {
- private readonly MethodDescriptorProto proto;
- private readonly ServiceDescriptor service;
- private MessageDescriptor inputType;
- private MessageDescriptor outputType;
-
- /// <value>
- /// The service this method belongs to.
- /// </value>
- public ServiceDescriptor Service { get { return service; } }
-
- /// <value>
- /// The method's input type.
- /// </value>
- public MessageDescriptor InputType { get { return inputType; } }
-
- /// <value>
- /// The method's input type.
- /// </value>
- public MessageDescriptor OutputType { get { return outputType; } }
-
- internal MethodDescriptor(MethodDescriptorProto proto, FileDescriptor file,
- ServiceDescriptor parent, int index)
- : base(file, parent.FullName + "." + proto.Name, index)
- {
- this.proto = proto;
- service = parent;
- file.DescriptorPool.AddSymbol(this);
- }
-
- internal MethodDescriptorProto Proto { get { return proto; } }
-
- /// <summary>
- /// The brief name of the descriptor's target.
- /// </summary>
- public override string Name { get { return proto.Name; } }
-
- internal void CrossLink()
- {
- IDescriptor lookup = File.DescriptorPool.LookupSymbol(Proto.InputType, this);
- if (!(lookup is MessageDescriptor))
- {
- throw new DescriptorValidationException(this, "\"" + Proto.InputType + "\" is not a message type.");
- }
- inputType = (MessageDescriptor) lookup;
-
- lookup = File.DescriptorPool.LookupSymbol(Proto.OutputType, this);
- if (!(lookup is MessageDescriptor))
- {
- throw new DescriptorValidationException(this, "\"" + Proto.OutputType + "\" is not a message type.");
- }
- outputType = (MessageDescriptor) lookup;
- }
- }
+#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +namespace Google.Protobuf.Reflection +{ + /// <summary> + /// Describes a single method in a service. + /// </summary> + public sealed class MethodDescriptor : DescriptorBase + { + private readonly MethodDescriptorProto proto; + private readonly ServiceDescriptor service; + private MessageDescriptor inputType; + private MessageDescriptor outputType; + + /// <value> + /// The service this method belongs to. + /// </value> + public ServiceDescriptor Service { get { return service; } } + + /// <value> + /// The method's input type. + /// </value> + public MessageDescriptor InputType { get { return inputType; } } + + /// <value> + /// The method's input type. + /// </value> + public MessageDescriptor OutputType { get { return outputType; } } + + internal MethodDescriptor(MethodDescriptorProto proto, FileDescriptor file, + ServiceDescriptor parent, int index) + : base(file, parent.FullName + "." + proto.Name, index) + { + this.proto = proto; + service = parent; + file.DescriptorPool.AddSymbol(this); + } + + internal MethodDescriptorProto Proto { get { return proto; } } + + /// <summary> + /// The brief name of the descriptor's target. + /// </summary> + public override string Name { get { return proto.Name; } } + + internal void CrossLink() + { + IDescriptor lookup = File.DescriptorPool.LookupSymbol(Proto.InputType, this); + if (!(lookup is MessageDescriptor)) + { + throw new DescriptorValidationException(this, "\"" + Proto.InputType + "\" is not a message type."); + } + inputType = (MessageDescriptor) lookup; + + lookup = File.DescriptorPool.LookupSymbol(Proto.OutputType, this); + if (!(lookup is MessageDescriptor)) + { + throw new DescriptorValidationException(this, "\"" + Proto.OutputType + "\" is not a message type."); + } + outputType = (MessageDescriptor) lookup; + } + } }
\ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/FieldAccess/OneofAccessor.cs b/csharp/src/ProtocolBuffers/Reflection/OneofAccessor.cs index feaa6232..7a11d36b 100644 --- a/csharp/src/ProtocolBuffers/FieldAccess/OneofAccessor.cs +++ b/csharp/src/ProtocolBuffers/Reflection/OneofAccessor.cs @@ -1,91 +1,85 @@ -#region Copyright notice and license
-// Protocol Buffers - Google's data interchange format
-// Copyright 2015 Google Inc. All rights reserved.
-// https://developers.google.com/protocol-buffers/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#endregion
-
-namespace Google.Protobuf.FieldAccess
-{
- // TODO(jonskeet): Add "new" oneof API support
-
- /// <summary>
- /// Access for an oneof
- /// </summary>
- internal class OneofAccessor<TMessage> where TMessage : IMessage<TMessage>
- {
- /*
- private readonly Func<TMessage, object> caseDelegate;
- private readonly Func<TBuilder, IBuilder> clearDelegate;
- private MessageDescriptor descriptor;
-
- internal OneofAccessor(MessageDescriptor descriptor, string name)
- {
- this.descriptor = descriptor;
- MethodInfo clearMethod = typeof(TBuilder).GetMethod("Clear" + name);
- PropertyInfo caseProperty = typeof(TMessage).GetProperty(name + "Case");
- if (clearMethod == null || caseProperty == null)
- {
- throw new ArgumentException("Not all required properties/methods available for oneof");
- }
-
-
- clearDelegate = ReflectionUtil.CreateDelegateFunc<TBuilder, IBuilder>(clearMethod);
- caseDelegate = ReflectionUtil.CreateUpcastDelegate<TMessage>(caseProperty.GetGetMethod());
- }
-
- /// <summary>
- /// Indicates whether the specified message has set any field in the oneof.
- /// </summary>
- public bool Has(TMessage message)
- {
- return ((int) caseDelegate(message) != 0);
- }
-
- /// <summary>
- /// Clears the oneof in the specified builder.
- /// </summary>
- public void Clear(TBuilder builder)
- {
- clearDelegate(builder);
- }
-
- /// <summary>
- /// Indicates which field in the oneof is set for specified message
- /// </summary>
- public virtual FieldDescriptor GetOneofFieldDescriptor(TMessage message)
- {
- int fieldNumber = (int) caseDelegate(message);
- if (fieldNumber > 0)
- {
- return descriptor.FindFieldByNumber(fieldNumber);
- }
- return null;
- }*/
- }
-}
+#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2015 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +using System; +using System.Reflection; + +namespace Google.Protobuf.Reflection +{ + /// <summary> + /// Reflection access for a oneof, allowing clear and "get case" actions. + /// </summary> + public sealed class OneofAccessor + { + private readonly Func<object, int> caseDelegate; + private readonly Action<object> clearDelegate; + private OneofDescriptor descriptor; + + internal OneofAccessor(Type type, string propertyName, OneofDescriptor descriptor) + { + PropertyInfo property = type.GetProperty(propertyName + "Case"); + if (property == null || !property.CanRead) + { + throw new ArgumentException("Not all required properties/methods available"); + } + this.descriptor = descriptor; + caseDelegate = ReflectionUtil.CreateFuncObjectT<int>(property.GetGetMethod()); + + this.descriptor = descriptor; + MethodInfo clearMethod = type.GetMethod("Clear" + propertyName); + clearDelegate = ReflectionUtil.CreateActionObject(clearMethod); + } + + public OneofDescriptor Descriptor { get { return descriptor; } } + + /// <summary> + /// Clears the oneof in the specified message. + /// </summary> + public void Clear(object message) + { + clearDelegate(message); + } + + /// <summary> + /// Indicates which field in the oneof is set for specified message + /// </summary> + public FieldDescriptor GetCaseFieldDescriptor(object message) + { + int fieldNumber = caseDelegate(message); + if (fieldNumber > 0) + { + return descriptor.ContainingType.FindFieldByNumber(fieldNumber); + } + return null; + } + } +} diff --git a/csharp/src/ProtocolBuffers/Descriptors/OneofDescriptor.cs b/csharp/src/ProtocolBuffers/Reflection/OneofDescriptor.cs index 8418948f..e92dc8bb 100644 --- a/csharp/src/ProtocolBuffers/Descriptors/OneofDescriptor.cs +++ b/csharp/src/ProtocolBuffers/Reflection/OneofDescriptor.cs @@ -1,79 +1,78 @@ -#region Copyright notice and license
-// Protocol Buffers - Google's data interchange format
-// Copyright 2015 Google Inc. All rights reserved.
-// https://developers.google.com/protocol-buffers/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#endregion
-
-using System.Collections.Generic;
-using System.Collections.ObjectModel;
-using Google.Protobuf.DescriptorProtos;
-
-namespace Google.Protobuf.Descriptors
-{
- public sealed class OneofDescriptor : DescriptorBase
- {
- private readonly OneofDescriptorProto proto;
- private MessageDescriptor containingType;
- private IList<FieldDescriptor> fields;
-
- internal OneofDescriptor(OneofDescriptorProto proto, FileDescriptor file, MessageDescriptor parent, int index)
- : base(file, file.ComputeFullName(parent, proto.Name), index)
- {
- this.proto = proto;
- containingType = parent;
-
- file.DescriptorPool.AddSymbol(this);
- }
-
- /// <summary>
- /// The brief name of the descriptor's target.
- /// </summary>
- public override string Name { get { return proto.Name; } }
-
- public MessageDescriptor ContainingType
- {
- get { return containingType; }
- }
-
- public IList<FieldDescriptor> Fields { get { return fields; } }
-
- internal void CrossLink()
- {
- List<FieldDescriptor> fieldCollection = new List<FieldDescriptor>();
- foreach (var field in ContainingType.Fields)
- {
- if (field.ContainingOneof == this)
- {
- fieldCollection.Add(field);
- }
- }
- fields = new ReadOnlyCollection<FieldDescriptor>(fieldCollection);
- }
- }
-}
+#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2015 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +using System.Collections.Generic; +using System.Collections.ObjectModel; + +namespace Google.Protobuf.Reflection +{ + public sealed class OneofDescriptor : DescriptorBase + { + private readonly OneofDescriptorProto proto; + private MessageDescriptor containingType; + private IList<FieldDescriptor> fields; + + internal OneofDescriptor(OneofDescriptorProto proto, FileDescriptor file, MessageDescriptor parent, int index) + : base(file, file.ComputeFullName(parent, proto.Name), index) + { + this.proto = proto; + containingType = parent; + + file.DescriptorPool.AddSymbol(this); + } + + /// <summary> + /// The brief name of the descriptor's target. + /// </summary> + public override string Name { get { return proto.Name; } } + + public MessageDescriptor ContainingType + { + get { return containingType; } + } + + public IList<FieldDescriptor> Fields { get { return fields; } } + + internal void CrossLink() + { + List<FieldDescriptor> fieldCollection = new List<FieldDescriptor>(); + foreach (var field in ContainingType.Fields) + { + if (field.ContainingOneof == this) + { + fieldCollection.Add(field); + } + } + fields = new ReadOnlyCollection<FieldDescriptor>(fieldCollection); + } + } +} diff --git a/csharp/src/ProtocolBuffers/Descriptors/PackageDescriptor.cs b/csharp/src/ProtocolBuffers/Reflection/PackageDescriptor.cs index 18adc9e3..e547d834 100644 --- a/csharp/src/ProtocolBuffers/Descriptors/PackageDescriptor.cs +++ b/csharp/src/ProtocolBuffers/Reflection/PackageDescriptor.cs @@ -1,68 +1,68 @@ -#region Copyright notice and license
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc. All rights reserved.
-// https://developers.google.com/protocol-buffers/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#endregion
-
-namespace Google.Protobuf.Descriptors
-{
- /// <summary>
- /// Represents a package in the symbol table. We use PackageDescriptors
- /// just as placeholders so that someone cannot define, say, a message type
- /// that has the same name as an existing package.
- /// </summary>
- internal sealed class PackageDescriptor : IDescriptor
- {
- private readonly string name;
- private readonly string fullName;
- private readonly FileDescriptor file;
-
- internal PackageDescriptor(string name, string fullName, FileDescriptor file)
- {
- this.file = file;
- this.fullName = fullName;
- this.name = name;
- }
-
- public string Name
- {
- get { return name; }
- }
-
- public string FullName
- {
- get { return fullName; }
- }
-
- public FileDescriptor File
- {
- get { return file; }
- }
- }
+#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +namespace Google.Protobuf.Reflection +{ + /// <summary> + /// Represents a package in the symbol table. We use PackageDescriptors + /// just as placeholders so that someone cannot define, say, a message type + /// that has the same name as an existing package. + /// </summary> + internal sealed class PackageDescriptor : IDescriptor + { + private readonly string name; + private readonly string fullName; + private readonly FileDescriptor file; + + internal PackageDescriptor(string name, string fullName, FileDescriptor file) + { + this.file = file; + this.fullName = fullName; + this.name = name; + } + + public string Name + { + get { return name; } + } + + public string FullName + { + get { return fullName; } + } + + public FileDescriptor File + { + get { return file; } + } + } }
\ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/DescriptorProtos/PartialClasses.cs b/csharp/src/ProtocolBuffers/Reflection/PartialClasses.cs index dc19cdad..c7ed4342 100644 --- a/csharp/src/ProtocolBuffers/DescriptorProtos/PartialClasses.cs +++ b/csharp/src/ProtocolBuffers/Reflection/PartialClasses.cs @@ -31,7 +31,7 @@ #endregion
// This file just contains partial classes for any autogenerated classes that need additional support.
-namespace Google.Protobuf.DescriptorProtos
+namespace Google.Protobuf.Reflection
{
internal partial class FieldDescriptorProto
{
diff --git a/csharp/src/ProtocolBuffers/FieldAccess/ReflectionUtil.cs b/csharp/src/ProtocolBuffers/Reflection/ReflectionUtil.cs index d3053920..d0dc3e8b 100644 --- a/csharp/src/ProtocolBuffers/FieldAccess/ReflectionUtil.cs +++ b/csharp/src/ProtocolBuffers/Reflection/ReflectionUtil.cs @@ -1,93 +1,106 @@ -#region Copyright notice and license
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc. All rights reserved.
-// https://developers.google.com/protocol-buffers/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#endregion
-
-using System;
-using System.Linq.Expressions;
-using System.Reflection;
-
-namespace Google.Protobuf.FieldAccess
-{
- /// <summary>
- /// The methods in this class are somewhat evil, and should not be tampered with lightly.
- /// Basically they allow the creation of relatively weakly typed delegates from MethodInfos
- /// which are more strongly typed. They do this by creating an appropriate strongly typed
- /// delegate from the MethodInfo, and then calling that within an anonymous method.
- /// Mind-bending stuff (at least to your humble narrator) but the resulting delegates are
- /// very fast compared with calling Invoke later on.
- /// </summary>
- internal static class ReflectionUtil
- {
- /// <summary>
- /// Empty Type[] used when calling GetProperty to force property instead of indexer fetching.
- /// </summary>
- internal static readonly Type[] EmptyTypes = new Type[0];
-
- /// <summary>
- /// Creates a delegate which will cast the argument to the appropriate method target type,
- /// call the method on it, then convert the result to object.
- /// </summary>
- internal static Func<object, object> CreateFuncObjectObject(MethodInfo method)
- {
- ParameterExpression parameter = Expression.Parameter(typeof(object), "p");
- Expression downcast = Expression.Convert(parameter, method.DeclaringType);
- Expression call = Expression.Call(downcast, method);
- Expression upcast = Expression.Convert(call, typeof(object));
- return Expression.Lambda<Func<object, object>>(upcast, parameter).Compile();
- }
-
- /// <summary>
- /// Creates a delegate which will execute the given method after casting the first argument to
- /// the target type of the method, and the second argument to the first parameter type of the method.
- /// </summary>
- internal static Action<object, object> CreateActionObjectObject(MethodInfo method)
- {
- ParameterExpression targetParameter = Expression.Parameter(typeof(object), "target");
- ParameterExpression argParameter = Expression.Parameter(typeof(object), "arg");
- Expression castTarget = Expression.Convert(targetParameter, method.DeclaringType);
- Expression castArgument = Expression.Convert(argParameter, method.GetParameters()[0].ParameterType);
- Expression call = Expression.Call(castTarget, method, castArgument);
- return Expression.Lambda<Action<object, object>>(call, targetParameter, argParameter).Compile();
- }
-
- /// <summary>
- /// Creates a delegate which will execute the given method after casting the first argument to
- /// the target type of the method.
- /// </summary>
- internal static Action<object> CreateActionObject(MethodInfo method)
- {
- ParameterExpression targetParameter = Expression.Parameter(typeof(object), "target");
- Expression castTarget = Expression.Convert(targetParameter, method.DeclaringType);
- Expression call = Expression.Call(castTarget, method);
- return Expression.Lambda<Action<object>>(call, targetParameter).Compile();
- }
- }
+#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +using System; +using System.Linq.Expressions; +using System.Reflection; + +namespace Google.Protobuf.Reflection +{ + /// <summary> + /// The methods in this class are somewhat evil, and should not be tampered with lightly. + /// Basically they allow the creation of relatively weakly typed delegates from MethodInfos + /// which are more strongly typed. They do this by creating an appropriate strongly typed + /// delegate from the MethodInfo, and then calling that within an anonymous method. + /// Mind-bending stuff (at least to your humble narrator) but the resulting delegates are + /// very fast compared with calling Invoke later on. + /// </summary> + internal static class ReflectionUtil + { + /// <summary> + /// Empty Type[] used when calling GetProperty to force property instead of indexer fetching. + /// </summary> + internal static readonly Type[] EmptyTypes = new Type[0]; + + /// <summary> + /// Creates a delegate which will cast the argument to the appropriate method target type, + /// call the method on it, then convert the result to object. + /// </summary> + internal static Func<object, object> CreateFuncObjectObject(MethodInfo method) + { + ParameterExpression parameter = Expression.Parameter(typeof(object), "p"); + Expression downcast = Expression.Convert(parameter, method.DeclaringType); + Expression call = Expression.Call(downcast, method); + Expression upcast = Expression.Convert(call, typeof(object)); + return Expression.Lambda<Func<object, object>>(upcast, parameter).Compile(); + } + + /// <summary> + /// Creates a delegate which will cast the argument to the appropriate method target type, + /// call the method on it, then convert the result to the specified type. + /// </summary> + internal static Func<object, T> CreateFuncObjectT<T>(MethodInfo method) + { + ParameterExpression parameter = Expression.Parameter(typeof(object), "p"); + Expression downcast = Expression.Convert(parameter, method.DeclaringType); + Expression call = Expression.Call(downcast, method); + Expression upcast = Expression.Convert(call, typeof(T)); + return Expression.Lambda<Func<object, T>>(upcast, parameter).Compile(); + } + + /// <summary> + /// Creates a delegate which will execute the given method after casting the first argument to + /// the target type of the method, and the second argument to the first parameter type of the method. + /// </summary> + internal static Action<object, object> CreateActionObjectObject(MethodInfo method) + { + ParameterExpression targetParameter = Expression.Parameter(typeof(object), "target"); + ParameterExpression argParameter = Expression.Parameter(typeof(object), "arg"); + Expression castTarget = Expression.Convert(targetParameter, method.DeclaringType); + Expression castArgument = Expression.Convert(argParameter, method.GetParameters()[0].ParameterType); + Expression call = Expression.Call(castTarget, method, castArgument); + return Expression.Lambda<Action<object, object>>(call, targetParameter, argParameter).Compile(); + } + + /// <summary> + /// Creates a delegate which will execute the given method after casting the first argument to + /// the target type of the method. + /// </summary> + internal static Action<object> CreateActionObject(MethodInfo method) + { + ParameterExpression targetParameter = Expression.Parameter(typeof(object), "target"); + Expression castTarget = Expression.Convert(targetParameter, method.DeclaringType); + Expression call = Expression.Call(castTarget, method); + return Expression.Lambda<Action<object>>(call, targetParameter).Compile(); + } + } }
\ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/FieldAccess/RepeatedFieldAccessor.cs b/csharp/src/ProtocolBuffers/Reflection/RepeatedFieldAccessor.cs index 8d7ecbaf..0ada7567 100644 --- a/csharp/src/ProtocolBuffers/FieldAccess/RepeatedFieldAccessor.cs +++ b/csharp/src/ProtocolBuffers/Reflection/RepeatedFieldAccessor.cs @@ -32,9 +32,8 @@ using System; using System.Collections; -using Google.Protobuf.Descriptors; -namespace Google.Protobuf.FieldAccess +namespace Google.Protobuf.Reflection { /// <summary> /// Accessor for repeated fields. diff --git a/csharp/src/ProtocolBuffers/Descriptors/ServiceDescriptor.cs b/csharp/src/ProtocolBuffers/Reflection/ServiceDescriptor.cs index 2556e272..cc0a5010 100644 --- a/csharp/src/ProtocolBuffers/Descriptors/ServiceDescriptor.cs +++ b/csharp/src/ProtocolBuffers/Reflection/ServiceDescriptor.cs @@ -1,90 +1,89 @@ -#region Copyright notice and license
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc. All rights reserved.
-// https://developers.google.com/protocol-buffers/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#endregion
-
-using System;
-using System.Collections.Generic;
-using Google.Protobuf.DescriptorProtos;
-
-namespace Google.Protobuf.Descriptors
-{
- /// <summary>
- /// Describes a service type.
- /// </summary>
- public sealed class ServiceDescriptor : DescriptorBase
- {
- private readonly ServiceDescriptorProto proto;
- private readonly IList<MethodDescriptor> methods;
-
- internal ServiceDescriptor(ServiceDescriptorProto proto, FileDescriptor file, int index)
- : base(file, file.ComputeFullName(null, proto.Name), index)
- {
- this.proto = proto;
- methods = DescriptorUtil.ConvertAndMakeReadOnly(proto.Method,
- (method, i) => new MethodDescriptor(method, file, this, i));
-
- file.DescriptorPool.AddSymbol(this);
- }
-
- /// <summary>
- /// The brief name of the descriptor's target.
- /// </summary>
- public override string Name { get { return proto.Name; } }
-
- internal ServiceDescriptorProto Proto { get { return proto; } }
-
- /// <value>
- /// An unmodifiable list of methods in this service.
- /// </value>
- public IList<MethodDescriptor> Methods
- {
- get { return methods; }
- }
-
- /// <summary>
- /// Finds a method by name.
- /// </summary>
- /// <param name="name">The unqualified name of the method (e.g. "Foo").</param>
- /// <returns>The method's decsriptor, or null if not found.</returns>
- public MethodDescriptor FindMethodByName(String name)
- {
- return File.DescriptorPool.FindSymbol<MethodDescriptor>(FullName + "." + name);
- }
-
- internal void CrossLink()
- {
- foreach (MethodDescriptor method in methods)
- {
- method.CrossLink();
- }
- }
- }
+#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +using System; +using System.Collections.Generic; + +namespace Google.Protobuf.Reflection +{ + /// <summary> + /// Describes a service type. + /// </summary> + public sealed class ServiceDescriptor : DescriptorBase + { + private readonly ServiceDescriptorProto proto; + private readonly IList<MethodDescriptor> methods; + + internal ServiceDescriptor(ServiceDescriptorProto proto, FileDescriptor file, int index) + : base(file, file.ComputeFullName(null, proto.Name), index) + { + this.proto = proto; + methods = DescriptorUtil.ConvertAndMakeReadOnly(proto.Method, + (method, i) => new MethodDescriptor(method, file, this, i)); + + file.DescriptorPool.AddSymbol(this); + } + + /// <summary> + /// The brief name of the descriptor's target. + /// </summary> + public override string Name { get { return proto.Name; } } + + internal ServiceDescriptorProto Proto { get { return proto; } } + + /// <value> + /// An unmodifiable list of methods in this service. + /// </value> + public IList<MethodDescriptor> Methods + { + get { return methods; } + } + + /// <summary> + /// Finds a method by name. + /// </summary> + /// <param name="name">The unqualified name of the method (e.g. "Foo").</param> + /// <returns>The method's decsriptor, or null if not found.</returns> + public MethodDescriptor FindMethodByName(String name) + { + return File.DescriptorPool.FindSymbol<MethodDescriptor>(FullName + "." + name); + } + + internal void CrossLink() + { + foreach (MethodDescriptor method in methods) + { + method.CrossLink(); + } + } + } }
\ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/FieldAccess/SingleFieldAccessor.cs b/csharp/src/ProtocolBuffers/Reflection/SingleFieldAccessor.cs index cdc89e8d..8c24e46e 100644 --- a/csharp/src/ProtocolBuffers/FieldAccess/SingleFieldAccessor.cs +++ b/csharp/src/ProtocolBuffers/Reflection/SingleFieldAccessor.cs @@ -29,12 +29,11 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #endregion - + using System; using System.Reflection; -using Google.Protobuf.Descriptors; -namespace Google.Protobuf.FieldAccess +namespace Google.Protobuf.Reflection { /// <summary> /// Accessor for single fields. diff --git a/csharp/src/ProtocolBuffers/WellKnownTypes/Any.cs b/csharp/src/ProtocolBuffers/WellKnownTypes/Any.cs new file mode 100644 index 00000000..64d52ac5 --- /dev/null +++ b/csharp/src/ProtocolBuffers/WellKnownTypes/Any.cs @@ -0,0 +1,195 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/protobuf/any.proto +#pragma warning disable 1591, 0612, 3021 +#region Designer generated code + +using pb = global::Google.Protobuf; +using pbc = global::Google.Protobuf.Collections; +using pbr = global::Google.Protobuf.Reflection; +using scg = global::System.Collections.Generic; +namespace Google.Protobuf.WellKnownTypes { + + namespace Proto { + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public static partial class Any { + + #region Static variables + internal static pbr::FieldAccessorTable internal__static_google_protobuf_Any__FieldAccessorTable; + #endregion + #region Descriptor + public static pbr::FileDescriptor Descriptor { + get { return descriptor; } + } + private static pbr::FileDescriptor descriptor; + + static Any() { + byte[] descriptorData = global::System.Convert.FromBase64String( + string.Concat( + "Chlnb29nbGUvcHJvdG9idWYvYW55LnByb3RvEg9nb29nbGUucHJvdG9idWYi", + "JgoDQW55EhAKCHR5cGVfdXJsGAEgASgJEg0KBXZhbHVlGAIgASgMQksKE2Nv", + "bS5nb29nbGUucHJvdG9idWZCCEFueVByb3RvUAGgAQGiAgNHUEKqAh5Hb29n", + "bGUuUHJvdG9idWYuV2VsbEtub3duVHlwZXNiBnByb3RvMw==")); + descriptor = pbr::FileDescriptor.InternalBuildGeneratedFileFrom(descriptorData, + new pbr::FileDescriptor[] { + }); + internal__static_google_protobuf_Any__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.WellKnownTypes.Any), descriptor.MessageTypes[0], + new string[] { "TypeUrl", "Value", }, new string[] { }); + } + #endregion + + } + } + #region Messages + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class Any : pb::IMessage<Any> { + private static readonly pb::MessageParser<Any> _parser = new pb::MessageParser<Any>(() => new Any()); + public static pb::MessageParser<Any> Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "type_url", "value" }; + private static readonly uint[] _fieldTags = new uint[] { 10, 18 }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.WellKnownTypes.Proto.Any.Descriptor.MessageTypes[0]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.WellKnownTypes.Proto.Any.internal__static_google_protobuf_Any__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public Any() { + OnConstruction(); + } + + partial void OnConstruction(); + + public Any(Any other) : this() { + typeUrl_ = other.typeUrl_; + value_ = other.value_; + } + + public Any Clone() { + return new Any(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + } + + public const int TypeUrlFieldNumber = 1; + private string typeUrl_ = ""; + public string TypeUrl { + get { return typeUrl_; } + set { + pb::Freezable.CheckMutable(this); + typeUrl_ = value ?? ""; + } + } + + public const int ValueFieldNumber = 2; + private pb::ByteString value_ = pb::ByteString.Empty; + public pb::ByteString Value { + get { return value_; } + set { + pb::Freezable.CheckMutable(this); + value_ = value ?? pb::ByteString.Empty; + } + } + + public override bool Equals(object other) { + return Equals(other as Any); + } + + public bool Equals(Any other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (TypeUrl != other.TypeUrl) return false; + if (Value != other.Value) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + if (TypeUrl.Length != 0) hash ^= TypeUrl.GetHashCode(); + if (Value.Length != 0) hash ^= Value.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + if (TypeUrl.Length != 0) { + output.WriteRawTag(10); + output.WriteString(TypeUrl); + } + if (Value.Length != 0) { + output.WriteRawTag(18); + output.WriteBytes(Value); + } + } + + public int CalculateSize() { + int size = 0; + if (TypeUrl.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(TypeUrl); + } + if (Value.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeBytesSize(Value); + } + return size; + } + + public void MergeFrom(Any other) { + if (other == null) { + return; + } + if (other.TypeUrl.Length != 0) { + TypeUrl = other.TypeUrl; + } + if (other.Value.Length != 0) { + Value = other.Value; + } + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + case 10: { + TypeUrl = input.ReadString(); + break; + } + case 18: { + Value = input.ReadBytes(); + break; + } + } + } + } + + } + + #endregion + +} + +#endregion Designer generated code diff --git a/csharp/src/ProtocolBuffers/WellKnownTypes/Api.cs b/csharp/src/ProtocolBuffers/WellKnownTypes/Api.cs new file mode 100644 index 00000000..1e2506a4 --- /dev/null +++ b/csharp/src/ProtocolBuffers/WellKnownTypes/Api.cs @@ -0,0 +1,528 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/protobuf/api.proto +#pragma warning disable 1591, 0612, 3021 +#region Designer generated code + +using pb = global::Google.Protobuf; +using pbc = global::Google.Protobuf.Collections; +using pbr = global::Google.Protobuf.Reflection; +using scg = global::System.Collections.Generic; +namespace Google.Protobuf.WellKnownTypes { + + namespace Proto { + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public static partial class Api { + + #region Static variables + internal static pbr::FieldAccessorTable internal__static_google_protobuf_Api__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_google_protobuf_Method__FieldAccessorTable; + #endregion + #region Descriptor + public static pbr::FileDescriptor Descriptor { + get { return descriptor; } + } + private static pbr::FileDescriptor descriptor; + + static Api() { + byte[] descriptorData = global::System.Convert.FromBase64String( + string.Concat( + "Chlnb29nbGUvcHJvdG9idWYvYXBpLnByb3RvEg9nb29nbGUucHJvdG9idWYa", + "JGdvb2dsZS9wcm90b2J1Zi9zb3VyY2VfY29udGV4dC5wcm90bxoaZ29vZ2xl", + "L3Byb3RvYnVmL3R5cGUucHJvdG8isAEKA0FwaRIMCgRuYW1lGAEgASgJEigK", + "B21ldGhvZHMYAiADKAsyFy5nb29nbGUucHJvdG9idWYuTWV0aG9kEigKB29w", + "dGlvbnMYAyADKAsyFy5nb29nbGUucHJvdG9idWYuT3B0aW9uEg8KB3ZlcnNp", + "b24YBCABKAkSNgoOc291cmNlX2NvbnRleHQYBSABKAsyHi5nb29nbGUucHJv", + "dG9idWYuU291cmNlQ29udGV4dCKsAQoGTWV0aG9kEgwKBG5hbWUYASABKAkS", + "GAoQcmVxdWVzdF90eXBlX3VybBgCIAEoCRIZChFyZXF1ZXN0X3N0cmVhbWlu", + "ZxgDIAEoCBIZChFyZXNwb25zZV90eXBlX3VybBgEIAEoCRIaChJyZXNwb25z", + "ZV9zdHJlYW1pbmcYBSABKAgSKAoHb3B0aW9ucxgGIAMoCzIXLmdvb2dsZS5w", + "cm90b2J1Zi5PcHRpb25CSAoTY29tLmdvb2dsZS5wcm90b2J1ZkIIQXBpUHJv", + "dG9QAaICA0dQQqoCHkdvb2dsZS5Qcm90b2J1Zi5XZWxsS25vd25UeXBlc2IG", + "cHJvdG8z")); + descriptor = pbr::FileDescriptor.InternalBuildGeneratedFileFrom(descriptorData, + new pbr::FileDescriptor[] { + global::Google.Protobuf.WellKnownTypes.Proto.SourceContext.Descriptor, + global::Google.Protobuf.WellKnownTypes.Proto.Type.Descriptor, + }); + internal__static_google_protobuf_Api__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.WellKnownTypes.Api), descriptor.MessageTypes[0], + new string[] { "Name", "Methods", "Options", "Version", "SourceContext", }, new string[] { }); + internal__static_google_protobuf_Method__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.WellKnownTypes.Method), descriptor.MessageTypes[1], + new string[] { "Name", "RequestTypeUrl", "RequestStreaming", "ResponseTypeUrl", "ResponseStreaming", "Options", }, new string[] { }); + } + #endregion + + } + } + #region Messages + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class Api : pb::IMessage<Api> { + private static readonly pb::MessageParser<Api> _parser = new pb::MessageParser<Api>(() => new Api()); + public static pb::MessageParser<Api> Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "methods", "name", "options", "source_context", "version" }; + private static readonly uint[] _fieldTags = new uint[] { 18, 10, 26, 42, 34 }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.WellKnownTypes.Proto.Api.Descriptor.MessageTypes[0]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.WellKnownTypes.Proto.Api.internal__static_google_protobuf_Api__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public Api() { + OnConstruction(); + } + + partial void OnConstruction(); + + public Api(Api other) : this() { + name_ = other.name_; + methods_ = other.methods_.Clone(); + options_ = other.options_.Clone(); + version_ = other.version_; + SourceContext = other.sourceContext_ != null ? other.SourceContext.Clone() : null; + } + + public Api Clone() { + return new Api(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + methods_.Freeze(); + options_.Freeze(); + if (sourceContext_ != null) SourceContext.Freeze(); + } + + public const int NameFieldNumber = 1; + private string name_ = ""; + public string Name { + get { return name_; } + set { + pb::Freezable.CheckMutable(this); + name_ = value ?? ""; + } + } + + public const int MethodsFieldNumber = 2; + private static readonly pb::FieldCodec<global::Google.Protobuf.WellKnownTypes.Method> _repeated_methods_codec + = pb::FieldCodec.ForMessage(18, global::Google.Protobuf.WellKnownTypes.Method.Parser); + private readonly pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Method> methods_ = new pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Method>(); + public pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Method> Methods { + get { return methods_; } + } + + public const int OptionsFieldNumber = 3; + private static readonly pb::FieldCodec<global::Google.Protobuf.WellKnownTypes.Option> _repeated_options_codec + = pb::FieldCodec.ForMessage(26, global::Google.Protobuf.WellKnownTypes.Option.Parser); + private readonly pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Option> options_ = new pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Option>(); + public pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Option> Options { + get { return options_; } + } + + public const int VersionFieldNumber = 4; + private string version_ = ""; + public string Version { + get { return version_; } + set { + pb::Freezable.CheckMutable(this); + version_ = value ?? ""; + } + } + + public const int SourceContextFieldNumber = 5; + private global::Google.Protobuf.WellKnownTypes.SourceContext sourceContext_; + public global::Google.Protobuf.WellKnownTypes.SourceContext SourceContext { + get { return sourceContext_; } + set { + pb::Freezable.CheckMutable(this); + sourceContext_ = value; + } + } + + public override bool Equals(object other) { + return Equals(other as Api); + } + + public bool Equals(Api other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Name != other.Name) return false; + if(!methods_.Equals(other.methods_)) return false; + if(!options_.Equals(other.options_)) return false; + if (Version != other.Version) return false; + if (!object.Equals(SourceContext, other.SourceContext)) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + if (Name.Length != 0) hash ^= Name.GetHashCode(); + hash ^= methods_.GetHashCode(); + hash ^= options_.GetHashCode(); + if (Version.Length != 0) hash ^= Version.GetHashCode(); + if (sourceContext_ != null) hash ^= SourceContext.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + if (Name.Length != 0) { + output.WriteRawTag(10); + output.WriteString(Name); + } + methods_.WriteTo(output, _repeated_methods_codec); + options_.WriteTo(output, _repeated_options_codec); + if (Version.Length != 0) { + output.WriteRawTag(34); + output.WriteString(Version); + } + if (sourceContext_ != null) { + output.WriteRawTag(42); + output.WriteMessage(SourceContext); + } + } + + public int CalculateSize() { + int size = 0; + if (Name.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Name); + } + size += methods_.CalculateSize(_repeated_methods_codec); + size += options_.CalculateSize(_repeated_options_codec); + if (Version.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Version); + } + if (sourceContext_ != null) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(SourceContext); + } + return size; + } + + public void MergeFrom(Api other) { + if (other == null) { + return; + } + if (other.Name.Length != 0) { + Name = other.Name; + } + methods_.Add(other.methods_); + options_.Add(other.options_); + if (other.Version.Length != 0) { + Version = other.Version; + } + if (other.sourceContext_ != null) { + if (sourceContext_ == null) { + sourceContext_ = new global::Google.Protobuf.WellKnownTypes.SourceContext(); + } + SourceContext.MergeFrom(other.SourceContext); + } + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + case 10: { + Name = input.ReadString(); + break; + } + case 18: { + methods_.AddEntriesFrom(input, _repeated_methods_codec); + break; + } + case 26: { + options_.AddEntriesFrom(input, _repeated_options_codec); + break; + } + case 34: { + Version = input.ReadString(); + break; + } + case 42: { + if (sourceContext_ == null) { + sourceContext_ = new global::Google.Protobuf.WellKnownTypes.SourceContext(); + } + input.ReadMessage(sourceContext_); + break; + } + } + } + } + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class Method : pb::IMessage<Method> { + private static readonly pb::MessageParser<Method> _parser = new pb::MessageParser<Method>(() => new Method()); + public static pb::MessageParser<Method> Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "name", "options", "request_streaming", "request_type_url", "response_streaming", "response_type_url" }; + private static readonly uint[] _fieldTags = new uint[] { 10, 50, 24, 18, 40, 34 }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.WellKnownTypes.Proto.Api.Descriptor.MessageTypes[1]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.WellKnownTypes.Proto.Api.internal__static_google_protobuf_Method__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public Method() { + OnConstruction(); + } + + partial void OnConstruction(); + + public Method(Method other) : this() { + name_ = other.name_; + requestTypeUrl_ = other.requestTypeUrl_; + requestStreaming_ = other.requestStreaming_; + responseTypeUrl_ = other.responseTypeUrl_; + responseStreaming_ = other.responseStreaming_; + options_ = other.options_.Clone(); + } + + public Method Clone() { + return new Method(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + options_.Freeze(); + } + + public const int NameFieldNumber = 1; + private string name_ = ""; + public string Name { + get { return name_; } + set { + pb::Freezable.CheckMutable(this); + name_ = value ?? ""; + } + } + + public const int RequestTypeUrlFieldNumber = 2; + private string requestTypeUrl_ = ""; + public string RequestTypeUrl { + get { return requestTypeUrl_; } + set { + pb::Freezable.CheckMutable(this); + requestTypeUrl_ = value ?? ""; + } + } + + public const int RequestStreamingFieldNumber = 3; + private bool requestStreaming_; + public bool RequestStreaming { + get { return requestStreaming_; } + set { + pb::Freezable.CheckMutable(this); + requestStreaming_ = value; + } + } + + public const int ResponseTypeUrlFieldNumber = 4; + private string responseTypeUrl_ = ""; + public string ResponseTypeUrl { + get { return responseTypeUrl_; } + set { + pb::Freezable.CheckMutable(this); + responseTypeUrl_ = value ?? ""; + } + } + + public const int ResponseStreamingFieldNumber = 5; + private bool responseStreaming_; + public bool ResponseStreaming { + get { return responseStreaming_; } + set { + pb::Freezable.CheckMutable(this); + responseStreaming_ = value; + } + } + + public const int OptionsFieldNumber = 6; + private static readonly pb::FieldCodec<global::Google.Protobuf.WellKnownTypes.Option> _repeated_options_codec + = pb::FieldCodec.ForMessage(50, global::Google.Protobuf.WellKnownTypes.Option.Parser); + private readonly pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Option> options_ = new pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Option>(); + public pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Option> Options { + get { return options_; } + } + + public override bool Equals(object other) { + return Equals(other as Method); + } + + public bool Equals(Method other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Name != other.Name) return false; + if (RequestTypeUrl != other.RequestTypeUrl) return false; + if (RequestStreaming != other.RequestStreaming) return false; + if (ResponseTypeUrl != other.ResponseTypeUrl) return false; + if (ResponseStreaming != other.ResponseStreaming) return false; + if(!options_.Equals(other.options_)) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + if (Name.Length != 0) hash ^= Name.GetHashCode(); + if (RequestTypeUrl.Length != 0) hash ^= RequestTypeUrl.GetHashCode(); + if (RequestStreaming != false) hash ^= RequestStreaming.GetHashCode(); + if (ResponseTypeUrl.Length != 0) hash ^= ResponseTypeUrl.GetHashCode(); + if (ResponseStreaming != false) hash ^= ResponseStreaming.GetHashCode(); + hash ^= options_.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + if (Name.Length != 0) { + output.WriteRawTag(10); + output.WriteString(Name); + } + if (RequestTypeUrl.Length != 0) { + output.WriteRawTag(18); + output.WriteString(RequestTypeUrl); + } + if (RequestStreaming != false) { + output.WriteRawTag(24); + output.WriteBool(RequestStreaming); + } + if (ResponseTypeUrl.Length != 0) { + output.WriteRawTag(34); + output.WriteString(ResponseTypeUrl); + } + if (ResponseStreaming != false) { + output.WriteRawTag(40); + output.WriteBool(ResponseStreaming); + } + options_.WriteTo(output, _repeated_options_codec); + } + + public int CalculateSize() { + int size = 0; + if (Name.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Name); + } + if (RequestTypeUrl.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(RequestTypeUrl); + } + if (RequestStreaming != false) { + size += 1 + 1; + } + if (ResponseTypeUrl.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(ResponseTypeUrl); + } + if (ResponseStreaming != false) { + size += 1 + 1; + } + size += options_.CalculateSize(_repeated_options_codec); + return size; + } + + public void MergeFrom(Method other) { + if (other == null) { + return; + } + if (other.Name.Length != 0) { + Name = other.Name; + } + if (other.RequestTypeUrl.Length != 0) { + RequestTypeUrl = other.RequestTypeUrl; + } + if (other.RequestStreaming != false) { + RequestStreaming = other.RequestStreaming; + } + if (other.ResponseTypeUrl.Length != 0) { + ResponseTypeUrl = other.ResponseTypeUrl; + } + if (other.ResponseStreaming != false) { + ResponseStreaming = other.ResponseStreaming; + } + options_.Add(other.options_); + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + case 10: { + Name = input.ReadString(); + break; + } + case 18: { + RequestTypeUrl = input.ReadString(); + break; + } + case 24: { + RequestStreaming = input.ReadBool(); + break; + } + case 34: { + ResponseTypeUrl = input.ReadString(); + break; + } + case 40: { + ResponseStreaming = input.ReadBool(); + break; + } + case 50: { + options_.AddEntriesFrom(input, _repeated_options_codec); + break; + } + } + } + } + + } + + #endregion + +} + +#endregion Designer generated code diff --git a/csharp/src/ProtocolBuffers/WellKnownTypes/Duration.cs b/csharp/src/ProtocolBuffers/WellKnownTypes/Duration.cs new file mode 100644 index 00000000..fbc9c007 --- /dev/null +++ b/csharp/src/ProtocolBuffers/WellKnownTypes/Duration.cs @@ -0,0 +1,196 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/protobuf/duration.proto +#pragma warning disable 1591, 0612, 3021 +#region Designer generated code + +using pb = global::Google.Protobuf; +using pbc = global::Google.Protobuf.Collections; +using pbr = global::Google.Protobuf.Reflection; +using scg = global::System.Collections.Generic; +namespace Google.Protobuf.WellKnownTypes { + + namespace Proto { + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public static partial class Duration { + + #region Static variables + internal static pbr::FieldAccessorTable internal__static_google_protobuf_Duration__FieldAccessorTable; + #endregion + #region Descriptor + public static pbr::FileDescriptor Descriptor { + get { return descriptor; } + } + private static pbr::FileDescriptor descriptor; + + static Duration() { + byte[] descriptorData = global::System.Convert.FromBase64String( + string.Concat( + "Ch5nb29nbGUvcHJvdG9idWYvZHVyYXRpb24ucHJvdG8SD2dvb2dsZS5wcm90", + "b2J1ZiIqCghEdXJhdGlvbhIPCgdzZWNvbmRzGAEgASgDEg0KBW5hbm9zGAIg", + "ASgFQlAKE2NvbS5nb29nbGUucHJvdG9idWZCDUR1cmF0aW9uUHJvdG9QAaAB", + "AaICA0dQQqoCHkdvb2dsZS5Qcm90b2J1Zi5XZWxsS25vd25UeXBlc2IGcHJv", + "dG8z")); + descriptor = pbr::FileDescriptor.InternalBuildGeneratedFileFrom(descriptorData, + new pbr::FileDescriptor[] { + }); + internal__static_google_protobuf_Duration__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.WellKnownTypes.Duration), descriptor.MessageTypes[0], + new string[] { "Seconds", "Nanos", }, new string[] { }); + } + #endregion + + } + } + #region Messages + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class Duration : pb::IMessage<Duration> { + private static readonly pb::MessageParser<Duration> _parser = new pb::MessageParser<Duration>(() => new Duration()); + public static pb::MessageParser<Duration> Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "nanos", "seconds" }; + private static readonly uint[] _fieldTags = new uint[] { 16, 8 }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.WellKnownTypes.Proto.Duration.Descriptor.MessageTypes[0]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.WellKnownTypes.Proto.Duration.internal__static_google_protobuf_Duration__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public Duration() { + OnConstruction(); + } + + partial void OnConstruction(); + + public Duration(Duration other) : this() { + seconds_ = other.seconds_; + nanos_ = other.nanos_; + } + + public Duration Clone() { + return new Duration(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + } + + public const int SecondsFieldNumber = 1; + private long seconds_; + public long Seconds { + get { return seconds_; } + set { + pb::Freezable.CheckMutable(this); + seconds_ = value; + } + } + + public const int NanosFieldNumber = 2; + private int nanos_; + public int Nanos { + get { return nanos_; } + set { + pb::Freezable.CheckMutable(this); + nanos_ = value; + } + } + + public override bool Equals(object other) { + return Equals(other as Duration); + } + + public bool Equals(Duration other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Seconds != other.Seconds) return false; + if (Nanos != other.Nanos) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + if (Seconds != 0L) hash ^= Seconds.GetHashCode(); + if (Nanos != 0) hash ^= Nanos.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + if (Seconds != 0L) { + output.WriteRawTag(8); + output.WriteInt64(Seconds); + } + if (Nanos != 0) { + output.WriteRawTag(16); + output.WriteInt32(Nanos); + } + } + + public int CalculateSize() { + int size = 0; + if (Seconds != 0L) { + size += 1 + pb::CodedOutputStream.ComputeInt64Size(Seconds); + } + if (Nanos != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(Nanos); + } + return size; + } + + public void MergeFrom(Duration other) { + if (other == null) { + return; + } + if (other.Seconds != 0L) { + Seconds = other.Seconds; + } + if (other.Nanos != 0) { + Nanos = other.Nanos; + } + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + case 8: { + Seconds = input.ReadInt64(); + break; + } + case 16: { + Nanos = input.ReadInt32(); + break; + } + } + } + } + + } + + #endregion + +} + +#endregion Designer generated code diff --git a/csharp/src/ProtocolBuffers/WellKnownTypes/Empty.cs b/csharp/src/ProtocolBuffers/WellKnownTypes/Empty.cs new file mode 100644 index 00000000..c2681e29 --- /dev/null +++ b/csharp/src/ProtocolBuffers/WellKnownTypes/Empty.cs @@ -0,0 +1,141 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/protobuf/empty.proto +#pragma warning disable 1591, 0612, 3021 +#region Designer generated code + +using pb = global::Google.Protobuf; +using pbc = global::Google.Protobuf.Collections; +using pbr = global::Google.Protobuf.Reflection; +using scg = global::System.Collections.Generic; +namespace Google.Protobuf.WellKnownTypes { + + namespace Proto { + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public static partial class Empty { + + #region Static variables + internal static pbr::FieldAccessorTable internal__static_google_protobuf_Empty__FieldAccessorTable; + #endregion + #region Descriptor + public static pbr::FileDescriptor Descriptor { + get { return descriptor; } + } + private static pbr::FileDescriptor descriptor; + + static Empty() { + byte[] descriptorData = global::System.Convert.FromBase64String( + string.Concat( + "Chtnb29nbGUvcHJvdG9idWYvZW1wdHkucHJvdG8SD2dvb2dsZS5wcm90b2J1", + "ZiIHCgVFbXB0eUJKChNjb20uZ29vZ2xlLnByb3RvYnVmQgpFbXB0eVByb3Rv", + "UAGiAgNHUEKqAh5Hb29nbGUuUHJvdG9idWYuV2VsbEtub3duVHlwZXNiBnBy", + "b3RvMw==")); + descriptor = pbr::FileDescriptor.InternalBuildGeneratedFileFrom(descriptorData, + new pbr::FileDescriptor[] { + }); + internal__static_google_protobuf_Empty__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.WellKnownTypes.Empty), descriptor.MessageTypes[0], + new string[] { }, new string[] { }); + } + #endregion + + } + } + #region Messages + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class Empty : pb::IMessage<Empty> { + private static readonly pb::MessageParser<Empty> _parser = new pb::MessageParser<Empty>(() => new Empty()); + public static pb::MessageParser<Empty> Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { }; + private static readonly uint[] _fieldTags = new uint[] { }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.WellKnownTypes.Proto.Empty.Descriptor.MessageTypes[0]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.WellKnownTypes.Proto.Empty.internal__static_google_protobuf_Empty__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public Empty() { + OnConstruction(); + } + + partial void OnConstruction(); + + public Empty(Empty other) : this() { + } + + public Empty Clone() { + return new Empty(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + } + + public override bool Equals(object other) { + return Equals(other as Empty); + } + + public bool Equals(Empty other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + return true; + } + + public override int GetHashCode() { + int hash = 1; + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + } + + public int CalculateSize() { + int size = 0; + return size; + } + + public void MergeFrom(Empty other) { + if (other == null) { + return; + } + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + } + } + } + + } + + #endregion + +} + +#endregion Designer generated code diff --git a/csharp/src/ProtocolBuffers/WellKnownTypes/FieldMask.cs b/csharp/src/ProtocolBuffers/WellKnownTypes/FieldMask.cs new file mode 100644 index 00000000..310c0d21 --- /dev/null +++ b/csharp/src/ProtocolBuffers/WellKnownTypes/FieldMask.cs @@ -0,0 +1,160 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/protobuf/field_mask.proto +#pragma warning disable 1591, 0612, 3021 +#region Designer generated code + +using pb = global::Google.Protobuf; +using pbc = global::Google.Protobuf.Collections; +using pbr = global::Google.Protobuf.Reflection; +using scg = global::System.Collections.Generic; +namespace Google.Protobuf.WellKnownTypes { + + namespace Proto { + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public static partial class FieldMask { + + #region Static variables + internal static pbr::FieldAccessorTable internal__static_google_protobuf_FieldMask__FieldAccessorTable; + #endregion + #region Descriptor + public static pbr::FileDescriptor Descriptor { + get { return descriptor; } + } + private static pbr::FileDescriptor descriptor; + + static FieldMask() { + byte[] descriptorData = global::System.Convert.FromBase64String( + string.Concat( + "CiBnb29nbGUvcHJvdG9idWYvZmllbGRfbWFzay5wcm90bxIPZ29vZ2xlLnBy", + "b3RvYnVmIhoKCUZpZWxkTWFzaxINCgVwYXRocxgBIAMoCUJOChNjb20uZ29v", + "Z2xlLnByb3RvYnVmQg5GaWVsZE1hc2tQcm90b1ABogIDR1BCqgIeR29vZ2xl", + "LlByb3RvYnVmLldlbGxLbm93blR5cGVzYgZwcm90bzM=")); + descriptor = pbr::FileDescriptor.InternalBuildGeneratedFileFrom(descriptorData, + new pbr::FileDescriptor[] { + }); + internal__static_google_protobuf_FieldMask__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.WellKnownTypes.FieldMask), descriptor.MessageTypes[0], + new string[] { "Paths", }, new string[] { }); + } + #endregion + + } + } + #region Messages + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class FieldMask : pb::IMessage<FieldMask> { + private static readonly pb::MessageParser<FieldMask> _parser = new pb::MessageParser<FieldMask>(() => new FieldMask()); + public static pb::MessageParser<FieldMask> Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "paths" }; + private static readonly uint[] _fieldTags = new uint[] { 10 }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.WellKnownTypes.Proto.FieldMask.Descriptor.MessageTypes[0]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.WellKnownTypes.Proto.FieldMask.internal__static_google_protobuf_FieldMask__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public FieldMask() { + OnConstruction(); + } + + partial void OnConstruction(); + + public FieldMask(FieldMask other) : this() { + paths_ = other.paths_.Clone(); + } + + public FieldMask Clone() { + return new FieldMask(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + paths_.Freeze(); + } + + public const int PathsFieldNumber = 1; + private static readonly pb::FieldCodec<string> _repeated_paths_codec + = pb::FieldCodec.ForString(10); + private readonly pbc::RepeatedField<string> paths_ = new pbc::RepeatedField<string>(); + public pbc::RepeatedField<string> Paths { + get { return paths_; } + } + + public override bool Equals(object other) { + return Equals(other as FieldMask); + } + + public bool Equals(FieldMask other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if(!paths_.Equals(other.paths_)) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + hash ^= paths_.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + paths_.WriteTo(output, _repeated_paths_codec); + } + + public int CalculateSize() { + int size = 0; + size += paths_.CalculateSize(_repeated_paths_codec); + return size; + } + + public void MergeFrom(FieldMask other) { + if (other == null) { + return; + } + paths_.Add(other.paths_); + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + case 10: { + paths_.AddEntriesFrom(input, _repeated_paths_codec); + break; + } + } + } + } + + } + + #endregion + +} + +#endregion Designer generated code diff --git a/csharp/src/ProtocolBuffers/WellKnownTypes/SourceContext.cs b/csharp/src/ProtocolBuffers/WellKnownTypes/SourceContext.cs new file mode 100644 index 00000000..ee60fbe9 --- /dev/null +++ b/csharp/src/ProtocolBuffers/WellKnownTypes/SourceContext.cs @@ -0,0 +1,169 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/protobuf/source_context.proto +#pragma warning disable 1591, 0612, 3021 +#region Designer generated code + +using pb = global::Google.Protobuf; +using pbc = global::Google.Protobuf.Collections; +using pbr = global::Google.Protobuf.Reflection; +using scg = global::System.Collections.Generic; +namespace Google.Protobuf.WellKnownTypes { + + namespace Proto { + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public static partial class SourceContext { + + #region Static variables + internal static pbr::FieldAccessorTable internal__static_google_protobuf_SourceContext__FieldAccessorTable; + #endregion + #region Descriptor + public static pbr::FileDescriptor Descriptor { + get { return descriptor; } + } + private static pbr::FileDescriptor descriptor; + + static SourceContext() { + byte[] descriptorData = global::System.Convert.FromBase64String( + string.Concat( + "CiRnb29nbGUvcHJvdG9idWYvc291cmNlX2NvbnRleHQucHJvdG8SD2dvb2ds", + "ZS5wcm90b2J1ZiIiCg1Tb3VyY2VDb250ZXh0EhEKCWZpbGVfbmFtZRgBIAEo", + "CUJSChNjb20uZ29vZ2xlLnByb3RvYnVmQhJTb3VyY2VDb250ZXh0UHJvdG9Q", + "AaICA0dQQqoCHkdvb2dsZS5Qcm90b2J1Zi5XZWxsS25vd25UeXBlc2IGcHJv", + "dG8z")); + descriptor = pbr::FileDescriptor.InternalBuildGeneratedFileFrom(descriptorData, + new pbr::FileDescriptor[] { + }); + internal__static_google_protobuf_SourceContext__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.WellKnownTypes.SourceContext), descriptor.MessageTypes[0], + new string[] { "FileName", }, new string[] { }); + } + #endregion + + } + } + #region Messages + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class SourceContext : pb::IMessage<SourceContext> { + private static readonly pb::MessageParser<SourceContext> _parser = new pb::MessageParser<SourceContext>(() => new SourceContext()); + public static pb::MessageParser<SourceContext> Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "file_name" }; + private static readonly uint[] _fieldTags = new uint[] { 10 }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.WellKnownTypes.Proto.SourceContext.Descriptor.MessageTypes[0]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.WellKnownTypes.Proto.SourceContext.internal__static_google_protobuf_SourceContext__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public SourceContext() { + OnConstruction(); + } + + partial void OnConstruction(); + + public SourceContext(SourceContext other) : this() { + fileName_ = other.fileName_; + } + + public SourceContext Clone() { + return new SourceContext(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + } + + public const int FileNameFieldNumber = 1; + private string fileName_ = ""; + public string FileName { + get { return fileName_; } + set { + pb::Freezable.CheckMutable(this); + fileName_ = value ?? ""; + } + } + + public override bool Equals(object other) { + return Equals(other as SourceContext); + } + + public bool Equals(SourceContext other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (FileName != other.FileName) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + if (FileName.Length != 0) hash ^= FileName.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + if (FileName.Length != 0) { + output.WriteRawTag(10); + output.WriteString(FileName); + } + } + + public int CalculateSize() { + int size = 0; + if (FileName.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(FileName); + } + return size; + } + + public void MergeFrom(SourceContext other) { + if (other == null) { + return; + } + if (other.FileName.Length != 0) { + FileName = other.FileName; + } + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + case 10: { + FileName = input.ReadString(); + break; + } + } + } + } + + } + + #endregion + +} + +#endregion Designer generated code diff --git a/csharp/src/ProtocolBuffers/WellKnownTypes/Struct.cs b/csharp/src/ProtocolBuffers/WellKnownTypes/Struct.cs new file mode 100644 index 00000000..99f88a96 --- /dev/null +++ b/csharp/src/ProtocolBuffers/WellKnownTypes/Struct.cs @@ -0,0 +1,601 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/protobuf/struct.proto +#pragma warning disable 1591, 0612, 3021 +#region Designer generated code + +using pb = global::Google.Protobuf; +using pbc = global::Google.Protobuf.Collections; +using pbr = global::Google.Protobuf.Reflection; +using scg = global::System.Collections.Generic; +namespace Google.Protobuf.WellKnownTypes { + + namespace Proto { + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public static partial class Struct { + + #region Static variables + internal static pbr::FieldAccessorTable internal__static_google_protobuf_Struct__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_google_protobuf_Value__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_google_protobuf_ListValue__FieldAccessorTable; + #endregion + #region Descriptor + public static pbr::FileDescriptor Descriptor { + get { return descriptor; } + } + private static pbr::FileDescriptor descriptor; + + static Struct() { + byte[] descriptorData = global::System.Convert.FromBase64String( + string.Concat( + "Chxnb29nbGUvcHJvdG9idWYvc3RydWN0LnByb3RvEg9nb29nbGUucHJvdG9i", + "dWYihAEKBlN0cnVjdBIzCgZmaWVsZHMYASADKAsyIy5nb29nbGUucHJvdG9i", + "dWYuU3RydWN0LkZpZWxkc0VudHJ5GkUKC0ZpZWxkc0VudHJ5EgsKA2tleRgB", + "IAEoCRIlCgV2YWx1ZRgCIAEoCzIWLmdvb2dsZS5wcm90b2J1Zi5WYWx1ZToC", + "OAEi6gEKBVZhbHVlEjAKCm51bGxfdmFsdWUYASABKA4yGi5nb29nbGUucHJv", + "dG9idWYuTnVsbFZhbHVlSAASFgoMbnVtYmVyX3ZhbHVlGAIgASgBSAASFgoM", + "c3RyaW5nX3ZhbHVlGAMgASgJSAASFAoKYm9vbF92YWx1ZRgEIAEoCEgAEi8K", + "DHN0cnVjdF92YWx1ZRgFIAEoCzIXLmdvb2dsZS5wcm90b2J1Zi5TdHJ1Y3RI", + "ABIwCgpsaXN0X3ZhbHVlGAYgASgLMhouZ29vZ2xlLnByb3RvYnVmLkxpc3RW", + "YWx1ZUgAQgYKBGtpbmQiMwoJTGlzdFZhbHVlEiYKBnZhbHVlcxgBIAMoCzIW", + "Lmdvb2dsZS5wcm90b2J1Zi5WYWx1ZSobCglOdWxsVmFsdWUSDgoKTlVMTF9W", + "QUxVRRAAQk4KE2NvbS5nb29nbGUucHJvdG9idWZCC1N0cnVjdFByb3RvUAGg", + "AQGiAgNHUEKqAh5Hb29nbGUuUHJvdG9idWYuV2VsbEtub3duVHlwZXNiBnBy", + "b3RvMw==")); + descriptor = pbr::FileDescriptor.InternalBuildGeneratedFileFrom(descriptorData, + new pbr::FileDescriptor[] { + }); + internal__static_google_protobuf_Struct__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.WellKnownTypes.Struct), descriptor.MessageTypes[0], + new string[] { "Fields", }, new string[] { }); + internal__static_google_protobuf_Value__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.WellKnownTypes.Value), descriptor.MessageTypes[1], + new string[] { "NullValue", "NumberValue", "StringValue", "BoolValue", "StructValue", "ListValue", }, new string[] { "Kind", }); + internal__static_google_protobuf_ListValue__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.WellKnownTypes.ListValue), descriptor.MessageTypes[2], + new string[] { "Values", }, new string[] { }); + } + #endregion + + } + } + #region Enums + public enum NullValue { + NULL_VALUE = 0, + } + + #endregion + + #region Messages + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class Struct : pb::IMessage<Struct> { + private static readonly pb::MessageParser<Struct> _parser = new pb::MessageParser<Struct>(() => new Struct()); + public static pb::MessageParser<Struct> Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "fields" }; + private static readonly uint[] _fieldTags = new uint[] { 10 }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.WellKnownTypes.Proto.Struct.Descriptor.MessageTypes[0]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.WellKnownTypes.Proto.Struct.internal__static_google_protobuf_Struct__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public Struct() { + OnConstruction(); + } + + partial void OnConstruction(); + + public Struct(Struct other) : this() { + fields_ = other.fields_.Clone(); + } + + public Struct Clone() { + return new Struct(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + fields_.Freeze(); + } + + public const int FieldsFieldNumber = 1; + private static readonly pbc::MapField<string, global::Google.Protobuf.WellKnownTypes.Value>.Codec _map_fields_codec + = new pbc::MapField<string, global::Google.Protobuf.WellKnownTypes.Value>.Codec(pb::FieldCodec.ForString(10), pb::FieldCodec.ForMessage(18, global::Google.Protobuf.WellKnownTypes.Value.Parser), 10); + private readonly pbc::MapField<string, global::Google.Protobuf.WellKnownTypes.Value> fields_ = new pbc::MapField<string, global::Google.Protobuf.WellKnownTypes.Value>(); + public pbc::MapField<string, global::Google.Protobuf.WellKnownTypes.Value> Fields { + get { return fields_; } + } + + public override bool Equals(object other) { + return Equals(other as Struct); + } + + public bool Equals(Struct other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (!Fields.Equals(other.Fields)) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + hash ^= Fields.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + fields_.WriteTo(output, _map_fields_codec); + } + + public int CalculateSize() { + int size = 0; + size += fields_.CalculateSize(_map_fields_codec); + return size; + } + + public void MergeFrom(Struct other) { + if (other == null) { + return; + } + fields_.Add(other.fields_); + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + case 10: { + fields_.AddEntriesFrom(input, _map_fields_codec); + break; + } + } + } + } + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class Value : pb::IMessage<Value> { + private static readonly pb::MessageParser<Value> _parser = new pb::MessageParser<Value>(() => new Value()); + public static pb::MessageParser<Value> Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "bool_value", "list_value", "null_value", "number_value", "string_value", "struct_value" }; + private static readonly uint[] _fieldTags = new uint[] { 32, 50, 8, 17, 26, 42 }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.WellKnownTypes.Proto.Struct.Descriptor.MessageTypes[1]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.WellKnownTypes.Proto.Struct.internal__static_google_protobuf_Value__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public Value() { + OnConstruction(); + } + + partial void OnConstruction(); + + public Value(Value other) : this() { + switch (other.KindCase) { + case KindOneofCase.NullValue: + NullValue = other.NullValue; + break; + case KindOneofCase.NumberValue: + NumberValue = other.NumberValue; + break; + case KindOneofCase.StringValue: + StringValue = other.StringValue; + break; + case KindOneofCase.BoolValue: + BoolValue = other.BoolValue; + break; + case KindOneofCase.StructValue: + StructValue = other.StructValue.Clone(); + break; + case KindOneofCase.ListValue: + ListValue = other.ListValue.Clone(); + break; + } + + } + + public Value Clone() { + return new Value(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + if (kind_ is IFreezable) ((IFreezable) kind_).Freeze(); + } + + public const int NullValueFieldNumber = 1; + public global::Google.Protobuf.WellKnownTypes.NullValue NullValue { + get { return kindCase_ == KindOneofCase.NullValue ? (global::Google.Protobuf.WellKnownTypes.NullValue) kind_ : global::Google.Protobuf.WellKnownTypes.NullValue.NULL_VALUE; } + set { + pb::Freezable.CheckMutable(this); + kind_ = value; + kindCase_ = KindOneofCase.NullValue; + } + } + + public const int NumberValueFieldNumber = 2; + public double NumberValue { + get { return kindCase_ == KindOneofCase.NumberValue ? (double) kind_ : 0D; } + set { + pb::Freezable.CheckMutable(this); + kind_ = value; + kindCase_ = KindOneofCase.NumberValue; + } + } + + public const int StringValueFieldNumber = 3; + public string StringValue { + get { return kindCase_ == KindOneofCase.StringValue ? (string) kind_ : ""; } + set { + pb::Freezable.CheckMutable(this); + kind_ = value ?? ""; + kindCase_ = KindOneofCase.StringValue; + } + } + + public const int BoolValueFieldNumber = 4; + public bool BoolValue { + get { return kindCase_ == KindOneofCase.BoolValue ? (bool) kind_ : false; } + set { + pb::Freezable.CheckMutable(this); + kind_ = value; + kindCase_ = KindOneofCase.BoolValue; + } + } + + public const int StructValueFieldNumber = 5; + public global::Google.Protobuf.WellKnownTypes.Struct StructValue { + get { return kindCase_ == KindOneofCase.StructValue ? (global::Google.Protobuf.WellKnownTypes.Struct) kind_ : null; } + set { + pb::Freezable.CheckMutable(this); + kind_ = value; + kindCase_ = value == null ? KindOneofCase.None : KindOneofCase.StructValue; + } + } + + public const int ListValueFieldNumber = 6; + public global::Google.Protobuf.WellKnownTypes.ListValue ListValue { + get { return kindCase_ == KindOneofCase.ListValue ? (global::Google.Protobuf.WellKnownTypes.ListValue) kind_ : null; } + set { + pb::Freezable.CheckMutable(this); + kind_ = value; + kindCase_ = value == null ? KindOneofCase.None : KindOneofCase.ListValue; + } + } + + private object kind_; + public enum KindOneofCase { + None = 0, + NullValue = 1, + NumberValue = 2, + StringValue = 3, + BoolValue = 4, + StructValue = 5, + ListValue = 6, + } + private KindOneofCase kindCase_ = KindOneofCase.None; + public KindOneofCase KindCase { + get { return kindCase_; } + } + + public void ClearKind() { + pb::Freezable.CheckMutable(this); + kindCase_ = KindOneofCase.None; + kind_ = null; + } + + public override bool Equals(object other) { + return Equals(other as Value); + } + + public bool Equals(Value other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (NullValue != other.NullValue) return false; + if (NumberValue != other.NumberValue) return false; + if (StringValue != other.StringValue) return false; + if (BoolValue != other.BoolValue) return false; + if (!object.Equals(StructValue, other.StructValue)) return false; + if (!object.Equals(ListValue, other.ListValue)) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + if (kindCase_ == KindOneofCase.NullValue) hash ^= NullValue.GetHashCode(); + if (kindCase_ == KindOneofCase.NumberValue) hash ^= NumberValue.GetHashCode(); + if (kindCase_ == KindOneofCase.StringValue) hash ^= StringValue.GetHashCode(); + if (kindCase_ == KindOneofCase.BoolValue) hash ^= BoolValue.GetHashCode(); + if (kindCase_ == KindOneofCase.StructValue) hash ^= StructValue.GetHashCode(); + if (kindCase_ == KindOneofCase.ListValue) hash ^= ListValue.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + if (kindCase_ == KindOneofCase.NullValue) { + output.WriteRawTag(8); + output.WriteEnum((int) NullValue); + } + if (kindCase_ == KindOneofCase.NumberValue) { + output.WriteRawTag(17); + output.WriteDouble(NumberValue); + } + if (kindCase_ == KindOneofCase.StringValue) { + output.WriteRawTag(26); + output.WriteString(StringValue); + } + if (kindCase_ == KindOneofCase.BoolValue) { + output.WriteRawTag(32); + output.WriteBool(BoolValue); + } + if (kindCase_ == KindOneofCase.StructValue) { + output.WriteRawTag(42); + output.WriteMessage(StructValue); + } + if (kindCase_ == KindOneofCase.ListValue) { + output.WriteRawTag(50); + output.WriteMessage(ListValue); + } + } + + public int CalculateSize() { + int size = 0; + if (kindCase_ == KindOneofCase.NullValue) { + size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) NullValue); + } + if (kindCase_ == KindOneofCase.NumberValue) { + size += 1 + 8; + } + if (kindCase_ == KindOneofCase.StringValue) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(StringValue); + } + if (kindCase_ == KindOneofCase.BoolValue) { + size += 1 + 1; + } + if (kindCase_ == KindOneofCase.StructValue) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(StructValue); + } + if (kindCase_ == KindOneofCase.ListValue) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(ListValue); + } + return size; + } + + public void MergeFrom(Value other) { + if (other == null) { + return; + } + switch (other.KindCase) { + case KindOneofCase.NullValue: + NullValue = other.NullValue; + break; + case KindOneofCase.NumberValue: + NumberValue = other.NumberValue; + break; + case KindOneofCase.StringValue: + StringValue = other.StringValue; + break; + case KindOneofCase.BoolValue: + BoolValue = other.BoolValue; + break; + case KindOneofCase.StructValue: + StructValue = other.StructValue; + break; + case KindOneofCase.ListValue: + ListValue = other.ListValue; + break; + } + + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + case 8: { + kind_ = input.ReadEnum(); + kindCase_ = KindOneofCase.NullValue; + break; + } + case 17: { + NumberValue = input.ReadDouble(); + break; + } + case 26: { + StringValue = input.ReadString(); + break; + } + case 32: { + BoolValue = input.ReadBool(); + break; + } + case 42: { + global::Google.Protobuf.WellKnownTypes.Struct subBuilder = new global::Google.Protobuf.WellKnownTypes.Struct(); + if (kindCase_ == KindOneofCase.StructValue) { + subBuilder.MergeFrom(StructValue); + } + input.ReadMessage(subBuilder); + StructValue = subBuilder; + break; + } + case 50: { + global::Google.Protobuf.WellKnownTypes.ListValue subBuilder = new global::Google.Protobuf.WellKnownTypes.ListValue(); + if (kindCase_ == KindOneofCase.ListValue) { + subBuilder.MergeFrom(ListValue); + } + input.ReadMessage(subBuilder); + ListValue = subBuilder; + break; + } + } + } + } + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class ListValue : pb::IMessage<ListValue> { + private static readonly pb::MessageParser<ListValue> _parser = new pb::MessageParser<ListValue>(() => new ListValue()); + public static pb::MessageParser<ListValue> Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "values" }; + private static readonly uint[] _fieldTags = new uint[] { 10 }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.WellKnownTypes.Proto.Struct.Descriptor.MessageTypes[2]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.WellKnownTypes.Proto.Struct.internal__static_google_protobuf_ListValue__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public ListValue() { + OnConstruction(); + } + + partial void OnConstruction(); + + public ListValue(ListValue other) : this() { + values_ = other.values_.Clone(); + } + + public ListValue Clone() { + return new ListValue(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + values_.Freeze(); + } + + public const int ValuesFieldNumber = 1; + private static readonly pb::FieldCodec<global::Google.Protobuf.WellKnownTypes.Value> _repeated_values_codec + = pb::FieldCodec.ForMessage(10, global::Google.Protobuf.WellKnownTypes.Value.Parser); + private readonly pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Value> values_ = new pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Value>(); + public pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Value> Values { + get { return values_; } + } + + public override bool Equals(object other) { + return Equals(other as ListValue); + } + + public bool Equals(ListValue other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if(!values_.Equals(other.values_)) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + hash ^= values_.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + values_.WriteTo(output, _repeated_values_codec); + } + + public int CalculateSize() { + int size = 0; + size += values_.CalculateSize(_repeated_values_codec); + return size; + } + + public void MergeFrom(ListValue other) { + if (other == null) { + return; + } + values_.Add(other.values_); + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + case 10: { + values_.AddEntriesFrom(input, _repeated_values_codec); + break; + } + } + } + } + + } + + #endregion + +} + +#endregion Designer generated code diff --git a/csharp/src/ProtocolBuffers/WellKnownTypes/Timestamp.cs b/csharp/src/ProtocolBuffers/WellKnownTypes/Timestamp.cs new file mode 100644 index 00000000..e3bb3c37 --- /dev/null +++ b/csharp/src/ProtocolBuffers/WellKnownTypes/Timestamp.cs @@ -0,0 +1,196 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/protobuf/timestamp.proto +#pragma warning disable 1591, 0612, 3021 +#region Designer generated code + +using pb = global::Google.Protobuf; +using pbc = global::Google.Protobuf.Collections; +using pbr = global::Google.Protobuf.Reflection; +using scg = global::System.Collections.Generic; +namespace Google.Protobuf.WellKnownTypes { + + namespace Proto { + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public static partial class Timestamp { + + #region Static variables + internal static pbr::FieldAccessorTable internal__static_google_protobuf_Timestamp__FieldAccessorTable; + #endregion + #region Descriptor + public static pbr::FileDescriptor Descriptor { + get { return descriptor; } + } + private static pbr::FileDescriptor descriptor; + + static Timestamp() { + byte[] descriptorData = global::System.Convert.FromBase64String( + string.Concat( + "Ch9nb29nbGUvcHJvdG9idWYvdGltZXN0YW1wLnByb3RvEg9nb29nbGUucHJv", + "dG9idWYiKwoJVGltZXN0YW1wEg8KB3NlY29uZHMYASABKAMSDQoFbmFub3MY", + "AiABKAVCUQoTY29tLmdvb2dsZS5wcm90b2J1ZkIOVGltZXN0YW1wUHJvdG9Q", + "AaABAaICA0dQQqoCHkdvb2dsZS5Qcm90b2J1Zi5XZWxsS25vd25UeXBlc2IG", + "cHJvdG8z")); + descriptor = pbr::FileDescriptor.InternalBuildGeneratedFileFrom(descriptorData, + new pbr::FileDescriptor[] { + }); + internal__static_google_protobuf_Timestamp__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.WellKnownTypes.Timestamp), descriptor.MessageTypes[0], + new string[] { "Seconds", "Nanos", }, new string[] { }); + } + #endregion + + } + } + #region Messages + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class Timestamp : pb::IMessage<Timestamp> { + private static readonly pb::MessageParser<Timestamp> _parser = new pb::MessageParser<Timestamp>(() => new Timestamp()); + public static pb::MessageParser<Timestamp> Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "nanos", "seconds" }; + private static readonly uint[] _fieldTags = new uint[] { 16, 8 }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.WellKnownTypes.Proto.Timestamp.Descriptor.MessageTypes[0]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.WellKnownTypes.Proto.Timestamp.internal__static_google_protobuf_Timestamp__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public Timestamp() { + OnConstruction(); + } + + partial void OnConstruction(); + + public Timestamp(Timestamp other) : this() { + seconds_ = other.seconds_; + nanos_ = other.nanos_; + } + + public Timestamp Clone() { + return new Timestamp(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + } + + public const int SecondsFieldNumber = 1; + private long seconds_; + public long Seconds { + get { return seconds_; } + set { + pb::Freezable.CheckMutable(this); + seconds_ = value; + } + } + + public const int NanosFieldNumber = 2; + private int nanos_; + public int Nanos { + get { return nanos_; } + set { + pb::Freezable.CheckMutable(this); + nanos_ = value; + } + } + + public override bool Equals(object other) { + return Equals(other as Timestamp); + } + + public bool Equals(Timestamp other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Seconds != other.Seconds) return false; + if (Nanos != other.Nanos) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + if (Seconds != 0L) hash ^= Seconds.GetHashCode(); + if (Nanos != 0) hash ^= Nanos.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + if (Seconds != 0L) { + output.WriteRawTag(8); + output.WriteInt64(Seconds); + } + if (Nanos != 0) { + output.WriteRawTag(16); + output.WriteInt32(Nanos); + } + } + + public int CalculateSize() { + int size = 0; + if (Seconds != 0L) { + size += 1 + pb::CodedOutputStream.ComputeInt64Size(Seconds); + } + if (Nanos != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(Nanos); + } + return size; + } + + public void MergeFrom(Timestamp other) { + if (other == null) { + return; + } + if (other.Seconds != 0L) { + Seconds = other.Seconds; + } + if (other.Nanos != 0) { + Nanos = other.Nanos; + } + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + case 8: { + Seconds = input.ReadInt64(); + break; + } + case 16: { + Nanos = input.ReadInt32(); + break; + } + } + } + } + + } + + #endregion + +} + +#endregion Designer generated code diff --git a/csharp/src/ProtocolBuffers/WellKnownTypes/Type.cs b/csharp/src/ProtocolBuffers/WellKnownTypes/Type.cs new file mode 100644 index 00000000..dbc1ee0d --- /dev/null +++ b/csharp/src/ProtocolBuffers/WellKnownTypes/Type.cs @@ -0,0 +1,1147 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/protobuf/type.proto +#pragma warning disable 1591, 0612, 3021 +#region Designer generated code + +using pb = global::Google.Protobuf; +using pbc = global::Google.Protobuf.Collections; +using pbr = global::Google.Protobuf.Reflection; +using scg = global::System.Collections.Generic; +namespace Google.Protobuf.WellKnownTypes { + + namespace Proto { + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public static partial class Type { + + #region Static variables + internal static pbr::FieldAccessorTable internal__static_google_protobuf_Type__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_google_protobuf_Field__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_google_protobuf_Enum__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_google_protobuf_EnumValue__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_google_protobuf_Option__FieldAccessorTable; + #endregion + #region Descriptor + public static pbr::FileDescriptor Descriptor { + get { return descriptor; } + } + private static pbr::FileDescriptor descriptor; + + static Type() { + byte[] descriptorData = global::System.Convert.FromBase64String( + string.Concat( + "Chpnb29nbGUvcHJvdG9idWYvdHlwZS5wcm90bxIPZ29vZ2xlLnByb3RvYnVm", + "Ghlnb29nbGUvcHJvdG9idWYvYW55LnByb3RvGiRnb29nbGUvcHJvdG9idWYv", + "c291cmNlX2NvbnRleHQucHJvdG8irgEKBFR5cGUSDAoEbmFtZRgBIAEoCRIm", + "CgZmaWVsZHMYAiADKAsyFi5nb29nbGUucHJvdG9idWYuRmllbGQSDgoGb25l", + "b2ZzGAMgAygJEigKB29wdGlvbnMYBCADKAsyFy5nb29nbGUucHJvdG9idWYu", + "T3B0aW9uEjYKDnNvdXJjZV9jb250ZXh0GAUgASgLMh4uZ29vZ2xlLnByb3Rv", + "YnVmLlNvdXJjZUNvbnRleHQimwUKBUZpZWxkEikKBGtpbmQYASABKA4yGy5n", + "b29nbGUucHJvdG9idWYuRmllbGQuS2luZBI3CgtjYXJkaW5hbGl0eRgCIAEo", + "DjIiLmdvb2dsZS5wcm90b2J1Zi5GaWVsZC5DYXJkaW5hbGl0eRIOCgZudW1i", + "ZXIYAyABKAUSDAoEbmFtZRgEIAEoCRIQCgh0eXBlX3VybBgGIAEoCRITCgtv", + "bmVvZl9pbmRleBgHIAEoBRIOCgZwYWNrZWQYCCABKAgSKAoHb3B0aW9ucxgJ", + "IAMoCzIXLmdvb2dsZS5wcm90b2J1Zi5PcHRpb24iuAIKBEtpbmQSEAoMVFlQ", + "RV9VTktOT1dOEAASDwoLVFlQRV9ET1VCTEUQARIOCgpUWVBFX0ZMT0FUEAIS", + "DgoKVFlQRV9JTlQ2NBADEg8KC1RZUEVfVUlOVDY0EAQSDgoKVFlQRV9JTlQz", + "MhAFEhAKDFRZUEVfRklYRUQ2NBAGEhAKDFRZUEVfRklYRUQzMhAHEg0KCVRZ", + "UEVfQk9PTBAIEg8KC1RZUEVfU1RSSU5HEAkSEAoMVFlQRV9NRVNTQUdFEAsS", + "DgoKVFlQRV9CWVRFUxAMEg8KC1RZUEVfVUlOVDMyEA0SDQoJVFlQRV9FTlVN", + "EA4SEQoNVFlQRV9TRklYRUQzMhAPEhEKDVRZUEVfU0ZJWEVENjQQEBIPCgtU", + "WVBFX1NJTlQzMhAREg8KC1RZUEVfU0lOVDY0EBIidAoLQ2FyZGluYWxpdHkS", + "FwoTQ0FSRElOQUxJVFlfVU5LTk9XThAAEhgKFENBUkRJTkFMSVRZX09QVElP", + "TkFMEAESGAoUQ0FSRElOQUxJVFlfUkVRVUlSRUQQAhIYChRDQVJESU5BTElU", + "WV9SRVBFQVRFRBADIqUBCgRFbnVtEgwKBG5hbWUYASABKAkSLQoJZW51bXZh", + "bHVlGAIgAygLMhouZ29vZ2xlLnByb3RvYnVmLkVudW1WYWx1ZRIoCgdvcHRp", + "b25zGAMgAygLMhcuZ29vZ2xlLnByb3RvYnVmLk9wdGlvbhI2Cg5zb3VyY2Vf", + "Y29udGV4dBgEIAEoCzIeLmdvb2dsZS5wcm90b2J1Zi5Tb3VyY2VDb250ZXh0", + "IlMKCUVudW1WYWx1ZRIMCgRuYW1lGAEgASgJEg4KBm51bWJlchgCIAEoBRIo", + "CgdvcHRpb25zGAMgAygLMhcuZ29vZ2xlLnByb3RvYnVmLk9wdGlvbiI7CgZP", + "cHRpb24SDAoEbmFtZRgBIAEoCRIjCgV2YWx1ZRgCIAEoCzIULmdvb2dsZS5w", + "cm90b2J1Zi5BbnlCSQoTY29tLmdvb2dsZS5wcm90b2J1ZkIJVHlwZVByb3Rv", + "UAGiAgNHUEKqAh5Hb29nbGUuUHJvdG9idWYuV2VsbEtub3duVHlwZXNiBnBy", + "b3RvMw==")); + descriptor = pbr::FileDescriptor.InternalBuildGeneratedFileFrom(descriptorData, + new pbr::FileDescriptor[] { + global::Google.Protobuf.WellKnownTypes.Proto.Any.Descriptor, + global::Google.Protobuf.WellKnownTypes.Proto.SourceContext.Descriptor, + }); + internal__static_google_protobuf_Type__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.WellKnownTypes.Type), descriptor.MessageTypes[0], + new string[] { "Name", "Fields", "Oneofs", "Options", "SourceContext", }, new string[] { }); + internal__static_google_protobuf_Field__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.WellKnownTypes.Field), descriptor.MessageTypes[1], + new string[] { "Kind", "Cardinality", "Number", "Name", "TypeUrl", "OneofIndex", "Packed", "Options", }, new string[] { }); + internal__static_google_protobuf_Enum__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.WellKnownTypes.Enum), descriptor.MessageTypes[2], + new string[] { "Name", "Enumvalue", "Options", "SourceContext", }, new string[] { }); + internal__static_google_protobuf_EnumValue__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.WellKnownTypes.EnumValue), descriptor.MessageTypes[3], + new string[] { "Name", "Number", "Options", }, new string[] { }); + internal__static_google_protobuf_Option__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.WellKnownTypes.Option), descriptor.MessageTypes[4], + new string[] { "Name", "Value", }, new string[] { }); + } + #endregion + + } + } + #region Messages + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class Type : pb::IMessage<Type> { + private static readonly pb::MessageParser<Type> _parser = new pb::MessageParser<Type>(() => new Type()); + public static pb::MessageParser<Type> Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "fields", "name", "oneofs", "options", "source_context" }; + private static readonly uint[] _fieldTags = new uint[] { 18, 10, 26, 34, 42 }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.WellKnownTypes.Proto.Type.Descriptor.MessageTypes[0]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.WellKnownTypes.Proto.Type.internal__static_google_protobuf_Type__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public Type() { + OnConstruction(); + } + + partial void OnConstruction(); + + public Type(Type other) : this() { + name_ = other.name_; + fields_ = other.fields_.Clone(); + oneofs_ = other.oneofs_.Clone(); + options_ = other.options_.Clone(); + SourceContext = other.sourceContext_ != null ? other.SourceContext.Clone() : null; + } + + public Type Clone() { + return new Type(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + fields_.Freeze(); + oneofs_.Freeze(); + options_.Freeze(); + if (sourceContext_ != null) SourceContext.Freeze(); + } + + public const int NameFieldNumber = 1; + private string name_ = ""; + public string Name { + get { return name_; } + set { + pb::Freezable.CheckMutable(this); + name_ = value ?? ""; + } + } + + public const int FieldsFieldNumber = 2; + private static readonly pb::FieldCodec<global::Google.Protobuf.WellKnownTypes.Field> _repeated_fields_codec + = pb::FieldCodec.ForMessage(18, global::Google.Protobuf.WellKnownTypes.Field.Parser); + private readonly pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Field> fields_ = new pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Field>(); + public pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Field> Fields { + get { return fields_; } + } + + public const int OneofsFieldNumber = 3; + private static readonly pb::FieldCodec<string> _repeated_oneofs_codec + = pb::FieldCodec.ForString(26); + private readonly pbc::RepeatedField<string> oneofs_ = new pbc::RepeatedField<string>(); + public pbc::RepeatedField<string> Oneofs { + get { return oneofs_; } + } + + public const int OptionsFieldNumber = 4; + private static readonly pb::FieldCodec<global::Google.Protobuf.WellKnownTypes.Option> _repeated_options_codec + = pb::FieldCodec.ForMessage(34, global::Google.Protobuf.WellKnownTypes.Option.Parser); + private readonly pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Option> options_ = new pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Option>(); + public pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Option> Options { + get { return options_; } + } + + public const int SourceContextFieldNumber = 5; + private global::Google.Protobuf.WellKnownTypes.SourceContext sourceContext_; + public global::Google.Protobuf.WellKnownTypes.SourceContext SourceContext { + get { return sourceContext_; } + set { + pb::Freezable.CheckMutable(this); + sourceContext_ = value; + } + } + + public override bool Equals(object other) { + return Equals(other as Type); + } + + public bool Equals(Type other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Name != other.Name) return false; + if(!fields_.Equals(other.fields_)) return false; + if(!oneofs_.Equals(other.oneofs_)) return false; + if(!options_.Equals(other.options_)) return false; + if (!object.Equals(SourceContext, other.SourceContext)) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + if (Name.Length != 0) hash ^= Name.GetHashCode(); + hash ^= fields_.GetHashCode(); + hash ^= oneofs_.GetHashCode(); + hash ^= options_.GetHashCode(); + if (sourceContext_ != null) hash ^= SourceContext.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + if (Name.Length != 0) { + output.WriteRawTag(10); + output.WriteString(Name); + } + fields_.WriteTo(output, _repeated_fields_codec); + oneofs_.WriteTo(output, _repeated_oneofs_codec); + options_.WriteTo(output, _repeated_options_codec); + if (sourceContext_ != null) { + output.WriteRawTag(42); + output.WriteMessage(SourceContext); + } + } + + public int CalculateSize() { + int size = 0; + if (Name.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Name); + } + size += fields_.CalculateSize(_repeated_fields_codec); + size += oneofs_.CalculateSize(_repeated_oneofs_codec); + size += options_.CalculateSize(_repeated_options_codec); + if (sourceContext_ != null) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(SourceContext); + } + return size; + } + + public void MergeFrom(Type other) { + if (other == null) { + return; + } + if (other.Name.Length != 0) { + Name = other.Name; + } + fields_.Add(other.fields_); + oneofs_.Add(other.oneofs_); + options_.Add(other.options_); + if (other.sourceContext_ != null) { + if (sourceContext_ == null) { + sourceContext_ = new global::Google.Protobuf.WellKnownTypes.SourceContext(); + } + SourceContext.MergeFrom(other.SourceContext); + } + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + case 10: { + Name = input.ReadString(); + break; + } + case 18: { + fields_.AddEntriesFrom(input, _repeated_fields_codec); + break; + } + case 26: { + oneofs_.AddEntriesFrom(input, _repeated_oneofs_codec); + break; + } + case 34: { + options_.AddEntriesFrom(input, _repeated_options_codec); + break; + } + case 42: { + if (sourceContext_ == null) { + sourceContext_ = new global::Google.Protobuf.WellKnownTypes.SourceContext(); + } + input.ReadMessage(sourceContext_); + break; + } + } + } + } + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class Field : pb::IMessage<Field> { + private static readonly pb::MessageParser<Field> _parser = new pb::MessageParser<Field>(() => new Field()); + public static pb::MessageParser<Field> Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "cardinality", "kind", "name", "number", "oneof_index", "options", "packed", "type_url" }; + private static readonly uint[] _fieldTags = new uint[] { 16, 8, 34, 24, 56, 74, 64, 50 }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.WellKnownTypes.Proto.Type.Descriptor.MessageTypes[1]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.WellKnownTypes.Proto.Type.internal__static_google_protobuf_Field__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public Field() { + OnConstruction(); + } + + partial void OnConstruction(); + + public Field(Field other) : this() { + kind_ = other.kind_; + cardinality_ = other.cardinality_; + number_ = other.number_; + name_ = other.name_; + typeUrl_ = other.typeUrl_; + oneofIndex_ = other.oneofIndex_; + packed_ = other.packed_; + options_ = other.options_.Clone(); + } + + public Field Clone() { + return new Field(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + options_.Freeze(); + } + + public const int KindFieldNumber = 1; + private global::Google.Protobuf.WellKnownTypes.Field.Types.Kind kind_ = global::Google.Protobuf.WellKnownTypes.Field.Types.Kind.TYPE_UNKNOWN; + public global::Google.Protobuf.WellKnownTypes.Field.Types.Kind Kind { + get { return kind_; } + set { + pb::Freezable.CheckMutable(this); + kind_ = value; + } + } + + public const int CardinalityFieldNumber = 2; + private global::Google.Protobuf.WellKnownTypes.Field.Types.Cardinality cardinality_ = global::Google.Protobuf.WellKnownTypes.Field.Types.Cardinality.CARDINALITY_UNKNOWN; + public global::Google.Protobuf.WellKnownTypes.Field.Types.Cardinality Cardinality { + get { return cardinality_; } + set { + pb::Freezable.CheckMutable(this); + cardinality_ = value; + } + } + + public const int NumberFieldNumber = 3; + private int number_; + public int Number { + get { return number_; } + set { + pb::Freezable.CheckMutable(this); + number_ = value; + } + } + + public const int NameFieldNumber = 4; + private string name_ = ""; + public string Name { + get { return name_; } + set { + pb::Freezable.CheckMutable(this); + name_ = value ?? ""; + } + } + + public const int TypeUrlFieldNumber = 6; + private string typeUrl_ = ""; + public string TypeUrl { + get { return typeUrl_; } + set { + pb::Freezable.CheckMutable(this); + typeUrl_ = value ?? ""; + } + } + + public const int OneofIndexFieldNumber = 7; + private int oneofIndex_; + public int OneofIndex { + get { return oneofIndex_; } + set { + pb::Freezable.CheckMutable(this); + oneofIndex_ = value; + } + } + + public const int PackedFieldNumber = 8; + private bool packed_; + public bool Packed { + get { return packed_; } + set { + pb::Freezable.CheckMutable(this); + packed_ = value; + } + } + + public const int OptionsFieldNumber = 9; + private static readonly pb::FieldCodec<global::Google.Protobuf.WellKnownTypes.Option> _repeated_options_codec + = pb::FieldCodec.ForMessage(74, global::Google.Protobuf.WellKnownTypes.Option.Parser); + private readonly pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Option> options_ = new pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Option>(); + public pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Option> Options { + get { return options_; } + } + + public override bool Equals(object other) { + return Equals(other as Field); + } + + public bool Equals(Field other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Kind != other.Kind) return false; + if (Cardinality != other.Cardinality) return false; + if (Number != other.Number) return false; + if (Name != other.Name) return false; + if (TypeUrl != other.TypeUrl) return false; + if (OneofIndex != other.OneofIndex) return false; + if (Packed != other.Packed) return false; + if(!options_.Equals(other.options_)) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + if (Kind != global::Google.Protobuf.WellKnownTypes.Field.Types.Kind.TYPE_UNKNOWN) hash ^= Kind.GetHashCode(); + if (Cardinality != global::Google.Protobuf.WellKnownTypes.Field.Types.Cardinality.CARDINALITY_UNKNOWN) hash ^= Cardinality.GetHashCode(); + if (Number != 0) hash ^= Number.GetHashCode(); + if (Name.Length != 0) hash ^= Name.GetHashCode(); + if (TypeUrl.Length != 0) hash ^= TypeUrl.GetHashCode(); + if (OneofIndex != 0) hash ^= OneofIndex.GetHashCode(); + if (Packed != false) hash ^= Packed.GetHashCode(); + hash ^= options_.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + if (Kind != global::Google.Protobuf.WellKnownTypes.Field.Types.Kind.TYPE_UNKNOWN) { + output.WriteRawTag(8); + output.WriteEnum((int) Kind); + } + if (Cardinality != global::Google.Protobuf.WellKnownTypes.Field.Types.Cardinality.CARDINALITY_UNKNOWN) { + output.WriteRawTag(16); + output.WriteEnum((int) Cardinality); + } + if (Number != 0) { + output.WriteRawTag(24); + output.WriteInt32(Number); + } + if (Name.Length != 0) { + output.WriteRawTag(34); + output.WriteString(Name); + } + if (TypeUrl.Length != 0) { + output.WriteRawTag(50); + output.WriteString(TypeUrl); + } + if (OneofIndex != 0) { + output.WriteRawTag(56); + output.WriteInt32(OneofIndex); + } + if (Packed != false) { + output.WriteRawTag(64); + output.WriteBool(Packed); + } + options_.WriteTo(output, _repeated_options_codec); + } + + public int CalculateSize() { + int size = 0; + if (Kind != global::Google.Protobuf.WellKnownTypes.Field.Types.Kind.TYPE_UNKNOWN) { + size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Kind); + } + if (Cardinality != global::Google.Protobuf.WellKnownTypes.Field.Types.Cardinality.CARDINALITY_UNKNOWN) { + size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Cardinality); + } + if (Number != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(Number); + } + if (Name.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Name); + } + if (TypeUrl.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(TypeUrl); + } + if (OneofIndex != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(OneofIndex); + } + if (Packed != false) { + size += 1 + 1; + } + size += options_.CalculateSize(_repeated_options_codec); + return size; + } + + public void MergeFrom(Field other) { + if (other == null) { + return; + } + if (other.Kind != global::Google.Protobuf.WellKnownTypes.Field.Types.Kind.TYPE_UNKNOWN) { + Kind = other.Kind; + } + if (other.Cardinality != global::Google.Protobuf.WellKnownTypes.Field.Types.Cardinality.CARDINALITY_UNKNOWN) { + Cardinality = other.Cardinality; + } + if (other.Number != 0) { + Number = other.Number; + } + if (other.Name.Length != 0) { + Name = other.Name; + } + if (other.TypeUrl.Length != 0) { + TypeUrl = other.TypeUrl; + } + if (other.OneofIndex != 0) { + OneofIndex = other.OneofIndex; + } + if (other.Packed != false) { + Packed = other.Packed; + } + options_.Add(other.options_); + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + case 8: { + kind_ = (global::Google.Protobuf.WellKnownTypes.Field.Types.Kind) input.ReadEnum(); + break; + } + case 16: { + cardinality_ = (global::Google.Protobuf.WellKnownTypes.Field.Types.Cardinality) input.ReadEnum(); + break; + } + case 24: { + Number = input.ReadInt32(); + break; + } + case 34: { + Name = input.ReadString(); + break; + } + case 50: { + TypeUrl = input.ReadString(); + break; + } + case 56: { + OneofIndex = input.ReadInt32(); + break; + } + case 64: { + Packed = input.ReadBool(); + break; + } + case 74: { + options_.AddEntriesFrom(input, _repeated_options_codec); + break; + } + } + } + } + + #region Nested types + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public static partial class Types { + public enum Kind { + TYPE_UNKNOWN = 0, + TYPE_DOUBLE = 1, + TYPE_FLOAT = 2, + TYPE_INT64 = 3, + TYPE_UINT64 = 4, + TYPE_INT32 = 5, + TYPE_FIXED64 = 6, + TYPE_FIXED32 = 7, + TYPE_BOOL = 8, + TYPE_STRING = 9, + TYPE_MESSAGE = 11, + TYPE_BYTES = 12, + TYPE_UINT32 = 13, + TYPE_ENUM = 14, + TYPE_SFIXED32 = 15, + TYPE_SFIXED64 = 16, + TYPE_SINT32 = 17, + TYPE_SINT64 = 18, + } + + public enum Cardinality { + CARDINALITY_UNKNOWN = 0, + CARDINALITY_OPTIONAL = 1, + CARDINALITY_REQUIRED = 2, + CARDINALITY_REPEATED = 3, + } + + } + #endregion + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class Enum : pb::IMessage<Enum> { + private static readonly pb::MessageParser<Enum> _parser = new pb::MessageParser<Enum>(() => new Enum()); + public static pb::MessageParser<Enum> Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "enumvalue", "name", "options", "source_context" }; + private static readonly uint[] _fieldTags = new uint[] { 18, 10, 26, 34 }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.WellKnownTypes.Proto.Type.Descriptor.MessageTypes[2]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.WellKnownTypes.Proto.Type.internal__static_google_protobuf_Enum__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public Enum() { + OnConstruction(); + } + + partial void OnConstruction(); + + public Enum(Enum other) : this() { + name_ = other.name_; + enumvalue_ = other.enumvalue_.Clone(); + options_ = other.options_.Clone(); + SourceContext = other.sourceContext_ != null ? other.SourceContext.Clone() : null; + } + + public Enum Clone() { + return new Enum(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + enumvalue_.Freeze(); + options_.Freeze(); + if (sourceContext_ != null) SourceContext.Freeze(); + } + + public const int NameFieldNumber = 1; + private string name_ = ""; + public string Name { + get { return name_; } + set { + pb::Freezable.CheckMutable(this); + name_ = value ?? ""; + } + } + + public const int EnumvalueFieldNumber = 2; + private static readonly pb::FieldCodec<global::Google.Protobuf.WellKnownTypes.EnumValue> _repeated_enumvalue_codec + = pb::FieldCodec.ForMessage(18, global::Google.Protobuf.WellKnownTypes.EnumValue.Parser); + private readonly pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.EnumValue> enumvalue_ = new pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.EnumValue>(); + public pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.EnumValue> Enumvalue { + get { return enumvalue_; } + } + + public const int OptionsFieldNumber = 3; + private static readonly pb::FieldCodec<global::Google.Protobuf.WellKnownTypes.Option> _repeated_options_codec + = pb::FieldCodec.ForMessage(26, global::Google.Protobuf.WellKnownTypes.Option.Parser); + private readonly pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Option> options_ = new pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Option>(); + public pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Option> Options { + get { return options_; } + } + + public const int SourceContextFieldNumber = 4; + private global::Google.Protobuf.WellKnownTypes.SourceContext sourceContext_; + public global::Google.Protobuf.WellKnownTypes.SourceContext SourceContext { + get { return sourceContext_; } + set { + pb::Freezable.CheckMutable(this); + sourceContext_ = value; + } + } + + public override bool Equals(object other) { + return Equals(other as Enum); + } + + public bool Equals(Enum other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Name != other.Name) return false; + if(!enumvalue_.Equals(other.enumvalue_)) return false; + if(!options_.Equals(other.options_)) return false; + if (!object.Equals(SourceContext, other.SourceContext)) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + if (Name.Length != 0) hash ^= Name.GetHashCode(); + hash ^= enumvalue_.GetHashCode(); + hash ^= options_.GetHashCode(); + if (sourceContext_ != null) hash ^= SourceContext.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + if (Name.Length != 0) { + output.WriteRawTag(10); + output.WriteString(Name); + } + enumvalue_.WriteTo(output, _repeated_enumvalue_codec); + options_.WriteTo(output, _repeated_options_codec); + if (sourceContext_ != null) { + output.WriteRawTag(34); + output.WriteMessage(SourceContext); + } + } + + public int CalculateSize() { + int size = 0; + if (Name.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Name); + } + size += enumvalue_.CalculateSize(_repeated_enumvalue_codec); + size += options_.CalculateSize(_repeated_options_codec); + if (sourceContext_ != null) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(SourceContext); + } + return size; + } + + public void MergeFrom(Enum other) { + if (other == null) { + return; + } + if (other.Name.Length != 0) { + Name = other.Name; + } + enumvalue_.Add(other.enumvalue_); + options_.Add(other.options_); + if (other.sourceContext_ != null) { + if (sourceContext_ == null) { + sourceContext_ = new global::Google.Protobuf.WellKnownTypes.SourceContext(); + } + SourceContext.MergeFrom(other.SourceContext); + } + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + case 10: { + Name = input.ReadString(); + break; + } + case 18: { + enumvalue_.AddEntriesFrom(input, _repeated_enumvalue_codec); + break; + } + case 26: { + options_.AddEntriesFrom(input, _repeated_options_codec); + break; + } + case 34: { + if (sourceContext_ == null) { + sourceContext_ = new global::Google.Protobuf.WellKnownTypes.SourceContext(); + } + input.ReadMessage(sourceContext_); + break; + } + } + } + } + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class EnumValue : pb::IMessage<EnumValue> { + private static readonly pb::MessageParser<EnumValue> _parser = new pb::MessageParser<EnumValue>(() => new EnumValue()); + public static pb::MessageParser<EnumValue> Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "name", "number", "options" }; + private static readonly uint[] _fieldTags = new uint[] { 10, 16, 26 }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.WellKnownTypes.Proto.Type.Descriptor.MessageTypes[3]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.WellKnownTypes.Proto.Type.internal__static_google_protobuf_EnumValue__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public EnumValue() { + OnConstruction(); + } + + partial void OnConstruction(); + + public EnumValue(EnumValue other) : this() { + name_ = other.name_; + number_ = other.number_; + options_ = other.options_.Clone(); + } + + public EnumValue Clone() { + return new EnumValue(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + options_.Freeze(); + } + + public const int NameFieldNumber = 1; + private string name_ = ""; + public string Name { + get { return name_; } + set { + pb::Freezable.CheckMutable(this); + name_ = value ?? ""; + } + } + + public const int NumberFieldNumber = 2; + private int number_; + public int Number { + get { return number_; } + set { + pb::Freezable.CheckMutable(this); + number_ = value; + } + } + + public const int OptionsFieldNumber = 3; + private static readonly pb::FieldCodec<global::Google.Protobuf.WellKnownTypes.Option> _repeated_options_codec + = pb::FieldCodec.ForMessage(26, global::Google.Protobuf.WellKnownTypes.Option.Parser); + private readonly pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Option> options_ = new pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Option>(); + public pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Option> Options { + get { return options_; } + } + + public override bool Equals(object other) { + return Equals(other as EnumValue); + } + + public bool Equals(EnumValue other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Name != other.Name) return false; + if (Number != other.Number) return false; + if(!options_.Equals(other.options_)) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + if (Name.Length != 0) hash ^= Name.GetHashCode(); + if (Number != 0) hash ^= Number.GetHashCode(); + hash ^= options_.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + if (Name.Length != 0) { + output.WriteRawTag(10); + output.WriteString(Name); + } + if (Number != 0) { + output.WriteRawTag(16); + output.WriteInt32(Number); + } + options_.WriteTo(output, _repeated_options_codec); + } + + public int CalculateSize() { + int size = 0; + if (Name.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Name); + } + if (Number != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(Number); + } + size += options_.CalculateSize(_repeated_options_codec); + return size; + } + + public void MergeFrom(EnumValue other) { + if (other == null) { + return; + } + if (other.Name.Length != 0) { + Name = other.Name; + } + if (other.Number != 0) { + Number = other.Number; + } + options_.Add(other.options_); + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + case 10: { + Name = input.ReadString(); + break; + } + case 16: { + Number = input.ReadInt32(); + break; + } + case 26: { + options_.AddEntriesFrom(input, _repeated_options_codec); + break; + } + } + } + } + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class Option : pb::IMessage<Option> { + private static readonly pb::MessageParser<Option> _parser = new pb::MessageParser<Option>(() => new Option()); + public static pb::MessageParser<Option> Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "name", "value" }; + private static readonly uint[] _fieldTags = new uint[] { 10, 18 }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.WellKnownTypes.Proto.Type.Descriptor.MessageTypes[4]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.WellKnownTypes.Proto.Type.internal__static_google_protobuf_Option__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public Option() { + OnConstruction(); + } + + partial void OnConstruction(); + + public Option(Option other) : this() { + name_ = other.name_; + Value = other.value_ != null ? other.Value.Clone() : null; + } + + public Option Clone() { + return new Option(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + if (value_ != null) Value.Freeze(); + } + + public const int NameFieldNumber = 1; + private string name_ = ""; + public string Name { + get { return name_; } + set { + pb::Freezable.CheckMutable(this); + name_ = value ?? ""; + } + } + + public const int ValueFieldNumber = 2; + private global::Google.Protobuf.WellKnownTypes.Any value_; + public global::Google.Protobuf.WellKnownTypes.Any Value { + get { return value_; } + set { + pb::Freezable.CheckMutable(this); + value_ = value; + } + } + + public override bool Equals(object other) { + return Equals(other as Option); + } + + public bool Equals(Option other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Name != other.Name) return false; + if (!object.Equals(Value, other.Value)) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + if (Name.Length != 0) hash ^= Name.GetHashCode(); + if (value_ != null) hash ^= Value.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + if (Name.Length != 0) { + output.WriteRawTag(10); + output.WriteString(Name); + } + if (value_ != null) { + output.WriteRawTag(18); + output.WriteMessage(Value); + } + } + + public int CalculateSize() { + int size = 0; + if (Name.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Name); + } + if (value_ != null) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(Value); + } + return size; + } + + public void MergeFrom(Option other) { + if (other == null) { + return; + } + if (other.Name.Length != 0) { + Name = other.Name; + } + if (other.value_ != null) { + if (value_ == null) { + value_ = new global::Google.Protobuf.WellKnownTypes.Any(); + } + Value.MergeFrom(other.Value); + } + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + case 10: { + Name = input.ReadString(); + break; + } + case 18: { + if (value_ == null) { + value_ = new global::Google.Protobuf.WellKnownTypes.Any(); + } + input.ReadMessage(value_); + break; + } + } + } + } + + } + + #endregion + +} + +#endregion Designer generated code diff --git a/csharp/src/ProtocolBuffers/WellKnownTypes/Wrappers.cs b/csharp/src/ProtocolBuffers/WellKnownTypes/Wrappers.cs new file mode 100644 index 00000000..c26f874d --- /dev/null +++ b/csharp/src/ProtocolBuffers/WellKnownTypes/Wrappers.cs @@ -0,0 +1,1154 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/protobuf/wrappers.proto +#pragma warning disable 1591, 0612, 3021 +#region Designer generated code + +using pb = global::Google.Protobuf; +using pbc = global::Google.Protobuf.Collections; +using pbr = global::Google.Protobuf.Reflection; +using scg = global::System.Collections.Generic; +namespace Google.Protobuf.WellKnownTypes { + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public static partial class Wrappers { + + #region Static variables + internal static pbr::FieldAccessorTable internal__static_google_protobuf_DoubleValue__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_google_protobuf_FloatValue__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_google_protobuf_Int64Value__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_google_protobuf_UInt64Value__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_google_protobuf_Int32Value__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_google_protobuf_UInt32Value__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_google_protobuf_BoolValue__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_google_protobuf_StringValue__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_google_protobuf_BytesValue__FieldAccessorTable; + #endregion + #region Descriptor + public static pbr::FileDescriptor Descriptor { + get { return descriptor; } + } + private static pbr::FileDescriptor descriptor; + + static Wrappers() { + byte[] descriptorData = global::System.Convert.FromBase64String( + string.Concat( + "Ch5nb29nbGUvcHJvdG9idWYvd3JhcHBlcnMucHJvdG8SD2dvb2dsZS5wcm90", + "b2J1ZiIcCgtEb3VibGVWYWx1ZRINCgV2YWx1ZRgBIAEoASIbCgpGbG9hdFZh", + "bHVlEg0KBXZhbHVlGAEgASgCIhsKCkludDY0VmFsdWUSDQoFdmFsdWUYASAB", + "KAMiHAoLVUludDY0VmFsdWUSDQoFdmFsdWUYASABKAQiGwoKSW50MzJWYWx1", + "ZRINCgV2YWx1ZRgBIAEoBSIcCgtVSW50MzJWYWx1ZRINCgV2YWx1ZRgBIAEo", + "DSIaCglCb29sVmFsdWUSDQoFdmFsdWUYASABKAgiHAoLU3RyaW5nVmFsdWUS", + "DQoFdmFsdWUYASABKAkiGwoKQnl0ZXNWYWx1ZRINCgV2YWx1ZRgBIAEoDEJN", + "ChNjb20uZ29vZ2xlLnByb3RvYnVmQg1XcmFwcGVyc1Byb3RvUAGiAgNHUEKq", + "Ah5Hb29nbGUuUHJvdG9idWYuV2VsbEtub3duVHlwZXNiBnByb3RvMw==")); + descriptor = pbr::FileDescriptor.InternalBuildGeneratedFileFrom(descriptorData, + new pbr::FileDescriptor[] { + }); + internal__static_google_protobuf_DoubleValue__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.WellKnownTypes.DoubleValue), descriptor.MessageTypes[0], + new string[] { "Value", }, new string[] { }); + internal__static_google_protobuf_FloatValue__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.WellKnownTypes.FloatValue), descriptor.MessageTypes[1], + new string[] { "Value", }, new string[] { }); + internal__static_google_protobuf_Int64Value__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.WellKnownTypes.Int64Value), descriptor.MessageTypes[2], + new string[] { "Value", }, new string[] { }); + internal__static_google_protobuf_UInt64Value__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.WellKnownTypes.UInt64Value), descriptor.MessageTypes[3], + new string[] { "Value", }, new string[] { }); + internal__static_google_protobuf_Int32Value__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.WellKnownTypes.Int32Value), descriptor.MessageTypes[4], + new string[] { "Value", }, new string[] { }); + internal__static_google_protobuf_UInt32Value__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.WellKnownTypes.UInt32Value), descriptor.MessageTypes[5], + new string[] { "Value", }, new string[] { }); + internal__static_google_protobuf_BoolValue__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.WellKnownTypes.BoolValue), descriptor.MessageTypes[6], + new string[] { "Value", }, new string[] { }); + internal__static_google_protobuf_StringValue__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.WellKnownTypes.StringValue), descriptor.MessageTypes[7], + new string[] { "Value", }, new string[] { }); + internal__static_google_protobuf_BytesValue__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.WellKnownTypes.BytesValue), descriptor.MessageTypes[8], + new string[] { "Value", }, new string[] { }); + } + #endregion + + } + #region Messages + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class DoubleValue : pb::IMessage<DoubleValue> { + private static readonly pb::MessageParser<DoubleValue> _parser = new pb::MessageParser<DoubleValue>(() => new DoubleValue()); + public static pb::MessageParser<DoubleValue> Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "value" }; + private static readonly uint[] _fieldTags = new uint[] { 9 }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.WellKnownTypes.Wrappers.Descriptor.MessageTypes[0]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.WellKnownTypes.Wrappers.internal__static_google_protobuf_DoubleValue__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public DoubleValue() { + OnConstruction(); + } + + partial void OnConstruction(); + + public DoubleValue(DoubleValue other) : this() { + value_ = other.value_; + } + + public DoubleValue Clone() { + return new DoubleValue(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + } + + public const int ValueFieldNumber = 1; + private double value_; + public double Value { + get { return value_; } + set { + pb::Freezable.CheckMutable(this); + value_ = value; + } + } + + public override bool Equals(object other) { + return Equals(other as DoubleValue); + } + + public bool Equals(DoubleValue other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Value != other.Value) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + if (Value != 0D) hash ^= Value.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + if (Value != 0D) { + output.WriteRawTag(9); + output.WriteDouble(Value); + } + } + + public int CalculateSize() { + int size = 0; + if (Value != 0D) { + size += 1 + 8; + } + return size; + } + + public void MergeFrom(DoubleValue other) { + if (other == null) { + return; + } + if (other.Value != 0D) { + Value = other.Value; + } + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + case 9: { + Value = input.ReadDouble(); + break; + } + } + } + } + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class FloatValue : pb::IMessage<FloatValue> { + private static readonly pb::MessageParser<FloatValue> _parser = new pb::MessageParser<FloatValue>(() => new FloatValue()); + public static pb::MessageParser<FloatValue> Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "value" }; + private static readonly uint[] _fieldTags = new uint[] { 13 }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.WellKnownTypes.Wrappers.Descriptor.MessageTypes[1]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.WellKnownTypes.Wrappers.internal__static_google_protobuf_FloatValue__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public FloatValue() { + OnConstruction(); + } + + partial void OnConstruction(); + + public FloatValue(FloatValue other) : this() { + value_ = other.value_; + } + + public FloatValue Clone() { + return new FloatValue(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + } + + public const int ValueFieldNumber = 1; + private float value_; + public float Value { + get { return value_; } + set { + pb::Freezable.CheckMutable(this); + value_ = value; + } + } + + public override bool Equals(object other) { + return Equals(other as FloatValue); + } + + public bool Equals(FloatValue other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Value != other.Value) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + if (Value != 0F) hash ^= Value.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + if (Value != 0F) { + output.WriteRawTag(13); + output.WriteFloat(Value); + } + } + + public int CalculateSize() { + int size = 0; + if (Value != 0F) { + size += 1 + 4; + } + return size; + } + + public void MergeFrom(FloatValue other) { + if (other == null) { + return; + } + if (other.Value != 0F) { + Value = other.Value; + } + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + case 13: { + Value = input.ReadFloat(); + break; + } + } + } + } + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class Int64Value : pb::IMessage<Int64Value> { + private static readonly pb::MessageParser<Int64Value> _parser = new pb::MessageParser<Int64Value>(() => new Int64Value()); + public static pb::MessageParser<Int64Value> Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "value" }; + private static readonly uint[] _fieldTags = new uint[] { 8 }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.WellKnownTypes.Wrappers.Descriptor.MessageTypes[2]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.WellKnownTypes.Wrappers.internal__static_google_protobuf_Int64Value__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public Int64Value() { + OnConstruction(); + } + + partial void OnConstruction(); + + public Int64Value(Int64Value other) : this() { + value_ = other.value_; + } + + public Int64Value Clone() { + return new Int64Value(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + } + + public const int ValueFieldNumber = 1; + private long value_; + public long Value { + get { return value_; } + set { + pb::Freezable.CheckMutable(this); + value_ = value; + } + } + + public override bool Equals(object other) { + return Equals(other as Int64Value); + } + + public bool Equals(Int64Value other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Value != other.Value) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + if (Value != 0L) hash ^= Value.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + if (Value != 0L) { + output.WriteRawTag(8); + output.WriteInt64(Value); + } + } + + public int CalculateSize() { + int size = 0; + if (Value != 0L) { + size += 1 + pb::CodedOutputStream.ComputeInt64Size(Value); + } + return size; + } + + public void MergeFrom(Int64Value other) { + if (other == null) { + return; + } + if (other.Value != 0L) { + Value = other.Value; + } + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + case 8: { + Value = input.ReadInt64(); + break; + } + } + } + } + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class UInt64Value : pb::IMessage<UInt64Value> { + private static readonly pb::MessageParser<UInt64Value> _parser = new pb::MessageParser<UInt64Value>(() => new UInt64Value()); + public static pb::MessageParser<UInt64Value> Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "value" }; + private static readonly uint[] _fieldTags = new uint[] { 8 }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.WellKnownTypes.Wrappers.Descriptor.MessageTypes[3]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.WellKnownTypes.Wrappers.internal__static_google_protobuf_UInt64Value__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public UInt64Value() { + OnConstruction(); + } + + partial void OnConstruction(); + + public UInt64Value(UInt64Value other) : this() { + value_ = other.value_; + } + + public UInt64Value Clone() { + return new UInt64Value(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + } + + public const int ValueFieldNumber = 1; + private ulong value_; + public ulong Value { + get { return value_; } + set { + pb::Freezable.CheckMutable(this); + value_ = value; + } + } + + public override bool Equals(object other) { + return Equals(other as UInt64Value); + } + + public bool Equals(UInt64Value other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Value != other.Value) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + if (Value != 0UL) hash ^= Value.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + if (Value != 0UL) { + output.WriteRawTag(8); + output.WriteUInt64(Value); + } + } + + public int CalculateSize() { + int size = 0; + if (Value != 0UL) { + size += 1 + pb::CodedOutputStream.ComputeUInt64Size(Value); + } + return size; + } + + public void MergeFrom(UInt64Value other) { + if (other == null) { + return; + } + if (other.Value != 0UL) { + Value = other.Value; + } + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + case 8: { + Value = input.ReadUInt64(); + break; + } + } + } + } + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class Int32Value : pb::IMessage<Int32Value> { + private static readonly pb::MessageParser<Int32Value> _parser = new pb::MessageParser<Int32Value>(() => new Int32Value()); + public static pb::MessageParser<Int32Value> Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "value" }; + private static readonly uint[] _fieldTags = new uint[] { 8 }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.WellKnownTypes.Wrappers.Descriptor.MessageTypes[4]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.WellKnownTypes.Wrappers.internal__static_google_protobuf_Int32Value__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public Int32Value() { + OnConstruction(); + } + + partial void OnConstruction(); + + public Int32Value(Int32Value other) : this() { + value_ = other.value_; + } + + public Int32Value Clone() { + return new Int32Value(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + } + + public const int ValueFieldNumber = 1; + private int value_; + public int Value { + get { return value_; } + set { + pb::Freezable.CheckMutable(this); + value_ = value; + } + } + + public override bool Equals(object other) { + return Equals(other as Int32Value); + } + + public bool Equals(Int32Value other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Value != other.Value) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + if (Value != 0) hash ^= Value.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + if (Value != 0) { + output.WriteRawTag(8); + output.WriteInt32(Value); + } + } + + public int CalculateSize() { + int size = 0; + if (Value != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(Value); + } + return size; + } + + public void MergeFrom(Int32Value other) { + if (other == null) { + return; + } + if (other.Value != 0) { + Value = other.Value; + } + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + case 8: { + Value = input.ReadInt32(); + break; + } + } + } + } + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class UInt32Value : pb::IMessage<UInt32Value> { + private static readonly pb::MessageParser<UInt32Value> _parser = new pb::MessageParser<UInt32Value>(() => new UInt32Value()); + public static pb::MessageParser<UInt32Value> Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "value" }; + private static readonly uint[] _fieldTags = new uint[] { 8 }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.WellKnownTypes.Wrappers.Descriptor.MessageTypes[5]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.WellKnownTypes.Wrappers.internal__static_google_protobuf_UInt32Value__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public UInt32Value() { + OnConstruction(); + } + + partial void OnConstruction(); + + public UInt32Value(UInt32Value other) : this() { + value_ = other.value_; + } + + public UInt32Value Clone() { + return new UInt32Value(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + } + + public const int ValueFieldNumber = 1; + private uint value_; + public uint Value { + get { return value_; } + set { + pb::Freezable.CheckMutable(this); + value_ = value; + } + } + + public override bool Equals(object other) { + return Equals(other as UInt32Value); + } + + public bool Equals(UInt32Value other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Value != other.Value) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + if (Value != 0) hash ^= Value.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + if (Value != 0) { + output.WriteRawTag(8); + output.WriteUInt32(Value); + } + } + + public int CalculateSize() { + int size = 0; + if (Value != 0) { + size += 1 + pb::CodedOutputStream.ComputeUInt32Size(Value); + } + return size; + } + + public void MergeFrom(UInt32Value other) { + if (other == null) { + return; + } + if (other.Value != 0) { + Value = other.Value; + } + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + case 8: { + Value = input.ReadUInt32(); + break; + } + } + } + } + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class BoolValue : pb::IMessage<BoolValue> { + private static readonly pb::MessageParser<BoolValue> _parser = new pb::MessageParser<BoolValue>(() => new BoolValue()); + public static pb::MessageParser<BoolValue> Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "value" }; + private static readonly uint[] _fieldTags = new uint[] { 8 }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.WellKnownTypes.Wrappers.Descriptor.MessageTypes[6]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.WellKnownTypes.Wrappers.internal__static_google_protobuf_BoolValue__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public BoolValue() { + OnConstruction(); + } + + partial void OnConstruction(); + + public BoolValue(BoolValue other) : this() { + value_ = other.value_; + } + + public BoolValue Clone() { + return new BoolValue(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + } + + public const int ValueFieldNumber = 1; + private bool value_; + public bool Value { + get { return value_; } + set { + pb::Freezable.CheckMutable(this); + value_ = value; + } + } + + public override bool Equals(object other) { + return Equals(other as BoolValue); + } + + public bool Equals(BoolValue other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Value != other.Value) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + if (Value != false) hash ^= Value.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + if (Value != false) { + output.WriteRawTag(8); + output.WriteBool(Value); + } + } + + public int CalculateSize() { + int size = 0; + if (Value != false) { + size += 1 + 1; + } + return size; + } + + public void MergeFrom(BoolValue other) { + if (other == null) { + return; + } + if (other.Value != false) { + Value = other.Value; + } + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + case 8: { + Value = input.ReadBool(); + break; + } + } + } + } + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class StringValue : pb::IMessage<StringValue> { + private static readonly pb::MessageParser<StringValue> _parser = new pb::MessageParser<StringValue>(() => new StringValue()); + public static pb::MessageParser<StringValue> Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "value" }; + private static readonly uint[] _fieldTags = new uint[] { 10 }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.WellKnownTypes.Wrappers.Descriptor.MessageTypes[7]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.WellKnownTypes.Wrappers.internal__static_google_protobuf_StringValue__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public StringValue() { + OnConstruction(); + } + + partial void OnConstruction(); + + public StringValue(StringValue other) : this() { + value_ = other.value_; + } + + public StringValue Clone() { + return new StringValue(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + } + + public const int ValueFieldNumber = 1; + private string value_ = ""; + public string Value { + get { return value_; } + set { + pb::Freezable.CheckMutable(this); + value_ = value ?? ""; + } + } + + public override bool Equals(object other) { + return Equals(other as StringValue); + } + + public bool Equals(StringValue other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Value != other.Value) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + if (Value.Length != 0) hash ^= Value.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + if (Value.Length != 0) { + output.WriteRawTag(10); + output.WriteString(Value); + } + } + + public int CalculateSize() { + int size = 0; + if (Value.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Value); + } + return size; + } + + public void MergeFrom(StringValue other) { + if (other == null) { + return; + } + if (other.Value.Length != 0) { + Value = other.Value; + } + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + case 10: { + Value = input.ReadString(); + break; + } + } + } + } + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class BytesValue : pb::IMessage<BytesValue> { + private static readonly pb::MessageParser<BytesValue> _parser = new pb::MessageParser<BytesValue>(() => new BytesValue()); + public static pb::MessageParser<BytesValue> Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "value" }; + private static readonly uint[] _fieldTags = new uint[] { 10 }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.WellKnownTypes.Wrappers.Descriptor.MessageTypes[8]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.WellKnownTypes.Wrappers.internal__static_google_protobuf_BytesValue__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public BytesValue() { + OnConstruction(); + } + + partial void OnConstruction(); + + public BytesValue(BytesValue other) : this() { + value_ = other.value_; + } + + public BytesValue Clone() { + return new BytesValue(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + } + + public const int ValueFieldNumber = 1; + private pb::ByteString value_ = pb::ByteString.Empty; + public pb::ByteString Value { + get { return value_; } + set { + pb::Freezable.CheckMutable(this); + value_ = value ?? pb::ByteString.Empty; + } + } + + public override bool Equals(object other) { + return Equals(other as BytesValue); + } + + public bool Equals(BytesValue other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Value != other.Value) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + if (Value.Length != 0) hash ^= Value.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + if (Value.Length != 0) { + output.WriteRawTag(10); + output.WriteBytes(Value); + } + } + + public int CalculateSize() { + int size = 0; + if (Value.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeBytesSize(Value); + } + return size; + } + + public void MergeFrom(BytesValue other) { + if (other == null) { + return; + } + if (other.Value.Length != 0) { + Value = other.Value; + } + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + case 10: { + Value = input.ReadBytes(); + break; + } + } + } + } + + } + + #endregion + +} + +#endregion Designer generated code diff --git a/csharp/src/ProtocolBuffers/WireFormat.cs b/csharp/src/ProtocolBuffers/WireFormat.cs index 7489c2fc..c1712daa 100644 --- a/csharp/src/ProtocolBuffers/WireFormat.cs +++ b/csharp/src/ProtocolBuffers/WireFormat.cs @@ -31,7 +31,7 @@ #endregion
using System;
-using Google.Protobuf.Descriptors;
+using Google.Protobuf.Reflection;
namespace Google.Protobuf
{
|