Class FieldOptions (3.23.0)

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

Inheritance

object > FieldOptions

Namespace

Google.Protobuf.Reflection

Assembly

Google.Protobuf.dll

Constructors

FieldOptions()

public FieldOptions()

FieldOptions(FieldOptions)

public FieldOptions(FieldOptions other)
Parameter
NameDescription
otherFieldOptions

Fields

CtypeFieldNumber

public const int CtypeFieldNumber = 1

Field number for the "ctype" field.

Field Value
TypeDescription
int

DebugRedactFieldNumber

public const int DebugRedactFieldNumber = 16

Field number for the "debug_redact" field.

Field Value
TypeDescription
int

DeprecatedFieldNumber

public const int DeprecatedFieldNumber = 3

Field number for the "deprecated" field.

Field Value
TypeDescription
int

JstypeFieldNumber

public const int JstypeFieldNumber = 6

Field number for the "jstype" field.

Field Value
TypeDescription
int

LazyFieldNumber

public const int LazyFieldNumber = 5

Field number for the "lazy" field.

Field Value
TypeDescription
int

PackedFieldNumber

public const int PackedFieldNumber = 2

Field number for the "packed" field.

Field Value
TypeDescription
int

RetentionFieldNumber

public const int RetentionFieldNumber = 17

Field number for the "retention" field.

Field Value
TypeDescription
int

TargetFieldNumber

public const int TargetFieldNumber = 18

Field number for the "target" field.

Field Value
TypeDescription
int

TargetsFieldNumber

public const int TargetsFieldNumber = 19

Field number for the "targets" field.

Field Value
TypeDescription
int

UninterpretedOptionFieldNumber

public const int UninterpretedOptionFieldNumber = 999

Field number for the "uninterpreted_option" field.

Field Value
TypeDescription
int

UnverifiedLazyFieldNumber

public const int UnverifiedLazyFieldNumber = 15

Field number for the "unverified_lazy" field.

Field Value
TypeDescription
int

WeakFieldNumber

public const int WeakFieldNumber = 10

Field number for the "weak" field.

Field Value
TypeDescription
int

Properties

Ctype

public FieldOptions.Types.CType Ctype { get; set; }

The ctype option instructs the C++ code generator to use a different representation of the field than it normally would. See the specific options below. This option is only implemented to support use of [ctype=CORD] and [ctype=STRING] (the default) on non-repeated fields of type "bytes" in the open source release -- sorry, we'll try to include other types in a future version!

Property Value
TypeDescription
FieldOptionsTypesCType

DebugRedact

public bool DebugRedact { get; set; }

Indicate that the field value should not be printed out when using debug formats, e.g. when the field contains sensitive credentials.

Property Value
TypeDescription
bool

Deprecated

public bool Deprecated { get; set; }

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

Property Value
TypeDescription
bool

Descriptor

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

HasCtype

public bool HasCtype { get; }

Gets whether the "ctype" field is set

Property Value
TypeDescription
bool

HasDebugRedact

public bool HasDebugRedact { get; }

Gets whether the "debug_redact" field is set

Property Value
TypeDescription
bool

HasDeprecated

public bool HasDeprecated { get; }

Gets whether the "deprecated" field is set

Property Value
TypeDescription
bool

HasJstype

public bool HasJstype { get; }

Gets whether the "jstype" field is set

Property Value
TypeDescription
bool

HasLazy

public bool HasLazy { get; }

Gets whether the "lazy" field is set

Property Value
TypeDescription
bool

HasPacked

public bool HasPacked { get; }

Gets whether the "packed" field is set

Property Value
TypeDescription
bool

HasRetention

public bool HasRetention { get; }

Gets whether the "retention" field is set

Property Value
TypeDescription
bool

HasTarget

[Obsolete]
public bool HasTarget { get; }

Gets whether the "target" field is set

Property Value
TypeDescription
bool

HasUnverifiedLazy

public bool HasUnverifiedLazy { get; }

Gets whether the "unverified_lazy" field is set

Property Value
TypeDescription
bool

HasWeak

public bool HasWeak { get; }

Gets whether the "weak" field is set

Property Value
TypeDescription
bool

Jstype

public FieldOptions.Types.JSType Jstype { get; set; }

The jstype option determines the JavaScript type used for values of the field. The option is permitted only for 64 bit integral and fixed types (int64, uint64, sint64, fixed64, sfixed64). A field with jstype JS_STRING is represented as JavaScript string, which avoids loss of precision that can happen when a large value is converted to a floating point JavaScript. Specifying JS_NUMBER for the jstype causes the generated JavaScript code to use the JavaScript "number" type. The behavior of the default option JS_NORMAL is implementation dependent.

This option is an enum to permit additional types to be added, e.g. goog.math.Integer.

Property Value
TypeDescription
FieldOptionsTypesJSType

Lazy

public bool Lazy { get; set; }

Should this field be parsed lazily? Lazy applies only to message-type fields. It means that when the outer message is initially parsed, the inner message's contents will not be parsed but instead stored in encoded form. The inner message will actually be parsed when it is first accessed.

