# Namespace Google.Protobuf (3.27.1)

<button class="button button-with-icon cloud-select-dropdown__button " aria-haspopup="true">Version latest</button>

- [3.27.1 (latest)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf)
- [3.23.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/3.23.0/Google.Protobuf)
- [3.15.8](https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/3.15.8/Google.Protobuf)

## Classes

### [ByteString](https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.ByteString)

Immutable array of bytes.

### [CodedInputStream](https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.CodedInputStream)

Reads and decodes protocol message fields.

### [CodedOutputStream](https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.CodedOutputStream)

Encodes and writes protocol message fields.

### [CodedOutputStream.OutOfSpaceException](https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.CodedOutputStream.OutOfSpaceException)

Indicates that a CodedOutputStream wrapping a flat byte array
ran out of space.

### [Extension](https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.Extension)

Represents a non-generic extension definition. This API is experimental and subject to change.

### [ExtensionRegistry](https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.ExtensionRegistry)

Provides extensions to messages while parsing. This API is experimental and subject to change.

### [ExtensionSet](https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.ExtensionSet)

Methods for managing [ExtensionSet\<TTarget\>](https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.ExtensionSet-1)s with null checking.

Most users will not use this class directly and its API is experimental and subject to change.

### [ExtensionSet\<TTarget\>](https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.ExtensionSet-1)

Used for keeping track of extensions in messages.
[IExtendableMessage\<T\>](https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IExtendableMessage-1) methods route to this set.

Most users will not need to use this class directly

### [Extension\<TTarget, TValue\>](https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.Extension-2)

Represents a type-safe extension identifier used for getting and setting single extension values in [IExtendableMessage\<T\>](https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IExtendableMessage-1) instances.
This API is experimental and subject to change.

### [FieldCodec](https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.FieldCodec)

Factory methods for [FieldCodec\<T\>](https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.FieldCodec-1).

### [FieldCodec\<T\>](https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.FieldCodec-1)


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.

### [InvalidJsonException](https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.InvalidJsonException)

Thrown when an attempt is made to parse invalid JSON, e.g. using
a non-string property key, or including a redundant comma. Parsing a protocol buffer
message represented in JSON using [JsonParser](https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.JsonParser) can throw both this
exception and [InvalidProtocolBufferException](https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.InvalidProtocolBufferException) depending on the situation. This
exception is only thrown for "pure JSON" errors, whereas `InvalidProtocolBufferException`
is thrown when the JSON may be valid in and of itself, but cannot be parsed as a protocol buffer
message.

### [InvalidProtocolBufferException](https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.InvalidProtocolBufferException)

Thrown when a protocol message being parsed is invalid in some way,
e.g. it contains a malformed varint or a negative byte length.

### [JsonFormatter](https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.JsonFormatter)

Reflection-based converter from messages to JSON.

### [JsonFormatter.Settings](https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.JsonFormatter.Settings)

Settings controlling JSON formatting.

### [JsonParser](https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.JsonParser)

Reflection-based converter from JSON to messages.

### [JsonParser.Settings](https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.JsonParser.Settings)

Settings controlling JSON parsing.

### [MessageExtensions](https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.MessageExtensions)

Extension methods on [IMessage](https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IMessage) and [IMessage\<T\>](https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IMessage-1).

### [MessageParser](https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.MessageParser)

A general message parser, typically used by reflection-based code as all the methods
return simple [IMessage](https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IMessage).

### [MessageParser\<T\>](https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.MessageParser-1)

A parser for a specific message type.

### [ProtoPreconditions](https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.ProtoPreconditions)

Helper methods for throwing exceptions when preconditions are not met.

### [RepeatedExtension\<TTarget, TValue\>](https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.RepeatedExtension-2)

Represents a type-safe extension identifier used for getting repeated extension values in [IExtendableMessage\<T\>](https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IExtendableMessage-1) instances.
This API is experimental and subject to change.

### [UnknownFieldSet](https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.UnknownFieldSet)

Used to keep track of fields which were seen when parsing a protocol message
but whose field numbers or types are unrecognized. This most frequently
occurs when new fields are added to a message type and then messages containing
those fields are read by old software that was built before the new types were
added.

Most users will never need to use this class directly.

### [UnsafeByteOperations](https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.UnsafeByteOperations)

Provides a number of unsafe byte operations to be used by advanced applications with high performance
requirements. These methods are referred to as "unsafe" due to the fact that they potentially expose
the backing buffer of a [ByteString](https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.ByteString) to the application.

### [WireFormat](https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.WireFormat)

This class is used internally by the Protocol Buffer Library and generated
message implementations. It is public only for the sake of those generated
messages. Others should not use this class directly.


This class contains constants and helper functions useful for dealing with
the Protocol Buffer wire format.

<br />

## Structs

### [ParseContext](https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.ParseContext)

An opaque struct that represents the current parsing state and is passed along
as the parsing proceeds.
All the public methods are intended to be invoked only by the generated code,
users should never invoke them directly.

### [WriteContext](https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.WriteContext)

An opaque struct that represents the current serialization state and is passed along
as the serialization proceeds.
All the public methods are intended to be invoked only by the generated code,
users should never invoke them directly.

## Interfaces

### [IBufferMessage](https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IBufferMessage)

Interface for a Protocol Buffers message, supporting
parsing from [ParseContext](https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.ParseContext) and writing to [WriteContext](https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.WriteContext).

### [ICustomDiagnosticMessage](https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.ICustomDiagnosticMessage)

A message type that has a custom string format for diagnostic purposes.

### [IDeepCloneable\<T\>](https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IDeepCloneable-1)

Generic interface for a deeply cloneable type.

### [IExtendableMessage\<T\>](https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IExtendableMessage-1)

Generic interface for a Protocol Buffers message containing one or more extensions, where the type parameter is expected to be the same type as the implementation class.
This interface is experiemental and is subject to change.

### [IMessage](https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IMessage)

Interface for a Protocol Buffers message, supporting
basic operations required for serialization.

### [IMessage\<T\>](https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IMessage-1)

Generic interface for a Protocol Buffers message,
where the type parameter is expected to be the same type as
the implementation class.

## Enums

### [WireFormat.WireType](https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.WireFormat.WireType)

Wire types within protobuf encoding.