diff options
author | csharptest <roger@csharptest.net> | 2011-06-08 20:13:29 -0500 |
---|---|---|
committer | rogerk <devnull@localhost> | 2011-06-08 20:13:29 -0500 |
commit | 920b09a3b0af58440ed936183d5dfd5342eae1a0 (patch) | |
tree | 12bd44e1f596eacc05cc871ba30cc10114ae5868 /src/ProtocolBuffers/UnknownFieldSet.cs | |
parent | aef072a46f7c902e6fa1adf18e34f8d4b1eba38a (diff) | |
download | protobuf-920b09a3b0af58440ed936183d5dfd5342eae1a0.tar.gz protobuf-920b09a3b0af58440ed936183d5dfd5342eae1a0.tar.bz2 protobuf-920b09a3b0af58440ed936183d5dfd5342eae1a0.zip |
Finished adding find tag by name
Diffstat (limited to 'src/ProtocolBuffers/UnknownFieldSet.cs')
-rw-r--r-- | src/ProtocolBuffers/UnknownFieldSet.cs | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/ProtocolBuffers/UnknownFieldSet.cs b/src/ProtocolBuffers/UnknownFieldSet.cs index 70910cbf..fbafb892 100644 --- a/src/ProtocolBuffers/UnknownFieldSet.cs +++ b/src/ProtocolBuffers/UnknownFieldSet.cs @@ -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())
|