Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

271
Views
ServiceStack Grpc - Generate proto file without invoking types/proto endpoint

I have a .Net Core 3.1 Grpc application created using ServiceStack framework. ServiceStack provides a way to auto-generate .proto files through /types/proto endpoint. It internally invokes GrpcProtoGenerator class to generate .proto file. It also requires AppHost, IHostingEnvironment and other objects to generate it.

However, I want to manually invoke GrpcProtoGenerator class for file generation instead of invoking /types/proto endpoint, but it's throwing an error, saying IHostingEnvironment is null. Is there a way to manually invoke the class by providing all necessary objects?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

A lot of ServiceStack Features especially ServiceStack Services require a fully initialized AppHost. You can checkout at GrpcTests for an example of how to initialize a grpc-enabled AppHost in code, after the AppHost is initialized you should then be able to invoke GrpcProtoGenerator manually.

This is what the /types/proto Service uses to generate the proto for all your gRPC Services:

var typesConfig = NativeTypesMetadata.GetConfig(request);
var metadataTypes = NativeTypesMetadata.GetMetadataTypes(Request, typesConfig);
var proto = new GrpcProtoGenerator(typesConfig).GetCode(metadataTypes, base.Request);
return proto;

The GrpcTests also shows examples of creating a proto for adhoc types:

static string GetServiceProto<T>()
    => GrpcConfig.TypeModel.GetSchema(MetaTypeConfig<T>.GetMetaType().Type, ProtoBuf.Meta.ProtoSyntax.Proto3);

    var schema = GetServiceProto<CustomRequestDto>();
    Assert.AreEqual(@"syntax = ""proto3"";

package ServiceStack.Extensions.Tests;
message CustomRequestDto {
       int32 PageName = 42;
       string Name = 105;
    }
    ", schema);
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!