public static void Main(string[] args) { if (args.Contains("--proto")) { var generator = new ProtoBuf.Grpc.Reflection.SchemaGenerator(); var schema = generator.GetSchema <IGatewayService>(); var path = Path.Join(Directory.GetCurrentDirectory(), "protos", "service.proto"); File.WriteAllText(path, schema); Console.WriteLine($"Proto definitions dumped to {path}"); } else { CreateHostBuilder(args).Build().Run(); } }
public async Task StartAsync(CancellationToken aCancellationToken) { Logger.LogInformation($"{nameof(ProtobufGenerationHostedService)} has started."); // TODO automate the generation of these using Reflection var schemaGenerator = new ProtoBuf.Grpc.Reflection.SchemaGenerator { ProtoSyntax = ProtoBuf.Meta.ProtoSyntax.Proto3 }; string schema = schemaGenerator.GetSchema <ISuperheroService>(); System.IO.Directory.CreateDirectory("protos"); System.IO.File.WriteAllText("protos/superherocservice.proto", schema); await Task.CompletedTask; }