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

Refactoring of CodedInputStream.Read??? to use boolean return with out param.

parent 99284416
......@@ -304,22 +304,22 @@ namespace Google.ProtocolBuffers.Examples.AddressBook {
if (unknownFields == null) {
unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
}
ParseUnknownField(input, unknownFields, extensionRegistry, tag);
ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
break;
}
case 10: {
Number = input.ReadString();
result.hasNumber |= input.ReadString(ref result.number_);
break;
}
case 16: {
int rawValue = input.ReadEnum();
if (!global::System.Enum.IsDefined(typeof(global::Google.ProtocolBuffers.Examples.AddressBook.Person.Types.PhoneType), rawValue)) {
object unknown;
if(input.ReadEnum(ref result.type_, out unknown)) {
result.hasType = true;
} else if(unknown is int) {
if (unknownFields == null) {
unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
}
unknownFields.MergeVarintField(2, (ulong) rawValue);
} else {
Type = (global::Google.ProtocolBuffers.Examples.AddressBook.Person.Types.PhoneType) rawValue;
unknownFields.MergeVarintField(2, (ulong)(int)unknown);
}
break;
}
......@@ -602,25 +602,23 @@ namespace Google.ProtocolBuffers.Examples.AddressBook {
if (unknownFields == null) {
unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
}
ParseUnknownField(input, unknownFields, extensionRegistry, tag);
ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
break;
}
case 10: {
Name = input.ReadString();
result.hasName |= input.ReadString(ref result.name_);
break;
}
case 16: {
Id = input.ReadInt32();
result.hasId |= input.ReadInt32(ref result.id_);
break;
}
case 26: {
Email = input.ReadString();
result.hasEmail |= input.ReadString(ref result.email_);
break;
}
case 34: {
global::Google.ProtocolBuffers.Examples.AddressBook.Person.Types.PhoneNumber.Builder subBuilder = global::Google.ProtocolBuffers.Examples.AddressBook.Person.Types.PhoneNumber.CreateBuilder();
input.ReadMessage(subBuilder, extensionRegistry);
AddPhone(subBuilder.BuildPartial());
input.ReadMessageArray(tag, field_name, result.phone_, global::Google.ProtocolBuffers.Examples.AddressBook.Person.Types.PhoneNumber.DefaultInstance, extensionRegistry);
break;
}
}
......@@ -922,13 +920,11 @@ namespace Google.ProtocolBuffers.Examples.AddressBook {
if (unknownFields == null) {
unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
}
ParseUnknownField(input, unknownFields, extensionRegistry, tag);
ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
break;
}
case 10: {
global::Google.ProtocolBuffers.Examples.AddressBook.Person.Builder subBuilder = global::Google.ProtocolBuffers.Examples.AddressBook.Person.CreateBuilder();
input.ReadMessage(subBuilder, extensionRegistry);
AddPerson(subBuilder.BuildPartial());
input.ReadMessageArray(tag, field_name, result.person_, global::Google.ProtocolBuffers.Examples.AddressBook.Person.DefaultInstance, extensionRegistry);
break;
}
}
......
......@@ -95,19 +95,32 @@ namespace Google.ProtocolBuffers.ProtoGen
public void GenerateParsingCode(TextGenerator writer)
{
// TODO(jonskeet): Make a more efficient way of doing this
writer.WriteLine("int rawValue = input.ReadEnum();");
writer.WriteLine("if (!global::System.Enum.IsDefined(typeof({0}), rawValue)) {{", TypeName);
writer.WriteLine("object unknown;");
writer.WriteLine("if(input.ReadEnum(ref result.{0}_, out unknown)) {{", Name);
writer.WriteLine(" result.has{0} = true;", PropertyName);
writer.WriteLine("} else if(unknown is int) {");
if (!UseLiteRuntime)
{
writer.WriteLine(" if (unknownFields == null) {"); // First unknown field - create builder now
writer.WriteLine(" unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);");
writer.WriteLine(" }");
writer.WriteLine(" unknownFields.MergeVarintField({0}, (ulong) rawValue);", Number);
writer.WriteLine(" unknownFields.MergeVarintField({0}, (ulong)(int)unknown);", Number);
}
writer.WriteLine("} else {");
writer.WriteLine(" {0} = ({1}) rawValue;", PropertyName, TypeName);
writer.WriteLine("}");
// TO DO(jonskeet): Make a more efficient way of doing this
//writer.WriteLine("int rawValue = input.ReadEnum();");
//writer.WriteLine("if (!global::System.Enum.IsDefined(typeof({0}), rawValue)) {{", TypeName);
//if (!UseLiteRuntime)
//{
// writer.WriteLine(" if (unknownFields == null) {"); // First unknown field - create builder now
// writer.WriteLine(" unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);");
// writer.WriteLine(" }");
// writer.WriteLine(" unknownFields.MergeVarintField({0}, (ulong) rawValue);", Number);
//}
//writer.WriteLine("} else {");
//writer.WriteLine(" {0} = ({1}) rawValue;", PropertyName, TypeName);
//writer.WriteLine("}");
}
public void GenerateSerializationCode(TextGenerator writer)
......
......@@ -647,7 +647,7 @@ namespace Google.ProtocolBuffers.ProtoGen
writer.WriteLine(" unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);");
writer.WriteLine(" }");
}
writer.WriteLine(" ParseUnknownField(input, {0}extensionRegistry, tag);",
writer.WriteLine(" ParseUnknownField(input, {0}extensionRegistry, tag, field_name);",
UseLiteRuntime ? "" : "unknownFields, ");
writer.WriteLine(" break;");
writer.WriteLine("}");
......
......@@ -97,7 +97,7 @@ namespace Google.ProtocolBuffers.ProtoGen
public void GenerateParsingCode(TextGenerator writer)
{
writer.WriteLine("{0} = input.Read{1}();", PropertyName, CapitalizedTypeName);
writer.WriteLine("result.has{0} |= input.Read{1}(ref result.{2}_);", PropertyName, CapitalizedTypeName, Name);
}
public void GenerateSerializationCode(TextGenerator writer)
......
......@@ -112,36 +112,50 @@ namespace Google.ProtocolBuffers.ProtoGen
public void GenerateParsingCode(TextGenerator writer)
{
// If packed, set up the while loop
if (Descriptor.IsPacked)
{
writer.WriteLine("int length = input.ReadInt32();");
writer.WriteLine("int oldLimit = input.PushLimit(length);");
writer.WriteLine("while (!input.ReachedLimit) {");
writer.Indent();
}
// Read and store the enum
// TODO(jonskeet): Make a more efficient way of doing this
writer.WriteLine("int rawValue = input.ReadEnum();");
writer.WriteLine("if (!global::System.Enum.IsDefined(typeof({0}), rawValue)) {{", TypeName);
writer.WriteLine("scg::ICollection<object> unknownItems;");
writer.WriteLine("input.ReadEnumArray<{0}>(tag, field_name, result.{1}_, out unknownItems);", TypeName, Name);
if (!UseLiteRuntime)
{
writer.WriteLine(" if (unknownFields == null) {"); // First unknown field - create builder now
writer.WriteLine("if (unknownItems != null) {");
writer.WriteLine(" if (unknownFields == null) {");
writer.WriteLine(" unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);");
writer.WriteLine(" }");
writer.WriteLine(" unknownFields.MergeVarintField({0}, (ulong) rawValue);", Number);
}
writer.WriteLine("} else {");
writer.WriteLine(" Add{0}(({1}) rawValue);", PropertyName, TypeName);
writer.WriteLine("}");
if (Descriptor.IsPacked)
{
writer.Outdent();
writer.WriteLine(" foreach (object rawValue in unknownItems)");
writer.WriteLine(" if (rawValue is int)");
writer.WriteLine(" unknownFields.MergeVarintField({0}, (ulong)(int)rawValue);", Number);
writer.WriteLine("}");
writer.WriteLine("input.PopLimit(oldLimit);");
}
//// If packed, set up the while loop
//if (Descriptor.IsPacked)
//{
// writer.WriteLine("int length = input.ReadInt32();");
// writer.WriteLine("int oldLimit = input.PushLimit(length);");
// writer.WriteLine("while (!input.ReachedLimit) {");
// writer.Indent();
//}
//// Read and store the enum
//// TO DO(jonskeet): Make a more efficient way of doing this
//writer.WriteLine("int rawValue = input.ReadEnum();");
//writer.WriteLine("if (!global::System.Enum.IsDefined(typeof({0}), rawValue)) {{", TypeName);
//if (!UseLiteRuntime)
//{
// writer.WriteLine(" if (unknownFields == null) {"); // First unknown field - create builder now
// writer.WriteLine(" unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);");
// writer.WriteLine(" }");
// writer.WriteLine(" unknownFields.MergeVarintField({0}, (ulong) rawValue);", Number);
//}
//writer.WriteLine("} else {");
//writer.WriteLine(" Add{0}(({1}) rawValue);", PropertyName, TypeName);
//writer.WriteLine("}");
//if (Descriptor.IsPacked)
//{
// writer.Outdent();
// writer.WriteLine("}");
// writer.WriteLine("input.PopLimit(oldLimit);");
//}
}
public void GenerateSerializationCode(TextGenerator writer)
......
......@@ -34,6 +34,7 @@
#endregion
using System;
using Google.ProtocolBuffers.Descriptors;
namespace Google.ProtocolBuffers.ProtoGen
......@@ -121,16 +122,18 @@ namespace Google.ProtocolBuffers.ProtoGen
public void GenerateParsingCode(TextGenerator writer)
{
writer.WriteLine("{0}.Builder subBuilder = {0}.CreateBuilder();", TypeName);
if (Descriptor.FieldType == FieldType.Group)
{
writer.WriteLine("input.ReadGroup({0}, subBuilder, extensionRegistry);", Number);
}
else
{
writer.WriteLine("input.ReadMessage(subBuilder, extensionRegistry);");
}
writer.WriteLine("Add{0}(subBuilder.BuildPartial());", PropertyName);
writer.WriteLine("input.Read{0}Array(tag, field_name, result.{1}_, {2}.DefaultInstance, extensionRegistry);", MessageOrGroup, Name, TypeName);
//writer.WriteLine("{0}.Builder subBuilder = {0}.CreateBuilder();", TypeName);
//if (Descriptor.FieldType == FieldType.Group)
//{
// writer.WriteLine("input.ReadGroup({0}, subBuilder, extensionRegistry);", Number);
//}
//else
//{
// writer.WriteLine("input.ReadMessage(subBuilder, extensionRegistry);");
//}
//writer.WriteLine("Add{0}(subBuilder.BuildPartial());", PropertyName);
}
public void GenerateSerializationCode(TextGenerator writer)
......
......@@ -121,19 +121,20 @@ namespace Google.ProtocolBuffers.ProtoGen
public void GenerateParsingCode(TextGenerator writer)
{
if (Descriptor.IsPacked)
{
writer.WriteLine("int length = input.ReadInt32();");
writer.WriteLine("int limit = input.PushLimit(length);");
writer.WriteLine("while (!input.ReachedLimit) {");
writer.WriteLine(" Add{0}(input.Read{1}());", PropertyName, CapitalizedTypeName);
writer.WriteLine("}");
writer.WriteLine("input.PopLimit(limit);");
}
else
{
writer.WriteLine("Add{0}(input.Read{1}());", PropertyName, CapitalizedTypeName);
}
writer.WriteLine("input.ReadPrimitiveArray(pbd::FieldType.{1}, tag, field_name, result.{0}_);", Name, Descriptor.FieldType);
//if (Descriptor.IsPacked)
//{
// writer.WriteLine("int length = input.ReadInt32();");
// writer.WriteLine("int limit = input.PushLimit(length);");
// writer.WriteLine("while (!input.ReachedLimit) {");
// writer.WriteLine(" Add{0}(input.Read{1}());", PropertyName, CapitalizedTypeName);
// writer.WriteLine("}");
// writer.WriteLine("input.PopLimit(limit);");
//}
//else
//{
// writer.WriteLine("Add{0}(input.Read{1}());", PropertyName, CapitalizedTypeName);
//}
}
public void GenerateSerializationCode(TextGenerator writer)
......
......@@ -362,7 +362,8 @@ namespace Google.ProtocolBuffers
try
{
input.ReadBytes();
ByteString bytes = null;
input.ReadBytes(ref bytes);
Assert.Fail("Should have thrown an exception!");
}
catch (InvalidProtocolBufferException)
......@@ -506,7 +507,8 @@ namespace Google.ProtocolBuffers
Assert.IsTrue(input.ReadTag(out testtag, out ignored));
Assert.AreEqual(tag, testtag);
string text = input.ReadString();
string text = null;
input.ReadString(ref text);
Assert.AreEqual('\ufffd', text[0]);
}
......
......@@ -276,19 +276,19 @@ namespace Google.ProtocolBuffers.TestProtos {
if (unknownFields == null) {
unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
}
ParseUnknownField(input, unknownFields, extensionRegistry, tag);
ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
break;
}
case 10: {
Normal = input.ReadString();
result.hasNormal |= input.ReadString(ref result.normal_);
break;
}
case 18: {
OptionsMessage_ = input.ReadString();
result.hasOptionsMessage_ |= input.ReadString(ref result.optionsMessage_);
break;
}
case 26: {
CustomName = input.ReadString();
result.hasCustomName |= input.ReadString(ref result.customized_);
break;
}
}
......
......@@ -593,11 +593,11 @@ namespace Google.ProtocolBuffers.TestProtos {
if (unknownFields == null) {
unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
}
ParseUnknownField(input, unknownFields, extensionRegistry, tag);
ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
break;
}
case 10: {
Field1 = input.ReadString();
result.hasField1 |= input.ReadString(ref result.field1_);
break;
}
}
......@@ -799,7 +799,7 @@ namespace Google.ProtocolBuffers.TestProtos {
if (unknownFields == null) {
unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
}
ParseUnknownField(input, unknownFields, extensionRegistry, tag);
ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
break;
}
}
......@@ -982,7 +982,7 @@ namespace Google.ProtocolBuffers.TestProtos {
if (unknownFields == null) {
unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
}
ParseUnknownField(input, unknownFields, extensionRegistry, tag);
ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
break;
}
}
......@@ -1180,7 +1180,7 @@ namespace Google.ProtocolBuffers.TestProtos {
if (unknownFields == null) {
unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
}
ParseUnknownField(input, unknownFields, extensionRegistry, tag);
ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
break;
}
}
......@@ -1363,7 +1363,7 @@ namespace Google.ProtocolBuffers.TestProtos {
if (unknownFields == null) {
unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
}
ParseUnknownField(input, unknownFields, extensionRegistry, tag);
ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
break;
}
}
......@@ -1546,7 +1546,7 @@ namespace Google.ProtocolBuffers.TestProtos {
if (unknownFields == null) {
unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
}
ParseUnknownField(input, unknownFields, extensionRegistry, tag);
ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
break;
}
}
......@@ -1729,7 +1729,7 @@ namespace Google.ProtocolBuffers.TestProtos {
if (unknownFields == null) {
unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
}
ParseUnknownField(input, unknownFields, extensionRegistry, tag);
ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
break;
}
}
......@@ -1912,7 +1912,7 @@ namespace Google.ProtocolBuffers.TestProtos {
if (unknownFields == null) {
unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
}
ParseUnknownField(input, unknownFields, extensionRegistry, tag);
ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
break;
}
}
......@@ -2095,7 +2095,7 @@ namespace Google.ProtocolBuffers.TestProtos {
if (unknownFields == null) {
unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
}
ParseUnknownField(input, unknownFields, extensionRegistry, tag);
ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
break;
}
}
......@@ -2278,7 +2278,7 @@ namespace Google.ProtocolBuffers.TestProtos {
if (unknownFields == null) {
unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
}
ParseUnknownField(input, unknownFields, extensionRegistry, tag);
ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
break;
}
}
......@@ -2523,19 +2523,19 @@ namespace Google.ProtocolBuffers.TestProtos {
if (unknownFields == null) {
unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
}
ParseUnknownField(input, unknownFields, extensionRegistry, tag);
ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
break;
}
case 8: {
Foo = input.ReadInt32();
result.hasFoo |= input.ReadInt32(ref result.foo_);
break;
}
case 16: {
Foo2 = input.ReadInt32();
result.hasFoo2 |= input.ReadInt32(ref result.foo2_);
break;
}
case 24: {
Foo3 = input.ReadInt32();
result.hasFoo3 |= input.ReadInt32(ref result.foo3_);
break;
}
}
......@@ -2823,11 +2823,11 @@ namespace Google.ProtocolBuffers.TestProtos {
if (unknownFields == null) {
unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
}
ParseUnknownField(input, unknownFields, extensionRegistry, tag);
ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
break;
}
case 8: {
Waldo = input.ReadInt32();
result.hasWaldo |= input.ReadInt32(ref result.waldo_);
break;
}
}
......@@ -3071,7 +3071,7 @@ namespace Google.ProtocolBuffers.TestProtos {
if (unknownFields == null) {
unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
}
ParseUnknownField(input, unknownFields, extensionRegistry, tag);
ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
break;
}
case 10: {
......@@ -3084,7 +3084,7 @@ namespace Google.ProtocolBuffers.TestProtos {
break;
}
case 16: {
Baz = input.ReadInt32();
result.hasBaz |= input.ReadInt32(ref result.baz_);
break;
}
case 26: {
......@@ -3415,11 +3415,11 @@ namespace Google.ProtocolBuffers.TestProtos {
if (unknownFields == null) {
unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
}
ParseUnknownField(input, unknownFields, extensionRegistry, tag);
ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
break;
}
case 24: {
Plugh = input.ReadInt32();
result.hasPlugh |= input.ReadInt32(ref result.plugh_);
break;
}
}
......@@ -3636,11 +3636,11 @@ namespace Google.ProtocolBuffers.TestProtos {
if (unknownFields == null) {
unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
}
ParseUnknownField(input, unknownFields, extensionRegistry, tag);
ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
break;
}
case 8: {
Qux = input.ReadInt32();
result.hasQux |= input.ReadInt32(ref result.qux_);
break;
}
case 19: {
......@@ -3905,11 +3905,11 @@ namespace Google.ProtocolBuffers.TestProtos {
if (unknownFields == null) {
unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
}
ParseUnknownField(input, unknownFields, extensionRegistry, tag);
ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
break;
}
case 60751608: {
Xyzzy = input.ReadInt32();
result.hasXyzzy |= input.ReadInt32(ref result.xyzzy_);
break;
}
}
......@@ -4110,7 +4110,7 @@ namespace Google.ProtocolBuffers.TestProtos {
if (unknownFields == null) {
unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
}
ParseUnknownField(input, unknownFields, extensionRegistry, tag);
ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
break;
}
}
......
......@@ -270,7 +270,7 @@ namespace Google.ProtocolBuffers.TestProtos {
if (unknownFields == null) {
unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
}
ParseUnknownField(input, unknownFields, extensionRegistry, tag);
ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
break;
}
case 10: {
......@@ -283,9 +283,7 @@ namespace Google.ProtocolBuffers.TestProtos {
break;
}
case 18: {
global::Google.ProtocolBuffers.TestProtos.TestOptimizedForSize.Builder subBuilder = global::Google.ProtocolBuffers.TestProtos.TestOptimizedForSize.CreateBuilder();
input.ReadMessage(subBuilder, extensionRegistry);
AddRepeatedMessage(subBuilder.BuildPartial());
input.ReadMessageArray(tag, field_name, result.repeatedMessage_, global::Google.ProtocolBuffers.TestProtos.TestOptimizedForSize.DefaultInstance, extensionRegistry);
break;
}
}
......
......@@ -218,11 +218,11 @@ namespace Google.ProtocolBuffers.TestProtos {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return this;
}
ParseUnknownField(input, extensionRegistry, tag);
ParseUnknownField(input, extensionRegistry, tag, field_name);
break;
}
case 8: {
D = input.ReadInt32();
result.hasD |= input.ReadInt32(ref result.d_);
break;
}
}
......
......@@ -249,11 +249,11 @@ namespace Google.ProtocolBuffers.TestProtos {
if (unknownFields == null) {
unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
}
ParseUnknownField(input, unknownFields, extensionRegistry, tag);
ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
break;
}
case 8: {
D = input.ReadInt32();
result.hasD |= input.ReadInt32(ref result.d_);
break;
}
}
......
......@@ -267,7 +267,7 @@ namespace Google.ProtocolBuffers.TestProtos {
if (unknownFields == null) {
unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
}
ParseUnknownField(input, unknownFields, extensionRegistry, tag);
ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
break;
}
}
......@@ -469,7 +469,7 @@ namespace Google.ProtocolBuffers.TestProtos {
if (unknownFields == null) {
unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
}
ParseUnknownField(input, unknownFields, extensionRegistry, tag);
ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
break;
}
case 10: {
......@@ -718,11 +718,11 @@ namespace Google.ProtocolBuffers.TestProtos {
if (unknownFields == null) {
unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
}
ParseUnknownField(input, unknownFields, extensionRegistry, tag);
ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
break;
}
case 120: {
I = input.ReadInt32();
result.hasI |= input.ReadInt32(ref result.i_);
break;
}
}
......@@ -944,11 +944,11 @@ namespace Google.ProtocolBuffers.TestProtos {
if (unknownFields == null) {
unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
}
ParseUnknownField(input, unknownFields, extensionRegistry, tag);
ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
break;
}
case 202: {
Str = input.ReadString();
result.hasStr |= input.ReadString(ref result.str_);
break;
}
}
......@@ -1220,15 +1220,15 @@ namespace Google.ProtocolBuffers.TestProtos {
if (unknownFields == null) {
unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
}
ParseUnknownField(input, unknownFields, extensionRegistry, tag);
ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
break;
}
case 16: {
TypeId = input.ReadInt32();
result.hasTypeId |= input.ReadInt32(ref result.typeId_);
break;
}
case 26: {
Message = input.ReadBytes();
result.hasMessage |= input.ReadBytes(ref result.message_);
break;
}
}
......@@ -1448,13 +1448,11 @@ namespace Google.ProtocolBuffers.TestProtos {
if (unknownFields == null) {
unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
}
ParseUnknownField(input, unknownFields, extensionRegistry, tag);
ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
break;
}
case 11: {
global::Google.ProtocolBuffers.TestProtos.RawMessageSet.Types.Item.Builder subBuilder = global::Google.ProtocolBuffers.TestProtos.RawMessageSet.Types.Item.CreateBuilder();
input.ReadGroup(1, subBuilder, extensionRegistry);
AddItem(subBuilder.BuildPartial());
input.ReadGroupArray(tag, field_name, result.item_, global::Google.ProtocolBuffers.TestProtos.RawMessageSet.Types.Item.DefaultInstance, extensionRegistry);
break;
}
}
......
......@@ -264,11 +264,11 @@ namespace Google.ProtocolBuffers.TestProtos.NoGenericService {
if (unknownFields == null) {
unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
}
ParseUnknownField(input, unknownFields, extensionRegistry, tag);
ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
break;
}
case 8: {
A = input.ReadInt32();
result.hasA |= input.ReadInt32(ref result.a_);
break;
}
}
......
......@@ -269,11 +269,11 @@ namespace Google.ProtocolBuffers.TestProtos {
if (unknownFields == null) {
unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
}
ParseUnknownField(input, unknownFields, extensionRegistry, tag);
ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
break;
}
case 10: {
AddCriteria(input.ReadString());
input.ReadPrimitiveArray(pbd::FieldType.String, tag, field_name, result.criteria_);
break;
}
}
......@@ -553,15 +553,15 @@ namespace Google.ProtocolBuffers.TestProtos {
if (unknownFields == null) {
unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
}
ParseUnknownField(input, unknownFields, extensionRegistry, tag);
ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
break;
}
case 10: {
Url = input.ReadString();
result.hasUrl |= input.ReadString(ref result.url_);
break;
}
case 18: {
Name = input.ReadString();
result.hasName |= input.ReadString(ref result.name_);
break;
}
}
......@@ -785,13 +785,11 @@ namespace Google.ProtocolBuffers.TestProtos {
if (unknownFields == null) {
unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
}
ParseUnknownField(input, unknownFields, extensionRegistry, tag);
ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
break;
}
case 10: {
global::Google.ProtocolBuffers.TestProtos.SearchResponse.Types.ResultItem.Builder subBuilder = global::Google.ProtocolBuffers.TestProtos.SearchResponse.Types.ResultItem.CreateBuilder();
input.ReadMessage(subBuilder, extensionRegistry);
AddResults(subBuilder.BuildPartial());
input.ReadMessageArray(tag, field_name, result.results_, global::Google.ProtocolBuffers.TestProtos.SearchResponse.Types.ResultItem.DefaultInstance, extensionRegistry);
break;
}
}
......@@ -1060,11 +1058,11 @@ namespace Google.ProtocolBuffers.TestProtos {
if (unknownFields == null) {
unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
}
ParseUnknownField(input, unknownFields, extensionRegistry, tag);
ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
break;
}
case 10: {
AddCriteria(input.ReadString());
input.ReadPrimitiveArray(pbd::FieldType.String, tag, field_name, result.criteria_);
break;
}
case 18: {
......
......@@ -337,23 +337,24 @@ namespace Google.ProtocolBuffers.TestProtos {
if (unknownFields == null) {
unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
}
ParseUnknownField(input, unknownFields, extensionRegistry, tag);
ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
break;
}
case 24: {
int rawValue = input.ReadEnum();
if (!global::System.Enum.IsDefined(typeof(global::Google.ProtocolBuffers.TestProtos.EnumOptions), rawValue)) {
scg::ICollection<object> unknownItems;
input.ReadEnumArray<global::Google.ProtocolBuffers.TestProtos.EnumOptions>(tag, field_name, result.options_, out unknownItems);
if (unknownItems != null) {
if (unknownFields == null) {
unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
}
unknownFields.MergeVarintField(3, (ulong) rawValue);
} else {
AddOptions((global::Google.ProtocolBuffers.TestProtos.EnumOptions) rawValue);
foreach (object rawValue in unknownItems)
if (rawValue is int)
unknownFields.MergeVarintField(3, (ulong)(int)rawValue);
}
break;
}
case 34: {
Binary = input.ReadBytes();
result.hasBinary |= input.ReadBytes(ref result.binary_);
break;
}
}
......@@ -581,7 +582,7 @@ namespace Google.ProtocolBuffers.TestProtos {
if (unknownFields == null) {
unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
}
ParseUnknownField(input, unknownFields, extensionRegistry, tag);
ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
break;
}
}
......@@ -842,23 +843,24 @@ namespace Google.ProtocolBuffers.TestProtos {
if (unknownFields == null) {
unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
}
ParseUnknownField(input, unknownFields, extensionRegistry, tag);
ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
break;
}
case 24: {
int rawValue = input.ReadEnum();
if (!global::System.Enum.IsDefined(typeof(global::Google.ProtocolBuffers.TestProtos.EnumOptions), rawValue)) {
scg::ICollection<object> unknownItems;
input.ReadEnumArray<global::Google.ProtocolBuffers.TestProtos.EnumOptions>(tag, field_name, result.options_, out unknownItems);
if (unknownItems != null) {
if (unknownFields == null) {
unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
}
unknownFields.MergeVarintField(3, (ulong) rawValue);
} else {
AddOptions((global::Google.ProtocolBuffers.TestProtos.EnumOptions) rawValue);
foreach (object rawValue in unknownItems)
if (rawValue is int)
unknownFields.MergeVarintField(3, (ulong)(int)rawValue);
}
break;
}
case 34: {
Binary = input.ReadBytes();
result.hasBinary |= input.ReadBytes(ref result.binary_);
break;
}
}
......@@ -1221,7 +1223,7 @@ namespace Google.ProtocolBuffers.TestProtos {
if (unknownFields == null) {
unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
}
ParseUnknownField(input, unknownFields, extensionRegistry, tag);
ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
break;
}
case 10: {
......@@ -1234,29 +1236,27 @@ namespace Google.ProtocolBuffers.TestProtos {
break;
}
case 16: {
AddNumbers(input.ReadInt32());
input.ReadPrimitiveArray(pbd::FieldType.Int32, tag, field_name, result.numbers_);
break;
}
case 26: {
Text = input.ReadString();
result.hasText |= input.ReadString(ref result.text_);
break;
}
case 40: {
Valid = input.ReadBool();
result.hasValid |= input.ReadBool(ref result.valid_);
break;
}
case 48: {
Number = input.ReadInt64();
result.hasNumber |= input.ReadInt64(ref result.number_);
break;
}
case 3211: {
global::Google.ProtocolBuffers.TestProtos.TestXmlMessage.Types.Children.Builder subBuilder = global::Google.ProtocolBuffers.TestProtos.TestXmlMessage.Types.Children.CreateBuilder();
input.ReadGroup(401, subBuilder, extensionRegistry);
AddChildren(subBuilder.BuildPartial());
input.ReadGroupArray(tag, field_name, result.children_, global::Google.ProtocolBuffers.TestProtos.TestXmlMessage.Types.Children.DefaultInstance, extensionRegistry);
break;
}
case 5602: {
AddTextlines(input.ReadString());
input.ReadPrimitiveArray(pbd::FieldType.String, tag, field_name, result.textlines_);
break;
}
}
......@@ -1642,11 +1642,11 @@ namespace Google.ProtocolBuffers.TestProtos {
if (unknownFields == null) {
unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
}
ParseUnknownField(input, unknownFields, extensionRegistry, tag);
ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
break;
}
case 8: {
Number = input.ReadInt32();
result.hasNumber |= input.ReadInt32(ref result.number_);
break;
}
}
......
This diff is collapsed.
......@@ -531,66 +531,66 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
if (unknownFields == null) {
unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
}
ParseUnknownField(input, unknownFields, extensionRegistry, tag);
ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
break;
}
case 10: {
Namespace = input.ReadString();
result.hasNamespace |= input.ReadString(ref result.namespace_);
break;
}
case 18: {
UmbrellaClassname = input.ReadString();
result.hasUmbrellaClassname |= input.ReadString(ref result.umbrellaClassname_);
break;
}
case 24: {
PublicClasses = input.ReadBool();
result.hasPublicClasses |= input.ReadBool(ref result.publicClasses_);
break;
}
case 32: {
MultipleFiles = input.ReadBool();
result.hasMultipleFiles |= input.ReadBool(ref result.multipleFiles_);
break;
}
case 40: {
NestClasses = input.ReadBool();
result.hasNestClasses |= input.ReadBool(ref result.nestClasses_);
break;
}
case 48: {
CodeContracts = input.ReadBool();
result.hasCodeContracts |= input.ReadBool(ref result.codeContracts_);
break;
}
case 56: {
ExpandNamespaceDirectories = input.ReadBool();
result.hasExpandNamespaceDirectories |= input.ReadBool(ref result.expandNamespaceDirectories_);
break;
}
case 64: {
ClsCompliance = input.ReadBool();
result.hasClsCompliance |= input.ReadBool(ref result.clsCompliance_);
break;
}
case 1770: {
FileExtension = input.ReadString();
result.hasFileExtension |= input.ReadString(ref result.fileExtension_);
break;
}
case 1778: {
UmbrellaNamespace = input.ReadString();
result.hasUmbrellaNamespace |= input.ReadString(ref result.umbrellaNamespace_);
break;
}
case 1786: {
OutputDirectory = input.ReadString();
result.hasOutputDirectory |= input.ReadString(ref result.outputDirectory_);
break;
}
case 1792: {
IgnoreGoogleProtobuf = input.ReadBool();
result.hasIgnoreGoogleProtobuf |= input.ReadBool(ref result.ignoreGoogleProtobuf_);
break;
}
case 1800: {
int rawValue = input.ReadEnum();
if (!global::System.Enum.IsDefined(typeof(global::Google.ProtocolBuffers.DescriptorProtos.CSharpServiceType), rawValue)) {
object unknown;
if(input.ReadEnum(ref result.serviceGeneratorType_, out unknown)) {
result.hasServiceGeneratorType = true;
} else if(unknown is int) {
if (unknownFields == null) {
unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
}
unknownFields.MergeVarintField(225, (ulong) rawValue);
} else {
ServiceGeneratorType = (global::Google.ProtocolBuffers.DescriptorProtos.CSharpServiceType) rawValue;
unknownFields.MergeVarintField(225, (ulong)(int)unknown);
}
break;
}
......@@ -1032,11 +1032,11 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
if (unknownFields == null) {
unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
}
ParseUnknownField(input, unknownFields, extensionRegistry, tag);
ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
break;
}
case 10: {
PropertyName = input.ReadString();
result.hasPropertyName |= input.ReadString(ref result.propertyName_);
break;
}
}
......@@ -1257,11 +1257,11 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
if (unknownFields == null) {
unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
}
ParseUnknownField(input, unknownFields, extensionRegistry, tag);
ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
break;
}
case 10: {
InterfaceId = input.ReadString();
result.hasInterfaceId |= input.ReadString(ref result.interfaceId_);
break;
}
}
......@@ -1482,11 +1482,11 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
if (unknownFields == null) {
unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
}
ParseUnknownField(input, unknownFields, extensionRegistry, tag);
ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
break;
}
case 8: {
DispatchId = input.ReadInt32();
result.hasDispatchId |= input.ReadInt32(ref result.dispatchId_);
break;
}
}
......
......@@ -98,6 +98,10 @@ namespace Google.ProtocolBuffers.Descriptors
{
return FindValueByNumber(number);
}
IEnumLite IEnumLiteMap.FindValueByName(string name)
{
return FindValueByName(name);
}
/// <summary>
/// Finds an enum value by name.
......
......@@ -70,6 +70,7 @@ namespace Google.ProtocolBuffers
{
bool IsValidValue(IEnumLite value);
IEnumLite FindValueByNumber(int number);
IEnumLite FindValueByName(string name);
}
public class EnumLiteMap<TEnum> : IEnumLiteMap<IEnumLite>
......@@ -125,6 +126,14 @@ namespace Google.ProtocolBuffers
return items.TryGetValue(number, out val) ? val : null;
}
public IEnumLite FindValueByName(string name)
{
IEnumLite val;
if(Enum.IsDefined(typeof(TEnum), name))
return items.TryGetValue((int)Enum.Parse(typeof(TEnum), name, false), out val) ? val : null;
return null;
}
public bool IsValidValue(IEnumLite value)
{
return items.ContainsKey(value.Number);
......
......@@ -131,9 +131,9 @@ namespace Google.ProtocolBuffers
/// <returns>true unless the tag is an end-group tag</returns>
[CLSCompliant(false)]
protected override bool ParseUnknownField(CodedInputStream input, UnknownFieldSet.Builder unknownFields,
ExtensionRegistry extensionRegistry, uint tag)
ExtensionRegistry extensionRegistry, uint tag, string fieldName)
{
return unknownFields.MergeFieldFrom(input, extensionRegistry, this, tag);
return unknownFields.MergeFieldFrom(input, extensionRegistry, this, tag, fieldName);
}
// ---------------------------------------------------------------
......
......@@ -134,7 +134,7 @@ namespace Google.ProtocolBuffers
/// <returns>true unless the tag is an end-group tag</returns>
[CLSCompliant(false)]
protected override bool ParseUnknownField(CodedInputStream input,
ExtensionRegistry extensionRegistry, uint tag)
ExtensionRegistry extensionRegistry, uint tag, string fieldName)
{
FieldSet extensions = MessageBeingBuilt.Extensions;
......@@ -142,119 +142,81 @@ namespace Google.ProtocolBuffers
int fieldNumber = WireFormat.GetTagFieldNumber(tag);
IGeneratedExtensionLite extension = extensionRegistry[DefaultInstanceForType, fieldNumber];
bool unknown = false;
bool packed = false;
if (extension == null)
{
unknown = true; // Unknown field.
}
else if (wireType ==
FieldMappingAttribute.WireTypeFromFieldType(extension.Descriptor.FieldType, false /* isPacked */))
{
packed = false; // Normal, unpacked value.
}
else if (extension.Descriptor.IsRepeated &&
//?? just returns true ?? extension.Descriptor.type.isPackable() &&
wireType ==
FieldMappingAttribute.WireTypeFromFieldType(extension.Descriptor.FieldType, true /* isPacked */))
{
packed = true; // Packed value.
}
else
{
unknown = true; // Wrong wire type.
}
if (extension == null)//unknown field
return input.SkipField();
if (unknown)
{
// Unknown field or wrong wire type. Skip.
IFieldDescriptorLite field = extension.Descriptor;
if (!field.IsRepeated && wireType != WireFormat.GetWireType(field.FieldType)) //invalid wire type
return input.SkipField();
}
if (packed)
switch (field.FieldType)
{
int length = (int) Math.Min(int.MaxValue, input.ReadRawVarint32());
int limit = input.PushLimit(length);
if (extension.Descriptor.FieldType == FieldType.Enum)
{
while (!input.ReachedLimit)
case FieldType.Group:
case FieldType.Message:
{
int rawValue = input.ReadEnum();
Object value =
extension.Descriptor.EnumType.FindValueByNumber(rawValue);
if (value == null)
if (!field.IsRepeated)
{
IMessageLite message = extensions[extension.Descriptor] as IMessageLite;
IBuilderLite subBuilder = (message ?? extension.MessageDefaultInstance).WeakToBuilder();
if (field.FieldType == FieldType.Group)
input.ReadGroup(field.FieldNumber, subBuilder, extensionRegistry);
else
input.ReadMessage(subBuilder, extensionRegistry);
extensions[field] = subBuilder.WeakBuild();
}
else
{
// If the number isn't recognized as a valid value for this
// enum, drop it (don't even add it to unknownFields).
List<IMessageLite> list = new List<IMessageLite>();
if (field.FieldType == FieldType.Group)
input.ReadGroupArray(tag, fieldName, list, extension.MessageDefaultInstance, extensionRegistry);
else
input.ReadMessageArray(tag, fieldName, list, extension.MessageDefaultInstance, extensionRegistry);
foreach (IMessageLite m in list)
extensions.AddRepeatedField(field, m);
return true;
}
extensions.AddRepeatedField(extension.Descriptor, value);
break;
}
}
else
{
while (!input.ReachedLimit)
case FieldType.Enum:
{
Object value = input.ReadPrimitiveField(extension.Descriptor.FieldType);
extensions.AddRepeatedField(extension.Descriptor, value);
}
}
input.PopLimit(limit);
}
else
{
Object value;
switch (extension.Descriptor.MappedType)
{
case MappedType.Message:
if (!field.IsRepeated)
{
IBuilderLite subBuilder = null;
if (!extension.Descriptor.IsRepeated)
{
IMessageLite existingValue = extensions[extension.Descriptor] as IMessageLite;
if (existingValue != null)
{
subBuilder = existingValue.WeakToBuilder();
}
}
if (subBuilder == null)
{
subBuilder = extension.MessageDefaultInstance.WeakCreateBuilderForType();
}
if (extension.Descriptor.FieldType == FieldType.Group)
{
input.ReadGroup(extension.Number, subBuilder, extensionRegistry);
}
else
{
input.ReadMessage(subBuilder, extensionRegistry);
}
value = subBuilder.WeakBuild();
break;
object unknown;
IEnumLite value = null;
if (input.ReadEnum(ref value, out unknown, field.EnumType))
extensions[field] = value;
}
case MappedType.Enum:
int rawValue = input.ReadEnum();
value = extension.Descriptor.EnumType.FindValueByNumber(rawValue);
// If the number isn't recognized as a valid value for this enum,
// drop it.
if (value == null)
else
{
return true;
ICollection<object> unknown;
List<IEnumLite> list = new List<IEnumLite>();
input.ReadEnumArray(tag, fieldName, list, out unknown, field.EnumType);
foreach (IEnumLite en in list)
extensions.AddRepeatedField(field, en);
}
break;
default:
value = input.ReadPrimitiveField(extension.Descriptor.FieldType);
}
default:
{
if (!field.IsRepeated)
{
object value = null;
if (input.ReadPrimitiveField(field.FieldType, ref value))
extensions[field] = value;
}
else
{
List<object> list = new List<object>();
input.ReadPrimitiveArray(field.FieldType, tag, fieldName, list);
foreach (object oval in list)
extensions.AddRepeatedField(field, oval);
}
break;
}
if (extension.Descriptor.IsRepeated)
{
extensions.AddRepeatedField(extension.Descriptor, value);
}
else
{
extensions[extension.Descriptor] = value;
}
}
}
return true;
......
......@@ -116,7 +116,7 @@ namespace Google.ProtocolBuffers
/// <returns>true unless the tag is an end-group tag</returns>
[CLSCompliant(false)]
protected virtual bool ParseUnknownField(CodedInputStream input, UnknownFieldSet.Builder unknownFields,
ExtensionRegistry extensionRegistry, uint tag)
ExtensionRegistry extensionRegistry, uint tag, string fieldName)
{
return unknownFields.MergeFieldFrom(tag, input);
}
......
......@@ -99,7 +99,7 @@ namespace Google.ProtocolBuffers
/// <returns>true unless the tag is an end-group tag</returns>
[CLSCompliant(false)]
protected virtual bool ParseUnknownField(CodedInputStream input,
ExtensionRegistry extensionRegistry, uint tag)
ExtensionRegistry extensionRegistry, uint tag, string fieldName)
{
return input.SkipField();
}
......
This diff is collapsed.
......@@ -258,18 +258,18 @@ namespace Google.ProtocolBuffers.TestProtos {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return this;
}
ParseUnknownField(input, extensionRegistry, tag);
ParseUnknownField(input, extensionRegistry, tag, field_name);
break;
}
case 8: {
D = input.ReadInt32();
result.hasD |= input.ReadInt32(ref result.d_);
break;
}
case 16: {
int rawValue = input.ReadEnum();
if (!global::System.Enum.IsDefined(typeof(global::Google.ProtocolBuffers.TestProtos.ExtraEnum), rawValue)) {
} else {
En = (global::Google.ProtocolBuffers.TestProtos.ExtraEnum) rawValue;
object unknown;
if(input.ReadEnum(ref result.en_, out unknown)) {
result.hasEn = true;
} else if(unknown is int) {
}
break;
}
......@@ -555,18 +555,18 @@ namespace Google.ProtocolBuffers.TestProtos {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return this;
}
ParseUnknownField(input, extensionRegistry, tag);
ParseUnknownField(input, extensionRegistry, tag, field_name);
break;
}
case 10: {
Number = input.ReadString();
result.hasNumber |= input.ReadString(ref result.number_);
break;
}
case 16: {
int rawValue = input.ReadEnum();
if (!global::System.Enum.IsDefined(typeof(global::Google.ProtocolBuffers.TestProtos.TestInteropPersonLite.Types.PhoneType), rawValue)) {
} else {
Type = (global::Google.ProtocolBuffers.TestProtos.TestInteropPersonLite.Types.PhoneType) rawValue;
object unknown;
if(input.ReadEnum(ref result.type_, out unknown)) {
result.hasType = true;
} else if(unknown is int) {
}
break;
}
......@@ -893,27 +893,27 @@ namespace Google.ProtocolBuffers.TestProtos {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return this;
}
ParseUnknownField(input, extensionRegistry, tag);
ParseUnknownField(input, extensionRegistry, tag, field_name);
break;
}
case 10: {
Address = input.ReadString();
result.hasAddress |= input.ReadString(ref result.address_);
break;
}
case 18: {
Address2 = input.ReadString();
result.hasAddress2 |= input.ReadString(ref result.address2_);
break;
}
case 26: {
City = input.ReadString();
result.hasCity |= input.ReadString(ref result.city_);
break;
}
case 34: {
State = input.ReadString();
result.hasState |= input.ReadString(ref result.state_);
break;
}
case 45: {
Zip = input.ReadFixed32();
result.hasZip |= input.ReadFixed32(ref result.zip_);
break;
}
}
......@@ -1341,40 +1341,31 @@ namespace Google.ProtocolBuffers.TestProtos {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return this;
}
ParseUnknownField(input, extensionRegistry, tag);
ParseUnknownField(input, extensionRegistry, tag, field_name);
break;
}
case 10: {
Name = input.ReadString();
result.hasName |= input.ReadString(ref result.name_);
break;
}
case 16: {
Id = input.ReadInt32();
result.hasId |= input.ReadInt32(ref result.id_);
break;
}
case 26: {
Email = input.ReadString();
result.hasEmail |= input.ReadString(ref result.email_);
break;
}
case 34: {
global::Google.ProtocolBuffers.TestProtos.TestInteropPersonLite.Types.PhoneNumber.Builder subBuilder = global::Google.ProtocolBuffers.TestProtos.TestInteropPersonLite.Types.PhoneNumber.CreateBuilder();
input.ReadMessage(subBuilder, extensionRegistry);
AddPhone(subBuilder.BuildPartial());
input.ReadMessageArray(tag, field_name, result.phone_, global::Google.ProtocolBuffers.TestProtos.TestInteropPersonLite.Types.PhoneNumber.DefaultInstance, extensionRegistry);
break;
}
case 43: {
global::Google.ProtocolBuffers.TestProtos.TestInteropPersonLite.Types.Addresses.Builder subBuilder = global::Google.ProtocolBuffers.TestProtos.TestInteropPersonLite.Types.Addresses.CreateBuilder();
input.ReadGroup(5, subBuilder, extensionRegistry);
AddAddresses(subBuilder.BuildPartial());
input.ReadGroupArray(tag, field_name, result.addresses_, global::Google.ProtocolBuffers.TestProtos.TestInteropPersonLite.Types.Addresses.DefaultInstance, extensionRegistry);
break;
}
case 82: {
int length = input.ReadInt32();
int limit = input.PushLimit(length);
while (!input.ReachedLimit) {
AddCodes(input.ReadInt32());
}
input.PopLimit(limit);
input.ReadPrimitiveArray(pbd::FieldType.Int32, tag, field_name, result.codes_);
break;
}
}
......@@ -1729,11 +1720,11 @@ namespace Google.ProtocolBuffers.TestProtos {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return this;
}
ParseUnknownField(input, extensionRegistry, tag);
ParseUnknownField(input, extensionRegistry, tag, field_name);
break;
}
case 10: {
Number = input.ReadString();
result.hasNumber |= input.ReadString(ref result.number_);
break;
}
}
......
......@@ -218,11 +218,11 @@ namespace Google.ProtocolBuffers.TestProtos {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return this;
}
ParseUnknownField(input, extensionRegistry, tag);
ParseUnknownField(input, extensionRegistry, tag, field_name);
break;
}
case 8: {
D = input.ReadInt32();
result.hasD |= input.ReadInt32(ref result.d_);
break;
}
}
......
......@@ -249,11 +249,11 @@ namespace Google.ProtocolBuffers.TestProtos {
if (unknownFields == null) {
unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
}
ParseUnknownField(input, unknownFields, extensionRegistry, tag);
ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
break;
}
case 8: {
D = input.ReadInt32();
result.hasD |= input.ReadInt32(ref result.d_);
break;
}
}
......
......@@ -207,7 +207,7 @@ namespace Google.ProtocolBuffers.TestProtos {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return this;
}
ParseUnknownField(input, extensionRegistry, tag);
ParseUnknownField(input, extensionRegistry, tag, field_name);
break;
}
case 10: {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment