Debian Codegraph @

test/distrib/csharp/DistribTest/Program.cs

raw
1 #region Copyright notice and license
2
3 // Copyright 2015 gRPC authors.
4 //
5 // Licensed under the Apache License, Version 2.0 (the "License");
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16
17 #endregion
18
19 using System;
20 using System.Linq;
21 using System.Threading.Tasks;
22 using Grpc.Core;
23 using GrpcCsharpDistribtest.Helloworld;
24
25 namespace TestGrpcPackage
26 {
27 class MainClass
28 {
29 public static void Main(string[] args)
30 {
31 CheckGreeterProtobufCodegenWorks();
32 CheckGreeterGrpcProtobufPluginCodegenWorks();
33 CheckDuplicateProtoFilesAreOk();
34 }
35
36 private static object CheckGreeterProtobufCodegenWorks()
37 {
38 return new HelloRequest { Name = "ABC" };
39 }
40
41 private static object CheckGreeterGrpcProtobufPluginCodegenWorks()
42 {
43 return typeof(GreeterImpl);
44 }
45
46 // Test that codegen works well in case the .csproj has .proto files
47 // of the same name, but under different directories (see #17672).
48 // This method doesn't need to be used, it is enough to check that it builds.
49 private static object CheckDuplicateProtoFilesAreOk()
50 {
51 return new GrpcCsharpDistribtest.DuplicateProto.MessageFromDuplicateProto();
52 }
53 }
54
55 class GreeterImpl : Greeter.GreeterBase
56 {
57 // Server side handler of the SayHello RPC
58 public override Task<HelloReply> SayHello(HelloRequest request, ServerCallContext context)
59 {
60 return Task.FromResult(new HelloReply { Message = "Hello " + request.Name });
61 }
62 }
63 }