<PackageReference Include="Google.Protobuf" Version="3.35.1" />

Google.Protobuf.MessageExtensions

public static class MessageExtensions
Extension methods on IMessage and IMessage<T>.
public static bool IsInitialized(this IMessage message)

Checks if all required fields in a message have values set. For proto3 messages, this returns true.

public static void MergeDelimitedFrom(this IMessage message, Stream input)

Merges length-delimited data from the given stream into an existing message.

public static void MergeFrom(this IMessage message, byte[] data)

Merges data from the given byte array into an existing message.

public static void MergeFrom(this IMessage message, byte[] data, int offset, int length)

Merges data from the given byte array slice into an existing message.

public static void MergeFrom(this IMessage message, ByteString data)

Merges data from the given byte string into an existing message.

public static void MergeFrom(this IMessage message, Stream input)

Merges data from the given stream into an existing message.

public static void MergeFrom(this IMessage message, ReadOnlySpan<byte> span)

Merges data from the given span into an existing message.

public static void MergeFrom(this IMessage message, ReadOnlySequence<byte> sequence)

Merges data from the given sequence into an existing message.

public static byte[] ToByteArray(this IMessage message)

Converts the given message into a byte array in protobuf encoding.

public static ByteString ToByteString(this IMessage message)

Converts the given message into a byte string in protobuf encoding.

public static void WriteDelimitedTo(this IMessage message, Stream output)

Writes the length and then data of the given message to a stream.

public static void WriteLengthPrefixedTo(this IMessage message, IBufferWriter<byte> output)

Writes the length and then data of the given message to a buffer writer.

public static void WriteTo(this IMessage message, Stream output)

Writes the given message data to the given stream in protobuf encoding.

public static void WriteTo(this IMessage message, IBufferWriter<byte> output)

Writes the given message data to the given buffer writer in protobuf encoding.

public static void WriteTo(this IMessage message, Span<byte> output)

Writes the given message data to the given span in protobuf encoding. The size of the destination span needs to fit the serialized size of the message exactly, otherwise an exception is thrown.