Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
P
protobuf
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
protobuf
Commits
2093749c
Commit
2093749c
authored
9 years ago
by
Jan Tattermusch
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #718 from jskeet/descriptor-descriptor
Allow public access to descriptor.proto as a dependency.
parents
f818183f
a39ababb
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
2 deletions
+28
-2
FileDescriptor.cs
csharp/src/Google.Protobuf/Reflection/FileDescriptor.cs
+16
-0
csharp_helpers.h
src/google/protobuf/compiler/csharp/csharp_helpers.h
+4
-1
csharp_umbrella_class.cc
src/google/protobuf/compiler/csharp/csharp_umbrella_class.cc
+8
-1
No files found.
csharp/src/Google.Protobuf/Reflection/FileDescriptor.cs
View file @
2093749c
...
...
@@ -368,5 +368,20 @@ namespace Google.Protobuf.Reflection
{
return
"FileDescriptor for "
+
proto
.
Name
;
}
/// <summary>
/// Returns the file descriptor for descriptor.proto.
/// </summary>
/// <remarks>
/// This is used for protos which take a direct dependency on <c>descriptor.proto</c>, typically for
/// annotations. While <c>descriptor.proto</c> is a proto2 file, it is built into the Google.Protobuf
/// runtime for reflection purposes. The messages are internal to the runtime as they would require
/// proto2 semantics for full support, but the file descriptor is available via this property. The
/// C# codegen in protoc automatically uses this property when it detects a dependency on <c>descriptor.proto</c>.
/// </remarks>
/// <value>
/// The file descriptor for <c>descriptor.proto</c>.
/// </value>
public
static
FileDescriptor
DescriptorProtoFileDescriptor
{
get
{
return
DescriptorProtoFile
.
Descriptor
;
}
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/google/protobuf/compiler/csharp/csharp_helpers.h
View file @
2093749c
...
...
@@ -117,7 +117,10 @@ inline bool IsMapEntryMessage(const Descriptor* descriptor) {
inline
bool
IsDescriptorProto
(
const
FileDescriptor
*
descriptor
)
{
// TODO: Do this better! (Currently this depends on a hack in generate_protos.sh to rename
// the file...)
return
descriptor
->
name
()
==
"google/protobuf/descriptor_proto_file.proto"
;
// We need to be able to detect the "normal" name as well, for times that we're just
// depending on descriptor.proto instead of generating it.
return
descriptor
->
name
()
==
"google/protobuf/descriptor_proto_file.proto"
||
descriptor
->
name
()
==
"google/protobuf/descriptor.proto"
;
}
inline
bool
IsWrapperType
(
const
FieldDescriptor
*
descriptor
)
{
...
...
This diff is collapsed.
Click to expand it.
src/google/protobuf/compiler/csharp/csharp_umbrella_class.cc
View file @
2093749c
...
...
@@ -180,10 +180,17 @@ void UmbrellaClassGenerator::WriteDescriptor(io::Printer* printer) {
"descriptor = pbr::FileDescriptor.InternalBuildGeneratedFileFrom(descriptorData,
\n
"
);
printer
->
Print
(
" new pbr::FileDescriptor[] { "
);
for
(
int
i
=
0
;
i
<
file_
->
dependency_count
();
i
++
)
{
printer
->
Print
(
// descriptor.proto is special: we don't allow access to the generated code, but there's
// a separately-exposed property to get at the file descriptor, specifically to allow this
// kind of dependency.
if
(
IsDescriptorProto
(
file_
->
dependency
(
i
)))
{
printer
->
Print
(
"pbr::FileDescriptor.DescriptorProtoFileDescriptor, "
);
}
else
{
printer
->
Print
(
"$full_umbrella_class_name$.Descriptor, "
,
"full_umbrella_class_name"
,
GetUmbrellaClassName
(
file_
->
dependency
(
i
)));
}
}
printer
->
Print
(
"},
\n
"
" new pbr::GeneratedCodeInfo("
);
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment