Commit 920b09a3 authored by csharptest's avatar csharptest Committed by rogerk

Finished adding find tag by name

parent aef072a4
......@@ -67,6 +67,8 @@ namespace Google.ProtocolBuffers.Examples.AddressBook {
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("ProtoGen", "2.3.0.277")]
public sealed partial class Person : pb::GeneratedMessage<Person, Person.Builder> {
private static readonly Person defaultInstance = new Builder().BuildPartial();
private static readonly string[] _personFieldNames = new string[] { "email", "id", "name", "phone" };
private static readonly uint[] _personFieldTags = new uint[] { 26, 16, 10, 34 };
public static Person DefaultInstance {
get { return defaultInstance; }
}
......@@ -105,6 +107,8 @@ namespace Google.ProtocolBuffers.Examples.AddressBook {
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("ProtoGen", "2.3.0.277")]
public sealed partial class PhoneNumber : pb::GeneratedMessage<PhoneNumber, PhoneNumber.Builder> {
private static readonly PhoneNumber defaultInstance = new Builder().BuildPartial();
private static readonly string[] _phoneNumberFieldNames = new string[] { "number", "type" };
private static readonly uint[] _phoneNumberFieldTags = new uint[] { 10, 16 };
public static PhoneNumber DefaultInstance {
get { return defaultInstance; }
}
......@@ -154,11 +158,12 @@ namespace Google.ProtocolBuffers.Examples.AddressBook {
public override void WriteTo(pb::ICodedOutputStream output) {
int size = SerializedSize;
string[] field_names = _phoneNumberFieldNames;
if (hasNumber) {
output.WriteString(1, "number", Number);
output.WriteString(1, field_names[0], Number);
}
if (hasType) {
output.WriteEnum(2, "type", (int) Type, Type.ToString());
output.WriteEnum(2, field_names[1], (int) Type, Type.ToString());
}
UnknownFields.WriteTo(output);
}
......@@ -290,6 +295,18 @@ namespace Google.ProtocolBuffers.Examples.AddressBook {
uint tag;
string field_name;
while (input.ReadTag(out tag, out field_name)) {
if(tag == 0 && field_name != null) {
int field_ordinal = global::System.Array.BinarySearch(_phoneNumberFieldNames, field_name, global::System.StringComparer.Ordinal);
if(field_ordinal >= 0)
tag = _phoneNumberFieldTags[field_ordinal];
else {
if (unknownFields == null) {
unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
}
ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
continue;
}
}
switch (tag) {
case 0: {
throw pb::InvalidProtocolBufferException.InvalidTag();
......@@ -308,7 +325,7 @@ namespace Google.ProtocolBuffers.Examples.AddressBook {
break;
}
case 10: {
result.hasNumber |= input.ReadString(ref result.number_);
result.hasNumber = input.ReadString(ref result.number_);
break;
}
case 16: {
......@@ -433,17 +450,18 @@ namespace Google.ProtocolBuffers.Examples.AddressBook {
public override void WriteTo(pb::ICodedOutputStream output) {
int size = SerializedSize;
string[] field_names = _personFieldNames;
if (hasName) {
output.WriteString(1, "name", Name);
output.WriteString(1, field_names[2], Name);
}
if (hasId) {
output.WriteInt32(2, "id", Id);
output.WriteInt32(2, field_names[1], Id);
}
if (hasEmail) {
output.WriteString(3, "email", Email);
output.WriteString(3, field_names[0], Email);
}
if (phone_.Count > 0) {
output.WriteArray(pbd::FieldType.Message, 4, "phone", phone_);
output.WriteArray(pbd::FieldType.Message, 4, field_names[3], phone_);
}
UnknownFields.WriteTo(output);
}
......@@ -588,6 +606,18 @@ namespace Google.ProtocolBuffers.Examples.AddressBook {
uint tag;
string field_name;
while (input.ReadTag(out tag, out field_name)) {
if(tag == 0 && field_name != null) {
int field_ordinal = global::System.Array.BinarySearch(_personFieldNames, field_name, global::System.StringComparer.Ordinal);
if(field_ordinal >= 0)
tag = _personFieldTags[field_ordinal];
else {
if (unknownFields == null) {
unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
}
ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
continue;
}
}
switch (tag) {
case 0: {
throw pb::InvalidProtocolBufferException.InvalidTag();
......@@ -606,15 +636,15 @@ namespace Google.ProtocolBuffers.Examples.AddressBook {
break;
}
case 10: {
result.hasName |= input.ReadString(ref result.name_);
result.hasName = input.ReadString(ref result.name_);
break;
}
case 16: {
result.hasId |= input.ReadInt32(ref result.id_);
result.hasId = input.ReadInt32(ref result.id_);
break;
}
case 26: {
result.hasEmail |= input.ReadString(ref result.email_);
result.hasEmail = input.ReadString(ref result.email_);
break;
}
case 34: {
......@@ -735,6 +765,8 @@ namespace Google.ProtocolBuffers.Examples.AddressBook {
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("ProtoGen", "2.3.0.277")]
public sealed partial class AddressBook : pb::GeneratedMessage<AddressBook, AddressBook.Builder> {
private static readonly AddressBook defaultInstance = new Builder().BuildPartial();
private static readonly string[] _addressBookFieldNames = new string[] { "person" };
private static readonly uint[] _addressBookFieldTags = new uint[] { 10 };
public static AddressBook DefaultInstance {
get { return defaultInstance; }
}
......@@ -778,8 +810,9 @@ namespace Google.ProtocolBuffers.Examples.AddressBook {
public override void WriteTo(pb::ICodedOutputStream output) {
int size = SerializedSize;
string[] field_names = _addressBookFieldNames;
if (person_.Count > 0) {
output.WriteArray(pbd::FieldType.Message, 1, "person", person_);
output.WriteArray(pbd::FieldType.Message, 1, field_names[0], person_);
}
UnknownFields.WriteTo(output);
}
......@@ -906,6 +939,18 @@ namespace Google.ProtocolBuffers.Examples.AddressBook {
uint tag;
string field_name;
while (input.ReadTag(out tag, out field_name)) {
if(tag == 0 && field_name != null) {
int field_ordinal = global::System.Array.BinarySearch(_addressBookFieldNames, field_name, global::System.StringComparer.Ordinal);
if(field_ordinal >= 0)
tag = _addressBookFieldTags[field_ordinal];
else {
if (unknownFields == null) {
unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
}
ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
continue;
}
}
switch (tag) {
case 0: {
throw pb::InvalidProtocolBufferException.InvalidTag();
......
......@@ -58,6 +58,7 @@ namespace Google.ProtocolBuffers.ProtoBench
private static BenchmarkTest RunBenchmark;
[STAThread]
public static int Main(string[] args)
{
List<string> temp = new List<string>(args);
......@@ -160,9 +161,6 @@ namespace Google.ProtocolBuffers.ProtoBench
long totalCount = 0;
double best = double.MinValue, worst = double.MaxValue;
ThreadStart threadProc =
delegate()
{
action();
// Run it progressively more times until we've got a reasonable sample
......@@ -204,14 +202,6 @@ namespace Google.ProtocolBuffers.ProtoBench
totalCount += iterations;
iterations = (int) ((target.Ticks*totalCount)/(double) elapsed.Ticks);
}
};
Thread work = new Thread(threadProc);
work.Name = "Worker";
work.Priority = ThreadPriority.Highest;
work.SetApartmentState(ApartmentState.STA);
work.Start();
work.Join();
Console.WriteLine("{0}: averages {1} per {2:f3}s for {3} runs; avg: {4:f3}mbps; best: {5:f3}mbps; worst: {6:f3}mbps",
name, totalCount / runs, elapsed.TotalSeconds / runs, runs,
......
......@@ -40,8 +40,8 @@ namespace Google.ProtocolBuffers.ProtoGen
{
internal class EnumFieldGenerator : FieldGeneratorBase, IFieldSourceGenerator
{
internal EnumFieldGenerator(FieldDescriptor descriptor)
: base(descriptor)
internal EnumFieldGenerator(FieldDescriptor descriptor, int fieldOrdinal)
: base(descriptor, fieldOrdinal)
{
}
......@@ -107,26 +107,12 @@ namespace Google.ProtocolBuffers.ProtoGen
writer.WriteLine(" unknownFields.MergeVarintField({0}, (ulong)(int)unknown);", Number);
}
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)
{
writer.WriteLine("if (has{0}) {{", PropertyName);
writer.WriteLine(" output.WriteEnum({0}, \"{2}\", (int) {1}, {1}.ToString());", Number, PropertyName, Descriptor.Name);
writer.WriteLine(" output.WriteEnum({0}, field_names[{2}], (int) {1}, {1}.ToString());", Number, PropertyName, FieldOrdinal);
writer.WriteLine("}");
}
......
......@@ -48,7 +48,7 @@ namespace Google.ProtocolBuffers.ProtoGen
private readonly string name;
internal ExtensionGenerator(FieldDescriptor descriptor)
: base(descriptor)
: base(descriptor, 0)
{
if (Descriptor.ExtensionScope != null)
{
......
......@@ -42,15 +42,20 @@ namespace Google.ProtocolBuffers.ProtoGen
{
internal abstract class FieldGeneratorBase : SourceGeneratorBase<FieldDescriptor>
{
protected FieldGeneratorBase(FieldDescriptor descriptor)
private readonly int _fieldOrdinal;
protected FieldGeneratorBase(FieldDescriptor descriptor, int fieldOrdinal)
: base(descriptor)
{
_fieldOrdinal = fieldOrdinal;
}
public abstract void WriteHash(TextGenerator writer);
public abstract void WriteEquals(TextGenerator writer);
public abstract void WriteToString(TextGenerator writer);
public int FieldOrdinal { get { return _fieldOrdinal; } }
private static bool AllPrintableAscii(string text)
{
foreach (char c in text)
......
......@@ -40,8 +40,8 @@ namespace Google.ProtocolBuffers.ProtoGen
{
internal class MessageFieldGenerator : FieldGeneratorBase, IFieldSourceGenerator
{
internal MessageFieldGenerator(FieldDescriptor descriptor)
: base(descriptor)
internal MessageFieldGenerator(FieldDescriptor descriptor, int fieldOrdinal)
: base(descriptor, fieldOrdinal)
{
}
......@@ -129,7 +129,7 @@ namespace Google.ProtocolBuffers.ProtoGen
public void GenerateSerializationCode(TextGenerator writer)
{
writer.WriteLine("if (has{0}) {{", PropertyName);
writer.WriteLine(" output.Write{0}({1}, \"{3}\", {2});", MessageOrGroup, Number, PropertyName, Descriptor.Name);
writer.WriteLine(" output.Write{0}({1}, field_names[{3}], {2});", MessageOrGroup, Number, PropertyName, FieldOrdinal);
writer.WriteLine("}");
}
......
This diff is collapsed.
......@@ -41,8 +41,8 @@ namespace Google.ProtocolBuffers.ProtoGen
// TODO(jonskeet): Refactor this. There's loads of common code here.
internal class PrimitiveFieldGenerator : FieldGeneratorBase, IFieldSourceGenerator
{
internal PrimitiveFieldGenerator(FieldDescriptor descriptor)
: base(descriptor)
internal PrimitiveFieldGenerator(FieldDescriptor descriptor, int fieldOrdinal)
: base(descriptor, fieldOrdinal)
{
}
......@@ -97,13 +97,13 @@ namespace Google.ProtocolBuffers.ProtoGen
public void GenerateParsingCode(TextGenerator writer)
{
writer.WriteLine("result.has{0} |= input.Read{1}(ref result.{2}_);", PropertyName, CapitalizedTypeName, Name);
writer.WriteLine("result.has{0} = input.Read{1}(ref result.{2}_);", PropertyName, CapitalizedTypeName, Name);
}
public void GenerateSerializationCode(TextGenerator writer)
{
writer.WriteLine("if (has{0}) {{", PropertyName);
writer.WriteLine(" output.Write{0}({1}, \"{3}\", {2});", CapitalizedTypeName, Number, PropertyName, Descriptor.Name);
writer.WriteLine(" output.Write{0}({1}, field_names[{3}], {2});", CapitalizedTypeName, Number, PropertyName, FieldOrdinal);
writer.WriteLine("}");
}
......
......@@ -56,10 +56,6 @@
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="Google.ProtocolBuffers, Version=2.3.0.277, Culture=neutral, PublicKeyToken=17b3b1f090c3ea48, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\build\2.3.0.304\Google.ProtocolBuffers.dll</HintPath>
</Reference>
<Reference Include="mscorlib" />
<Reference Include="System" />
<Reference Include="System.Data" />
......@@ -113,6 +109,12 @@
<Install>true</Install>
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ProtocolBuffers\ProtocolBuffers.csproj">
<Project>{6908BDCE-D925-43F3-94AC-A531E6DF2591}</Project>
<Name>ProtocolBuffers</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
......
......@@ -41,8 +41,8 @@ namespace Google.ProtocolBuffers.ProtoGen
{
internal class RepeatedEnumFieldGenerator : FieldGeneratorBase, IFieldSourceGenerator
{
internal RepeatedEnumFieldGenerator(FieldDescriptor descriptor)
: base(descriptor)
internal RepeatedEnumFieldGenerator(FieldDescriptor descriptor, int fieldOrdinal)
: base(descriptor, fieldOrdinal)
{
}
......@@ -125,37 +125,6 @@ namespace Google.ProtocolBuffers.ProtoGen
writer.WriteLine(" unknownFields.MergeVarintField({0}, (ulong)(int)rawValue);", Number);
writer.WriteLine("}");
}
//// 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)
......@@ -163,23 +132,9 @@ namespace Google.ProtocolBuffers.ProtoGen
writer.WriteLine("if ({0}_.Count > 0) {{", Name);
writer.Indent();
if (Descriptor.IsPacked)
writer.WriteLine("output.WritePackedArray(pbd::FieldType.{3}, {0}, \"{2}\", {1}MemoizedSerializedSize, {1}_);", Number, Name, Descriptor.Name, Descriptor.FieldType);
writer.WriteLine("output.WritePackedArray(pbd::FieldType.{3}, {0}, field_names[{2}], {1}MemoizedSerializedSize, {1}_);", Number, Name, FieldOrdinal, Descriptor.FieldType);
else
writer.WriteLine("output.WriteArray(pbd::FieldType.{3}, {0}, \"{2}\", {1}_);", Number, Name, Descriptor.Name, Descriptor.FieldType);
//if (Descriptor.IsPacked)
//{
// writer.WriteLine("output.WriteRawVarint32({0});", WireFormat.MakeTag(Descriptor));
// writer.WriteLine("output.WriteRawVarint32((uint) {0}MemoizedSerializedSize);", Name);
// writer.WriteLine("foreach (int element in {0}_) {{", Name);
// writer.WriteLine(" output.WriteEnumNoTag(element);");
// writer.WriteLine("}");
//}
//else
//{
// writer.WriteLine("foreach (int element in {0}_) {{", Name);
// writer.WriteLine(" output.WriteEnum({0}, element);", Number);
// writer.WriteLine("}");
//}
writer.WriteLine("output.WriteArray(pbd::FieldType.{3}, {0}, field_names[{2}], {1}_);", Number, Name, FieldOrdinal, Descriptor.FieldType);
writer.Outdent();
writer.WriteLine("}");
}
......
......@@ -41,8 +41,8 @@ namespace Google.ProtocolBuffers.ProtoGen
{
internal class RepeatedMessageFieldGenerator : FieldGeneratorBase, IFieldSourceGenerator
{
internal RepeatedMessageFieldGenerator(FieldDescriptor descriptor)
: base(descriptor)
internal RepeatedMessageFieldGenerator(FieldDescriptor descriptor, int fieldOrdinal)
: base(descriptor, fieldOrdinal)
{
}
......@@ -123,33 +123,13 @@ namespace Google.ProtocolBuffers.ProtoGen
public void GenerateParsingCode(TextGenerator writer)
{
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)
{
writer.WriteLine("if ({0}_.Count > 0) {{", Name);
writer.Indent();
// Arrays of message types do not currently support 'packed' storage
//if (Descriptor.IsPacked)
// writer.WriteLine("output.WritePackedArray(pbd::FieldType.{3}, {0}, \"{2}\", {1}MemoizedSerializedSize, {1}_);", Number, Name, Descriptor.Name, Descriptor.FieldType);
//else
writer.WriteLine("output.WriteArray(pbd::FieldType.{3}, {0}, \"{2}\", {1}_);", Number, Name, Descriptor.Name, Descriptor.FieldType);
//writer.WriteLine("foreach ({0} element in {1}List) {{", TypeName, PropertyName);
//writer.WriteLine(" output.Write{0}({1}, element);", MessageOrGroup, Number);
//writer.WriteLine("}");
writer.WriteLine("output.WriteArray(pbd::FieldType.{3}, {0}, field_names[{2}], {1}_);", Number, Name, FieldOrdinal, Descriptor.FieldType);
writer.Outdent();
writer.WriteLine("}");
}
......
......@@ -41,8 +41,8 @@ namespace Google.ProtocolBuffers.ProtoGen
{
internal class RepeatedPrimitiveFieldGenerator : FieldGeneratorBase, IFieldSourceGenerator
{
internal RepeatedPrimitiveFieldGenerator(FieldDescriptor descriptor)
: base(descriptor)
internal RepeatedPrimitiveFieldGenerator(FieldDescriptor descriptor, int fieldOrdinal)
: base(descriptor, fieldOrdinal)
{
}
......@@ -122,19 +122,6 @@ namespace Google.ProtocolBuffers.ProtoGen
public void GenerateParsingCode(TextGenerator writer)
{
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)
......@@ -142,23 +129,9 @@ namespace Google.ProtocolBuffers.ProtoGen
writer.WriteLine("if ({0}_.Count > 0) {{", Name);
writer.Indent();
if (Descriptor.IsPacked)
writer.WriteLine("output.WritePackedArray(pbd::FieldType.{3}, {0}, \"{2}\", {1}MemoizedSerializedSize, {1}_);", Number, Name, Descriptor.Name, Descriptor.FieldType);
writer.WriteLine("output.WritePackedArray(pbd::FieldType.{3}, {0}, field_names[{2}], {1}MemoizedSerializedSize, {1}_);", Number, Name, FieldOrdinal, Descriptor.FieldType);
else
writer.WriteLine("output.WriteArray(pbd::FieldType.{3}, {0}, \"{2}\", {1}_);", Number, Name, Descriptor.Name, Descriptor.FieldType);
//if (Descriptor.IsPacked)
//{
// writer.WriteLine("output.WriteRawVarint32({0});", WireFormat.MakeTag(Descriptor));
// writer.WriteLine("output.WriteRawVarint32((uint) {0}MemoizedSerializedSize);", Name);
// writer.WriteLine("foreach ({0} element in {1}_) {{", TypeName, Name);
// writer.WriteLine(" output.Write{0}NoTag(element);", CapitalizedTypeName);
// writer.WriteLine("}");
//}
//else
//{
// writer.WriteLine("foreach ({0} element in {1}_) {{", TypeName, Name);
// writer.WriteLine(" output.Write{0}({1}, element);", CapitalizedTypeName, Number);
// writer.WriteLine("}");
//}
writer.WriteLine("output.WriteArray(pbd::FieldType.{3}, {0}, field_names[{2}], {1}_);", Number, Name, FieldOrdinal, Descriptor.FieldType);
writer.Outdent();
writer.WriteLine("}");
}
......
This diff is collapsed.
......@@ -59,6 +59,8 @@ namespace Google.ProtocolBuffers.TestProtos {
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("ProtoGen", "2.3.0.277")]
public sealed partial class OptionsMessage : pb::GeneratedMessage<OptionsMessage, OptionsMessage.Builder> {
private static readonly OptionsMessage defaultInstance = new Builder().BuildPartial();
private static readonly string[] _optionsMessageFieldNames = new string[] { "customized", "normal", "options_message" };
private static readonly uint[] _optionsMessageFieldTags = new uint[] { 26, 10, 18 };
public static OptionsMessage DefaultInstance {
get { return defaultInstance; }
}
......@@ -117,14 +119,15 @@ namespace Google.ProtocolBuffers.TestProtos {
public override void WriteTo(pb::ICodedOutputStream output) {
int size = SerializedSize;
string[] field_names = _optionsMessageFieldNames;
if (hasNormal) {
output.WriteString(1, "normal", Normal);
output.WriteString(1, field_names[1], Normal);
}
if (hasOptionsMessage_) {
output.WriteString(2, "options_message", OptionsMessage_);
output.WriteString(2, field_names[2], OptionsMessage_);
}
if (hasCustomName) {
output.WriteString(3, "customized", CustomName);
output.WriteString(3, field_names[0], CustomName);
}
UnknownFields.WriteTo(output);
}
......@@ -262,6 +265,18 @@ namespace Google.ProtocolBuffers.TestProtos {
uint tag;
string field_name;
while (input.ReadTag(out tag, out field_name)) {
if(tag == 0 && field_name != null) {
int field_ordinal = global::System.Array.BinarySearch(_optionsMessageFieldNames, field_name, global::System.StringComparer.Ordinal);
if(field_ordinal >= 0)
tag = _optionsMessageFieldTags[field_ordinal];
else {
if (unknownFields == null) {
unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
}
ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
continue;
}
}
switch (tag) {
case 0: {
throw pb::InvalidProtocolBufferException.InvalidTag();
......@@ -280,15 +295,15 @@ namespace Google.ProtocolBuffers.TestProtos {
break;
}
case 10: {
result.hasNormal |= input.ReadString(ref result.normal_);
result.hasNormal = input.ReadString(ref result.normal_);
break;
}
case 18: {
result.hasOptionsMessage_ |= input.ReadString(ref result.optionsMessage_);
result.hasOptionsMessage_ = input.ReadString(ref result.optionsMessage_);
break;
}
case 26: {
result.hasCustomName |= input.ReadString(ref result.customized_);
result.hasCustomName = input.ReadString(ref result.customized_);
break;
}
}
......
......@@ -63,6 +63,8 @@ namespace Google.ProtocolBuffers.TestProtos {
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("ProtoGen", "2.3.0.277")]
public sealed partial class TestEmbedOptimizedForSize : pb::GeneratedMessage<TestEmbedOptimizedForSize, TestEmbedOptimizedForSize.Builder> {
private static readonly TestEmbedOptimizedForSize defaultInstance = new Builder().BuildPartial();
private static readonly string[] _testEmbedOptimizedForSizeFieldNames = new string[] { "optional_message", "repeated_message" };
private static readonly uint[] _testEmbedOptimizedForSizeFieldTags = new uint[] { 10, 18 };
public static TestEmbedOptimizedForSize DefaultInstance {
get { return defaultInstance; }
}
......@@ -119,11 +121,12 @@ namespace Google.ProtocolBuffers.TestProtos {
public override void WriteTo(pb::ICodedOutputStream output) {
int size = SerializedSize;
string[] field_names = _testEmbedOptimizedForSizeFieldNames;
if (hasOptionalMessage) {
output.WriteMessage(1, "optional_message", OptionalMessage);
output.WriteMessage(1, field_names[0], OptionalMessage);
}
if (repeatedMessage_.Count > 0) {
output.WriteArray(pbd::FieldType.Message, 2, "repeated_message", repeatedMessage_);
output.WriteArray(pbd::FieldType.Message, 2, field_names[1], repeatedMessage_);
}
UnknownFields.WriteTo(output);
}
......@@ -256,6 +259,18 @@ namespace Google.ProtocolBuffers.TestProtos {
uint tag;
string field_name;
while (input.ReadTag(out tag, out field_name)) {
if(tag == 0 && field_name != null) {
int field_ordinal = global::System.Array.BinarySearch(_testEmbedOptimizedForSizeFieldNames, field_name, global::System.StringComparer.Ordinal);
if(field_ordinal >= 0)
tag = _testEmbedOptimizedForSizeFieldTags[field_ordinal];
else {
if (unknownFields == null) {
unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
}
ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
continue;
}
}
switch (tag) {
case 0: {
throw pb::InvalidProtocolBufferException.InvalidTag();
......
......@@ -42,6 +42,8 @@ namespace Google.ProtocolBuffers.TestProtos {
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("ProtoGen", "2.3.0.277")]
public sealed partial class ImportMessageLite : pb::GeneratedMessageLite<ImportMessageLite, ImportMessageLite.Builder> {
private static readonly ImportMessageLite defaultInstance = new Builder().BuildPartial();
private static readonly string[] _importMessageLiteFieldNames = new string[] { "d" };
private static readonly uint[] _importMessageLiteFieldTags = new uint[] { 8 };
public static ImportMessageLite DefaultInstance {
get { return defaultInstance; }
}
......@@ -72,8 +74,9 @@ namespace Google.ProtocolBuffers.TestProtos {
public override void WriteTo(pb::ICodedOutputStream output) {
int size = SerializedSize;
string[] field_names = _importMessageLiteFieldNames;
if (hasD) {
output.WriteInt32(1, "d", D);
output.WriteInt32(1, field_names[0], D);
}
}
......@@ -210,6 +213,15 @@ namespace Google.ProtocolBuffers.TestProtos {
uint tag;
string field_name;
while (input.ReadTag(out tag, out field_name)) {
if(tag == 0 && field_name != null) {
int field_ordinal = global::System.Array.BinarySearch(_importMessageLiteFieldNames, field_name, global::System.StringComparer.Ordinal);
if(field_ordinal >= 0)
tag = _importMessageLiteFieldTags[field_ordinal];
else {
ParseUnknownField(input, extensionRegistry, tag, field_name);
continue;
}
}
switch (tag) {
case 0: {
throw pb::InvalidProtocolBufferException.InvalidTag();
......@@ -222,7 +234,7 @@ namespace Google.ProtocolBuffers.TestProtos {
break;
}
case 8: {
result.hasD |= input.ReadInt32(ref result.d_);
result.hasD = input.ReadInt32(ref result.d_);
break;
}
}
......
......@@ -70,6 +70,8 @@ namespace Google.ProtocolBuffers.TestProtos {
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("ProtoGen", "2.3.0.277")]
public sealed partial class ImportMessage : pb::GeneratedMessage<ImportMessage, ImportMessage.Builder> {
private static readonly ImportMessage defaultInstance = new Builder().BuildPartial();
private static readonly string[] _importMessageFieldNames = new string[] { "d" };
private static readonly uint[] _importMessageFieldTags = new uint[] { 8 };
public static ImportMessage DefaultInstance {
get { return defaultInstance; }
}
......@@ -108,8 +110,9 @@ namespace Google.ProtocolBuffers.TestProtos {
public override void WriteTo(pb::ICodedOutputStream output) {
int size = SerializedSize;
string[] field_names = _importMessageFieldNames;
if (hasD) {
output.WriteInt32(1, "d", D);
output.WriteInt32(1, field_names[0], D);
}
UnknownFields.WriteTo(output);
}
......@@ -235,6 +238,18 @@ namespace Google.ProtocolBuffers.TestProtos {
uint tag;
string field_name;
while (input.ReadTag(out tag, out field_name)) {
if(tag == 0 && field_name != null) {
int field_ordinal = global::System.Array.BinarySearch(_importMessageFieldNames, field_name, global::System.StringComparer.Ordinal);
if(field_ordinal >= 0)
tag = _importMessageFieldTags[field_ordinal];
else {
if (unknownFields == null) {
unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
}
ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
continue;
}
}
switch (tag) {
case 0: {
throw pb::InvalidProtocolBufferException.InvalidTag();
......@@ -253,7 +268,7 @@ namespace Google.ProtocolBuffers.TestProtos {
break;
}
case 8: {
result.hasD |= input.ReadInt32(ref result.d_);
result.hasD = input.ReadInt32(ref result.d_);
break;
}
}
......
......@@ -80,6 +80,8 @@ namespace Google.ProtocolBuffers.TestProtos.NoGenericService {
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("ProtoGen", "2.3.0.277")]
public sealed partial class TestMessage : pb::ExtendableMessage<TestMessage, TestMessage.Builder> {
private static readonly TestMessage defaultInstance = new Builder().BuildPartial();
private static readonly string[] _testMessageFieldNames = new string[] { "a" };
private static readonly uint[] _testMessageFieldTags = new uint[] { 8 };
public static TestMessage DefaultInstance {
get { return defaultInstance; }
}
......@@ -119,9 +121,10 @@ namespace Google.ProtocolBuffers.TestProtos.NoGenericService {
public override void WriteTo(pb::ICodedOutputStream output) {
int size = SerializedSize;
string[] field_names = _testMessageFieldNames;
pb::ExtendableMessage<TestMessage, TestMessage.Builder>.ExtensionWriter extensionWriter = CreateExtensionWriter(this);
if (hasA) {
output.WriteInt32(1, "a", A);
output.WriteInt32(1, field_names[0], A);
}
extensionWriter.WriteUntil(536870912, output);
UnknownFields.WriteTo(output);
......@@ -250,6 +253,18 @@ namespace Google.ProtocolBuffers.TestProtos.NoGenericService {
uint tag;
string field_name;
while (input.ReadTag(out tag, out field_name)) {
if(tag == 0 && field_name != null) {
int field_ordinal = global::System.Array.BinarySearch(_testMessageFieldNames, field_name, global::System.StringComparer.Ordinal);
if(field_ordinal >= 0)
tag = _testMessageFieldTags[field_ordinal];
else {
if (unknownFields == null) {
unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
}
ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
continue;
}
}
switch (tag) {
case 0: {
throw pb::InvalidProtocolBufferException.InvalidTag();
......@@ -268,7 +283,7 @@ namespace Google.ProtocolBuffers.TestProtos.NoGenericService {
break;
}
case 8: {
result.hasA |= input.ReadInt32(ref result.a_);
result.hasA = input.ReadInt32(ref result.a_);
break;
}
}
......
......@@ -82,6 +82,8 @@ namespace Google.ProtocolBuffers.TestProtos {
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("ProtoGen", "2.3.0.277")]
public sealed partial class SearchRequest : pb::GeneratedMessage<SearchRequest, SearchRequest.Builder> {
private static readonly SearchRequest defaultInstance = new Builder().BuildPartial();
private static readonly string[] _searchRequestFieldNames = new string[] { "Criteria" };
private static readonly uint[] _searchRequestFieldTags = new uint[] { 10 };
public static SearchRequest DefaultInstance {
get { return defaultInstance; }
}
......@@ -122,8 +124,9 @@ namespace Google.ProtocolBuffers.TestProtos {
public override void WriteTo(pb::ICodedOutputStream output) {
int size = SerializedSize;
string[] field_names = _searchRequestFieldNames;
if (criteria_.Count > 0) {
output.WriteArray(pbd::FieldType.String, 1, "Criteria", criteria_);
output.WriteArray(pbd::FieldType.String, 1, field_names[0], criteria_);
}
UnknownFields.WriteTo(output);
}
......@@ -255,6 +258,18 @@ namespace Google.ProtocolBuffers.TestProtos {
uint tag;
string field_name;
while (input.ReadTag(out tag, out field_name)) {
if(tag == 0 && field_name != null) {
int field_ordinal = global::System.Array.BinarySearch(_searchRequestFieldNames, field_name, global::System.StringComparer.Ordinal);
if(field_ordinal >= 0)
tag = _searchRequestFieldTags[field_ordinal];
else {
if (unknownFields == null) {
unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
}
ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
continue;
}
}
switch (tag) {
case 0: {
throw pb::InvalidProtocolBufferException.InvalidTag();
......@@ -324,6 +339,8 @@ namespace Google.ProtocolBuffers.TestProtos {
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("ProtoGen", "2.3.0.277")]
public sealed partial class SearchResponse : pb::GeneratedMessage<SearchResponse, SearchResponse.Builder> {
private static readonly SearchResponse defaultInstance = new Builder().BuildPartial();
private static readonly string[] _searchResponseFieldNames = new string[] { "results" };
private static readonly uint[] _searchResponseFieldTags = new uint[] { 10 };
public static SearchResponse DefaultInstance {
get { return defaultInstance; }
}
......@@ -354,6 +371,8 @@ namespace Google.ProtocolBuffers.TestProtos {
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("ProtoGen", "2.3.0.277")]
public sealed partial class ResultItem : pb::GeneratedMessage<ResultItem, ResultItem.Builder> {
private static readonly ResultItem defaultInstance = new Builder().BuildPartial();
private static readonly string[] _resultItemFieldNames = new string[] { "name", "url" };
private static readonly uint[] _resultItemFieldTags = new uint[] { 18, 10 };
public static ResultItem DefaultInstance {
get { return defaultInstance; }
}
......@@ -403,11 +422,12 @@ namespace Google.ProtocolBuffers.TestProtos {
public override void WriteTo(pb::ICodedOutputStream output) {
int size = SerializedSize;
string[] field_names = _resultItemFieldNames;
if (hasUrl) {
output.WriteString(1, "url", Url);
output.WriteString(1, field_names[1], Url);
}
if (hasName) {
output.WriteString(2, "name", Name);
output.WriteString(2, field_names[0], Name);
}
UnknownFields.WriteTo(output);
}
......@@ -539,6 +559,18 @@ namespace Google.ProtocolBuffers.TestProtos {
uint tag;
string field_name;
while (input.ReadTag(out tag, out field_name)) {
if(tag == 0 && field_name != null) {
int field_ordinal = global::System.Array.BinarySearch(_resultItemFieldNames, field_name, global::System.StringComparer.Ordinal);
if(field_ordinal >= 0)
tag = _resultItemFieldTags[field_ordinal];
else {
if (unknownFields == null) {
unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
}
ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
continue;
}
}
switch (tag) {
case 0: {
throw pb::InvalidProtocolBufferException.InvalidTag();
......@@ -557,11 +589,11 @@ namespace Google.ProtocolBuffers.TestProtos {
break;
}
case 10: {
result.hasUrl |= input.ReadString(ref result.url_);
result.hasUrl = input.ReadString(ref result.url_);
break;
}
case 18: {
result.hasName |= input.ReadString(ref result.name_);
result.hasName = input.ReadString(ref result.name_);
break;
}
}
......@@ -643,8 +675,9 @@ namespace Google.ProtocolBuffers.TestProtos {
public override void WriteTo(pb::ICodedOutputStream output) {
int size = SerializedSize;
string[] field_names = _searchResponseFieldNames;
if (results_.Count > 0) {
output.WriteArray(pbd::FieldType.Message, 1, "results", results_);
output.WriteArray(pbd::FieldType.Message, 1, field_names[0], results_);
}
UnknownFields.WriteTo(output);
}
......@@ -771,6 +804,18 @@ namespace Google.ProtocolBuffers.TestProtos {
uint tag;
string field_name;
while (input.ReadTag(out tag, out field_name)) {
if(tag == 0 && field_name != null) {
int field_ordinal = global::System.Array.BinarySearch(_searchResponseFieldNames, field_name, global::System.StringComparer.Ordinal);
if(field_ordinal >= 0)
tag = _searchResponseFieldTags[field_ordinal];
else {
if (unknownFields == null) {
unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
}
ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
continue;
}
}
switch (tag) {
case 0: {
throw pb::InvalidProtocolBufferException.InvalidTag();
......@@ -850,6 +895,8 @@ namespace Google.ProtocolBuffers.TestProtos {
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("ProtoGen", "2.3.0.277")]
public sealed partial class RefineSearchRequest : pb::GeneratedMessage<RefineSearchRequest, RefineSearchRequest.Builder> {
private static readonly RefineSearchRequest defaultInstance = new Builder().BuildPartial();
private static readonly string[] _refineSearchRequestFieldNames = new string[] { "Criteria", "previous_results" };
private static readonly uint[] _refineSearchRequestFieldTags = new uint[] { 10, 18 };
public static RefineSearchRequest DefaultInstance {
get { return defaultInstance; }
}
......@@ -902,11 +949,12 @@ namespace Google.ProtocolBuffers.TestProtos {
public override void WriteTo(pb::ICodedOutputStream output) {
int size = SerializedSize;
string[] field_names = _refineSearchRequestFieldNames;
if (criteria_.Count > 0) {
output.WriteArray(pbd::FieldType.String, 1, "Criteria", criteria_);
output.WriteArray(pbd::FieldType.String, 1, field_names[0], criteria_);
}
if (hasPreviousResults) {
output.WriteMessage(2, "previous_results", PreviousResults);
output.WriteMessage(2, field_names[1], PreviousResults);
}
UnknownFields.WriteTo(output);
}
......@@ -1044,6 +1092,18 @@ namespace Google.ProtocolBuffers.TestProtos {
uint tag;
string field_name;
while (input.ReadTag(out tag, out field_name)) {
if(tag == 0 && field_name != null) {
int field_ordinal = global::System.Array.BinarySearch(_refineSearchRequestFieldNames, field_name, global::System.StringComparer.Ordinal);
if(field_ordinal >= 0)
tag = _refineSearchRequestFieldTags[field_ordinal];
else {
if (unknownFields == null) {
unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
}
ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
continue;
}
}
switch (tag) {
case 0: {
throw pb::InvalidProtocolBufferException.InvalidTag();
......
......@@ -607,6 +607,18 @@ namespace Google.ProtocolBuffers
string name;
while (input.ReadTag(out tag, out name))
{
if (tag == 0 && name != null)
{
FieldDescriptor fieldByName = builder.DescriptorForType.FindFieldByName(name);
if (fieldByName != null)
tag = WireFormat.MakeTag(fieldByName);
else
{
ExtensionInfo extension = extensionRegistry.FindByName(builder.DescriptorForType, name);
if (extension != null)
tag = WireFormat.MakeTag(extension.Descriptor);
}
}
if (tag == 0)
{
if (input.SkipField())
......@@ -634,6 +646,19 @@ namespace Google.ProtocolBuffers
internal bool MergeFieldFrom(ICodedInputStream input,
ExtensionRegistry extensionRegistry, IBuilder builder, uint tag, string fieldName)
{
if (tag == 0 && fieldName != null)
{
FieldDescriptor fieldByName = builder.DescriptorForType.FindFieldByName(fieldName);
if (fieldByName != null)
tag = WireFormat.MakeTag(fieldByName);
else
{
ExtensionInfo extension = extensionRegistry.FindByName(builder.DescriptorForType, fieldName);
if (extension != null)
tag = WireFormat.MakeTag(extension.Descriptor);
}
}
MessageDescriptor type = builder.DescriptorForType;
if (type.Options.MessageSetWireFormat && tag == WireFormat.MessageSetTag.ItemStart)
{
......@@ -799,6 +824,11 @@ namespace Google.ProtocolBuffers
string name;
while (input.ReadTag(out tag, out name))
{
if (tag == 0 && name != null)
{
if (name == "type_id") tag = WireFormat.MessageSetTag.TypeID;
else if (name == "message") tag = WireFormat.MessageSetTag.Message;
}
if (tag == 0)
{
if (input.SkipField())
......
......@@ -42,6 +42,8 @@ namespace Google.ProtocolBuffers.TestProtos {
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("ProtoGen", "2.3.0.277")]
public sealed partial class ImportMessageLite : pb::GeneratedMessageLite<ImportMessageLite, ImportMessageLite.Builder> {
private static readonly ImportMessageLite defaultInstance = new Builder().BuildPartial();
private static readonly string[] _importMessageLiteFieldNames = new string[] { "d" };
private static readonly uint[] _importMessageLiteFieldTags = new uint[] { 8 };
public static ImportMessageLite DefaultInstance {
get { return defaultInstance; }
}
......@@ -72,8 +74,9 @@ namespace Google.ProtocolBuffers.TestProtos {
public override void WriteTo(pb::ICodedOutputStream output) {
int size = SerializedSize;
string[] field_names = _importMessageLiteFieldNames;
if (hasD) {
output.WriteInt32(1, "d", D);
output.WriteInt32(1, field_names[0], D);
}
}
......@@ -210,6 +213,15 @@ namespace Google.ProtocolBuffers.TestProtos {
uint tag;
string field_name;
while (input.ReadTag(out tag, out field_name)) {
if(tag == 0 && field_name != null) {
int field_ordinal = global::System.Array.BinarySearch(_importMessageLiteFieldNames, field_name, global::System.StringComparer.Ordinal);
if(field_ordinal >= 0)
tag = _importMessageLiteFieldTags[field_ordinal];
else {
ParseUnknownField(input, extensionRegistry, tag, field_name);
continue;
}
}
switch (tag) {
case 0: {
throw pb::InvalidProtocolBufferException.InvalidTag();
......@@ -222,7 +234,7 @@ namespace Google.ProtocolBuffers.TestProtos {
break;
}
case 8: {
result.hasD |= input.ReadInt32(ref result.d_);
result.hasD = input.ReadInt32(ref result.d_);
break;
}
}
......
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