diff options
Diffstat (limited to 'src/csharp')
-rw-r--r-- | src/csharp/Grpc.Core/ChannelOptions.cs | 56 | ||||
-rw-r--r-- | src/csharp/doc/README.md | 19 | ||||
-rwxr-xr-x | src/csharp/doc/generate_reference_docs.sh | 38 | ||||
-rw-r--r-- | src/csharp/experimental/README.md | 4 |
4 files changed, 115 insertions, 2 deletions
diff --git a/src/csharp/Grpc.Core/ChannelOptions.cs b/src/csharp/Grpc.Core/ChannelOptions.cs index 6ad5d56cad..880f2bef5f 100644 --- a/src/csharp/Grpc.Core/ChannelOptions.cs +++ b/src/csharp/Grpc.Core/ChannelOptions.cs @@ -26,8 +26,10 @@ namespace Grpc.Core /// <summary> /// Channel option specified when creating a channel. /// Corresponds to grpc_channel_args from grpc/grpc.h. + /// Commonly used channel option names are defined in <c>ChannelOptions</c>, + /// but any of the GRPC_ARG_* channel options names defined in grpc_types.h can be used. /// </summary> - public sealed class ChannelOption + public sealed class ChannelOption : IEquatable<ChannelOption> { /// <summary> /// Type of <c>ChannelOption</c>. @@ -119,10 +121,60 @@ namespace Grpc.Core return stringValue; } } + + /// <summary> + /// Determines whether the specified object is equal to the current object. + /// </summary> + public override bool Equals(object obj) + { + return Equals(obj as ChannelOption); + } + + /// <summary> + /// Determines whether the specified object is equal to the current object. + /// </summary> + public bool Equals(ChannelOption other) + { + return other != null && + type == other.type && + name == other.name && + intValue == other.intValue && + stringValue == other.stringValue; + } + + /// <summary> + /// A hash code for the current object. + /// </summary> + public override int GetHashCode() + { + var hashCode = 1412678443; + hashCode = hashCode * -1521134295 + type.GetHashCode(); + hashCode = hashCode * -1521134295 + EqualityComparer<string>.Default.GetHashCode(name); + hashCode = hashCode * -1521134295 + intValue.GetHashCode(); + hashCode = hashCode * -1521134295 + EqualityComparer<string>.Default.GetHashCode(stringValue); + return hashCode; + } + + /// <summary> + /// Equality operator. + /// </summary> + public static bool operator ==(ChannelOption option1, ChannelOption option2) + { + return EqualityComparer<ChannelOption>.Default.Equals(option1, option2); + } + + /// <summary> + /// Inequality operator. + /// </summary> + public static bool operator !=(ChannelOption option1, ChannelOption option2) + { + return !(option1 == option2); + } } /// <summary> - /// Defines names of supported channel options. + /// Defines names of most commonly used channel options. + /// Other supported options names can be found in grpc_types.h (GRPC_ARG_* definitions) /// </summary> public static class ChannelOptions { diff --git a/src/csharp/doc/README.md b/src/csharp/doc/README.md index 46cce013a1..427f457eb6 100644 --- a/src/csharp/doc/README.md +++ b/src/csharp/doc/README.md @@ -1,9 +1,28 @@ DocFX-generated C# API Reference -------------------------------- +## Generating docs manually (on Windows) + Install docfx based on instructions here: https://github.com/dotnet/docfx ``` # generate docfx documentation into ./html directory $ docfx ``` + +## Release process: script for regenerating the docs automatically + +After each gRPC C# release, the docs need to be regenerated +and updated on the grpc.io site. The automated script will +re-generate the docs (using dockerized docfx installation) +and make everything ready for creating a PR to update the docs. + +``` +# 1. Run the script on Linux with docker installed +$ ./generate_reference_docs.sh + +# 2. Enter the git repo with updated "gh-pages" branch +$ cd grpc-gh-pages + +# 3. Review the changes and create a pull request +``` diff --git a/src/csharp/doc/generate_reference_docs.sh b/src/csharp/doc/generate_reference_docs.sh new file mode 100755 index 0000000000..c20d6c30bd --- /dev/null +++ b/src/csharp/doc/generate_reference_docs.sh @@ -0,0 +1,38 @@ +#!/bin/sh +# Copyright 2018 The gRPC Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Generates C# API docs using docfx inside docker. +set -ex +cd $(dirname $0) + +# cleanup temporary files +rm -rf html obj grpc-gh-pages + +# generate into src/csharp/doc/html directory +cd .. +docker run --rm -v "$(pwd)":/work -w /work/doc --user "$(id -u):$(id -g)" -it tsgkadot/docker-docfx:latest docfx +cd doc + +# prepare a clone of "gh-pages" branch where the generated docs are stored +GITHUB_USER="${USER}" +git clone -b gh-pages -o upstream git@github.com:grpc/grpc.git grpc-gh-pages +cd grpc-gh-pages +git remote add origin "git@github.com:${GITHUB_USER}/grpc.git" + +# replace old generated docs by the ones we just generated +rm -r csharp +cp -r ../html csharp + +echo "Done. Go to src/csharp/doc/grpc-gh-pages git repository and create a pull request to update the generated docs." diff --git a/src/csharp/experimental/README.md b/src/csharp/experimental/README.md index bd53cbcd35..64515075ce 100644 --- a/src/csharp/experimental/README.md +++ b/src/csharp/experimental/README.md @@ -22,10 +22,14 @@ gRPC C# now has experimental support for Unity. Please try using gRPC with Unity and provide feedback! How to test gRPC in a Unity project + 1. Create a Unity project that targets .NET 4.x (Edit -> Project Settings -> Editor -> Scripting Runtime Version). gRPC uses APIs that are only available in .NET4.5+ so this is a requirement. + 2. Download the latest development build of `grpc_unity_package.VERSION.zip` from [daily builds](https://packages.grpc.io/) + 3. Extract the `.zip` file in the `Assets` directory in your Unity project + 4. Unity IDE will pick up all the bundled files and add them to project automatically. You should be able to use gRPC and Protobuf in your scripts from now on. |