aboutsummaryrefslogtreecommitdiff
path: root/csharp/src/ProtocolBuffers/Descriptors/FileDescriptor.cs
diff options
context:
space:
mode:
authorJon Skeet <jonskeet@google.com>2015-07-01 17:19:48 +0100
committerJon Skeet <jonskeet@google.com>2015-07-09 08:26:06 +0100
commitaf259b77bf04fcfb68609776cb27f04d289a2c39 (patch)
tree3e5434199a9c59b8556e9267fb9eb7b73211f8c5 /csharp/src/ProtocolBuffers/Descriptors/FileDescriptor.cs
parent5350822b0a923287bc23375a10c2f3cb07cff5fb (diff)
downloadprotobuf-af259b77bf04fcfb68609776cb27f04d289a2c39.tar.gz
protobuf-af259b77bf04fcfb68609776cb27f04d289a2c39.tar.bz2
protobuf-af259b77bf04fcfb68609776cb27f04d289a2c39.zip
Fix descriptor reflection in various ways
- The protos are no longer publicly exposed at all - Oneof detection now works (as we default to -1, not 0) - OneofDescriptor exposes the fields in the oneof - Removed unnecessary code for replacing protos - remnant of extensions - There's now just the non-generic form of IDescriptor
Diffstat (limited to 'csharp/src/ProtocolBuffers/Descriptors/FileDescriptor.cs')
-rw-r--r--csharp/src/ProtocolBuffers/Descriptors/FileDescriptor.cs53
1 files changed, 19 insertions, 34 deletions
diff --git a/csharp/src/ProtocolBuffers/Descriptors/FileDescriptor.cs b/csharp/src/ProtocolBuffers/Descriptors/FileDescriptor.cs
index a6320a31..9d0bdfd3 100644
--- a/csharp/src/ProtocolBuffers/Descriptors/FileDescriptor.cs
+++ b/csharp/src/ProtocolBuffers/Descriptors/FileDescriptor.cs
@@ -43,7 +43,7 @@ namespace Google.Protobuf.Descriptors
/// IDescriptor is implemented such that the File property returns this descriptor,
/// and the FullName is the same as the Name.
/// </summary>
- public sealed class FileDescriptor : IDescriptor<FileDescriptorProto>
+ public sealed class FileDescriptor : IDescriptor
{
private readonly FileDescriptorProto proto;
private readonly IList<MessageDescriptor> messageTypes;
@@ -88,6 +88,22 @@ namespace Google.Protobuf.Descriptors
}
/// <summary>
+ /// Computes the full name of a descriptor within this file, with an optional parent message.
+ /// </summary>
+ internal string ComputeFullName(MessageDescriptor parent, string name)
+ {
+ if (parent != null)
+ {
+ return parent.FullName + "." + name;
+ }
+ if (Package.Length > 0)
+ {
+ return Package + "." + name;
+ }
+ return name;
+ }
+
+ /// <summary>
/// Extracts public dependencies from direct dependencies. This is a static method despite its
/// first parameter, as the value we're in the middle of constructing is only used for exceptions.
/// </summary>
@@ -127,20 +143,12 @@ namespace Google.Protobuf.Descriptors
/// <value>
/// The descriptor in its protocol message representation.
/// </value>
- public FileDescriptorProto Proto
+ internal FileDescriptorProto Proto
{
get { return proto; }
}
/// <value>
- /// The <see cref="DescriptorProtos.FileOptions" /> defined in <c>descriptor.proto</c>.
- /// </value>
- public FileOptions Options
- {
- get { return proto.Options; }
- }
-
- /// <value>
/// The file name.
/// </value>
public string Name
@@ -214,14 +222,6 @@ namespace Google.Protobuf.Descriptors
}
/// <value>
- /// Protocol buffer describing this descriptor.
- /// </value>
- IMessage IDescriptor.Proto
- {
- get { return Proto; }
- }
-
- /// <value>
/// Pool containing symbol descriptors.
/// </value>
internal DescriptorPool DescriptorPool
@@ -255,22 +255,7 @@ namespace Google.Protobuf.Descriptors
}
return null;
}
-
- /// <summary>
- /// Builds a FileDescriptor from its protocol buffer representation.
- /// </summary>
- /// <param name="proto">The protocol message form of the FileDescriptor.</param>
- /// <param name="dependencies">FileDescriptors corresponding to all of the
- /// 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>
- /// <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>
- public static FileDescriptor BuildFrom(FileDescriptorProto proto, FileDescriptor[] dependencies)
- {
- return BuildFrom(proto, dependencies, false);
- }
-
+
/// <summary>
/// Builds a FileDescriptor from its protocol buffer representation.
/// </summary>