{"action":"opened","issue":{"url":"https://api.github.com/repos/grpc/grpc/issues/15913","repository_url":"https://api.github.com/repos/grpc/grpc","labels_url":"https://api.github.com/repos/grpc/grpc/issues/15913/labels{/name}","comments_url":"https://api.github.com/repos/grpc/grpc/issues/15913/comments","events_url":"https://api.github.com/repos/grpc/grpc/issues/15913/events","html_url":"https://github.com/grpc/grpc/issues/15913","id":336829683,"node_id":"MDU6SXNzdWUzMzY4Mjk2ODM=","number":15913,"title":"Add contracts for codegen and move method BindService into ServiceBinder","user":{"login":"m-andrei","id":7547988,"node_id":"MDQ6VXNlcjc1NDc5ODg=","avatar_url":"https://avatars2.githubusercontent.com/u/7547988?v=4","gravatar_id":"","url":"https://api.github.com/users/m-andrei","html_url":"https://github.com/m-andrei","followers_url":"https://api.github.com/users/m-andrei/followers","following_url":"https://api.github.com/users/m-andrei/following{/other_user}","gists_url":"https://api.github.com/users/m-andrei/gists{/gist_id}","starred_url":"https://api.github.com/users/m-andrei/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/m-andrei/subscriptions","organizations_url":"https://api.github.com/users/m-andrei/orgs","repos_url":"https://api.github.com/users/m-andrei/repos","events_url":"https://api.github.com/users/m-andrei/events{/privacy}","received_events_url":"https://api.github.com/users/m-andrei/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-06-29T01:10:06Z","updated_at":"2018-06-29T01:10:06Z","closed_at":null,"author_association":"NONE","body":" \r\n### What version of gRPC and what language are you using?\r\n Proto-3, .net core\r\n \r\n### What operating system (Linux, Windows, …) and version?\r\n n/m\r\n \r\n### What runtime / compiler are you using (e.g. python version or version of gcc)\r\n n/m\r\n \r\n### What did you do?\r\nHello guys, i tried to create some simple extension for .net developers which should help combine asp.net framework code base with grpc libraries.\r\n\r\nFor now i have simple project: \r\nhttps://github.com/m-andrei/grpc-example-for-.net-core\r\nWhich show my purposes, everything perfect except one thing: i can't move it into separate library due to grpc server codegen don't have interface contracts and method BindService stricly tied on codegen implementation. \r\nI offer to add simple interface for Server and move \"BindService\" method into separate class like:\r\n\r\n`\r\n        \r\n    public interface IGrpcService {}\r\n    public interface IGrpcServiceBinder\r\n    {\r\n        ServerServiceDefinition BindService(IGrpcService serviceImpl);\r\n    }\r\n\r\n    //CodeGen then will be like:\r\n    namespace Grpc.Example\r\n    {\r\n        /// <summary>Base class for server-side implementations of Greeter</summary>\r\n        public abstract partial class GreeterBase : IGrpcService\r\n        {\r\n            public virtual Task<HelloReply> SayHello(HelloRequest request, ServerCallContext context)\r\n            {\r\n                throw new RpcException(new Status(StatusCode.Unimplemented, \"\"));\r\n            }\r\n        }\r\n\r\n        //and:\r\n\r\n        public class GreeterBaseBinder : IGrpcServiceBinder\r\n        {\r\n            public ServerServiceDefinition BindService(IGrpcService serviceImpl)\r\n            {\r\n                GreeterBase service = (GreeterBase) serviceImpl;\r\n                return ServerServiceDefinition.CreateBuilder()\r\n                    .AddMethod(__Method_SayHello, service.SayHello).Build();\r\n            }\r\n        }\r\n    }\r\n`\r\nBoth IGrpcService IGrpcServiceBinder should be in Grpc.Core library.\r\nthis will allow everyone to create they own nuget packages and share it.\r\nI believe almost everyone faced with that issue when tried to share they code with other teams in company.\r\n\r\n"}}
{"actor":{"display_login":"m-andrei"}}