aboutsummaryrefslogtreecommitdiff
path: root/csharp/src/Google.Protobuf/Reflection
diff options
context:
space:
mode:
Diffstat (limited to 'csharp/src/Google.Protobuf/Reflection')
-rw-r--r--csharp/src/Google.Protobuf/Reflection/DescriptorProtoFile.cs248
-rw-r--r--csharp/src/Google.Protobuf/Reflection/DescriptorUtil.cs5
-rw-r--r--csharp/src/Google.Protobuf/Reflection/EnumDescriptor.cs10
-rw-r--r--csharp/src/Google.Protobuf/Reflection/FieldAccessorBase.cs7
-rw-r--r--csharp/src/Google.Protobuf/Reflection/FieldAccessorTable.cs97
-rw-r--r--csharp/src/Google.Protobuf/Reflection/FieldDescriptor.cs30
-rw-r--r--csharp/src/Google.Protobuf/Reflection/FileDescriptor.cs26
-rw-r--r--csharp/src/Google.Protobuf/Reflection/GeneratedCodeInfo.cs66
-rw-r--r--csharp/src/Google.Protobuf/Reflection/MapFieldAccessor.cs3
-rw-r--r--csharp/src/Google.Protobuf/Reflection/MessageDescriptor.cs68
-rw-r--r--csharp/src/Google.Protobuf/Reflection/OneofAccessor.cs10
-rw-r--r--csharp/src/Google.Protobuf/Reflection/OneofDescriptor.cs27
-rw-r--r--csharp/src/Google.Protobuf/Reflection/ReflectionUtil.cs3
-rw-r--r--csharp/src/Google.Protobuf/Reflection/RepeatedFieldAccessor.cs3
-rw-r--r--csharp/src/Google.Protobuf/Reflection/SingleFieldAccessor.cs5
15 files changed, 279 insertions, 329 deletions
diff --git a/csharp/src/Google.Protobuf/Reflection/DescriptorProtoFile.cs b/csharp/src/Google.Protobuf/Reflection/DescriptorProtoFile.cs
index c87969b9..def70b53 100644
--- a/csharp/src/Google.Protobuf/Reflection/DescriptorProtoFile.cs
+++ b/csharp/src/Google.Protobuf/Reflection/DescriptorProtoFile.cs
@@ -12,30 +12,6 @@ namespace Google.Protobuf.Reflection {
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
internal static partial class DescriptorProtoFile {
- #region Static variables
- internal static pbr::FieldAccessorTable internal__static_google_protobuf_FileDescriptorSet__FieldAccessorTable;
- internal static pbr::FieldAccessorTable internal__static_google_protobuf_FileDescriptorProto__FieldAccessorTable;
- internal static pbr::FieldAccessorTable internal__static_google_protobuf_DescriptorProto__FieldAccessorTable;
- internal static pbr::FieldAccessorTable internal__static_google_protobuf_DescriptorProto_ExtensionRange__FieldAccessorTable;
- internal static pbr::FieldAccessorTable internal__static_google_protobuf_DescriptorProto_ReservedRange__FieldAccessorTable;
- internal static pbr::FieldAccessorTable internal__static_google_protobuf_FieldDescriptorProto__FieldAccessorTable;
- internal static pbr::FieldAccessorTable internal__static_google_protobuf_OneofDescriptorProto__FieldAccessorTable;
- internal static pbr::FieldAccessorTable internal__static_google_protobuf_EnumDescriptorProto__FieldAccessorTable;
- internal static pbr::FieldAccessorTable internal__static_google_protobuf_EnumValueDescriptorProto__FieldAccessorTable;
- internal static pbr::FieldAccessorTable internal__static_google_protobuf_ServiceDescriptorProto__FieldAccessorTable;
- internal static pbr::FieldAccessorTable internal__static_google_protobuf_MethodDescriptorProto__FieldAccessorTable;
- internal static pbr::FieldAccessorTable internal__static_google_protobuf_FileOptions__FieldAccessorTable;
- internal static pbr::FieldAccessorTable internal__static_google_protobuf_MessageOptions__FieldAccessorTable;
- internal static pbr::FieldAccessorTable internal__static_google_protobuf_FieldOptions__FieldAccessorTable;
- internal static pbr::FieldAccessorTable internal__static_google_protobuf_EnumOptions__FieldAccessorTable;
- internal static pbr::FieldAccessorTable internal__static_google_protobuf_EnumValueOptions__FieldAccessorTable;
- internal static pbr::FieldAccessorTable internal__static_google_protobuf_ServiceOptions__FieldAccessorTable;
- internal static pbr::FieldAccessorTable internal__static_google_protobuf_MethodOptions__FieldAccessorTable;
- internal static pbr::FieldAccessorTable internal__static_google_protobuf_UninterpretedOption__FieldAccessorTable;
- internal static pbr::FieldAccessorTable internal__static_google_protobuf_UninterpretedOption_NamePart__FieldAccessorTable;
- internal static pbr::FieldAccessorTable internal__static_google_protobuf_SourceCodeInfo__FieldAccessorTable;
- internal static pbr::FieldAccessorTable internal__static_google_protobuf_SourceCodeInfo_Location__FieldAccessorTable;
- #endregion
#region Descriptor
public static pbr::FileDescriptor Descriptor {
get { return descriptor; }
@@ -155,76 +131,30 @@ namespace Google.Protobuf.Reflection {
"YWlsaW5nX2NvbW1lbnRzGAQgASgJEiEKGWxlYWRpbmdfZGV0YWNoZWRfY29t",
"bWVudHMYBiADKAlCWAoTY29tLmdvb2dsZS5wcm90b2J1ZkIQRGVzY3JpcHRv",
"clByb3Rvc0gBWgpkZXNjcmlwdG9yogIDR1BCqgIaR29vZ2xlLlByb3RvYnVm",
- "LlJlZmxlY3Rpb24="));
+ "LlJlZmxlY3Rpb24="));
descriptor = pbr::FileDescriptor.InternalBuildGeneratedFileFrom(descriptorData,
- new pbr::FileDescriptor[] {
- });
- internal__static_google_protobuf_FileDescriptorSet__FieldAccessorTable =
- new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.Reflection.FileDescriptorSet), descriptor.MessageTypes[0],
- new string[] { "File", }, new string[] { });
- internal__static_google_protobuf_FileDescriptorProto__FieldAccessorTable =
- new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.Reflection.FileDescriptorProto), descriptor.MessageTypes[1],
- new string[] { "Name", "Package", "Dependency", "PublicDependency", "WeakDependency", "MessageType", "EnumType", "Service", "Extension", "Options", "SourceCodeInfo", "Syntax", }, new string[] { });
- internal__static_google_protobuf_DescriptorProto__FieldAccessorTable =
- new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.Reflection.DescriptorProto), descriptor.MessageTypes[2],
- new string[] { "Name", "Field", "Extension", "NestedType", "EnumType", "ExtensionRange", "OneofDecl", "Options", "ReservedRange", "ReservedName", }, new string[] { });
- internal__static_google_protobuf_DescriptorProto_ExtensionRange__FieldAccessorTable =
- new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.Reflection.DescriptorProto.Types.ExtensionRange), descriptor.MessageTypes[2].NestedTypes[0],
- new string[] { "Start", "End", }, new string[] { });
- internal__static_google_protobuf_DescriptorProto_ReservedRange__FieldAccessorTable =
- new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.Reflection.DescriptorProto.Types.ReservedRange), descriptor.MessageTypes[2].NestedTypes[1],
- new string[] { "Start", "End", }, new string[] { });
- internal__static_google_protobuf_FieldDescriptorProto__FieldAccessorTable =
- new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.Reflection.FieldDescriptorProto), descriptor.MessageTypes[3],
- new string[] { "Name", "Number", "Label", "Type", "TypeName", "Extendee", "DefaultValue", "OneofIndex", "Options", }, new string[] { });
- internal__static_google_protobuf_OneofDescriptorProto__FieldAccessorTable =
- new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.Reflection.OneofDescriptorProto), descriptor.MessageTypes[4],
- new string[] { "Name", }, new string[] { });
- internal__static_google_protobuf_EnumDescriptorProto__FieldAccessorTable =
- new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.Reflection.EnumDescriptorProto), descriptor.MessageTypes[5],
- new string[] { "Name", "Value", "Options", }, new string[] { });
- internal__static_google_protobuf_EnumValueDescriptorProto__FieldAccessorTable =
- new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.Reflection.EnumValueDescriptorProto), descriptor.MessageTypes[6],
- new string[] { "Name", "Number", "Options", }, new string[] { });
- internal__static_google_protobuf_ServiceDescriptorProto__FieldAccessorTable =
- new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.Reflection.ServiceDescriptorProto), descriptor.MessageTypes[7],
- new string[] { "Name", "Method", "Options", }, new string[] { });
- internal__static_google_protobuf_MethodDescriptorProto__FieldAccessorTable =
- new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.Reflection.MethodDescriptorProto), descriptor.MessageTypes[8],
- new string[] { "Name", "InputType", "OutputType", "Options", "ClientStreaming", "ServerStreaming", }, new string[] { });
- internal__static_google_protobuf_FileOptions__FieldAccessorTable =
- new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.Reflection.FileOptions), descriptor.MessageTypes[9],
- new string[] { "JavaPackage", "JavaOuterClassname", "JavaMultipleFiles", "JavaGenerateEqualsAndHash", "JavaStringCheckUtf8", "OptimizeFor", "GoPackage", "CcGenericServices", "JavaGenericServices", "PyGenericServices", "Deprecated", "CcEnableArenas", "ObjcClassPrefix", "CsharpNamespace", "UninterpretedOption", }, new string[] { });
- internal__static_google_protobuf_MessageOptions__FieldAccessorTable =
- new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.Reflection.MessageOptions), descriptor.MessageTypes[10],
- new string[] { "MessageSetWireFormat", "NoStandardDescriptorAccessor", "Deprecated", "MapEntry", "UninterpretedOption", }, new string[] { });
- internal__static_google_protobuf_FieldOptions__FieldAccessorTable =
- new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.Reflection.FieldOptions), descriptor.MessageTypes[11],
- new string[] { "Ctype", "Packed", "Jstype", "Lazy", "Deprecated", "Weak", "UninterpretedOption", }, new string[] { });
- internal__static_google_protobuf_EnumOptions__FieldAccessorTable =
- new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.Reflection.EnumOptions), descriptor.MessageTypes[12],
- new string[] { "AllowAlias", "Deprecated", "UninterpretedOption", }, new string[] { });
- internal__static_google_protobuf_EnumValueOptions__FieldAccessorTable =
- new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.Reflection.EnumValueOptions), descriptor.MessageTypes[13],
- new string[] { "Deprecated", "UninterpretedOption", }, new string[] { });
- internal__static_google_protobuf_ServiceOptions__FieldAccessorTable =
- new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.Reflection.ServiceOptions), descriptor.MessageTypes[14],
- new string[] { "Deprecated", "UninterpretedOption", }, new string[] { });
- internal__static_google_protobuf_MethodOptions__FieldAccessorTable =
- new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.Reflection.MethodOptions), descriptor.MessageTypes[15],
- new string[] { "Deprecated", "UninterpretedOption", }, new string[] { });
- internal__static_google_protobuf_UninterpretedOption__FieldAccessorTable =
- new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.Reflection.UninterpretedOption), descriptor.MessageTypes[16],
- new string[] { "Name", "IdentifierValue", "PositiveIntValue", "NegativeIntValue", "DoubleValue", "StringValue", "AggregateValue", }, new string[] { });
- internal__static_google_protobuf_UninterpretedOption_NamePart__FieldAccessorTable =
- new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.Reflection.UninterpretedOption.Types.NamePart), descriptor.MessageTypes[16].NestedTypes[0],
- new string[] { "NamePart_", "IsExtension", }, new string[] { });
- internal__static_google_protobuf_SourceCodeInfo__FieldAccessorTable =
- new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.Reflection.SourceCodeInfo), descriptor.MessageTypes[17],
- new string[] { "Location", }, new string[] { });
- internal__static_google_protobuf_SourceCodeInfo_Location__FieldAccessorTable =
- new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.Reflection.SourceCodeInfo.Types.Location), descriptor.MessageTypes[17].NestedTypes[0],
- new string[] { "Path", "Span", "LeadingComments", "TrailingComments", "LeadingDetachedComments", }, new string[] { });
+ new pbr::FileDescriptor[] { },
+ new pbr::GeneratedCodeInfo(null, new pbr::GeneratedCodeInfo[] {
+ new pbr::GeneratedCodeInfo(typeof(global::Google.Protobuf.Reflection.FileDescriptorSet), new[]{ "File" }, null, null, null),
+ new pbr::GeneratedCodeInfo(typeof(global::Google.Protobuf.Reflection.FileDescriptorProto), new[]{ "Name", "Package", "Dependency", "PublicDependency", "WeakDependency", "MessageType", "EnumType", "Service", "Extension", "Options", "SourceCodeInfo", "Syntax" }, null, null, null),
+ new pbr::GeneratedCodeInfo(typeof(global::Google.Protobuf.Reflection.DescriptorProto), new[]{ "Name", "Field", "Extension", "NestedType", "EnumType", "ExtensionRange", "OneofDecl", "Options", "ReservedRange", "ReservedName" }, null, null, new pbr::GeneratedCodeInfo[] { new pbr::GeneratedCodeInfo(typeof(global::Google.Protobuf.Reflection.DescriptorProto.Types.ExtensionRange), new[]{ "Start", "End" }, null, null, null),
+ new pbr::GeneratedCodeInfo(typeof(global::Google.Protobuf.Reflection.DescriptorProto.Types.ReservedRange), new[]{ "Start", "End" }, null, null, null)}),
+ new pbr::GeneratedCodeInfo(typeof(global::Google.Protobuf.Reflection.FieldDescriptorProto), new[]{ "Name", "Number", "Label", "Type", "TypeName", "Extendee", "DefaultValue", "OneofIndex", "Options" }, null, new[]{ typeof(global::Google.Protobuf.Reflection.FieldDescriptorProto.Types.Type), typeof(global::Google.Protobuf.Reflection.FieldDescriptorProto.Types.Label) }, null),
+ new pbr::GeneratedCodeInfo(typeof(global::Google.Protobuf.Reflection.OneofDescriptorProto), new[]{ "Name" }, null, null, null),
+ new pbr::GeneratedCodeInfo(typeof(global::Google.Protobuf.Reflection.EnumDescriptorProto), new[]{ "Name", "Value", "Options" }, null, null, null),
+ new pbr::GeneratedCodeInfo(typeof(global::Google.Protobuf.Reflection.EnumValueDescriptorProto), new[]{ "Name", "Number", "Options" }, null, null, null),
+ new pbr::GeneratedCodeInfo(typeof(global::Google.Protobuf.Reflection.ServiceDescriptorProto), new[]{ "Name", "Method", "Options" }, null, null, null),
+ new pbr::GeneratedCodeInfo(typeof(global::Google.Protobuf.Reflection.MethodDescriptorProto), new[]{ "Name", "InputType", "OutputType", "Options", "ClientStreaming", "ServerStreaming" }, null, null, null),
+ new pbr::GeneratedCodeInfo(typeof(global::Google.Protobuf.Reflection.FileOptions), new[]{ "JavaPackage", "JavaOuterClassname", "JavaMultipleFiles", "JavaGenerateEqualsAndHash", "JavaStringCheckUtf8", "OptimizeFor", "GoPackage", "CcGenericServices", "JavaGenericServices", "PyGenericServices", "Deprecated", "CcEnableArenas", "ObjcClassPrefix", "CsharpNamespace", "UninterpretedOption" }, null, new[]{ typeof(global::Google.Protobuf.Reflection.FileOptions.Types.OptimizeMode) }, null),
+ new pbr::GeneratedCodeInfo(typeof(global::Google.Protobuf.Reflection.MessageOptions), new[]{ "MessageSetWireFormat", "NoStandardDescriptorAccessor", "Deprecated", "MapEntry", "UninterpretedOption" }, null, null, null),
+ new pbr::GeneratedCodeInfo(typeof(global::Google.Protobuf.Reflection.FieldOptions), new[]{ "Ctype", "Packed", "Jstype", "Lazy", "Deprecated", "Weak", "UninterpretedOption" }, null, new[]{ typeof(global::Google.Protobuf.Reflection.FieldOptions.Types.CType), typeof(global::Google.Protobuf.Reflection.FieldOptions.Types.JSType) }, null),
+ new pbr::GeneratedCodeInfo(typeof(global::Google.Protobuf.Reflection.EnumOptions), new[]{ "AllowAlias", "Deprecated", "UninterpretedOption" }, null, null, null),
+ new pbr::GeneratedCodeInfo(typeof(global::Google.Protobuf.Reflection.EnumValueOptions), new[]{ "Deprecated", "UninterpretedOption" }, null, null, null),
+ new pbr::GeneratedCodeInfo(typeof(global::Google.Protobuf.Reflection.ServiceOptions), new[]{ "Deprecated", "UninterpretedOption" }, null, null, null),
+ new pbr::GeneratedCodeInfo(typeof(global::Google.Protobuf.Reflection.MethodOptions), new[]{ "Deprecated", "UninterpretedOption" }, null, null, null),
+ new pbr::GeneratedCodeInfo(typeof(global::Google.Protobuf.Reflection.UninterpretedOption), new[]{ "Name", "IdentifierValue", "PositiveIntValue", "NegativeIntValue", "DoubleValue", "StringValue", "AggregateValue" }, null, null, new pbr::GeneratedCodeInfo[] { new pbr::GeneratedCodeInfo(typeof(global::Google.Protobuf.Reflection.UninterpretedOption.Types.NamePart), new[]{ "NamePart_", "IsExtension" }, null, null, null)}),
+ new pbr::GeneratedCodeInfo(typeof(global::Google.Protobuf.Reflection.SourceCodeInfo), new[]{ "Location" }, null, null, new pbr::GeneratedCodeInfo[] { new pbr::GeneratedCodeInfo(typeof(global::Google.Protobuf.Reflection.SourceCodeInfo.Types.Location), new[]{ "Path", "Span", "LeadingComments", "TrailingComments", "LeadingDetachedComments" }, null, null, null)})
+ }));
}
#endregion
@@ -235,14 +165,12 @@ namespace Google.Protobuf.Reflection {
private static readonly pb::MessageParser<FileDescriptorSet> _parser = new pb::MessageParser<FileDescriptorSet>(() => new FileDescriptorSet());
public static pb::MessageParser<FileDescriptorSet> Parser { get { return _parser; } }
- private static readonly string[] _fieldNames = new string[] { "file" };
- private static readonly uint[] _fieldTags = new uint[] { 10 };
public static pbr::MessageDescriptor Descriptor {
get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.Descriptor.MessageTypes[0]; }
}
- pbr::FieldAccessorTable pb::IReflectedMessage.Fields {
- get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.internal__static_google_protobuf_FileDescriptorSet__FieldAccessorTable; }
+ pbr::MessageDescriptor pb::IMessage.Descriptor {
+ get { return Descriptor; }
}
private bool _frozen = false;
@@ -346,14 +274,12 @@ namespace Google.Protobuf.Reflection {
private static readonly pb::MessageParser<FileDescriptorProto> _parser = new pb::MessageParser<FileDescriptorProto>(() => new FileDescriptorProto());
public static pb::MessageParser<FileDescriptorProto> Parser { get { return _parser; } }
- private static readonly string[] _fieldNames = new string[] { "dependency", "enum_type", "extension", "message_type", "name", "options", "package", "public_dependency", "service", "source_code_info", "syntax", "weak_dependency" };
- private static readonly uint[] _fieldTags = new uint[] { 26, 42, 58, 34, 10, 66, 18, 80, 50, 74, 98, 88 };
public static pbr::MessageDescriptor Descriptor {
get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.Descriptor.MessageTypes[1]; }
}
- pbr::FieldAccessorTable pb::IReflectedMessage.Fields {
- get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.internal__static_google_protobuf_FileDescriptorProto__FieldAccessorTable; }
+ pbr::MessageDescriptor pb::IMessage.Descriptor {
+ get { return Descriptor; }
}
private bool _frozen = false;
@@ -722,14 +648,12 @@ namespace Google.Protobuf.Reflection {
private static readonly pb::MessageParser<DescriptorProto> _parser = new pb::MessageParser<DescriptorProto>(() => new DescriptorProto());
public static pb::MessageParser<DescriptorProto> Parser { get { return _parser; } }
- private static readonly string[] _fieldNames = new string[] { "enum_type", "extension", "extension_range", "field", "name", "nested_type", "oneof_decl", "options", "reserved_name", "reserved_range" };
- private static readonly uint[] _fieldTags = new uint[] { 34, 50, 42, 18, 10, 26, 66, 58, 82, 74 };
public static pbr::MessageDescriptor Descriptor {
get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.Descriptor.MessageTypes[2]; }
}
- pbr::FieldAccessorTable pb::IReflectedMessage.Fields {
- get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.internal__static_google_protobuf_DescriptorProto__FieldAccessorTable; }
+ pbr::MessageDescriptor pb::IMessage.Descriptor {
+ get { return Descriptor; }
}
private bool _frozen = false;
@@ -1028,14 +952,12 @@ namespace Google.Protobuf.Reflection {
private static readonly pb::MessageParser<ExtensionRange> _parser = new pb::MessageParser<ExtensionRange>(() => new ExtensionRange());
public static pb::MessageParser<ExtensionRange> Parser { get { return _parser; } }
- private static readonly string[] _fieldNames = new string[] { "end", "start" };
- private static readonly uint[] _fieldTags = new uint[] { 16, 8 };
public static pbr::MessageDescriptor Descriptor {
get { return global::Google.Protobuf.Reflection.DescriptorProto.Descriptor.NestedTypes[0]; }
}
- pbr::FieldAccessorTable pb::IReflectedMessage.Fields {
- get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.internal__static_google_protobuf_DescriptorProto_ExtensionRange__FieldAccessorTable; }
+ pbr::MessageDescriptor pb::IMessage.Descriptor {
+ get { return Descriptor; }
}
private bool _frozen = false;
@@ -1174,14 +1096,12 @@ namespace Google.Protobuf.Reflection {
private static readonly pb::MessageParser<ReservedRange> _parser = new pb::MessageParser<ReservedRange>(() => new ReservedRange());
public static pb::MessageParser<ReservedRange> Parser { get { return _parser; } }
- private static readonly string[] _fieldNames = new string[] { "end", "start" };
- private static readonly uint[] _fieldTags = new uint[] { 16, 8 };
public static pbr::MessageDescriptor Descriptor {
get { return global::Google.Protobuf.Reflection.DescriptorProto.Descriptor.NestedTypes[1]; }
}
- pbr::FieldAccessorTable pb::IReflectedMessage.Fields {
- get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.internal__static_google_protobuf_DescriptorProto_ReservedRange__FieldAccessorTable; }
+ pbr::MessageDescriptor pb::IMessage.Descriptor {
+ get { return Descriptor; }
}
private bool _frozen = false;
@@ -1325,14 +1245,12 @@ namespace Google.Protobuf.Reflection {
private static readonly pb::MessageParser<FieldDescriptorProto> _parser = new pb::MessageParser<FieldDescriptorProto>(() => new FieldDescriptorProto());
public static pb::MessageParser<FieldDescriptorProto> Parser { get { return _parser; } }
- private static readonly string[] _fieldNames = new string[] { "default_value", "extendee", "label", "name", "number", "oneof_index", "options", "type", "type_name" };
- private static readonly uint[] _fieldTags = new uint[] { 58, 18, 32, 10, 24, 72, 66, 40, 50 };
public static pbr::MessageDescriptor Descriptor {
get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.Descriptor.MessageTypes[3]; }
}
- pbr::FieldAccessorTable pb::IReflectedMessage.Fields {
- get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.internal__static_google_protobuf_FieldDescriptorProto__FieldAccessorTable; }
+ pbr::MessageDescriptor pb::IMessage.Descriptor {
+ get { return Descriptor; }
}
private bool _frozen = false;
@@ -1700,14 +1618,12 @@ namespace Google.Protobuf.Reflection {
private static readonly pb::MessageParser<OneofDescriptorProto> _parser = new pb::MessageParser<OneofDescriptorProto>(() => new OneofDescriptorProto());
public static pb::MessageParser<OneofDescriptorProto> Parser { get { return _parser; } }
- private static readonly string[] _fieldNames = new string[] { "name" };
- private static readonly uint[] _fieldTags = new uint[] { 10 };
public static pbr::MessageDescriptor Descriptor {
get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.Descriptor.MessageTypes[4]; }
}
- pbr::FieldAccessorTable pb::IReflectedMessage.Fields {
- get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.internal__static_google_protobuf_OneofDescriptorProto__FieldAccessorTable; }
+ pbr::MessageDescriptor pb::IMessage.Descriptor {
+ get { return Descriptor; }
}
private bool _frozen = false;
@@ -1819,14 +1735,12 @@ namespace Google.Protobuf.Reflection {
private static readonly pb::MessageParser<EnumDescriptorProto> _parser = new pb::MessageParser<EnumDescriptorProto>(() => new EnumDescriptorProto());
public static pb::MessageParser<EnumDescriptorProto> Parser { get { return _parser; } }
- private static readonly string[] _fieldNames = new string[] { "name", "options", "value" };
- private static readonly uint[] _fieldTags = new uint[] { 10, 26, 18 };
public static pbr::MessageDescriptor Descriptor {
get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.Descriptor.MessageTypes[5]; }
}
- pbr::FieldAccessorTable pb::IReflectedMessage.Fields {
- get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.internal__static_google_protobuf_EnumDescriptorProto__FieldAccessorTable; }
+ pbr::MessageDescriptor pb::IMessage.Descriptor {
+ get { return Descriptor; }
}
private bool _frozen = false;
@@ -1991,14 +1905,12 @@ namespace Google.Protobuf.Reflection {
private static readonly pb::MessageParser<EnumValueDescriptorProto> _parser = new pb::MessageParser<EnumValueDescriptorProto>(() => new EnumValueDescriptorProto());
public static pb::MessageParser<EnumValueDescriptorProto> Parser { get { return _parser; } }
- private static readonly string[] _fieldNames = new string[] { "name", "number", "options" };
- private static readonly uint[] _fieldTags = new uint[] { 10, 16, 26 };
public static pbr::MessageDescriptor Descriptor {
get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.Descriptor.MessageTypes[6]; }
}
- pbr::FieldAccessorTable pb::IReflectedMessage.Fields {
- get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.internal__static_google_protobuf_EnumValueDescriptorProto__FieldAccessorTable; }
+ pbr::MessageDescriptor pb::IMessage.Descriptor {
+ get { return Descriptor; }
}
private bool _frozen = false;
@@ -2171,14 +2083,12 @@ namespace Google.Protobuf.Reflection {
private static readonly pb::MessageParser<ServiceDescriptorProto> _parser = new pb::MessageParser<ServiceDescriptorProto>(() => new ServiceDescriptorProto());
public static pb::MessageParser<ServiceDescriptorProto> Parser { get { return _parser; } }
- private static readonly string[] _fieldNames = new string[] { "method", "name", "options" };
- private static readonly uint[] _fieldTags = new uint[] { 18, 10, 26 };
public static pbr::MessageDescriptor Descriptor {
get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.Descriptor.MessageTypes[7]; }
}
- pbr::FieldAccessorTable pb::IReflectedMessage.Fields {
- get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.internal__static_google_protobuf_ServiceDescriptorProto__FieldAccessorTable; }
+ pbr::MessageDescriptor pb::IMessage.Descriptor {
+ get { return Descriptor; }
}
private bool _frozen = false;
@@ -2343,14 +2253,12 @@ namespace Google.Protobuf.Reflection {
private static readonly pb::MessageParser<MethodDescriptorProto> _parser = new pb::MessageParser<MethodDescriptorProto>(() => new MethodDescriptorProto());
public static pb::MessageParser<MethodDescriptorProto> Parser { get { return _parser; } }
- private static readonly string[] _fieldNames = new string[] { "client_streaming", "input_type", "name", "options", "output_type", "server_streaming" };
- private static readonly uint[] _fieldTags = new uint[] { 40, 18, 10, 34, 26, 48 };
public static pbr::MessageDescriptor Descriptor {
get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.Descriptor.MessageTypes[8]; }
}
- pbr::FieldAccessorTable pb::IReflectedMessage.Fields {
- get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.internal__static_google_protobuf_MethodDescriptorProto__FieldAccessorTable; }
+ pbr::MessageDescriptor pb::IMessage.Descriptor {
+ get { return Descriptor; }
}
private bool _frozen = false;
@@ -2604,14 +2512,12 @@ namespace Google.Protobuf.Reflection {
private static readonly pb::MessageParser<FileOptions> _parser = new pb::MessageParser<FileOptions>(() => new FileOptions());
public static pb::MessageParser<FileOptions> Parser { get { return _parser; } }
- private static readonly string[] _fieldNames = new string[] { "cc_enable_arenas", "cc_generic_services", "csharp_namespace", "deprecated", "go_package", "java_generate_equals_and_hash", "java_generic_services", "java_multiple_files", "java_outer_classname", "java_package", "java_string_check_utf8", "objc_class_prefix", "optimize_for", "py_generic_services", "uninterpreted_option" };
- private static readonly uint[] _fieldTags = new uint[] { 248, 128, 298, 184, 90, 160, 136, 80, 66, 10, 216, 290, 72, 144, 7994 };
public static pbr::MessageDescriptor Descriptor {
get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.Descriptor.MessageTypes[9]; }
}
- pbr::FieldAccessorTable pb::IReflectedMessage.Fields {
- get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.internal__static_google_protobuf_FileOptions__FieldAccessorTable; }
+ pbr::MessageDescriptor pb::IMessage.Descriptor {
+ get { return Descriptor; }
}
private bool _frozen = false;
@@ -3105,14 +3011,12 @@ namespace Google.Protobuf.Reflection {
private static readonly pb::MessageParser<MessageOptions> _parser = new pb::MessageParser<MessageOptions>(() => new MessageOptions());
public static pb::MessageParser<MessageOptions> Parser { get { return _parser; } }
- private static readonly string[] _fieldNames = new string[] { "deprecated", "map_entry", "message_set_wire_format", "no_standard_descriptor_accessor", "uninterpreted_option" };
- private static readonly uint[] _fieldTags = new uint[] { 24, 56, 8, 16, 7994 };
public static pbr::MessageDescriptor Descriptor {
get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.Descriptor.MessageTypes[10]; }
}
- pbr::FieldAccessorTable pb::IReflectedMessage.Fields {
- get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.internal__static_google_protobuf_MessageOptions__FieldAccessorTable; }
+ pbr::MessageDescriptor pb::IMessage.Descriptor {
+ get { return Descriptor; }
}
private bool _frozen = false;
@@ -3324,14 +3228,12 @@ namespace Google.Protobuf.Reflection {
private static readonly pb::MessageParser<FieldOptions> _parser = new pb::MessageParser<FieldOptions>(() => new FieldOptions());
public static pb::MessageParser<FieldOptions> Parser { get { return _parser; } }
- private static readonly string[] _fieldNames = new string[] { "ctype", "deprecated", "jstype", "lazy", "packed", "uninterpreted_option", "weak" };
- private static readonly uint[] _fieldTags = new uint[] { 8, 24, 48, 40, 16, 7994, 80 };
public static pbr::MessageDescriptor Descriptor {
get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.Descriptor.MessageTypes[11]; }
}
- pbr::FieldAccessorTable pb::IReflectedMessage.Fields {
- get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.internal__static_google_protobuf_FieldOptions__FieldAccessorTable; }
+ pbr::MessageDescriptor pb::IMessage.Descriptor {
+ get { return Descriptor; }
}
private bool _frozen = false;
@@ -3615,14 +3517,12 @@ namespace Google.Protobuf.Reflection {
private static readonly pb::MessageParser<EnumOptions> _parser = new pb::MessageParser<EnumOptions>(() => new EnumOptions());
public static pb::MessageParser<EnumOptions> Parser { get { return _parser; } }
- private static readonly string[] _fieldNames = new string[] { "allow_alias", "deprecated", "uninterpreted_option" };
- private static readonly uint[] _fieldTags = new uint[] { 16, 24, 7994 };
public static pbr::MessageDescriptor Descriptor {
get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.Descriptor.MessageTypes[12]; }
}
- pbr::FieldAccessorTable pb::IReflectedMessage.Fields {
- get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.internal__static_google_protobuf_EnumOptions__FieldAccessorTable; }
+ pbr::MessageDescriptor pb::IMessage.Descriptor {
+ get { return Descriptor; }
}
private bool _frozen = false;
@@ -3780,14 +3680,12 @@ namespace Google.Protobuf.Reflection {
private static readonly pb::MessageParser<EnumValueOptions> _parser = new pb::MessageParser<EnumValueOptions>(() => new EnumValueOptions());
public static pb::MessageParser<EnumValueOptions> Parser { get { return _parser; } }
- private static readonly string[] _fieldNames = new string[] { "deprecated", "uninterpreted_option" };
- private static readonly uint[] _fieldTags = new uint[] { 8, 7994 };
public static pbr::MessageDescriptor Descriptor {
get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.Descriptor.MessageTypes[13]; }
}
- pbr::FieldAccessorTable pb::IReflectedMessage.Fields {
- get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.internal__static_google_protobuf_EnumValueOptions__FieldAccessorTable; }
+ pbr::MessageDescriptor pb::IMessage.Descriptor {
+ get { return Descriptor; }
}
private bool _frozen = false;
@@ -3918,14 +3816,12 @@ namespace Google.Protobuf.Reflection {
private static readonly pb::MessageParser<ServiceOptions> _parser = new pb::MessageParser<ServiceOptions>(() => new ServiceOptions());
public static pb::MessageParser<ServiceOptions> Parser { get { return _parser; } }
- private static readonly string[] _fieldNames = new string[] { "deprecated", "uninterpreted_option" };
- private static readonly uint[] _fieldTags = new uint[] { 264, 7994 };
public static pbr::MessageDescriptor Descriptor {
get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.Descriptor.MessageTypes[14]; }
}
- pbr::FieldAccessorTable pb::IReflectedMessage.Fields {
- get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.internal__static_google_protobuf_ServiceOptions__FieldAccessorTable; }
+ pbr::MessageDescriptor pb::IMessage.Descriptor {
+ get { return Descriptor; }
}
private bool _frozen = false;
@@ -4056,14 +3952,12 @@ namespace Google.Protobuf.Reflection {
private static readonly pb::MessageParser<MethodOptions> _parser = new pb::MessageParser<MethodOptions>(() => new MethodOptions());
public static pb::MessageParser<MethodOptions> Parser { get { return _parser; } }
- private static readonly string[] _fieldNames = new string[] { "deprecated", "uninterpreted_option" };
- private static readonly uint[] _fieldTags = new uint[] { 264, 7994 };
public static pbr::MessageDescriptor Descriptor {
get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.Descriptor.MessageTypes[15]; }
}
- pbr::FieldAccessorTable pb::IReflectedMessage.Fields {
- get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.internal__static_google_protobuf_MethodOptions__FieldAccessorTable; }
+ pbr::MessageDescriptor pb::IMessage.Descriptor {
+ get { return Descriptor; }
}
private bool _frozen = false;
@@ -4194,14 +4088,12 @@ namespace Google.Protobuf.Reflection {
private static readonly pb::MessageParser<UninterpretedOption> _parser = new pb::MessageParser<UninterpretedOption>(() => new UninterpretedOption());
public static pb::MessageParser<UninterpretedOption> Parser { get { return _parser; } }
- private static readonly string[] _fieldNames = new string[] { "aggregate_value", "double_value", "identifier_value", "name", "negative_int_value", "positive_int_value", "string_value" };
- private static readonly uint[] _fieldTags = new uint[] { 66, 49, 26, 18, 40, 32, 58 };
public static pbr::MessageDescriptor Descriptor {
get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.Descriptor.MessageTypes[16]; }
}
- pbr::FieldAccessorTable pb::IReflectedMessage.Fields {
- get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.internal__static_google_protobuf_UninterpretedOption__FieldAccessorTable; }
+ pbr::MessageDescriptor pb::IMessage.Descriptor {
+ get { return Descriptor; }
}
private bool _frozen = false;
@@ -4468,14 +4360,12 @@ namespace Google.Protobuf.Reflection {
private static readonly pb::MessageParser<NamePart> _parser = new pb::MessageParser<NamePart>(() => new NamePart());
public static pb::MessageParser<NamePart> Parser { get { return _parser; } }
- private static readonly string[] _fieldNames = new string[] { "is_extension", "name_part" };
- private static readonly uint[] _fieldTags = new uint[] { 16, 10 };
public static pbr::MessageDescriptor Descriptor {
get { return global::Google.Protobuf.Reflection.UninterpretedOption.Descriptor.NestedTypes[0]; }
}
- pbr::FieldAccessorTable pb::IReflectedMessage.Fields {
- get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.internal__static_google_protobuf_UninterpretedOption_NamePart__FieldAccessorTable; }
+ pbr::MessageDescriptor pb::IMessage.Descriptor {
+ get { return Descriptor; }
}
private bool _frozen = false;
@@ -4619,14 +4509,12 @@ namespace Google.Protobuf.Reflection {
private static readonly pb::MessageParser<SourceCodeInfo> _parser = new pb::MessageParser<SourceCodeInfo>(() => new SourceCodeInfo());
public static pb::MessageParser<SourceCodeInfo> Parser { get { return _parser; } }
- private static readonly string[] _fieldNames = new string[] { "location" };
- private static readonly uint[] _fieldTags = new uint[] { 10 };
public static pbr::MessageDescriptor Descriptor {
get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.Descriptor.MessageTypes[17]; }
}
- pbr::FieldAccessorTable pb::IReflectedMessage.Fields {
- get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.internal__static_google_protobuf_SourceCodeInfo__FieldAccessorTable; }
+ pbr::MessageDescriptor pb::IMessage.Descriptor {
+ get { return Descriptor; }
}
private bool _frozen = false;
@@ -4731,14 +4619,12 @@ namespace Google.Protobuf.Reflection {
private static readonly pb::MessageParser<Location> _parser = new pb::MessageParser<Location>(() => new Location());
public static pb::MessageParser<Location> Parser { get { return _parser; } }
- private static readonly string[] _fieldNames = new string[] { "leading_comments", "leading_detached_comments", "path", "span", "trailing_comments" };
- private static readonly uint[] _fieldTags = new uint[] { 26, 50, 10, 18, 34 };
public static pbr::MessageDescriptor Descriptor {
get { return global::Google.Protobuf.Reflection.SourceCodeInfo.Descriptor.NestedTypes[0]; }
}
- pbr::FieldAccessorTable pb::IReflectedMessage.Fields {
- get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.internal__static_google_protobuf_SourceCodeInfo_Location__FieldAccessorTable; }
+ pbr::MessageDescriptor pb::IMessage.Descriptor {
+ get { return Descriptor; }
}
private bool _frozen = false;
diff --git a/csharp/src/Google.Protobuf/Reflection/DescriptorUtil.cs b/csharp/src/Google.Protobuf/Reflection/DescriptorUtil.cs
index af31dfb1..f5570fc4 100644
--- a/csharp/src/Google.Protobuf/Reflection/DescriptorUtil.cs
+++ b/csharp/src/Google.Protobuf/Reflection/DescriptorUtil.cs
@@ -50,9 +50,8 @@ namespace Google.Protobuf.Reflection
/// Converts the given array into a read-only list, applying the specified conversion to
/// each input element.
/// </summary>
- internal static IList<TOutput> ConvertAndMakeReadOnly<TInput, TOutput>(IList<TInput> input,
- IndexedConverter<TInput, TOutput>
- converter)
+ internal static IList<TOutput> ConvertAndMakeReadOnly<TInput, TOutput>
+ (IList<TInput> input, IndexedConverter<TInput, TOutput> converter)
{
TOutput[] array = new TOutput[input.Count];
for (int i = 0; i < array.Length; i++)
diff --git a/csharp/src/Google.Protobuf/Reflection/EnumDescriptor.cs b/csharp/src/Google.Protobuf/Reflection/EnumDescriptor.cs
index bf8f8c83..285f26f3 100644
--- a/csharp/src/Google.Protobuf/Reflection/EnumDescriptor.cs
+++ b/csharp/src/Google.Protobuf/Reflection/EnumDescriptor.cs
@@ -30,6 +30,7 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#endregion
+using System;
using System.Collections.Generic;
namespace Google.Protobuf.Reflection
@@ -42,11 +43,13 @@ namespace Google.Protobuf.Reflection
private readonly EnumDescriptorProto proto;
private readonly MessageDescriptor containingType;
private readonly IList<EnumValueDescriptor> values;
+ private readonly Type generatedType;
- internal EnumDescriptor(EnumDescriptorProto proto, FileDescriptor file, MessageDescriptor parent, int index)
+ internal EnumDescriptor(EnumDescriptorProto proto, FileDescriptor file, MessageDescriptor parent, int index, Type generatedType)
: base(file, file.ComputeFullName(parent, proto.Name), index)
{
this.proto = proto;
+ this.generatedType = generatedType;
containingType = parent;
if (proto.Value.Count == 0)
@@ -69,6 +72,11 @@ namespace Google.Protobuf.Reflection
/// </summary>
public override string Name { get { return proto.Name; } }
+ /// <summary>
+ /// The generated type for this enum, or <c>null</c> if the descriptor does not represent a generated type.
+ /// </summary>
+ public Type GeneratedType { get { return generatedType; } }
+
/// <value>
/// If this is a nested type, get the outer descriptor, otherwise null.
/// </value>
diff --git a/csharp/src/Google.Protobuf/Reflection/FieldAccessorBase.cs b/csharp/src/Google.Protobuf/Reflection/FieldAccessorBase.cs
index 39a63b47..0893dc3d 100644
--- a/csharp/src/Google.Protobuf/Reflection/FieldAccessorBase.cs
+++ b/csharp/src/Google.Protobuf/Reflection/FieldAccessorBase.cs
@@ -43,13 +43,8 @@ namespace Google.Protobuf.Reflection
private readonly Func<object, object> getValueDelegate;
private readonly FieldDescriptor descriptor;
- internal FieldAccessorBase(Type type, string propertyName, FieldDescriptor descriptor)
+ internal FieldAccessorBase(PropertyInfo property, FieldDescriptor descriptor)
{
- PropertyInfo property = type.GetProperty(propertyName);
- if (property == null || !property.CanRead)
- {
- throw new ArgumentException("Not all required properties/methods available");
- }
this.descriptor = descriptor;
getValueDelegate = ReflectionUtil.CreateFuncObjectObject(property.GetGetMethod());
}
diff --git a/csharp/src/Google.Protobuf/Reflection/FieldAccessorTable.cs b/csharp/src/Google.Protobuf/Reflection/FieldAccessorTable.cs
deleted file mode 100644
index 24fcbc64..00000000
--- a/csharp/src/Google.Protobuf/Reflection/FieldAccessorTable.cs
+++ /dev/null
@@ -1,97 +0,0 @@
-#region Copyright notice and license
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc. All rights reserved.
-// https://developers.google.com/protocol-buffers/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#endregion
-
-using System;
-using System.Collections.ObjectModel;
-
-namespace Google.Protobuf.Reflection
-{
- /// <summary>
- /// Provides access to fields in generated messages via reflection.
- /// </summary>
- public sealed class FieldAccessorTable
- {
- private readonly ReadOnlyCollection<IFieldAccessor> accessors;
- private readonly ReadOnlyCollection<OneofAccessor> oneofs;
- private readonly MessageDescriptor descriptor;
-
- /// <summary>
- /// Constructs a FieldAccessorTable for a particular message class.
- /// Only one FieldAccessorTable should be constructed per class.
- /// </summary>
- /// <param name="type">The CLR type for the message.</param>
- /// <param name="descriptor">The type's descriptor</param>
- /// <param name="propertyNames">The Pascal-case names of all the field-based properties in the message.</param>
- public FieldAccessorTable(Type type, MessageDescriptor descriptor, string[] propertyNames, string[] oneofPropertyNames)
- {
- this.descriptor = descriptor;
- var accessorsArray = new IFieldAccessor[descriptor.Fields.Count];
- for (int i = 0; i < accessorsArray.Length; i++)
- {
- var field = descriptor.Fields[i];
- var name = propertyNames[i];
- accessorsArray[i] =
- field.IsMap ? new MapFieldAccessor(type, name, field)
- : field.IsRepeated ? new RepeatedFieldAccessor(type, name, field)
- : (IFieldAccessor) new SingleFieldAccessor(type, name, field);
- }
- accessors = new ReadOnlyCollection<IFieldAccessor>(accessorsArray);
- var oneofsArray = new OneofAccessor[descriptor.Oneofs.Count];
- for (int i = 0; i < oneofsArray.Length; i++)
- {
- var oneof = descriptor.Oneofs[i];
- oneofsArray[i] = new OneofAccessor(type, oneofPropertyNames[i], oneof);
- }
- oneofs = new ReadOnlyCollection<OneofAccessor>(oneofsArray);
- }
-
- // TODO: Validate the name here... should possibly make this type a more "general reflection access" type,
- // bearing in mind the oneof parts to come as well.
- /// <summary>
- /// Returns all of the field accessors for the message type.
- /// </summary>
- public ReadOnlyCollection<IFieldAccessor> Accessors { get { return accessors; } }
-
- public ReadOnlyCollection<OneofAccessor> Oneofs { get { return oneofs; } }
-
- // TODO: Review this, as it's easy to get confused between FieldNumber and Index.
- // Currently only used to get an accessor related to a oneof... maybe just make that simpler?
- public IFieldAccessor this[int fieldNumber]
- {
- get
- {
- FieldDescriptor field = descriptor.FindFieldByNumber(fieldNumber);
- return accessors[field.Index];
- }
- }
- }
-} \ No newline at end of file
diff --git a/csharp/src/Google.Protobuf/Reflection/FieldDescriptor.cs b/csharp/src/Google.Protobuf/Reflection/FieldDescriptor.cs
index 3d9d0d75..a8609b8a 100644
--- a/csharp/src/Google.Protobuf/Reflection/FieldDescriptor.cs
+++ b/csharp/src/Google.Protobuf/Reflection/FieldDescriptor.cs
@@ -31,6 +31,7 @@
#endregion
using System;
+using System.Linq;
namespace Google.Protobuf.Reflection
{
@@ -45,9 +46,11 @@ namespace Google.Protobuf.Reflection
private readonly MessageDescriptor containingType;
private readonly OneofDescriptor containingOneof;
private FieldType fieldType;
+ private readonly string propertyName; // Annoyingly, needed in Crosslink.
+ private IFieldAccessor accessor;
internal FieldDescriptor(FieldDescriptorProto proto, FileDescriptor file,
- MessageDescriptor parent, int index)
+ MessageDescriptor parent, int index, string propertyName)
: base(file, file.ComputeFullName(parent, proto.Name), index)
{
this.proto = proto;
@@ -74,6 +77,12 @@ namespace Google.Protobuf.Reflection
}
file.DescriptorPool.AddSymbol(this);
+ // We can't create the accessor until we've cross-linked, unfortunately, as we
+ // may not know whether the type of the field is a map or not. Remember the property name
+ // for later.
+ // We could trust the generated code and check whether the type of the property is
+ // a MapField, but that feels a tad nasty.
+ this.propertyName = propertyName;
}
/// <summary>
@@ -82,6 +91,8 @@ namespace Google.Protobuf.Reflection
public override string Name { get { return proto.Name; } }
internal FieldDescriptorProto Proto { get { return proto; } }
+
+ public IFieldAccessor Accessor { get { return accessor; } }
/// <summary>
/// Maps a field type as included in the .proto file to a FieldType.
@@ -287,6 +298,23 @@ namespace Google.Protobuf.Reflection
{
throw new DescriptorValidationException(this, "MessageSet format is not supported.");
}
+ accessor = CreateAccessor(propertyName);
+ }
+
+ private IFieldAccessor CreateAccessor(string propertyName)
+ {
+ if (containingType.GeneratedType == null || propertyName == null)
+ {
+ return null;
+ }
+ var property = containingType.GeneratedType.GetProperty(propertyName);
+ if (property == null)
+ {
+ throw new DescriptorValidationException(this, "Property " + propertyName + " not found in " + containingType.GeneratedType);
+ }
+ return IsMap ? new MapFieldAccessor(property, this)
+ : IsRepeated ? new RepeatedFieldAccessor(property, this)
+ : (IFieldAccessor) new SingleFieldAccessor(property, this);
}
}
} \ No newline at end of file
diff --git a/csharp/src/Google.Protobuf/Reflection/FileDescriptor.cs b/csharp/src/Google.Protobuf/Reflection/FileDescriptor.cs
index db393480..041d4711 100644
--- a/csharp/src/Google.Protobuf/Reflection/FileDescriptor.cs
+++ b/csharp/src/Google.Protobuf/Reflection/FileDescriptor.cs
@@ -62,7 +62,7 @@ namespace Google.Protobuf.Reflection
get { return proto.Syntax == "proto3" ? ProtoSyntax.Proto3 : ProtoSyntax.Proto2; }
}
- private FileDescriptor(FileDescriptorProto proto, FileDescriptor[] dependencies, DescriptorPool pool, bool allowUnknownDependencies)
+ private FileDescriptor(FileDescriptorProto proto, FileDescriptor[] dependencies, DescriptorPool pool, bool allowUnknownDependencies, GeneratedCodeInfo generatedCodeInfo)
{
this.pool = pool;
this.proto = proto;
@@ -74,11 +74,11 @@ namespace Google.Protobuf.Reflection
messageTypes = DescriptorUtil.ConvertAndMakeReadOnly(proto.MessageType,
(message, index) =>
- new MessageDescriptor(message, this, null, index));
+ new MessageDescriptor(message, this, null, index, generatedCodeInfo == null ? null : generatedCodeInfo.NestedTypes[index]));
enumTypes = DescriptorUtil.ConvertAndMakeReadOnly(proto.EnumType,
(enumType, index) =>
- new EnumDescriptor(enumType, this, null, index));
+ new EnumDescriptor(enumType, this, null, index, generatedCodeInfo == null ? null : generatedCodeInfo.NestedEnums[index]));
services = DescriptorUtil.ConvertAndMakeReadOnly(proto.Service,
(service, index) =>
@@ -253,7 +253,7 @@ namespace Google.Protobuf.Reflection
}
return null;
}
-
+
/// <summary>
/// Builds a FileDescriptor from its protocol buffer representation.
/// </summary>
@@ -262,10 +262,11 @@ namespace Google.Protobuf.Reflection
/// file's dependencies, in the exact order listed in the .proto file. May be null,
/// in which case it is treated as an empty array.</param>
/// <param name="allowUnknownDependencies">Whether unknown dependencies are ignored (true) or cause an exception to be thrown (false).</param>
+ /// <param name="generatedCodeInfo">Reflection information, if any. May be null, specifically for non-generated code.</param>
/// <exception cref="DescriptorValidationException">If <paramref name="proto"/> is not
/// a valid descriptor. This can occur for a number of reasons, such as a field
/// having an undefined type or because two messages were defined with the same name.</exception>
- private static FileDescriptor BuildFrom(FileDescriptorProto proto, FileDescriptor[] dependencies, bool allowUnknownDependencies)
+ private static FileDescriptor BuildFrom(FileDescriptorProto proto, FileDescriptor[] dependencies, bool allowUnknownDependencies, GeneratedCodeInfo generatedCodeInfo)
{
// Building descriptors involves two steps: translating and linking.
// In the translation step (implemented by FileDescriptor's
@@ -282,7 +283,7 @@ namespace Google.Protobuf.Reflection
}
DescriptorPool pool = new DescriptorPool(dependencies);
- FileDescriptor result = new FileDescriptor(proto, dependencies, pool, allowUnknownDependencies);
+ FileDescriptor result = new FileDescriptor(proto, dependencies, pool, allowUnknownDependencies, generatedCodeInfo);
// TODO(jonskeet): Reinstate these checks, or get rid of them entirely. They aren't in the Java code,
// and fail for the CustomOptions test right now. (We get "descriptor.proto" vs "google/protobuf/descriptor.proto".)
@@ -319,8 +320,17 @@ namespace Google.Protobuf.Reflection
}
}
+ /// <summary>
+ /// Creates an instance for generated code.
+ /// </summary>
+ /// <remarks>
+ /// The <paramref name="generatedCodeInfo"/> parameter should be null for descriptors which don't correspond to
+ /// generated types. Otherwise, it should be a <see cref="GeneratedCodeInfo"/> with nested types and nested
+ /// enums corresponding to the types and enums contained within the file descriptor.
+ /// </remarks>
public static FileDescriptor InternalBuildGeneratedFileFrom(byte[] descriptorData,
- FileDescriptor[] dependencies)
+ FileDescriptor[] dependencies,
+ GeneratedCodeInfo generatedCodeInfo)
{
FileDescriptorProto proto;
try
@@ -336,7 +346,7 @@ namespace Google.Protobuf.Reflection
{
// When building descriptors for generated code, we allow unknown
// dependencies by default.
- return BuildFrom(proto, dependencies, true);
+ return BuildFrom(proto, dependencies, true, generatedCodeInfo);
}
catch (DescriptorValidationException e)
{
diff --git a/csharp/src/Google.Protobuf/Reflection/GeneratedCodeInfo.cs b/csharp/src/Google.Protobuf/Reflection/GeneratedCodeInfo.cs
new file mode 100644
index 00000000..8c52cd12
--- /dev/null
+++ b/csharp/src/Google.Protobuf/Reflection/GeneratedCodeInfo.cs
@@ -0,0 +1,66 @@
+using System;
+
+namespace Google.Protobuf.Reflection
+{
+ /// <summary>
+ /// Extra information provided by generated code when initializing a message or file descriptor.
+ /// These are constructed as required, and are not long-lived. Hand-written code should
+ /// never need to use this type.
+ /// </summary>
+ public sealed class GeneratedCodeInfo
+ {
+ private static readonly string[] EmptyNames = new string[0];
+ private static readonly GeneratedCodeInfo[] EmptyCodeInfo = new GeneratedCodeInfo[0];
+
+ /// <summary>
+ /// Irrelevant for file descriptors; the CLR type for the message for message descriptors.
+ /// </summary>
+ public Type ClrType { get; private set; }
+
+ /// <summary>
+ /// Irrelevant for file descriptors; the CLR property names (in message descriptor field order)
+ /// for fields in the message for message descriptors.
+ /// </summary>
+ public string[] PropertyNames { get; private set; }
+
+ /// <summary>
+ /// Irrelevant for file descriptors; the CLR property "base" names (in message descriptor oneof order)
+ /// for oneofs in the message for message descriptors. It is expected that for a oneof name of "Foo",
+ /// there will be a "FooCase" property and a "ClearFoo" method.
+ /// </summary>
+ public string[] OneofNames { get; private set; }
+
+ /// <summary>
+ /// The reflection information for types within this file/message descriptor. Elements may be null
+ /// if there is no corresponding generated type, e.g. for map entry types.
+ /// </summary>
+ public GeneratedCodeInfo[] NestedTypes { get; private set; }
+
+ /// <summary>
+ /// The CLR types for enums within this file/message descriptor.
+ /// </summary>
+ public Type[] NestedEnums { get; private set; }
+
+ /// <summary>
+ /// Creates a GeneratedCodeInfo for a message descriptor, with nested types, nested enums, the CLR type, property names and oneof names.
+ /// Each array parameter may be null, to indicate a lack of values.
+ /// The parameter order is designed to make it feasible to format the generated code readably.
+ /// </summary>
+ public GeneratedCodeInfo(Type clrType, string[] propertyNames, string[] oneofNames, Type[] nestedEnums, GeneratedCodeInfo[] nestedTypes)
+ {
+ NestedTypes = nestedTypes ?? EmptyCodeInfo;
+ NestedEnums = nestedEnums ?? ReflectionUtil.EmptyTypes;
+ ClrType = clrType;
+ PropertyNames = propertyNames ?? EmptyNames;
+ OneofNames = oneofNames ?? EmptyNames;
+ }
+
+ /// <summary>
+ /// Creates a GeneratedCodeInfo for a file descriptor, with only types and enums.
+ /// </summary>
+ public GeneratedCodeInfo(Type[] nestedEnums, GeneratedCodeInfo[] nestedTypes)
+ : this(null, null, null, nestedEnums, nestedTypes)
+ {
+ }
+ }
+} \ No newline at end of file
diff --git a/csharp/src/Google.Protobuf/Reflection/MapFieldAccessor.cs b/csharp/src/Google.Protobuf/Reflection/MapFieldAccessor.cs
index 317fbd8d..6df4c5f0 100644
--- a/csharp/src/Google.Protobuf/Reflection/MapFieldAccessor.cs
+++ b/csharp/src/Google.Protobuf/Reflection/MapFieldAccessor.cs
@@ -32,6 +32,7 @@
using System;
using System.Collections;
+using System.Reflection;
namespace Google.Protobuf.Reflection
{
@@ -40,7 +41,7 @@ namespace Google.Protobuf.Reflection
/// </summary>
internal sealed class MapFieldAccessor : FieldAccessorBase
{
- internal MapFieldAccessor(Type type, string propertyName, FieldDescriptor descriptor) : base(type, propertyName, descriptor)
+ internal MapFieldAccessor(PropertyInfo property, FieldDescriptor descriptor) : base(property, descriptor)
{
}
diff --git a/csharp/src/Google.Protobuf/Reflection/MessageDescriptor.cs b/csharp/src/Google.Protobuf/Reflection/MessageDescriptor.cs
index 1c22c460..b29b4b20 100644
--- a/csharp/src/Google.Protobuf/Reflection/MessageDescriptor.cs
+++ b/csharp/src/Google.Protobuf/Reflection/MessageDescriptor.cs
@@ -30,8 +30,10 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#endregion
+using Google.Protobuf.Collections;
using System;
using System.Collections.Generic;
+using System.Linq;
namespace Google.Protobuf.Reflection
{
@@ -60,31 +62,47 @@ namespace Google.Protobuf.Reflection
private readonly IList<EnumDescriptor> enumTypes;
private readonly IList<FieldDescriptor> fields;
private readonly IList<OneofDescriptor> oneofs;
+ // CLR representation of the type described by this descriptor, if any.
+ private readonly Type generatedType;
+ private IDictionary<int, IFieldAccessor> fieldAccessorsByFieldNumber;
- internal MessageDescriptor(DescriptorProto proto, FileDescriptor file, MessageDescriptor parent, int typeIndex)
+ internal MessageDescriptor(DescriptorProto proto, FileDescriptor file, MessageDescriptor parent, int typeIndex, GeneratedCodeInfo generatedCodeInfo)
: base(file, file.ComputeFullName(parent, proto.Name), typeIndex)
{
this.proto = proto;
- containingType = parent;
-
- oneofs = DescriptorUtil.ConvertAndMakeReadOnly(proto.OneofDecl,
- (oneof, index) =>
- new OneofDescriptor(oneof, file, this, index));
+ generatedType = generatedCodeInfo == null ? null : generatedCodeInfo.ClrType;
- nestedTypes = DescriptorUtil.ConvertAndMakeReadOnly(proto.NestedType,
- (type, index) =>
- new MessageDescriptor(type, file, this, index));
-
- enumTypes = DescriptorUtil.ConvertAndMakeReadOnly(proto.EnumType,
- (type, index) =>
- new EnumDescriptor(type, file, this, index));
+ containingType = parent;
- // TODO(jonskeet): Sort fields first?
- fields = DescriptorUtil.ConvertAndMakeReadOnly(proto.Field,
- (field, index) =>
- new FieldDescriptor(field, file, this, index));
+ oneofs = DescriptorUtil.ConvertAndMakeReadOnly(
+ proto.OneofDecl,
+ (oneof, index) =>
+ new OneofDescriptor(oneof, file, this, index, generatedCodeInfo == null ? null : generatedCodeInfo.OneofNames[index]));
+
+ nestedTypes = DescriptorUtil.ConvertAndMakeReadOnly(
+ proto.NestedType,
+ (type, index) =>
+ new MessageDescriptor(type, file, this, index, generatedCodeInfo == null ? null : generatedCodeInfo.NestedTypes[index]));
+
+ enumTypes = DescriptorUtil.ConvertAndMakeReadOnly(
+ proto.EnumType,
+ (type, index) =>
+ new EnumDescriptor(type, file, this, index, generatedCodeInfo == null ? null : generatedCodeInfo.NestedEnums[index]));
+
+ fields = DescriptorUtil.ConvertAndMakeReadOnly(
+ proto.Field,
+ (field, index) =>
+ new FieldDescriptor(field, file, this, index, generatedCodeInfo == null ? null : generatedCodeInfo.PropertyNames[index]));
file.DescriptorPool.AddSymbol(this);
}
+
+ /// <summary>
+ /// Returns the total number of nested types and enums, recursively.
+ /// </summary>
+ private int CountTotalGeneratedTypes()
+ {
+ return nestedTypes.Sum(nested => nested.CountTotalGeneratedTypes()) + enumTypes.Count;
+ }
/// <summary>
/// The brief name of the descriptor's target.
@@ -94,6 +112,11 @@ namespace Google.Protobuf.Reflection
internal DescriptorProto Proto { get { return proto; } }
/// <summary>
+ /// The generated type for this message, or <c>null</c> if the descriptor does not represent a generated type.
+ /// </summary>
+ public Type GeneratedType { get { return generatedType; } }
+
+ /// <summary>
/// Returns whether this message is one of the "well known types" which may have runtime/protoc support.
/// </summary>
internal bool IsWellKnownType
@@ -142,6 +165,13 @@ namespace Google.Protobuf.Reflection
}
/// <summary>
+ /// Returns a map from field number to accessor.
+ /// TODO: Revisit this. It's mostly in place to make the transition from FieldAccessorTable
+ /// to descriptor-based reflection simple in terms of tests. Work out what we really want.
+ /// </summary>
+ public IDictionary<int, IFieldAccessor> FieldAccessorsByFieldNumber { get { return fieldAccessorsByFieldNumber; } }
+
+ /// <summary>
/// Finds a field by field name.
/// </summary>
/// <param name="name">The unqualified name of the field (e.g. "foo").</param>
@@ -192,6 +222,8 @@ namespace Google.Protobuf.Reflection
{
oneof.CrossLink();
}
- }
+
+ fieldAccessorsByFieldNumber = new ReadOnlyDictionary<int, IFieldAccessor>(fields.ToDictionary(field => field.FieldNumber, field => field.Accessor));
+ }
}
} \ No newline at end of file
diff --git a/csharp/src/Google.Protobuf/Reflection/OneofAccessor.cs b/csharp/src/Google.Protobuf/Reflection/OneofAccessor.cs
index 7a11d36b..20cbea92 100644
--- a/csharp/src/Google.Protobuf/Reflection/OneofAccessor.cs
+++ b/csharp/src/Google.Protobuf/Reflection/OneofAccessor.cs
@@ -44,18 +44,16 @@ namespace Google.Protobuf.Reflection
private readonly Action<object> clearDelegate;
private OneofDescriptor descriptor;
- internal OneofAccessor(Type type, string propertyName, OneofDescriptor descriptor)
+ internal OneofAccessor(PropertyInfo caseProperty, MethodInfo clearMethod, OneofDescriptor descriptor)
{
- PropertyInfo property = type.GetProperty(propertyName + "Case");
- if (property == null || !property.CanRead)
+ if (!caseProperty.CanRead)
{
- throw new ArgumentException("Not all required properties/methods available");
+ throw new ArgumentException("Cannot read from property");
}
this.descriptor = descriptor;
- caseDelegate = ReflectionUtil.CreateFuncObjectT<int>(property.GetGetMethod());
+ caseDelegate = ReflectionUtil.CreateFuncObjectT<int>(caseProperty.GetGetMethod());
this.descriptor = descriptor;
- MethodInfo clearMethod = type.GetMethod("Clear" + propertyName);
clearDelegate = ReflectionUtil.CreateActionObject(clearMethod);
}
diff --git a/csharp/src/Google.Protobuf/Reflection/OneofDescriptor.cs b/csharp/src/Google.Protobuf/Reflection/OneofDescriptor.cs
index e92dc8bb..a79d9de4 100644
--- a/csharp/src/Google.Protobuf/Reflection/OneofDescriptor.cs
+++ b/csharp/src/Google.Protobuf/Reflection/OneofDescriptor.cs
@@ -32,6 +32,7 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
+using System.Linq;
namespace Google.Protobuf.Reflection
{
@@ -40,14 +41,16 @@ namespace Google.Protobuf.Reflection
private readonly OneofDescriptorProto proto;
private MessageDescriptor containingType;
private IList<FieldDescriptor> fields;
+ private readonly OneofAccessor accessor;
- internal OneofDescriptor(OneofDescriptorProto proto, FileDescriptor file, MessageDescriptor parent, int index)
+ internal OneofDescriptor(OneofDescriptorProto proto, FileDescriptor file, MessageDescriptor parent, int index, string clrName)
: base(file, file.ComputeFullName(parent, proto.Name), index)
{
this.proto = proto;
containingType = parent;
file.DescriptorPool.AddSymbol(this);
+ accessor = CreateAccessor(clrName);
}
/// <summary>
@@ -62,6 +65,8 @@ namespace Google.Protobuf.Reflection
public IList<FieldDescriptor> Fields { get { return fields; } }
+ public OneofAccessor Accessor { get { return accessor; } }
+
internal void CrossLink()
{
List<FieldDescriptor> fieldCollection = new List<FieldDescriptor>();
@@ -74,5 +79,25 @@ namespace Google.Protobuf.Reflection
}
fields = new ReadOnlyCollection<FieldDescriptor>(fieldCollection);
}
+
+ private OneofAccessor CreateAccessor(string clrName)
+ {
+ if (containingType.GeneratedType == null || clrName == null)
+ {
+ return null;
+ }
+ var caseProperty = containingType.GeneratedType.GetProperty(clrName + "Case");
+ if (caseProperty == null)
+ {
+ throw new DescriptorValidationException(this, "Property " + clrName + "Case not found in " + containingType.GeneratedType);
+ }
+ var clearMethod = containingType.GeneratedType.GetMethod("Clear" + clrName, ReflectionUtil.EmptyTypes);
+ if (clearMethod == null)
+ {
+ throw new DescriptorValidationException(this, "Method Clear" + clrName + " not found in " + containingType.GeneratedType);
+ }
+
+ return new OneofAccessor(caseProperty, clearMethod, this);
+ }
}
}
diff --git a/csharp/src/Google.Protobuf/Reflection/ReflectionUtil.cs b/csharp/src/Google.Protobuf/Reflection/ReflectionUtil.cs
index d0dc3e8b..5b3cbb36 100644
--- a/csharp/src/Google.Protobuf/Reflection/ReflectionUtil.cs
+++ b/csharp/src/Google.Protobuf/Reflection/ReflectionUtil.cs
@@ -31,6 +31,7 @@
#endregion
using System;
+using System.Collections.Generic;
using System.Linq.Expressions;
using System.Reflection;
@@ -101,6 +102,6 @@ namespace Google.Protobuf.Reflection
Expression castTarget = Expression.Convert(targetParameter, method.DeclaringType);
Expression call = Expression.Call(castTarget, method);
return Expression.Lambda<Action<object>>(call, targetParameter).Compile();
- }
+ }
}
} \ No newline at end of file
diff --git a/csharp/src/Google.Protobuf/Reflection/RepeatedFieldAccessor.cs b/csharp/src/Google.Protobuf/Reflection/RepeatedFieldAccessor.cs
index 0ada7567..acb3c8d5 100644
--- a/csharp/src/Google.Protobuf/Reflection/RepeatedFieldAccessor.cs
+++ b/csharp/src/Google.Protobuf/Reflection/RepeatedFieldAccessor.cs
@@ -32,6 +32,7 @@
using System;
using System.Collections;
+using System.Reflection;
namespace Google.Protobuf.Reflection
{
@@ -40,7 +41,7 @@ namespace Google.Protobuf.Reflection
/// </summary>
internal sealed class RepeatedFieldAccessor : FieldAccessorBase
{
- internal RepeatedFieldAccessor(Type type, string propertyName, FieldDescriptor descriptor) : base(type, propertyName, descriptor)
+ internal RepeatedFieldAccessor(PropertyInfo property, FieldDescriptor descriptor) : base(property, descriptor)
{
}
diff --git a/csharp/src/Google.Protobuf/Reflection/SingleFieldAccessor.cs b/csharp/src/Google.Protobuf/Reflection/SingleFieldAccessor.cs
index 8c24e46e..f00a51ba 100644
--- a/csharp/src/Google.Protobuf/Reflection/SingleFieldAccessor.cs
+++ b/csharp/src/Google.Protobuf/Reflection/SingleFieldAccessor.cs
@@ -48,11 +48,8 @@ namespace Google.Protobuf.Reflection
private readonly Action<object, object> setValueDelegate;
private readonly Action<object> clearDelegate;
- internal SingleFieldAccessor(Type type, string propertyName, FieldDescriptor descriptor) : base(type, propertyName, descriptor)
+ internal SingleFieldAccessor(PropertyInfo property, FieldDescriptor descriptor) : base(property, descriptor)
{
- PropertyInfo property = type.GetProperty(propertyName);
- // We know there *is* such a property, or the base class constructor would have thrown. We should be able to write
- // to it though.
if (!property.CanWrite)
{
throw new ArgumentException("Not all required properties/methods available");