From f964e772afcbe237cc08e7674e41e381e73a9d75 Mon Sep 17 00:00:00 2001 From: Matt Kwong Date: Thu, 27 Oct 2016 10:45:47 -0700 Subject: [PATCH 01/86] Add --inner_jobs args to run_tests_matrix.py --- tools/run_tests/run_tests_matrix.py | 84 +++++++++++++++++------------ 1 file changed, 51 insertions(+), 33 deletions(-) diff --git a/tools/run_tests/run_tests_matrix.py b/tools/run_tests/run_tests_matrix.py index 21d3dd4a0bc..af24d75236a 100755 --- a/tools/run_tests/run_tests_matrix.py +++ b/tools/run_tests/run_tests_matrix.py @@ -46,16 +46,16 @@ os.chdir(_ROOT) _RUNTESTS_TIMEOUT = 2*60*60 # Number of jobs assigned to each run_tests.py instance -_INNER_JOBS = 2 +_DEFAULT_INNER_JOBS = 2 -def _docker_jobspec(name, runtests_args=[]): +def _docker_jobspec(name, runtests_args=[], inner_jobs=_DEFAULT_INNER_JOBS): """Run a single instance of run_tests.py in a docker container""" test_job = jobset.JobSpec( cmdline=['python', 'tools/run_tests/run_tests.py', '--use_docker', '-t', - '-j', str(_INNER_JOBS), + '-j', str(inner_jobs), '-x', 'report_%s.xml' % name, '--report_suite_name', '%s' % name] + runtests_args, shortname='run_tests_%s' % name, @@ -63,7 +63,7 @@ def _docker_jobspec(name, runtests_args=[]): return test_job -def _workspace_jobspec(name, runtests_args=[], workspace_name=None): +def _workspace_jobspec(name, runtests_args=[], workspace_name=None, inner_jobs=_DEFAULT_INNER_JOBS): """Run a single instance of run_tests.py in a separate workspace""" if not workspace_name: workspace_name = 'workspace_%s' % name @@ -71,7 +71,7 @@ def _workspace_jobspec(name, runtests_args=[], workspace_name=None): test_job = jobset.JobSpec( cmdline=['tools/run_tests/run_tests_in_workspace.sh', '-t', - '-j', str(_INNER_JOBS), + '-j', str(inner_jobs), '-x', '../report_%s.xml' % name, '--report_suite_name', '%s' % name] + runtests_args, environ=env, @@ -82,7 +82,8 @@ def _workspace_jobspec(name, runtests_args=[], workspace_name=None): def _generate_jobs(languages, configs, platforms, arch=None, compiler=None, - labels=[], extra_args=[]): + labels=[], extra_args=[], + inner_jobs=_DEFAULT_INNER_JOBS): result = [] for language in languages: for platform in platforms: @@ -97,60 +98,66 @@ def _generate_jobs(languages, configs, platforms, runtests_args += extra_args if platform == 'linux': - job = _docker_jobspec(name=name, runtests_args=runtests_args) + job = _docker_jobspec(name=name, runtests_args=runtests_args, inner_jobs=inner_jobs) else: - job = _workspace_jobspec(name=name, runtests_args=runtests_args) + job = _workspace_jobspec(name=name, runtests_args=runtests_args, inner_jobs=inner_jobs) job.labels = [platform, config, language] + labels result.append(job) return result -def _create_test_jobs(extra_args=[]): +def _create_test_jobs(extra_args=[], inner_jobs=_DEFAULT_INNER_JOBS): test_jobs = [] # supported on linux only test_jobs += _generate_jobs(languages=['sanity', 'php7'], configs=['dbg', 'opt'], platforms=['linux'], labels=['basictests'], - extra_args=extra_args) - + extra_args=extra_args, + inner_jobs=inner_jobs) + # supported on all platforms. test_jobs += _generate_jobs(languages=['c', 'csharp', 'node', 'python'], configs=['dbg', 'opt'], platforms=['linux', 'macos', 'windows'], labels=['basictests'], - extra_args=extra_args) - + extra_args=extra_args, + inner_jobs=inner_jobs) + # supported on linux and mac. test_jobs += _generate_jobs(languages=['c++', 'ruby', 'php'], configs=['dbg', 'opt'], platforms=['linux', 'macos'], labels=['basictests'], - extra_args=extra_args) - + extra_args=extra_args, + inner_jobs=inner_jobs) + # supported on mac only. test_jobs += _generate_jobs(languages=['objc'], configs=['dbg', 'opt'], platforms=['macos'], labels=['basictests'], - extra_args=extra_args) - + extra_args=extra_args, + inner_jobs=inner_jobs) + # sanitizers test_jobs += _generate_jobs(languages=['c'], configs=['msan', 'asan', 'tsan'], platforms=['linux'], labels=['sanitizers'], - extra_args=extra_args) + extra_args=extra_args, + inner_jobs=inner_jobs) test_jobs += _generate_jobs(languages=['c++'], configs=['asan', 'tsan'], platforms=['linux'], labels=['sanitizers'], - extra_args=extra_args) + extra_args=extra_args, + inner_jobs=inner_jobs) return test_jobs - -def _create_portability_test_jobs(extra_args=[]): + +def _create_portability_test_jobs(extra_args=[], inner_jobs=_DEFAULT_INNER_JOBS): test_jobs = [] # portability C x86 test_jobs += _generate_jobs(languages=['c'], @@ -159,8 +166,9 @@ def _create_portability_test_jobs(extra_args=[]): arch='x86', compiler='default', labels=['portability'], - extra_args=extra_args) - + extra_args=extra_args, + inner_jobs=inner_jobs) + # portability C and C++ on x64 for compiler in ['gcc4.4', 'gcc4.6', 'gcc5.3', 'clang3.5', 'clang3.6', 'clang3.7']: @@ -170,8 +178,9 @@ def _create_portability_test_jobs(extra_args=[]): arch='x64', compiler=compiler, labels=['portability'], - extra_args=extra_args) - + extra_args=extra_args, + inner_jobs=inner_jobs) + # portability C on Windows for arch in ['x86', 'x64']: for compiler in ['vs2013', 'vs2015']: @@ -181,24 +190,27 @@ def _create_portability_test_jobs(extra_args=[]): arch=arch, compiler=compiler, labels=['portability'], - extra_args=extra_args) - + extra_args=extra_args, + inner_jobs=inner_jobs) + test_jobs += _generate_jobs(languages=['python'], configs=['dbg'], platforms=['linux'], arch='default', compiler='python3.4', labels=['portability'], - extra_args=extra_args) - + extra_args=extra_args, + inner_jobs=inner_jobs) + test_jobs += _generate_jobs(languages=['csharp'], configs=['dbg'], platforms=['linux'], arch='default', compiler='coreclr', labels=['portability'], - extra_args=extra_args) - return test_jobs + extra_args=extra_args, + inner_jobs=inner_jobs) + return test_jobs def _allowed_labels(): @@ -212,7 +224,7 @@ def _allowed_labels(): argp = argparse.ArgumentParser(description='Run a matrix of run_tests.py tests.') argp.add_argument('-j', '--jobs', - default=multiprocessing.cpu_count()/_INNER_JOBS, + default=multiprocessing.cpu_count()/_DEFAULT_INNER_JOBS, type=int, help='Number of concurrent run_tests.py instances.') argp.add_argument('-f', '--filter', @@ -241,15 +253,21 @@ argp.add_argument('--base_branch', default='origin/master', type=str, help='Branch that pull request is requesting to merge into') +argp.add_argument('--inner_jobs', + default=_DEFAULT_INNER_JOBS, + type=int, + help='Number of jobs in each run_tests.py instance') args = argp.parse_args() + extra_args = [] if args.build_only: extra_args.append('--build_only') if args.force_default_poller: extra_args.append('--force_default_poller') -all_jobs = _create_test_jobs(extra_args=extra_args) + _create_portability_test_jobs(extra_args=extra_args) +all_jobs = _create_test_jobs(extra_args=extra_args, inner_jobs=args.inner_jobs) + \ + _create_portability_test_jobs(extra_args=extra_args, inner_jobs=args.inner_jobs) jobs = [] for job in all_jobs: From 84be265239bbc1d1313aa5a0a79b724a847ff5f1 Mon Sep 17 00:00:00 2001 From: Alexander Polcyn Date: Thu, 27 Oct 2016 23:52:16 -0700 Subject: [PATCH 02/86] strong name sign csharp nuget builds with dotnet on windows --- src/csharp/Grpc.Auth/project.json | 1 - src/csharp/Grpc.Core.Tests/project.json | 2 - src/csharp/Grpc.Core/project.json | 1 - .../Grpc.Examples.MathClient/project.json | 2 - .../Grpc.Examples.MathServer/project.json | 2 - src/csharp/Grpc.Examples.Tests/project.json | 2 - .../Grpc.HealthCheck.Tests/project.json | 2 - src/csharp/Grpc.HealthCheck/project.json | 1 - .../project.json | 2 - .../project.json | 2 - .../project.json | 2 - .../project.json | 2 - .../Grpc.IntegrationTesting/project.json | 2 - src/csharp/build_packages_dotnetcli.bat | 79 +++++++++++++++++++ .../csharp/Grpc.Auth/project.json.template | 1 - .../csharp/Grpc.Core/project.json.template | 1 - .../Grpc.HealthCheck/project.json.template | 1 - templates/src/csharp/build_options.include | 2 - tools/run_tests/package_targets.py | 11 +-- 19 files changed, 81 insertions(+), 37 deletions(-) create mode 100755 src/csharp/build_packages_dotnetcli.bat diff --git a/src/csharp/Grpc.Auth/project.json b/src/csharp/Grpc.Auth/project.json index 6b0df9045a1..06e76b3b7f7 100644 --- a/src/csharp/Grpc.Auth/project.json +++ b/src/csharp/Grpc.Auth/project.json @@ -15,7 +15,6 @@ "buildOptions": { "define": [ "SIGNED" ], "keyFile": "../keys/Grpc.snk", - "publicSign": true, "xmlDoc": true, "compile": { "includeFiles": [ "../Grpc.Core/Version.cs" ] diff --git a/src/csharp/Grpc.Core.Tests/project.json b/src/csharp/Grpc.Core.Tests/project.json index faf28dcee84..509084a71a6 100644 --- a/src/csharp/Grpc.Core.Tests/project.json +++ b/src/csharp/Grpc.Core.Tests/project.json @@ -7,7 +7,6 @@ "buildOptions": { "define": [ "SIGNED" ], "keyFile": "../keys/Grpc.snk", - "publicSign": true, "xmlDoc": true, "compile": { "includeFiles": [ "../Grpc.Core/Version.cs" ] @@ -26,7 +25,6 @@ "buildOptions": { "define": [ "SIGNED" ], "keyFile": "../keys/Grpc.snk", - "publicSign": true, "xmlDoc": true, "compile": { "includeFiles": [ "../Grpc.Core/Version.cs" ] diff --git a/src/csharp/Grpc.Core/project.json b/src/csharp/Grpc.Core/project.json index 29d35555c07..dabc05ad276 100644 --- a/src/csharp/Grpc.Core/project.json +++ b/src/csharp/Grpc.Core/project.json @@ -27,7 +27,6 @@ "embed": [ "../../../etc/roots.pem" ], "define": [ "SIGNED" ], "keyFile": "../keys/Grpc.snk", - "publicSign": true, "xmlDoc": true }, "dependencies": { diff --git a/src/csharp/Grpc.Examples.MathClient/project.json b/src/csharp/Grpc.Examples.MathClient/project.json index 628f5329661..9a8880b5d42 100644 --- a/src/csharp/Grpc.Examples.MathClient/project.json +++ b/src/csharp/Grpc.Examples.MathClient/project.json @@ -7,7 +7,6 @@ "buildOptions": { "define": [ "SIGNED" ], "keyFile": "../keys/Grpc.snk", - "publicSign": true, "xmlDoc": true, "compile": { "includeFiles": [ "../Grpc.Core/Version.cs" ] @@ -26,7 +25,6 @@ "buildOptions": { "define": [ "SIGNED" ], "keyFile": "../keys/Grpc.snk", - "publicSign": true, "xmlDoc": true, "compile": { "includeFiles": [ "../Grpc.Core/Version.cs" ] diff --git a/src/csharp/Grpc.Examples.MathServer/project.json b/src/csharp/Grpc.Examples.MathServer/project.json index 628f5329661..9a8880b5d42 100644 --- a/src/csharp/Grpc.Examples.MathServer/project.json +++ b/src/csharp/Grpc.Examples.MathServer/project.json @@ -7,7 +7,6 @@ "buildOptions": { "define": [ "SIGNED" ], "keyFile": "../keys/Grpc.snk", - "publicSign": true, "xmlDoc": true, "compile": { "includeFiles": [ "../Grpc.Core/Version.cs" ] @@ -26,7 +25,6 @@ "buildOptions": { "define": [ "SIGNED" ], "keyFile": "../keys/Grpc.snk", - "publicSign": true, "xmlDoc": true, "compile": { "includeFiles": [ "../Grpc.Core/Version.cs" ] diff --git a/src/csharp/Grpc.Examples.Tests/project.json b/src/csharp/Grpc.Examples.Tests/project.json index 0109617e6b5..3e130beeac9 100644 --- a/src/csharp/Grpc.Examples.Tests/project.json +++ b/src/csharp/Grpc.Examples.Tests/project.json @@ -7,7 +7,6 @@ "buildOptions": { "define": [ "SIGNED" ], "keyFile": "../keys/Grpc.snk", - "publicSign": true, "xmlDoc": true, "compile": { "includeFiles": [ "../Grpc.Core/Version.cs" ] @@ -26,7 +25,6 @@ "buildOptions": { "define": [ "SIGNED" ], "keyFile": "../keys/Grpc.snk", - "publicSign": true, "xmlDoc": true, "compile": { "includeFiles": [ "../Grpc.Core/Version.cs" ] diff --git a/src/csharp/Grpc.HealthCheck.Tests/project.json b/src/csharp/Grpc.HealthCheck.Tests/project.json index 66dcd79a397..addc782afe8 100644 --- a/src/csharp/Grpc.HealthCheck.Tests/project.json +++ b/src/csharp/Grpc.HealthCheck.Tests/project.json @@ -7,7 +7,6 @@ "buildOptions": { "define": [ "SIGNED" ], "keyFile": "../keys/Grpc.snk", - "publicSign": true, "xmlDoc": true, "compile": { "includeFiles": [ "../Grpc.Core/Version.cs" ] @@ -26,7 +25,6 @@ "buildOptions": { "define": [ "SIGNED" ], "keyFile": "../keys/Grpc.snk", - "publicSign": true, "xmlDoc": true, "compile": { "includeFiles": [ "../Grpc.Core/Version.cs" ] diff --git a/src/csharp/Grpc.HealthCheck/project.json b/src/csharp/Grpc.HealthCheck/project.json index 62aa361efa2..72ab64a06d5 100644 --- a/src/csharp/Grpc.HealthCheck/project.json +++ b/src/csharp/Grpc.HealthCheck/project.json @@ -15,7 +15,6 @@ "buildOptions": { "define": [ "SIGNED" ], "keyFile": "../keys/Grpc.snk", - "publicSign": true, "xmlDoc": true, "compile": { "includeFiles": [ "../Grpc.Core/Version.cs" ] diff --git a/src/csharp/Grpc.IntegrationTesting.Client/project.json b/src/csharp/Grpc.IntegrationTesting.Client/project.json index 1b900c8af32..ad81cbc48b3 100644 --- a/src/csharp/Grpc.IntegrationTesting.Client/project.json +++ b/src/csharp/Grpc.IntegrationTesting.Client/project.json @@ -7,7 +7,6 @@ "buildOptions": { "define": [ "SIGNED" ], "keyFile": "../keys/Grpc.snk", - "publicSign": true, "xmlDoc": true, "compile": { "includeFiles": [ "../Grpc.Core/Version.cs" ] @@ -29,7 +28,6 @@ "buildOptions": { "define": [ "SIGNED" ], "keyFile": "../keys/Grpc.snk", - "publicSign": true, "xmlDoc": true, "compile": { "includeFiles": [ "../Grpc.Core/Version.cs" ] diff --git a/src/csharp/Grpc.IntegrationTesting.QpsWorker/project.json b/src/csharp/Grpc.IntegrationTesting.QpsWorker/project.json index 1b900c8af32..ad81cbc48b3 100644 --- a/src/csharp/Grpc.IntegrationTesting.QpsWorker/project.json +++ b/src/csharp/Grpc.IntegrationTesting.QpsWorker/project.json @@ -7,7 +7,6 @@ "buildOptions": { "define": [ "SIGNED" ], "keyFile": "../keys/Grpc.snk", - "publicSign": true, "xmlDoc": true, "compile": { "includeFiles": [ "../Grpc.Core/Version.cs" ] @@ -29,7 +28,6 @@ "buildOptions": { "define": [ "SIGNED" ], "keyFile": "../keys/Grpc.snk", - "publicSign": true, "xmlDoc": true, "compile": { "includeFiles": [ "../Grpc.Core/Version.cs" ] diff --git a/src/csharp/Grpc.IntegrationTesting.Server/project.json b/src/csharp/Grpc.IntegrationTesting.Server/project.json index 1b900c8af32..ad81cbc48b3 100644 --- a/src/csharp/Grpc.IntegrationTesting.Server/project.json +++ b/src/csharp/Grpc.IntegrationTesting.Server/project.json @@ -7,7 +7,6 @@ "buildOptions": { "define": [ "SIGNED" ], "keyFile": "../keys/Grpc.snk", - "publicSign": true, "xmlDoc": true, "compile": { "includeFiles": [ "../Grpc.Core/Version.cs" ] @@ -29,7 +28,6 @@ "buildOptions": { "define": [ "SIGNED" ], "keyFile": "../keys/Grpc.snk", - "publicSign": true, "xmlDoc": true, "compile": { "includeFiles": [ "../Grpc.Core/Version.cs" ] diff --git a/src/csharp/Grpc.IntegrationTesting.StressClient/project.json b/src/csharp/Grpc.IntegrationTesting.StressClient/project.json index 1b900c8af32..ad81cbc48b3 100644 --- a/src/csharp/Grpc.IntegrationTesting.StressClient/project.json +++ b/src/csharp/Grpc.IntegrationTesting.StressClient/project.json @@ -7,7 +7,6 @@ "buildOptions": { "define": [ "SIGNED" ], "keyFile": "../keys/Grpc.snk", - "publicSign": true, "xmlDoc": true, "compile": { "includeFiles": [ "../Grpc.Core/Version.cs" ] @@ -29,7 +28,6 @@ "buildOptions": { "define": [ "SIGNED" ], "keyFile": "../keys/Grpc.snk", - "publicSign": true, "xmlDoc": true, "compile": { "includeFiles": [ "../Grpc.Core/Version.cs" ] diff --git a/src/csharp/Grpc.IntegrationTesting/project.json b/src/csharp/Grpc.IntegrationTesting/project.json index 0225abb4148..e47b5953da0 100644 --- a/src/csharp/Grpc.IntegrationTesting/project.json +++ b/src/csharp/Grpc.IntegrationTesting/project.json @@ -7,7 +7,6 @@ "buildOptions": { "define": [ "SIGNED" ], "keyFile": "../keys/Grpc.snk", - "publicSign": true, "xmlDoc": true, "compile": { "includeFiles": [ "../Grpc.Core/Version.cs" ] @@ -29,7 +28,6 @@ "buildOptions": { "define": [ "SIGNED" ], "keyFile": "../keys/Grpc.snk", - "publicSign": true, "xmlDoc": true, "compile": { "includeFiles": [ "../Grpc.Core/Version.cs" ] diff --git a/src/csharp/build_packages_dotnetcli.bat b/src/csharp/build_packages_dotnetcli.bat new file mode 100755 index 00000000000..b0e358fdff9 --- /dev/null +++ b/src/csharp/build_packages_dotnetcli.bat @@ -0,0 +1,79 @@ +@rem Copyright 2016, Google Inc. +@rem All rights reserved. +@rem +@rem Redistribution and use in source and binary forms, with or without +@rem modification, are permitted provided that the following conditions are +@rem met: +@rem +@rem * Redistributions of source code must retain the above copyright +@rem notice, this list of conditions and the following disclaimer. +@rem * Redistributions in binary form must reproduce the above +@rem copyright notice, this list of conditions and the following disclaimer +@rem in the documentation and/or other materials provided with the +@rem distribution. +@rem * Neither the name of Google Inc. nor the names of its +@rem contributors may be used to endorse or promote products derived from +@rem this software without specific prior written permission. +@rem +@rem THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +@rem "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +@rem LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +@rem A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +@rem OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +@rem SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +@rem LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +@rem DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +@rem THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +@rem (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +@rem OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +@rem Current package versions +set VERSION=1.0.1 +set PROTOBUF_VERSION=3.0.0 + +@rem Adjust the location of nuget.exe +set NUGET=C:\nuget\nuget.exe +set DOTNET=C:\dotnet\dotnet.exe + +set -ex + +mkdir -p ..\..\artifacts\ + +@rem Collect the artifacts built by the previous build step if running on Jenkins +@rem TODO(jtattermusch): is there a better way to do this? +xcopy /Y /I ..\..\architecture=x86,language=csharp,platform=windows\artifacts\* nativelibs\windows_x86\ +xcopy /Y /I ..\..\architecture=x64,language=csharp,platform=windows\artifacts\* nativelibs\windows_x64\ +xcopy /Y /I ..\..\architecture=x86,language=csharp,platform=linux\artifacts\* nativelibs\linux_x86\ +xcopy /Y /I ..\..\architecture=x64,language=csharp,platform=linux\artifacts\* nativelibs\linux_x64\ +xcopy /Y /I ..\..\architecture=x86,language=csharp,platform=macos\artifacts\* nativelibs\macosx_x86\ +xcopy /Y /I ..\..\architecture=x64,language=csharp,platform=macos\artifacts\* nativelibs\macosx_x64\ + +@rem Collect protoc artifacts built by the previous build step +xcopy /Y /I ..\..\architecture=x86,language=protoc,platform=windows\artifacts\* protoc_plugins\windows_x86\ +xcopy /Y /I ..\..\architecture=x64,language=protoc,platform=windows\artifacts\* protoc_plugins\windows_x64\ +xcopy /Y /I ..\..\architecture=x86,language=protoc,platform=linux\artifacts\* protoc_plugins\linux_x86\ +xcopy /Y /I ..\..\architecture=x64,language=protoc,platform=linux\artifacts\* protoc_plugins\linux_x64\ +xcopy /Y /I ..\..\architecture=x86,language=protoc,platform=macos\artifacts\* protoc_plugins\macosx_x86\ +xcopy /Y /I ..\..\architecture=x64,language=protoc,platform=macos\artifacts\* protoc_plugins\macosx_x64\ + +%DOTNET% restore . || goto :error + +%DOTNET% pack --configuration Release Grpc.Core\project.json --output ..\..\artifacts || goto :error +%DOTNET% pack --configuration Release Grpc.Auth\project.json --output ..\..\artifacts || goto :error +%DOTNET% pack --configuration Release Grpc.HealthCheck\project.json --output ..\..\artifacts || goto :error + +%NUGET% pack Grpc.nuspec -Version "1.0.1" -OutputDirectory ..\..\artifacts || goto :error +%NUGET% pack Grpc.Tools.nuspec -Version "1.0.1" -OutputDirectory ..\..\artifacts + +@rem copy resulting nuget packages to artifacts directory +xcopy /Y /I *.nupkg ..\..\artifacts\ || goto :error + +@rem create a zipfile with the artifacts as well +powershell -Command "Add-Type -Assembly 'System.IO.Compression.FileSystem'; [System.IO.Compression.ZipFile]::CreateFromDirectory('..\..\artifacts', 'csharp_nugets_windows_dotnetcli.zip');" +xcopy /Y /I csharp_nugets_windows_dotnetcli.zip ..\..\artifacts\ || goto :error + +goto :EOF + +:error +echo Failed! +exit /b %errorlevel% diff --git a/templates/src/csharp/Grpc.Auth/project.json.template b/templates/src/csharp/Grpc.Auth/project.json.template index 939a0c8d280..8bcac1ac740 100644 --- a/templates/src/csharp/Grpc.Auth/project.json.template +++ b/templates/src/csharp/Grpc.Auth/project.json.template @@ -17,7 +17,6 @@ "buildOptions": { "define": [ "SIGNED" ], "keyFile": "../keys/Grpc.snk", - "publicSign": true, "xmlDoc": true, "compile": { "includeFiles": [ "../Grpc.Core/Version.cs" ] diff --git a/templates/src/csharp/Grpc.Core/project.json.template b/templates/src/csharp/Grpc.Core/project.json.template index fcbef536c63..88895e7b6ca 100644 --- a/templates/src/csharp/Grpc.Core/project.json.template +++ b/templates/src/csharp/Grpc.Core/project.json.template @@ -29,7 +29,6 @@ "embed": [ "../../../etc/roots.pem" ], "define": [ "SIGNED" ], "keyFile": "../keys/Grpc.snk", - "publicSign": true, "xmlDoc": true }, "dependencies": { diff --git a/templates/src/csharp/Grpc.HealthCheck/project.json.template b/templates/src/csharp/Grpc.HealthCheck/project.json.template index 46307dda002..cba68940153 100644 --- a/templates/src/csharp/Grpc.HealthCheck/project.json.template +++ b/templates/src/csharp/Grpc.HealthCheck/project.json.template @@ -17,7 +17,6 @@ "buildOptions": { "define": [ "SIGNED" ], "keyFile": "../keys/Grpc.snk", - "publicSign": true, "xmlDoc": true, "compile": { "includeFiles": [ "../Grpc.Core/Version.cs" ] diff --git a/templates/src/csharp/build_options.include b/templates/src/csharp/build_options.include index bda2d760747..9a32b7c6f45 100644 --- a/templates/src/csharp/build_options.include +++ b/templates/src/csharp/build_options.include @@ -10,7 +10,6 @@ "buildOptions": { "define": [ "SIGNED" ], "keyFile": "../keys/Grpc.snk", - "publicSign": true, "xmlDoc": true, "compile": { "includeFiles": [ "../Grpc.Core/Version.cs" ] @@ -34,7 +33,6 @@ "buildOptions": { "define": [ "SIGNED" ], "keyFile": "../keys/Grpc.snk", - "publicSign": true, "xmlDoc": true, "compile": { "includeFiles": [ "../Grpc.Core/Version.cs" ] diff --git a/tools/run_tests/package_targets.py b/tools/run_tests/package_targets.py index 14d30cf06d6..1b66b5d9357 100644 --- a/tools/run_tests/package_targets.py +++ b/tools/run_tests/package_targets.py @@ -81,14 +81,7 @@ class CSharpPackage: self.labels += ['windows'] def pre_build_jobspecs(self): - if 'windows' in self.labels: - return [create_jobspec('prebuild_%s' % self.name, - ['tools\\run_tests\\pre_build_csharp.bat'], - shell=True, - flake_retries=5, - timeout_retries=2)] - else: - return [] + return [] # now using dotnet cli to build all packages def build_jobspec(self): if self.use_dotnet_cli: @@ -98,7 +91,7 @@ class CSharpPackage: 'src/csharp/build_packages_dotnetcli.sh') else: return create_jobspec(self.name, - ['build_packages.bat'], + ['build_packages_dotnetcli.bat'], cwd='src\\csharp', shell=True) From c064ff4e5667282545d23954b90b912da5362799 Mon Sep 17 00:00:00 2001 From: Alex Polcyn Date: Tue, 1 Nov 2016 18:58:56 -0700 Subject: [PATCH 03/86] keep old obsolete csharp package builds but add windows dotnetcli package build. change names of package build targets too --- tools/run_tests/package_targets.py | 40 ++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/tools/run_tests/package_targets.py b/tools/run_tests/package_targets.py index 1b66b5d9357..05183db87cc 100644 --- a/tools/run_tests/package_targets.py +++ b/tools/run_tests/package_targets.py @@ -71,29 +71,52 @@ def create_jobspec(name, cmdline, environ=None, cwd=None, shell=False, class CSharpPackage: """Builds C# nuget packages.""" - def __init__(self, use_dotnet_cli=False): + def __init__(self, linux=False, use_dotnet_cli=True): + self.linux = linux self.use_dotnet_cli = use_dotnet_cli - self.name = 'csharp_package_dotnetcli' if use_dotnet_cli else 'csharp_package' + self.labels = ['package', 'csharp'] + if use_dotnet_cli: - self.labels += ['linux'] + if linux: + self.name = 'csharp_package_dotnetcli_linux' + self.labels += ['linux'] + else: + self.name = 'csharp_package_dotnetcli_windows' + self.labels += ['windows'] else: - self.labels += ['windows'] + # official packages built with dotnet cli rather than nuget pack + self.name = 'csharp_package_obsolete' + self.labels += ['obsolete'] + def pre_build_jobspecs(self): - return [] # now using dotnet cli to build all packages + # The older, obsolete build uses nuget only instead of dotnet cli + if 'obsolete' in self.labels: + return [create_jobspec('prebuild_%s' % self.name, + ['tools\\run_tests\\pre_build_csharp.bat'], + shell=True, + flake_retries=5, + timeout_retries=2)] + else: + return [] def build_jobspec(self): - if self.use_dotnet_cli: + if self.use_dotnet_cli and self.linux: return create_docker_jobspec( self.name, 'tools/dockerfile/test/csharp_coreclr_x64', 'src/csharp/build_packages_dotnetcli.sh') - else: + elif self.use_dotnet_cli: return create_jobspec(self.name, ['build_packages_dotnetcli.bat'], cwd='src\\csharp', shell=True) + else: + return create_jobspec(self.name, + ['build_packages.bat'], + cwd='src\\csharp', + shell=True) def __str__(self): return self.name @@ -170,7 +193,8 @@ class PHPPackage: def targets(): """Gets list of supported targets""" return [CSharpPackage(), - CSharpPackage(use_dotnet_cli=True), + CSharpPackage(linux=True), + CSharpPackage(use_dotnet_cli=False), NodePackage(), RubyPackage(), PythonPackage(), From 660e4b082c4d53bd5fddce2447986de130155e15 Mon Sep 17 00:00:00 2001 From: Alexander Polcyn Date: Thu, 3 Nov 2016 10:15:19 -0700 Subject: [PATCH 04/86] generate partial c# client stubs as partial classes --- src/compiler/csharp_generator.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/compiler/csharp_generator.cc b/src/compiler/csharp_generator.cc index f5a0876cf98..3d4a8cb9c28 100644 --- a/src/compiler/csharp_generator.cc +++ b/src/compiler/csharp_generator.cc @@ -327,7 +327,7 @@ void GenerateClientStub(Printer* out, const ServiceDescriptor *service) { out->Print("/// Client for $servicename$\n", "servicename", GetServiceClassName(service)); out->Print( - "public class $name$ : ClientBase<$name$>\n", + "public partial class $name$ : ClientBase<$name$>\n", "name", GetClientClassName(service)); out->Print("{\n"); out->Indent(); @@ -495,7 +495,7 @@ void GenerateService(Printer* out, const ServiceDescriptor *service, bool generate_client, bool generate_server, bool internal_access) { GenerateDocCommentBody(out, service); - out->Print("$access_level$ static class $classname$\n", "access_level", + out->Print("$access_level$ static partial class $classname$\n", "access_level", GetAccessLevel(internal_access), "classname", GetServiceClassName(service)); out->Print("{\n"); From d09d24d044f3fcf241c429d94c3ca0da32abed43 Mon Sep 17 00:00:00 2001 From: Alexander Polcyn Date: Thu, 3 Nov 2016 10:25:47 -0700 Subject: [PATCH 05/86] regenerate example code with changed c# plugin --- .../helloworld-from-cli/Greeter/Helloworld.cs | 33 ++++++- .../Greeter/HelloworldGrpc.cs | 4 +- .../csharp/helloworld/Greeter/Helloworld.cs | 33 ++++++- .../helloworld/Greeter/HelloworldGrpc.cs | 4 +- .../route_guide/RouteGuide/RouteGuide.cs | 88 +++++++++++++++++-- .../route_guide/RouteGuide/RouteGuideGrpc.cs | 4 +- 6 files changed, 148 insertions(+), 18 deletions(-) diff --git a/examples/csharp/helloworld-from-cli/Greeter/Helloworld.cs b/examples/csharp/helloworld-from-cli/Greeter/Helloworld.cs index 6477b4f35be..d38ac5f26d1 100644 --- a/examples/csharp/helloworld-from-cli/Greeter/Helloworld.cs +++ b/examples/csharp/helloworld-from-cli/Greeter/Helloworld.cs @@ -10,7 +10,6 @@ using scg = global::System.Collections.Generic; namespace Helloworld { /// Holder for reflection information generated from helloworld.proto - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public static partial class HelloworldReflection { #region Descriptor @@ -43,29 +42,34 @@ namespace Helloworld { /// /// The request message containing the user's name. /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class HelloRequest : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new HelloRequest()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::Helloworld.HelloworldReflection.Descriptor.MessageTypes[0]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public HelloRequest() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public HelloRequest(HelloRequest other) : this() { name_ = other.name_; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public HelloRequest Clone() { return new HelloRequest(this); } @@ -73,6 +77,7 @@ namespace Helloworld { /// Field number for the "name" field. public const int NameFieldNumber = 1; private string name_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string Name { get { return name_; } set { @@ -80,10 +85,12 @@ namespace Helloworld { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as HelloRequest); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(HelloRequest other) { if (ReferenceEquals(other, null)) { return false; @@ -95,16 +102,19 @@ namespace Helloworld { return true; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; if (Name.Length != 0) hash ^= Name.GetHashCode(); return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { if (Name.Length != 0) { output.WriteRawTag(10); @@ -112,6 +122,7 @@ namespace Helloworld { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; if (Name.Length != 0) { @@ -120,6 +131,7 @@ namespace Helloworld { return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(HelloRequest other) { if (other == null) { return; @@ -129,6 +141,7 @@ namespace Helloworld { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { @@ -149,29 +162,34 @@ namespace Helloworld { /// /// The response message containing the greetings /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class HelloReply : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new HelloReply()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::Helloworld.HelloworldReflection.Descriptor.MessageTypes[1]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public HelloReply() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public HelloReply(HelloReply other) : this() { message_ = other.message_; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public HelloReply Clone() { return new HelloReply(this); } @@ -179,6 +197,7 @@ namespace Helloworld { /// Field number for the "message" field. public const int MessageFieldNumber = 1; private string message_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string Message { get { return message_; } set { @@ -186,10 +205,12 @@ namespace Helloworld { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as HelloReply); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(HelloReply other) { if (ReferenceEquals(other, null)) { return false; @@ -201,16 +222,19 @@ namespace Helloworld { return true; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; if (Message.Length != 0) hash ^= Message.GetHashCode(); return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { if (Message.Length != 0) { output.WriteRawTag(10); @@ -218,6 +242,7 @@ namespace Helloworld { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; if (Message.Length != 0) { @@ -226,6 +251,7 @@ namespace Helloworld { return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(HelloReply other) { if (other == null) { return; @@ -235,6 +261,7 @@ namespace Helloworld { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { diff --git a/examples/csharp/helloworld-from-cli/Greeter/HelloworldGrpc.cs b/examples/csharp/helloworld-from-cli/Greeter/HelloworldGrpc.cs index 041f5a78d75..297e030a650 100644 --- a/examples/csharp/helloworld-from-cli/Greeter/HelloworldGrpc.cs +++ b/examples/csharp/helloworld-from-cli/Greeter/HelloworldGrpc.cs @@ -41,7 +41,7 @@ namespace Helloworld { /// /// The greeting service definition. /// - public static class Greeter + public static partial class Greeter { static readonly string __ServiceName = "helloworld.Greeter"; @@ -75,7 +75,7 @@ namespace Helloworld { } /// Client for Greeter - public class GreeterClient : ClientBase + public partial class GreeterClient : ClientBase { /// Creates a new client for Greeter /// The channel to use to make remote calls. diff --git a/examples/csharp/helloworld/Greeter/Helloworld.cs b/examples/csharp/helloworld/Greeter/Helloworld.cs index 6477b4f35be..d38ac5f26d1 100644 --- a/examples/csharp/helloworld/Greeter/Helloworld.cs +++ b/examples/csharp/helloworld/Greeter/Helloworld.cs @@ -10,7 +10,6 @@ using scg = global::System.Collections.Generic; namespace Helloworld { /// Holder for reflection information generated from helloworld.proto - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public static partial class HelloworldReflection { #region Descriptor @@ -43,29 +42,34 @@ namespace Helloworld { /// /// The request message containing the user's name. /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class HelloRequest : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new HelloRequest()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::Helloworld.HelloworldReflection.Descriptor.MessageTypes[0]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public HelloRequest() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public HelloRequest(HelloRequest other) : this() { name_ = other.name_; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public HelloRequest Clone() { return new HelloRequest(this); } @@ -73,6 +77,7 @@ namespace Helloworld { /// Field number for the "name" field. public const int NameFieldNumber = 1; private string name_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string Name { get { return name_; } set { @@ -80,10 +85,12 @@ namespace Helloworld { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as HelloRequest); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(HelloRequest other) { if (ReferenceEquals(other, null)) { return false; @@ -95,16 +102,19 @@ namespace Helloworld { return true; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; if (Name.Length != 0) hash ^= Name.GetHashCode(); return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { if (Name.Length != 0) { output.WriteRawTag(10); @@ -112,6 +122,7 @@ namespace Helloworld { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; if (Name.Length != 0) { @@ -120,6 +131,7 @@ namespace Helloworld { return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(HelloRequest other) { if (other == null) { return; @@ -129,6 +141,7 @@ namespace Helloworld { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { @@ -149,29 +162,34 @@ namespace Helloworld { /// /// The response message containing the greetings /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class HelloReply : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new HelloReply()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::Helloworld.HelloworldReflection.Descriptor.MessageTypes[1]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public HelloReply() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public HelloReply(HelloReply other) : this() { message_ = other.message_; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public HelloReply Clone() { return new HelloReply(this); } @@ -179,6 +197,7 @@ namespace Helloworld { /// Field number for the "message" field. public const int MessageFieldNumber = 1; private string message_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string Message { get { return message_; } set { @@ -186,10 +205,12 @@ namespace Helloworld { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as HelloReply); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(HelloReply other) { if (ReferenceEquals(other, null)) { return false; @@ -201,16 +222,19 @@ namespace Helloworld { return true; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; if (Message.Length != 0) hash ^= Message.GetHashCode(); return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { if (Message.Length != 0) { output.WriteRawTag(10); @@ -218,6 +242,7 @@ namespace Helloworld { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; if (Message.Length != 0) { @@ -226,6 +251,7 @@ namespace Helloworld { return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(HelloReply other) { if (other == null) { return; @@ -235,6 +261,7 @@ namespace Helloworld { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { diff --git a/examples/csharp/helloworld/Greeter/HelloworldGrpc.cs b/examples/csharp/helloworld/Greeter/HelloworldGrpc.cs index 041f5a78d75..297e030a650 100644 --- a/examples/csharp/helloworld/Greeter/HelloworldGrpc.cs +++ b/examples/csharp/helloworld/Greeter/HelloworldGrpc.cs @@ -41,7 +41,7 @@ namespace Helloworld { /// /// The greeting service definition. /// - public static class Greeter + public static partial class Greeter { static readonly string __ServiceName = "helloworld.Greeter"; @@ -75,7 +75,7 @@ namespace Helloworld { } /// Client for Greeter - public class GreeterClient : ClientBase + public partial class GreeterClient : ClientBase { /// Creates a new client for Greeter /// The channel to use to make remote calls. diff --git a/examples/csharp/route_guide/RouteGuide/RouteGuide.cs b/examples/csharp/route_guide/RouteGuide/RouteGuide.cs index 446113de9d5..54cb823983e 100644 --- a/examples/csharp/route_guide/RouteGuide/RouteGuide.cs +++ b/examples/csharp/route_guide/RouteGuide/RouteGuide.cs @@ -10,7 +10,6 @@ using scg = global::System.Collections.Generic; namespace Routeguide { /// Holder for reflection information generated from route_guide.proto - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public static partial class RouteGuideReflection { #region Descriptor @@ -59,30 +58,35 @@ namespace Routeguide { /// Latitudes should be in the range +/- 90 degrees and longitude should be in /// the range +/- 180 degrees (inclusive). /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class Point : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Point()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::Routeguide.RouteGuideReflection.Descriptor.MessageTypes[0]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Point() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Point(Point other) : this() { latitude_ = other.latitude_; longitude_ = other.longitude_; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Point Clone() { return new Point(this); } @@ -90,6 +94,7 @@ namespace Routeguide { /// Field number for the "latitude" field. public const int LatitudeFieldNumber = 1; private int latitude_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int Latitude { get { return latitude_; } set { @@ -100,6 +105,7 @@ namespace Routeguide { /// Field number for the "longitude" field. public const int LongitudeFieldNumber = 2; private int longitude_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int Longitude { get { return longitude_; } set { @@ -107,10 +113,12 @@ namespace Routeguide { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as Point); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(Point other) { if (ReferenceEquals(other, null)) { return false; @@ -123,6 +131,7 @@ namespace Routeguide { return true; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; if (Latitude != 0) hash ^= Latitude.GetHashCode(); @@ -130,10 +139,12 @@ namespace Routeguide { return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { if (Latitude != 0) { output.WriteRawTag(8); @@ -145,6 +156,7 @@ namespace Routeguide { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; if (Latitude != 0) { @@ -156,6 +168,7 @@ namespace Routeguide { return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(Point other) { if (other == null) { return; @@ -168,6 +181,7 @@ namespace Routeguide { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { @@ -193,30 +207,35 @@ namespace Routeguide { /// A latitude-longitude rectangle, represented as two diagonally opposite /// points "lo" and "hi". /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class Rectangle : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Rectangle()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::Routeguide.RouteGuideReflection.Descriptor.MessageTypes[1]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Rectangle() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Rectangle(Rectangle other) : this() { Lo = other.lo_ != null ? other.Lo.Clone() : null; Hi = other.hi_ != null ? other.Hi.Clone() : null; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Rectangle Clone() { return new Rectangle(this); } @@ -227,6 +246,7 @@ namespace Routeguide { /// /// One corner of the rectangle. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public global::Routeguide.Point Lo { get { return lo_; } set { @@ -240,6 +260,7 @@ namespace Routeguide { /// /// The other corner of the rectangle. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public global::Routeguide.Point Hi { get { return hi_; } set { @@ -247,10 +268,12 @@ namespace Routeguide { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as Rectangle); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(Rectangle other) { if (ReferenceEquals(other, null)) { return false; @@ -263,6 +286,7 @@ namespace Routeguide { return true; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; if (lo_ != null) hash ^= Lo.GetHashCode(); @@ -270,10 +294,12 @@ namespace Routeguide { return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { if (lo_ != null) { output.WriteRawTag(10); @@ -285,6 +311,7 @@ namespace Routeguide { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; if (lo_ != null) { @@ -296,6 +323,7 @@ namespace Routeguide { return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(Rectangle other) { if (other == null) { return; @@ -314,6 +342,7 @@ namespace Routeguide { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { @@ -346,30 +375,35 @@ namespace Routeguide { /// /// If a feature could not be named, the name is empty. /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class Feature : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Feature()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::Routeguide.RouteGuideReflection.Descriptor.MessageTypes[2]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Feature() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Feature(Feature other) : this() { name_ = other.name_; Location = other.location_ != null ? other.Location.Clone() : null; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Feature Clone() { return new Feature(this); } @@ -380,6 +414,7 @@ namespace Routeguide { /// /// The name of the feature. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string Name { get { return name_; } set { @@ -393,6 +428,7 @@ namespace Routeguide { /// /// The point where the feature is detected. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public global::Routeguide.Point Location { get { return location_; } set { @@ -400,10 +436,12 @@ namespace Routeguide { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as Feature); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(Feature other) { if (ReferenceEquals(other, null)) { return false; @@ -416,6 +454,7 @@ namespace Routeguide { return true; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; if (Name.Length != 0) hash ^= Name.GetHashCode(); @@ -423,10 +462,12 @@ namespace Routeguide { return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { if (Name.Length != 0) { output.WriteRawTag(10); @@ -438,6 +479,7 @@ namespace Routeguide { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; if (Name.Length != 0) { @@ -449,6 +491,7 @@ namespace Routeguide { return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(Feature other) { if (other == null) { return; @@ -464,6 +507,7 @@ namespace Routeguide { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { @@ -491,30 +535,35 @@ namespace Routeguide { /// /// A RouteNote is a message sent while at a given point. /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class RouteNote : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new RouteNote()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::Routeguide.RouteGuideReflection.Descriptor.MessageTypes[3]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public RouteNote() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public RouteNote(RouteNote other) : this() { Location = other.location_ != null ? other.Location.Clone() : null; message_ = other.message_; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public RouteNote Clone() { return new RouteNote(this); } @@ -525,6 +574,7 @@ namespace Routeguide { /// /// The location from which the message is sent. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public global::Routeguide.Point Location { get { return location_; } set { @@ -538,6 +588,7 @@ namespace Routeguide { /// /// The message to be sent. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string Message { get { return message_; } set { @@ -545,10 +596,12 @@ namespace Routeguide { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as RouteNote); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(RouteNote other) { if (ReferenceEquals(other, null)) { return false; @@ -561,6 +614,7 @@ namespace Routeguide { return true; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; if (location_ != null) hash ^= Location.GetHashCode(); @@ -568,10 +622,12 @@ namespace Routeguide { return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { if (location_ != null) { output.WriteRawTag(10); @@ -583,6 +639,7 @@ namespace Routeguide { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; if (location_ != null) { @@ -594,6 +651,7 @@ namespace Routeguide { return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(RouteNote other) { if (other == null) { return; @@ -609,6 +667,7 @@ namespace Routeguide { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { @@ -640,25 +699,29 @@ namespace Routeguide { /// detected features, and the total distance covered as the cumulative sum of /// the distance between each point. /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class RouteSummary : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new RouteSummary()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::Routeguide.RouteGuideReflection.Descriptor.MessageTypes[4]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public RouteSummary() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public RouteSummary(RouteSummary other) : this() { pointCount_ = other.pointCount_; featureCount_ = other.featureCount_; @@ -666,6 +729,7 @@ namespace Routeguide { elapsedTime_ = other.elapsedTime_; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public RouteSummary Clone() { return new RouteSummary(this); } @@ -676,6 +740,7 @@ namespace Routeguide { /// /// The number of points received. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int PointCount { get { return pointCount_; } set { @@ -689,6 +754,7 @@ namespace Routeguide { /// /// The number of known features passed while traversing the route. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int FeatureCount { get { return featureCount_; } set { @@ -702,6 +768,7 @@ namespace Routeguide { /// /// The distance covered in metres. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int Distance { get { return distance_; } set { @@ -715,6 +782,7 @@ namespace Routeguide { /// /// The duration of the traversal in seconds. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int ElapsedTime { get { return elapsedTime_; } set { @@ -722,10 +790,12 @@ namespace Routeguide { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as RouteSummary); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(RouteSummary other) { if (ReferenceEquals(other, null)) { return false; @@ -740,6 +810,7 @@ namespace Routeguide { return true; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; if (PointCount != 0) hash ^= PointCount.GetHashCode(); @@ -749,10 +820,12 @@ namespace Routeguide { return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { if (PointCount != 0) { output.WriteRawTag(8); @@ -772,6 +845,7 @@ namespace Routeguide { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; if (PointCount != 0) { @@ -789,6 +863,7 @@ namespace Routeguide { return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(RouteSummary other) { if (other == null) { return; @@ -807,6 +882,7 @@ namespace Routeguide { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { diff --git a/examples/csharp/route_guide/RouteGuide/RouteGuideGrpc.cs b/examples/csharp/route_guide/RouteGuide/RouteGuideGrpc.cs index eb70c8e2db5..3cca24a9442 100644 --- a/examples/csharp/route_guide/RouteGuide/RouteGuideGrpc.cs +++ b/examples/csharp/route_guide/RouteGuide/RouteGuideGrpc.cs @@ -41,7 +41,7 @@ namespace Routeguide { /// /// Interface exported by the server. /// - public static class RouteGuide + public static partial class RouteGuide { static readonly string __ServiceName = "routeguide.RouteGuide"; @@ -139,7 +139,7 @@ namespace Routeguide { } /// Client for RouteGuide - public class RouteGuideClient : ClientBase + public partial class RouteGuideClient : ClientBase { /// Creates a new client for RouteGuide /// The channel to use to make remote calls. From c75fdea628ce942fadd857b46f1bd9a92d5cc10e Mon Sep 17 00:00:00 2001 From: Alexander Polcyn Date: Thu, 3 Nov 2016 10:32:05 -0700 Subject: [PATCH 06/86] revert code changes to example files generated by only protobuf --- .../helloworld-from-cli/Greeter/Helloworld.cs | 33 +------ .../csharp/helloworld/Greeter/Helloworld.cs | 33 +------ .../route_guide/RouteGuide/RouteGuide.cs | 88 ++----------------- 3 files changed, 12 insertions(+), 142 deletions(-) diff --git a/examples/csharp/helloworld-from-cli/Greeter/Helloworld.cs b/examples/csharp/helloworld-from-cli/Greeter/Helloworld.cs index d38ac5f26d1..6477b4f35be 100644 --- a/examples/csharp/helloworld-from-cli/Greeter/Helloworld.cs +++ b/examples/csharp/helloworld-from-cli/Greeter/Helloworld.cs @@ -10,6 +10,7 @@ using scg = global::System.Collections.Generic; namespace Helloworld { /// Holder for reflection information generated from helloworld.proto + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public static partial class HelloworldReflection { #region Descriptor @@ -42,34 +43,29 @@ namespace Helloworld { /// /// The request message containing the user's name. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class HelloRequest : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new HelloRequest()); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::Helloworld.HelloworldReflection.Descriptor.MessageTypes[0]; } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public HelloRequest() { OnConstruction(); } partial void OnConstruction(); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public HelloRequest(HelloRequest other) : this() { name_ = other.name_; } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public HelloRequest Clone() { return new HelloRequest(this); } @@ -77,7 +73,6 @@ namespace Helloworld { /// Field number for the "name" field. public const int NameFieldNumber = 1; private string name_ = ""; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string Name { get { return name_; } set { @@ -85,12 +80,10 @@ namespace Helloworld { } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as HelloRequest); } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(HelloRequest other) { if (ReferenceEquals(other, null)) { return false; @@ -102,19 +95,16 @@ namespace Helloworld { return true; } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; if (Name.Length != 0) hash ^= Name.GetHashCode(); return hash; } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { if (Name.Length != 0) { output.WriteRawTag(10); @@ -122,7 +112,6 @@ namespace Helloworld { } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; if (Name.Length != 0) { @@ -131,7 +120,6 @@ namespace Helloworld { return size; } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(HelloRequest other) { if (other == null) { return; @@ -141,7 +129,6 @@ namespace Helloworld { } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { @@ -162,34 +149,29 @@ namespace Helloworld { /// /// The response message containing the greetings /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class HelloReply : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new HelloReply()); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::Helloworld.HelloworldReflection.Descriptor.MessageTypes[1]; } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public HelloReply() { OnConstruction(); } partial void OnConstruction(); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public HelloReply(HelloReply other) : this() { message_ = other.message_; } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public HelloReply Clone() { return new HelloReply(this); } @@ -197,7 +179,6 @@ namespace Helloworld { /// Field number for the "message" field. public const int MessageFieldNumber = 1; private string message_ = ""; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string Message { get { return message_; } set { @@ -205,12 +186,10 @@ namespace Helloworld { } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as HelloReply); } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(HelloReply other) { if (ReferenceEquals(other, null)) { return false; @@ -222,19 +201,16 @@ namespace Helloworld { return true; } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; if (Message.Length != 0) hash ^= Message.GetHashCode(); return hash; } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { if (Message.Length != 0) { output.WriteRawTag(10); @@ -242,7 +218,6 @@ namespace Helloworld { } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; if (Message.Length != 0) { @@ -251,7 +226,6 @@ namespace Helloworld { return size; } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(HelloReply other) { if (other == null) { return; @@ -261,7 +235,6 @@ namespace Helloworld { } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { diff --git a/examples/csharp/helloworld/Greeter/Helloworld.cs b/examples/csharp/helloworld/Greeter/Helloworld.cs index d38ac5f26d1..6477b4f35be 100644 --- a/examples/csharp/helloworld/Greeter/Helloworld.cs +++ b/examples/csharp/helloworld/Greeter/Helloworld.cs @@ -10,6 +10,7 @@ using scg = global::System.Collections.Generic; namespace Helloworld { /// Holder for reflection information generated from helloworld.proto + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public static partial class HelloworldReflection { #region Descriptor @@ -42,34 +43,29 @@ namespace Helloworld { /// /// The request message containing the user's name. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class HelloRequest : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new HelloRequest()); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::Helloworld.HelloworldReflection.Descriptor.MessageTypes[0]; } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public HelloRequest() { OnConstruction(); } partial void OnConstruction(); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public HelloRequest(HelloRequest other) : this() { name_ = other.name_; } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public HelloRequest Clone() { return new HelloRequest(this); } @@ -77,7 +73,6 @@ namespace Helloworld { /// Field number for the "name" field. public const int NameFieldNumber = 1; private string name_ = ""; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string Name { get { return name_; } set { @@ -85,12 +80,10 @@ namespace Helloworld { } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as HelloRequest); } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(HelloRequest other) { if (ReferenceEquals(other, null)) { return false; @@ -102,19 +95,16 @@ namespace Helloworld { return true; } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; if (Name.Length != 0) hash ^= Name.GetHashCode(); return hash; } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { if (Name.Length != 0) { output.WriteRawTag(10); @@ -122,7 +112,6 @@ namespace Helloworld { } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; if (Name.Length != 0) { @@ -131,7 +120,6 @@ namespace Helloworld { return size; } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(HelloRequest other) { if (other == null) { return; @@ -141,7 +129,6 @@ namespace Helloworld { } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { @@ -162,34 +149,29 @@ namespace Helloworld { /// /// The response message containing the greetings /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class HelloReply : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new HelloReply()); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::Helloworld.HelloworldReflection.Descriptor.MessageTypes[1]; } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public HelloReply() { OnConstruction(); } partial void OnConstruction(); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public HelloReply(HelloReply other) : this() { message_ = other.message_; } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public HelloReply Clone() { return new HelloReply(this); } @@ -197,7 +179,6 @@ namespace Helloworld { /// Field number for the "message" field. public const int MessageFieldNumber = 1; private string message_ = ""; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string Message { get { return message_; } set { @@ -205,12 +186,10 @@ namespace Helloworld { } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as HelloReply); } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(HelloReply other) { if (ReferenceEquals(other, null)) { return false; @@ -222,19 +201,16 @@ namespace Helloworld { return true; } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; if (Message.Length != 0) hash ^= Message.GetHashCode(); return hash; } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { if (Message.Length != 0) { output.WriteRawTag(10); @@ -242,7 +218,6 @@ namespace Helloworld { } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; if (Message.Length != 0) { @@ -251,7 +226,6 @@ namespace Helloworld { return size; } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(HelloReply other) { if (other == null) { return; @@ -261,7 +235,6 @@ namespace Helloworld { } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { diff --git a/examples/csharp/route_guide/RouteGuide/RouteGuide.cs b/examples/csharp/route_guide/RouteGuide/RouteGuide.cs index 54cb823983e..446113de9d5 100644 --- a/examples/csharp/route_guide/RouteGuide/RouteGuide.cs +++ b/examples/csharp/route_guide/RouteGuide/RouteGuide.cs @@ -10,6 +10,7 @@ using scg = global::System.Collections.Generic; namespace Routeguide { /// Holder for reflection information generated from route_guide.proto + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public static partial class RouteGuideReflection { #region Descriptor @@ -58,35 +59,30 @@ namespace Routeguide { /// Latitudes should be in the range +/- 90 degrees and longitude should be in /// the range +/- 180 degrees (inclusive). /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class Point : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Point()); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::Routeguide.RouteGuideReflection.Descriptor.MessageTypes[0]; } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Point() { OnConstruction(); } partial void OnConstruction(); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Point(Point other) : this() { latitude_ = other.latitude_; longitude_ = other.longitude_; } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Point Clone() { return new Point(this); } @@ -94,7 +90,6 @@ namespace Routeguide { /// Field number for the "latitude" field. public const int LatitudeFieldNumber = 1; private int latitude_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int Latitude { get { return latitude_; } set { @@ -105,7 +100,6 @@ namespace Routeguide { /// Field number for the "longitude" field. public const int LongitudeFieldNumber = 2; private int longitude_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int Longitude { get { return longitude_; } set { @@ -113,12 +107,10 @@ namespace Routeguide { } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as Point); } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(Point other) { if (ReferenceEquals(other, null)) { return false; @@ -131,7 +123,6 @@ namespace Routeguide { return true; } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; if (Latitude != 0) hash ^= Latitude.GetHashCode(); @@ -139,12 +130,10 @@ namespace Routeguide { return hash; } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { if (Latitude != 0) { output.WriteRawTag(8); @@ -156,7 +145,6 @@ namespace Routeguide { } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; if (Latitude != 0) { @@ -168,7 +156,6 @@ namespace Routeguide { return size; } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(Point other) { if (other == null) { return; @@ -181,7 +168,6 @@ namespace Routeguide { } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { @@ -207,35 +193,30 @@ namespace Routeguide { /// A latitude-longitude rectangle, represented as two diagonally opposite /// points "lo" and "hi". /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class Rectangle : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Rectangle()); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::Routeguide.RouteGuideReflection.Descriptor.MessageTypes[1]; } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Rectangle() { OnConstruction(); } partial void OnConstruction(); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Rectangle(Rectangle other) : this() { Lo = other.lo_ != null ? other.Lo.Clone() : null; Hi = other.hi_ != null ? other.Hi.Clone() : null; } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Rectangle Clone() { return new Rectangle(this); } @@ -246,7 +227,6 @@ namespace Routeguide { /// /// One corner of the rectangle. /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public global::Routeguide.Point Lo { get { return lo_; } set { @@ -260,7 +240,6 @@ namespace Routeguide { /// /// The other corner of the rectangle. /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public global::Routeguide.Point Hi { get { return hi_; } set { @@ -268,12 +247,10 @@ namespace Routeguide { } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as Rectangle); } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(Rectangle other) { if (ReferenceEquals(other, null)) { return false; @@ -286,7 +263,6 @@ namespace Routeguide { return true; } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; if (lo_ != null) hash ^= Lo.GetHashCode(); @@ -294,12 +270,10 @@ namespace Routeguide { return hash; } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { if (lo_ != null) { output.WriteRawTag(10); @@ -311,7 +285,6 @@ namespace Routeguide { } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; if (lo_ != null) { @@ -323,7 +296,6 @@ namespace Routeguide { return size; } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(Rectangle other) { if (other == null) { return; @@ -342,7 +314,6 @@ namespace Routeguide { } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { @@ -375,35 +346,30 @@ namespace Routeguide { /// /// If a feature could not be named, the name is empty. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class Feature : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Feature()); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::Routeguide.RouteGuideReflection.Descriptor.MessageTypes[2]; } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Feature() { OnConstruction(); } partial void OnConstruction(); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Feature(Feature other) : this() { name_ = other.name_; Location = other.location_ != null ? other.Location.Clone() : null; } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Feature Clone() { return new Feature(this); } @@ -414,7 +380,6 @@ namespace Routeguide { /// /// The name of the feature. /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string Name { get { return name_; } set { @@ -428,7 +393,6 @@ namespace Routeguide { /// /// The point where the feature is detected. /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public global::Routeguide.Point Location { get { return location_; } set { @@ -436,12 +400,10 @@ namespace Routeguide { } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as Feature); } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(Feature other) { if (ReferenceEquals(other, null)) { return false; @@ -454,7 +416,6 @@ namespace Routeguide { return true; } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; if (Name.Length != 0) hash ^= Name.GetHashCode(); @@ -462,12 +423,10 @@ namespace Routeguide { return hash; } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { if (Name.Length != 0) { output.WriteRawTag(10); @@ -479,7 +438,6 @@ namespace Routeguide { } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; if (Name.Length != 0) { @@ -491,7 +449,6 @@ namespace Routeguide { return size; } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(Feature other) { if (other == null) { return; @@ -507,7 +464,6 @@ namespace Routeguide { } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { @@ -535,35 +491,30 @@ namespace Routeguide { /// /// A RouteNote is a message sent while at a given point. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class RouteNote : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new RouteNote()); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::Routeguide.RouteGuideReflection.Descriptor.MessageTypes[3]; } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public RouteNote() { OnConstruction(); } partial void OnConstruction(); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public RouteNote(RouteNote other) : this() { Location = other.location_ != null ? other.Location.Clone() : null; message_ = other.message_; } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public RouteNote Clone() { return new RouteNote(this); } @@ -574,7 +525,6 @@ namespace Routeguide { /// /// The location from which the message is sent. /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public global::Routeguide.Point Location { get { return location_; } set { @@ -588,7 +538,6 @@ namespace Routeguide { /// /// The message to be sent. /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string Message { get { return message_; } set { @@ -596,12 +545,10 @@ namespace Routeguide { } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as RouteNote); } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(RouteNote other) { if (ReferenceEquals(other, null)) { return false; @@ -614,7 +561,6 @@ namespace Routeguide { return true; } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; if (location_ != null) hash ^= Location.GetHashCode(); @@ -622,12 +568,10 @@ namespace Routeguide { return hash; } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { if (location_ != null) { output.WriteRawTag(10); @@ -639,7 +583,6 @@ namespace Routeguide { } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; if (location_ != null) { @@ -651,7 +594,6 @@ namespace Routeguide { return size; } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(RouteNote other) { if (other == null) { return; @@ -667,7 +609,6 @@ namespace Routeguide { } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { @@ -699,29 +640,25 @@ namespace Routeguide { /// detected features, and the total distance covered as the cumulative sum of /// the distance between each point. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class RouteSummary : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new RouteSummary()); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::Routeguide.RouteGuideReflection.Descriptor.MessageTypes[4]; } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public RouteSummary() { OnConstruction(); } partial void OnConstruction(); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public RouteSummary(RouteSummary other) : this() { pointCount_ = other.pointCount_; featureCount_ = other.featureCount_; @@ -729,7 +666,6 @@ namespace Routeguide { elapsedTime_ = other.elapsedTime_; } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public RouteSummary Clone() { return new RouteSummary(this); } @@ -740,7 +676,6 @@ namespace Routeguide { /// /// The number of points received. /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int PointCount { get { return pointCount_; } set { @@ -754,7 +689,6 @@ namespace Routeguide { /// /// The number of known features passed while traversing the route. /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int FeatureCount { get { return featureCount_; } set { @@ -768,7 +702,6 @@ namespace Routeguide { /// /// The distance covered in metres. /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int Distance { get { return distance_; } set { @@ -782,7 +715,6 @@ namespace Routeguide { /// /// The duration of the traversal in seconds. /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int ElapsedTime { get { return elapsedTime_; } set { @@ -790,12 +722,10 @@ namespace Routeguide { } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as RouteSummary); } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(RouteSummary other) { if (ReferenceEquals(other, null)) { return false; @@ -810,7 +740,6 @@ namespace Routeguide { return true; } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; if (PointCount != 0) hash ^= PointCount.GetHashCode(); @@ -820,12 +749,10 @@ namespace Routeguide { return hash; } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { if (PointCount != 0) { output.WriteRawTag(8); @@ -845,7 +772,6 @@ namespace Routeguide { } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; if (PointCount != 0) { @@ -863,7 +789,6 @@ namespace Routeguide { return size; } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(RouteSummary other) { if (other == null) { return; @@ -882,7 +807,6 @@ namespace Routeguide { } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { From 333658177dad958fd3b4402d2b351b3a4c4b170f Mon Sep 17 00:00:00 2001 From: Alexander Polcyn Date: Thu, 3 Nov 2016 11:07:42 -0700 Subject: [PATCH 07/86] generate server base class as partial too --- examples/csharp/helloworld-from-cli/Greeter/HelloworldGrpc.cs | 2 +- examples/csharp/helloworld/Greeter/HelloworldGrpc.cs | 2 +- examples/csharp/route_guide/RouteGuide/RouteGuideGrpc.cs | 2 +- src/compiler/csharp_generator.cc | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/csharp/helloworld-from-cli/Greeter/HelloworldGrpc.cs b/examples/csharp/helloworld-from-cli/Greeter/HelloworldGrpc.cs index 297e030a650..9974620da4f 100644 --- a/examples/csharp/helloworld-from-cli/Greeter/HelloworldGrpc.cs +++ b/examples/csharp/helloworld-from-cli/Greeter/HelloworldGrpc.cs @@ -62,7 +62,7 @@ namespace Helloworld { } /// Base class for server-side implementations of Greeter - public abstract class GreeterBase + public abstract partial class GreeterBase { /// /// Sends a greeting diff --git a/examples/csharp/helloworld/Greeter/HelloworldGrpc.cs b/examples/csharp/helloworld/Greeter/HelloworldGrpc.cs index 297e030a650..9974620da4f 100644 --- a/examples/csharp/helloworld/Greeter/HelloworldGrpc.cs +++ b/examples/csharp/helloworld/Greeter/HelloworldGrpc.cs @@ -62,7 +62,7 @@ namespace Helloworld { } /// Base class for server-side implementations of Greeter - public abstract class GreeterBase + public abstract partial class GreeterBase { /// /// Sends a greeting diff --git a/examples/csharp/route_guide/RouteGuide/RouteGuideGrpc.cs b/examples/csharp/route_guide/RouteGuide/RouteGuideGrpc.cs index 3cca24a9442..aaaac0d1b63 100644 --- a/examples/csharp/route_guide/RouteGuide/RouteGuideGrpc.cs +++ b/examples/csharp/route_guide/RouteGuide/RouteGuideGrpc.cs @@ -86,7 +86,7 @@ namespace Routeguide { } /// Base class for server-side implementations of RouteGuide - public abstract class RouteGuideBase + public abstract partial class RouteGuideBase { /// /// A simple RPC. diff --git a/src/compiler/csharp_generator.cc b/src/compiler/csharp_generator.cc index 3d4a8cb9c28..977600ffb24 100644 --- a/src/compiler/csharp_generator.cc +++ b/src/compiler/csharp_generator.cc @@ -297,7 +297,7 @@ void GenerateServiceDescriptorProperty(Printer* out, const ServiceDescriptor *se void GenerateServerClass(Printer* out, const ServiceDescriptor *service) { out->Print("/// Base class for server-side implementations of $servicename$\n", "servicename", GetServiceClassName(service)); - out->Print("public abstract class $name$\n", "name", + out->Print("public abstract partial class $name$\n", "name", GetServerClassName(service)); out->Print("{\n"); out->Indent(); From 0350471b2e7a3065562b00f122d883d5c4348e60 Mon Sep 17 00:00:00 2001 From: Alexander Polcyn Date: Thu, 3 Nov 2016 12:27:06 -0700 Subject: [PATCH 08/86] example changes to smoke test with 1.0.1 --- .../helloworld-from-cli/Greeter/project.json | 11 ++- .../GreeterClient/project.json | 11 ++- .../GreeterServer/project.json | 11 ++- .../csharp/helloworld/Greeter/Greeter.csproj | 8 +- .../csharp/helloworld/Greeter/packages.config | 6 +- .../GreeterClient/GreeterClient.csproj | 8 +- .../helloworld/GreeterClient/packages.config | 4 +- .../GreeterServer/GreeterServer.csproj | 8 +- .../helloworld/GreeterServer/packages.config | 4 +- .../route_guide/RouteGuide/RouteGuide.cs | 88 +++++++++++++++++-- .../route_guide/RouteGuide/RouteGuide.csproj | 8 +- .../route_guide/RouteGuide/packages.config | 4 +- .../RouteGuideClient/RouteGuideClient.csproj | 8 +- .../RouteGuideClient/packages.config | 4 +- .../RouteGuideServer/RouteGuideServer.csproj | 8 +- .../RouteGuideServer/packages.config | 6 +- 16 files changed, 150 insertions(+), 47 deletions(-) diff --git a/examples/csharp/helloworld-from-cli/Greeter/project.json b/examples/csharp/helloworld-from-cli/Greeter/project.json index 40fba7cf1f5..72254ce73e9 100644 --- a/examples/csharp/helloworld-from-cli/Greeter/project.json +++ b/examples/csharp/helloworld-from-cli/Greeter/project.json @@ -6,7 +6,7 @@ }, "dependencies": { "Google.Protobuf": "3.0.0", - "Grpc": "1.0.0", + "Grpc": "1.0.1", }, "frameworks": { "net45": { @@ -17,6 +17,15 @@ "dependencies": { "Microsoft.NETCore.Platforms": "1.0.1" } + }, + "netcoreapp1.0": { + "dependencies": { + "Microsoft.NETCore.App": { + "type": "platform", + "version": "1.0.1" + } + }, + "imports": "dnxcore50" } } } diff --git a/examples/csharp/helloworld-from-cli/GreeterClient/project.json b/examples/csharp/helloworld-from-cli/GreeterClient/project.json index 74962a90e90..09e156f68e8 100644 --- a/examples/csharp/helloworld-from-cli/GreeterClient/project.json +++ b/examples/csharp/helloworld-from-cli/GreeterClient/project.json @@ -7,7 +7,7 @@ }, "dependencies": { "Google.Protobuf": "3.0.0", - "Grpc": "1.0.0", + "Grpc": "1.0.1", "Greeter": { "target": "project" } @@ -21,6 +21,15 @@ "dependencies": { "Microsoft.NETCore.Platforms": "1.0.1" } + }, + "netcoreapp1.0": { + "dependencies": { + "Microsoft.NETCore.App": { + "type": "platform", + "version": "1.0.1" + } + }, + "imports": "dnxcore50" } } } diff --git a/examples/csharp/helloworld-from-cli/GreeterServer/project.json b/examples/csharp/helloworld-from-cli/GreeterServer/project.json index 33af2544819..8802fe32657 100644 --- a/examples/csharp/helloworld-from-cli/GreeterServer/project.json +++ b/examples/csharp/helloworld-from-cli/GreeterServer/project.json @@ -7,7 +7,7 @@ }, "dependencies": { "Google.Protobuf": "3.0.0", - "Grpc": "1.0.0", + "Grpc": "1.0.1", "Greeter": { "target": "project" } @@ -21,6 +21,15 @@ "dependencies": { "Microsoft.NETCore.Platforms": "1.0.1" } + }, + "netcoreapp1.0": { + "dependencies": { + "Microsoft.NETCore.App": { + "type": "platform", + "version": "1.0.1" + } + }, + "imports": "dnxcore50" } } } diff --git a/examples/csharp/helloworld/Greeter/Greeter.csproj b/examples/csharp/helloworld/Greeter/Greeter.csproj index 54a41d1746a..036e6b59fbc 100644 --- a/examples/csharp/helloworld/Greeter/Greeter.csproj +++ b/examples/csharp/helloworld/Greeter/Greeter.csproj @@ -35,9 +35,9 @@ False ..\packages\Google.Protobuf.3.0.0\lib\net45\Google.Protobuf.dll - + False - ..\packages\Grpc.Core.1.0.0\lib\net45\Grpc.Core.dll + ..\packages\Grpc.Core.1.0.1\lib\net45\Grpc.Core.dll @@ -61,11 +61,11 @@ - + This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + diff --git a/examples/csharp/helloworld/Greeter/packages.config b/examples/csharp/helloworld/Greeter/packages.config index 46f7ddacb76..2bb3a182a66 100644 --- a/examples/csharp/helloworld/Greeter/packages.config +++ b/examples/csharp/helloworld/Greeter/packages.config @@ -1,8 +1,8 @@  - - + + - + diff --git a/examples/csharp/helloworld/GreeterClient/GreeterClient.csproj b/examples/csharp/helloworld/GreeterClient/GreeterClient.csproj index 43d85e194cf..639ac0e70ca 100644 --- a/examples/csharp/helloworld/GreeterClient/GreeterClient.csproj +++ b/examples/csharp/helloworld/GreeterClient/GreeterClient.csproj @@ -35,9 +35,9 @@ False ..\packages\Google.Protobuf.3.0.0\lib\net45\Google.Protobuf.dll - + False - ..\packages\Grpc.Core.1.0.0\lib\net45\Grpc.Core.dll + ..\packages\Grpc.Core.1.0.1\lib\net45\Grpc.Core.dll @@ -59,11 +59,11 @@ - + This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + diff --git a/examples/csharp/helloworld/GreeterClient/packages.config b/examples/csharp/helloworld/GreeterClient/packages.config index 9f5509769a1..addcae0f173 100644 --- a/examples/csharp/helloworld/GreeterClient/packages.config +++ b/examples/csharp/helloworld/GreeterClient/packages.config @@ -1,7 +1,7 @@  - - + + diff --git a/examples/csharp/helloworld/GreeterServer/GreeterServer.csproj b/examples/csharp/helloworld/GreeterServer/GreeterServer.csproj index 5a3457fb7a2..aa7188839c5 100644 --- a/examples/csharp/helloworld/GreeterServer/GreeterServer.csproj +++ b/examples/csharp/helloworld/GreeterServer/GreeterServer.csproj @@ -35,9 +35,9 @@ False ..\packages\Google.Protobuf.3.0.0\lib\net45\Google.Protobuf.dll - + False - ..\packages\Grpc.Core.1.0.0\lib\net45\Grpc.Core.dll + ..\packages\Grpc.Core.1.0.1\lib\net45\Grpc.Core.dll @@ -59,11 +59,11 @@ - + This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + diff --git a/examples/csharp/helloworld/GreeterServer/packages.config b/examples/csharp/helloworld/GreeterServer/packages.config index 9f5509769a1..addcae0f173 100644 --- a/examples/csharp/helloworld/GreeterServer/packages.config +++ b/examples/csharp/helloworld/GreeterServer/packages.config @@ -1,7 +1,7 @@  - - + + diff --git a/examples/csharp/route_guide/RouteGuide/RouteGuide.cs b/examples/csharp/route_guide/RouteGuide/RouteGuide.cs index 446113de9d5..54cb823983e 100644 --- a/examples/csharp/route_guide/RouteGuide/RouteGuide.cs +++ b/examples/csharp/route_guide/RouteGuide/RouteGuide.cs @@ -10,7 +10,6 @@ using scg = global::System.Collections.Generic; namespace Routeguide { /// Holder for reflection information generated from route_guide.proto - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public static partial class RouteGuideReflection { #region Descriptor @@ -59,30 +58,35 @@ namespace Routeguide { /// Latitudes should be in the range +/- 90 degrees and longitude should be in /// the range +/- 180 degrees (inclusive). /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class Point : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Point()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::Routeguide.RouteGuideReflection.Descriptor.MessageTypes[0]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Point() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Point(Point other) : this() { latitude_ = other.latitude_; longitude_ = other.longitude_; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Point Clone() { return new Point(this); } @@ -90,6 +94,7 @@ namespace Routeguide { /// Field number for the "latitude" field. public const int LatitudeFieldNumber = 1; private int latitude_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int Latitude { get { return latitude_; } set { @@ -100,6 +105,7 @@ namespace Routeguide { /// Field number for the "longitude" field. public const int LongitudeFieldNumber = 2; private int longitude_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int Longitude { get { return longitude_; } set { @@ -107,10 +113,12 @@ namespace Routeguide { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as Point); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(Point other) { if (ReferenceEquals(other, null)) { return false; @@ -123,6 +131,7 @@ namespace Routeguide { return true; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; if (Latitude != 0) hash ^= Latitude.GetHashCode(); @@ -130,10 +139,12 @@ namespace Routeguide { return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { if (Latitude != 0) { output.WriteRawTag(8); @@ -145,6 +156,7 @@ namespace Routeguide { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; if (Latitude != 0) { @@ -156,6 +168,7 @@ namespace Routeguide { return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(Point other) { if (other == null) { return; @@ -168,6 +181,7 @@ namespace Routeguide { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { @@ -193,30 +207,35 @@ namespace Routeguide { /// A latitude-longitude rectangle, represented as two diagonally opposite /// points "lo" and "hi". /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class Rectangle : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Rectangle()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::Routeguide.RouteGuideReflection.Descriptor.MessageTypes[1]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Rectangle() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Rectangle(Rectangle other) : this() { Lo = other.lo_ != null ? other.Lo.Clone() : null; Hi = other.hi_ != null ? other.Hi.Clone() : null; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Rectangle Clone() { return new Rectangle(this); } @@ -227,6 +246,7 @@ namespace Routeguide { /// /// One corner of the rectangle. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public global::Routeguide.Point Lo { get { return lo_; } set { @@ -240,6 +260,7 @@ namespace Routeguide { /// /// The other corner of the rectangle. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public global::Routeguide.Point Hi { get { return hi_; } set { @@ -247,10 +268,12 @@ namespace Routeguide { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as Rectangle); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(Rectangle other) { if (ReferenceEquals(other, null)) { return false; @@ -263,6 +286,7 @@ namespace Routeguide { return true; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; if (lo_ != null) hash ^= Lo.GetHashCode(); @@ -270,10 +294,12 @@ namespace Routeguide { return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { if (lo_ != null) { output.WriteRawTag(10); @@ -285,6 +311,7 @@ namespace Routeguide { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; if (lo_ != null) { @@ -296,6 +323,7 @@ namespace Routeguide { return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(Rectangle other) { if (other == null) { return; @@ -314,6 +342,7 @@ namespace Routeguide { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { @@ -346,30 +375,35 @@ namespace Routeguide { /// /// If a feature could not be named, the name is empty. /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class Feature : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Feature()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::Routeguide.RouteGuideReflection.Descriptor.MessageTypes[2]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Feature() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Feature(Feature other) : this() { name_ = other.name_; Location = other.location_ != null ? other.Location.Clone() : null; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Feature Clone() { return new Feature(this); } @@ -380,6 +414,7 @@ namespace Routeguide { /// /// The name of the feature. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string Name { get { return name_; } set { @@ -393,6 +428,7 @@ namespace Routeguide { /// /// The point where the feature is detected. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public global::Routeguide.Point Location { get { return location_; } set { @@ -400,10 +436,12 @@ namespace Routeguide { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as Feature); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(Feature other) { if (ReferenceEquals(other, null)) { return false; @@ -416,6 +454,7 @@ namespace Routeguide { return true; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; if (Name.Length != 0) hash ^= Name.GetHashCode(); @@ -423,10 +462,12 @@ namespace Routeguide { return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { if (Name.Length != 0) { output.WriteRawTag(10); @@ -438,6 +479,7 @@ namespace Routeguide { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; if (Name.Length != 0) { @@ -449,6 +491,7 @@ namespace Routeguide { return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(Feature other) { if (other == null) { return; @@ -464,6 +507,7 @@ namespace Routeguide { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { @@ -491,30 +535,35 @@ namespace Routeguide { /// /// A RouteNote is a message sent while at a given point. /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class RouteNote : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new RouteNote()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::Routeguide.RouteGuideReflection.Descriptor.MessageTypes[3]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public RouteNote() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public RouteNote(RouteNote other) : this() { Location = other.location_ != null ? other.Location.Clone() : null; message_ = other.message_; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public RouteNote Clone() { return new RouteNote(this); } @@ -525,6 +574,7 @@ namespace Routeguide { /// /// The location from which the message is sent. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public global::Routeguide.Point Location { get { return location_; } set { @@ -538,6 +588,7 @@ namespace Routeguide { /// /// The message to be sent. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string Message { get { return message_; } set { @@ -545,10 +596,12 @@ namespace Routeguide { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as RouteNote); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(RouteNote other) { if (ReferenceEquals(other, null)) { return false; @@ -561,6 +614,7 @@ namespace Routeguide { return true; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; if (location_ != null) hash ^= Location.GetHashCode(); @@ -568,10 +622,12 @@ namespace Routeguide { return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { if (location_ != null) { output.WriteRawTag(10); @@ -583,6 +639,7 @@ namespace Routeguide { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; if (location_ != null) { @@ -594,6 +651,7 @@ namespace Routeguide { return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(RouteNote other) { if (other == null) { return; @@ -609,6 +667,7 @@ namespace Routeguide { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { @@ -640,25 +699,29 @@ namespace Routeguide { /// detected features, and the total distance covered as the cumulative sum of /// the distance between each point. /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class RouteSummary : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new RouteSummary()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::Routeguide.RouteGuideReflection.Descriptor.MessageTypes[4]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public RouteSummary() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public RouteSummary(RouteSummary other) : this() { pointCount_ = other.pointCount_; featureCount_ = other.featureCount_; @@ -666,6 +729,7 @@ namespace Routeguide { elapsedTime_ = other.elapsedTime_; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public RouteSummary Clone() { return new RouteSummary(this); } @@ -676,6 +740,7 @@ namespace Routeguide { /// /// The number of points received. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int PointCount { get { return pointCount_; } set { @@ -689,6 +754,7 @@ namespace Routeguide { /// /// The number of known features passed while traversing the route. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int FeatureCount { get { return featureCount_; } set { @@ -702,6 +768,7 @@ namespace Routeguide { /// /// The distance covered in metres. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int Distance { get { return distance_; } set { @@ -715,6 +782,7 @@ namespace Routeguide { /// /// The duration of the traversal in seconds. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int ElapsedTime { get { return elapsedTime_; } set { @@ -722,10 +790,12 @@ namespace Routeguide { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as RouteSummary); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(RouteSummary other) { if (ReferenceEquals(other, null)) { return false; @@ -740,6 +810,7 @@ namespace Routeguide { return true; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; if (PointCount != 0) hash ^= PointCount.GetHashCode(); @@ -749,10 +820,12 @@ namespace Routeguide { return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { if (PointCount != 0) { output.WriteRawTag(8); @@ -772,6 +845,7 @@ namespace Routeguide { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; if (PointCount != 0) { @@ -789,6 +863,7 @@ namespace Routeguide { return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(RouteSummary other) { if (other == null) { return; @@ -807,6 +882,7 @@ namespace Routeguide { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { diff --git a/examples/csharp/route_guide/RouteGuide/RouteGuide.csproj b/examples/csharp/route_guide/RouteGuide/RouteGuide.csproj index 02bca2fc725..eee8f0a1bce 100644 --- a/examples/csharp/route_guide/RouteGuide/RouteGuide.csproj +++ b/examples/csharp/route_guide/RouteGuide/RouteGuide.csproj @@ -35,9 +35,9 @@ False ..\packages\Google.Protobuf.3.0.0\lib\net45\Google.Protobuf.dll - + False - ..\packages\Grpc.Core.1.0.0\lib\net45\Grpc.Core.dll + ..\packages\Grpc.Core.1.0.1\lib\net45\Grpc.Core.dll False @@ -74,12 +74,12 @@ - + This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + + \ No newline at end of file diff --git a/src/csharp/Grpc.Reflection.Tests/Grpc.Reflection.Tests.project.json b/src/csharp/Grpc.Reflection.Tests/Grpc.Reflection.Tests.project.json new file mode 100644 index 00000000000..c2f5bcb1637 --- /dev/null +++ b/src/csharp/Grpc.Reflection.Tests/Grpc.Reflection.Tests.project.json @@ -0,0 +1,8 @@ +{ + "frameworks": { + "net45": { } + }, + "runtimes": { + "win": { } + } +} diff --git a/src/csharp/Grpc.Reflection.Tests/Grpc.Reflection.Tests.xproj b/src/csharp/Grpc.Reflection.Tests/Grpc.Reflection.Tests.xproj new file mode 100644 index 00000000000..4a3100853d1 --- /dev/null +++ b/src/csharp/Grpc.Reflection.Tests/Grpc.Reflection.Tests.xproj @@ -0,0 +1,18 @@ + + + + 14.0.25123 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + fe90181d-a4b3-4a5c-8490-f07561e18e3b + Grpc.Reflection.Tests + ..\artifacts\obj\$(MSBuildProjectName) + .\bin\ + + + 2.0 + + + \ No newline at end of file diff --git a/src/csharp/Grpc.Reflection.Tests/NUnitMain.cs b/src/csharp/Grpc.Reflection.Tests/NUnitMain.cs new file mode 100644 index 00000000000..a60d7b03eb8 --- /dev/null +++ b/src/csharp/Grpc.Reflection.Tests/NUnitMain.cs @@ -0,0 +1,59 @@ +#region Copyright notice and license + +// Copyright 2016, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#endregion + +using System; +using System.Reflection; +using Grpc.Core; +using Grpc.Core.Logging; +using NUnit.Common; +using NUnitLite; + +namespace Grpc.Reflection.Tests +{ + /// + /// Provides entry point for NUnitLite + /// + public class NUnitMain + { + public static int Main(string[] args) + { + // Make logger immune to NUnit capturing stdout and stderr to workaround https://github.com/nunit/nunit/issues/1406. + GrpcEnvironment.SetLogger(new TextWriterLogger(Console.Error)); +#if NETCOREAPP1_0 + return new AutoRun(typeof(NUnitMain).GetTypeInfo().Assembly).Execute(args, new ExtendedTextWrapper(Console.Out), Console.In); +#else + return new AutoRun().Execute(args); +#endif + } + } +} diff --git a/src/csharp/Grpc.Reflection.Tests/Properties/AssemblyInfo.cs b/src/csharp/Grpc.Reflection.Tests/Properties/AssemblyInfo.cs new file mode 100644 index 00000000000..d29054a4d14 --- /dev/null +++ b/src/csharp/Grpc.Reflection.Tests/Properties/AssemblyInfo.cs @@ -0,0 +1,44 @@ +#region Copyright notice and license + +// Copyright 2015, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#endregion + +using System.Reflection; +using System.Runtime.CompilerServices; + +[assembly: AssemblyTitle("Grpc.Reflection.Tests")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("")] +[assembly: AssemblyCopyright("Google Inc. All rights reserved.")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] diff --git a/src/csharp/Grpc.Reflection.Tests/ReflectionClientServerTest.cs b/src/csharp/Grpc.Reflection.Tests/ReflectionClientServerTest.cs new file mode 100644 index 00000000000..1d0845e276c --- /dev/null +++ b/src/csharp/Grpc.Reflection.Tests/ReflectionClientServerTest.cs @@ -0,0 +1,154 @@ +#region Copyright notice and license +// Copyright 2015, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +using Grpc.Core; +using Grpc.Reflection; +using Grpc.Reflection.V1Alpha; +using NUnit.Framework; + +namespace Grpc.Reflection.Tests +{ + /// + /// Reflection client talks to reflection server. + /// + public class ReflectionClientServerTest + { + const string Host = "localhost"; + Server server; + Channel channel; + ServerReflection.ServerReflectionClient client; + ReflectionServiceImpl serviceImpl; + + [TestFixtureSetUp] + public void Init() + { + serviceImpl = new ReflectionServiceImpl(ServerReflection.Descriptor); + + server = new Server + { + Services = { ServerReflection.BindService(serviceImpl) }, + Ports = { { Host, ServerPort.PickUnused, ServerCredentials.Insecure } } + }; + server.Start(); + channel = new Channel(Host, server.Ports.Single().BoundPort, ChannelCredentials.Insecure); + + client = new ServerReflection.ServerReflectionClient(channel); + } + + [TestFixtureTearDown] + public void Cleanup() + { + channel.ShutdownAsync().Wait(); + server.ShutdownAsync().Wait(); + } + + [Test] + public async Task FileByFilename_NotFound() + { + var response = await SingleRequestAsync(new ServerReflectionRequest + { + FileByFilename = "somepackage/nonexistent.proto" + }); + Assert.AreEqual((int)StatusCode.NotFound, response.ErrorResponse.ErrorCode); + } + + [Test] + public async Task FileByFilename() + { + var response = await SingleRequestAsync(new ServerReflectionRequest + { + FileByFilename = "grpc/reflection/v1alpha/reflection.proto" + }); + Assert.AreEqual(1, response.FileDescriptorResponse.FileDescriptorProto.Count); + Assert.AreEqual(ReflectionReflection.Descriptor.SerializedData, response.FileDescriptorResponse.FileDescriptorProto[0]); + } + + [Test] + public async Task FileContainingSymbol() + { + var response = await SingleRequestAsync(new ServerReflectionRequest + { + FileContainingSymbol = "grpc.reflection.v1alpha.ServerReflection" + }); + Assert.AreEqual(1, response.FileDescriptorResponse.FileDescriptorProto.Count); + Assert.AreEqual(ReflectionReflection.Descriptor.SerializedData, response.FileDescriptorResponse.FileDescriptorProto[0]); + } + + [Test] + public async Task FileContainingSymbol_NotFound() + { + var response = await SingleRequestAsync(new ServerReflectionRequest + { + FileContainingSymbol = "somepackage.Nonexistent" + }); + Assert.AreEqual((int)StatusCode.NotFound, response.ErrorResponse.ErrorCode); + } + + [Test] + public async Task ListServices() + { + var response = await SingleRequestAsync(new ServerReflectionRequest + { + ListServices = "" + }); + Assert.AreEqual(1, response.ListServicesResponse.Service.Count); + Assert.AreEqual(ServerReflection.Descriptor.FullName, response.ListServicesResponse.Service[0].Name); + } + + [Test] + public async Task FileContainingExtension() + { + var response = await SingleRequestAsync(new ServerReflectionRequest + { + FileContainingExtension = new ExtensionRequest() + }); + Assert.AreEqual((int)StatusCode.Unimplemented, response.ErrorResponse.ErrorCode); + } + + private async Task SingleRequestAsync(ServerReflectionRequest request) + { + var call = client.ServerReflectionInfo(); + await call.RequestStream.WriteAsync(request); + Assert.IsTrue(await call.ResponseStream.MoveNext()); + + var response = call.ResponseStream.Current; + await call.RequestStream.CompleteAsync(); + Assert.IsFalse(await call.ResponseStream.MoveNext()); + return response; + } + } +} diff --git a/src/csharp/Grpc.Reflection.Tests/SymbolRegistryTest.cs b/src/csharp/Grpc.Reflection.Tests/SymbolRegistryTest.cs new file mode 100644 index 00000000000..68ee6dc10d7 --- /dev/null +++ b/src/csharp/Grpc.Reflection.Tests/SymbolRegistryTest.cs @@ -0,0 +1,63 @@ +#region Copyright notice and license +// Copyright 2015, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +using Grpc.Reflection; +using Grpc.Reflection.V1Alpha; +using NUnit.Framework; + + +namespace Grpc.Reflection.Tests +{ + /// + /// Tests for ReflectionServiceImpl + /// + public class SymbolRegistryTest + { + SymbolRegistry registry = SymbolRegistry.FromFiles(new[] { ReflectionReflection.Descriptor, Google.Protobuf.WellKnownTypes.Duration.Descriptor.File }); + + [Test] + public void FileByName() + { + Assert.AreSame(Google.Protobuf.WellKnownTypes.Duration.Descriptor.File, registry.FileByName("google/protobuf/duration.proto")); + Assert.IsNull(registry.FileByName("somepackage/nonexistent.proto")); + } + + [Test] + public void FileContainingSymbol() + { + Assert.AreSame(Google.Protobuf.WellKnownTypes.Duration.Descriptor.File, registry.FileContainingSymbol("google.protobuf.Duration")); + Assert.AreSame(ReflectionReflection.Descriptor, registry.FileContainingSymbol("grpc.reflection.v1alpha.ServerReflection.ServerReflectionInfo")); // method + Assert.AreSame(ReflectionReflection.Descriptor, registry.FileContainingSymbol("grpc.reflection.v1alpha.ServerReflection")); // service + Assert.AreSame(ReflectionReflection.Descriptor, registry.FileContainingSymbol("grpc.reflection.v1alpha.ServerReflectionRequest")); // message + Assert.IsNull(registry.FileContainingSymbol("somepackage.Nonexistent")); + } + } +} diff --git a/src/csharp/Grpc.Reflection.Tests/packages.config b/src/csharp/Grpc.Reflection.Tests/packages.config new file mode 100644 index 00000000000..0fed4dbd415 --- /dev/null +++ b/src/csharp/Grpc.Reflection.Tests/packages.config @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/src/csharp/Grpc.Reflection.Tests/project.json b/src/csharp/Grpc.Reflection.Tests/project.json new file mode 100644 index 00000000000..61d3b7e47b7 --- /dev/null +++ b/src/csharp/Grpc.Reflection.Tests/project.json @@ -0,0 +1,65 @@ +{ + "buildOptions": { + "emitEntryPoint": true + }, + "configurations": { + "Debug": { + "buildOptions": { + "define": [ "SIGNED" ], + "keyFile": "../keys/Grpc.snk", + "xmlDoc": true, + "compile": { + "includeFiles": [ "../Grpc.Core/Version.cs" ] + }, + "copyToOutput": { + "mappings": { + "grpc_csharp_ext.x64.dll": "../../../vsprojects/x64/Debug/grpc_csharp_ext.dll", + "grpc_csharp_ext.x86.dll": "../../../vsprojects/Debug/grpc_csharp_ext.dll", + "libgrpc_csharp_ext.x64.so": "../../../libs/dbg/libgrpc_csharp_ext.so", + "libgrpc_csharp_ext.x64.dylib": "../../../libs/dbg/libgrpc_csharp_ext.dylib" + } + } + } + }, + "Release": { + "buildOptions": { + "define": [ "SIGNED" ], + "keyFile": "../keys/Grpc.snk", + "xmlDoc": true, + "compile": { + "includeFiles": [ "../Grpc.Core/Version.cs" ] + }, + "copyToOutput": { + "mappings": { + "grpc_csharp_ext.x64.dll": "../../../vsprojects/x64/Release/grpc_csharp_ext.dll", + "grpc_csharp_ext.x86.dll": "../../../vsprojects/Release/grpc_csharp_ext.dll", + "libgrpc_csharp_ext.x64.so": "../../../libs/opt/libgrpc_csharp_ext.so", + "libgrpc_csharp_ext.x64.dylib": "../../../libs/opt/libgrpc_csharp_ext.dylib" + } + } + } + } + }, + + "dependencies": { + "Grpc.Reflection": { + "target": "project" + }, + "NUnit": "3.2.0", + "NUnitLite": "3.2.0-*" + }, + "frameworks": { + "net45": { }, + "netcoreapp1.0": { + "imports": [ + "portable-net45" + ], + "dependencies": { + "Microsoft.NETCore.App": { + "type": "platform", + "version": "1.0.0" + } + } + } + } +} diff --git a/src/csharp/Grpc.Reflection/.gitignore b/src/csharp/Grpc.Reflection/.gitignore new file mode 100644 index 00000000000..1746e3269ed --- /dev/null +++ b/src/csharp/Grpc.Reflection/.gitignore @@ -0,0 +1,2 @@ +bin +obj diff --git a/src/csharp/Grpc.Reflection/Grpc.Reflection.csproj b/src/csharp/Grpc.Reflection/Grpc.Reflection.csproj new file mode 100644 index 00000000000..06559c15f02 --- /dev/null +++ b/src/csharp/Grpc.Reflection/Grpc.Reflection.csproj @@ -0,0 +1,84 @@ + + + + + Debug + AnyCPU + {4F18CF52-B3DB-4A77-97C5-7F7F4B6C1715} + Library + Properties + Grpc.Reflection + Grpc.Reflection + v4.5 + 512 + bin\$(Configuration)\Grpc.Reflection.Xml + + + true + full + false + bin\Debug\ + prompt + 4 + + + pdbonly + true + bin\Release\ + prompt + 4 + + + pdbonly + true + bin\ReleaseSigned + prompt + 4 + True + ..\keys\Grpc.snk + + + + + + + + + + + ..\packages\Google.Protobuf.3.0.0\lib\net45\Google.Protobuf.dll + + + ..\packages\System.Interactive.Async.3.1.1\lib\net45\System.Interactive.Async.dll + + + + + Version.cs + + + + + + + + + + + + + + + {ccc4440e-49f7-4790-b0af-feabb0837ae7} + Grpc.Core + + + + + \ No newline at end of file diff --git a/src/csharp/Grpc.Reflection/Grpc.Reflection.nuspec b/src/csharp/Grpc.Reflection/Grpc.Reflection.nuspec new file mode 100644 index 00000000000..c07fa96b1d1 --- /dev/null +++ b/src/csharp/Grpc.Reflection/Grpc.Reflection.nuspec @@ -0,0 +1,28 @@ + + + + Grpc.Reflection + gRPC C# Reflection + Implementation of gRPC reflection service + Provides information about services running on a gRPC C# server. + $version$ + Google Inc. + grpc-packages + https://github.com/grpc/grpc/blob/master/LICENSE + https://github.com/grpc/grpc + false + Copyright 2016, Google Inc. + gRPC reflection + + + + + + + + + + + + + diff --git a/src/csharp/Grpc.Reflection/Grpc.Reflection.project.json b/src/csharp/Grpc.Reflection/Grpc.Reflection.project.json new file mode 100644 index 00000000000..c2f5bcb1637 --- /dev/null +++ b/src/csharp/Grpc.Reflection/Grpc.Reflection.project.json @@ -0,0 +1,8 @@ +{ + "frameworks": { + "net45": { } + }, + "runtimes": { + "win": { } + } +} diff --git a/src/csharp/Grpc.Reflection/Grpc.Reflection.xproj b/src/csharp/Grpc.Reflection/Grpc.Reflection.xproj new file mode 100644 index 00000000000..833d98b1216 --- /dev/null +++ b/src/csharp/Grpc.Reflection/Grpc.Reflection.xproj @@ -0,0 +1,18 @@ + + + + 14.0.25123 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + 2b372155-80ba-4cf9-82d6-4b938e8ec3a0 + Grpc.Reflection + ..\artifacts\obj\$(MSBuildProjectName) + .\bin\ + + + 2.0 + + + \ No newline at end of file diff --git a/src/csharp/Grpc.Reflection/Properties/AssemblyInfo.cs b/src/csharp/Grpc.Reflection/Properties/AssemblyInfo.cs new file mode 100644 index 00000000000..3104ecdd546 --- /dev/null +++ b/src/csharp/Grpc.Reflection/Properties/AssemblyInfo.cs @@ -0,0 +1,44 @@ +#region Copyright notice and license + +// Copyright 2015, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#endregion + +using System.Reflection; +using System.Runtime.CompilerServices; + +[assembly: AssemblyTitle("Grpc.Reflection")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("")] +[assembly: AssemblyCopyright("Google Inc. All rights reserved.")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] diff --git a/src/csharp/Grpc.Reflection/Reflection.cs b/src/csharp/Grpc.Reflection/Reflection.cs new file mode 100644 index 00000000000..bb92dfcbaeb --- /dev/null +++ b/src/csharp/Grpc.Reflection/Reflection.cs @@ -0,0 +1,1556 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: reflection.proto +#pragma warning disable 1591, 0612, 3021 +#region Designer generated code + +using pb = global::Google.Protobuf; +using pbc = global::Google.Protobuf.Collections; +using pbr = global::Google.Protobuf.Reflection; +using scg = global::System.Collections.Generic; +namespace Grpc.Reflection.V1Alpha { + + /// Holder for reflection information generated from reflection.proto + public static partial class ReflectionReflection { + + #region Descriptor + /// File descriptor for reflection.proto + public static pbr::FileDescriptor Descriptor { + get { return descriptor; } + } + private static pbr::FileDescriptor descriptor; + + static ReflectionReflection() { + byte[] descriptorData = global::System.Convert.FromBase64String( + string.Concat( + "ChByZWZsZWN0aW9uLnByb3RvEhdncnBjLnJlZmxlY3Rpb24udjFhbHBoYSKK", + "AgoXU2VydmVyUmVmbGVjdGlvblJlcXVlc3QSDAoEaG9zdBgBIAEoCRIaChBm", + "aWxlX2J5X2ZpbGVuYW1lGAMgASgJSAASIAoWZmlsZV9jb250YWluaW5nX3N5", + "bWJvbBgEIAEoCUgAEk4KGWZpbGVfY29udGFpbmluZ19leHRlbnNpb24YBSAB", + "KAsyKS5ncnBjLnJlZmxlY3Rpb24udjFhbHBoYS5FeHRlbnNpb25SZXF1ZXN0", + "SAASJwodYWxsX2V4dGVuc2lvbl9udW1iZXJzX29mX3R5cGUYBiABKAlIABIX", + "Cg1saXN0X3NlcnZpY2VzGAcgASgJSABCEQoPbWVzc2FnZV9yZXF1ZXN0IkUK", + "EEV4dGVuc2lvblJlcXVlc3QSFwoPY29udGFpbmluZ190eXBlGAEgASgJEhgK", + "EGV4dGVuc2lvbl9udW1iZXIYAiABKAUi0QMKGFNlcnZlclJlZmxlY3Rpb25S", + "ZXNwb25zZRISCgp2YWxpZF9ob3N0GAEgASgJEkoKEG9yaWdpbmFsX3JlcXVl", + "c3QYAiABKAsyMC5ncnBjLnJlZmxlY3Rpb24udjFhbHBoYS5TZXJ2ZXJSZWZs", + "ZWN0aW9uUmVxdWVzdBJTChhmaWxlX2Rlc2NyaXB0b3JfcmVzcG9uc2UYBCAB", + "KAsyLy5ncnBjLnJlZmxlY3Rpb24udjFhbHBoYS5GaWxlRGVzY3JpcHRvclJl", + "c3BvbnNlSAASWgoeYWxsX2V4dGVuc2lvbl9udW1iZXJzX3Jlc3BvbnNlGAUg", + "ASgLMjAuZ3JwYy5yZWZsZWN0aW9uLnYxYWxwaGEuRXh0ZW5zaW9uTnVtYmVy", + "UmVzcG9uc2VIABJOChZsaXN0X3NlcnZpY2VzX3Jlc3BvbnNlGAYgASgLMiwu", + "Z3JwYy5yZWZsZWN0aW9uLnYxYWxwaGEuTGlzdFNlcnZpY2VSZXNwb25zZUgA", + "EkAKDmVycm9yX3Jlc3BvbnNlGAcgASgLMiYuZ3JwYy5yZWZsZWN0aW9uLnYx", + "YWxwaGEuRXJyb3JSZXNwb25zZUgAQhIKEG1lc3NhZ2VfcmVzcG9uc2UiNwoW", + "RmlsZURlc2NyaXB0b3JSZXNwb25zZRIdChVmaWxlX2Rlc2NyaXB0b3JfcHJv", + "dG8YASADKAwiSwoXRXh0ZW5zaW9uTnVtYmVyUmVzcG9uc2USFgoOYmFzZV90", + "eXBlX25hbWUYASABKAkSGAoQZXh0ZW5zaW9uX251bWJlchgCIAMoBSJQChNM", + "aXN0U2VydmljZVJlc3BvbnNlEjkKB3NlcnZpY2UYASADKAsyKC5ncnBjLnJl", + "ZmxlY3Rpb24udjFhbHBoYS5TZXJ2aWNlUmVzcG9uc2UiHwoPU2VydmljZVJl", + "c3BvbnNlEgwKBG5hbWUYASABKAkiOgoNRXJyb3JSZXNwb25zZRISCgplcnJv", + "cl9jb2RlGAEgASgFEhUKDWVycm9yX21lc3NhZ2UYAiABKAkykwEKEFNlcnZl", + "clJlZmxlY3Rpb24SfwoUU2VydmVyUmVmbGVjdGlvbkluZm8SMC5ncnBjLnJl", + "ZmxlY3Rpb24udjFhbHBoYS5TZXJ2ZXJSZWZsZWN0aW9uUmVxdWVzdBoxLmdy", + "cGMucmVmbGVjdGlvbi52MWFscGhhLlNlcnZlclJlZmxlY3Rpb25SZXNwb25z", + "ZSgBMAFiBnByb3RvMw==")); + descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, + new pbr::FileDescriptor[] { }, + new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { + new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Reflection.V1Alpha.ServerReflectionRequest), global::Grpc.Reflection.V1Alpha.ServerReflectionRequest.Parser, new[]{ "Host", "FileByFilename", "FileContainingSymbol", "FileContainingExtension", "AllExtensionNumbersOfType", "ListServices" }, new[]{ "MessageRequest" }, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Reflection.V1Alpha.ExtensionRequest), global::Grpc.Reflection.V1Alpha.ExtensionRequest.Parser, new[]{ "ContainingType", "ExtensionNumber" }, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Reflection.V1Alpha.ServerReflectionResponse), global::Grpc.Reflection.V1Alpha.ServerReflectionResponse.Parser, new[]{ "ValidHost", "OriginalRequest", "FileDescriptorResponse", "AllExtensionNumbersResponse", "ListServicesResponse", "ErrorResponse" }, new[]{ "MessageResponse" }, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Reflection.V1Alpha.FileDescriptorResponse), global::Grpc.Reflection.V1Alpha.FileDescriptorResponse.Parser, new[]{ "FileDescriptorProto" }, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Reflection.V1Alpha.ExtensionNumberResponse), global::Grpc.Reflection.V1Alpha.ExtensionNumberResponse.Parser, new[]{ "BaseTypeName", "ExtensionNumber" }, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Reflection.V1Alpha.ListServiceResponse), global::Grpc.Reflection.V1Alpha.ListServiceResponse.Parser, new[]{ "Service" }, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Reflection.V1Alpha.ServiceResponse), global::Grpc.Reflection.V1Alpha.ServiceResponse.Parser, new[]{ "Name" }, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Reflection.V1Alpha.ErrorResponse), global::Grpc.Reflection.V1Alpha.ErrorResponse.Parser, new[]{ "ErrorCode", "ErrorMessage" }, null, null, null) + })); + } + #endregion + + } + #region Messages + /// + /// The message sent by the client when calling ServerReflectionInfo method. + /// + public sealed partial class ServerReflectionRequest : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ServerReflectionRequest()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Grpc.Reflection.V1Alpha.ReflectionReflection.Descriptor.MessageTypes[0]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ServerReflectionRequest() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ServerReflectionRequest(ServerReflectionRequest other) : this() { + host_ = other.host_; + switch (other.MessageRequestCase) { + case MessageRequestOneofCase.FileByFilename: + FileByFilename = other.FileByFilename; + break; + case MessageRequestOneofCase.FileContainingSymbol: + FileContainingSymbol = other.FileContainingSymbol; + break; + case MessageRequestOneofCase.FileContainingExtension: + FileContainingExtension = other.FileContainingExtension.Clone(); + break; + case MessageRequestOneofCase.AllExtensionNumbersOfType: + AllExtensionNumbersOfType = other.AllExtensionNumbersOfType; + break; + case MessageRequestOneofCase.ListServices: + ListServices = other.ListServices; + break; + } + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ServerReflectionRequest Clone() { + return new ServerReflectionRequest(this); + } + + /// Field number for the "host" field. + public const int HostFieldNumber = 1; + private string host_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string Host { + get { return host_; } + set { + host_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "file_by_filename" field. + public const int FileByFilenameFieldNumber = 3; + /// + /// Find a proto file by the file name. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string FileByFilename { + get { return messageRequestCase_ == MessageRequestOneofCase.FileByFilename ? (string) messageRequest_ : ""; } + set { + messageRequest_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + messageRequestCase_ = MessageRequestOneofCase.FileByFilename; + } + } + + /// Field number for the "file_containing_symbol" field. + public const int FileContainingSymbolFieldNumber = 4; + /// + /// Find the proto file that declares the given fully-qualified symbol name. + /// This field should be a fully-qualified symbol name + /// (e.g. <package>.<service>[.<method>] or <package>.<type>). + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string FileContainingSymbol { + get { return messageRequestCase_ == MessageRequestOneofCase.FileContainingSymbol ? (string) messageRequest_ : ""; } + set { + messageRequest_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + messageRequestCase_ = MessageRequestOneofCase.FileContainingSymbol; + } + } + + /// Field number for the "file_containing_extension" field. + public const int FileContainingExtensionFieldNumber = 5; + /// + /// Find the proto file which defines an extension extending the given + /// message type with the given field number. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::Grpc.Reflection.V1Alpha.ExtensionRequest FileContainingExtension { + get { return messageRequestCase_ == MessageRequestOneofCase.FileContainingExtension ? (global::Grpc.Reflection.V1Alpha.ExtensionRequest) messageRequest_ : null; } + set { + messageRequest_ = value; + messageRequestCase_ = value == null ? MessageRequestOneofCase.None : MessageRequestOneofCase.FileContainingExtension; + } + } + + /// Field number for the "all_extension_numbers_of_type" field. + public const int AllExtensionNumbersOfTypeFieldNumber = 6; + /// + /// Finds the tag numbers used by all known extensions of the given message + /// type, and appends them to ExtensionNumberResponse in an undefined order. + /// Its corresponding method is best-effort: it's not guaranteed that the + /// reflection service will implement this method, and it's not guaranteed + /// that this method will provide all extensions. Returns + /// StatusCode::UNIMPLEMENTED if it's not implemented. + /// This field should be a fully-qualified type name. The format is + /// <package>.<type> + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string AllExtensionNumbersOfType { + get { return messageRequestCase_ == MessageRequestOneofCase.AllExtensionNumbersOfType ? (string) messageRequest_ : ""; } + set { + messageRequest_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + messageRequestCase_ = MessageRequestOneofCase.AllExtensionNumbersOfType; + } + } + + /// Field number for the "list_services" field. + public const int ListServicesFieldNumber = 7; + /// + /// List the full names of registered services. The content will not be + /// checked. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string ListServices { + get { return messageRequestCase_ == MessageRequestOneofCase.ListServices ? (string) messageRequest_ : ""; } + set { + messageRequest_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + messageRequestCase_ = MessageRequestOneofCase.ListServices; + } + } + + private object messageRequest_; + /// Enum of possible cases for the "message_request" oneof. + public enum MessageRequestOneofCase { + None = 0, + FileByFilename = 3, + FileContainingSymbol = 4, + FileContainingExtension = 5, + AllExtensionNumbersOfType = 6, + ListServices = 7, + } + private MessageRequestOneofCase messageRequestCase_ = MessageRequestOneofCase.None; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public MessageRequestOneofCase MessageRequestCase { + get { return messageRequestCase_; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearMessageRequest() { + messageRequestCase_ = MessageRequestOneofCase.None; + messageRequest_ = null; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as ServerReflectionRequest); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(ServerReflectionRequest other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Host != other.Host) return false; + if (FileByFilename != other.FileByFilename) return false; + if (FileContainingSymbol != other.FileContainingSymbol) return false; + if (!object.Equals(FileContainingExtension, other.FileContainingExtension)) return false; + if (AllExtensionNumbersOfType != other.AllExtensionNumbersOfType) return false; + if (ListServices != other.ListServices) return false; + if (MessageRequestCase != other.MessageRequestCase) return false; + return true; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (Host.Length != 0) hash ^= Host.GetHashCode(); + if (messageRequestCase_ == MessageRequestOneofCase.FileByFilename) hash ^= FileByFilename.GetHashCode(); + if (messageRequestCase_ == MessageRequestOneofCase.FileContainingSymbol) hash ^= FileContainingSymbol.GetHashCode(); + if (messageRequestCase_ == MessageRequestOneofCase.FileContainingExtension) hash ^= FileContainingExtension.GetHashCode(); + if (messageRequestCase_ == MessageRequestOneofCase.AllExtensionNumbersOfType) hash ^= AllExtensionNumbersOfType.GetHashCode(); + if (messageRequestCase_ == MessageRequestOneofCase.ListServices) hash ^= ListServices.GetHashCode(); + hash ^= (int) messageRequestCase_; + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (Host.Length != 0) { + output.WriteRawTag(10); + output.WriteString(Host); + } + if (messageRequestCase_ == MessageRequestOneofCase.FileByFilename) { + output.WriteRawTag(26); + output.WriteString(FileByFilename); + } + if (messageRequestCase_ == MessageRequestOneofCase.FileContainingSymbol) { + output.WriteRawTag(34); + output.WriteString(FileContainingSymbol); + } + if (messageRequestCase_ == MessageRequestOneofCase.FileContainingExtension) { + output.WriteRawTag(42); + output.WriteMessage(FileContainingExtension); + } + if (messageRequestCase_ == MessageRequestOneofCase.AllExtensionNumbersOfType) { + output.WriteRawTag(50); + output.WriteString(AllExtensionNumbersOfType); + } + if (messageRequestCase_ == MessageRequestOneofCase.ListServices) { + output.WriteRawTag(58); + output.WriteString(ListServices); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (Host.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Host); + } + if (messageRequestCase_ == MessageRequestOneofCase.FileByFilename) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(FileByFilename); + } + if (messageRequestCase_ == MessageRequestOneofCase.FileContainingSymbol) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(FileContainingSymbol); + } + if (messageRequestCase_ == MessageRequestOneofCase.FileContainingExtension) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(FileContainingExtension); + } + if (messageRequestCase_ == MessageRequestOneofCase.AllExtensionNumbersOfType) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(AllExtensionNumbersOfType); + } + if (messageRequestCase_ == MessageRequestOneofCase.ListServices) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(ListServices); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ServerReflectionRequest other) { + if (other == null) { + return; + } + if (other.Host.Length != 0) { + Host = other.Host; + } + switch (other.MessageRequestCase) { + case MessageRequestOneofCase.FileByFilename: + FileByFilename = other.FileByFilename; + break; + case MessageRequestOneofCase.FileContainingSymbol: + FileContainingSymbol = other.FileContainingSymbol; + break; + case MessageRequestOneofCase.FileContainingExtension: + FileContainingExtension = other.FileContainingExtension; + break; + case MessageRequestOneofCase.AllExtensionNumbersOfType: + AllExtensionNumbersOfType = other.AllExtensionNumbersOfType; + break; + case MessageRequestOneofCase.ListServices: + ListServices = other.ListServices; + break; + } + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + case 10: { + Host = input.ReadString(); + break; + } + case 26: { + FileByFilename = input.ReadString(); + break; + } + case 34: { + FileContainingSymbol = input.ReadString(); + break; + } + case 42: { + global::Grpc.Reflection.V1Alpha.ExtensionRequest subBuilder = new global::Grpc.Reflection.V1Alpha.ExtensionRequest(); + if (messageRequestCase_ == MessageRequestOneofCase.FileContainingExtension) { + subBuilder.MergeFrom(FileContainingExtension); + } + input.ReadMessage(subBuilder); + FileContainingExtension = subBuilder; + break; + } + case 50: { + AllExtensionNumbersOfType = input.ReadString(); + break; + } + case 58: { + ListServices = input.ReadString(); + break; + } + } + } + } + + } + + /// + /// The type name and extension number sent by the client when requesting + /// file_containing_extension. + /// + public sealed partial class ExtensionRequest : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ExtensionRequest()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Grpc.Reflection.V1Alpha.ReflectionReflection.Descriptor.MessageTypes[1]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ExtensionRequest() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ExtensionRequest(ExtensionRequest other) : this() { + containingType_ = other.containingType_; + extensionNumber_ = other.extensionNumber_; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ExtensionRequest Clone() { + return new ExtensionRequest(this); + } + + /// Field number for the "containing_type" field. + public const int ContainingTypeFieldNumber = 1; + private string containingType_ = ""; + /// + /// Fully-qualified type name. The format should be <package>.<type> + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string ContainingType { + get { return containingType_; } + set { + containingType_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "extension_number" field. + public const int ExtensionNumberFieldNumber = 2; + private int extensionNumber_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int ExtensionNumber { + get { return extensionNumber_; } + set { + extensionNumber_ = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as ExtensionRequest); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(ExtensionRequest other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (ContainingType != other.ContainingType) return false; + if (ExtensionNumber != other.ExtensionNumber) return false; + return true; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (ContainingType.Length != 0) hash ^= ContainingType.GetHashCode(); + if (ExtensionNumber != 0) hash ^= ExtensionNumber.GetHashCode(); + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (ContainingType.Length != 0) { + output.WriteRawTag(10); + output.WriteString(ContainingType); + } + if (ExtensionNumber != 0) { + output.WriteRawTag(16); + output.WriteInt32(ExtensionNumber); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (ContainingType.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(ContainingType); + } + if (ExtensionNumber != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(ExtensionNumber); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ExtensionRequest other) { + if (other == null) { + return; + } + if (other.ContainingType.Length != 0) { + ContainingType = other.ContainingType; + } + if (other.ExtensionNumber != 0) { + ExtensionNumber = other.ExtensionNumber; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + case 10: { + ContainingType = input.ReadString(); + break; + } + case 16: { + ExtensionNumber = input.ReadInt32(); + break; + } + } + } + } + + } + + /// + /// The message sent by the server to answer ServerReflectionInfo method. + /// + public sealed partial class ServerReflectionResponse : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ServerReflectionResponse()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Grpc.Reflection.V1Alpha.ReflectionReflection.Descriptor.MessageTypes[2]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ServerReflectionResponse() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ServerReflectionResponse(ServerReflectionResponse other) : this() { + validHost_ = other.validHost_; + OriginalRequest = other.originalRequest_ != null ? other.OriginalRequest.Clone() : null; + switch (other.MessageResponseCase) { + case MessageResponseOneofCase.FileDescriptorResponse: + FileDescriptorResponse = other.FileDescriptorResponse.Clone(); + break; + case MessageResponseOneofCase.AllExtensionNumbersResponse: + AllExtensionNumbersResponse = other.AllExtensionNumbersResponse.Clone(); + break; + case MessageResponseOneofCase.ListServicesResponse: + ListServicesResponse = other.ListServicesResponse.Clone(); + break; + case MessageResponseOneofCase.ErrorResponse: + ErrorResponse = other.ErrorResponse.Clone(); + break; + } + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ServerReflectionResponse Clone() { + return new ServerReflectionResponse(this); + } + + /// Field number for the "valid_host" field. + public const int ValidHostFieldNumber = 1; + private string validHost_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string ValidHost { + get { return validHost_; } + set { + validHost_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "original_request" field. + public const int OriginalRequestFieldNumber = 2; + private global::Grpc.Reflection.V1Alpha.ServerReflectionRequest originalRequest_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::Grpc.Reflection.V1Alpha.ServerReflectionRequest OriginalRequest { + get { return originalRequest_; } + set { + originalRequest_ = value; + } + } + + /// Field number for the "file_descriptor_response" field. + public const int FileDescriptorResponseFieldNumber = 4; + /// + /// This message is used to answer file_by_filename, file_containing_symbol, + /// file_containing_extension requests with transitive dependencies. As + /// the repeated label is not allowed in oneof fields, we use a + /// FileDescriptorResponse message to encapsulate the repeated fields. + /// The reflection service is allowed to avoid sending FileDescriptorProtos + /// that were previously sent in response to earlier requests in the stream. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::Grpc.Reflection.V1Alpha.FileDescriptorResponse FileDescriptorResponse { + get { return messageResponseCase_ == MessageResponseOneofCase.FileDescriptorResponse ? (global::Grpc.Reflection.V1Alpha.FileDescriptorResponse) messageResponse_ : null; } + set { + messageResponse_ = value; + messageResponseCase_ = value == null ? MessageResponseOneofCase.None : MessageResponseOneofCase.FileDescriptorResponse; + } + } + + /// Field number for the "all_extension_numbers_response" field. + public const int AllExtensionNumbersResponseFieldNumber = 5; + /// + /// This message is used to answer all_extension_numbers_of_type requst. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::Grpc.Reflection.V1Alpha.ExtensionNumberResponse AllExtensionNumbersResponse { + get { return messageResponseCase_ == MessageResponseOneofCase.AllExtensionNumbersResponse ? (global::Grpc.Reflection.V1Alpha.ExtensionNumberResponse) messageResponse_ : null; } + set { + messageResponse_ = value; + messageResponseCase_ = value == null ? MessageResponseOneofCase.None : MessageResponseOneofCase.AllExtensionNumbersResponse; + } + } + + /// Field number for the "list_services_response" field. + public const int ListServicesResponseFieldNumber = 6; + /// + /// This message is used to answer list_services request. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::Grpc.Reflection.V1Alpha.ListServiceResponse ListServicesResponse { + get { return messageResponseCase_ == MessageResponseOneofCase.ListServicesResponse ? (global::Grpc.Reflection.V1Alpha.ListServiceResponse) messageResponse_ : null; } + set { + messageResponse_ = value; + messageResponseCase_ = value == null ? MessageResponseOneofCase.None : MessageResponseOneofCase.ListServicesResponse; + } + } + + /// Field number for the "error_response" field. + public const int ErrorResponseFieldNumber = 7; + /// + /// This message is used when an error occurs. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::Grpc.Reflection.V1Alpha.ErrorResponse ErrorResponse { + get { return messageResponseCase_ == MessageResponseOneofCase.ErrorResponse ? (global::Grpc.Reflection.V1Alpha.ErrorResponse) messageResponse_ : null; } + set { + messageResponse_ = value; + messageResponseCase_ = value == null ? MessageResponseOneofCase.None : MessageResponseOneofCase.ErrorResponse; + } + } + + private object messageResponse_; + /// Enum of possible cases for the "message_response" oneof. + public enum MessageResponseOneofCase { + None = 0, + FileDescriptorResponse = 4, + AllExtensionNumbersResponse = 5, + ListServicesResponse = 6, + ErrorResponse = 7, + } + private MessageResponseOneofCase messageResponseCase_ = MessageResponseOneofCase.None; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public MessageResponseOneofCase MessageResponseCase { + get { return messageResponseCase_; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearMessageResponse() { + messageResponseCase_ = MessageResponseOneofCase.None; + messageResponse_ = null; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as ServerReflectionResponse); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(ServerReflectionResponse other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (ValidHost != other.ValidHost) return false; + if (!object.Equals(OriginalRequest, other.OriginalRequest)) return false; + if (!object.Equals(FileDescriptorResponse, other.FileDescriptorResponse)) return false; + if (!object.Equals(AllExtensionNumbersResponse, other.AllExtensionNumbersResponse)) return false; + if (!object.Equals(ListServicesResponse, other.ListServicesResponse)) return false; + if (!object.Equals(ErrorResponse, other.ErrorResponse)) return false; + if (MessageResponseCase != other.MessageResponseCase) return false; + return true; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (ValidHost.Length != 0) hash ^= ValidHost.GetHashCode(); + if (originalRequest_ != null) hash ^= OriginalRequest.GetHashCode(); + if (messageResponseCase_ == MessageResponseOneofCase.FileDescriptorResponse) hash ^= FileDescriptorResponse.GetHashCode(); + if (messageResponseCase_ == MessageResponseOneofCase.AllExtensionNumbersResponse) hash ^= AllExtensionNumbersResponse.GetHashCode(); + if (messageResponseCase_ == MessageResponseOneofCase.ListServicesResponse) hash ^= ListServicesResponse.GetHashCode(); + if (messageResponseCase_ == MessageResponseOneofCase.ErrorResponse) hash ^= ErrorResponse.GetHashCode(); + hash ^= (int) messageResponseCase_; + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (ValidHost.Length != 0) { + output.WriteRawTag(10); + output.WriteString(ValidHost); + } + if (originalRequest_ != null) { + output.WriteRawTag(18); + output.WriteMessage(OriginalRequest); + } + if (messageResponseCase_ == MessageResponseOneofCase.FileDescriptorResponse) { + output.WriteRawTag(34); + output.WriteMessage(FileDescriptorResponse); + } + if (messageResponseCase_ == MessageResponseOneofCase.AllExtensionNumbersResponse) { + output.WriteRawTag(42); + output.WriteMessage(AllExtensionNumbersResponse); + } + if (messageResponseCase_ == MessageResponseOneofCase.ListServicesResponse) { + output.WriteRawTag(50); + output.WriteMessage(ListServicesResponse); + } + if (messageResponseCase_ == MessageResponseOneofCase.ErrorResponse) { + output.WriteRawTag(58); + output.WriteMessage(ErrorResponse); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (ValidHost.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(ValidHost); + } + if (originalRequest_ != null) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(OriginalRequest); + } + if (messageResponseCase_ == MessageResponseOneofCase.FileDescriptorResponse) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(FileDescriptorResponse); + } + if (messageResponseCase_ == MessageResponseOneofCase.AllExtensionNumbersResponse) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(AllExtensionNumbersResponse); + } + if (messageResponseCase_ == MessageResponseOneofCase.ListServicesResponse) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(ListServicesResponse); + } + if (messageResponseCase_ == MessageResponseOneofCase.ErrorResponse) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(ErrorResponse); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ServerReflectionResponse other) { + if (other == null) { + return; + } + if (other.ValidHost.Length != 0) { + ValidHost = other.ValidHost; + } + if (other.originalRequest_ != null) { + if (originalRequest_ == null) { + originalRequest_ = new global::Grpc.Reflection.V1Alpha.ServerReflectionRequest(); + } + OriginalRequest.MergeFrom(other.OriginalRequest); + } + switch (other.MessageResponseCase) { + case MessageResponseOneofCase.FileDescriptorResponse: + FileDescriptorResponse = other.FileDescriptorResponse; + break; + case MessageResponseOneofCase.AllExtensionNumbersResponse: + AllExtensionNumbersResponse = other.AllExtensionNumbersResponse; + break; + case MessageResponseOneofCase.ListServicesResponse: + ListServicesResponse = other.ListServicesResponse; + break; + case MessageResponseOneofCase.ErrorResponse: + ErrorResponse = other.ErrorResponse; + break; + } + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + case 10: { + ValidHost = input.ReadString(); + break; + } + case 18: { + if (originalRequest_ == null) { + originalRequest_ = new global::Grpc.Reflection.V1Alpha.ServerReflectionRequest(); + } + input.ReadMessage(originalRequest_); + break; + } + case 34: { + global::Grpc.Reflection.V1Alpha.FileDescriptorResponse subBuilder = new global::Grpc.Reflection.V1Alpha.FileDescriptorResponse(); + if (messageResponseCase_ == MessageResponseOneofCase.FileDescriptorResponse) { + subBuilder.MergeFrom(FileDescriptorResponse); + } + input.ReadMessage(subBuilder); + FileDescriptorResponse = subBuilder; + break; + } + case 42: { + global::Grpc.Reflection.V1Alpha.ExtensionNumberResponse subBuilder = new global::Grpc.Reflection.V1Alpha.ExtensionNumberResponse(); + if (messageResponseCase_ == MessageResponseOneofCase.AllExtensionNumbersResponse) { + subBuilder.MergeFrom(AllExtensionNumbersResponse); + } + input.ReadMessage(subBuilder); + AllExtensionNumbersResponse = subBuilder; + break; + } + case 50: { + global::Grpc.Reflection.V1Alpha.ListServiceResponse subBuilder = new global::Grpc.Reflection.V1Alpha.ListServiceResponse(); + if (messageResponseCase_ == MessageResponseOneofCase.ListServicesResponse) { + subBuilder.MergeFrom(ListServicesResponse); + } + input.ReadMessage(subBuilder); + ListServicesResponse = subBuilder; + break; + } + case 58: { + global::Grpc.Reflection.V1Alpha.ErrorResponse subBuilder = new global::Grpc.Reflection.V1Alpha.ErrorResponse(); + if (messageResponseCase_ == MessageResponseOneofCase.ErrorResponse) { + subBuilder.MergeFrom(ErrorResponse); + } + input.ReadMessage(subBuilder); + ErrorResponse = subBuilder; + break; + } + } + } + } + + } + + /// + /// Serialized FileDescriptorProto messages sent by the server answering + /// a file_by_filename, file_containing_symbol, or file_containing_extension + /// request. + /// + public sealed partial class FileDescriptorResponse : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new FileDescriptorResponse()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Grpc.Reflection.V1Alpha.ReflectionReflection.Descriptor.MessageTypes[3]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public FileDescriptorResponse() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public FileDescriptorResponse(FileDescriptorResponse other) : this() { + fileDescriptorProto_ = other.fileDescriptorProto_.Clone(); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public FileDescriptorResponse Clone() { + return new FileDescriptorResponse(this); + } + + /// Field number for the "file_descriptor_proto" field. + public const int FileDescriptorProtoFieldNumber = 1; + private static readonly pb::FieldCodec _repeated_fileDescriptorProto_codec + = pb::FieldCodec.ForBytes(10); + private readonly pbc::RepeatedField fileDescriptorProto_ = new pbc::RepeatedField(); + /// + /// Serialized FileDescriptorProto messages. We avoid taking a dependency on + /// descriptor.proto, which uses proto2 only features, by making them opaque + /// bytes instead. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField FileDescriptorProto { + get { return fileDescriptorProto_; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as FileDescriptorResponse); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(FileDescriptorResponse other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if(!fileDescriptorProto_.Equals(other.fileDescriptorProto_)) return false; + return true; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + hash ^= fileDescriptorProto_.GetHashCode(); + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + fileDescriptorProto_.WriteTo(output, _repeated_fileDescriptorProto_codec); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + size += fileDescriptorProto_.CalculateSize(_repeated_fileDescriptorProto_codec); + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(FileDescriptorResponse other) { + if (other == null) { + return; + } + fileDescriptorProto_.Add(other.fileDescriptorProto_); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + case 10: { + fileDescriptorProto_.AddEntriesFrom(input, _repeated_fileDescriptorProto_codec); + break; + } + } + } + } + + } + + /// + /// A list of extension numbers sent by the server answering + /// all_extension_numbers_of_type request. + /// + public sealed partial class ExtensionNumberResponse : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ExtensionNumberResponse()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Grpc.Reflection.V1Alpha.ReflectionReflection.Descriptor.MessageTypes[4]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ExtensionNumberResponse() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ExtensionNumberResponse(ExtensionNumberResponse other) : this() { + baseTypeName_ = other.baseTypeName_; + extensionNumber_ = other.extensionNumber_.Clone(); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ExtensionNumberResponse Clone() { + return new ExtensionNumberResponse(this); + } + + /// Field number for the "base_type_name" field. + public const int BaseTypeNameFieldNumber = 1; + private string baseTypeName_ = ""; + /// + /// Full name of the base type, including the package name. The format + /// is <package>.<type> + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string BaseTypeName { + get { return baseTypeName_; } + set { + baseTypeName_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "extension_number" field. + public const int ExtensionNumberFieldNumber = 2; + private static readonly pb::FieldCodec _repeated_extensionNumber_codec + = pb::FieldCodec.ForInt32(18); + private readonly pbc::RepeatedField extensionNumber_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField ExtensionNumber { + get { return extensionNumber_; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as ExtensionNumberResponse); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(ExtensionNumberResponse other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (BaseTypeName != other.BaseTypeName) return false; + if(!extensionNumber_.Equals(other.extensionNumber_)) return false; + return true; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (BaseTypeName.Length != 0) hash ^= BaseTypeName.GetHashCode(); + hash ^= extensionNumber_.GetHashCode(); + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (BaseTypeName.Length != 0) { + output.WriteRawTag(10); + output.WriteString(BaseTypeName); + } + extensionNumber_.WriteTo(output, _repeated_extensionNumber_codec); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (BaseTypeName.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(BaseTypeName); + } + size += extensionNumber_.CalculateSize(_repeated_extensionNumber_codec); + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ExtensionNumberResponse other) { + if (other == null) { + return; + } + if (other.BaseTypeName.Length != 0) { + BaseTypeName = other.BaseTypeName; + } + extensionNumber_.Add(other.extensionNumber_); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + case 10: { + BaseTypeName = input.ReadString(); + break; + } + case 18: + case 16: { + extensionNumber_.AddEntriesFrom(input, _repeated_extensionNumber_codec); + break; + } + } + } + } + + } + + /// + /// A list of ServiceResponse sent by the server answering list_services request. + /// + public sealed partial class ListServiceResponse : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ListServiceResponse()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Grpc.Reflection.V1Alpha.ReflectionReflection.Descriptor.MessageTypes[5]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ListServiceResponse() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ListServiceResponse(ListServiceResponse other) : this() { + service_ = other.service_.Clone(); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ListServiceResponse Clone() { + return new ListServiceResponse(this); + } + + /// Field number for the "service" field. + public const int ServiceFieldNumber = 1; + private static readonly pb::FieldCodec _repeated_service_codec + = pb::FieldCodec.ForMessage(10, global::Grpc.Reflection.V1Alpha.ServiceResponse.Parser); + private readonly pbc::RepeatedField service_ = new pbc::RepeatedField(); + /// + /// The information of each service may be expanded in the future, so we use + /// ServiceResponse message to encapsulate it. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField Service { + get { return service_; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as ListServiceResponse); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(ListServiceResponse other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if(!service_.Equals(other.service_)) return false; + return true; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + hash ^= service_.GetHashCode(); + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + service_.WriteTo(output, _repeated_service_codec); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + size += service_.CalculateSize(_repeated_service_codec); + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ListServiceResponse other) { + if (other == null) { + return; + } + service_.Add(other.service_); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + case 10: { + service_.AddEntriesFrom(input, _repeated_service_codec); + break; + } + } + } + } + + } + + /// + /// The information of a single service used by ListServiceResponse to answer + /// list_services request. + /// + public sealed partial class ServiceResponse : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ServiceResponse()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Grpc.Reflection.V1Alpha.ReflectionReflection.Descriptor.MessageTypes[6]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ServiceResponse() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ServiceResponse(ServiceResponse other) : this() { + name_ = other.name_; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ServiceResponse Clone() { + return new ServiceResponse(this); + } + + /// Field number for the "name" field. + public const int NameFieldNumber = 1; + private string name_ = ""; + /// + /// Full name of a registered service, including its package name. The format + /// is <package>.<service> + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string Name { + get { return name_; } + set { + name_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as ServiceResponse); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(ServiceResponse other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Name != other.Name) return false; + return true; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (Name.Length != 0) hash ^= Name.GetHashCode(); + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (Name.Length != 0) { + output.WriteRawTag(10); + output.WriteString(Name); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (Name.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Name); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ServiceResponse other) { + if (other == null) { + return; + } + if (other.Name.Length != 0) { + Name = other.Name; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + case 10: { + Name = input.ReadString(); + break; + } + } + } + } + + } + + /// + /// The error code and error message sent by the server when an error occurs. + /// + public sealed partial class ErrorResponse : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ErrorResponse()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Grpc.Reflection.V1Alpha.ReflectionReflection.Descriptor.MessageTypes[7]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ErrorResponse() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ErrorResponse(ErrorResponse other) : this() { + errorCode_ = other.errorCode_; + errorMessage_ = other.errorMessage_; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ErrorResponse Clone() { + return new ErrorResponse(this); + } + + /// Field number for the "error_code" field. + public const int ErrorCodeFieldNumber = 1; + private int errorCode_; + /// + /// This field uses the error codes defined in grpc::StatusCode. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int ErrorCode { + get { return errorCode_; } + set { + errorCode_ = value; + } + } + + /// Field number for the "error_message" field. + public const int ErrorMessageFieldNumber = 2; + private string errorMessage_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string ErrorMessage { + get { return errorMessage_; } + set { + errorMessage_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as ErrorResponse); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(ErrorResponse other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (ErrorCode != other.ErrorCode) return false; + if (ErrorMessage != other.ErrorMessage) return false; + return true; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (ErrorCode != 0) hash ^= ErrorCode.GetHashCode(); + if (ErrorMessage.Length != 0) hash ^= ErrorMessage.GetHashCode(); + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (ErrorCode != 0) { + output.WriteRawTag(8); + output.WriteInt32(ErrorCode); + } + if (ErrorMessage.Length != 0) { + output.WriteRawTag(18); + output.WriteString(ErrorMessage); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (ErrorCode != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(ErrorCode); + } + if (ErrorMessage.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(ErrorMessage); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ErrorResponse other) { + if (other == null) { + return; + } + if (other.ErrorCode != 0) { + ErrorCode = other.ErrorCode; + } + if (other.ErrorMessage.Length != 0) { + ErrorMessage = other.ErrorMessage; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + case 8: { + ErrorCode = input.ReadInt32(); + break; + } + case 18: { + ErrorMessage = input.ReadString(); + break; + } + } + } + } + + } + + #endregion + +} + +#endregion Designer generated code diff --git a/src/csharp/Grpc.Reflection/ReflectionGrpc.cs b/src/csharp/Grpc.Reflection/ReflectionGrpc.cs new file mode 100644 index 00000000000..229244e6736 --- /dev/null +++ b/src/csharp/Grpc.Reflection/ReflectionGrpc.cs @@ -0,0 +1,132 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: reflection.proto +// Original file comments: +// Copyright 2016, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Service exported by server reflection +// +#region Designer generated code + +using System; +using System.Threading; +using System.Threading.Tasks; +using Grpc.Core; + +namespace Grpc.Reflection.V1Alpha { + public static class ServerReflection + { + static readonly string __ServiceName = "grpc.reflection.v1alpha.ServerReflection"; + + static readonly Marshaller __Marshaller_ServerReflectionRequest = Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Reflection.V1Alpha.ServerReflectionRequest.Parser.ParseFrom); + static readonly Marshaller __Marshaller_ServerReflectionResponse = Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Reflection.V1Alpha.ServerReflectionResponse.Parser.ParseFrom); + + static readonly Method __Method_ServerReflectionInfo = new Method( + MethodType.DuplexStreaming, + __ServiceName, + "ServerReflectionInfo", + __Marshaller_ServerReflectionRequest, + __Marshaller_ServerReflectionResponse); + + /// Service descriptor + public static global::Google.Protobuf.Reflection.ServiceDescriptor Descriptor + { + get { return global::Grpc.Reflection.V1Alpha.ReflectionReflection.Descriptor.Services[0]; } + } + + /// Base class for server-side implementations of ServerReflection + public abstract class ServerReflectionBase + { + /// + /// The reflection service is structured as a bidirectional stream, ensuring + /// all related requests go to a single server. + /// + public virtual global::System.Threading.Tasks.Task ServerReflectionInfo(IAsyncStreamReader requestStream, IServerStreamWriter responseStream, ServerCallContext context) + { + throw new RpcException(new Status(StatusCode.Unimplemented, "")); + } + + } + + /// Client for ServerReflection + public class ServerReflectionClient : ClientBase + { + /// Creates a new client for ServerReflection + /// The channel to use to make remote calls. + public ServerReflectionClient(Channel channel) : base(channel) + { + } + /// Creates a new client for ServerReflection that uses a custom CallInvoker. + /// The callInvoker to use to make remote calls. + public ServerReflectionClient(CallInvoker callInvoker) : base(callInvoker) + { + } + /// Protected parameterless constructor to allow creation of test doubles. + protected ServerReflectionClient() : base() + { + } + /// Protected constructor to allow creation of configured clients. + /// The client configuration. + protected ServerReflectionClient(ClientBaseConfiguration configuration) : base(configuration) + { + } + + /// + /// The reflection service is structured as a bidirectional stream, ensuring + /// all related requests go to a single server. + /// + public virtual AsyncDuplexStreamingCall ServerReflectionInfo(Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) + { + return ServerReflectionInfo(new CallOptions(headers, deadline, cancellationToken)); + } + /// + /// The reflection service is structured as a bidirectional stream, ensuring + /// all related requests go to a single server. + /// + public virtual AsyncDuplexStreamingCall ServerReflectionInfo(CallOptions options) + { + return CallInvoker.AsyncDuplexStreamingCall(__Method_ServerReflectionInfo, null, options); + } + /// Creates a new instance of client from given ClientBaseConfiguration. + protected override ServerReflectionClient NewInstance(ClientBaseConfiguration configuration) + { + return new ServerReflectionClient(configuration); + } + } + + /// Creates service definition that can be registered with a server + public static ServerServiceDefinition BindService(ServerReflectionBase serviceImpl) + { + return ServerServiceDefinition.CreateBuilder() + .AddMethod(__Method_ServerReflectionInfo, serviceImpl.ServerReflectionInfo).Build(); + } + + } +} +#endregion diff --git a/src/csharp/Grpc.Reflection/ReflectionServiceImpl.cs b/src/csharp/Grpc.Reflection/ReflectionServiceImpl.cs new file mode 100644 index 00000000000..105c4c963b5 --- /dev/null +++ b/src/csharp/Grpc.Reflection/ReflectionServiceImpl.cs @@ -0,0 +1,173 @@ +#region Copyright notice and license +// Copyright 2015, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +using Grpc.Core; +using Grpc.Core.Utils; +using Grpc.Reflection.V1Alpha; +using Google.Protobuf.Reflection; + +namespace Grpc.Reflection +{ + /// + /// Implementation of server reflection service. + /// + public class ReflectionServiceImpl : Grpc.Reflection.V1Alpha.ServerReflection.ServerReflectionBase + { + readonly List services; + readonly SymbolRegistry symbolRegistry; + + /// + /// Creates a new instance of ReflectionServiceIml. + /// + public ReflectionServiceImpl(IEnumerable services, SymbolRegistry symbolRegistry) + { + this.services = new List(services); + this.symbolRegistry = symbolRegistry; + } + + /// + /// Creates a new instance of ReflectionServiceIml. + /// + public ReflectionServiceImpl(IEnumerable serviceDescriptors) + { + this.services = new List(serviceDescriptors.Select((serviceDescriptor) => serviceDescriptor.FullName)); + this.symbolRegistry = SymbolRegistry.FromFiles(serviceDescriptors.Select((serviceDescriptor) => serviceDescriptor.File)); + } + + /// + /// Creates a new instance of ReflectionServiceIml. + /// + public ReflectionServiceImpl(params ServiceDescriptor[] serviceDescriptors) : this((IEnumerable) serviceDescriptors) + { + } + + public override async Task ServerReflectionInfo(IAsyncStreamReader requestStream, IServerStreamWriter responseStream, ServerCallContext context) + { + while (await requestStream.MoveNext()) + { + var response = ProcessRequest(requestStream.Current); + await responseStream.WriteAsync(response); + } + } + + ServerReflectionResponse ProcessRequest(ServerReflectionRequest request) + { + switch (request.MessageRequestCase) + { + case ServerReflectionRequest.MessageRequestOneofCase.FileByFilename: + return FileByFilename(request.FileByFilename); + case ServerReflectionRequest.MessageRequestOneofCase.FileContainingSymbol: + return FileContainingSymbol(request.FileContainingSymbol); + case ServerReflectionRequest.MessageRequestOneofCase.ListServices: + return ListServices(); + case ServerReflectionRequest.MessageRequestOneofCase.AllExtensionNumbersOfType: + case ServerReflectionRequest.MessageRequestOneofCase.FileContainingExtension: + default: + return CreateErrorResponse(StatusCode.Unimplemented, "Request type not supported by C# reflection service."); + } + } + + ServerReflectionResponse FileByFilename(string filename) + { + FileDescriptor file = symbolRegistry.FileByName(filename); + if (file == null) + { + return CreateErrorResponse(StatusCode.NotFound, "File not found."); + } + + var transitiveDependencies = new HashSet(); + CollectTransitiveDependencies(file, transitiveDependencies); + + return new ServerReflectionResponse + { + FileDescriptorResponse = new FileDescriptorResponse { FileDescriptorProto = { transitiveDependencies.Select((d) => d.SerializedData) } } + }; + } + + ServerReflectionResponse FileContainingSymbol(string symbol) + { + FileDescriptor file = symbolRegistry.FileContainingSymbol(symbol); + if (file == null) + { + return CreateErrorResponse(StatusCode.NotFound, "Symbol not found."); + } + + var transitiveDependencies = new HashSet(); + CollectTransitiveDependencies(file, transitiveDependencies); + + return new ServerReflectionResponse + { + FileDescriptorResponse = new FileDescriptorResponse { FileDescriptorProto = { transitiveDependencies.Select((d) => d.SerializedData) } } + }; + } + + ServerReflectionResponse ListServices() + { + var serviceResponses = new ListServiceResponse(); + foreach (string serviceName in services) + { + serviceResponses.Service.Add(new ServiceResponse { Name = serviceName }); + } + + return new ServerReflectionResponse + { + ListServicesResponse = serviceResponses + }; + } + + ServerReflectionResponse CreateErrorResponse(StatusCode status, string message) + { + return new ServerReflectionResponse + { + ErrorResponse = new ErrorResponse { ErrorCode = (int) status, ErrorMessage = message } + }; + } + + void CollectTransitiveDependencies(FileDescriptor descriptor, HashSet pool) + { + pool.Add(descriptor); + foreach (var dependency in descriptor.Dependencies) + { + if (pool.Add(dependency)) + { + // descriptors cannot have circular dependencies + CollectTransitiveDependencies(dependency, pool); + } + } + } + } +} diff --git a/src/csharp/Grpc.Reflection/Settings.StyleCop b/src/csharp/Grpc.Reflection/Settings.StyleCop new file mode 100644 index 00000000000..2942add9623 --- /dev/null +++ b/src/csharp/Grpc.Reflection/Settings.StyleCop @@ -0,0 +1,10 @@ + + + Health.cs + + + False + + + + diff --git a/src/csharp/Grpc.Reflection/SymbolRegistry.cs b/src/csharp/Grpc.Reflection/SymbolRegistry.cs new file mode 100644 index 00000000000..b7104ab2f9a --- /dev/null +++ b/src/csharp/Grpc.Reflection/SymbolRegistry.cs @@ -0,0 +1,160 @@ +#region Copyright notice and license +// Copyright 2015, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +using System.Collections.Generic; +using Grpc.Core.Utils; +using Google.Protobuf.Reflection; + +namespace Grpc.Reflection +{ + /// Registry of protobuf symbols + public class SymbolRegistry + { + private readonly Dictionary filesByName; + private readonly Dictionary filesBySymbol; + + private SymbolRegistry(Dictionary filesByName, Dictionary filesBySymbol) + { + this.filesByName = new Dictionary(filesByName); + this.filesBySymbol = new Dictionary(filesBySymbol); + } + + /// + /// Creates a symbol registry from the specified set of file descriptors. + /// + /// The set of files to include in the registry. Must not contain null values. + /// A symbol registry for the given files. + public static SymbolRegistry FromFiles(IEnumerable fileDescriptors) + { + GrpcPreconditions.CheckNotNull(fileDescriptors); + var builder = new Builder(); + foreach (var file in fileDescriptors) + { + builder.AddFile(file); + } + return builder.Build(); + } + + /// + /// Gets file descriptor for given file name (including package path). Returns null if not found. + /// + public FileDescriptor FileByName(string filename) + { + FileDescriptor file; + filesByName.TryGetValue(filename, out file); + return file; + } + + /// + /// Gets file descriptor that contains definition of given symbol full name (including package path). Returns null if not found. + /// + public FileDescriptor FileContainingSymbol(string symbol) + { + FileDescriptor file; + filesBySymbol.TryGetValue(symbol, out file); + return file; + } + + /// + /// Builder class which isn't exposed, but acts as a convenient alternative to passing round two dictionaries in recursive calls. + /// + private class Builder + { + private readonly Dictionary filesByName; + private readonly Dictionary filesBySymbol; + + + internal Builder() + { + filesByName = new Dictionary(); + filesBySymbol = new Dictionary(); + } + + internal void AddFile(FileDescriptor fileDescriptor) + { + if (filesByName.ContainsKey(fileDescriptor.Name)) + { + return; + } + filesByName.Add(fileDescriptor.Name, fileDescriptor); + + foreach (var dependency in fileDescriptor.Dependencies) + { + AddFile(dependency); + } + foreach (var enumeration in fileDescriptor.EnumTypes) + { + AddEnum(enumeration); + } + foreach (var message in fileDescriptor.MessageTypes) + { + AddMessage(message); + } + foreach (var service in fileDescriptor.Services) + { + AddService(service); + } + } + + private void AddEnum(EnumDescriptor enumDescriptor) + { + filesBySymbol[enumDescriptor.FullName] = enumDescriptor.File; + } + + private void AddMessage(MessageDescriptor messageDescriptor) + { + foreach (var nestedEnum in messageDescriptor.EnumTypes) + { + AddEnum(nestedEnum); + } + foreach (var nestedType in messageDescriptor.NestedTypes) + { + AddMessage(nestedType); + } + filesBySymbol[messageDescriptor.FullName] = messageDescriptor.File; + } + + private void AddService(ServiceDescriptor serviceDescriptor) + { + foreach (var method in serviceDescriptor.Methods) + { + filesBySymbol[method.FullName] = method.File; + } + filesBySymbol[serviceDescriptor.FullName] = serviceDescriptor.File; + } + + internal SymbolRegistry Build() + { + return new SymbolRegistry(filesByName, filesBySymbol); + } + } + } +} diff --git a/src/csharp/Grpc.Reflection/packages.config b/src/csharp/Grpc.Reflection/packages.config new file mode 100644 index 00000000000..5ab40b7a8ce --- /dev/null +++ b/src/csharp/Grpc.Reflection/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/src/csharp/Grpc.Reflection/project.json b/src/csharp/Grpc.Reflection/project.json new file mode 100644 index 00000000000..fc37bb2682a --- /dev/null +++ b/src/csharp/Grpc.Reflection/project.json @@ -0,0 +1,41 @@ +{ + "version": "1.1.0-dev", + "title": "gRPC C# Reflection", + "authors": [ "Google Inc." ], + "copyright": "Copyright 2016, Google Inc.", + "packOptions": { + "summary": "Implementation of gRPC reflection service", + "description": "Provides information about services running on a gRPC C# server.", + "owners": [ "grpc-packages" ], + "licenseUrl": "https://github.com/grpc/grpc/blob/master/LICENSE", + "projectUrl": "https://github.com/grpc/grpc", + "requireLicenseAcceptance": false, + "tags": [ "gRPC reflection" ] + }, + "buildOptions": { + "define": [ "SIGNED" ], + "keyFile": "../keys/Grpc.snk", + "publicSign": true, + "xmlDoc": true, + "compile": { + "includeFiles": [ "../Grpc.Core/Version.cs" ] + } + }, + "dependencies": { + "Grpc.Core": "1.1.0-dev", + "Google.Protobuf": "3.0.0" + }, + "frameworks": { + "net45": { + "frameworkAssemblies": { + "System.Runtime": "", + "System.IO": "" + } + }, + "netstandard1.5": { + "dependencies": { + "NETStandard.Library": "1.6.0" + } + } + } +} diff --git a/src/csharp/Grpc.sln b/src/csharp/Grpc.sln index 9be36c0caa4..2e6a8fd4354 100644 --- a/src/csharp/Grpc.sln +++ b/src/csharp/Grpc.sln @@ -36,6 +36,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Grpc.IntegrationTesting.Qps EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Grpc.IntegrationTesting.StressClient", "Grpc.IntegrationTesting.StressClient\Grpc.IntegrationTesting.StressClient.csproj", "{ADEBA147-80AE-4710-82E9-5B7F93690266}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Grpc.Reflection", "Grpc.Reflection\Grpc.Reflection.csproj", "{4F18CF52-B3DB-4A77-97C5-7F7F4B6C1715}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Grpc.Reflection.Tests", "Grpc.Reflection.Tests\Grpc.Reflection.Tests.csproj", "{B88F91D6-436D-4C78-8B99-47800FA8DE03}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -55,6 +59,12 @@ Global {3D166931-BA2D-416E-95A3-D36E8F6E90B9}.Release|Any CPU.Build.0 = Release|Any CPU {3D166931-BA2D-416E-95A3-D36E8F6E90B9}.ReleaseSigned|Any CPU.ActiveCfg = ReleaseSigned|Any CPU {3D166931-BA2D-416E-95A3-D36E8F6E90B9}.ReleaseSigned|Any CPU.Build.0 = ReleaseSigned|Any CPU + {4F18CF52-B3DB-4A77-97C5-7F7F4B6C1715}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4F18CF52-B3DB-4A77-97C5-7F7F4B6C1715}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4F18CF52-B3DB-4A77-97C5-7F7F4B6C1715}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4F18CF52-B3DB-4A77-97C5-7F7F4B6C1715}.Release|Any CPU.Build.0 = Release|Any CPU + {4F18CF52-B3DB-4A77-97C5-7F7F4B6C1715}.ReleaseSigned|Any CPU.ActiveCfg = ReleaseSigned|Any CPU + {4F18CF52-B3DB-4A77-97C5-7F7F4B6C1715}.ReleaseSigned|Any CPU.Build.0 = ReleaseSigned|Any CPU {61ECB8EE-0C96-4F8E-B187-8E4D227417C0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {61ECB8EE-0C96-4F8E-B187-8E4D227417C0}.Debug|Any CPU.Build.0 = Debug|Any CPU {61ECB8EE-0C96-4F8E-B187-8E4D227417C0}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -103,6 +113,12 @@ Global {B82B7DFE-7F7B-40EF-B3D6-064FF2B01294}.Release|Any CPU.Build.0 = Release|Any CPU {B82B7DFE-7F7B-40EF-B3D6-064FF2B01294}.ReleaseSigned|Any CPU.ActiveCfg = Release|Any CPU {B82B7DFE-7F7B-40EF-B3D6-064FF2B01294}.ReleaseSigned|Any CPU.Build.0 = Release|Any CPU + {B88F91D6-436D-4C78-8B99-47800FA8DE03}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B88F91D6-436D-4C78-8B99-47800FA8DE03}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B88F91D6-436D-4C78-8B99-47800FA8DE03}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B88F91D6-436D-4C78-8B99-47800FA8DE03}.Release|Any CPU.Build.0 = Release|Any CPU + {B88F91D6-436D-4C78-8B99-47800FA8DE03}.ReleaseSigned|Any CPU.ActiveCfg = ReleaseSigned|Any CPU + {B88F91D6-436D-4C78-8B99-47800FA8DE03}.ReleaseSigned|Any CPU.Build.0 = ReleaseSigned|Any CPU {BF62FE08-373A-43D6-9D73-41CAA38B7011}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {BF62FE08-373A-43D6-9D73-41CAA38B7011}.Debug|Any CPU.Build.0 = Debug|Any CPU {BF62FE08-373A-43D6-9D73-41CAA38B7011}.Release|Any CPU.ActiveCfg = Release|Any CPU diff --git a/src/csharp/generate_proto_csharp.sh b/src/csharp/generate_proto_csharp.sh index 79488e02a53..429289b6fcc 100755 --- a/src/csharp/generate_proto_csharp.sh +++ b/src/csharp/generate_proto_csharp.sh @@ -36,6 +36,7 @@ PROTOC=bins/opt/protobuf/protoc PLUGIN=protoc-gen-grpc=bins/opt/grpc_csharp_plugin EXAMPLES_DIR=src/csharp/Grpc.Examples HEALTHCHECK_DIR=src/csharp/Grpc.HealthCheck +REFLECTION_DIR=src/csharp/Grpc.Reflection TESTING_DIR=src/csharp/Grpc.IntegrationTesting $PROTOC --plugin=$PLUGIN --csharp_out=$EXAMPLES_DIR --grpc_out=$EXAMPLES_DIR \ @@ -43,6 +44,9 @@ $PROTOC --plugin=$PLUGIN --csharp_out=$EXAMPLES_DIR --grpc_out=$EXAMPLES_DIR \ $PROTOC --plugin=$PLUGIN --csharp_out=$HEALTHCHECK_DIR --grpc_out=$HEALTHCHECK_DIR \ -I src/proto/grpc/health/v1 src/proto/grpc/health/v1/health.proto + +$PROTOC --plugin=$PLUGIN --csharp_out=$REFLECTION_DIR --grpc_out=$REFLECTION_DIR \ + -I src/proto/grpc/reflection/v1alpha src/proto/grpc/reflection/v1alpha/reflection.proto $PROTOC --plugin=$PLUGIN --csharp_out=$TESTING_DIR --grpc_out=$TESTING_DIR \ -I . src/proto/grpc/testing/{control,empty,messages,metrics,payloads,services,stats,test}.proto diff --git a/src/csharp/tests.json b/src/csharp/tests.json index 7e7aee1093a..4ce6769eee5 100644 --- a/src/csharp/tests.json +++ b/src/csharp/tests.json @@ -48,5 +48,9 @@ "Grpc.IntegrationTesting.MetadataCredentialsTest", "Grpc.IntegrationTesting.RunnerClientServerTest", "Grpc.IntegrationTesting.SslCredentialsTest" + ], + "Grpc.Reflection.Tests": [ + "Grpc.Reflection.Tests.ReflectionClientServerTest", + "Grpc.Reflection.Tests.SymbolRegistryTest" ] } \ No newline at end of file diff --git a/templates/src/csharp/Grpc.Reflection.Tests/project.json.template b/templates/src/csharp/Grpc.Reflection.Tests/project.json.template new file mode 100644 index 00000000000..2869609138b --- /dev/null +++ b/templates/src/csharp/Grpc.Reflection.Tests/project.json.template @@ -0,0 +1,26 @@ +%YAML 1.2 +--- | + { + <%include file="../build_options.include" args="executable=True"/> + "dependencies": { + "Grpc.Reflection": { + "target": "project" + }, + "NUnit": "3.2.0", + "NUnitLite": "3.2.0-*" + }, + "frameworks": { + "net45": { }, + "netcoreapp1.0": { + "imports": [ + "portable-net45" + ], + "dependencies": { + "Microsoft.NETCore.App": { + "type": "platform", + "version": "1.0.0" + } + } + } + } + } diff --git a/templates/src/csharp/Grpc.Reflection/project.json.template b/templates/src/csharp/Grpc.Reflection/project.json.template new file mode 100644 index 00000000000..c13b3a8d7d9 --- /dev/null +++ b/templates/src/csharp/Grpc.Reflection/project.json.template @@ -0,0 +1,43 @@ +%YAML 1.2 +--- | + { + "version": "${settings.csharp_version}", + "title": "gRPC C# Reflection", + "authors": [ "Google Inc." ], + "copyright": "Copyright 2016, Google Inc.", + "packOptions": { + "summary": "Implementation of gRPC reflection service", + "description": "Provides information about services running on a gRPC C# server.", + "owners": [ "grpc-packages" ], + "licenseUrl": "https://github.com/grpc/grpc/blob/master/LICENSE", + "projectUrl": "https://github.com/grpc/grpc", + "requireLicenseAcceptance": false, + "tags": [ "gRPC reflection" ] + }, + "buildOptions": { + "define": [ "SIGNED" ], + "keyFile": "../keys/Grpc.snk", + "publicSign": true, + "xmlDoc": true, + "compile": { + "includeFiles": [ "../Grpc.Core/Version.cs" ] + } + }, + "dependencies": { + "Grpc.Core": "${settings.csharp_version}", + "Google.Protobuf": "3.0.0" + }, + "frameworks": { + "net45": { + "frameworkAssemblies": { + "System.Runtime": "", + "System.IO": "" + } + }, + "netstandard1.5": { + "dependencies": { + "NETStandard.Library": "1.6.0" + } + } + } + } From 091057a4e5aa52c5d6de9ef3a712d8e32603d240 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Thu, 24 Nov 2016 13:08:45 +0100 Subject: [PATCH 67/86] fix proto import paths for C# where possible --- src/csharp/Grpc.Examples/Math.cs | 24 +++---- src/csharp/Grpc.Examples/MathGrpc.cs | 2 +- src/csharp/Grpc.HealthCheck/Health.cs | 22 +++---- src/csharp/Grpc.HealthCheck/HealthGrpc.cs | 2 +- src/csharp/Grpc.Reflection/Reflection.cs | 66 ++++++++++---------- src/csharp/Grpc.Reflection/ReflectionGrpc.cs | 8 +-- src/csharp/generate_proto_csharp.sh | 9 ++- 7 files changed, 68 insertions(+), 65 deletions(-) diff --git a/src/csharp/Grpc.Examples/Math.cs b/src/csharp/Grpc.Examples/Math.cs index fae4fd3c264..e5b76f83052 100644 --- a/src/csharp/Grpc.Examples/Math.cs +++ b/src/csharp/Grpc.Examples/Math.cs @@ -1,5 +1,5 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! -// source: math.proto +// source: math/math.proto #pragma warning disable 1591, 0612, 3021 #region Designer generated code @@ -9,11 +9,11 @@ using pbr = global::Google.Protobuf.Reflection; using scg = global::System.Collections.Generic; namespace Math { - /// Holder for reflection information generated from math.proto + /// Holder for reflection information generated from math/math.proto public static partial class MathReflection { #region Descriptor - /// File descriptor for math.proto + /// File descriptor for math/math.proto public static pbr::FileDescriptor Descriptor { get { return descriptor; } } @@ -22,15 +22,15 @@ namespace Math { static MathReflection() { byte[] descriptorData = global::System.Convert.FromBase64String( string.Concat( - "CgptYXRoLnByb3RvEgRtYXRoIiwKB0RpdkFyZ3MSEAoIZGl2aWRlbmQYASAB", - "KAMSDwoHZGl2aXNvchgCIAEoAyIvCghEaXZSZXBseRIQCghxdW90aWVudBgB", - "IAEoAxIRCglyZW1haW5kZXIYAiABKAMiGAoHRmliQXJncxINCgVsaW1pdBgB", - "IAEoAyISCgNOdW0SCwoDbnVtGAEgASgDIhkKCEZpYlJlcGx5Eg0KBWNvdW50", - "GAEgASgDMqQBCgRNYXRoEiYKA0RpdhINLm1hdGguRGl2QXJncxoOLm1hdGgu", - "RGl2UmVwbHkiABIuCgdEaXZNYW55Eg0ubWF0aC5EaXZBcmdzGg4ubWF0aC5E", - "aXZSZXBseSIAKAEwARIjCgNGaWISDS5tYXRoLkZpYkFyZ3MaCS5tYXRoLk51", - "bSIAMAESHwoDU3VtEgkubWF0aC5OdW0aCS5tYXRoLk51bSIAKAFiBnByb3Rv", - "Mw==")); + "Cg9tYXRoL21hdGgucHJvdG8SBG1hdGgiLAoHRGl2QXJncxIQCghkaXZpZGVu", + "ZBgBIAEoAxIPCgdkaXZpc29yGAIgASgDIi8KCERpdlJlcGx5EhAKCHF1b3Rp", + "ZW50GAEgASgDEhEKCXJlbWFpbmRlchgCIAEoAyIYCgdGaWJBcmdzEg0KBWxp", + "bWl0GAEgASgDIhIKA051bRILCgNudW0YASABKAMiGQoIRmliUmVwbHkSDQoF", + "Y291bnQYASABKAMypAEKBE1hdGgSJgoDRGl2Eg0ubWF0aC5EaXZBcmdzGg4u", + "bWF0aC5EaXZSZXBseSIAEi4KB0Rpdk1hbnkSDS5tYXRoLkRpdkFyZ3MaDi5t", + "YXRoLkRpdlJlcGx5IgAoATABEiMKA0ZpYhINLm1hdGguRmliQXJncxoJLm1h", + "dGguTnVtIgAwARIfCgNTdW0SCS5tYXRoLk51bRoJLm1hdGguTnVtIgAoAWIG", + "cHJvdG8z")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { }, new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { diff --git a/src/csharp/Grpc.Examples/MathGrpc.cs b/src/csharp/Grpc.Examples/MathGrpc.cs index 21727d57c6b..8b431c72184 100644 --- a/src/csharp/Grpc.Examples/MathGrpc.cs +++ b/src/csharp/Grpc.Examples/MathGrpc.cs @@ -1,5 +1,5 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! -// source: math.proto +// source: math/math.proto // Original file comments: // Copyright 2015, Google Inc. // All rights reserved. diff --git a/src/csharp/Grpc.HealthCheck/Health.cs b/src/csharp/Grpc.HealthCheck/Health.cs index b8e2e2274cb..b9880d96369 100644 --- a/src/csharp/Grpc.HealthCheck/Health.cs +++ b/src/csharp/Grpc.HealthCheck/Health.cs @@ -1,5 +1,5 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! -// source: health.proto +// source: grpc/health/v1/health.proto #pragma warning disable 1591, 0612, 3021 #region Designer generated code @@ -9,11 +9,11 @@ using pbr = global::Google.Protobuf.Reflection; using scg = global::System.Collections.Generic; namespace Grpc.Health.V1 { - /// Holder for reflection information generated from health.proto + /// Holder for reflection information generated from grpc/health/v1/health.proto public static partial class HealthReflection { #region Descriptor - /// File descriptor for health.proto + /// File descriptor for grpc/health/v1/health.proto public static pbr::FileDescriptor Descriptor { get { return descriptor; } } @@ -22,14 +22,14 @@ namespace Grpc.Health.V1 { static HealthReflection() { byte[] descriptorData = global::System.Convert.FromBase64String( string.Concat( - "CgxoZWFsdGgucHJvdG8SDmdycGMuaGVhbHRoLnYxIiUKEkhlYWx0aENoZWNr", - "UmVxdWVzdBIPCgdzZXJ2aWNlGAEgASgJIpQBChNIZWFsdGhDaGVja1Jlc3Bv", - "bnNlEkEKBnN0YXR1cxgBIAEoDjIxLmdycGMuaGVhbHRoLnYxLkhlYWx0aENo", - "ZWNrUmVzcG9uc2UuU2VydmluZ1N0YXR1cyI6Cg1TZXJ2aW5nU3RhdHVzEgsK", - "B1VOS05PV04QABILCgdTRVJWSU5HEAESDwoLTk9UX1NFUlZJTkcQAjJaCgZI", - "ZWFsdGgSUAoFQ2hlY2sSIi5ncnBjLmhlYWx0aC52MS5IZWFsdGhDaGVja1Jl", - "cXVlc3QaIy5ncnBjLmhlYWx0aC52MS5IZWFsdGhDaGVja1Jlc3BvbnNlQhGq", - "Ag5HcnBjLkhlYWx0aC5WMWIGcHJvdG8z")); + "ChtncnBjL2hlYWx0aC92MS9oZWFsdGgucHJvdG8SDmdycGMuaGVhbHRoLnYx", + "IiUKEkhlYWx0aENoZWNrUmVxdWVzdBIPCgdzZXJ2aWNlGAEgASgJIpQBChNI", + "ZWFsdGhDaGVja1Jlc3BvbnNlEkEKBnN0YXR1cxgBIAEoDjIxLmdycGMuaGVh", + "bHRoLnYxLkhlYWx0aENoZWNrUmVzcG9uc2UuU2VydmluZ1N0YXR1cyI6Cg1T", + "ZXJ2aW5nU3RhdHVzEgsKB1VOS05PV04QABILCgdTRVJWSU5HEAESDwoLTk9U", + "X1NFUlZJTkcQAjJaCgZIZWFsdGgSUAoFQ2hlY2sSIi5ncnBjLmhlYWx0aC52", + "MS5IZWFsdGhDaGVja1JlcXVlc3QaIy5ncnBjLmhlYWx0aC52MS5IZWFsdGhD", + "aGVja1Jlc3BvbnNlQhGqAg5HcnBjLkhlYWx0aC5WMWIGcHJvdG8z")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { }, new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { diff --git a/src/csharp/Grpc.HealthCheck/HealthGrpc.cs b/src/csharp/Grpc.HealthCheck/HealthGrpc.cs index 03381f0b884..ad5cf11b75e 100644 --- a/src/csharp/Grpc.HealthCheck/HealthGrpc.cs +++ b/src/csharp/Grpc.HealthCheck/HealthGrpc.cs @@ -1,5 +1,5 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! -// source: health.proto +// source: grpc/health/v1/health.proto // Original file comments: // Copyright 2015, Google Inc. // All rights reserved. diff --git a/src/csharp/Grpc.Reflection/Reflection.cs b/src/csharp/Grpc.Reflection/Reflection.cs index bb92dfcbaeb..06c5d08030d 100644 --- a/src/csharp/Grpc.Reflection/Reflection.cs +++ b/src/csharp/Grpc.Reflection/Reflection.cs @@ -1,5 +1,5 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! -// source: reflection.proto +// source: grpc/reflection/v1alpha/reflection.proto #pragma warning disable 1591, 0612, 3021 #region Designer generated code @@ -9,11 +9,11 @@ using pbr = global::Google.Protobuf.Reflection; using scg = global::System.Collections.Generic; namespace Grpc.Reflection.V1Alpha { - /// Holder for reflection information generated from reflection.proto + /// Holder for reflection information generated from grpc/reflection/v1alpha/reflection.proto public static partial class ReflectionReflection { #region Descriptor - /// File descriptor for reflection.proto + /// File descriptor for grpc/reflection/v1alpha/reflection.proto public static pbr::FileDescriptor Descriptor { get { return descriptor; } } @@ -22,36 +22,36 @@ namespace Grpc.Reflection.V1Alpha { static ReflectionReflection() { byte[] descriptorData = global::System.Convert.FromBase64String( string.Concat( - "ChByZWZsZWN0aW9uLnByb3RvEhdncnBjLnJlZmxlY3Rpb24udjFhbHBoYSKK", - "AgoXU2VydmVyUmVmbGVjdGlvblJlcXVlc3QSDAoEaG9zdBgBIAEoCRIaChBm", - "aWxlX2J5X2ZpbGVuYW1lGAMgASgJSAASIAoWZmlsZV9jb250YWluaW5nX3N5", - "bWJvbBgEIAEoCUgAEk4KGWZpbGVfY29udGFpbmluZ19leHRlbnNpb24YBSAB", - "KAsyKS5ncnBjLnJlZmxlY3Rpb24udjFhbHBoYS5FeHRlbnNpb25SZXF1ZXN0", - "SAASJwodYWxsX2V4dGVuc2lvbl9udW1iZXJzX29mX3R5cGUYBiABKAlIABIX", - "Cg1saXN0X3NlcnZpY2VzGAcgASgJSABCEQoPbWVzc2FnZV9yZXF1ZXN0IkUK", - "EEV4dGVuc2lvblJlcXVlc3QSFwoPY29udGFpbmluZ190eXBlGAEgASgJEhgK", - "EGV4dGVuc2lvbl9udW1iZXIYAiABKAUi0QMKGFNlcnZlclJlZmxlY3Rpb25S", - "ZXNwb25zZRISCgp2YWxpZF9ob3N0GAEgASgJEkoKEG9yaWdpbmFsX3JlcXVl", - "c3QYAiABKAsyMC5ncnBjLnJlZmxlY3Rpb24udjFhbHBoYS5TZXJ2ZXJSZWZs", - "ZWN0aW9uUmVxdWVzdBJTChhmaWxlX2Rlc2NyaXB0b3JfcmVzcG9uc2UYBCAB", - "KAsyLy5ncnBjLnJlZmxlY3Rpb24udjFhbHBoYS5GaWxlRGVzY3JpcHRvclJl", - "c3BvbnNlSAASWgoeYWxsX2V4dGVuc2lvbl9udW1iZXJzX3Jlc3BvbnNlGAUg", - "ASgLMjAuZ3JwYy5yZWZsZWN0aW9uLnYxYWxwaGEuRXh0ZW5zaW9uTnVtYmVy", - "UmVzcG9uc2VIABJOChZsaXN0X3NlcnZpY2VzX3Jlc3BvbnNlGAYgASgLMiwu", - "Z3JwYy5yZWZsZWN0aW9uLnYxYWxwaGEuTGlzdFNlcnZpY2VSZXNwb25zZUgA", - "EkAKDmVycm9yX3Jlc3BvbnNlGAcgASgLMiYuZ3JwYy5yZWZsZWN0aW9uLnYx", - "YWxwaGEuRXJyb3JSZXNwb25zZUgAQhIKEG1lc3NhZ2VfcmVzcG9uc2UiNwoW", - "RmlsZURlc2NyaXB0b3JSZXNwb25zZRIdChVmaWxlX2Rlc2NyaXB0b3JfcHJv", - "dG8YASADKAwiSwoXRXh0ZW5zaW9uTnVtYmVyUmVzcG9uc2USFgoOYmFzZV90", - "eXBlX25hbWUYASABKAkSGAoQZXh0ZW5zaW9uX251bWJlchgCIAMoBSJQChNM", - "aXN0U2VydmljZVJlc3BvbnNlEjkKB3NlcnZpY2UYASADKAsyKC5ncnBjLnJl", - "ZmxlY3Rpb24udjFhbHBoYS5TZXJ2aWNlUmVzcG9uc2UiHwoPU2VydmljZVJl", - "c3BvbnNlEgwKBG5hbWUYASABKAkiOgoNRXJyb3JSZXNwb25zZRISCgplcnJv", - "cl9jb2RlGAEgASgFEhUKDWVycm9yX21lc3NhZ2UYAiABKAkykwEKEFNlcnZl", - "clJlZmxlY3Rpb24SfwoUU2VydmVyUmVmbGVjdGlvbkluZm8SMC5ncnBjLnJl", - "ZmxlY3Rpb24udjFhbHBoYS5TZXJ2ZXJSZWZsZWN0aW9uUmVxdWVzdBoxLmdy", - "cGMucmVmbGVjdGlvbi52MWFscGhhLlNlcnZlclJlZmxlY3Rpb25SZXNwb25z", - "ZSgBMAFiBnByb3RvMw==")); + "CihncnBjL3JlZmxlY3Rpb24vdjFhbHBoYS9yZWZsZWN0aW9uLnByb3RvEhdn", + "cnBjLnJlZmxlY3Rpb24udjFhbHBoYSKKAgoXU2VydmVyUmVmbGVjdGlvblJl", + "cXVlc3QSDAoEaG9zdBgBIAEoCRIaChBmaWxlX2J5X2ZpbGVuYW1lGAMgASgJ", + "SAASIAoWZmlsZV9jb250YWluaW5nX3N5bWJvbBgEIAEoCUgAEk4KGWZpbGVf", + "Y29udGFpbmluZ19leHRlbnNpb24YBSABKAsyKS5ncnBjLnJlZmxlY3Rpb24u", + "djFhbHBoYS5FeHRlbnNpb25SZXF1ZXN0SAASJwodYWxsX2V4dGVuc2lvbl9u", + "dW1iZXJzX29mX3R5cGUYBiABKAlIABIXCg1saXN0X3NlcnZpY2VzGAcgASgJ", + "SABCEQoPbWVzc2FnZV9yZXF1ZXN0IkUKEEV4dGVuc2lvblJlcXVlc3QSFwoP", + "Y29udGFpbmluZ190eXBlGAEgASgJEhgKEGV4dGVuc2lvbl9udW1iZXIYAiAB", + "KAUi0QMKGFNlcnZlclJlZmxlY3Rpb25SZXNwb25zZRISCgp2YWxpZF9ob3N0", + "GAEgASgJEkoKEG9yaWdpbmFsX3JlcXVlc3QYAiABKAsyMC5ncnBjLnJlZmxl", + "Y3Rpb24udjFhbHBoYS5TZXJ2ZXJSZWZsZWN0aW9uUmVxdWVzdBJTChhmaWxl", + "X2Rlc2NyaXB0b3JfcmVzcG9uc2UYBCABKAsyLy5ncnBjLnJlZmxlY3Rpb24u", + "djFhbHBoYS5GaWxlRGVzY3JpcHRvclJlc3BvbnNlSAASWgoeYWxsX2V4dGVu", + "c2lvbl9udW1iZXJzX3Jlc3BvbnNlGAUgASgLMjAuZ3JwYy5yZWZsZWN0aW9u", + "LnYxYWxwaGEuRXh0ZW5zaW9uTnVtYmVyUmVzcG9uc2VIABJOChZsaXN0X3Nl", + "cnZpY2VzX3Jlc3BvbnNlGAYgASgLMiwuZ3JwYy5yZWZsZWN0aW9uLnYxYWxw", + "aGEuTGlzdFNlcnZpY2VSZXNwb25zZUgAEkAKDmVycm9yX3Jlc3BvbnNlGAcg", + "ASgLMiYuZ3JwYy5yZWZsZWN0aW9uLnYxYWxwaGEuRXJyb3JSZXNwb25zZUgA", + "QhIKEG1lc3NhZ2VfcmVzcG9uc2UiNwoWRmlsZURlc2NyaXB0b3JSZXNwb25z", + "ZRIdChVmaWxlX2Rlc2NyaXB0b3JfcHJvdG8YASADKAwiSwoXRXh0ZW5zaW9u", + "TnVtYmVyUmVzcG9uc2USFgoOYmFzZV90eXBlX25hbWUYASABKAkSGAoQZXh0", + "ZW5zaW9uX251bWJlchgCIAMoBSJQChNMaXN0U2VydmljZVJlc3BvbnNlEjkK", + "B3NlcnZpY2UYASADKAsyKC5ncnBjLnJlZmxlY3Rpb24udjFhbHBoYS5TZXJ2", + "aWNlUmVzcG9uc2UiHwoPU2VydmljZVJlc3BvbnNlEgwKBG5hbWUYASABKAki", + "OgoNRXJyb3JSZXNwb25zZRISCgplcnJvcl9jb2RlGAEgASgFEhUKDWVycm9y", + "X21lc3NhZ2UYAiABKAkykwEKEFNlcnZlclJlZmxlY3Rpb24SfwoUU2VydmVy", + "UmVmbGVjdGlvbkluZm8SMC5ncnBjLnJlZmxlY3Rpb24udjFhbHBoYS5TZXJ2", + "ZXJSZWZsZWN0aW9uUmVxdWVzdBoxLmdycGMucmVmbGVjdGlvbi52MWFscGhh", + "LlNlcnZlclJlZmxlY3Rpb25SZXNwb25zZSgBMAFiBnByb3RvMw==")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { }, new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { diff --git a/src/csharp/Grpc.Reflection/ReflectionGrpc.cs b/src/csharp/Grpc.Reflection/ReflectionGrpc.cs index 229244e6736..1b6f96ce7c7 100644 --- a/src/csharp/Grpc.Reflection/ReflectionGrpc.cs +++ b/src/csharp/Grpc.Reflection/ReflectionGrpc.cs @@ -1,5 +1,5 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! -// source: reflection.proto +// source: grpc/reflection/v1alpha/reflection.proto // Original file comments: // Copyright 2016, Google Inc. // All rights reserved. @@ -40,7 +40,7 @@ using System.Threading.Tasks; using Grpc.Core; namespace Grpc.Reflection.V1Alpha { - public static class ServerReflection + public static partial class ServerReflection { static readonly string __ServiceName = "grpc.reflection.v1alpha.ServerReflection"; @@ -61,7 +61,7 @@ namespace Grpc.Reflection.V1Alpha { } /// Base class for server-side implementations of ServerReflection - public abstract class ServerReflectionBase + public abstract partial class ServerReflectionBase { /// /// The reflection service is structured as a bidirectional stream, ensuring @@ -75,7 +75,7 @@ namespace Grpc.Reflection.V1Alpha { } /// Client for ServerReflection - public class ServerReflectionClient : ClientBase + public partial class ServerReflectionClient : ClientBase { /// Creates a new client for ServerReflection /// The channel to use to make remote calls. diff --git a/src/csharp/generate_proto_csharp.sh b/src/csharp/generate_proto_csharp.sh index 429289b6fcc..ea5d678cba2 100755 --- a/src/csharp/generate_proto_csharp.sh +++ b/src/csharp/generate_proto_csharp.sh @@ -40,13 +40,16 @@ REFLECTION_DIR=src/csharp/Grpc.Reflection TESTING_DIR=src/csharp/Grpc.IntegrationTesting $PROTOC --plugin=$PLUGIN --csharp_out=$EXAMPLES_DIR --grpc_out=$EXAMPLES_DIR \ - -I src/proto/math src/proto/math/math.proto + -I src/proto src/proto/math/math.proto $PROTOC --plugin=$PLUGIN --csharp_out=$HEALTHCHECK_DIR --grpc_out=$HEALTHCHECK_DIR \ - -I src/proto/grpc/health/v1 src/proto/grpc/health/v1/health.proto + -I src/proto src/proto/grpc/health/v1/health.proto $PROTOC --plugin=$PLUGIN --csharp_out=$REFLECTION_DIR --grpc_out=$REFLECTION_DIR \ - -I src/proto/grpc/reflection/v1alpha src/proto/grpc/reflection/v1alpha/reflection.proto + -I src/proto src/proto/grpc/reflection/v1alpha/reflection.proto +# TODO(jtattermusch): following .proto files are a bit broken and import paths +# don't match the package names. Setting -I to the correct value src/proto +# breaks the code generation. $PROTOC --plugin=$PLUGIN --csharp_out=$TESTING_DIR --grpc_out=$TESTING_DIR \ -I . src/proto/grpc/testing/{control,empty,messages,metrics,payloads,services,stats,test}.proto From c56d3ebd7eadca14322230d97fdddedd9579f41a Mon Sep 17 00:00:00 2001 From: "Mark D. Roth" Date: Tue, 29 Nov 2016 07:32:39 -0800 Subject: [PATCH 68/86] Improve logging. --- test/cpp/qps/json_run_localhost.cc | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/test/cpp/qps/json_run_localhost.cc b/test/cpp/qps/json_run_localhost.cc index b36dbcec2f9..106509ab83e 100644 --- a/test/cpp/qps/json_run_localhost.cc +++ b/test/cpp/qps/json_run_localhost.cc @@ -50,15 +50,15 @@ std::string as_string(const T& val) { return out.str(); } -static void LogStatus(int status) { +static void LogStatus(int status, const char* label) { if (WIFEXITED(status)) { - gpr_log(GPR_INFO, "subprocess exited with status %d", + gpr_log(GPR_INFO, "%s: subprocess exited with status %d", label, WEXITSTATUS(status)); } else if (WIFSIGNALED(status)) { - gpr_log(GPR_INFO, "subprocess terminated with signal %d", + gpr_log(GPR_INFO, "%s: subprocess terminated with signal %d", label, WTERMSIG(status)); } else { - gpr_log(GPR_INFO, "unknown subprocess status: %d", status); + gpr_log(GPR_INFO, "%s: unknown subprocess status: %d", label, status); } } @@ -87,21 +87,18 @@ int main(int argc, char** argv) { for (int i = 1; i < argc; i++) { args.push_back(argv[i]); } -gpr_log(GPR_INFO, "calling Join() on driver"); int status = SubProcess(args).Join(); if (status != 0) { - LogStatus(status); - GPR_ASSERT(status == 0); + LogStatus(status, "driver"); } for (auto it = jobs.begin(); it != jobs.end(); ++it) { (*it)->Interrupt(); } for (auto it = jobs.begin(); it != jobs.end(); ++it) { -gpr_log(GPR_INFO, "calling Join() on job"); status = (*it)->Join(); if (status != 0) { - LogStatus(status); + LogStatus(status, "worker"); } } } From e89e54f4b6251c7c1bead962a82a060a86b2dcfe Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 29 Nov 2016 08:20:05 -0800 Subject: [PATCH 69/86] clang-format code --- test/cpp/microbenchmarks/bm_fullstack.cc | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/test/cpp/microbenchmarks/bm_fullstack.cc b/test/cpp/microbenchmarks/bm_fullstack.cc index bc6038d3ec7..559e66cdd70 100644 --- a/test/cpp/microbenchmarks/bm_fullstack.cc +++ b/test/cpp/microbenchmarks/bm_fullstack.cc @@ -71,9 +71,7 @@ static class InitializeStuff { rq_ = grpc_resource_quota_create("bm"); } - ~InitializeStuff() { - init_lib_.shutdown(); - } + ~InitializeStuff() { init_lib_.shutdown(); } grpc_resource_quota* rq() { return rq_; } From d04c822b5835f34fb7153e5c86599bf1e3ba0f45 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 29 Nov 2016 08:54:36 -0800 Subject: [PATCH 70/86] Unique-ify uds address between concurrent bm_fullstack runs --- test/cpp/microbenchmarks/bm_fullstack.cc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/test/cpp/microbenchmarks/bm_fullstack.cc b/test/cpp/microbenchmarks/bm_fullstack.cc index 559e66cdd70..696b453fa31 100644 --- a/test/cpp/microbenchmarks/bm_fullstack.cc +++ b/test/cpp/microbenchmarks/bm_fullstack.cc @@ -128,7 +128,16 @@ class TCP : public FullstackFixture { class UDS : public FullstackFixture { public: - UDS(Service* service) : FullstackFixture(service, "unix:bm_fullstack") {} + UDS(Service* service) : FullstackFixture(service, MakeAddress()) {} + + private: + static grpc::string MakeAddress() { + int port = grpc_pick_unused_port_or_die(); // just for a unique id - not a + // real port + std::stringstream addr; + addr << "unix:/tmp/bm_fullstack." << port; + return addr.str(); + } }; class EndpointPairFixture { From 9564cf9f0a6e3dbfaf0dba637c98d4479667769f Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 29 Nov 2016 09:12:48 -0800 Subject: [PATCH 71/86] Take into account all the configs --- test/cpp/qps/gen_build_yaml.py | 4 +- tools/run_tests/tests.json | 544 ++++++++++++++++++++++++++++----- 2 files changed, 479 insertions(+), 69 deletions(-) diff --git a/test/cpp/qps/gen_build_yaml.py b/test/cpp/qps/gen_build_yaml.py index 67e5a29883e..4aa58d2737c 100755 --- a/test/cpp/qps/gen_build_yaml.py +++ b/test/cpp/qps/gen_build_yaml.py @@ -43,6 +43,8 @@ sys.path.append(run_tests_root) import performance.scenario_config as scenario_config +configs_from_yaml = yaml.load(open(os.path.join(os.path.dirname(sys.argv[0]), '../../../build.yaml')))['configs'].keys() + def mutate_scenario(scenario_json, is_tsan): # tweak parameters to get fast test times scenario_json = dict(scenario_json) @@ -106,7 +108,7 @@ print yaml.dump({ 'boringssl': True, 'defaults': 'boringssl', 'cpu_cost': guess_cpu(scenario_json, True), - 'exclude_configs': ['dbg', 'opt', 'asan', 'msan'], + 'exclude_configs': sorted(c for c in configs_from_yaml if c != 'tsan'), 'timeout_seconds': 6*60 } for scenario_json in scenario_config.CXXLanguage().scenarios() diff --git a/tools/run_tests/tests.json b/tools/run_tests/tests.json index 9931640f01c..c4bfd0a9a74 100644 --- a/tools/run_tests/tests.json +++ b/tools/run_tests/tests.json @@ -37547,10 +37547,22 @@ "cpu_cost": 2, "defaults": "boringssl", "exclude_configs": [ + "asan", + "asan-noleaks", + "asan-trace-cmp", + "basicprof", "dbg", + "easan", + "edbg", + "etsan", + "gcov", + "helgrind", + "memcheck", + "msan", + "mutrace", "opt", - "asan", - "msan" + "stapprof", + "ubsan" ], "flaky": false, "language": "c++", @@ -37573,10 +37585,22 @@ "cpu_cost": "capacity", "defaults": "boringssl", "exclude_configs": [ + "asan", + "asan-noleaks", + "asan-trace-cmp", + "basicprof", "dbg", + "easan", + "edbg", + "etsan", + "gcov", + "helgrind", + "memcheck", + "msan", + "mutrace", "opt", - "asan", - "msan" + "stapprof", + "ubsan" ], "flaky": false, "language": "c++", @@ -37599,10 +37623,22 @@ "cpu_cost": "capacity", "defaults": "boringssl", "exclude_configs": [ + "asan", + "asan-noleaks", + "asan-trace-cmp", + "basicprof", "dbg", + "easan", + "edbg", + "etsan", + "gcov", + "helgrind", + "memcheck", + "msan", + "mutrace", "opt", - "asan", - "msan" + "stapprof", + "ubsan" ], "flaky": false, "language": "c++", @@ -37625,10 +37661,22 @@ "cpu_cost": "capacity", "defaults": "boringssl", "exclude_configs": [ + "asan", + "asan-noleaks", + "asan-trace-cmp", + "basicprof", "dbg", + "easan", + "edbg", + "etsan", + "gcov", + "helgrind", + "memcheck", + "msan", + "mutrace", "opt", - "asan", - "msan" + "stapprof", + "ubsan" ], "flaky": false, "language": "c++", @@ -37651,10 +37699,22 @@ "cpu_cost": "capacity", "defaults": "boringssl", "exclude_configs": [ + "asan", + "asan-noleaks", + "asan-trace-cmp", + "basicprof", "dbg", + "easan", + "edbg", + "etsan", + "gcov", + "helgrind", + "memcheck", + "msan", + "mutrace", "opt", - "asan", - "msan" + "stapprof", + "ubsan" ], "flaky": false, "language": "c++", @@ -37677,10 +37737,22 @@ "cpu_cost": 2, "defaults": "boringssl", "exclude_configs": [ + "asan", + "asan-noleaks", + "asan-trace-cmp", + "basicprof", "dbg", + "easan", + "edbg", + "etsan", + "gcov", + "helgrind", + "memcheck", + "msan", + "mutrace", "opt", - "asan", - "msan" + "stapprof", + "ubsan" ], "flaky": false, "language": "c++", @@ -37703,10 +37775,22 @@ "cpu_cost": 64, "defaults": "boringssl", "exclude_configs": [ + "asan", + "asan-noleaks", + "asan-trace-cmp", + "basicprof", "dbg", + "easan", + "edbg", + "etsan", + "gcov", + "helgrind", + "memcheck", + "msan", + "mutrace", "opt", - "asan", - "msan" + "stapprof", + "ubsan" ], "flaky": false, "language": "c++", @@ -37729,10 +37813,22 @@ "cpu_cost": 64, "defaults": "boringssl", "exclude_configs": [ + "asan", + "asan-noleaks", + "asan-trace-cmp", + "basicprof", "dbg", + "easan", + "edbg", + "etsan", + "gcov", + "helgrind", + "memcheck", + "msan", + "mutrace", "opt", - "asan", - "msan" + "stapprof", + "ubsan" ], "flaky": false, "language": "c++", @@ -37755,10 +37851,22 @@ "cpu_cost": 2, "defaults": "boringssl", "exclude_configs": [ + "asan", + "asan-noleaks", + "asan-trace-cmp", + "basicprof", "dbg", + "easan", + "edbg", + "etsan", + "gcov", + "helgrind", + "memcheck", + "msan", + "mutrace", "opt", - "asan", - "msan" + "stapprof", + "ubsan" ], "flaky": false, "language": "c++", @@ -37781,10 +37889,22 @@ "cpu_cost": "capacity", "defaults": "boringssl", "exclude_configs": [ + "asan", + "asan-noleaks", + "asan-trace-cmp", + "basicprof", "dbg", + "easan", + "edbg", + "etsan", + "gcov", + "helgrind", + "memcheck", + "msan", + "mutrace", "opt", - "asan", - "msan" + "stapprof", + "ubsan" ], "flaky": false, "language": "c++", @@ -37807,10 +37927,22 @@ "cpu_cost": "capacity", "defaults": "boringssl", "exclude_configs": [ + "asan", + "asan-noleaks", + "asan-trace-cmp", + "basicprof", "dbg", + "easan", + "edbg", + "etsan", + "gcov", + "helgrind", + "memcheck", + "msan", + "mutrace", "opt", - "asan", - "msan" + "stapprof", + "ubsan" ], "flaky": false, "language": "c++", @@ -37833,10 +37965,22 @@ "cpu_cost": 2, "defaults": "boringssl", "exclude_configs": [ + "asan", + "asan-noleaks", + "asan-trace-cmp", + "basicprof", "dbg", + "easan", + "edbg", + "etsan", + "gcov", + "helgrind", + "memcheck", + "msan", + "mutrace", "opt", - "asan", - "msan" + "stapprof", + "ubsan" ], "flaky": false, "language": "c++", @@ -37859,10 +38003,22 @@ "cpu_cost": 64, "defaults": "boringssl", "exclude_configs": [ + "asan", + "asan-noleaks", + "asan-trace-cmp", + "basicprof", "dbg", + "easan", + "edbg", + "etsan", + "gcov", + "helgrind", + "memcheck", + "msan", + "mutrace", "opt", - "asan", - "msan" + "stapprof", + "ubsan" ], "flaky": false, "language": "c++", @@ -37885,10 +38041,22 @@ "cpu_cost": 64, "defaults": "boringssl", "exclude_configs": [ + "asan", + "asan-noleaks", + "asan-trace-cmp", + "basicprof", "dbg", + "easan", + "edbg", + "etsan", + "gcov", + "helgrind", + "memcheck", + "msan", + "mutrace", "opt", - "asan", - "msan" + "stapprof", + "ubsan" ], "flaky": false, "language": "c++", @@ -37911,10 +38079,22 @@ "cpu_cost": 2, "defaults": "boringssl", "exclude_configs": [ + "asan", + "asan-noleaks", + "asan-trace-cmp", + "basicprof", "dbg", + "easan", + "edbg", + "etsan", + "gcov", + "helgrind", + "memcheck", + "msan", + "mutrace", "opt", - "asan", - "msan" + "stapprof", + "ubsan" ], "flaky": false, "language": "c++", @@ -37937,10 +38117,22 @@ "cpu_cost": "capacity", "defaults": "boringssl", "exclude_configs": [ + "asan", + "asan-noleaks", + "asan-trace-cmp", + "basicprof", "dbg", + "easan", + "edbg", + "etsan", + "gcov", + "helgrind", + "memcheck", + "msan", + "mutrace", "opt", - "asan", - "msan" + "stapprof", + "ubsan" ], "flaky": false, "language": "c++", @@ -37963,10 +38155,22 @@ "cpu_cost": "capacity", "defaults": "boringssl", "exclude_configs": [ + "asan", + "asan-noleaks", + "asan-trace-cmp", + "basicprof", "dbg", + "easan", + "edbg", + "etsan", + "gcov", + "helgrind", + "memcheck", + "msan", + "mutrace", "opt", - "asan", - "msan" + "stapprof", + "ubsan" ], "flaky": false, "language": "c++", @@ -37989,10 +38193,22 @@ "cpu_cost": 2, "defaults": "boringssl", "exclude_configs": [ + "asan", + "asan-noleaks", + "asan-trace-cmp", + "basicprof", "dbg", + "easan", + "edbg", + "etsan", + "gcov", + "helgrind", + "memcheck", + "msan", + "mutrace", "opt", - "asan", - "msan" + "stapprof", + "ubsan" ], "flaky": false, "language": "c++", @@ -38015,10 +38231,22 @@ "cpu_cost": "capacity", "defaults": "boringssl", "exclude_configs": [ + "asan", + "asan-noleaks", + "asan-trace-cmp", + "basicprof", "dbg", + "easan", + "edbg", + "etsan", + "gcov", + "helgrind", + "memcheck", + "msan", + "mutrace", "opt", - "asan", - "msan" + "stapprof", + "ubsan" ], "flaky": false, "language": "c++", @@ -38041,10 +38269,22 @@ "cpu_cost": "capacity", "defaults": "boringssl", "exclude_configs": [ + "asan", + "asan-noleaks", + "asan-trace-cmp", + "basicprof", "dbg", + "easan", + "edbg", + "etsan", + "gcov", + "helgrind", + "memcheck", + "msan", + "mutrace", "opt", - "asan", - "msan" + "stapprof", + "ubsan" ], "flaky": false, "language": "c++", @@ -38067,10 +38307,22 @@ "cpu_cost": "capacity", "defaults": "boringssl", "exclude_configs": [ + "asan", + "asan-noleaks", + "asan-trace-cmp", + "basicprof", "dbg", + "easan", + "edbg", + "etsan", + "gcov", + "helgrind", + "memcheck", + "msan", + "mutrace", "opt", - "asan", - "msan" + "stapprof", + "ubsan" ], "flaky": false, "language": "c++", @@ -38093,10 +38345,22 @@ "cpu_cost": "capacity", "defaults": "boringssl", "exclude_configs": [ + "asan", + "asan-noleaks", + "asan-trace-cmp", + "basicprof", "dbg", + "easan", + "edbg", + "etsan", + "gcov", + "helgrind", + "memcheck", + "msan", + "mutrace", "opt", - "asan", - "msan" + "stapprof", + "ubsan" ], "flaky": false, "language": "c++", @@ -38119,10 +38383,22 @@ "cpu_cost": 2, "defaults": "boringssl", "exclude_configs": [ + "asan", + "asan-noleaks", + "asan-trace-cmp", + "basicprof", "dbg", + "easan", + "edbg", + "etsan", + "gcov", + "helgrind", + "memcheck", + "msan", + "mutrace", "opt", - "asan", - "msan" + "stapprof", + "ubsan" ], "flaky": false, "language": "c++", @@ -38145,10 +38421,22 @@ "cpu_cost": 64, "defaults": "boringssl", "exclude_configs": [ + "asan", + "asan-noleaks", + "asan-trace-cmp", + "basicprof", "dbg", + "easan", + "edbg", + "etsan", + "gcov", + "helgrind", + "memcheck", + "msan", + "mutrace", "opt", - "asan", - "msan" + "stapprof", + "ubsan" ], "flaky": false, "language": "c++", @@ -38171,10 +38459,22 @@ "cpu_cost": 64, "defaults": "boringssl", "exclude_configs": [ + "asan", + "asan-noleaks", + "asan-trace-cmp", + "basicprof", "dbg", + "easan", + "edbg", + "etsan", + "gcov", + "helgrind", + "memcheck", + "msan", + "mutrace", "opt", - "asan", - "msan" + "stapprof", + "ubsan" ], "flaky": false, "language": "c++", @@ -38197,10 +38497,22 @@ "cpu_cost": 2, "defaults": "boringssl", "exclude_configs": [ + "asan", + "asan-noleaks", + "asan-trace-cmp", + "basicprof", "dbg", + "easan", + "edbg", + "etsan", + "gcov", + "helgrind", + "memcheck", + "msan", + "mutrace", "opt", - "asan", - "msan" + "stapprof", + "ubsan" ], "flaky": false, "language": "c++", @@ -38223,10 +38535,22 @@ "cpu_cost": "capacity", "defaults": "boringssl", "exclude_configs": [ + "asan", + "asan-noleaks", + "asan-trace-cmp", + "basicprof", "dbg", + "easan", + "edbg", + "etsan", + "gcov", + "helgrind", + "memcheck", + "msan", + "mutrace", "opt", - "asan", - "msan" + "stapprof", + "ubsan" ], "flaky": false, "language": "c++", @@ -38249,10 +38573,22 @@ "cpu_cost": "capacity", "defaults": "boringssl", "exclude_configs": [ + "asan", + "asan-noleaks", + "asan-trace-cmp", + "basicprof", "dbg", + "easan", + "edbg", + "etsan", + "gcov", + "helgrind", + "memcheck", + "msan", + "mutrace", "opt", - "asan", - "msan" + "stapprof", + "ubsan" ], "flaky": false, "language": "c++", @@ -38275,10 +38611,22 @@ "cpu_cost": 2, "defaults": "boringssl", "exclude_configs": [ + "asan", + "asan-noleaks", + "asan-trace-cmp", + "basicprof", "dbg", + "easan", + "edbg", + "etsan", + "gcov", + "helgrind", + "memcheck", + "msan", + "mutrace", "opt", - "asan", - "msan" + "stapprof", + "ubsan" ], "flaky": false, "language": "c++", @@ -38301,10 +38649,22 @@ "cpu_cost": 64, "defaults": "boringssl", "exclude_configs": [ + "asan", + "asan-noleaks", + "asan-trace-cmp", + "basicprof", "dbg", + "easan", + "edbg", + "etsan", + "gcov", + "helgrind", + "memcheck", + "msan", + "mutrace", "opt", - "asan", - "msan" + "stapprof", + "ubsan" ], "flaky": false, "language": "c++", @@ -38327,10 +38687,22 @@ "cpu_cost": 64, "defaults": "boringssl", "exclude_configs": [ + "asan", + "asan-noleaks", + "asan-trace-cmp", + "basicprof", "dbg", + "easan", + "edbg", + "etsan", + "gcov", + "helgrind", + "memcheck", + "msan", + "mutrace", "opt", - "asan", - "msan" + "stapprof", + "ubsan" ], "flaky": false, "language": "c++", @@ -38353,10 +38725,22 @@ "cpu_cost": 2, "defaults": "boringssl", "exclude_configs": [ + "asan", + "asan-noleaks", + "asan-trace-cmp", + "basicprof", "dbg", + "easan", + "edbg", + "etsan", + "gcov", + "helgrind", + "memcheck", + "msan", + "mutrace", "opt", - "asan", - "msan" + "stapprof", + "ubsan" ], "flaky": false, "language": "c++", @@ -38379,10 +38763,22 @@ "cpu_cost": "capacity", "defaults": "boringssl", "exclude_configs": [ + "asan", + "asan-noleaks", + "asan-trace-cmp", + "basicprof", "dbg", + "easan", + "edbg", + "etsan", + "gcov", + "helgrind", + "memcheck", + "msan", + "mutrace", "opt", - "asan", - "msan" + "stapprof", + "ubsan" ], "flaky": false, "language": "c++", @@ -38405,10 +38801,22 @@ "cpu_cost": "capacity", "defaults": "boringssl", "exclude_configs": [ + "asan", + "asan-noleaks", + "asan-trace-cmp", + "basicprof", "dbg", + "easan", + "edbg", + "etsan", + "gcov", + "helgrind", + "memcheck", + "msan", + "mutrace", "opt", - "asan", - "msan" + "stapprof", + "ubsan" ], "flaky": false, "language": "c++", From 9f07b4fbad6460b49ef2688bf93ccb082d8d4ea3 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 29 Nov 2016 09:36:51 -0800 Subject: [PATCH 72/86] Increase timeout for now: seems this can take longer under some configurations --- test/core/end2end/tests/resource_quota_server.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/core/end2end/tests/resource_quota_server.c b/test/core/end2end/tests/resource_quota_server.c index 7ec33e97a3b..c919faea89f 100644 --- a/test/core/end2end/tests/resource_quota_server.c +++ b/test/core/end2end/tests/resource_quota_server.c @@ -234,7 +234,7 @@ void resource_quota_server(grpc_end2end_test_config config) { while (pending_client_calls + pending_server_recv_calls + pending_server_end_calls > 0) { - grpc_event ev = grpc_completion_queue_next(f.cq, n_seconds_time(10), NULL); + grpc_event ev = grpc_completion_queue_next(f.cq, n_seconds_time(60), NULL); GPR_ASSERT(ev.type == GRPC_OP_COMPLETE); int ev_tag = (int)(intptr_t)ev.tag; From c0c0dbc01ce092a9f8bbf3f0dd8ea12d5486b026 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 29 Nov 2016 10:10:21 -0800 Subject: [PATCH 73/86] Fix TSAN race on adding a reclaimer --- src/core/lib/iomgr/resource_quota.c | 30 +++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/src/core/lib/iomgr/resource_quota.c b/src/core/lib/iomgr/resource_quota.c index 051a30baa34..379bf9bd23b 100644 --- a/src/core/lib/iomgr/resource_quota.c +++ b/src/core/lib/iomgr/resource_quota.c @@ -104,6 +104,9 @@ struct grpc_resource_user { /* Reclaimers: index 0 is the benign reclaimer, 1 is the destructive reclaimer */ grpc_closure *reclaimers[2]; + /* Reclaimers just posted: once we're in the combiner lock, we'll move them + to the array above */ + grpc_closure *new_reclaimers[2]; /* Trampoline closures to finish reclamation and re-enter the quota combiner lock */ grpc_closure post_reclaimer_closure[2]; @@ -418,9 +421,25 @@ static void ru_add_to_free_pool(grpc_exec_ctx *exec_ctx, void *ru, rulist_add_tail(resource_user, GRPC_RULIST_NON_EMPTY_FREE_POOL); } +static bool ru_post_reclaimer(grpc_exec_ctx *exec_ctx, + grpc_resource_user *resource_user, + bool destructive) { + grpc_closure *closure = resource_user->new_reclaimers[destructive]; + GPR_ASSERT(closure != NULL); + resource_user->new_reclaimers[destructive] = NULL; + GPR_ASSERT(resource_user->reclaimers[destructive] == NULL); + if (gpr_atm_acq_load(&resource_user->shutdown) > 0) { + grpc_exec_ctx_sched(exec_ctx, closure, GRPC_ERROR_CANCELLED, NULL); + return false; + } + resource_user->reclaimers[destructive] = closure; + return true; +} + static void ru_post_benign_reclaimer(grpc_exec_ctx *exec_ctx, void *ru, grpc_error *error) { grpc_resource_user *resource_user = ru; + if (!ru_post_reclaimer(exec_ctx, resource_user, false)) return; if (!rulist_empty(resource_user->resource_quota, GRPC_RULIST_AWAITING_ALLOCATION) && rulist_empty(resource_user->resource_quota, @@ -435,6 +454,7 @@ static void ru_post_benign_reclaimer(grpc_exec_ctx *exec_ctx, void *ru, static void ru_post_destructive_reclaimer(grpc_exec_ctx *exec_ctx, void *ru, grpc_error *error) { grpc_resource_user *resource_user = ru; + if (!ru_post_reclaimer(exec_ctx, resource_user, true)) return; if (!rulist_empty(resource_user->resource_quota, GRPC_RULIST_AWAITING_ALLOCATION) && rulist_empty(resource_user->resource_quota, @@ -649,6 +669,8 @@ grpc_resource_user *grpc_resource_user_create( resource_user->added_to_free_pool = false; resource_user->reclaimers[0] = NULL; resource_user->reclaimers[1] = NULL; + resource_user->new_reclaimers[0] = NULL; + resource_user->new_reclaimers[1] = NULL; for (int i = 0; i < GRPC_RULIST_COUNT; i++) { resource_user->links[i].next = resource_user->links[i].prev = NULL; } @@ -748,12 +770,8 @@ void grpc_resource_user_post_reclaimer(grpc_exec_ctx *exec_ctx, grpc_resource_user *resource_user, bool destructive, grpc_closure *closure) { - GPR_ASSERT(resource_user->reclaimers[destructive] == NULL); - if (gpr_atm_acq_load(&resource_user->shutdown) > 0) { - grpc_exec_ctx_sched(exec_ctx, closure, GRPC_ERROR_CANCELLED, NULL); - return; - } - resource_user->reclaimers[destructive] = closure; + GPR_ASSERT(resource_user->new_reclaimers[destructive] == NULL); + resource_user->new_reclaimers[destructive] = closure; grpc_combiner_execute(exec_ctx, resource_user->resource_quota->combiner, &resource_user->post_reclaimer_closure[destructive], GRPC_ERROR_NONE, false); From b1236437713e907afe3f36dc5d347a5054f6743b Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Tue, 29 Nov 2016 19:24:29 +0100 Subject: [PATCH 74/86] remove one more publicSign --- src/csharp/Grpc.Reflection/project.json | 1 - templates/src/csharp/Grpc.Reflection/project.json.template | 1 - 2 files changed, 2 deletions(-) diff --git a/src/csharp/Grpc.Reflection/project.json b/src/csharp/Grpc.Reflection/project.json index fc37bb2682a..2fe617cc7a8 100644 --- a/src/csharp/Grpc.Reflection/project.json +++ b/src/csharp/Grpc.Reflection/project.json @@ -15,7 +15,6 @@ "buildOptions": { "define": [ "SIGNED" ], "keyFile": "../keys/Grpc.snk", - "publicSign": true, "xmlDoc": true, "compile": { "includeFiles": [ "../Grpc.Core/Version.cs" ] diff --git a/templates/src/csharp/Grpc.Reflection/project.json.template b/templates/src/csharp/Grpc.Reflection/project.json.template index c13b3a8d7d9..8a33e1ccc97 100644 --- a/templates/src/csharp/Grpc.Reflection/project.json.template +++ b/templates/src/csharp/Grpc.Reflection/project.json.template @@ -17,7 +17,6 @@ "buildOptions": { "define": [ "SIGNED" ], "keyFile": "../keys/Grpc.snk", - "publicSign": true, "xmlDoc": true, "compile": { "includeFiles": [ "../Grpc.Core/Version.cs" ] From 3b45b8d60b9f0a1678f5f497345e21f7bc71675a Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 29 Nov 2016 12:31:14 -0800 Subject: [PATCH 75/86] Revert "Test credentials provider update" --- build.yaml | 1 - test/cpp/end2end/async_end2end_test.cc | 19 ++---- test/cpp/end2end/end2end_test.cc | 20 ++---- test/cpp/interop/client.cc | 1 - test/cpp/interop/client_helper.cc | 10 +-- test/cpp/interop/interop_server.cc | 1 - test/cpp/interop/server_helper.cc | 18 +++--- test/cpp/interop/stress_test.cc | 1 - test/cpp/util/create_test_channel.cc | 64 +++---------------- test/cpp/util/create_test_channel.h | 4 -- test/cpp/util/test_credentials_provider.cc | 52 ++++++++++++--- test/cpp/util/test_credentials_provider.h | 50 +++++---------- tools/run_tests/sources_and_headers.json | 1 - .../interop_server_helper.vcxproj | 3 - 14 files changed, 92 insertions(+), 153 deletions(-) diff --git a/build.yaml b/build.yaml index fdc273e4dab..510b366b613 100644 --- a/build.yaml +++ b/build.yaml @@ -1233,7 +1233,6 @@ libs: src: - test/cpp/interop/server_helper.cc deps: - - grpc++_test_util - grpc_test_util - grpc++ - grpc diff --git a/test/cpp/end2end/async_end2end_test.cc b/test/cpp/end2end/async_end2end_test.cc index 2ce3f2f7bd9..8e385d100c1 100644 --- a/test/cpp/end2end/async_end2end_test.cc +++ b/test/cpp/end2end/async_end2end_test.cc @@ -254,8 +254,7 @@ class AsyncEnd2endTest : public ::testing::TestWithParam { // Setup server ServerBuilder builder; - auto server_creds = GetCredentialsProvider()->GetServerCredentials( - GetParam().credentials_type); + auto server_creds = GetServerCredentials(GetParam().credentials_type); builder.AddListeningPort(server_address_.str(), server_creds); builder.RegisterService(&service_); cq_ = builder.AddCompletionQueue(); @@ -284,8 +283,8 @@ class AsyncEnd2endTest : public ::testing::TestWithParam { void ResetStub() { ChannelArguments args; - auto channel_creds = GetCredentialsProvider()->GetChannelCredentials( - GetParam().credentials_type, &args); + auto channel_creds = + GetChannelCredentials(GetParam().credentials_type, &args); std::shared_ptr channel = CreateCustomChannel(server_address_.str(), channel_creds, args); stub_ = grpc::testing::EchoTestService::NewStub(channel); @@ -893,8 +892,8 @@ TEST_P(AsyncEnd2endTest, ServerCheckDone) { TEST_P(AsyncEnd2endTest, UnimplementedRpc) { ChannelArguments args; - auto channel_creds = GetCredentialsProvider()->GetChannelCredentials( - GetParam().credentials_type, &args); + auto channel_creds = + GetChannelCredentials(GetParam().credentials_type, &args); std::shared_ptr channel = CreateCustomChannel(server_address_.str(), channel_creds, args); std::unique_ptr stub; @@ -1405,15 +1404,11 @@ std::vector CreateTestScenarios(bool test_disable_blocking, std::vector credentials_types; std::vector messages; - if (GetCredentialsProvider()->GetChannelCredentials(kInsecureCredentialsType, - nullptr) != nullptr) { - credentials_types.push_back(kInsecureCredentialsType); - } - auto sec_list = GetCredentialsProvider()->GetSecureCredentialsTypeList(); + credentials_types.push_back(kInsecureCredentialsType); + auto sec_list = GetSecureCredentialsTypeList(); for (auto sec = sec_list.begin(); sec != sec_list.end(); sec++) { credentials_types.push_back(*sec); } - GPR_ASSERT(!credentials_types.empty()); messages.push_back("Hello"); for (int sz = 1; sz < test_big_limit; sz *= 2) { diff --git a/test/cpp/end2end/end2end_test.cc b/test/cpp/end2end/end2end_test.cc index 1a1a94e87c7..9bb892c694b 100644 --- a/test/cpp/end2end/end2end_test.cc +++ b/test/cpp/end2end/end2end_test.cc @@ -242,8 +242,7 @@ class End2endTest : public ::testing::TestWithParam { // Setup server ServerBuilder builder; ConfigureServerBuilder(&builder); - auto server_creds = GetCredentialsProvider()->GetServerCredentials( - GetParam().credentials_type); + auto server_creds = GetServerCredentials(GetParam().credentials_type); if (GetParam().credentials_type != kInsecureCredentialsType) { server_creds->SetAuthMetadataProcessor(processor); } @@ -271,8 +270,8 @@ class End2endTest : public ::testing::TestWithParam { } EXPECT_TRUE(is_server_started_); ChannelArguments args; - auto channel_creds = GetCredentialsProvider()->GetChannelCredentials( - GetParam().credentials_type, &args); + auto channel_creds = + GetChannelCredentials(GetParam().credentials_type, &args); if (!user_agent_prefix_.empty()) { args.SetUserAgentPrefix(user_agent_prefix_); } @@ -1521,18 +1520,11 @@ std::vector CreateTestScenarios(bool use_proxy, std::vector scenarios; std::vector credentials_types; if (test_secure) { - credentials_types = - GetCredentialsProvider()->GetSecureCredentialsTypeList(); + credentials_types = GetSecureCredentialsTypeList(); } if (test_insecure) { - // Only add insecure credentials type when it is registered with the - // provider. User may create providers that do not have insecure. - if (GetCredentialsProvider()->GetChannelCredentials( - kInsecureCredentialsType, nullptr) != nullptr) { - credentials_types.push_back(kInsecureCredentialsType); - } + credentials_types.push_back(kInsecureCredentialsType); } - GPR_ASSERT(!credentials_types.empty()); for (auto it = credentials_types.begin(); it != credentials_types.end(); ++it) { scenarios.emplace_back(false, *it); @@ -1549,7 +1541,7 @@ INSTANTIATE_TEST_CASE_P(End2end, End2endTest, INSTANTIATE_TEST_CASE_P(End2endServerTryCancel, End2endServerTryCancelTest, ::testing::ValuesIn(CreateTestScenarios(false, true, - true))); + false))); INSTANTIATE_TEST_CASE_P(ProxyEnd2end, ProxyEnd2endTest, ::testing::ValuesIn(CreateTestScenarios(true, true, diff --git a/test/cpp/interop/client.cc b/test/cpp/interop/client.cc index 3265554444b..c58910abc3f 100644 --- a/test/cpp/interop/client.cc +++ b/test/cpp/interop/client.cc @@ -49,7 +49,6 @@ #include "test/cpp/util/test_config.h" DEFINE_bool(use_tls, false, "Whether to use tls."); -DEFINE_string(custom_credentials_type, "", "User provided credentials type."); DEFINE_bool(use_test_ca, false, "False to use SSL roots for google"); DEFINE_int32(server_port, 0, "Server port."); DEFINE_string(server_host, "127.0.0.1", "Server host to connect to"); diff --git a/test/cpp/interop/client_helper.cc b/test/cpp/interop/client_helper.cc index 91564e5dcef..c171969e147 100644 --- a/test/cpp/interop/client_helper.cc +++ b/test/cpp/interop/client_helper.cc @@ -50,10 +50,8 @@ #include "src/cpp/client/secure_credentials.h" #include "test/core/security/oauth2_utils.h" #include "test/cpp/util/create_test_channel.h" -#include "test/cpp/util/test_credentials_provider.h" DECLARE_bool(use_tls); -DECLARE_string(custom_credentials_type); DECLARE_bool(use_test_ca); DECLARE_int32(server_port); DECLARE_string(server_host); @@ -116,12 +114,8 @@ std::shared_ptr CreateChannelForTestCase( creds = AccessTokenCredentials(raw_token); GPR_ASSERT(creds); } - if (FLAGS_custom_credentials_type.empty()) { - return CreateTestChannel(host_port, FLAGS_server_host_override, - FLAGS_use_tls, !FLAGS_use_test_ca, creds); - } else { - return CreateTestChannel(host_port, FLAGS_custom_credentials_type, creds); - } + return CreateTestChannel(host_port, FLAGS_server_host_override, FLAGS_use_tls, + !FLAGS_use_test_ca, creds); } } // namespace testing diff --git a/test/cpp/interop/interop_server.cc b/test/cpp/interop/interop_server.cc index bc6dc074541..8b50ae8c05a 100644 --- a/test/cpp/interop/interop_server.cc +++ b/test/cpp/interop/interop_server.cc @@ -56,7 +56,6 @@ #include "test/cpp/util/test_config.h" DEFINE_bool(use_tls, false, "Whether to use tls."); -DEFINE_string(custom_credentials_type, "", "User provided credentials type."); DEFINE_int32(port, 0, "Server port."); DEFINE_int32(max_send_message_size, -1, "The maximum send message size."); diff --git a/test/cpp/interop/server_helper.cc b/test/cpp/interop/server_helper.cc index d395f50fa59..8b0b511bcb8 100644 --- a/test/cpp/interop/server_helper.cc +++ b/test/cpp/interop/server_helper.cc @@ -39,23 +39,23 @@ #include #include "src/core/lib/surface/call_test_only.h" -#include "test/cpp/util/test_credentials_provider.h" +#include "test/core/end2end/data/ssl_test_data.h" DECLARE_bool(use_tls); -DECLARE_string(custom_credentials_type); namespace grpc { namespace testing { std::shared_ptr CreateInteropServerCredentials() { - if (!FLAGS_custom_credentials_type.empty()) { - return GetCredentialsProvider()->GetServerCredentials( - FLAGS_custom_credentials_type); - } else if (FLAGS_use_tls) { - return GetCredentialsProvider()->GetServerCredentials(kTlsCredentialsType); + if (FLAGS_use_tls) { + SslServerCredentialsOptions::PemKeyCertPair pkcp = {test_server1_key, + test_server1_cert}; + SslServerCredentialsOptions ssl_opts; + ssl_opts.pem_root_certs = ""; + ssl_opts.pem_key_cert_pairs.push_back(pkcp); + return SslServerCredentials(ssl_opts); } else { - return GetCredentialsProvider()->GetServerCredentials( - kInsecureCredentialsType); + return InsecureServerCredentials(); } } diff --git a/test/cpp/interop/stress_test.cc b/test/cpp/interop/stress_test.cc index af707d31905..fc35db5233a 100644 --- a/test/cpp/interop/stress_test.cc +++ b/test/cpp/interop/stress_test.cc @@ -147,7 +147,6 @@ DEFINE_bool(do_not_abort_on_transient_failures, true, // Options from client.cc (for compatibility with interop test). // TODO(sreek): Consolidate overlapping options DEFINE_bool(use_tls, false, "Whether to use tls."); -DEFINE_string(custom_credentials_type, "", "User provided credentials type."); DEFINE_bool(use_test_ca, false, "False to use SSL roots for google"); DEFINE_int32(server_port, 0, "Server port."); DEFINE_string(server_host, "127.0.0.1", "Server host to connect to"); diff --git a/test/cpp/util/create_test_channel.cc b/test/cpp/util/create_test_channel.cc index ad62e03490e..fe8b5d54235 100644 --- a/test/cpp/util/create_test_channel.cc +++ b/test/cpp/util/create_test_channel.cc @@ -35,37 +35,11 @@ #include #include -#include -#include "test/cpp/util/test_credentials_provider.h" +#include "test/core/end2end/data/ssl_test_data.h" namespace grpc { -namespace { - -const char kProdTlsCredentialsType[] = "prod_ssl"; - -class SslCredentialProvider : public testing::CredentialTypeProvider { - public: - std::shared_ptr GetChannelCredentials( - grpc::ChannelArguments* args) override { - return SslCredentials(SslCredentialsOptions()); - } - std::shared_ptr GetServerCredentials() override { - return nullptr; - } -}; - -gpr_once g_once_init_add_prod_ssl_provider = GPR_ONCE_INIT; -// Register ssl with non-test roots type to the credentials provider. -void AddProdSslType() { - testing::GetCredentialsProvider()->AddSecureType( - kProdTlsCredentialsType, std::unique_ptr( - new SslCredentialProvider)); -} - -} // namespace - // When ssl is enabled, if server is empty, override_hostname is used to // create channel. Otherwise, connect to server and override hostname if // override_hostname is provided. @@ -87,22 +61,16 @@ std::shared_ptr CreateTestChannel( const std::shared_ptr& creds, const ChannelArguments& args) { ChannelArguments channel_args(args); - std::shared_ptr channel_creds; if (enable_ssl) { - if (use_prod_roots) { - gpr_once_init(&g_once_init_add_prod_ssl_provider, &AddProdSslType); - channel_creds = testing::GetCredentialsProvider()->GetChannelCredentials( - kProdTlsCredentialsType, &channel_args); - if (!server.empty() && !override_hostname.empty()) { - channel_args.SetSslTargetNameOverride(override_hostname); - } - } else { - // override_hostname is discarded as the provider handles it. - channel_creds = testing::GetCredentialsProvider()->GetChannelCredentials( - testing::kTlsCredentialsType, &channel_args); - } - GPR_ASSERT(channel_creds != nullptr); + const char* roots_certs = use_prod_roots ? "" : test_root_cert; + SslCredentialsOptions ssl_opts = {roots_certs, "", ""}; + + std::shared_ptr channel_creds = + SslCredentials(ssl_opts); + if (!server.empty() && !override_hostname.empty()) { + channel_args.SetSslTargetNameOverride(override_hostname); + } const grpc::string& connect_to = server.empty() ? override_hostname : server; if (creds.get()) { @@ -135,18 +103,4 @@ std::shared_ptr CreateTestChannel(const grpc::string& server, return CreateTestChannel(server, "foo.test.google.fr", enable_ssl, false); } -std::shared_ptr CreateTestChannel( - const grpc::string& server, const grpc::string& credential_type, - const std::shared_ptr& creds) { - ChannelArguments channel_args; - std::shared_ptr channel_creds = - testing::GetCredentialsProvider()->GetChannelCredentials(credential_type, - &channel_args); - GPR_ASSERT(channel_creds != nullptr); - if (creds.get()) { - channel_creds = CompositeChannelCredentials(channel_creds, creds); - } - return CreateCustomChannel(server, channel_creds, channel_args); -} - } // namespace grpc diff --git a/test/cpp/util/create_test_channel.h b/test/cpp/util/create_test_channel.h index ce71a97edbb..4ff666dc1bc 100644 --- a/test/cpp/util/create_test_channel.h +++ b/test/cpp/util/create_test_channel.h @@ -59,10 +59,6 @@ std::shared_ptr CreateTestChannel( const std::shared_ptr& creds, const ChannelArguments& args); -std::shared_ptr CreateTestChannel( - const grpc::string& server, const grpc::string& credential_type, - const std::shared_ptr& creds); - } // namespace grpc #endif // GRPC_TEST_CPP_UTIL_CREATE_TEST_CHANNEL_H diff --git a/test/cpp/util/test_credentials_provider.cc b/test/cpp/util/test_credentials_provider.cc index 909b02a7019..0456b966671 100644 --- a/test/cpp/util/test_credentials_provider.cc +++ b/test/cpp/util/test_credentials_provider.cc @@ -43,9 +43,25 @@ #include "test/core/end2end/data/ssl_test_data.h" namespace grpc { -namespace testing { namespace { +using grpc::testing::CredentialTypeProvider; + +// Provide test credentials. Thread-safe. +class CredentialsProvider { + public: + virtual ~CredentialsProvider() {} + + virtual void AddSecureType( + const grpc::string& type, + std::unique_ptr type_provider) = 0; + virtual std::shared_ptr GetChannelCredentials( + const grpc::string& type, ChannelArguments* args) = 0; + virtual std::shared_ptr GetServerCredentials( + const grpc::string& type) = 0; + virtual std::vector GetSecureCredentialsTypeList() = 0; +}; + class DefaultCredentialsProvider : public CredentialsProvider { public: ~DefaultCredentialsProvider() override {} @@ -129,21 +145,37 @@ class DefaultCredentialsProvider : public CredentialsProvider { added_secure_type_providers_; }; +gpr_once g_once_init_provider = GPR_ONCE_INIT; CredentialsProvider* g_provider = nullptr; -} // namespace +void CreateDefaultProvider() { g_provider = new DefaultCredentialsProvider; } -CredentialsProvider* GetCredentialsProvider() { - if (g_provider == nullptr) { - g_provider = new DefaultCredentialsProvider; - } +CredentialsProvider* GetProvider() { + gpr_once_init(&g_once_init_provider, &CreateDefaultProvider); return g_provider; } -void SetCredentialsProvider(CredentialsProvider* provider) { - // For now, forbids overriding provider. - GPR_ASSERT(g_provider == nullptr); - g_provider = provider; +} // namespace + +namespace testing { + +void AddSecureType(const grpc::string& type, + std::unique_ptr type_provider) { + GetProvider()->AddSecureType(type, std::move(type_provider)); +} + +std::shared_ptr GetChannelCredentials( + const grpc::string& type, ChannelArguments* args) { + return GetProvider()->GetChannelCredentials(type, args); +} + +std::shared_ptr GetServerCredentials( + const grpc::string& type) { + return GetProvider()->GetServerCredentials(type); +} + +std::vector GetSecureCredentialsTypeList() { + return GetProvider()->GetSecureCredentialsTypeList(); } } // namespace testing diff --git a/test/cpp/util/test_credentials_provider.h b/test/cpp/util/test_credentials_provider.h index 0bc52ebe4df..1fb311e556e 100644 --- a/test/cpp/util/test_credentials_provider.h +++ b/test/cpp/util/test_credentials_provider.h @@ -59,39 +59,23 @@ class CredentialTypeProvider { virtual std::shared_ptr GetServerCredentials() = 0; }; -// Provide test credentials. Thread-safe. -class CredentialsProvider { - public: - virtual ~CredentialsProvider() {} - - // Add a secure type in addition to the defaults. The default provider has - // (kInsecureCredentialsType, kTlsCredentialsType). - virtual void AddSecureType( - const grpc::string& type, - std::unique_ptr type_provider) = 0; - - // Provide channel credentials according to the given type. Alter the channel - // arguments if needed. Return nullptr if type is not registered. - virtual std::shared_ptr GetChannelCredentials( - const grpc::string& type, ChannelArguments* args) = 0; - - // Provide server credentials according to the given type. - // Return nullptr if type is not registered. - virtual std::shared_ptr GetServerCredentials( - const grpc::string& type) = 0; - - // Provide a list of secure credentials type. - virtual std::vector GetSecureCredentialsTypeList() = 0; -}; - -// Get the current provider. Create a default one if not set. -// Not thread-safe. -CredentialsProvider* GetCredentialsProvider(); - -// Set the global provider. Takes ownership. The previous set provider will be -// destroyed. -// Not thread-safe. -void SetCredentialsProvider(CredentialsProvider* provider); +// Add a secure type in addition to the defaults above +// (kInsecureCredentialsType, kTlsCredentialsType) that can be returned from the +// functions below. +void AddSecureType(const grpc::string& type, + std::unique_ptr type_provider); + +// Provide channel credentials according to the given type. Alter the channel +// arguments if needed. +std::shared_ptr GetChannelCredentials( + const grpc::string& type, ChannelArguments* args); + +// Provide server credentials according to the given type. +std::shared_ptr GetServerCredentials( + const grpc::string& type); + +// Provide a list of secure credentials type. +std::vector GetSecureCredentialsTypeList(); } // namespace testing } // namespace grpc diff --git a/tools/run_tests/sources_and_headers.json b/tools/run_tests/sources_and_headers.json index a5700d26c34..abdcfe501b2 100644 --- a/tools/run_tests/sources_and_headers.json +++ b/tools/run_tests/sources_and_headers.json @@ -5447,7 +5447,6 @@ "gpr", "grpc", "grpc++", - "grpc++_test_util", "grpc_test_util" ], "headers": [ diff --git a/vsprojects/vcxproj/interop_server_helper/interop_server_helper.vcxproj b/vsprojects/vcxproj/interop_server_helper/interop_server_helper.vcxproj index 377cadc1a1e..4c99988a34c 100644 --- a/vsprojects/vcxproj/interop_server_helper/interop_server_helper.vcxproj +++ b/vsprojects/vcxproj/interop_server_helper/interop_server_helper.vcxproj @@ -154,9 +154,6 @@ - - {0BE77741-552A-929B-A497-4EF7ECE17A64} - {17BCAFC0-5FDC-4C94-AEB9-95F3E220614B} From cbafdd1084384e9233aa846b7f3e627fdc281910 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 29 Nov 2016 13:54:00 -0800 Subject: [PATCH 76/86] Fix races on tcp server shutdown on Windows - we were treating an int as atomic, which is dubious at best - it was possible to shutdown while an accept was being handled, and process that shutdown accept before the real accept finished, leading to a use-after-free up the stack --- src/core/lib/iomgr/tcp_server_windows.c | 77 ++++++++++++------------- 1 file changed, 37 insertions(+), 40 deletions(-) diff --git a/src/core/lib/iomgr/tcp_server_windows.c b/src/core/lib/iomgr/tcp_server_windows.c index ae54c70d2d0..cd031a6c029 100644 --- a/src/core/lib/iomgr/tcp_server_windows.c +++ b/src/core/lib/iomgr/tcp_server_windows.c @@ -73,6 +73,7 @@ struct grpc_tcp_listener { /* The cached AcceptEx for that port. */ LPFN_ACCEPTEX AcceptEx; int shutting_down; + int outstanding_calls; /* closure for socket notification of accept being ready */ grpc_closure on_accept; /* linked list */ @@ -140,10 +141,8 @@ grpc_error *grpc_tcp_server_create(grpc_exec_ctx *exec_ctx, return GRPC_ERROR_NONE; } -static void finish_shutdown(grpc_exec_ctx *exec_ctx, grpc_tcp_server *s) { - if (s->shutdown_complete != NULL) { - grpc_exec_ctx_sched(exec_ctx, s->shutdown_complete, GRPC_ERROR_NONE, NULL); - } +static void destroy_server(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) { + grpc_tcp_server *s = arg; /* Now that the accepts have been aborted, we can destroy the sockets. The IOCP won't get notified on these, so we can flag them as already @@ -159,6 +158,14 @@ static void finish_shutdown(grpc_exec_ctx *exec_ctx, grpc_tcp_server *s) { gpr_free(s); } +static void finish_shutdown_locked(grpc_exec_ctx *exec_ctx, grpc_tcp_server *s) { + if (s->shutdown_complete != NULL) { + grpc_exec_ctx_sched(exec_ctx, s->shutdown_complete, GRPC_ERROR_NONE, NULL); + } + + grpc_exec_ctx_sched(exec_ctx, grpc_closure_create(destroy_server, s), GRPC_ERROR_NONE, NULL); +} + grpc_tcp_server *grpc_tcp_server_ref(grpc_tcp_server *s) { gpr_ref_non_zero(&s->refs); return s; @@ -180,17 +187,14 @@ static void tcp_server_destroy(grpc_exec_ctx *exec_ctx, grpc_tcp_server *s) { /* First, shutdown all fd's. This will queue abortion calls for all of the pending accepts due to the normal operation mechanism. */ if (s->active_ports == 0) { - immediately_done = 1; - } - for (sp = s->head; sp; sp = sp->next) { - sp->shutting_down = 1; - grpc_winsocket_shutdown(sp->socket); + finish_shutdown_locked(exec_ctx, s); + } else { + for (sp = s->head; sp; sp = sp->next) { + sp->shutting_down = 1; + grpc_winsocket_shutdown(sp->socket); + } } gpr_mu_unlock(&s->mu); - - if (immediately_done) { - finish_shutdown(exec_ctx, s); - } } void grpc_tcp_server_unref(grpc_exec_ctx *exec_ctx, grpc_tcp_server *s) { @@ -251,24 +255,19 @@ failure: return error; } -static void decrement_active_ports_and_notify(grpc_exec_ctx *exec_ctx, +static void decrement_active_ports_and_notify_locked(grpc_exec_ctx *exec_ctx, grpc_tcp_listener *sp) { int notify = 0; sp->shutting_down = 0; - gpr_mu_lock(&sp->server->mu); GPR_ASSERT(sp->server->active_ports > 0); if (0 == --sp->server->active_ports) { - notify = 1; - } - gpr_mu_unlock(&sp->server->mu); - if (notify) { - finish_shutdown(exec_ctx, sp->server); + finish_shutdown_locked(exec_ctx, sp->server); } } /* In order to do an async accept, we need to create a socket first which will be the one assigned to the new incoming connection. */ -static grpc_error *start_accept(grpc_exec_ctx *exec_ctx, +static grpc_error *start_accept_locked(grpc_exec_ctx *exec_ctx, grpc_tcp_listener *port) { SOCKET sock = INVALID_SOCKET; BOOL success; @@ -276,6 +275,10 @@ static grpc_error *start_accept(grpc_exec_ctx *exec_ctx, DWORD bytes_received = 0; grpc_error *error = GRPC_ERROR_NONE; + if (port->shutting_down) { + return GRPC_ERROR_NONE; + } + sock = WSASocket(AF_INET6, SOCK_STREAM, IPPROTO_TCP, NULL, 0, WSA_FLAG_OVERLAPPED); if (sock == INVALID_SOCKET) { @@ -305,20 +308,11 @@ static grpc_error *start_accept(grpc_exec_ctx *exec_ctx, immediately process an accept that happened in the meantime. */ port->new_socket = sock; grpc_socket_notify_on_read(exec_ctx, port->socket, &port->on_accept); + port->outstanding_calls++; return error; failure: GPR_ASSERT(error != GRPC_ERROR_NONE); - if (port->shutting_down) { - /* We are abandoning the listener port, take that into account to prevent - occasional hangs on shutdown. The hang happens when sp->shutting_down - change is not seen by on_accept and we proceed to trying new accept, - but we fail there because the listening port has been closed in the - meantime. */ - decrement_active_ports_and_notify(exec_ctx, port); - GRPC_ERROR_UNREF(error); - return GRPC_ERROR_NONE; - } if (sock != INVALID_SOCKET) closesocket(sock); return error; } @@ -338,6 +332,8 @@ static void on_accept(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) { BOOL wsa_success; int err; + gpr_mu_lock(&sp->server->mu); + peer_name.len = sizeof(struct sockaddr_storage); /* The general mechanism for shutting down is to queue abortion calls. While @@ -347,6 +343,7 @@ static void on_accept(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) { const char *msg = grpc_error_string(error); gpr_log(GPR_INFO, "Skipping on_accept due to error: %s", msg); grpc_error_free_string(msg); + gpr_mu_unlock(&sp->server->mu); return; } @@ -356,17 +353,12 @@ static void on_accept(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) { wsa_success = WSAGetOverlappedResult(sock, &info->overlapped, &transfered_bytes, FALSE, &flags); if (!wsa_success) { - if (sp->shutting_down) { - /* During the shutdown case, we ARE expecting an error. So that's well, - and we can wake up the shutdown thread. */ - decrement_active_ports_and_notify(exec_ctx, sp); - return; - } else { + if (!sp->shutting_down) { char *utf8_message = gpr_format_message(WSAGetLastError()); gpr_log(GPR_ERROR, "on_accept error: %s", utf8_message); gpr_free(utf8_message); - closesocket(sock); } + closesocket(sock); } else { if (!sp->shutting_down) { peer_name_string = NULL; @@ -408,7 +400,11 @@ static void on_accept(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) { the former socked we created has now either been destroy or assigned to the new connection. We need to create a new one for the next connection. */ - GPR_ASSERT(GRPC_LOG_IF_ERROR("start_accept", start_accept(exec_ctx, sp))); + GPR_ASSERT(GRPC_LOG_IF_ERROR("start_accept", start_accept_locked(exec_ctx, sp))); + if (0 == --sp->outstanding_calls) { + decrement_active_ports_and_notify_locked(exec_ctx, sp); + } + gpr_mu_unlock(&sp->server->mu); } static grpc_error *add_socket_to_server(grpc_tcp_server *s, SOCKET sock, @@ -456,6 +452,7 @@ static grpc_error *add_socket_to_server(grpc_tcp_server *s, SOCKET sock, sp->server = s; sp->socket = grpc_winsocket_create(sock, "listener"); sp->shutting_down = 0; + sp->outstanding_calls = 0; sp->AcceptEx = AcceptEx; sp->new_socket = INVALID_SOCKET; sp->port = port; @@ -553,7 +550,7 @@ void grpc_tcp_server_start(grpc_exec_ctx *exec_ctx, grpc_tcp_server *s, s->on_accept_cb = on_accept_cb; s->on_accept_cb_arg = on_accept_cb_arg; for (sp = s->head; sp; sp = sp->next) { - GPR_ASSERT(GRPC_LOG_IF_ERROR("start_accept", start_accept(exec_ctx, sp))); + GPR_ASSERT(GRPC_LOG_IF_ERROR("start_accept", start_accept_locked(exec_ctx, sp))); s->active_ports++; } gpr_mu_unlock(&s->mu); From fdc17aab96b4a8a4651e7d3042051baa29860dba Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 29 Nov 2016 13:54:19 -0800 Subject: [PATCH 77/86] clang-format --- src/core/lib/iomgr/tcp_server_windows.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/core/lib/iomgr/tcp_server_windows.c b/src/core/lib/iomgr/tcp_server_windows.c index cd031a6c029..b8a391c0590 100644 --- a/src/core/lib/iomgr/tcp_server_windows.c +++ b/src/core/lib/iomgr/tcp_server_windows.c @@ -141,7 +141,8 @@ grpc_error *grpc_tcp_server_create(grpc_exec_ctx *exec_ctx, return GRPC_ERROR_NONE; } -static void destroy_server(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) { +static void destroy_server(grpc_exec_ctx *exec_ctx, void *arg, + grpc_error *error) { grpc_tcp_server *s = arg; /* Now that the accepts have been aborted, we can destroy the sockets. @@ -158,12 +159,14 @@ static void destroy_server(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error gpr_free(s); } -static void finish_shutdown_locked(grpc_exec_ctx *exec_ctx, grpc_tcp_server *s) { +static void finish_shutdown_locked(grpc_exec_ctx *exec_ctx, + grpc_tcp_server *s) { if (s->shutdown_complete != NULL) { grpc_exec_ctx_sched(exec_ctx, s->shutdown_complete, GRPC_ERROR_NONE, NULL); } - grpc_exec_ctx_sched(exec_ctx, grpc_closure_create(destroy_server, s), GRPC_ERROR_NONE, NULL); + grpc_exec_ctx_sched(exec_ctx, grpc_closure_create(destroy_server, s), + GRPC_ERROR_NONE, NULL); } grpc_tcp_server *grpc_tcp_server_ref(grpc_tcp_server *s) { @@ -256,7 +259,7 @@ failure: } static void decrement_active_ports_and_notify_locked(grpc_exec_ctx *exec_ctx, - grpc_tcp_listener *sp) { + grpc_tcp_listener *sp) { int notify = 0; sp->shutting_down = 0; GPR_ASSERT(sp->server->active_ports > 0); @@ -268,7 +271,7 @@ static void decrement_active_ports_and_notify_locked(grpc_exec_ctx *exec_ctx, /* In order to do an async accept, we need to create a socket first which will be the one assigned to the new incoming connection. */ static grpc_error *start_accept_locked(grpc_exec_ctx *exec_ctx, - grpc_tcp_listener *port) { + grpc_tcp_listener *port) { SOCKET sock = INVALID_SOCKET; BOOL success; DWORD addrlen = sizeof(struct sockaddr_in6) + 16; @@ -400,7 +403,8 @@ static void on_accept(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) { the former socked we created has now either been destroy or assigned to the new connection. We need to create a new one for the next connection. */ - GPR_ASSERT(GRPC_LOG_IF_ERROR("start_accept", start_accept_locked(exec_ctx, sp))); + GPR_ASSERT( + GRPC_LOG_IF_ERROR("start_accept", start_accept_locked(exec_ctx, sp))); if (0 == --sp->outstanding_calls) { decrement_active_ports_and_notify_locked(exec_ctx, sp); } @@ -550,7 +554,8 @@ void grpc_tcp_server_start(grpc_exec_ctx *exec_ctx, grpc_tcp_server *s, s->on_accept_cb = on_accept_cb; s->on_accept_cb_arg = on_accept_cb_arg; for (sp = s->head; sp; sp = sp->next) { - GPR_ASSERT(GRPC_LOG_IF_ERROR("start_accept", start_accept_locked(exec_ctx, sp))); + GPR_ASSERT( + GRPC_LOG_IF_ERROR("start_accept", start_accept_locked(exec_ctx, sp))); s->active_ports++; } gpr_mu_unlock(&s->mu); From d6936b6bee465f903a5788dd2c76bbd49f8cb48b Mon Sep 17 00:00:00 2001 From: David Garcia Quintas Date: Tue, 29 Nov 2016 17:22:48 -0800 Subject: [PATCH 78/86] PR comments --- test/cpp/qps/json_run_localhost.cc | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/test/cpp/qps/json_run_localhost.cc b/test/cpp/qps/json_run_localhost.cc index 70c50cdc71b..59a5a89ca34 100644 --- a/test/cpp/qps/json_run_localhost.cc +++ b/test/cpp/qps/json_run_localhost.cc @@ -47,8 +47,9 @@ using grpc::SubProcess; typedef std::unique_ptr SubProcessPtr; -std::vector g_workers; SubProcessPtr g_driver; +constexpr auto kNumWorkers = 2; +std::vector g_workers(2); template std::string as_string(const T& val) { @@ -58,10 +59,11 @@ std::string as_string(const T& val) { } static void sighandler(int sig) { + const int errno_saved = errno; g_driver->Interrupt(); - for (auto it = g_workers.begin(); it != g_workers.end(); ++it) { - (*it)->Interrupt(); - } + for (const auto& worker : g_workers) + if (worker) worker->Interrupt(); + errno = errno_saved; } static void register_sighandler() { @@ -82,11 +84,11 @@ int main(int argc, char** argv) { std::ostringstream env; bool first = true; - for (int i = 0; i < 2; i++) { - auto port = grpc_pick_unused_port_or_die(); + for (int i = 0; i < kNumWorkers; i++) { + const auto port = grpc_pick_unused_port_or_die(); std::vector args = {bin_dir + "/qps_worker", "-driver_port", as_string(port)}; - g_workers.emplace_back(new SubProcess(args)); + g_workers[i].reset(new SubProcess(args)); if (!first) env << ","; env << "localhost:" << port; first = false; @@ -100,11 +102,9 @@ int main(int argc, char** argv) { g_driver.reset(new SubProcess(args)); const int driver_join_status = g_driver->Join(); - for (auto it = g_workers.begin(); it != g_workers.end(); ++it) { - (*it)->Interrupt(); - } - for (auto it = g_workers.begin(); it != g_workers.end(); ++it) { - (*it)->Join(); - } + for (const auto& worker : g_workers) + if (worker) worker->Interrupt(); + for (const auto& worker : g_workers) + if (worker) worker->Join(); GPR_ASSERT(driver_join_status == 0); } From 4024e8961d051d7e38b05a4606d810c9eab9871e Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Tue, 29 Nov 2016 16:32:54 +0100 Subject: [PATCH 79/86] basic config for internal CI --- tools/README.md | 2 ++ tools/internal_ci/README.md | 6 ++++ tools/internal_ci/linux/grpc_master.cfg | 34 +++++++++++++++++++ tools/internal_ci/linux/run_tests.sh | 45 +++++++++++++++++++++++++ tools/jenkins/README.md | 5 +++ 5 files changed, 92 insertions(+) create mode 100644 tools/internal_ci/README.md create mode 100644 tools/internal_ci/linux/grpc_master.cfg create mode 100755 tools/internal_ci/linux/run_tests.sh diff --git a/tools/README.md b/tools/README.md index d142d4aee28..d051846c33e 100644 --- a/tools/README.md +++ b/tools/README.md @@ -11,6 +11,8 @@ gce: Scripts to help setup testing infrastructure on GCE. gcp: Helper scripts for interacting with various services on GCP (like Google container engine, BigQuery etc) +internal_ci: Support for running tests on an internal CI platform. + jenkins: Support for running tests on Jenkins. run_tests: Scripts to run gRPC tests in parallel. diff --git a/tools/internal_ci/README.md b/tools/internal_ci/README.md new file mode 100644 index 00000000000..8bed6ca782b --- /dev/null +++ b/tools/internal_ci/README.md @@ -0,0 +1,6 @@ +#Internal continuous integration + +gRPC's externally facing testing is managed by Jenkins CI (see `tools/jenkins` +directory). Nevertheless, some of the tests are better suited for being run +on internal infrastructure and using an internal CI system. Configuration for +such tests is under this directory. diff --git a/tools/internal_ci/linux/grpc_master.cfg b/tools/internal_ci/linux/grpc_master.cfg new file mode 100644 index 00000000000..1f816600780 --- /dev/null +++ b/tools/internal_ci/linux/grpc_master.cfg @@ -0,0 +1,34 @@ +#!/bin/bash +# Copyright 2016, Google Inc. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following disclaimer +# in the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Google Inc. nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +# Config file for the internal CI (in protobuf text format) + +# Location of the continuous shell script in repository. +build_file: "grpc/tools/internal_ci/linux/run_tests.sh" diff --git a/tools/internal_ci/linux/run_tests.sh b/tools/internal_ci/linux/run_tests.sh new file mode 100755 index 00000000000..be477c1271d --- /dev/null +++ b/tools/internal_ci/linux/run_tests.sh @@ -0,0 +1,45 @@ +#!/bin/bash +# Copyright 2016, Google Inc. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following disclaimer +# in the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Google Inc. nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +set -ex + +# change to grpc repo root +cd $(dirname $0)/../../.. + +# TODO(jtattermusch): get rid of the system inspection eventually +nproc || true +lsb_release -dc || true +gcc --version || true +clang --version || true +docker --version || true + +git submodule update --init + +tools/run_tests/run_tests.py -l c --build_only diff --git a/tools/jenkins/README.md b/tools/jenkins/README.md index 8e06b68466c..02f63f0f4a4 100644 --- a/tools/jenkins/README.md +++ b/tools/jenkins/README.md @@ -1 +1,6 @@ +# Jenkins CI scripts + Scripts invoked by Jenkins (our CI platform) to run gRPC test suites. +We run a comprehensive set of tests (unit, integration, interop, +performance, portability..) on each pull request and also periodically on +`master` and release branches. From 033c51e8c848c02ac256c823ffbc510daa1d4f56 Mon Sep 17 00:00:00 2001 From: David Garcia Quintas Date: Wed, 30 Nov 2016 00:49:29 -0800 Subject: [PATCH 80/86] Deflake grpclb test --- test/cpp/grpclb/grpclb_test.cc | 59 ++++++++++++++++++---------------- 1 file changed, 31 insertions(+), 28 deletions(-) diff --git a/test/cpp/grpclb/grpclb_test.cc b/test/cpp/grpclb/grpclb_test.cc index 57a53ca11e5..fcdcaba6a23 100644 --- a/test/cpp/grpclb/grpclb_test.cc +++ b/test/cpp/grpclb/grpclb_test.cc @@ -523,9 +523,8 @@ static void perform_request(client_fixture *cf) { CQ_EXPECT_COMPLETION(cqv, tag(2), 1); cq_verify(cqv); + gpr_log(GPR_INFO, "Client after sending msg %d / 4", i + 1); GPR_ASSERT(byte_buffer_eq_string(response_payload_recv, PAYLOAD)); - GPR_ASSERT(grpc_channel_check_connectivity_state( - cf->client, 0 /* try to connect */) == GRPC_CHANNEL_READY); grpc_byte_buffer_destroy(request_payload); grpc_byte_buffer_destroy(response_payload_recv); @@ -546,16 +545,17 @@ static void perform_request(client_fixture *cf) { cq_verify(cqv); peer = grpc_call_get_peer(c); gpr_log(GPR_INFO, "Client DONE WITH SERVER %s ", peer); - gpr_free(peer); grpc_call_destroy(c); - cq_verify_empty_timeout(cqv, 1); + cq_verify_empty_timeout(cqv, 1 /* seconds */); cq_verifier_destroy(cqv); grpc_metadata_array_destroy(&initial_metadata_recv); grpc_metadata_array_destroy(&trailing_metadata_recv); gpr_free(details); + gpr_log(GPR_INFO, "Client call (peer %s) DESTROYED.", peer); + gpr_free(peer); } static void setup_client(const char *server_hostport, client_fixture *cf) { @@ -699,39 +699,42 @@ static test_fixture test_update(int lb_server_update_delay_ms) { TEST(GrpclbTest, Updates) { grpc::test_fixture tf_result; - // Clients take a bit over one second to complete a call (the last part of the + // Clients take at least one second to complete a call (the last part of the // call sleeps for 1 second while verifying the client's completion queue is - // empty). Therefore: + // empty), more if the system is under load. Therefore: // // If the LB server waits 800ms before sending an update, it will arrive - // before the first client request is done, skipping the second server from - // batch 1 altogether: the 2nd client request will go to the 1st server of - // batch 2 (ie, the third one out of the four total servers). + // before the first client request finishes, skipping the second server from + // batch 1. All subsequent picks will come from the second half of the + // backends, those coming in the LB update. tf_result = grpc::test_update(800); GPR_ASSERT(tf_result.lb_backends[0].num_calls_serviced == 1); GPR_ASSERT(tf_result.lb_backends[1].num_calls_serviced == 0); - GPR_ASSERT(tf_result.lb_backends[2].num_calls_serviced == 2); - GPR_ASSERT(tf_result.lb_backends[3].num_calls_serviced == 1); + GPR_ASSERT(tf_result.lb_backends[2].num_calls_serviced + + tf_result.lb_backends[3].num_calls_serviced > + 0); + int num_serviced_calls = 0; + for (int i = 0; i < 4; i++) { + num_serviced_calls += tf_result.lb_backends[i].num_calls_serviced; + } + GPR_ASSERT(num_serviced_calls == 4); - // If the LB server waits 1500ms, the update arrives after having picked the - // 2nd server from batch 1 but before the next pick for the first server of - // batch 2. All server are used. - tf_result = grpc::test_update(1500); - GPR_ASSERT(tf_result.lb_backends[0].num_calls_serviced == 1); - GPR_ASSERT(tf_result.lb_backends[1].num_calls_serviced == 1); - GPR_ASSERT(tf_result.lb_backends[2].num_calls_serviced == 1); - GPR_ASSERT(tf_result.lb_backends[3].num_calls_serviced == 1); - - // If the LB server waits > 2000ms, the update arrives after the first two - // request are done and the third pick is performed, which returns, in RR - // fashion, the 1st server of the 1st update. Therefore, the second server of - // batch 1 is hit at least one, whereas the first server of batch 2 is never - // hit. + // If the LB server waits 2500ms, the update arrives after two calls and three + // picks. The third pick will be the 1st server of the 1st update (RR policy + // going around). The fourth and final pick will come from the second LB + // update. In any case, the total number of serviced calls must again be equal + // to four across all the backends. tf_result = grpc::test_update(2500); GPR_ASSERT(tf_result.lb_backends[0].num_calls_serviced >= 1); - GPR_ASSERT(tf_result.lb_backends[1].num_calls_serviced > 0); - GPR_ASSERT(tf_result.lb_backends[2].num_calls_serviced > 0); - GPR_ASSERT(tf_result.lb_backends[3].num_calls_serviced == 0); + GPR_ASSERT(tf_result.lb_backends[1].num_calls_serviced == 1); + GPR_ASSERT(tf_result.lb_backends[2].num_calls_serviced + + tf_result.lb_backends[3].num_calls_serviced > + 0); + num_serviced_calls = 0; + for (int i = 0; i < 4; i++) { + num_serviced_calls += tf_result.lb_backends[i].num_calls_serviced; + } + GPR_ASSERT(num_serviced_calls == 4); } TEST(GrpclbTest, InvalidAddressInServerlist) {} From d112ed94daf5a0f656f7d0d34f7c76d06a60e195 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Wed, 30 Nov 2016 09:16:07 -0800 Subject: [PATCH 81/86] Further safety fixes for TCP on Windows --- src/core/lib/iomgr/socket_windows.c | 8 ++++++++ src/core/lib/iomgr/socket_windows.h | 1 + src/core/lib/iomgr/tcp_client_windows.c | 24 ++++++++++++++---------- 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/src/core/lib/iomgr/socket_windows.c b/src/core/lib/iomgr/socket_windows.c index 35f23300dc7..54911e0e31f 100644 --- a/src/core/lib/iomgr/socket_windows.c +++ b/src/core/lib/iomgr/socket_windows.c @@ -76,6 +76,14 @@ void grpc_winsocket_shutdown(grpc_winsocket *winsocket) { LPFN_DISCONNECTEX DisconnectEx; DWORD ioctl_num_bytes; + gpr_mu_lock(&winsocket->state_mu); + if (winsocket->shutdown_called) { + gpr_mu_unlock(&winsocket->state_mu); + return; + } + winsocket->shutdown_called = true; + gpr_mu_unlock(&winsocket->state_mu); + status = WSAIoctl(winsocket->socket, SIO_GET_EXTENSION_FUNCTION_POINTER, &guid, sizeof(guid), &DisconnectEx, sizeof(DisconnectEx), &ioctl_num_bytes, NULL, NULL); diff --git a/src/core/lib/iomgr/socket_windows.h b/src/core/lib/iomgr/socket_windows.h index 490d0e0a067..a3875ce16c4 100644 --- a/src/core/lib/iomgr/socket_windows.h +++ b/src/core/lib/iomgr/socket_windows.h @@ -87,6 +87,7 @@ typedef struct grpc_winsocket { grpc_winsocket_callback_info read_info; gpr_mu state_mu; + bool shutdown_called; /* You can't add the same socket twice to the same IO Completion Port. This prevents that. */ diff --git a/src/core/lib/iomgr/tcp_client_windows.c b/src/core/lib/iomgr/tcp_client_windows.c index 4d1e809872a..14bd9447cb3 100644 --- a/src/core/lib/iomgr/tcp_client_windows.c +++ b/src/core/lib/iomgr/tcp_client_windows.c @@ -107,18 +107,22 @@ static void on_connect(grpc_exec_ctx *exec_ctx, void *acp, grpc_error *error) { gpr_mu_lock(&ac->mu); - if (error == GRPC_ERROR_NONE && socket != NULL) { - DWORD transfered_bytes = 0; - DWORD flags; - BOOL wsa_success = + if (error == GRPC_ERROR_NONE) { + if (socket != NULL) { + DWORD transfered_bytes = 0; + DWORD flags; + BOOL wsa_success = WSAGetOverlappedResult(socket->socket, &socket->write_info.overlapped, - &transfered_bytes, FALSE, &flags); - GPR_ASSERT(transfered_bytes == 0); - if (!wsa_success) { - error = GRPC_WSA_ERROR(WSAGetLastError(), "ConnectEx"); + &transfered_bytes, FALSE, &flags); + GPR_ASSERT(transfered_bytes == 0); + if (!wsa_success) { + error = GRPC_WSA_ERROR(WSAGetLastError(), "ConnectEx"); + } else { + *ep = grpc_tcp_create(socket, ac->resource_quota, ac->addr_name); + socket = NULL; + } } else { - *ep = grpc_tcp_create(socket, ac->resource_quota, ac->addr_name); - socket = NULL; + error = GRPC_ERROR_CREATE("socket is null"); } } From e06836130015bccc7d1ae8afd1fad403318503b0 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Wed, 30 Nov 2016 09:16:02 -0800 Subject: [PATCH 82/86] clang-format --- src/core/lib/iomgr/tcp_client_windows.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/lib/iomgr/tcp_client_windows.c b/src/core/lib/iomgr/tcp_client_windows.c index 14bd9447cb3..1127588ebc7 100644 --- a/src/core/lib/iomgr/tcp_client_windows.c +++ b/src/core/lib/iomgr/tcp_client_windows.c @@ -112,8 +112,8 @@ static void on_connect(grpc_exec_ctx *exec_ctx, void *acp, grpc_error *error) { DWORD transfered_bytes = 0; DWORD flags; BOOL wsa_success = - WSAGetOverlappedResult(socket->socket, &socket->write_info.overlapped, - &transfered_bytes, FALSE, &flags); + WSAGetOverlappedResult(socket->socket, &socket->write_info.overlapped, + &transfered_bytes, FALSE, &flags); GPR_ASSERT(transfered_bytes == 0); if (!wsa_success) { error = GRPC_WSA_ERROR(WSAGetLastError(), "ConnectEx"); From 523a4aa0a06de21ffe23582b373d18488f78c8e2 Mon Sep 17 00:00:00 2001 From: David Garcia Quintas Date: Wed, 30 Nov 2016 10:50:39 -0800 Subject: [PATCH 83/86] PR comments --- test/cpp/qps/json_run_localhost.cc | 31 ++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/test/cpp/qps/json_run_localhost.cc b/test/cpp/qps/json_run_localhost.cc index b6e96601d19..409abed12e8 100644 --- a/test/cpp/qps/json_run_localhost.cc +++ b/test/cpp/qps/json_run_localhost.cc @@ -46,10 +46,11 @@ #include "test/cpp/util/subprocess.h" using grpc::SubProcess; -typedef std::unique_ptr SubProcessPtr; -SubProcessPtr g_driver; + constexpr auto kNumWorkers = 2; -std::vector g_workers(2); + +static SubProcess* g_driver; +static SubProcess* g_workers[kNumWorkers]; template std::string as_string(const T& val) { @@ -61,8 +62,9 @@ std::string as_string(const T& val) { static void sighandler(int sig) { const int errno_saved = errno; g_driver->Interrupt(); - for (const auto& worker : g_workers) - if (worker) worker->Interrupt(); + for (int i = 0; i < kNumWorkers; ++i) { + if (g_workers[i]) g_workers[i]->Interrupt(); + } errno = errno_saved; } @@ -100,7 +102,7 @@ int main(int argc, char** argv) { const auto port = grpc_pick_unused_port_or_die(); std::vector args = {bin_dir + "/qps_worker", "-driver_port", as_string(port)}; - g_workers[i].reset(new SubProcess(args)); + g_workers[i] = new SubProcess(args); if (!first) env << ","; env << "localhost:" << port; first = false; @@ -112,20 +114,25 @@ int main(int argc, char** argv) { args.push_back(argv[i]); } - g_driver.reset(new SubProcess(args)); + g_driver = new SubProcess(args); const int driver_join_status = g_driver->Join(); if (driver_join_status != 0) { LogStatus(driver_join_status, "driver"); } - for (const auto& worker : g_workers) { - if (worker) worker->Interrupt(); + for (int i = 0; i < kNumWorkers; ++i) { + if (g_workers[i]) g_workers[i]->Interrupt(); } - for (const auto& worker : g_workers) { - if (worker) { - const int worker_status = worker->Join(); + + for (int i = 0; i < kNumWorkers; ++i) { + if (g_workers[i]) { + const int worker_status = g_workers[i]->Join(); if (worker_status != 0) { LogStatus(worker_status, "worker"); } } } + + delete g_driver; + for (int i = 0; i < kNumWorkers; ++i) delete g_workers[i]; + GPR_ASSERT(driver_join_status == 0); } From 3c5a868a1bbd0bf08d3c6a4213f7807f3cfdb893 Mon Sep 17 00:00:00 2001 From: David Garcia Quintas Date: Wed, 30 Nov 2016 11:26:58 -0800 Subject: [PATCH 84/86] PR comments #2 --- test/cpp/qps/json_run_localhost.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/cpp/qps/json_run_localhost.cc b/test/cpp/qps/json_run_localhost.cc index 409abed12e8..b7b2553f12d 100644 --- a/test/cpp/qps/json_run_localhost.cc +++ b/test/cpp/qps/json_run_localhost.cc @@ -61,7 +61,7 @@ std::string as_string(const T& val) { static void sighandler(int sig) { const int errno_saved = errno; - g_driver->Interrupt(); + if (g_driver != NULL) g_driver->Interrupt(); for (int i = 0; i < kNumWorkers; ++i) { if (g_workers[i]) g_workers[i]->Interrupt(); } @@ -133,6 +133,7 @@ int main(int argc, char** argv) { } delete g_driver; + g_driver = NULL; for (int i = 0; i < kNumWorkers; ++i) delete g_workers[i]; GPR_ASSERT(driver_join_status == 0); } From 296984b46c5e130c7aed4bdae1fc910108e3cbce Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Wed, 30 Nov 2016 12:25:02 -0800 Subject: [PATCH 85/86] Break infinite connection retry loop Previously, we'd keep retrying a connection until the channel closed. With this change, we only retry connecting *if there's a watcher on the subchannel connection state*. This ultimately means that if the lb_policy doesn't care if the subchannel connects, it'll stop trying. --- src/core/ext/client_channel/subchannel.c | 135 ++++++++++++-------- src/core/lib/transport/connectivity_state.c | 13 +- src/core/lib/transport/connectivity_state.h | 5 +- 3 files changed, 95 insertions(+), 58 deletions(-) diff --git a/src/core/ext/client_channel/subchannel.c b/src/core/ext/client_channel/subchannel.c index a148b2a0e1d..bb3d167becd 100644 --- a/src/core/ext/client_channel/subchannel.c +++ b/src/core/ext/client_channel/subchannel.c @@ -119,9 +119,9 @@ struct grpc_subchannel { gpr_mu mu; /** have we seen a disconnection? */ - int disconnected; + bool disconnected; /** are we connecting */ - int connecting; + bool connecting; /** connectivity state tracking */ grpc_connectivity_state_tracker state_tracker; @@ -132,7 +132,9 @@ struct grpc_subchannel { /** backoff state */ gpr_backoff backoff_state; /** do we have an active alarm? */ - int have_alarm; + bool have_alarm; + /** have we started the backoff loop */ + bool backoff_begun; /** our alarm */ grpc_timer alarm; }; @@ -264,7 +266,7 @@ static void disconnect(grpc_exec_ctx *exec_ctx, grpc_subchannel *c) { grpc_subchannel_index_unregister(exec_ctx, c->key, c); gpr_mu_lock(&c->mu); GPR_ASSERT(!c->disconnected); - c->disconnected = 1; + c->disconnected = true; grpc_connector_shutdown(exec_ctx, c->connector); con = GET_CONNECTED_SUBCHANNEL(c, no_barrier); if (con != NULL) { @@ -386,12 +388,6 @@ static void continue_connect(grpc_exec_ctx *exec_ctx, grpc_subchannel *c) { &c->connected); } -static void start_connect(grpc_exec_ctx *exec_ctx, grpc_subchannel *c) { - c->next_attempt = - gpr_backoff_begin(&c->backoff_state, gpr_now(GPR_CLOCK_MONOTONIC)); - continue_connect(exec_ctx, c); -} - grpc_connectivity_state grpc_subchannel_check_connectivity(grpc_subchannel *c, grpc_error **error) { grpc_connectivity_state state; @@ -418,6 +414,73 @@ static void on_external_state_watcher_done(grpc_exec_ctx *exec_ctx, void *arg, follow_up->cb(exec_ctx, follow_up->cb_arg, error); } +static void on_alarm(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) { + grpc_subchannel *c = arg; + gpr_mu_lock(&c->mu); + c->have_alarm = 0; + if (c->disconnected) { + error = GRPC_ERROR_CREATE_REFERENCING("Disconnected", &error, 1); + } else { + GRPC_ERROR_REF(error); + } + if (error == GRPC_ERROR_NONE) { + gpr_log(GPR_INFO, "Failed to connect to channel, retrying"); + c->next_attempt = + gpr_backoff_step(&c->backoff_state, gpr_now(GPR_CLOCK_MONOTONIC)); + continue_connect(exec_ctx, c); + gpr_mu_unlock(&c->mu); + } else { + gpr_mu_unlock(&c->mu); + GRPC_SUBCHANNEL_WEAK_UNREF(exec_ctx, c, "connecting"); + } + GRPC_ERROR_UNREF(error); +} + +static void maybe_start_connecting_locked(grpc_exec_ctx *exec_ctx, + grpc_subchannel *c) { + if (c->disconnected) { + /* Don't try to connect if we're already disconnected */ + return; + } + + if (c->connecting) { + /* Already connecting: don't restart */ + return; + } + + if (GET_CONNECTED_SUBCHANNEL(c, no_barrier) != NULL) { + /* Already connected: don't restart */ + return; + } + + if (!grpc_connectivity_state_has_watchers(&c->state_tracker)) { + /* Nobody is interested in connecting: so don't just yet */ + return; + } + + c->connecting = true; + GRPC_SUBCHANNEL_WEAK_REF(c, "connecting"); + + gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC); + if (!c->backoff_begun) { + c->backoff_begun = true; + c->next_attempt = gpr_backoff_begin(&c->backoff_state, now); + continue_connect(exec_ctx, c); + } else { + GPR_ASSERT(!c->have_alarm); + c->have_alarm = 1; + gpr_timespec time_til_next = gpr_time_sub(c->next_attempt, now); + if (gpr_time_cmp(time_til_next, gpr_time_0(time_til_next.clock_type)) <= + 0) { + gpr_log(GPR_INFO, "Retry immediately"); + } else { + gpr_log(GPR_INFO, "Retry in %" PRId64 ".%09d seconds", + time_til_next.tv_sec, time_til_next.tv_nsec); + } + grpc_timer_init(exec_ctx, &c->alarm, c->next_attempt, on_alarm, c, now); + } +} + void grpc_subchannel_notify_on_state_change( grpc_exec_ctx *exec_ctx, grpc_subchannel *c, grpc_pollset_set *interested_parties, grpc_connectivity_state *state, @@ -449,13 +512,9 @@ void grpc_subchannel_notify_on_state_change( w->next = &c->root_external_state_watcher; w->prev = w->next->prev; w->next->prev = w->prev->next = w; - if (grpc_connectivity_state_notify_on_state_change( - exec_ctx, &c->state_tracker, state, &w->closure)) { - c->connecting = 1; - /* released by connection */ - GRPC_SUBCHANNEL_WEAK_REF(c, "connecting"); - start_connect(exec_ctx, c); - } + grpc_connectivity_state_notify_on_state_change(exec_ctx, &c->state_tracker, + state, &w->closure); + maybe_start_connecting_locked(exec_ctx, c); gpr_mu_unlock(&c->mu); } } @@ -575,7 +634,6 @@ static void publish_transport_locked(grpc_exec_ctx *exec_ctx, Re-evaluate if we really need this. */ gpr_atm_full_barrier(); GPR_ASSERT(gpr_atm_rel_cas(&c->connected_subchannel, 0, (gpr_atm)con)); - c->connecting = 0; /* setup subchannel watching connected subchannel for changes; subchannel ref @@ -592,28 +650,6 @@ static void publish_transport_locked(grpc_exec_ctx *exec_ctx, GRPC_ERROR_NONE, "connected"); } -static void on_alarm(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) { - grpc_subchannel *c = arg; - gpr_mu_lock(&c->mu); - c->have_alarm = 0; - if (c->disconnected) { - error = GRPC_ERROR_CREATE_REFERENCING("Disconnected", &error, 1); - } else { - GRPC_ERROR_REF(error); - } - if (error == GRPC_ERROR_NONE) { - gpr_log(GPR_INFO, "Failed to connect to channel, retrying"); - c->next_attempt = - gpr_backoff_step(&c->backoff_state, gpr_now(GPR_CLOCK_MONOTONIC)); - continue_connect(exec_ctx, c); - gpr_mu_unlock(&c->mu); - } else { - gpr_mu_unlock(&c->mu); - GRPC_SUBCHANNEL_WEAK_UNREF(exec_ctx, c, "connecting"); - } - GRPC_ERROR_UNREF(error); -} - static void subchannel_connected(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) { grpc_subchannel *c = arg; @@ -621,35 +657,28 @@ static void subchannel_connected(grpc_exec_ctx *exec_ctx, void *arg, GRPC_SUBCHANNEL_WEAK_REF(c, "connected"); gpr_mu_lock(&c->mu); + c->connecting = false; if (c->connecting_result.transport != NULL) { publish_transport_locked(exec_ctx, c); } else if (c->disconnected) { GRPC_SUBCHANNEL_WEAK_UNREF(exec_ctx, c, "connecting"); } else { - gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC); - GPR_ASSERT(!c->have_alarm); - c->have_alarm = 1; grpc_connectivity_state_set( exec_ctx, &c->state_tracker, GRPC_CHANNEL_TRANSIENT_FAILURE, grpc_error_set_int( GRPC_ERROR_CREATE_REFERENCING("Connect Failed", &error, 1), GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAVAILABLE), "connect_failed"); - gpr_timespec time_til_next = gpr_time_sub(c->next_attempt, now); + const char *errmsg = grpc_error_string(error); gpr_log(GPR_INFO, "Connect failed: %s", errmsg); - if (gpr_time_cmp(time_til_next, gpr_time_0(time_til_next.clock_type)) <= - 0) { - gpr_log(GPR_INFO, "Retry immediately"); - } else { - gpr_log(GPR_INFO, "Retry in %" PRId64 ".%09d seconds", - time_til_next.tv_sec, time_til_next.tv_nsec); - } - grpc_timer_init(exec_ctx, &c->alarm, c->next_attempt, on_alarm, c, now); grpc_error_free_string(errmsg); + + maybe_start_connecting_locked(exec_ctx, c); + GRPC_SUBCHANNEL_WEAK_UNREF(exec_ctx, c, "connecting"); } gpr_mu_unlock(&c->mu); - GRPC_SUBCHANNEL_WEAK_UNREF(exec_ctx, c, "connecting"); + GRPC_SUBCHANNEL_WEAK_UNREF(exec_ctx, c, "connected"); grpc_channel_args_destroy(delete_channel_args); } diff --git a/src/core/lib/transport/connectivity_state.c b/src/core/lib/transport/connectivity_state.c index 89072879d94..4f49d7cf7d7 100644 --- a/src/core/lib/transport/connectivity_state.c +++ b/src/core/lib/transport/connectivity_state.c @@ -100,7 +100,12 @@ grpc_connectivity_state grpc_connectivity_state_check( return tracker->current_state; } -int grpc_connectivity_state_notify_on_state_change( +bool grpc_connectivity_state_has_watchers( + grpc_connectivity_state_tracker *connectivity_state) { + return connectivity_state->watchers != NULL; +} + +bool grpc_connectivity_state_notify_on_state_change( grpc_exec_ctx *exec_ctx, grpc_connectivity_state_tracker *tracker, grpc_connectivity_state *current, grpc_closure *notify) { if (grpc_connectivity_state_trace) { @@ -119,7 +124,7 @@ int grpc_connectivity_state_notify_on_state_change( grpc_exec_ctx_sched(exec_ctx, notify, GRPC_ERROR_CANCELLED, NULL); tracker->watchers = w->next; gpr_free(w); - return 0; + return false; } while (w != NULL) { grpc_connectivity_state_watcher *rm_candidate = w->next; @@ -127,11 +132,11 @@ int grpc_connectivity_state_notify_on_state_change( grpc_exec_ctx_sched(exec_ctx, notify, GRPC_ERROR_CANCELLED, NULL); w->next = w->next->next; gpr_free(rm_candidate); - return 0; + return false; } w = w->next; } - return 0; + return false; } else { if (tracker->current_state != *current) { *current = tracker->current_state; diff --git a/src/core/lib/transport/connectivity_state.h b/src/core/lib/transport/connectivity_state.h index 7a2fa52c103..769c675b797 100644 --- a/src/core/lib/transport/connectivity_state.h +++ b/src/core/lib/transport/connectivity_state.h @@ -75,13 +75,16 @@ void grpc_connectivity_state_set(grpc_exec_ctx *exec_ctx, grpc_error *associated_error, const char *reason); +bool grpc_connectivity_state_has_watchers( + grpc_connectivity_state_tracker *tracker); + grpc_connectivity_state grpc_connectivity_state_check( grpc_connectivity_state_tracker *tracker, grpc_error **current_error); /** Return 1 if the channel should start connecting, 0 otherwise. If current==NULL cancel notify if it is already queued (success==0 in that case) */ -int grpc_connectivity_state_notify_on_state_change( +bool grpc_connectivity_state_notify_on_state_change( grpc_exec_ctx *exec_ctx, grpc_connectivity_state_tracker *tracker, grpc_connectivity_state *current, grpc_closure *notify); From 9fbb3387d09e90670fba8e0fae01eff8f393acd9 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Wed, 30 Nov 2016 12:58:23 -0800 Subject: [PATCH 86/86] Review feedback --- src/core/ext/client_channel/subchannel.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/core/ext/client_channel/subchannel.c b/src/core/ext/client_channel/subchannel.c index bb3d167becd..b83c6882dc0 100644 --- a/src/core/ext/client_channel/subchannel.c +++ b/src/core/ext/client_channel/subchannel.c @@ -372,7 +372,8 @@ grpc_subchannel *grpc_subchannel_create(grpc_exec_ctx *exec_ctx, return grpc_subchannel_index_register(exec_ctx, key, c); } -static void continue_connect(grpc_exec_ctx *exec_ctx, grpc_subchannel *c) { +static void continue_connect_locked(grpc_exec_ctx *exec_ctx, + grpc_subchannel *c) { grpc_connect_in_args args; args.interested_parties = c->pollset_set; @@ -417,7 +418,7 @@ static void on_external_state_watcher_done(grpc_exec_ctx *exec_ctx, void *arg, static void on_alarm(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) { grpc_subchannel *c = arg; gpr_mu_lock(&c->mu); - c->have_alarm = 0; + c->have_alarm = false; if (c->disconnected) { error = GRPC_ERROR_CREATE_REFERENCING("Disconnected", &error, 1); } else { @@ -427,7 +428,7 @@ static void on_alarm(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) { gpr_log(GPR_INFO, "Failed to connect to channel, retrying"); c->next_attempt = gpr_backoff_step(&c->backoff_state, gpr_now(GPR_CLOCK_MONOTONIC)); - continue_connect(exec_ctx, c); + continue_connect_locked(exec_ctx, c); gpr_mu_unlock(&c->mu); } else { gpr_mu_unlock(&c->mu); @@ -465,10 +466,10 @@ static void maybe_start_connecting_locked(grpc_exec_ctx *exec_ctx, if (!c->backoff_begun) { c->backoff_begun = true; c->next_attempt = gpr_backoff_begin(&c->backoff_state, now); - continue_connect(exec_ctx, c); + continue_connect_locked(exec_ctx, c); } else { GPR_ASSERT(!c->have_alarm); - c->have_alarm = 1; + c->have_alarm = true; gpr_timespec time_til_next = gpr_time_sub(c->next_attempt, now); if (gpr_time_cmp(time_til_next, gpr_time_0(time_til_next.clock_type)) <= 0) {