Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

265
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda