deserialization context always has non-null payload

pull/16367/head
Jan Tattermusch 7 years ago
parent 26d3e774df
commit fb704ee949
  1. 11
      src/csharp/Grpc.Core/DeserializationContext.cs
  2. 4
      src/csharp/Grpc.Core/Marshaller.cs

@ -24,14 +24,9 @@ namespace Grpc.Core
public abstract class DeserializationContext
{
/// <summary>
/// Returns <c>true</c> if there is a payload to deserialize (= payload is not null), <c>false</c> otherwise.
/// Get the total length of the payload in bytes.
/// </summary>
public virtual bool HasPayload => PayloadLength.HasValue;
/// <summary>
/// Get the total length of the payload in bytes or <c>null</c> if the payload is null.
/// </summary>
public abstract int? PayloadLength { get; }
public abstract int PayloadLength { get; }
/// <summary>
/// Gets the entire payload as a newly allocated byte array.
@ -43,7 +38,7 @@ namespace Grpc.Core
/// the payload is more than 86700 bytes large (which means the newly allocated buffer will be placed in LOH,
/// and LOH object can only be garbage collected via a full ("stop the world") GC run).
/// </summary>
/// <returns>byte array containing the entire payload or null if there is no payload.</returns>
/// <returns>byte array containing the entire payload.</returns>
public abstract byte[] PayloadAsNewBuffer();
}
}

@ -137,10 +137,10 @@ namespace Grpc.Core
public EmulatedDeserializationContext(byte[] payload)
{
this.payload = payload;
this.payload = GrpcPreconditions.CheckNotNull(payload);
}
public override int? PayloadLength => payload?.Length;
public override int PayloadLength => payload.Length;
public override byte[] PayloadAsNewBuffer()
{

Loading…
Cancel
Save