Skip to content

Supported Argument Types#

Arguments can be defined with any type that...

  • is a primitive type:
  • contains a string constructor
  • has a TypeConverter

Includes, but not limited to:

  • string,char,enum,bool
  • short,int,long,decimal,double
  • Guid,Uri,FileInfo,DirectoryInfo

Also supports Nullable<T> and IEnumerable<T> (T[], List<T>, etc.) where T can be converted from string.


There can be only one List operand in the method, where List is any type of IEnumerable. List operands must be the last operand defined for the method.

Adding support for other types#

Options for supporting other types

  • If you control the type, consider adding a constructor with a single string parameter.
  • Create a TypeConverter for your type
  • Create a type descriptor

Type Descriptors#

Type descriptors are your best choice when you need

  • to override an existing TypeConverter
  • conditional logic based on argument metadata (custom attributes, etc)
  • the converter only for parsing parameters and not the business logic of your application

Implement IArgumentTypeDescriptor or instantiate a DelegatedTypeDescriptor and register with AppSettings.ArgumentTypeDescriptors.Register(...).

See StringCtorTypeDescriptor and ComponentModelTypeDescriptor for examples.

If the type has a limited range of acceptable values, the descriptor should also implement IAllowedValuesTypeDescriptor. See EnumTypeDescriptor for an example.