T1.GrpcProtoGenerator 1.0.2

dotnet add package T1.GrpcProtoGenerator --version 1.0.2
                    
NuGet\Install-Package T1.GrpcProtoGenerator -Version 1.0.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="T1.GrpcProtoGenerator" Version="1.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="T1.GrpcProtoGenerator" Version="1.0.2" />
                    
Directory.Packages.props
<PackageReference Include="T1.GrpcProtoGenerator" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add T1.GrpcProtoGenerator --version 1.0.2
                    
#r "nuget: T1.GrpcProtoGenerator, 1.0.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package T1.GrpcProtoGenerator@1.0.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=T1.GrpcProtoGenerator&version=1.0.2
                    
Install as a Cake Addin
#tool nuget:?package=T1.GrpcProtoGenerator&version=1.0.2
                    
Install as a Cake Tool

T1 gRPC Proto Generator

A C# source generator that creates clean SDK wrappers from .proto files for gRPC services. This tool simplifies gRPC client usage by generating strongly-typed wrapper classes that hide the complexity of gRPC channel management and provide a more intuitive API.

Features

  • 🚀 Automatic Code Generation: Generates client wrapper classes from .proto files at compile time
  • 🎯 Clean API: Provides simplified, strongly-typed methods for gRPC service calls
  • 🔧 Channel Management: Handles gRPC channel lifecycle automatically
  • 📦 Easy Integration: Works as a NuGet package with zero configuration
  • 🛡️ Type Safety: Full IntelliSense support and compile-time type checking
  • Performance: Minimal overhead with efficient code generation

Installation

Install the NuGet package in your project:

dotnet add package T1.GrpcProtoGenerator

Or via Package Manager Console:

Install-Package T1.GrpcProtoGenerator

Usage

  1. Given a .proto file:
syntax = "proto3";

service Greeter {
  rpc SayHello (HelloRequest) returns (HelloReply);
}

message HelloRequest {
  string name = 1;
}

message HelloReply {
  string message = 1;
}
  1. Add .proto files to your project and ensure they are included as <Protobuf> items in your .csproj:
<ItemGroup>
    
    <Protobuf Include="Protos\greet.proto" GrpcServices="Both" ProtoRoot="Protos" />
    <Protobuf Include="Protos\Messages\requests.proto" GrpcServices="None" ProtoRoot="Protos" />
    <Protobuf Include="Protos\Messages\responses.proto" GrpcServices="None" ProtoRoot="Protos" />
    <AdditionalFiles Include="Protos\**\*.proto" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Grpc.AspNetCore" Version="2.64.0"/>
<PackageReference Include="Google.Api.CommonProtos" Version="2.15.0"/>
<PackageReference Include="Grpc.AspNetCore.Web" Version="2.64.0"/>
</ItemGroup>

<ItemGroup>
<Compile Remove="Generated\**" />
</ItemGroup>
  1. Build your project - the source generator will automatically create wrapper classes for your gRPC services.
public class GreeterService : IGreeterGrpcService
{
    public Task<HelloReplyGrpcDto> SayHello(HelloRequestGrpcDto request)
    {
        var response = new HelloReplyGrpcDto
        {
            Message = $"Hello {request.Name}!"
        };
        return Task.FromResult(response);
    }
}   
  1. Use the generated server wrappers:
builder.Services.AddGrpc();
builder.Services.AddScoped<IGreeterGrpcService, GreeterService>();

var app = builder.Build();
// Configure the HTTP request pipeline.
app.MapGrpcService<GreeterNativeGrpcService>();
  1. Use the generated client wrappers:
var services = new ServiceCollection();
// Configure gRPC server settings
services.Configure<GreeterGrpcConfig>(config =>
{
    config.ServerUrl = "https://localhost:7001"; // Your gRPC server address
});
// Register gRPC SDK using auto-generated extension method
services.AddGreeterGrpcSdk();
// Generated wrapper provides a clean, easy-to-use API
var client = sp.GetRequiredService<IGreeterGrpcClient>();
var request = new HelloRequestGrpcDto 
{ 
    Name = "World from Consumer App" 
};
var response = await grpcClient.SayHelloAsync(request);
Console.WriteLine(response.Message);

Generated Code Structure

For each gRPC service in your .proto files, the generator creates:

  • Server wrapper class: {ServiceName}GrpcService
  • Client wrapper class: {ServiceName}GrpcClient
  • Strongly-typed methods: Async methods for each RPC call
  • Channel management: Automatic connection handling
  • Error handling: Proper exception propagation

Configuration

The source generator works with standard gRPC tooling configuration. Make sure your .proto files are properly configured in your project file:

<ItemGroup>
  <Protobuf Include="Protos\**\*.proto" GrpcServices="Client" />
  <PackageReference Include="Grpc.AspNetCore" Version="2.57.0" />
  <PackageReference Include="T1.GrpcProtoGenerator" Version="1.0.0">
    <PrivateAssets>all</PrivateAssets>
    <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
  </PackageReference>
</ItemGroup>

Requirements

  • .NET Standard 2.1 or higher
  • C# 8.0 or higher
  • gRPC tooling (Grpc.Tools package)

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Support

If you encounter any issues or have questions, please open an issue on GitHub.

There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

  • .NETStandard 2.1

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.2 175 9/22/2025

update document