This project is read-only.


Each value not captured by an option can be included in a collection of strings derived from System.Collections.Generic.IList<string>.
Obviously, this attribute has no name(s) and is derived directly from System.Attribute.
It's currently the only exception, but it's not excluded that in the future it will have similars.


namespace CommandLine
    public sealed class ValueListAttribute : System.Attribute
        public ValueListAttribute(Type concreteType);

        public int MaximumElements { get; set; }
  1. Must be assigned to a property of type IList<string>.
  2. The constructor must accept a type derived from IList<string> as List<string>.
  3. If the MaximumElements property is set to a number greater than 0, the parser will fail if the limit is exceeded.
  4. Set MaximumElements to 0 means that you do not accept values disassociated from options.
  5. The default implicit setting of MaximumElements (-1) allows an unlimited number of values.

Here is an example.


class Options
    // ...
    [ValueList(typeof(List<string>), MaximumElements = 3)]
    public IList<string> Items { get; set; };
    // ...

The following will be accepted.



GuideApp valueONE

GuideApp value-II value_three

GuideApp file0009.xml file0010.bin file0011.dat

The following will be refused.


GuideApp file0009.xml file0010.bin file0011.dat file0012.htm

Last edited May 15, 2012 at 9:13 AM by gsscoder, version 6


NirodhaSoftware Sep 19, 2014 at 3:39 PM 
There should be no semicolon on the end of: public IList<string> Items { get; set; };