pull/2597/head
Jan Tattermusch 9 years ago
parent 77415b63bb
commit 7f23a75422
  1. 21
      src/csharp/Grpc.Core.Tests/Internal/MetadataArraySafeHandleTest.cs
  2. 4
      src/csharp/ext/grpc_csharp_ext.c

@ -59,5 +59,26 @@ namespace Grpc.Core.Internal.Tests
var nativeMetadata = MetadataArraySafeHandle.Create(metadata); var nativeMetadata = MetadataArraySafeHandle.Create(metadata);
nativeMetadata.Dispose(); nativeMetadata.Dispose();
} }
[Test]
public void ReadMetadataFromPtrUnsafe()
{
var metadata = new Metadata
{
new Metadata.Entry("host", "somehost"),
new Metadata.Entry("header2", "header value"),
};
var nativeMetadata = MetadataArraySafeHandle.Create(metadata);
var copy = MetadataArraySafeHandle.ReadMetadataFromPtrUnsafe(nativeMetadata.Handle);
Assert.AreEqual(2, copy.Count);
Assert.AreEqual("host", copy[0].Key);
Assert.AreEqual("somehost", copy[0].Value);
Assert.AreEqual("header2", copy[1].Key);
Assert.AreEqual("header value", copy[1].Value);
nativeMetadata.Dispose();
}
} }
} }

@ -172,10 +172,10 @@ grpcsharp_metadata_array_count(grpc_metadata_array *array) {
return (gpr_intptr) array->count; return (gpr_intptr) array->count;
} }
GPR_EXPORT const grpc_metadata *GPR_CALLTYPE GPR_EXPORT grpc_metadata GPR_CALLTYPE
grpcsharp_metadata_array_get(grpc_metadata_array *array, size_t index) { grpcsharp_metadata_array_get(grpc_metadata_array *array, size_t index) {
GPR_ASSERT(index < array->count); GPR_ASSERT(index < array->count);
return &(array->metadata[index]); return array->metadata[index];
} }
/* Move contents of metadata array */ /* Move contents of metadata array */

Loading…
Cancel
Save