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

Google.Protobuf.FieldCodec<T>

public sealed class FieldCodec<T>

An encode/decode pair for a single field. This effectively encapsulates all the information needed to read or write the field value from/to a coded stream.

This class is public and has to be as it is used by generated code, but its public API is very limited - just what the generated code needs to call directly.

public int CalculateSizeWithTag(T value)

Calculates the size required to write the given value, with a tag, if the value is not the default.

public T Read(CodedInputStream input)

Reads a value of the codec type from the given CodedInputStream.

public T Read(ref ParseContext ctx)

Reads a value of the codec type from the given ParseContext.

public void WriteTagAndValue(CodedOutputStream output, T value)

Write a tag and the given value, *if* the value is not the default.

public void WriteTagAndValue(ref WriteContext ctx, T value)

Write a tag and the given value, *if* the value is not the default.