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
NameDescription
otherMessageOptions

Fields

DeprecatedFieldNumber

public const int DeprecatedFieldNumber = 3

Field number for the "deprecated" field.

Field Value
TypeDescription
int

DeprecatedLegacyJsonFieldConflictsFieldNumber

public const int DeprecatedLegacyJsonFieldConflictsFieldNumber = 11

Field number for the "deprecated_legacy_json_field_conflicts" field.

Field Value
TypeDescription
int

MapEntryFieldNumber

public const int MapEntryFieldNumber = 7

Field number for the "map_entry" field.

Field Value
TypeDescription
int

MessageSetWireFormatFieldNumber

public const int MessageSetWireFormatFieldNumber = 1

Field number for the "message_set_wire_format" field.

Field Value
TypeDescription
int

NoStandardDescriptorAccessorFieldNumber

public const int NoStandardDescriptorAccessorFieldNumber = 2

Field number for the "no_standard_descriptor_accessor" field.

Field Value
TypeDescription
int

UninterpretedOptionFieldNumber

public const int UninterpretedOptionFieldNumber = 999

Field number for the "uninterpreted_option" field.

Field Value
TypeDescription
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
TypeDescription
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
TypeDescription
bool

Descriptor

public static MessageDescriptor Descriptor { get; }
Property Value
TypeDescription
MessageDescriptor

HasDeprecated

public bool HasDeprecated { get; }

Gets whether the "deprecated" field is set

Property Value
TypeDescription
bool

HasDeprecatedLegacyJsonFieldConflicts

[Obsolete]
public bool HasDeprecatedLegacyJsonFieldConflicts { get; }

Gets whether the "deprecated_legacy_json_field_conflicts" field is set

Property Value
TypeDescription
bool

HasMapEntry

public bool HasMapEntry { get; }

Gets whether the "map_entry" field is set

Property Value
TypeDescription
bool

HasMessageSetWireFormat

public bool HasMessageSetWireFormat { get; }

Gets whether the "message_set_wire_format" field is set

Property Value
TypeDescription
bool

HasNoStandardDescriptorAccessor

public bool HasNoStandardDescriptorAccessor { get; }

Gets whether the "no_standard_descriptor_accessor" field is set

Property Value
TypeDescription
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
TypeDescription
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
TypeDescription
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
TypeDescription
bool

Parser

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

UninterpretedOption

public RepeatedField<UninterpretedOption> UninterpretedOption { get; }

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

Property Value
TypeDescription
RepeatedFieldUninterpretedOption

Methods

CalculateSize()

public int CalculateSize()

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

Returns
TypeDescription
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
NameDescription
extensionExtensionMessageOptions
Type Parameter
NameDescription
TValue

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

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

Clears the value of the specified repeated extension

Parameter
NameDescription
extensionRepeatedExtensionMessageOptions
Type Parameter
NameDescription
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
TypeDescription
MessageOptions

A deep clone of this object.

Equals(MessageOptions)

public bool Equals(MessageOptions other)
Parameter
NameDescription
otherMessageOptions
Returns
TypeDescription
bool

Equals(object)

public override bool Equals(object other)
Parameter
NameDescription
otherobject
Returns
TypeDescription
bool
Overrides

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

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

Gets the value of the specified extension

Parameter
NameDescription
extensionExtensionMessageOptions
Returns
TypeDescription
TValue
Type Parameter
NameDescription
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
NameDescription
extensionRepeatedExtensionMessageOptions
Returns
TypeDescription
RepeatedField
Type Parameter
NameDescription
TValue

GetHashCode()

public override int GetHashCode()
Returns
TypeDescription
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
NameDescription
extensionRepeatedExtensionMessageOptions
Returns
TypeDescription
RepeatedField
Type Parameter
NameDescription
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
NameDescription
extensionExtensionMessageOptions
Returns
TypeDescription
bool
Type Parameter
NameDescription
TValue

MergeFrom(CodedInputStream)

public void MergeFrom(CodedInputStream input)

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

Parameter
NameDescription
inputCodedInputStream
Remarks

See the user guide for precise merge semantics.

MergeFrom(MessageOptions)

public void MergeFrom(MessageOptions other)

Merges the given message into this one.

Parameter
NameDescription
otherMessageOptions
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
NameDescription
extensionExtensionMessageOptions
valueTValue
Type Parameter
NameDescription
TValue

ToString()

public override string ToString()
Returns
TypeDescription
string
Overrides

WriteTo(CodedOutputStream)

public void WriteTo(CodedOutputStream output)

Writes the data to the given coded output stream.

Parameter
NameDescription
outputCodedOutputStream

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

Extension Methods