--------------------------------------------------------------------------------
/examples/Aggregator/Client/Client.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net10.0
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/test/Shared/Logging/LogLevelAttribute.cs:
--------------------------------------------------------------------------------
1 | // Licensed to the .NET Foundation under one or more agreements.
2 | // The .NET Foundation licenses this file to you under the MIT license.
3 |
4 | #nullable disable
5 |
6 | using System;
7 |
8 | // Copied with permission from https://github.com/dotnet/aspnetcore/tree/08b60af1bca8cffff8ba0a72164fb7505ffe114d/src/Testing/src/Logging
9 | namespace Microsoft.Extensions.Logging.Testing;
10 |
11 | [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class | AttributeTargets.Assembly, AllowMultiple = false)]
12 | public class LogLevelAttribute : Attribute
13 | {
14 | public LogLevelAttribute(LogLevel logLevel)
15 | {
16 | LogLevel = logLevel;
17 | }
18 |
19 | public LogLevel LogLevel { get; }
20 | }
21 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/ask_question.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Ask a question
3 | about: Ask a question related to this project
4 | labels: question
5 |
6 | ---
7 |
8 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/examples/Definer/Definer.slnx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/examples/Progressor/Server/Monarchs-of-England.txt:
--------------------------------------------------------------------------------
1 | Offa
Egbert
Aethelwulf
Aethelbald
Aethelbert
Aethelred I
Alfred the Great
Edward the Elder
Athelstan
Edmund
Edred
Edwy
Edgar
Edward the Martyr
Ethelred II the Unready
Edmund lronside
Cnut (Canute)
Harold I Harefoot
Harthacanut
Edward the Confessor
Harold II
William I
William II
Henry I
Stephen
Henry II
Richard I
John
Henry III
Edward I
Edward II
Edward III
Richard II
Henry IV
Henry V
Henry VI
Edward IV
Edward V
Richard III
Henry VII
Henry VIII
Edward VI
Mary I
Elizabeth I
James I
Charles I
Commonwealth
Oliver Cromwell
Richard Cromwell
Charles II
James II
William III of Orange and Mary II (jointly)
William III (alone)
Anne
George I
George II
George III
George IV
William IV
Victoria
Edward VII
George V
Edward VIII
George VI
Elizabeth II
2 |
--------------------------------------------------------------------------------
/testassets/InteropTestsNativeServer/InteropTestsNativeServer.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net10.0
6 |
7 |
8 |
9 |
10 |
11 |
12 | PreserveNewest
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/examples/Container/Frontend/Frontend.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net10.0
5 |
6 |
7 | $(NoWarn);CS0618
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/examples/Tester/Tests/Tests.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net10.0
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/examples/Blazor/Server/Server.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net10.0
5 | 46982f83-f153-443e-b589-4b2bc7b5945e
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/test/Shared/Logging/TestLoggerProvider.cs:
--------------------------------------------------------------------------------
1 | // Licensed to the .NET Foundation under one or more agreements.
2 | // The .NET Foundation licenses this file to you under the MIT license.
3 |
4 | #nullable disable
5 |
6 | // Copied with permission from https://github.com/dotnet/aspnetcore/tree/08b60af1bca8cffff8ba0a72164fb7505ffe114d/src/Testing/src/Logging
7 | namespace Microsoft.Extensions.Logging.Testing;
8 |
9 | public class TestLoggerProvider : ILoggerProvider
10 | {
11 | private readonly ITestSink _sink;
12 |
13 | public TestLoggerProvider(ITestSink sink)
14 | {
15 | _sink = sink;
16 | }
17 |
18 | public ILogger CreateLogger(string categoryName)
19 | {
20 | return new TestLogger(categoryName, _sink, enabled: true);
21 | }
22 |
23 | public void Dispose()
24 | {
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/examples/Liber/Proto/common.proto:
--------------------------------------------------------------------------------
1 | // Copyright 2019 The gRPC Authors
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | syntax = "proto3";
16 |
17 | package common;
18 |
19 | message Name {
20 | string firstName = 1;
21 | string middleName = 2;
22 | string lastName = 3;
23 | }
24 |
--------------------------------------------------------------------------------
/examples/Browser/Server/wwwroot/Scripts/README.md:
--------------------------------------------------------------------------------
1 | # gRPC-Web generated client
2 |
3 | gRPC-Web JavaScript clients and messages are generated using `protoc` the gRPC-Web code generator plugin. Instructions for using it are available [here](https://github.com/grpc/grpc-web#code-generator-plugin).
4 |
5 | Files in this directory are generated from *greet.proto*:
6 |
7 | * *greet_grpc_web_pb.js* contains the gRPC-Web client.
8 | * *greet_pb.js* contains gRPC messages.
9 |
10 | Example of using `protoc` from PowerShell (`protoc` and `protoc-gen-grpc-web` should be on your computer and discoverable from your PATH):
11 |
12 | > protoc greet.proto --js_out=import_style=commonjs:CHANGE_TO_SCRIPTS_DIRECTORY --grpc-web_out=import_style=commonjs,mode=grpcwebtext:CHANGE_TO_SCRIPTS_DIRECTORY --plugin=protoc-gen-grpc-web=CHANGE_TO_PROTOC_GEN_GRPC_WEB_EXE_PATH
13 |
--------------------------------------------------------------------------------
/perf/Grpc.AspNetCore.Microbenchmarks/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | #region Copyright notice and license
2 |
3 | // Copyright 2019 The gRPC Authors
4 | //
5 | // Licensed under the Apache License, Version 2.0 (the "License");
6 | // you may not use this file except in compliance with the License.
7 | // You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing, software
12 | // distributed under the License is distributed on an "AS IS" BASIS,
13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | // See the License for the specific language governing permissions and
15 | // limitations under the License.
16 |
17 | #endregion
18 |
19 | using Grpc.AspNetCore.Microbenchmarks;
20 |
21 | [assembly: DefaultCoreConfigAttribute]
--------------------------------------------------------------------------------
/startvs.cmd:
--------------------------------------------------------------------------------
1 | @ECHO OFF
2 |
3 | :: This command launches a Visual Studio solution with environment variables required to use a local version of the .NET Core SDK.
4 |
5 | :: This tells .NET Core to use the same dotnet.exe that build scripts use
6 | SET DOTNET_ROOT=%~dp0.dotnet
7 |
8 | :: This tells .NET Core not to go looking for .NET Core in other places
9 | SET DOTNET_MULTILEVEL_LOOKUP=0
10 |
11 | :: Put our local dotnet.exe on PATH first so Visual Studio knows which one to use
12 | SET PATH=%DOTNET_ROOT%;%PATH%
13 |
14 | SET sln=%1
15 |
16 | IF "%sln%"=="" (
17 | SET sln=Grpc.DotNet.slnx
18 | )
19 |
20 | IF NOT EXIST "%DOTNET_ROOT%\dotnet.exe" (
21 | echo .NET Core has not yet been installed. Run `%~dp0build\get-dotnet.ps1` to install tools and activate the environment with `. %~dp0activate.ps1`
22 | exit /b 1
23 | )
24 |
25 | start %sln%
26 |
--------------------------------------------------------------------------------
/perf/benchmarkapps/GrpcClient/GrpcClientType.cs:
--------------------------------------------------------------------------------
1 | #region Copyright notice and license
2 |
3 | // Copyright 2019 The gRPC Authors
4 | //
5 | // Licensed under the Apache License, Version 2.0 (the "License");
6 | // you may not use this file except in compliance with the License.
7 | // You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing, software
12 | // distributed under the License is distributed on an "AS IS" BASIS,
13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | // See the License for the specific language governing permissions and
15 | // limitations under the License.
16 |
17 | #endregion
18 |
19 | namespace GrpcClient;
20 |
21 | public enum GrpcClientType
22 | {
23 | GrpcCore,
24 | GrpcNetClient
25 | }
--------------------------------------------------------------------------------
/src/Grpc.Net.Client/Internal/IDebugger.cs:
--------------------------------------------------------------------------------
1 | #region Copyright notice and license
2 |
3 | // Copyright 2019 The gRPC Authors
4 | //
5 | // Licensed under the Apache License, Version 2.0 (the "License");
6 | // you may not use this file except in compliance with the License.
7 | // You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing, software
12 | // distributed under the License is distributed on an "AS IS" BASIS,
13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | // See the License for the specific language governing permissions and
15 | // limitations under the License.
16 |
17 | #endregion
18 |
19 | namespace Grpc.Net.Client.Internal;
20 |
21 | internal interface IDebugger
22 | {
23 | bool IsAttached { get; }
24 | }
25 |
--------------------------------------------------------------------------------
/testassets/FunctionalTestsWebsite/Infrastructure/DynamicService.cs:
--------------------------------------------------------------------------------
1 | #region Copyright notice and license
2 |
3 | // Copyright 2019 The gRPC Authors
4 | //
5 | // Licensed under the Apache License, Version 2.0 (the "License");
6 | // you may not use this file except in compliance with the License.
7 | // You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing, software
12 | // distributed under the License is distributed on an "AS IS" BASIS,
13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | // See the License for the specific language governing permissions and
15 | // limitations under the License.
16 |
17 | #endregion
18 |
19 | namespace FunctionalTestsWebsite.Infrastructure;
20 |
21 | public class DynamicService
22 | {
23 | }
24 |
--------------------------------------------------------------------------------
/src/Grpc.AspNetCore.Server/ServerServiceDefinitionMarker.cs:
--------------------------------------------------------------------------------
1 | #region Copyright notice and license
2 |
3 | // Copyright 2019 The gRPC Authors
4 | //
5 | // Licensed under the Apache License, Version 2.0 (the "License");
6 | // you may not use this file except in compliance with the License.
7 | // You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing, software
12 | // distributed under the License is distributed on an "AS IS" BASIS,
13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | // See the License for the specific language governing permissions and
15 | // limitations under the License.
16 |
17 | #endregion
18 |
19 | namespace Grpc.AspNetCore.Server;
20 |
21 | internal sealed class ServerServiceDefinitionMarker
22 | {
23 | }
24 |
--------------------------------------------------------------------------------
/src/Grpc.Net.Client/Internal/ISystemClock.cs:
--------------------------------------------------------------------------------
1 | #region Copyright notice and license
2 |
3 | // Copyright 2019 The gRPC Authors
4 | //
5 | // Licensed under the Apache License, Version 2.0 (the "License");
6 | // you may not use this file except in compliance with the License.
7 | // You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing, software
12 | // distributed under the License is distributed on an "AS IS" BASIS,
13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | // See the License for the specific language governing permissions and
15 | // limitations under the License.
16 |
17 | #endregion
18 |
19 | namespace Grpc.Net.Client.Internal;
20 |
21 | internal interface ISystemClock
22 | {
23 | DateTime UtcNow { get; }
24 | }
25 |
--------------------------------------------------------------------------------
/testassets/Proto/race.proto:
--------------------------------------------------------------------------------
1 | // Copyright 2019 The gRPC Authors
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | syntax = "proto3";
16 |
17 | package Race;
18 |
19 | service Racer {
20 | rpc ReadySetGo (stream RaceMessage) returns (stream RaceMessage);
21 | }
22 |
23 | message RaceMessage {
24 | int32 count = 1;
25 | }
26 |
--------------------------------------------------------------------------------
/examples/Racer/Proto/race.proto:
--------------------------------------------------------------------------------
1 | // Copyright 2019 The gRPC Authors
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | syntax = "proto3";
16 |
17 | package race;
18 |
19 | service Racer {
20 | rpc ReadySetGo (stream RaceMessage) returns (stream RaceMessage);
21 | }
22 |
23 | message RaceMessage {
24 | int32 count = 1;
25 | }
26 |
--------------------------------------------------------------------------------
/examples/Tester/Server/Services/IGreeter.cs:
--------------------------------------------------------------------------------
1 | #region Copyright notice and license
2 |
3 | // Copyright 2019 The gRPC Authors
4 | //
5 | // Licensed under the Apache License, Version 2.0 (the "License");
6 | // you may not use this file except in compliance with the License.
7 | // You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing, software
12 | // distributed under the License is distributed on an "AS IS" BASIS,
13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | // See the License for the specific language governing permissions and
15 | // limitations under the License.
16 |
17 | #endregion
18 |
19 |
20 | namespace Server
21 | {
22 | public interface IGreeter
23 | {
24 | string Greet(string name);
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/test/Grpc.AspNetCore.Server.Tests/TestObjects/CustomMetadata.cs:
--------------------------------------------------------------------------------
1 | #region Copyright notice and license
2 |
3 | // Copyright 2019 The gRPC Authors
4 | //
5 | // Licensed under the Apache License, Version 2.0 (the "License");
6 | // you may not use this file except in compliance with the License.
7 | // You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing, software
12 | // distributed under the License is distributed on an "AS IS" BASIS,
13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | // See the License for the specific language governing permissions and
15 | // limitations under the License.
16 |
17 | #endregion
18 |
19 |
20 | namespace Grpc.AspNetCore.Server.Tests.TestObjects;
21 |
22 | public class CustomMetadata
23 | {
24 | }
25 |
--------------------------------------------------------------------------------
/src/dotnet-grpc/Options/Access.cs:
--------------------------------------------------------------------------------
1 | #region Copyright notice and license
2 |
3 | // Copyright 2019 The gRPC Authors
4 | //
5 | // Licensed under the Apache License, Version 2.0 (the "License");
6 | // you may not use this file except in compliance with the License.
7 | // You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing, software
12 | // distributed under the License is distributed on an "AS IS" BASIS,
13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | // See the License for the specific language governing permissions and
15 | // limitations under the License.
16 |
17 | #endregion
18 |
19 | namespace Grpc.Dotnet.Cli.Options;
20 |
21 | internal enum Access
22 | {
23 | // Default is Public
24 | Public = 0,
25 | Internal
26 | }
27 |
--------------------------------------------------------------------------------
/examples/Tester/Client/IGreetRepository.cs:
--------------------------------------------------------------------------------
1 | #region Copyright notice and license
2 |
3 | // Copyright 2019 The gRPC Authors
4 | //
5 | // Licensed under the Apache License, Version 2.0 (the "License");
6 | // you may not use this file except in compliance with the License.
7 | // You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing, software
12 | // distributed under the License is distributed on an "AS IS" BASIS,
13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | // See the License for the specific language governing permissions and
15 | // limitations under the License.
16 |
17 | #endregion
18 |
19 | namespace Client
20 | {
21 | public interface IGreetRepository
22 | {
23 | void SaveGreeting(string message);
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/Grpc.AspNetCore.Server/Internal/ISystemClock.cs:
--------------------------------------------------------------------------------
1 | #region Copyright notice and license
2 |
3 | // Copyright 2019 The gRPC Authors
4 | //
5 | // Licensed under the Apache License, Version 2.0 (the "License");
6 | // you may not use this file except in compliance with the License.
7 | // You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing, software
12 | // distributed under the License is distributed on an "AS IS" BASIS,
13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | // See the License for the specific language governing permissions and
15 | // limitations under the License.
16 |
17 | #endregion
18 |
19 |
20 | namespace Grpc.AspNetCore.Server.Internal;
21 |
22 | internal interface ISystemClock
23 | {
24 | DateTime UtcNow { get; }
25 | }
26 |
--------------------------------------------------------------------------------
/src/Grpc.Net.Client/Internal/Configuration/IConfigValue.cs:
--------------------------------------------------------------------------------
1 | #region Copyright notice and license
2 |
3 | // Copyright 2019 The gRPC Authors
4 | //
5 | // Licensed under the Apache License, Version 2.0 (the "License");
6 | // you may not use this file except in compliance with the License.
7 | // You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing, software
12 | // distributed under the License is distributed on an "AS IS" BASIS,
13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | // See the License for the specific language governing permissions and
15 | // limitations under the License.
16 |
17 | #endregion
18 |
19 | namespace Grpc.Net.Client.Internal.Configuration;
20 |
21 | internal interface IConfigValue
22 | {
23 | object Inner { get; }
24 | }
25 |
--------------------------------------------------------------------------------
/test/Grpc.AspNetCore.Server.Tests/Proto/race.proto:
--------------------------------------------------------------------------------
1 | // Copyright 2019 The gRPC Authors
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | syntax = "proto3";
16 |
17 | package race;
18 |
19 | service Racer {
20 | rpc ReadySetGo (stream RaceMessage) returns (stream RaceMessage);
21 | }
22 |
23 | message RaceMessage {
24 | int32 count = 1;
25 | }
26 |
--------------------------------------------------------------------------------
/examples/Browser/Server/Server.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net10.0
5 | wwwroot\
6 | $(DefaultItemExcludes);$(SpaRoot)node_modules\**;$(SpaRoot)dist\**
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/test/Grpc.AspNetCore.Server.Tests/TestObjects/Services/RaceServiceImpl.cs:
--------------------------------------------------------------------------------
1 | #region Copyright notice and license
2 |
3 | // Copyright 2019 The gRPC Authors
4 | //
5 | // Licensed under the Apache License, Version 2.0 (the "License");
6 | // you may not use this file except in compliance with the License.
7 | // You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing, software
12 | // distributed under the License is distributed on an "AS IS" BASIS,
13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | // See the License for the specific language governing permissions and
15 | // limitations under the License.
16 |
17 | #endregion
18 |
19 | namespace Grpc.AspNetCore.Server.Tests.TestObjects;
20 |
21 | public class RaceServiceImpl : Race.Racer.RacerBase
22 | {
23 | }
24 |
--------------------------------------------------------------------------------
/src/Shared/IsExternalInit.cs:
--------------------------------------------------------------------------------
1 | #region Copyright notice and license
2 |
3 | // Copyright 2019 The gRPC Authors
4 | //
5 | // Licensed under the Apache License, Version 2.0 (the "License");
6 | // you may not use this file except in compliance with the License.
7 | // You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing, software
12 | // distributed under the License is distributed on an "AS IS" BASIS,
13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | // See the License for the specific language governing permissions and
15 | // limitations under the License.
16 |
17 | #endregion
18 |
19 | namespace System.Runtime.CompilerServices;
20 |
21 | #if NETCOREAPP3_0 || NETSTANDARD2_0_OR_GREATER || NET462
22 | internal static class IsExternalInit
23 | {
24 | }
25 | #endif
26 |
--------------------------------------------------------------------------------
/testassets/InteropTestsWebsite/README.md:
--------------------------------------------------------------------------------
1 | Running Grpc.Core interop client against Grpc.AspNetCore.Server interop server.
2 | Context: https://github.com/grpc/grpc/blob/master/doc/interop-test-descriptions.md
3 |
4 | ## Start the InteropTestsWebsite
5 |
6 | ```
7 | # From this directory
8 | $ dotnet run
9 | Now listening on: http://localhost:50052
10 | ```
11 |
12 | ## Build gRPC C# as a developer:
13 | Follow https://github.com/grpc/grpc/tree/master/src/csharp
14 | ```
15 | python tools/run_tests/run_tests.py -l csharp -c dbg --build_only
16 | ```
17 |
18 | ## Running the interop client
19 |
20 | ```
21 | cd src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/net45
22 |
23 | mono Grpc.IntegrationTesting.Client.exe --server_host=localhost --server_port=50052 --test_case=large_unary
24 | ```
25 |
26 | NOTE: Currently the some tests will fail because not all the features are implemented
27 | by Grpc.AspNetCore.Server
28 |
--------------------------------------------------------------------------------
/perf/benchmarkapps/GrpcAspNetCoreServer/RunGrpcServer.ps1:
--------------------------------------------------------------------------------
1 | Param
2 | (
3 | [string]$protocol = "h2c",
4 | [string]$log_level = "None",
5 | [bool]$enable_cert_auth = $false,
6 | [bool]$publish_aot = $false
7 | )
8 |
9 | # Command line example:
10 | # .\RunGrpcServer.ps1 -publish_aot $true
11 |
12 | Write-Host "Protocol: $protocol" -ForegroundColor Cyan
13 | Write-Host "Log level: $log_level" -ForegroundColor Cyan
14 | Write-Host "Enable cert auth: $enable_cert_auth" -ForegroundColor Cyan
15 | Write-Host "Publish AOT: $publish_aot" -ForegroundColor Cyan
16 | Write-Host
17 |
18 | dotnet publish -r win-x64 -c Release --self-contained --output bin\Publish -p:PublishAot=$publish_aot
19 | if ($LASTEXITCODE -ne 0)
20 | {
21 | exit;
22 | }
23 |
24 | .\bin\Publish\GrpcAspNetCoreServer.exe --protocol $protocol --logLevel $log_level --enableCertAuth $enable_cert_auth
25 | Write-Host
26 |
27 | Write-Host "Done" -ForegroundColor Cyan
--------------------------------------------------------------------------------
/examples/Blazor/Client/Client.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net10.0
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/examples/Retrier/Proto/retry.proto:
--------------------------------------------------------------------------------
1 | // Copyright 2019 The gRPC Authors
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | syntax = "proto3";
16 |
17 | package retry;
18 |
19 | service Retrier {
20 | rpc DeliverPackage (Package) returns (Response);
21 | }
22 |
23 | message Package {
24 | string name = 1;
25 | }
26 |
27 | message Response {
28 | string message = 1;
29 | }
30 |
--------------------------------------------------------------------------------
/src/dotnet-grpc/Internal/CLIToolException.cs:
--------------------------------------------------------------------------------
1 | #region Copyright notice and license
2 |
3 | // Copyright 2019 The gRPC Authors
4 | //
5 | // Licensed under the Apache License, Version 2.0 (the "License");
6 | // you may not use this file except in compliance with the License.
7 | // You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing, software
12 | // distributed under the License is distributed on an "AS IS" BASIS,
13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | // See the License for the specific language governing permissions and
15 | // limitations under the License.
16 |
17 | #endregion
18 |
19 |
20 | namespace Grpc.Dotnet.Cli.Internal;
21 |
22 | internal sealed class CLIToolException : Exception
23 | {
24 | public CLIToolException(string message) : base(message) { }
25 | }
26 |
--------------------------------------------------------------------------------
/src/dotnet-grpc/Options/Services.cs:
--------------------------------------------------------------------------------
1 | #region Copyright notice and license
2 |
3 | // Copyright 2019 The gRPC Authors
4 | //
5 | // Licensed under the Apache License, Version 2.0 (the "License");
6 | // you may not use this file except in compliance with the License.
7 | // You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing, software
12 | // distributed under the License is distributed on an "AS IS" BASIS,
13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | // See the License for the specific language governing permissions and
15 | // limitations under the License.
16 |
17 | #endregion
18 |
19 | namespace Grpc.Dotnet.Cli.Options;
20 |
21 | internal enum Services
22 | {
23 | // Default is Both
24 | Default = 0,
25 | Both,
26 | Server,
27 | Client,
28 | None
29 | }
30 |
--------------------------------------------------------------------------------
/testassets/InteropTestsNativeServer/Program.cs:
--------------------------------------------------------------------------------
1 | #region Copyright notice and license
2 |
3 | // Copyright 2019 The gRPC Authors
4 | //
5 | // Licensed under the Apache License, Version 2.0 (the "License");
6 | // you may not use this file except in compliance with the License.
7 | // You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing, software
12 | // distributed under the License is distributed on an "AS IS" BASIS,
13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | // See the License for the specific language governing permissions and
15 | // limitations under the License.
16 |
17 | #endregion
18 |
19 | namespace InteropTestsNativeWebsite;
20 |
21 | public class Program
22 | {
23 | public static void Main(string[] args)
24 | {
25 | InteropServer.Run(args);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/testassets/Proto/nested.proto:
--------------------------------------------------------------------------------
1 | // Copyright 2019 The gRPC Authors
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | syntax = "proto3";
16 |
17 | package nested;
18 |
19 | service NestedService {
20 | rpc SayHello (HelloRequest) returns (HelloReply);
21 | }
22 |
23 | message HelloRequest {
24 | string name = 1;
25 | }
26 |
27 | message HelloReply {
28 | string message = 1;
29 | }
30 |
--------------------------------------------------------------------------------
/examples/Error/Server/Program.cs:
--------------------------------------------------------------------------------
1 | #region Copyright notice and license
2 |
3 | // Copyright 2019 The gRPC Authors
4 | //
5 | // Licensed under the Apache License, Version 2.0 (the "License");
6 | // you may not use this file except in compliance with the License.
7 | // You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing, software
12 | // distributed under the License is distributed on an "AS IS" BASIS,
13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | // See the License for the specific language governing permissions and
15 | // limitations under the License.
16 |
17 | #endregion
18 |
19 | using Server;
20 |
21 | var builder = WebApplication.CreateBuilder(args);
22 | builder.Services.AddGrpc();
23 |
24 | var app = builder.Build();
25 | app.MapGrpcService();
26 |
27 | app.Run();
28 |
--------------------------------------------------------------------------------
/examples/Liber/Server/Program.cs:
--------------------------------------------------------------------------------
1 | #region Copyright notice and license
2 |
3 | // Copyright 2019 The gRPC Authors
4 | //
5 | // Licensed under the Apache License, Version 2.0 (the "License");
6 | // you may not use this file except in compliance with the License.
7 | // You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing, software
12 | // distributed under the License is distributed on an "AS IS" BASIS,
13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | // See the License for the specific language governing permissions and
15 | // limitations under the License.
16 |
17 | #endregion
18 |
19 | using Server;
20 |
21 | var builder = WebApplication.CreateBuilder(args);
22 | builder.Services.AddGrpc();
23 |
24 | var app = builder.Build();
25 | app.MapGrpcService();
26 |
27 | app.Run();
28 |
--------------------------------------------------------------------------------
/examples/Racer/Server/Program.cs:
--------------------------------------------------------------------------------
1 | #region Copyright notice and license
2 |
3 | // Copyright 2019 The gRPC Authors
4 | //
5 | // Licensed under the Apache License, Version 2.0 (the "License");
6 | // you may not use this file except in compliance with the License.
7 | // You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing, software
12 | // distributed under the License is distributed on an "AS IS" BASIS,
13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | // See the License for the specific language governing permissions and
15 | // limitations under the License.
16 |
17 | #endregion
18 |
19 | using Server;
20 |
21 | var builder = WebApplication.CreateBuilder(args);
22 | builder.Services.AddGrpc();
23 |
24 | var app = builder.Build();
25 | app.MapGrpcService();
26 |
27 | app.Run();
28 |
--------------------------------------------------------------------------------
/examples/Greeter/Server/Program.cs:
--------------------------------------------------------------------------------
1 | #region Copyright notice and license
2 |
3 | // Copyright 2019 The gRPC Authors
4 | //
5 | // Licensed under the Apache License, Version 2.0 (the "License");
6 | // you may not use this file except in compliance with the License.
7 | // You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing, software
12 | // distributed under the License is distributed on an "AS IS" BASIS,
13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | // See the License for the specific language governing permissions and
15 | // limitations under the License.
16 |
17 | #endregion
18 |
19 | using Server;
20 |
21 | var builder = WebApplication.CreateBuilder(args);
22 | builder.Services.AddGrpc();
23 |
24 | var app = builder.Build();
25 | app.MapGrpcService();
26 |
27 | app.Run();
28 |
--------------------------------------------------------------------------------
/examples/Retrier/Server/Program.cs:
--------------------------------------------------------------------------------
1 | #region Copyright notice and license
2 |
3 | // Copyright 2019 The gRPC Authors
4 | //
5 | // Licensed under the Apache License, Version 2.0 (the "License");
6 | // you may not use this file except in compliance with the License.
7 | // You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing, software
12 | // distributed under the License is distributed on an "AS IS" BASIS,
13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | // See the License for the specific language governing permissions and
15 | // limitations under the License.
16 |
17 | #endregion
18 |
19 | using Server;
20 |
21 | var builder = WebApplication.CreateBuilder(args);
22 | builder.Services.AddGrpc();
23 |
24 | var app = builder.Build();
25 | app.MapGrpcService();
26 |
27 | app.Run();
28 |
--------------------------------------------------------------------------------
/examples/Uploader/Server/Program.cs:
--------------------------------------------------------------------------------
1 | #region Copyright notice and license
2 |
3 | // Copyright 2019 The gRPC Authors
4 | //
5 | // Licensed under the Apache License, Version 2.0 (the "License");
6 | // you may not use this file except in compliance with the License.
7 | // You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing, software
12 | // distributed under the License is distributed on an "AS IS" BASIS,
13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | // See the License for the specific language governing permissions and
15 | // limitations under the License.
16 |
17 | #endregion
18 |
19 | using Server;
20 |
21 | var builder = WebApplication.CreateBuilder(args);
22 | builder.Services.AddGrpc();
23 |
24 | var app = builder.Build();
25 | app.MapGrpcService();
26 |
27 | app.Run();
28 |
--------------------------------------------------------------------------------
/examples/Channeler/Server/Program.cs:
--------------------------------------------------------------------------------
1 | #region Copyright notice and license
2 |
3 | // Copyright 2019 The gRPC Authors
4 | //
5 | // Licensed under the Apache License, Version 2.0 (the "License");
6 | // you may not use this file except in compliance with the License.
7 | // You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing, software
12 | // distributed under the License is distributed on an "AS IS" BASIS,
13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | // See the License for the specific language governing permissions and
15 | // limitations under the License.
16 |
17 | #endregion
18 |
19 | using Server;
20 |
21 | var builder = WebApplication.CreateBuilder(args);
22 | builder.Services.AddGrpc();
23 |
24 | var app = builder.Build();
25 | app.MapGrpcService();
26 |
27 | app.Run();
28 |
--------------------------------------------------------------------------------
/examples/Downloader/Server/Program.cs:
--------------------------------------------------------------------------------
1 | #region Copyright notice and license
2 |
3 | // Copyright 2019 The gRPC Authors
4 | //
5 | // Licensed under the Apache License, Version 2.0 (the "License");
6 | // you may not use this file except in compliance with the License.
7 | // You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing, software
12 | // distributed under the License is distributed on an "AS IS" BASIS,
13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | // See the License for the specific language governing permissions and
15 | // limitations under the License.
16 |
17 | #endregion
18 |
19 | using Server;
20 |
21 | var builder = WebApplication.CreateBuilder(args);
22 | builder.Services.AddGrpc();
23 |
24 | var app = builder.Build();
25 | app.MapGrpcService();
26 |
27 | app.Run();
28 |
--------------------------------------------------------------------------------
/examples/Frameworker/Server/Program.cs:
--------------------------------------------------------------------------------
1 | #region Copyright notice and license
2 |
3 | // Copyright 2019 The gRPC Authors
4 | //
5 | // Licensed under the Apache License, Version 2.0 (the "License");
6 | // you may not use this file except in compliance with the License.
7 | // You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing, software
12 | // distributed under the License is distributed on an "AS IS" BASIS,
13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | // See the License for the specific language governing permissions and
15 | // limitations under the License.
16 |
17 | #endregion
18 |
19 | using Server;
20 |
21 | var builder = WebApplication.CreateBuilder(args);
22 | builder.Services.AddGrpc();
23 |
24 | var app = builder.Build();
25 | app.MapGrpcService();
26 |
27 | app.Run();
28 |
--------------------------------------------------------------------------------
/examples/Locator/Proto/external.proto:
--------------------------------------------------------------------------------
1 | // Copyright 2019 The gRPC Authors
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | syntax = "proto3";
16 |
17 | package greet;
18 |
19 | service External {
20 | rpc SayHello (ExternalRequest) returns (ExternalReply);
21 | }
22 |
23 | message ExternalRequest {
24 | string name = 1;
25 | }
26 |
27 | message ExternalReply {
28 | string message = 1;
29 | }
30 |
--------------------------------------------------------------------------------
/examples/Locator/Proto/internal.proto:
--------------------------------------------------------------------------------
1 | // Copyright 2019 The gRPC Authors
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | syntax = "proto3";
16 |
17 | package greet;
18 |
19 | service Internal {
20 | rpc SayHello (InternalRequest) returns (InternalReply);
21 | }
22 |
23 | message InternalRequest {
24 | string name = 1;
25 | }
26 |
27 | message InternalReply {
28 | string message = 1;
29 | }
30 |
--------------------------------------------------------------------------------
/examples/Progressor/Server/Program.cs:
--------------------------------------------------------------------------------
1 | #region Copyright notice and license
2 |
3 | // Copyright 2019 The gRPC Authors
4 | //
5 | // Licensed under the Apache License, Version 2.0 (the "License");
6 | // you may not use this file except in compliance with the License.
7 | // You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing, software
12 | // distributed under the License is distributed on an "AS IS" BASIS,
13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | // See the License for the specific language governing permissions and
15 | // limitations under the License.
16 |
17 | #endregion
18 |
19 | using Server;
20 |
21 | var builder = WebApplication.CreateBuilder(args);
22 | builder.Services.AddGrpc();
23 |
24 | var app = builder.Build();
25 | app.MapGrpcService();
26 |
27 | app.Run();
28 |
--------------------------------------------------------------------------------
/examples/Tester/Server/Program.cs:
--------------------------------------------------------------------------------
1 | #region Copyright notice and license
2 |
3 | // Copyright 2019 The gRPC Authors
4 | //
5 | // Licensed under the Apache License, Version 2.0 (the "License");
6 | // you may not use this file except in compliance with the License.
7 | // You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing, software
12 | // distributed under the License is distributed on an "AS IS" BASIS,
13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | // See the License for the specific language governing permissions and
15 | // limitations under the License.
16 |
17 | #endregion
18 |
19 | using Server;
20 |
21 | var host = Host.CreateDefaultBuilder(args)
22 | .ConfigureWebHostDefaults(webBuilder =>
23 | {
24 | webBuilder.UseStartup();
25 | }).Build();
26 |
27 | host.Run();
28 |
--------------------------------------------------------------------------------
/examples/Blazor/Proto/count.proto:
--------------------------------------------------------------------------------
1 | // Copyright 2019 The gRPC Authors
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | syntax = "proto3";
16 |
17 | package count;
18 |
19 | service Counter {
20 | rpc StartCounter (CounterRequest) returns (stream CounterResponse);
21 | }
22 |
23 | message CounterRequest {
24 | int32 start = 1;
25 | }
26 |
27 | message CounterResponse {
28 | int32 count = 1;
29 | }
30 |
--------------------------------------------------------------------------------
/docfx/README.md:
--------------------------------------------------------------------------------
1 | DocFX-generated C# API Reference
2 | --------------------------------
3 |
4 | ## Generating docs manually (on Windows)
5 |
6 | Install docfx based on instructions here: https://github.com/dotnet/docfx
7 |
8 | ```
9 | # generate docfx documentation into ./html directory
10 | $ docfx
11 |
12 | # view the resulting docs
13 | $ docfx server html
14 | ```
15 |
16 | ## Release process: script for regenerating the docs automatically
17 |
18 | After each gRPC C# release, the docs need to be regenerated
19 | and updated on the grpc.io site. The automated script will
20 | re-generate the docs (using dockerized docfx installation)
21 | and make everything ready for creating a PR to update the docs.
22 |
23 | ```
24 | # 1. Run the script on Linux with docker installed
25 | $ ./generate_reference_docs.sh
26 |
27 | # 2. Enter the git repo with updated "gh-pages" branch
28 | $ cd grpc-gh-pages
29 |
30 | # 3. Review the changes and create a pull request
31 | ```
32 |
--------------------------------------------------------------------------------
/test/Shared/Logging/TestLoggerFactory.cs:
--------------------------------------------------------------------------------
1 | // Licensed to the .NET Foundation under one or more agreements.
2 | // The .NET Foundation licenses this file to you under the MIT license.
3 |
4 | #nullable disable
5 |
6 | // Copied with permission from https://github.com/dotnet/aspnetcore/tree/08b60af1bca8cffff8ba0a72164fb7505ffe114d/src/Testing/src/Logging
7 | namespace Microsoft.Extensions.Logging.Testing;
8 |
9 | public class TestLoggerFactory : ILoggerFactory
10 | {
11 | private readonly ITestSink _sink;
12 | private readonly bool _enabled;
13 |
14 | public TestLoggerFactory(ITestSink sink, bool enabled)
15 | {
16 | _sink = sink;
17 | _enabled = enabled;
18 | }
19 |
20 | public ILogger CreateLogger(string name)
21 | {
22 | return new TestLogger(name, _sink, _enabled);
23 | }
24 |
25 | public void AddProvider(ILoggerProvider provider)
26 | {
27 | }
28 |
29 | public void Dispose()
30 | {
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/examples/Aggregator/Proto/aggregate.proto:
--------------------------------------------------------------------------------
1 | // Copyright 2019 The gRPC Authors
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | syntax = "proto3";
16 |
17 | import "count.proto";
18 | import "greet.proto";
19 |
20 | package aggregate;
21 |
22 | service Aggregator {
23 | rpc AccumulateCount (stream count.CounterRequest) returns (count.CounterReply);
24 | rpc SayHellos (greet.HelloRequest) returns (stream greet.HelloReply);
25 | }
--------------------------------------------------------------------------------
/examples/Aggregator/Server/Server.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net10.0
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/test/Grpc.AspNetCore.Server.Tests/TestObjects/Services/WithAttribute/GreeterWithAttributeService.cs:
--------------------------------------------------------------------------------
1 | #region Copyright notice and license
2 |
3 | // Copyright 2019 The gRPC Authors
4 | //
5 | // Licensed under the Apache License, Version 2.0 (the "License");
6 | // you may not use this file except in compliance with the License.
7 | // You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing, software
12 | // distributed under the License is distributed on an "AS IS" BASIS,
13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | // See the License for the specific language governing permissions and
15 | // limitations under the License.
16 |
17 | #endregion
18 |
19 | namespace Grpc.AspNetCore.Server.Tests.TestObjects.Services.WithAttribute;
20 |
21 | public class GreeterWithAttributeService : GreeterWithAttribute.GreeterBase
22 | {
23 | }
24 |
--------------------------------------------------------------------------------
/examples/Coder/Shared/HelloReply.cs:
--------------------------------------------------------------------------------
1 | #region Copyright notice and license
2 |
3 | // Copyright 2019 The gRPC Authors
4 | //
5 | // Licensed under the Apache License, Version 2.0 (the "License");
6 | // you may not use this file except in compliance with the License.
7 | // You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing, software
12 | // distributed under the License is distributed on an "AS IS" BASIS,
13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | // See the License for the specific language governing permissions and
15 | // limitations under the License.
16 |
17 | #endregion
18 |
19 | using System.Runtime.Serialization;
20 |
21 | namespace Shared
22 | {
23 | [DataContract]
24 | public class HelloReply
25 | {
26 | [DataMember(Order = 1)]
27 | public string? Message { get; set; }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/examples/Coder/Shared/HelloRequest.cs:
--------------------------------------------------------------------------------
1 | #region Copyright notice and license
2 |
3 | // Copyright 2019 The gRPC Authors
4 | //
5 | // Licensed under the Apache License, Version 2.0 (the "License");
6 | // you may not use this file except in compliance with the License.
7 | // You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing, software
12 | // distributed under the License is distributed on an "AS IS" BASIS,
13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | // See the License for the specific language governing permissions and
15 | // limitations under the License.
16 |
17 | #endregion
18 |
19 | using System.Runtime.Serialization;
20 |
21 | namespace Shared
22 | {
23 | [DataContract]
24 | public class HelloRequest
25 | {
26 | [DataMember(Order = 1)]
27 | public string? Name { get; set; }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/kokoro/interop.cfg:
--------------------------------------------------------------------------------
1 | # Copyright 2019 The gRPC Authors
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | # Config file for the internal CI (in protobuf text format)
16 |
17 | # Location of the continuous shell script in repository.
18 | build_file: "grpc-dotnet/kokoro/interop.sh"
19 | timeout_mins: 30
20 |
21 | action {
22 | define_artifacts {
23 | regex: "**/*sponge_log.*"
24 | regex: "github/grpc-dotnet/artifacts/**"
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/kokoro/linux.cfg:
--------------------------------------------------------------------------------
1 | # Copyright 2019 The gRPC Authors
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | # Config file for the internal CI (in protobuf text format)
16 |
17 | # Location of the continuous shell script in repository.
18 | build_file: "grpc-dotnet/kokoro/build_nuget.sh"
19 | timeout_mins: 30
20 |
21 | action {
22 | define_artifacts {
23 | regex: "**/*sponge_log.*"
24 | regex: "github/grpc-dotnet/artifacts/**"
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/Grpc.Net.ClientFactory/Internal/GrpcClientMappingRegistry.cs:
--------------------------------------------------------------------------------
1 | #region Copyright notice and license
2 |
3 | // Copyright 2019 The gRPC Authors
4 | //
5 | // Licensed under the Apache License, Version 2.0 (the "License");
6 | // you may not use this file except in compliance with the License.
7 | // You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing, software
12 | // distributed under the License is distributed on an "AS IS" BASIS,
13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | // See the License for the specific language governing permissions and
15 | // limitations under the License.
16 |
17 | #endregion
18 |
19 | namespace Grpc.Net.ClientFactory.Internal;
20 |
21 | internal class GrpcClientMappingRegistry
22 | {
23 | public Dictionary NamedClientRegistrations { get; } = new Dictionary();
24 | }
25 |
--------------------------------------------------------------------------------
/test/FunctionalTests/Infrastructure/TestConstants.cs:
--------------------------------------------------------------------------------
1 | #region Copyright notice and license
2 |
3 | // Copyright 2019 The gRPC Authors
4 | //
5 | // Licensed under the Apache License, Version 2.0 (the "License");
6 | // you may not use this file except in compliance with the License.
7 | // You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing, software
12 | // distributed under the License is distributed on an "AS IS" BASIS,
13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | // See the License for the specific language governing permissions and
15 | // limitations under the License.
16 |
17 | #endregion
18 |
19 | namespace Grpc.AspNetCore.FunctionalTests.Infrastructure;
20 |
21 | internal static class TestConstants
22 | {
23 | public const string ServerCallHandlerTestName = "SERVER Grpc.AspNetCore.Server.ServerCallHandler";
24 | }
25 |
--------------------------------------------------------------------------------
/src/Grpc.Net.Client/Internal/SystemClock.cs:
--------------------------------------------------------------------------------
1 | #region Copyright notice and license
2 |
3 | // Copyright 2019 The gRPC Authors
4 | //
5 | // Licensed under the Apache License, Version 2.0 (the "License");
6 | // you may not use this file except in compliance with the License.
7 | // You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing, software
12 | // distributed under the License is distributed on an "AS IS" BASIS,
13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | // See the License for the specific language governing permissions and
15 | // limitations under the License.
16 |
17 | #endregion
18 |
19 | namespace Grpc.Net.Client.Internal;
20 |
21 | internal sealed class SystemClock : ISystemClock
22 | {
23 | public static readonly SystemClock Instance = new SystemClock();
24 |
25 | public DateTime UtcNow => DateTime.UtcNow;
26 | }
27 |
--------------------------------------------------------------------------------
/test/Grpc.AspNetCore.Server.Tests/TestObjects/Services/WithAttribute/GreeterWithAttributeServiceSubClass.cs:
--------------------------------------------------------------------------------
1 | #region Copyright notice and license
2 |
3 | // Copyright 2019 The gRPC Authors
4 | //
5 | // Licensed under the Apache License, Version 2.0 (the "License");
6 | // you may not use this file except in compliance with the License.
7 | // You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing, software
12 | // distributed under the License is distributed on an "AS IS" BASIS,
13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | // See the License for the specific language governing permissions and
15 | // limitations under the License.
16 |
17 | #endregion
18 |
19 | namespace Grpc.AspNetCore.Server.Tests.TestObjects.Services.WithAttribute;
20 |
21 | public class GreeterWithAttributeServiceSubClass : GreeterWithAttributeService
22 | {
23 | }
24 |
--------------------------------------------------------------------------------
/kokoro/build_nuget.cfg:
--------------------------------------------------------------------------------
1 | # Copyright 2019 The gRPC Authors
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | # Config file for the internal CI (in protobuf text format)
16 |
17 | # Location of the continuous shell script in repository.
18 | build_file: "grpc-dotnet/kokoro/build_nuget.sh"
19 | timeout_mins: 30
20 |
21 | action {
22 | define_artifacts {
23 | regex: "**/*sponge_log.*"
24 | regex: "github/grpc-dotnet/artifacts/**"
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/test/Grpc.AspNetCore.Server.Tests/TestObjects/Services/WithoutAttribute/GreeterWithoutAttributeService.cs:
--------------------------------------------------------------------------------
1 | #region Copyright notice and license
2 |
3 | // Copyright 2019 The gRPC Authors
4 | //
5 | // Licensed under the Apache License, Version 2.0 (the "License");
6 | // you may not use this file except in compliance with the License.
7 | // You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing, software
12 | // distributed under the License is distributed on an "AS IS" BASIS,
13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | // See the License for the specific language governing permissions and
15 | // limitations under the License.
16 |
17 | #endregion
18 |
19 | namespace Grpc.AspNetCore.Server.Tests.TestObjects.Services.WithoutAttribute;
20 |
21 | public class GreeterWithoutAttributeService : GreeterWithoutAttribute.GreeterBase
22 | {
23 | }
24 |
--------------------------------------------------------------------------------
/testassets/Proto/chat.proto:
--------------------------------------------------------------------------------
1 | // Copyright 2019 The gRPC Authors
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | syntax = "proto3";
16 |
17 | package chat;
18 |
19 | // The greeting service definition.
20 | service Chatter {
21 | // Sends a greeting
22 | rpc Chat (stream ChatMessage) returns (stream ChatMessage);
23 | }
24 |
25 | // The chat message.
26 | message ChatMessage {
27 | string name = 1;
28 | string message = 2;
29 | }
30 |
--------------------------------------------------------------------------------
/test/Grpc.Net.Client.Tests/Infrastructure/Http2StreamException.cs:
--------------------------------------------------------------------------------
1 | #region Copyright notice and license
2 |
3 | // Copyright 2019 The gRPC Authors
4 | //
5 | // Licensed under the Apache License, Version 2.0 (the "License");
6 | // you may not use this file except in compliance with the License.
7 | // You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing, software
12 | // distributed under the License is distributed on an "AS IS" BASIS,
13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | // See the License for the specific language governing permissions and
15 | // limitations under the License.
16 |
17 | #endregion
18 |
19 | #if !NET7_0_OR_GREATER
20 | namespace System.Net.Http;
21 |
22 | public class Http2StreamException : Exception
23 | {
24 | public Http2StreamException(string message) : base(message)
25 | {
26 | }
27 | }
28 | #endif
29 |
--------------------------------------------------------------------------------
/TROUBLESHOOTING.md:
--------------------------------------------------------------------------------
1 | # Troubleshooting gRPC for .NET
2 |
3 | This guide is for troubleshooting gRPC for .NET (grpc-dotnet). For issues specific to Grpc.Core (C-core server and client), or code generation with Grpc.Tools, please refer to [TROUBLESHOOTING.md](https://github.com/grpc/grpc/blob/master/TROUBLESHOOTING.md) in `grpc/grpc` repository.
4 |
5 | ## Troubleshooting documentation
6 |
7 | For solutions for commonly encountered problems, see [gRPC troubleshooting](https://docs.microsoft.com/aspnet/core/grpc/troubleshoot).
8 |
9 | ## Answers on StackOverflow
10 |
11 | Your problem might have already been solved on StackOverflow. Search for questions with "grpc" tag: https://stackoverflow.com/questions/tagged/grpc
12 |
13 | ## Enabling extra logging and tracing
14 |
15 | Extra logging can be very useful for diagnosing problems. For documentation on configuring logging in gRPC services and clients, see
16 | [Logging and diagnostics in gRPC on .NET](https://docs.microsoft.com/aspnet/core/grpc/diagnostics).
17 |
--------------------------------------------------------------------------------
/examples/Certifier/Proto/certify.proto:
--------------------------------------------------------------------------------
1 | // Copyright 2019 The gRPC Authors
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | syntax = "proto3";
16 |
17 | import "google/protobuf/empty.proto";
18 |
19 | package certify;
20 |
21 | service Certifier {
22 | rpc GetCertificateInfo (google.protobuf.Empty) returns (CertificateInfoResponse);
23 | }
24 |
25 | message CertificateInfoResponse {
26 | bool hasCertificate = 1;
27 | string name = 2;
28 | }
29 |
--------------------------------------------------------------------------------
/examples/Mailer/Server/Program.cs:
--------------------------------------------------------------------------------
1 | #region Copyright notice and license
2 |
3 | // Copyright 2019 The gRPC Authors
4 | //
5 | // Licensed under the Apache License, Version 2.0 (the "License");
6 | // you may not use this file except in compliance with the License.
7 | // You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing, software
12 | // distributed under the License is distributed on an "AS IS" BASIS,
13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | // See the License for the specific language governing permissions and
15 | // limitations under the License.
16 |
17 | #endregion
18 |
19 | using Server;
20 |
21 | var builder = WebApplication.CreateBuilder(args);
22 | builder.Services.AddGrpc();
23 | builder.Services.AddSingleton();
24 |
25 | var app = builder.Build();
26 | app.MapGrpcService();
27 |
28 | app.Run();
29 |
--------------------------------------------------------------------------------
/examples/Worker/Server/Program.cs:
--------------------------------------------------------------------------------
1 | #region Copyright notice and license
2 |
3 | // Copyright 2019 The gRPC Authors
4 | //
5 | // Licensed under the Apache License, Version 2.0 (the "License");
6 | // you may not use this file except in compliance with the License.
7 | // You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing, software
12 | // distributed under the License is distributed on an "AS IS" BASIS,
13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | // See the License for the specific language governing permissions and
15 | // limitations under the License.
16 |
17 | #endregion
18 |
19 | using Server;
20 |
21 | var builder = WebApplication.CreateBuilder(args);
22 | builder.Services.AddGrpc();
23 | builder.Services.AddSingleton();
24 |
25 | var app = builder.Build();
26 | app.MapGrpcService();
27 |
28 | app.Run();
29 |
--------------------------------------------------------------------------------
/src/Grpc.AspNetCore.Server/Internal/SystemClock.cs:
--------------------------------------------------------------------------------
1 | #region Copyright notice and license
2 |
3 | // Copyright 2019 The gRPC Authors
4 | //
5 | // Licensed under the Apache License, Version 2.0 (the "License");
6 | // you may not use this file except in compliance with the License.
7 | // You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing, software
12 | // distributed under the License is distributed on an "AS IS" BASIS,
13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | // See the License for the specific language governing permissions and
15 | // limitations under the License.
16 |
17 | #endregion
18 |
19 | namespace Grpc.AspNetCore.Server.Internal;
20 |
21 | internal sealed class SystemClock : ISystemClock
22 | {
23 | public static readonly SystemClock Instance = new SystemClock();
24 |
25 | public DateTime UtcNow => DateTime.UtcNow;
26 | }
27 |
--------------------------------------------------------------------------------
/test/Grpc.AspNetCore.Server.Tests/TestObjects/Services/WithAttribute/GreeterWithAttributeServiceSubSubClass.cs:
--------------------------------------------------------------------------------
1 | #region Copyright notice and license
2 |
3 | // Copyright 2019 The gRPC Authors
4 | //
5 | // Licensed under the Apache License, Version 2.0 (the "License");
6 | // you may not use this file except in compliance with the License.
7 | // You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing, software
12 | // distributed under the License is distributed on an "AS IS" BASIS,
13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | // See the License for the specific language governing permissions and
15 | // limitations under the License.
16 |
17 | #endregion
18 |
19 | namespace Grpc.AspNetCore.Server.Tests.TestObjects.Services.WithAttribute;
20 |
21 | public class GreeterWithAttributeServiceSubSubClass : GreeterWithAttributeServiceSubClass
22 | {
23 | }
24 |
--------------------------------------------------------------------------------
/test/Grpc.AspNetCore.Server.Tests/TestObjects/Services/WithoutAttribute/GreeterWithoutAttributeServiceSubClass.cs:
--------------------------------------------------------------------------------
1 | #region Copyright notice and license
2 |
3 | // Copyright 2019 The gRPC Authors
4 | //
5 | // Licensed under the Apache License, Version 2.0 (the "License");
6 | // you may not use this file except in compliance with the License.
7 | // You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing, software
12 | // distributed under the License is distributed on an "AS IS" BASIS,
13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | // See the License for the specific language governing permissions and
15 | // limitations under the License.
16 |
17 | #endregion
18 |
19 | namespace Grpc.AspNetCore.Server.Tests.TestObjects.Services.WithoutAttribute;
20 |
21 | public class GreeterWithoutAttributeServiceSubClass : GreeterWithoutAttributeService
22 | {
23 | }
24 |
--------------------------------------------------------------------------------
/examples/Counter/Server/Program.cs:
--------------------------------------------------------------------------------
1 | #region Copyright notice and license
2 |
3 | // Copyright 2019 The gRPC Authors
4 | //
5 | // Licensed under the Apache License, Version 2.0 (the "License");
6 | // you may not use this file except in compliance with the License.
7 | // You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing, software
12 | // distributed under the License is distributed on an "AS IS" BASIS,
13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | // See the License for the specific language governing permissions and
15 | // limitations under the License.
16 |
17 | #endregion
18 |
19 | using Server;
20 |
21 | var builder = WebApplication.CreateBuilder(args);
22 | builder.Services.AddGrpc();
23 | builder.Services.AddSingleton();
24 |
25 | var app = builder.Build();
26 | app.MapGrpcService();
27 |
28 | app.Run();
29 |
--------------------------------------------------------------------------------
/test/FunctionalTests/Infrastructure/TestServerEndpointName.cs:
--------------------------------------------------------------------------------
1 | #region Copyright notice and license
2 |
3 | // Copyright 2019 The gRPC Authors
4 | //
5 | // Licensed under the Apache License, Version 2.0 (the "License");
6 | // you may not use this file except in compliance with the License.
7 | // You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing, software
12 | // distributed under the License is distributed on an "AS IS" BASIS,
13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | // See the License for the specific language governing permissions and
15 | // limitations under the License.
16 |
17 | #endregion
18 |
19 | namespace Grpc.AspNetCore.FunctionalTests.Infrastructure;
20 |
21 | public enum TestServerEndpointName
22 | {
23 | Http2,
24 | Http1,
25 | Http2WithTls,
26 | Http1WithTls,
27 | UnixDomainSocket,
28 | Http3WithTls,
29 | }
30 |
--------------------------------------------------------------------------------
/test/Shared/Logging/ITestSink.cs:
--------------------------------------------------------------------------------
1 | // Licensed to the .NET Foundation under one or more agreements.
2 | // The .NET Foundation licenses this file to you under the MIT license.
3 |
4 | #nullable disable
5 |
6 | using System;
7 | using System.Collections.Concurrent;
8 |
9 | // Copied with permission from https://github.com/dotnet/aspnetcore/tree/08b60af1bca8cffff8ba0a72164fb7505ffe114d/src/Testing/src/Logging
10 | namespace Microsoft.Extensions.Logging.Testing;
11 |
12 | public interface ITestSink
13 | {
14 | event Action MessageLogged;
15 |
16 | event Action ScopeStarted;
17 |
18 | Func WriteEnabled { get; set; }
19 |
20 | Func BeginEnabled { get; set; }
21 |
22 | IProducerConsumerCollection Scopes { get; set; }
23 |
24 | IProducerConsumerCollection Writes { get; set; }
25 |
26 | void Write(WriteContext context);
27 |
28 | void Begin(BeginScopeContext context);
29 | }
30 |
--------------------------------------------------------------------------------
/examples/Aggregator/Server/IncrementingCounter.cs:
--------------------------------------------------------------------------------
1 | #region Copyright notice and license
2 |
3 | // Copyright 2019 The gRPC Authors
4 | //
5 | // Licensed under the Apache License, Version 2.0 (the "License");
6 | // you may not use this file except in compliance with the License.
7 | // You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing, software
12 | // distributed under the License is distributed on an "AS IS" BASIS,
13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | // See the License for the specific language governing permissions and
15 | // limitations under the License.
16 |
17 | #endregion
18 |
19 | namespace Server
20 | {
21 | public class IncrementingCounter
22 | {
23 | public void Increment(int amount)
24 | {
25 | Count += amount;
26 | }
27 |
28 | public int Count { get; private set; }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/examples/Coder/Server/Program.cs:
--------------------------------------------------------------------------------
1 | #region Copyright notice and license
2 |
3 | // Copyright 2019 The gRPC Authors
4 | //
5 | // Licensed under the Apache License, Version 2.0 (the "License");
6 | // you may not use this file except in compliance with the License.
7 | // You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing, software
12 | // distributed under the License is distributed on an "AS IS" BASIS,
13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | // See the License for the specific language governing permissions and
15 | // limitations under the License.
16 |
17 | #endregion
18 |
19 | using ProtoBuf.Grpc.Server;
20 | using Server;
21 |
22 | var builder = WebApplication.CreateBuilder(args);
23 | builder.Services.AddGrpc();
24 | builder.Services.AddCodeFirstGrpc();
25 |
26 | var app = builder.Build();
27 | app.MapGrpcService();
28 |
29 | app.Run();
--------------------------------------------------------------------------------
/examples/Container/Backend/Program.cs:
--------------------------------------------------------------------------------
1 | #region Copyright notice and license
2 |
3 | // Copyright 2019 The gRPC Authors
4 | //
5 | // Licensed under the Apache License, Version 2.0 (the "License");
6 | // you may not use this file except in compliance with the License.
7 | // You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing, software
12 | // distributed under the License is distributed on an "AS IS" BASIS,
13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | // See the License for the specific language governing permissions and
15 | // limitations under the License.
16 |
17 | #endregion
18 |
19 | using Server.Services;
20 |
21 | var builder = WebApplication.CreateBuilder(args);
22 | builder.Logging.SetMinimumLevel(LogLevel.Trace);
23 | builder.Services.AddGrpc();
24 |
25 | var app = builder.Build();
26 | app.MapGrpcService();
27 |
28 | app.Run();
29 |
--------------------------------------------------------------------------------
/examples/Container/Frontend/Pages/Error.cshtml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Diagnostics;
4 | using System.Linq;
5 | using System.Threading.Tasks;
6 | using Microsoft.AspNetCore.Mvc;
7 | using Microsoft.AspNetCore.Mvc.RazorPages;
8 | using Microsoft.Extensions.Logging;
9 |
10 | namespace Frontend.Pages
11 | {
12 | [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
13 | [IgnoreAntiforgeryToken]
14 | public class ErrorModel : PageModel
15 | {
16 | public string? RequestId { get; set; }
17 |
18 | public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
19 |
20 | private readonly ILogger _logger;
21 |
22 | public ErrorModel(ILogger logger)
23 | {
24 | _logger = logger;
25 | }
26 |
27 | public void OnGet()
28 | {
29 | RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier;
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/examples/Counter/Server/IncrementingCounter.cs:
--------------------------------------------------------------------------------
1 | #region Copyright notice and license
2 |
3 | // Copyright 2019 The gRPC Authors
4 | //
5 | // Licensed under the Apache License, Version 2.0 (the "License");
6 | // you may not use this file except in compliance with the License.
7 | // You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing, software
12 | // distributed under the License is distributed on an "AS IS" BASIS,
13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | // See the License for the specific language governing permissions and
15 | // limitations under the License.
16 |
17 | #endregion
18 |
19 | namespace Server
20 | {
21 | public class IncrementingCounter
22 | {
23 | public void Increment(int amount)
24 | {
25 | Count += amount;
26 | }
27 |
28 | public int Count { get; private set; }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/examples/Worker/Server/IncrementingCounter.cs:
--------------------------------------------------------------------------------
1 | #region Copyright notice and license
2 |
3 | // Copyright 2019 The gRPC Authors
4 | //
5 | // Licensed under the Apache License, Version 2.0 (the "License");
6 | // you may not use this file except in compliance with the License.
7 | // You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing, software
12 | // distributed under the License is distributed on an "AS IS" BASIS,
13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | // See the License for the specific language governing permissions and
15 | // limitations under the License.
16 |
17 | #endregion
18 |
19 | namespace Server
20 | {
21 | public class IncrementingCounter
22 | {
23 | public void Increment(int amount)
24 | {
25 | Count += amount;
26 | }
27 |
28 | public int Count { get; private set; }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/Grpc.Auth/Grpc.Auth.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | gRPC C# Authentication Library
4 | gRPC RPC HTTP/2 Auth OAuth2
5 |
6 | true
7 | true
8 | net462;netstandard2.0
9 | README.md
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/test/Grpc.Net.Client.Tests/Infrastructure/QuicStreamAbortedException.cs:
--------------------------------------------------------------------------------
1 | #region Copyright notice and license
2 |
3 | // Copyright 2019 The gRPC Authors
4 | //
5 | // Licensed under the Apache License, Version 2.0 (the "License");
6 | // you may not use this file except in compliance with the License.
7 | // You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing, software
12 | // distributed under the License is distributed on an "AS IS" BASIS,
13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | // See the License for the specific language governing permissions and
15 | // limitations under the License.
16 |
17 | #endregion
18 |
19 | #if !NET7_0_OR_GREATER
20 | namespace System.Net.Quic;
21 |
22 | public class QuicStreamAbortedException : Exception
23 | {
24 | public QuicStreamAbortedException(string message) : base(message)
25 | {
26 | }
27 | }
28 | #endif
29 |
--------------------------------------------------------------------------------
/examples/Compressor/Server/Program.cs:
--------------------------------------------------------------------------------
1 | #region Copyright notice and license
2 |
3 | // Copyright 2019 The gRPC Authors
4 | //
5 | // Licensed under the Apache License, Version 2.0 (the "License");
6 | // you may not use this file except in compliance with the License.
7 | // You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing, software
12 | // distributed under the License is distributed on an "AS IS" BASIS,
13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | // See the License for the specific language governing permissions and
15 | // limitations under the License.
16 |
17 | #endregion
18 |
19 | using Server;
20 |
21 | var builder = WebApplication.CreateBuilder(args);
22 | builder.Services.AddGrpc(o =>
23 | {
24 | o.ResponseCompressionAlgorithm = "gzip";
25 | });
26 |
27 | var app = builder.Build();
28 | app.MapGrpcService();
29 |
30 | app.Run();
31 |
--------------------------------------------------------------------------------
/perf/Grpc.AspNetCore.Microbenchmarks/Proto/chat.proto:
--------------------------------------------------------------------------------
1 | // Copyright 2019 The gRPC Authors
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | syntax = "proto3";
16 |
17 | package chat;
18 |
19 | // The greeting service definition.
20 | service Chatter {
21 | // Sends a greeting
22 | rpc Chat (stream ChatMessage) returns (stream ChatMessage);
23 | }
24 |
25 | // The chat message.
26 | message ChatMessage {
27 | string name = 1;
28 | string message = 2;
29 | }
30 |
--------------------------------------------------------------------------------
/test/Grpc.AspNetCore.Server.Tests/TestObjects/Services/WithoutAttribute/GreeterWithoutAttributeServiceSubSubClass.cs:
--------------------------------------------------------------------------------
1 | #region Copyright notice and license
2 |
3 | // Copyright 2019 The gRPC Authors
4 | //
5 | // Licensed under the Apache License, Version 2.0 (the "License");
6 | // you may not use this file except in compliance with the License.
7 | // You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing, software
12 | // distributed under the License is distributed on an "AS IS" BASIS,
13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | // See the License for the specific language governing permissions and
15 | // limitations under the License.
16 |
17 | #endregion
18 |
19 | namespace Grpc.AspNetCore.Server.Tests.TestObjects.Services.WithoutAttribute;
20 |
21 | public class GreeterWithoutAttributeServiceSubSubClass : GreeterWithoutAttributeServiceSubClass
22 | {
23 | }
24 |
--------------------------------------------------------------------------------
/testassets/Proto/unimplemented.proto:
--------------------------------------------------------------------------------
1 | // Copyright 2019 The gRPC Authors
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | syntax = "proto3";
16 |
17 | package unimplemented;
18 |
19 | // No service is registered on the server so methods will return unimplemented
20 | service UnimplementedService {
21 | rpc DuplexData (stream UnimplementeDataMessage) returns (stream UnimplementeDataMessage);
22 | }
23 |
24 | message UnimplementeDataMessage {
25 | bytes data = 1;
26 | }
--------------------------------------------------------------------------------
/examples/Reflector/Server/Program.cs:
--------------------------------------------------------------------------------
1 | #region Copyright notice and license
2 |
3 | // Copyright 2019 The gRPC Authors
4 | //
5 | // Licensed under the Apache License, Version 2.0 (the "License");
6 | // you may not use this file except in compliance with the License.
7 | // You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing, software
12 | // distributed under the License is distributed on an "AS IS" BASIS,
13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | // See the License for the specific language governing permissions and
15 | // limitations under the License.
16 |
17 | #endregion
18 |
19 | using Server;
20 |
21 | var builder = WebApplication.CreateBuilder(args);
22 | builder.Services.AddGrpc();
23 | builder.Services.AddGrpcReflection();
24 |
25 | var app = builder.Build();
26 | app.MapGrpcService();
27 | app.MapGrpcReflectionService();
28 |
29 | app.Run();
30 |
--------------------------------------------------------------------------------
/testassets/FunctionalTestsWebsite/Infrastructure/IncrementingCounter.cs:
--------------------------------------------------------------------------------
1 | #region Copyright notice and license
2 |
3 | // Copyright 2019 The gRPC Authors
4 | //
5 | // Licensed under the Apache License, Version 2.0 (the "License");
6 | // you may not use this file except in compliance with the License.
7 | // You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing, software
12 | // distributed under the License is distributed on an "AS IS" BASIS,
13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | // See the License for the specific language governing permissions and
15 | // limitations under the License.
16 |
17 | #endregion
18 |
19 | namespace FunctionalTestsWebsite.Infrastructure;
20 |
21 | public class IncrementingCounter
22 | {
23 | public void Increment(int amount)
24 | {
25 | Count += amount;
26 | }
27 |
28 | public int Count { get; private set; }
29 | }
30 |
--------------------------------------------------------------------------------
/testassets/Proto/authorize.proto:
--------------------------------------------------------------------------------
1 | // Copyright 2019 The gRPC Authors
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | syntax = "proto3";
16 |
17 | package authorize;
18 |
19 | // The greeting service definition.
20 | service AuthorizedGreeter {
21 | rpc SayHello (HelloRequest) returns (HelloReply);
22 | }
23 |
24 | message HelloRequest {
25 | string name = 1;
26 | }
27 |
28 | message HelloReply {
29 | string message = 1;
30 | map claims = 2;
31 | }
32 |
--------------------------------------------------------------------------------
/examples/Blazor/Server/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "iisSettings": {
3 | "windowsAuthentication": false,
4 | "anonymousAuthentication": true,
5 | "iisExpress": {
6 | "applicationUrl": "http://localhost:59193/",
7 | "sslPort": 44375
8 | }
9 | },
10 | "profiles": {
11 | "IIS Express": {
12 | "commandName": "IISExpress",
13 | "launchBrowser": true,
14 | "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
15 | "environmentVariables": {
16 | "ASPNETCORE_ENVIRONMENT": "Development"
17 | }
18 | },
19 | "Server": {
20 | "commandName": "Project",
21 | "launchBrowser": true,
22 | "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
23 | "environmentVariables": {
24 | "ASPNETCORE_ENVIRONMENT": "Development"
25 | },
26 | "applicationUrl": "https://localhost:5001;http://localhost:5000"
27 | }
28 | }
29 | }
--------------------------------------------------------------------------------
/src/Grpc.AspNetCore.Web/Internal/ServerGrpcWebMode.cs:
--------------------------------------------------------------------------------
1 | #region Copyright notice and license
2 |
3 | // Copyright 2019 The gRPC Authors
4 | //
5 | // Licensed under the Apache License, Version 2.0 (the "License");
6 | // you may not use this file except in compliance with the License.
7 | // You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing, software
12 | // distributed under the License is distributed on an "AS IS" BASIS,
13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | // See the License for the specific language governing permissions and
15 | // limitations under the License.
16 |
17 | #endregion
18 |
19 | namespace Grpc.AspNetCore.Web.Internal;
20 |
21 | internal readonly record struct ServerGrpcWebContext(ServerGrpcWebMode Request, ServerGrpcWebMode Response);
22 |
23 | internal enum ServerGrpcWebMode : byte
24 | {
25 | None,
26 | GrpcWeb,
27 | GrpcWebText
28 | }
29 |
--------------------------------------------------------------------------------