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