Class OptionMetadata
- Assembly
- McMaster.Extensions.CommandLineUtils.dll
Metadata about a command option, extracted at compile time or via reflection.
public sealed class OptionMetadata
- Inheritance
-
objectOptionMetadata
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
propertyNamestringThe name of the property this option maps to.
propertyTypeTypeThe CLR type of the property.
getterFunc<object, object>Delegate to get the property value from a model instance.
setterAction<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
Description
A description of this option.
public string? Description { get; init; }
Property Value
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
LongName
The long name (e.g., "name").
public string? LongName { get; init; }
Property Value
OptionType
The option type.
public CommandOptionType OptionType { get; init; }
Property Value
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
PropertyName
The name of the property this option maps to.
public string PropertyName { get; }
Property Value
PropertyType
The CLR type of the property.
public Type PropertyType { get; }
Property Value
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
ShowInHelpText
Whether this option appears in generated help text.
public bool ShowInHelpText { get; init; }
Property Value
SymbolName
The symbol name (e.g., "?").
public string? SymbolName { get; init; }
Property Value
Template
The option template (e.g., "-n|--name <VALUE>").
public string? Template { get; init; }
Property Value
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; }