aboutsummaryrefslogtreecommitdiff
path: root/csharp/src/ProtocolBuffers/Descriptors/FieldDescriptor.cs
diff options
context:
space:
mode:
authorJon Skeet <jonskeet@google.com>2015-07-01 14:47:03 +0100
committerJon Skeet <jonskeet@google.com>2015-07-09 08:24:49 +0100
commit78ea98f56f7a0a028e378aee6394549707e199bc (patch)
treeb3275e8d8b01528dc58af6ec0877c4ee79cd1b54 /csharp/src/ProtocolBuffers/Descriptors/FieldDescriptor.cs
parent3805b43009d35422bed85c56aaf2d6ce4d007fe5 (diff)
downloadprotobuf-78ea98f56f7a0a028e378aee6394549707e199bc.tar.gz
protobuf-78ea98f56f7a0a028e378aee6394549707e199bc.tar.bz2
protobuf-78ea98f56f7a0a028e378aee6394549707e199bc.zip
Implement reflection properly for fields.
- FieldAccessorTable is now non-generic - We don't have a static field per message type in the umbrella class. (Message descriptors are accessed via the file descriptor.) - Removed the "descriptor assigner" complication from the descriptor fixup; without extensions, we don't need it - MapField implements IDictionary (more tests would be good...) - RepeatedField implements IList (more tests would be good) - Use expression trees to build accessors. (Will need to test this on various platforms... probably need a fallback strategy just using reflection directly.) - Added FieldDescriptor.IsMap - Added tests for reflection with generated messages Changes to generated code coming in next commit.
Diffstat (limited to 'csharp/src/ProtocolBuffers/Descriptors/FieldDescriptor.cs')
-rw-r--r--csharp/src/ProtocolBuffers/Descriptors/FieldDescriptor.cs5
1 files changed, 5 insertions, 0 deletions
diff --git a/csharp/src/ProtocolBuffers/Descriptors/FieldDescriptor.cs b/csharp/src/ProtocolBuffers/Descriptors/FieldDescriptor.cs
index 2f2c5806..3b36a280 100644
--- a/csharp/src/ProtocolBuffers/Descriptors/FieldDescriptor.cs
+++ b/csharp/src/ProtocolBuffers/Descriptors/FieldDescriptor.cs
@@ -131,6 +131,11 @@ namespace Google.Protobuf.Descriptors
get { return Proto.Label == FieldDescriptorProto.Types.Label.LABEL_REPEATED; }
}
+ public bool IsMap
+ {
+ get { return fieldType == FieldType.Message && messageType.Options != null && messageType.Options.MapEntry; }
+ }
+
public bool IsPacked
{
get { return Proto.Options.Packed; }