Skip to content
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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Kronicaler
Copy link

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.

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.
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Jul 21, 2023

CLA Signed

The committers listed above are authorized under a signed CLA.

@@ -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);
Copy link

@Jecha1917 Jecha1917 Jan 22, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants