Complete the payload written to the buffer writer.Complete()can only be called once.
Complete(byte[])
publicvirtualvoidComplete(byte[]payload)
Use the byte array as serialized form of current message and mark serialization process as complete.Complete(byte[])can only be called once. By calling this method the caller gives up the ownership of the
payload which must not be accessed afterwards.
Parameter
Name
Description
payload
System.Byte
the serialized form of current message
GetBufferWriter()
public virtual IBufferWriter<byte> GetBufferWriter()
Gets buffer writer that can be used to write the serialized data. Once serialization is finished,Complete()needs to be called.
Sets the payload length when writing serialized data into a buffer writer. If the serializer knows the full payload
length in advance, providing that information before obtaining the buffer writer usingGetBufferWriter()can improve
serialization efficiency by avoiding copies. The provided payload length must be the same as the data written to the writer.
Calling this method is optional. If the payload length is not set then the length is calculated using the data written to
the buffer writer whenComplete()is called.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[[["\u003cp\u003e\u003ccode\u003eSerializationContext\u003c/code\u003e is an abstract class that provides storage for payload data during message serialization.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eComplete()\u003c/code\u003e method finalizes the payload written to the buffer writer, and can only be called once.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eComplete(byte[])\u003c/code\u003e method finalizes the payload from a byte array, marking the serialization complete and relinquishing ownership of the byte array.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eGetBufferWriter()\u003c/code\u003e method provides an \u003ccode\u003eIBufferWriter\u003c/code\u003e that allows you to directly write serialized data.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eSetPayloadLength(int)\u003c/code\u003e can optionally be used to specify the total length of the payload in bytes before writing to improve serialization performance.\u003c/p\u003e\n"]]],[],null,["# Class SerializationContext (2.66.0)\n\nVersion latestkeyboard_arrow_down\n\n- [2.66.0 (latest)](/dotnet/docs/reference/Grpc.Core/latest/Grpc.Core.SerializationContext)\n- [2.63.0](/dotnet/docs/reference/Grpc.Core/2.63.0/Grpc.Core.SerializationContext)\n- [2.48.0](/dotnet/docs/reference/Grpc.Core/2.48.0/Grpc.Core.SerializationContext) \n\n public abstract class SerializationContext\n\nProvides storage for payload when serializing a message. \n\nInheritance\n-----------\n\n[object](https://learn.microsoft.com/dotnet/api/system.object) \\\u003e SerializationContext \n\nInherited Members\n-----------------\n\n[object.Equals(object)](https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object)) \n[object.Equals(object, object)](https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object-system-object)) \n[object.GetHashCode()](https://learn.microsoft.com/dotnet/api/system.object.gethashcode) \n[object.GetType()](https://learn.microsoft.com/dotnet/api/system.object.gettype) \n[object.MemberwiseClone()](https://learn.microsoft.com/dotnet/api/system.object.memberwiseclone) \n[object.ReferenceEquals(object, object)](https://learn.microsoft.com/dotnet/api/system.object.referenceequals) \n[object.ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring)\n\nNamespace\n---------\n\n[Grpc.Core](/dotnet/docs/reference/Grpc.Core/latest/Grpc.Core)\n\nAssembly\n--------\n\nGrpc.Core.Api.dll\n\nMethods\n-------\n\n### Complete()\n\n public virtual void Complete()\n\nComplete the payload written to the buffer writer. `Complete()` can only be called once.\n\n### Complete(byte\\[\\])\n\n public virtual void Complete(byte[] payload)\n\nUse the byte array as serialized form of current message and mark serialization process as complete.\n`Complete(byte[])` can only be called once. By calling this method the caller gives up the ownership of the\npayload which must not be accessed afterwards.\n\n### GetBufferWriter()\n\n public virtual IBufferWriter\u003cbyte\u003e GetBufferWriter()\n\nGets buffer writer that can be used to write the serialized data. Once serialization is finished,\n`Complete()` needs to be called.\n\n### SetPayloadLength(int)\n\n public virtual void SetPayloadLength(int payloadLength)\n\nSets the payload length when writing serialized data into a buffer writer. If the serializer knows the full payload\nlength in advance, providing that information before obtaining the buffer writer using `GetBufferWriter()` can improve\nserialization efficiency by avoiding copies. The provided payload length must be the same as the data written to the writer.\nCalling this method is optional. If the payload length is not set then the length is calculated using the data written to\nthe buffer writer when `Complete()` is called."]]