GeneratedParserAttribute Class

Indicates that the target arguments type should use source generation.

Definition

Namespace: Ookii.CommandLine
Assembly: Ookii.CommandLine (in Ookii.CommandLine.dll) Version: 4.2.0+a4d3631e4dcc0970081ed435288efdebc1325f83
C#
public sealed class GeneratedParserAttribute : Attribute
Inheritance
Object    Attribute    GeneratedParserAttribute

Remarks

When this attribute is applied to a class that defines command line arguments, source generation will be used to create a CommandLineParserT instance for those arguments, instead of the normal approach which uses run-time reflection.

To use the generated parser, source generation will add several static methods to the target class: the CreateParser(ParseOptions) method, and the Parse(ParseOptions) method and its overload. If you are targeting an older version of .Net than .Net 7.0, the same methods are added, but they will not implement the static interfaces.

Using these generated methods allows the use of trimming and native AOT for your application, as they avoid the regular constructors of the CommandLineParser and CommandLineParserT class, which are incompatible with these options.

When using source generation with subcommands, you should also use a class with the GeneratedCommandManagerAttribute attribute to access the commands.

Constructors

GeneratedParserAttributeInitializes a new instance of the GeneratedParserAttribute class

Properties

GenerateParseMethods Gets or sets a value that indicates whether to generate an implementation of the IParserTSelf interface for the arguments class.
TypeIdWhen implemented in a derived class, gets a unique identifier for this Attribute.
(Inherited from Attribute)

Methods

EqualsReturns a value that indicates whether this instance is equal to a specified object.
(Inherited from Attribute)
GetHashCodeReturns the hash code for this instance.
(Inherited from Attribute)
GetTypeGets the Type of the current instance.
(Inherited from Object)
IsDefaultAttributeWhen overridden in a derived class, indicates whether the value of this instance is the default value for the derived class.
(Inherited from Attribute)
MatchWhen overridden in a derived class, returns a value that indicates whether this instance equals a specified object.
(Inherited from Attribute)
ToStringReturns a string that represents the current object.
(Inherited from Object)

Thread Safety

Static members of this type are safe for multi-threaded operations. Instance members of this type are safe for multi-threaded operations.

See Also