nikatark
nikatark
CC#
Created by nikatark on 2/27/2025 in #help
Grpc.Tools generating camelCase classes
Hello, I am integrating a Java gRPC service in my .NET application but gRPC.Tools generates camelCase classes I boiled down the proto file to minumum for the example
syntax = "proto3";

package services;

option java_package = "services";
option java_multiple_files = true;

//file content

service ExampleService {
rpc example (exampleRequest) returns (exampleResponse);
}

message exampleRequest {
int32 user_id = 1;
}

message exampleResponse {
int32 status_code = 1;
string message = 2;
}
syntax = "proto3";

package services;

option java_package = "services";
option java_multiple_files = true;

//file content

service ExampleService {
rpc example (exampleRequest) returns (exampleResponse);
}

message exampleRequest {
int32 user_id = 1;
}

message exampleResponse {
int32 status_code = 1;
string message = 2;
}
after building, the exampleRequest class is generated as it was written in the .proto file, and since the file was generated by a java server, its camelCase instead of PascalCase
var channel = GrpcChannel.ForAddress("http://example.com");
var client = new ExampleService.ExampleServiceClient(channel);
var request = new exampleRequest { UserId = 1 };
var channel = GrpcChannel.ForAddress("http://example.com");
var client = new ExampleService.ExampleServiceClient(channel);
var request = new exampleRequest { UserId = 1 };
my .csproj file:
<ItemGroup>
<Protobuf Include="services\exampleService.proto" GrpcServices="Client" />
</ItemGroup>
<ItemGroup>
<Protobuf Include="services\exampleService.proto" GrpcServices="Client" />
</ItemGroup>
Is there any way to force PascalCase names in the generated classes?
8 replies