OLD | NEW |
1 #region Copyright notice and license | 1 #region Copyright notice and license |
2 // Protocol Buffers - Google's data interchange format | 2 // Protocol Buffers - Google's data interchange format |
3 // Copyright 2008 Google Inc. All rights reserved. | 3 // Copyright 2008 Google Inc. All rights reserved. |
4 // https://developers.google.com/protocol-buffers/ | 4 // https://developers.google.com/protocol-buffers/ |
5 // | 5 // |
6 // Redistribution and use in source and binary forms, with or without | 6 // Redistribution and use in source and binary forms, with or without |
7 // modification, are permitted provided that the following conditions are | 7 // modification, are permitted provided that the following conditions are |
8 // met: | 8 // met: |
9 // | 9 // |
10 // * Redistributions of source code must retain the above copyright | 10 // * Redistributions of source code must retain the above copyright |
(...skipping 25 matching lines...) Expand all Loading... |
36 | 36 |
37 namespace Google.Protobuf.Reflection | 37 namespace Google.Protobuf.Reflection |
38 { | 38 { |
39 /// <summary> | 39 /// <summary> |
40 /// Describes a .proto file, including everything defined within. | 40 /// Describes a .proto file, including everything defined within. |
41 /// IDescriptor is implemented such that the File property returns this desc
riptor, | 41 /// IDescriptor is implemented such that the File property returns this desc
riptor, |
42 /// and the FullName is the same as the Name. | 42 /// and the FullName is the same as the Name. |
43 /// </summary> | 43 /// </summary> |
44 public sealed class FileDescriptor : IDescriptor | 44 public sealed class FileDescriptor : IDescriptor |
45 { | 45 { |
46 private FileDescriptor(ByteString descriptorData, FileDescriptorProto pr
oto, FileDescriptor[] dependencies, DescriptorPool pool, bool allowUnknownDepend
encies, GeneratedCodeInfo generatedCodeInfo) | 46 private FileDescriptor(ByteString descriptorData, FileDescriptorProto pr
oto, FileDescriptor[] dependencies, DescriptorPool pool, bool allowUnknownDepend
encies, GeneratedClrTypeInfo generatedCodeInfo) |
47 { | 47 { |
48 SerializedData = descriptorData; | 48 SerializedData = descriptorData; |
49 DescriptorPool = pool; | 49 DescriptorPool = pool; |
50 Proto = proto; | 50 Proto = proto; |
51 Dependencies = new ReadOnlyCollection<FileDescriptor>((FileDescripto
r[]) dependencies.Clone()); | 51 Dependencies = new ReadOnlyCollection<FileDescriptor>((FileDescripto
r[]) dependencies.Clone()); |
52 | 52 |
53 PublicDependencies = DeterminePublicDependencies(this, proto, depend
encies, allowUnknownDependencies); | 53 PublicDependencies = DeterminePublicDependencies(this, proto, depend
encies, allowUnknownDependencies); |
54 | 54 |
55 pool.AddPackage(Package, this); | 55 pool.AddPackage(Package, this); |
56 | 56 |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 /// would not necessarily give us this.</param> | 216 /// would not necessarily give us this.</param> |
217 /// <param name="proto">The protocol message form of the FileDescriptor.
</param> | 217 /// <param name="proto">The protocol message form of the FileDescriptor.
</param> |
218 /// <param name="dependencies">FileDescriptors corresponding to all of t
he | 218 /// <param name="dependencies">FileDescriptors corresponding to all of t
he |
219 /// file's dependencies, in the exact order listed in the .proto file. M
ay be null, | 219 /// file's dependencies, in the exact order listed in the .proto file. M
ay be null, |
220 /// in which case it is treated as an empty array.</param> | 220 /// in which case it is treated as an empty array.</param> |
221 /// <param name="allowUnknownDependencies">Whether unknown dependencies
are ignored (true) or cause an exception to be thrown (false).</param> | 221 /// <param name="allowUnknownDependencies">Whether unknown dependencies
are ignored (true) or cause an exception to be thrown (false).</param> |
222 /// <param name="generatedCodeInfo">Details about generated code, for th
e purposes of reflection.</param> | 222 /// <param name="generatedCodeInfo">Details about generated code, for th
e purposes of reflection.</param> |
223 /// <exception cref="DescriptorValidationException">If <paramref name="p
roto"/> is not | 223 /// <exception cref="DescriptorValidationException">If <paramref name="p
roto"/> is not |
224 /// a valid descriptor. This can occur for a number of reasons, such as
a field | 224 /// a valid descriptor. This can occur for a number of reasons, such as
a field |
225 /// having an undefined type or because two messages were defined with t
he same name.</exception> | 225 /// having an undefined type or because two messages were defined with t
he same name.</exception> |
226 private static FileDescriptor BuildFrom(ByteString descriptorData, FileD
escriptorProto proto, FileDescriptor[] dependencies, bool allowUnknownDependenci
es, GeneratedCodeInfo generatedCodeInfo) | 226 private static FileDescriptor BuildFrom(ByteString descriptorData, FileD
escriptorProto proto, FileDescriptor[] dependencies, bool allowUnknownDependenci
es, GeneratedClrTypeInfo generatedCodeInfo) |
227 { | 227 { |
228 // Building descriptors involves two steps: translating and linking. | 228 // Building descriptors involves two steps: translating and linking. |
229 // In the translation step (implemented by FileDescriptor's | 229 // In the translation step (implemented by FileDescriptor's |
230 // constructor), we build an object tree mirroring the | 230 // constructor), we build an object tree mirroring the |
231 // FileDescriptorProto's tree and put all of the descriptors into th
e | 231 // FileDescriptorProto's tree and put all of the descriptors into th
e |
232 // DescriptorPool's lookup tables. In the linking step, we look up
all | 232 // DescriptorPool's lookup tables. In the linking step, we look up
all |
233 // type references in the DescriptorPool, so that, for example, a | 233 // type references in the DescriptorPool, so that, for example, a |
234 // FieldDescriptor for an embedded message contains a pointer direct
ly | 234 // FieldDescriptor for an embedded message contains a pointer direct
ly |
235 // to the Descriptor for that message's type. We also detect undefi
ned | 235 // to the Descriptor for that message's type. We also detect undefi
ned |
236 // types in the linking step. | 236 // types in the linking step. |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 /// Creates a descriptor for generated code. | 284 /// Creates a descriptor for generated code. |
285 /// </summary> | 285 /// </summary> |
286 /// <remarks> | 286 /// <remarks> |
287 /// This method is only designed to be used by the results of generating
code with protoc, | 287 /// This method is only designed to be used by the results of generating
code with protoc, |
288 /// which creates the appropriate dependencies etc. It has to be public
because the generated | 288 /// which creates the appropriate dependencies etc. It has to be public
because the generated |
289 /// code is "external", but should not be called directly by end users. | 289 /// code is "external", but should not be called directly by end users. |
290 /// </remarks> | 290 /// </remarks> |
291 public static FileDescriptor FromGeneratedCode( | 291 public static FileDescriptor FromGeneratedCode( |
292 byte[] descriptorData, | 292 byte[] descriptorData, |
293 FileDescriptor[] dependencies, | 293 FileDescriptor[] dependencies, |
294 GeneratedCodeInfo generatedCodeInfo) | 294 GeneratedClrTypeInfo generatedCodeInfo) |
295 { | 295 { |
296 FileDescriptorProto proto; | 296 FileDescriptorProto proto; |
297 try | 297 try |
298 { | 298 { |
299 proto = FileDescriptorProto.Parser.ParseFrom(descriptorData); | 299 proto = FileDescriptorProto.Parser.ParseFrom(descriptorData); |
300 } | 300 } |
301 catch (InvalidProtocolBufferException e) | 301 catch (InvalidProtocolBufferException e) |
302 { | 302 { |
303 throw new ArgumentException("Failed to parse protocol buffer des
criptor for generated code.", e); | 303 throw new ArgumentException("Failed to parse protocol buffer des
criptor for generated code.", e); |
304 } | 304 } |
(...skipping 30 matching lines...) Expand all Loading... |
335 /// runtime for reflection purposes. The messages are internal to the ru
ntime as they would require | 335 /// runtime for reflection purposes. The messages are internal to the ru
ntime as they would require |
336 /// proto2 semantics for full support, but the file descriptor is availa
ble via this property. The | 336 /// proto2 semantics for full support, but the file descriptor is availa
ble via this property. The |
337 /// C# codegen in protoc automatically uses this property when it detect
s a dependency on <c>descriptor.proto</c>. | 337 /// C# codegen in protoc automatically uses this property when it detect
s a dependency on <c>descriptor.proto</c>. |
338 /// </remarks> | 338 /// </remarks> |
339 /// <value> | 339 /// <value> |
340 /// The file descriptor for <c>descriptor.proto</c>. | 340 /// The file descriptor for <c>descriptor.proto</c>. |
341 /// </value> | 341 /// </value> |
342 public static FileDescriptor DescriptorProtoFileDescriptor { get { retur
n DescriptorReflection.Descriptor; } } | 342 public static FileDescriptor DescriptorProtoFileDescriptor { get { retur
n DescriptorReflection.Descriptor; } } |
343 } | 343 } |
344 } | 344 } |
OLD | NEW |