From c288d1a89482b0d3d8284d522bb87e6d15dd572d Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Tue, 2 Oct 2018 13:55:38 +0200 Subject: [PATCH 1/3] improve doc comments for ChannelOptions --- src/csharp/Grpc.Core/ChannelOptions.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/csharp/Grpc.Core/ChannelOptions.cs b/src/csharp/Grpc.Core/ChannelOptions.cs index 6ad5d56cad6..6fd66bf129c 100644 --- a/src/csharp/Grpc.Core/ChannelOptions.cs +++ b/src/csharp/Grpc.Core/ChannelOptions.cs @@ -26,6 +26,8 @@ namespace Grpc.Core /// /// Channel option specified when creating a channel. /// Corresponds to grpc_channel_args from grpc/grpc.h. + /// Commonly used channel option names are defined in ChannelOptions, + /// but any of the GRPC_ARG_* channel options names defined in grpc_types.h can be used. /// public sealed class ChannelOption { @@ -122,7 +124,8 @@ namespace Grpc.Core } /// - /// 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) /// public static class ChannelOptions { From 8eb6daddd9312d000db4f7b33dd35a509adea2a2 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Tue, 2 Oct 2018 14:08:06 +0200 Subject: [PATCH 2/3] ChannelOption: implement hashcode and equals --- src/csharp/Grpc.Core/ChannelOptions.cs | 36 +++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/src/csharp/Grpc.Core/ChannelOptions.cs b/src/csharp/Grpc.Core/ChannelOptions.cs index 6fd66bf129c..3ea05120c10 100644 --- a/src/csharp/Grpc.Core/ChannelOptions.cs +++ b/src/csharp/Grpc.Core/ChannelOptions.cs @@ -29,7 +29,7 @@ namespace Grpc.Core /// Commonly used channel option names are defined in ChannelOptions, /// but any of the GRPC_ARG_* channel options names defined in grpc_types.h can be used. /// - public sealed class ChannelOption + public sealed class ChannelOption : IEquatable { /// /// Type of ChannelOption. @@ -121,6 +121,40 @@ namespace Grpc.Core return stringValue; } } + + public override bool Equals(object obj) + { + return Equals(obj as ChannelOption); + } + + public bool Equals(ChannelOption other) + { + return other != null && + type == other.type && + name == other.name && + intValue == other.intValue && + stringValue == other.stringValue; + } + + public override int GetHashCode() + { + var hashCode = 1412678443; + hashCode = hashCode * -1521134295 + type.GetHashCode(); + hashCode = hashCode * -1521134295 + EqualityComparer.Default.GetHashCode(name); + hashCode = hashCode * -1521134295 + intValue.GetHashCode(); + hashCode = hashCode * -1521134295 + EqualityComparer.Default.GetHashCode(stringValue); + return hashCode; + } + + public static bool operator ==(ChannelOption option1, ChannelOption option2) + { + return EqualityComparer.Default.Equals(option1, option2); + } + + public static bool operator !=(ChannelOption option1, ChannelOption option2) + { + return !(option1 == option2); + } } /// From e88a40ae265ee82073ef9238a0289e6e952557a8 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Tue, 2 Oct 2018 14:34:20 +0200 Subject: [PATCH 3/3] add xmldoc comments --- src/csharp/Grpc.Core/ChannelOptions.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/csharp/Grpc.Core/ChannelOptions.cs b/src/csharp/Grpc.Core/ChannelOptions.cs index 3ea05120c10..880f2bef5f9 100644 --- a/src/csharp/Grpc.Core/ChannelOptions.cs +++ b/src/csharp/Grpc.Core/ChannelOptions.cs @@ -122,11 +122,17 @@ namespace Grpc.Core } } + /// + /// Determines whether the specified object is equal to the current object. + /// public override bool Equals(object obj) { return Equals(obj as ChannelOption); } + /// + /// Determines whether the specified object is equal to the current object. + /// public bool Equals(ChannelOption other) { return other != null && @@ -136,6 +142,9 @@ namespace Grpc.Core stringValue == other.stringValue; } + /// + /// A hash code for the current object. + /// public override int GetHashCode() { var hashCode = 1412678443; @@ -146,11 +155,17 @@ namespace Grpc.Core return hashCode; } + /// + /// Equality operator. + /// public static bool operator ==(ChannelOption option1, ChannelOption option2) { return EqualityComparer.Default.Equals(option1, option2); } + /// + /// Inequality operator. + /// public static bool operator !=(ChannelOption option1, ChannelOption option2) { return !(option1 == option2);