This is only a hint. Implementations are free to choose whether to use eager or lazy parsing regardless of the value of this option. However, setting this option true suggests that the protocol author believes that using lazy parsing on this field is worth the additional bookkeeping overhead typically needed to implement it.

This option does not affect the public interface of any generated code; all method signatures remain the same. Furthermore, thread-safety of the interface is not affected by this option; const methods remain safe to call from multiple threads concurrently, while non-const methods continue to require exclusive access.

Note that implementations may choose not to check required fields within a lazy sub-message. That is, calling IsInitialized() on the outer message may return true even if the inner message has missing required fields. This is necessary because otherwise the inner message would have to be parsed in order to perform the check, defeating the purpose of lazy parsing. An implementation which chooses not to check required fields must be consistent about it. That is, for any particular sub-message, the implementation must either always check its required fields, or never check its required fields, regardless of whether or not the message has been parsed.

As of May 2022, lazy verifies the contents of the byte stream during parsing. An invalid byte stream will cause the overall parsing to fail.

Property Value
TypeDescription
bool

Packed

public bool Packed { get; set; }

The packed option can be enabled for repeated primitive fields to enable a more efficient representation on the wire. Rather than repeatedly writing the tag and type for each element, the entire array is encoded as a single length-delimited blob. In proto3, only explicit setting it to false will avoid using packed encoding.

Property Value
TypeDescription
bool

Parser

public static MessageParser<FieldOptions> Parser { get; }
Property Value
TypeDescription
MessageParserFieldOptions

Retention

public FieldOptions.Types.OptionRetention Retention { get; set; }
Property Value
TypeDescription
FieldOptionsTypesOptionRetention

Target

[Obsolete]
public FieldOptions.Types.OptionTargetType Target { get; set; }
Property Value
TypeDescription
FieldOptionsTypesOptionTargetType

Targets

public RepeatedField<FieldOptions.Types.OptionTargetType> Targets { get; }
Property Value
TypeDescription
RepeatedFieldFieldOptionsTypesOptionTargetType

UninterpretedOption

public RepeatedField<UninterpretedOption> UninterpretedOption { get; }

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

Property Value
TypeDescription
RepeatedFieldUninterpretedOption

UnverifiedLazy

public bool UnverifiedLazy { get; set; }

unverified_lazy does no correctness checks on the byte stream. This should only be used where lazy with verification is prohibitive for performance reasons.

Property Value
TypeDescription
bool

Weak

public bool Weak { get; set; }

For Google-internal migration only. Do not use.

Property Value
TypeDescription
bool

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.

ClearCtype()

public void ClearCtype()

Clears the value of the "ctype" field

ClearDebugRedact()

public void ClearDebugRedact()

Clears the value of the "debug_redact" field

ClearDeprecated()

public void ClearDeprecated()

Clears the value of the "deprecated" field

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

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

Clears the value of the specified extension

Parameter
NameDescription
extensionExtensionFieldOptions
Type Parameter
NameDescription
TValue

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

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

Clears the value of the specified repeated extension

Parameter
NameDescription
extensionRepeatedExtensionFieldOptions
Type Parameter
NameDescription
TValue

ClearJstype()

public void ClearJstype()

Clears the value of the "jstype" field

ClearLazy()

public void ClearLazy()

Clears the value of the "lazy" field

ClearPacked()

public void ClearPacked()

Clears the value of the "packed" field

ClearRetention()

public void ClearRetention()

Clears the value of the "retention" field

ClearTarget()

[Obsolete]
public void ClearTarget()

Clears the value of the "target" field

ClearUnverifiedLazy()

public void ClearUnverifiedLazy()

Clears the value of the "unverified_lazy" field

ClearWeak()

public void ClearWeak()

Clears the value of the "weak" field

Clone()

public FieldOptions Clone()

Creates a deep clone of this object.

Returns
TypeDescription
FieldOptions

A deep clone of this object.

Equals(FieldOptions)

public bool Equals(FieldOptions other)
Parameter
NameDescription
otherFieldOptions
Returns
TypeDescription
bool

Equals(object)

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

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

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

Gets the value of the specified extension

Parameter
NameDescription
extensionExtensionFieldOptions
Returns
TypeDescription
TValue
Type Parameter
NameDescription
TValue

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

public RepeatedField<TValue> GetExtension<TValue>(RepeatedExtension<FieldOptions, 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
extensionRepeatedExtensionFieldOptions
Returns
TypeDescription
RepeatedField
Type Parameter
NameDescription
TValue

GetHashCode()

public override int GetHashCode()
Returns
TypeDescription
int
Overrides

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

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

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

Parameter
NameDescription
extensionRepeatedExtensionFieldOptions
Returns
TypeDescription
RepeatedField
Type Parameter
NameDescription
TValue

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

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

Gets whether the value of the specified extension is set

Parameter
NameDescription
extensionExtensionFieldOptions
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(FieldOptions)

public void MergeFrom(FieldOptions other)

Merges the given message into this one.

Parameter
NameDescription
otherFieldOptions
Remarks

See the user guide for precise merge semantics.

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

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

Sets the value of the specified extension

Parameters
NameDescription
extensionExtensionFieldOptions
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