-
Notifications
You must be signed in to change notification settings - Fork 770
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a recursive parameter to the dotnet-grpc add-files CLI command #2204
base: master
Are you sure you want to change the base?
Conversation
Add a recursive parameter to the dotnet-grpc add-files CLI command. The new parameter will add files in the requested folder recursively. A unit test which verifies the functionality has been added.
@@ -315,7 +315,7 @@ internal string[] GlobReferences(string[] references) | |||
var directoryToSearch = Path.GetPathRoot(reference)!; | |||
var searchPattern = reference.Substring(directoryToSearch.Length); | |||
|
|||
var resolvedFiles = Directory.GetFiles(directoryToSearch, searchPattern); | |||
var resolvedFiles = Directory.GetFiles(directoryToSearch, searchPattern, searchOption); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not a good idea to import all proto files, it's better to go through the proto imports recursively and import the specified files if they exist. It will look like this: we add only the securities.proto
file, the definition of the service, the rest used will be pulled up recursively.
example: securities.proto
syntax = "proto3";
import "proto/fftapi/v1/security.proto";
package grpc.fftapi.v1;
message GetSecuritiesRequest {
}
message GetSecuritiesResult {
repeated proto.fftapi.v1.Security securities = 1;
}
service Securities {
rpc GetSecurities(grpc.fftapi.v1.GetSecuritiesRequest) returns (grpc.fftapi.v1.GetSecuritiesResult);
}
This example is from a real service. The approach that implements recursive directory search not only fails to complete successfully but also generates unnecessary services and types.
When will this PR be merged? Thanks. |
Add a recursive parameter to the dotnet-grpc add-files CLI command.
The new parameter will search the files in the requested folder recursively which enables adding proto references to projects inside multiple sub-folders.
A unit test which verifies the functionality has been added and previous non recursive unit tests were changed.