Table of Contents

Class OptionMetadata

Namespace
McMaster.Extensions.CommandLineUtils.SourceGeneration
Assembly
McMaster.Extensions.CommandLineUtils.dll

Metadata about a command option, extracted at compile time or via reflection.

public sealed class OptionMetadata
Inheritance
object
OptionMetadata

Constructors

OptionMetadata(string, Type, Func<object, object?>, Action<object, object?>)

Initializes a new instance of the OptionMetadata class.

public OptionMetadata(string propertyName, Type propertyType, Func<object, object?> getter, Action<object, object?> setter)

Parameters

propertyName string

The name of the property this option maps to.

propertyType Type

The CLR type of the property.

getter Func<object, object>

Delegate to get the property value from a model instance.

setter Action<object, object>

Delegate to set the property value on a model instance.

Properties

DeclaringType

The type that declares this property.

public Type? DeclaringType { get; init; }

Property Value

Type

Description

A description of this option.

public string? Description { get; init; }

Property Value

string

Getter

Delegate to get the property value from a model instance.

public Func<object, object?> Getter { get; }

Property Value

Func<object, object>

Inherited

Whether subcommands should also have access to this option.

public bool Inherited { get; init; }

Property Value

bool

LongName

The long name (e.g., "name").

public string? LongName { get; init; }

Property Value

string

OptionType

The option type.

public CommandOptionType OptionType { get; init; }

Property Value

CommandOptionType

OptionTypeExplicitlySet

Whether the OptionType was explicitly set in the attribute (vs. inferred from property type). If true, skip parser validation at convention-apply time since a custom parser may be added later.

public bool OptionTypeExplicitlySet { get; init; }

Property Value

bool

PropertyName

The name of the property this option maps to.

public string PropertyName { get; }

Property Value

string

PropertyType

The CLR type of the property.

public Type PropertyType { get; }

Property Value

Type

Setter

Delegate to set the property value on a model instance.

public Action<object, object?> Setter { get; }

Property Value

Action<object, object>

ShortName

The short name (e.g., "n").

public string? ShortName { get; init; }

Property Value

string

ShowInHelpText

Whether this option appears in generated help text.

public bool ShowInHelpText { get; init; }

Property Value

bool

SymbolName

The symbol name (e.g., "?").

public string? SymbolName { get; init; }

Property Value

string

Template

The option template (e.g., "-n|--name <VALUE>").

public string? Template { get; init; }

Property Value

string

Validators

Validation attributes applied to this option.

public IReadOnlyList<ValidationAttribute> Validators { get; init; }

Property Value

IReadOnlyList<ValidationAttribute>

ValueName

The name of value(s) shown in help text.

public string? ValueName { get; init; }

Property Value

string