Merge pull request #2873 from jtattermusch/expose_version_string

expose C core version string to C#
pull/2878/head
Jan Tattermusch 9 years ago
commit b5ea2f89fd
  1. 8
      src/csharp/Grpc.Core.Tests/GrpcEnvironmentTest.cs
  2. 12
      src/csharp/Grpc.Core/GrpcEnvironment.cs
  3. 5
      src/csharp/ext/grpc_csharp_ext.c

@ -69,5 +69,13 @@ namespace Grpc.Core.Tests
Assert.IsFalse(object.ReferenceEquals(env1, env2));
}
[Test]
public void GetCoreVersionString()
{
var coreVersion = GrpcEnvironment.GetCoreVersionString();
var parts = coreVersion.Split('.');
Assert.AreEqual(4, parts.Length);
}
}
}

@ -53,6 +53,9 @@ namespace Grpc.Core
[DllImport("grpc_csharp_ext.dll")]
static extern void grpcsharp_shutdown();
[DllImport("grpc_csharp_ext.dll")]
static extern IntPtr grpcsharp_version_string(); // returns not-owned const char*
static object staticLock = new object();
static GrpcEnvironment instance;
@ -163,6 +166,15 @@ namespace Grpc.Core
}
}
/// <summary>
/// Gets version of gRPC C core.
/// </summary>
internal static string GetCoreVersionString()
{
var ptr = grpcsharp_version_string(); // the pointer is not owned
return Marshal.PtrToStringAnsi(ptr);
}
/// <summary>
/// Shuts down this environment.
/// </summary>

@ -876,6 +876,11 @@ GPR_EXPORT void GPR_CALLTYPE grpcsharp_redirect_log(grpcsharp_log_func func) {
typedef void(GPR_CALLTYPE *test_callback_funcptr)(gpr_int32 success);
/* Version info */
GPR_EXPORT const char *GPR_CALLTYPE grpcsharp_version_string() {
return grpc_version_string();
}
/* For testing */
GPR_EXPORT void GPR_CALLTYPE
grpcsharp_test_callback(test_callback_funcptr callback) {

Loading…
Cancel
Save