Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

266
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda