Class MessageOptions (3.23.0)

public sealed class MessageOptions : IExtendableMessage<MessageOptions>, IMessage<MessageOptions>, IEquatable<MessageOptions>, IDeepCloneable<MessageOptions>, IBufferMessage, IMessage

Inheritance

object > MessageOptions

Namespace

Google.Protobuf.Reflection

Assembly

Google.Protobuf.dll

Constructors

MessageOptions()

public MessageOptions()

MessageOptions(MessageOptions)

public MessageOptions(MessageOptions other)
Parameter
Name Description
other MessageOptions

Fields

DeprecatedFieldNumber

public const int DeprecatedFieldNumber = 3

Field number for the "deprecated" field.

Field Value
Type Description
int

DeprecatedLegacyJsonFieldConflictsFieldNumber

public const int DeprecatedLegacyJsonFieldConflictsFieldNumber = 11

Field number for the "deprecated_legacy_json_field_conflicts" field.

Field Value
Type Description
int

MapEntryFieldNumber

public const int MapEntryFieldNumber = 7

Field number for the "map_entry" field.

Field Value
Type Description
int

MessageSetWireFormatFieldNumber

public const int MessageSetWireFormatFieldNumber = 1

Field number for the "message_set_wire_format" field.

Field Value
Type Description
int

NoStandardDescriptorAccessorFieldNumber

public const int NoStandardDescriptorAccessorFieldNumber = 2

Field number for the "no_standard_descriptor_accessor" field.

Field Value
Type Description
int

UninterpretedOptionFieldNumber

public const int UninterpretedOptionFieldNumber = 999

Field number for the "uninterpreted_option" field.

Field Value
Type Description
int

Properties

Deprecated

public bool Deprecated { get; set; }

Is this message deprecated? Depending on the target platform, this can emit Deprecated annotations for the message, or it will be completely ignored; in the very least, this is a formalization for deprecating messages.

Property Value
Type Description
bool

DeprecatedLegacyJsonFieldConflicts

[Obsolete]
public bool DeprecatedLegacyJsonFieldConflicts { get; set; }

Enable the legacy handling of JSON field name conflicts. This lowercases and strips underscored from the fields before comparison in proto3 only. The new behavior takes json_name into account and applies to proto2 as well.

This should only be used as a temporary measure against broken builds due to the change in behavior for JSON field name conflicts.

TODO(b/261750190) This is legacy behavior we plan to remove once downstream teams have had time to migrate.

Property Value
Type Description
bool

Descriptor

public static MessageDescriptor Descriptor { get; }
Property Value
Type Description
MessageDescriptor

HasDeprecated

public bool HasDeprecated { get; }

Gets whether the "deprecated" field is set

Property Value
Type Description
bool

HasDeprecatedLegacyJsonFieldConflicts

[Obsolete]
public bool HasDeprecatedLegacyJsonFieldConflicts { get; }

Gets whether the "deprecated_legacy_json_field_conflicts" field is set

Property Value
Type Description
bool

HasMapEntry

public bool HasMapEntry { get; }

Gets whether the "map_entry" field is set

Property Value
Type Description
bool

HasMessageSetWireFormat

public bool HasMessageSetWireFormat { get; }

Gets whether the "message_set_wire_format" field is set

Property Value
Type Description
bool

HasNoStandardDescriptorAccessor

public bool HasNoStandardDescriptorAccessor { get; }

Gets whether the "no_standard_descriptor_accessor" field is set

Property Value
Type Description
bool

MapEntry

public bool MapEntry { get; set; }

NOTE: Do not set the option in .proto files. Always use the maps syntax instead. The option should only be implicitly set by the proto compiler parser.

Whether the message is an automatically generated map entry type for the maps field.

For maps fields: map<KeyType, ValueType> map_field = 1; The parsed descriptor looks like: message MapFieldEntry { option map_entry = true; optional KeyType key = 1; optional ValueType value = 2; } repeated MapFieldEntry map_field = 1;

Implementations may choose not to generate the map_entry=true message, but use a native map in the target language to hold the keys and values. The reflection APIs in such implementations still need to work as if the field is a repeated message field.

Property Value
Type Description
bool

MessageSetWireFormat

public bool MessageSetWireFormat { get; set; }

Set true to use the old proto1 MessageSet wire format for extensions. This is provided for backwards-compatibility with the MessageSet wire format. You should not use this for any other reason: It's less efficient, has fewer features, and is more complicated.

The message must be defined exactly as follows: message Foo { option message_set_wire_format = true; extensions 4 to max; } Note that the message cannot have any defined fields; MessageSets only have extensions.

All extensions of your type must be singular messages; e.g. they cannot be int32s, enums, or repeated messages.

Because this is an option, the above two restrictions are not enforced by the protocol compiler.

Property Value
Type Description
bool

NoStandardDescriptorAccessor

public bool NoStandardDescriptorAccessor { get; set; }

Disables the generation of the standard "descriptor()" accessor, which can conflict with a field of the same name. This is meant to make migration from proto1 easier; new code should avoid fields named "descriptor".

Property Value
Type Description
bool

Parser

public static MessageParser<MessageOptions> Parser { get; }
Property Value
Type Description
MessageParserMessageOptions

UninterpretedOption

public RepeatedField<UninterpretedOption> UninterpretedOption { get; }

The parser stores options it doesn't recognize here. See above.

Property Value
Type Description
RepeatedFieldUninterpretedOption

Methods

CalculateSize()

public int CalculateSize()

Calculates the size of this message in Protocol Buffer wire format, in bytes.

Returns
Type Description
int

The number of bytes required to write this message to a coded output stream.

ClearDeprecated()

public void ClearDeprecated()

Clears the value of the "deprecated" field

ClearDeprecatedLegacyJsonFieldConflicts()

[Obsolete]
public void ClearDeprecatedLegacyJsonFieldConflicts()

Clears the value of the "deprecated_legacy_json_field_conflicts" field

ClearExtension<TValue>(Extension<MessageOptions, TValue>)

public void ClearExtension<TValue>(Extension<MessageOptions, TValue> extension)

Clears the value of the specified extension

Parameter
Name Description
extension ExtensionMessageOptions
Type Parameter
Name Description
TValue

ClearExtension<TValue>(RepeatedExtension<MessageOptions, TValue>)

public void ClearExtension<TValue>(RepeatedExtension<MessageOptions, TValue> extension)

Clears the value of the specified repeated extension

Parameter
Name Description
extension RepeatedExtensionMessageOptions
Type Parameter
Name Description
TValue

ClearMapEntry()

public void ClearMapEntry()

Clears the value of the "map_entry" field

ClearMessageSetWireFormat()

public void ClearMessageSetWireFormat()

Clears the value of the "message_set_wire_format" field

ClearNoStandardDescriptorAccessor()

public void ClearNoStandardDescriptorAccessor()

Clears the value of the "no_standard_descriptor_accessor" field

Clone()

public MessageOptions Clone()

Creates a deep clone of this object.

Returns
Type Description
MessageOptions

A deep clone of this object.

Equals(MessageOptions)

public bool Equals(MessageOptions other)
Parameter
Name Description
other MessageOptions
Returns
Type Description
bool

Equals(object)

public override bool Equals(object other)
Parameter
Name Description
other object
Returns
Type Description
bool
Overrides

GetExtension<TValue>(Extension<MessageOptions, TValue>)

public TValue GetExtension<TValue>(Extension<MessageOptions, TValue> extension)

Gets the value of the specified extension

Parameter
Name Description
extension ExtensionMessageOptions
Returns
Type Description
TValue
Type Parameter
Name Description
TValue

GetExtension<TValue>(RepeatedExtension<MessageOptions, TValue>)

public RepeatedField<TValue> GetExtension<TValue>(RepeatedExtension<MessageOptions, TValue> extension)

Gets the value of the specified repeated extension or null if the extension isn't registered in this set. For a version of this method that never returns null, use GetOrInitializeExtension<TValue>(RepeatedExtension<T, TValue>)

Parameter
Name Description
extension RepeatedExtensionMessageOptions
Returns
Type Description
RepeatedField
Type Parameter
Name Description
TValue

GetHashCode()

public override int GetHashCode()
Returns
Type Description
int
Overrides

GetOrInitializeExtension<TValue>(RepeatedExtension<MessageOptions, TValue>)

public RepeatedField<TValue> GetOrInitializeExtension<TValue>(RepeatedExtension<MessageOptions, TValue> extension)

Gets the value of the specified repeated extension, registering it if it hasn't already been registered.

Parameter
Name Description
extension RepeatedExtensionMessageOptions
Returns
Type Description
RepeatedField
Type Parameter
Name Description
TValue

HasExtension<TValue>(Extension<MessageOptions, TValue>)

public bool HasExtension<TValue>(Extension<MessageOptions, TValue> extension)

Gets whether the value of the specified extension is set

Parameter
Name Description
extension ExtensionMessageOptions
Returns
Type Description
bool
Type Parameter
Name Description
TValue

MergeFrom(CodedInputStream)

public void MergeFrom(CodedInputStream input)

Merges the data from the specified coded input stream with the current message.

Parameter
Name Description
input CodedInputStream
Remarks

See the user guide for precise merge semantics.

MergeFrom(MessageOptions)

public void MergeFrom(MessageOptions other)

Merges the given message into this one.

Parameter
Name Description
other MessageOptions
Remarks

See the user guide for precise merge semantics.

SetExtension<TValue>(Extension<MessageOptions, TValue>, TValue)

public void SetExtension<TValue>(Extension<MessageOptions, TValue> extension, TValue value)

Sets the value of the specified extension

Parameters
Name Description
extension ExtensionMessageOptions
value TValue
Type Parameter
Name Description
TValue

ToString()

public override string ToString()
Returns
Type Description
string
Overrides

WriteTo(CodedOutputStream)

public void WriteTo(CodedOutputStream output)

Writes the data to the given coded output stream.

Parameter
Name Description
output CodedOutputStream

Coded output stream to write the data to. Must not be null.

Extension Methods