[C#] Add ChannelCredentials.SecureSsl property for better codecompletion with ChannelCredentials (#26472)

* Add ChannelCredentials.Secure

* Update

* Test

* PR feedback
pull/26550/head
James Newton-King 3 years ago committed by GitHub
parent b04a1ce5e6
commit 2537957c78
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 17
      src/csharp/Grpc.Core.Api/ChannelCredentials.cs
  2. 10
      src/csharp/Grpc.Core.Tests/ChannelCredentialsTest.cs

@ -31,6 +31,7 @@ namespace Grpc.Core
public abstract class ChannelCredentials
{
static readonly ChannelCredentials InsecureInstance = new InsecureCredentials();
static readonly ChannelCredentials SecureSslInstance = new SslCredentials();
/// <summary>
/// Creates a new instance of channel credentials
@ -51,6 +52,22 @@ namespace Grpc.Core
}
}
/// <summary>
/// Returns instance of credentials that provides SSL security.
/// <para>
/// These credentials are the same as creating <see cref="SslCredentials"/> without parameters.
/// Apps that are using Grpc.Core can create <see cref="SslCredentials"/> directly to customize
/// the secure SSL credentials.
/// </para>
/// </summary>
public static ChannelCredentials SecureSsl
{
get
{
return SecureSslInstance;
}
}
/// <summary>
/// Creates a new instance of <c>ChannelCredentials</c> class by composing
/// given channel credentials with call credentials.

@ -30,6 +30,12 @@ namespace Grpc.Core.Tests
Assert.IsFalse(ChannelCredentials.Insecure.IsComposable);
}
[Test]
public void SecureCredentials_IsComposable()
{
Assert.IsTrue(ChannelCredentials.SecureSsl.IsComposable);
}
[Test]
public void ChannelCredentials_CreateComposite()
{
@ -52,6 +58,10 @@ namespace Grpc.Core.Tests
var nativeCreds1 = creds.ToNativeCredentials();
var nativeCreds2 = creds.ToNativeCredentials();
Assert.AreSame(nativeCreds1, nativeCreds2);
var nativeCreds3 = ChannelCredentials.SecureSsl.ToNativeCredentials();
var nativeCreds4 = ChannelCredentials.SecureSsl.ToNativeCredentials();
Assert.AreSame(nativeCreds3, nativeCreds4);
}
}
}

Loading…
Cancel
Save