Skip to content

Commit 327829f

Browse files
authored
Change order for how FileDescriptors are returned in reflection service. (#153)
- FileDescriptors should be returned with the service first and then all dependencies after. All dependencies should occur after a FileDescriptor. - See grpc/grpc-go#2949 The Java implementation of the reflection service includes the entire transitive closure for a request file, in toplogical order such that a file's dependencies always appear after the file (so the requested file is first, with all of its dependencies after it).
1 parent e7d5887 commit 327829f

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/protobuf-net.Grpc.Reflection/ReflectionService.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,19 +153,19 @@ public int Compare(FileDescriptorProto? left, FileDescriptorProto? right)
153153
{
154154
if (left is null)
155155
{
156-
return right is null ? 0 : -1;
156+
return right is null ? 0 : 1;
157157
}
158158
if (right is null)
159159
{
160-
return 1;
160+
return -1;
161161
}
162162
if (GetTransitiveDependencies(left).Contains(right.Name))
163163
{
164-
return 1;
164+
return -1;
165165
}
166166
if (GetTransitiveDependencies(right).Contains(left.Name))
167167
{
168-
return -1;
168+
return 1;
169169
}
170170

171171
return string.Compare(left.Name, right.Name, StringComparison.Ordinal);

tests/protobuf-net.Grpc.Reflection.Test/ReflectionServiceTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ async IAsyncEnumerable<ServerReflectionRequest> GetRequest()
7474
".ReflectionTest.BclService",
7575
new[]
7676
{
77+
"ReflectionTest.BclService.proto",
7778
"google/protobuf/empty.proto",
78-
"protobuf-net/bcl.proto",
79-
"ReflectionTest.BclService.proto"
79+
"protobuf-net/bcl.proto"
8080
}
8181
,
8282
new[]

0 commit comments

Comments
 (0)