public static string GenerateCsCodeForProtoFile(string protoContent) { var f = new FileDescriptorProto(); var errors = new List <Error>(); var t = new StringReader(protoContent); #pragma warning disable 618 f.Parse(t, errors, "someFile"); #pragma warning restore 618 // do some transforms based on the file context var ast = new ProtoFile { PackageName = f.Package, CsNamespace = f.Options?.CsharpNamespace ?? f.Package, Messages = f .MessageTypes .ToArray() .Select(mt => new ProtoMessage { Name = mt.Name }) .ToArray(), Services = f .Services .ToArray() .Select( s => new ProtoService { Name = s.Name, Methods = s.Methods.ToArray() .Select( (m, i) => new ProtoMethod { Index = i, Name = m.Name, InputName = RemovePackageName(m.InputType), OutputName = RemovePackageName(m.OutputType), } ) .ToArray() } ) .ToArray() }; var f1 = Handlebars.Compile(Template.Code); var result = f1(ast); var output = result; return(output);