MetaEngine.CSharp.Protobuf.HttpClient.Tool
Protobuf 3 → an idiomatic C# gRPC-Connect client and System.Text.Json record models — HttpClient-based services over Connect-over-HTTP with a typed GrpcException, or binary gRPC clients (Grpc.Net.Client + protobuf-net) via --grpc-binary. Ships as a NuGet library plus a dotnet tool CLI.
Pick your registry
The same generator, published to every ecosystem we support. Install however your project expects.
Drive it from the CLI or programmatically
dotnet tool ships a zero-config CLI. NuGet ships the same generator as a C# fluent API — same options, same output.
After install, point the CLI at your schema. It writes the generated tree to your chosen output directory.
metaengine-protobuf-csharp-httpclient <input> <output> <namespace> [options]Generates an HttpClient gRPC-Connect client (System.Text.Json record models) from Protobuf 3 .proto files, or binary gRPC clients with --grpc-binary. Connect errors are always parsed into a typed GrpcException (gRPC status code + message) — there is no error-handling flag. Install with: dotnet tool install --global MetaEngine.CSharp.Protobuf.HttpClient.Tool
dotnet tool install --global MetaEngine.CSharp.Protobuf.HttpClient.Toolmetaengine-protobuf-csharp-httpclient ./service.proto ./Generated MyApp.Api.Clientmetaengine-protobuf-csharp-httpclient ./service.proto ./Generated MyApp.Api.Client \
--documentation \
--dependency-injectionmetaengine-protobuf-csharp-httpclient ./service.proto ./Generated MyApp.Api.Client \
--bearer-auth \
--retries 3 \
--custom-header X-Tenant-ID=TENANT_IDmetaengine-protobuf-csharp-httpclient ./service.proto ./Generated MyApp.Api.Client \
--grpc-binary \
--cleanEvery knob, documented
Every option is available on the C# fluent API as a method, and most are also exposed as CLI flags. Cross-cutting auth, headers, retries and timeouts apply across frameworks.
C# Output
3WithMiddleware()Generate middleware infrastructure (ApiDelegatingHandler + ServiceCollectionExtensions) so auth / headers ride a DelegatingHandlerWithValidationAnnotations()Emit System.ComponentModel.DataAnnotations attributes on models from protovalidate (buf.validate) constraintsWithMethodNames(Func)Custom method naming rule with access to operation context
Auth · Headers · Resilience
9WithBearerAuth()Bearer token from env var (default API_TOKEN) — adds an Authorization header to all requestsWithBearerAuth(string)Bearer token from a specific env var nameWithBearerAuth(string, string)Bearer token from an env var with a custom header name (e.g. X-Api-Key)WithBasicAuth()HTTP Basic auth from the default env vars (API_USERNAME / API_PASSWORD)WithBasicAuth(string, string)HTTP Basic auth from username + password env vars, sent as a Base64 Authorization headerWithCustomHeader(string, string)Static header read from an env var. Repeatable (e.g. X-Tenant-ID ← TENANT_ID)WithRetries()Retries with exponential backoff (default max 3 attempts, base delay 0.5s, max delay 30s, retry on 429 / 503)WithRetries(int)Retries with a custom max-attempts count (default base 0.5s / max 30s, status 429 / 503)WithRetries(int, double, double, int[])Retries with full custom settings: max attempts, base delay, max delay, and the HTTP status codes that trigger a retry
Protobuf Options
5WithDocumentation()Generate XML doc comments (///) from .proto field and service descriptionsWithDependencyInjection()Generate IServiceCollection extension methods for DI registration of the typed HttpClientsWithGrpcBinary()Generate binary gRPC clients (Grpc.Net.Client + protobuf-net, [ProtoContract] / [ProtoMember] models, GrpcChannel + CallInvoker) instead of Connect-RPC JSON over HttpClientWithTypeFilter(Func)Filter extracted proto types (messages + enums) before registration — only types returning true are generatedWithTypeMapping(string, Type)Override the .NET mapping for a protobuf well-known type by fully-qualified name (e.g. google.protobuf.Timestamp → System.DateTime)
Naming Transformations
3Types(Func)Transform type namesPaths(Func)Transform output pathsFileNames(Func)Transform file names
File Management
5CleanDestination()Clean output directory before generationAlwaysOverwrite()Always overwrite existing filesOnlyWhenModelChanged()Update only when model changesOnlyWhenNew()Write only new files, preserve existingCleanDirectories(...)Clean specific subdirectories
Diagnostics
2Verbose()Enable verbose loggingWithLogger(Action<string>)Route generation log output to a custom sink