--- /dev/null
+<Type Name="Command" FullName="Mono.Options.Command">
+ <TypeSignature Language="C#" Value="public class Command" />
+ <TypeSignature Language="ILAsm" Value=".class public auto ansi beforefieldinit Command extends System.Object" />
+ <AssemblyInfo>
+ <AssemblyName>Mono.Options</AssemblyName>
+ <AssemblyVersion>0.2.3.0</AssemblyVersion>
+ </AssemblyInfo>
+ <ThreadingSafetyStatement>
+ Public <c>static</c> members of this type are thread safe.
+ Any instance members are not guaranteed to be thread safe.
+ </ThreadingSafetyStatement>
+ <Base>
+ <BaseTypeName>System.Object</BaseTypeName>
+ </Base>
+ <Interfaces />
+ <Docs>
+ <summary>
+ Represents a program command.
+ </summary>
+ <remarks>
+ <para>
+ Many command-line utilities are <i>suites</i> of commands, with a single
+ "outer" command and multiple commands. Examples of this style of
+ utility includes <b>git</b>, <b>svn</b>, and <b>mdoc</b>.
+ </para>
+ <para>
+ A <c>Command</c> represents a specific command in such a suite.
+ It has a <see cref="P:Mono.Options.Command.Name" /> which is the
+ command name for invocation purposes, optional help text through
+ the <see cref="P:Mono.Options.Command.Help" /> property, an optional
+ <see cref="T:Mono.Options.OptionSet" /> accessible through the
+ <see cref="P:Mono.Options.Command.Options" /> property for command-line
+ parsing, and two ways to have code executed when a command is
+ invoked: the <see cref="P:Mono.Options.Command.Run" /> property and
+ the <see cref="M:Mono.Options.Command.Invoke" /> method.
+ </para>
+ </remarks>
+ </Docs>
+ <Members>
+ <Member MemberName=".ctor">
+ <MemberSignature Language="C#" Value="public Command (string name, string help = null);" />
+ <MemberSignature Language="ILAsm" Value=".method public hidebysig specialname rtspecialname instance void .ctor(string name, string help) cil managed" />
+ <MemberType>Constructor</MemberType>
+ <AssemblyInfo>
+ <AssemblyVersion>0.2.3.0</AssemblyVersion>
+ </AssemblyInfo>
+ <Parameters>
+ <Parameter Name="name" Type="System.String" />
+ <Parameter Name="help" Type="System.String" />
+ </Parameters>
+ <Docs>
+ <param name="name">
+ A <see cref="T:System.String" /> which is the command name.
+ </param>
+ <param name="help">
+ A <see cref="T:System.String" /> which is the command help text.
+ </param>
+ <summary>
+ Creates and initializes a new instance of the <c>Command</c> class.
+ </summary>
+ <remarks>
+ <para>
+ This constructor initializes the
+ <see cref="P:Mono.Options.Command.Name" /> property of the new
+ instance using <paramref name="name" /> and initializes the
+ <see cref="P:Mono.Options.Command.Help" /> property of the new
+ instance using <paramref name="help" />.
+ </para>
+ </remarks>
+ <exception cref="T:System.ArgumentNullException">
+ <paramref name="name" /> is <see langword="null" />.
+ </exception>
+ </Docs>
+ </Member>
+ <Member MemberName="CommandSet">
+ <MemberSignature Language="C#" Value="public Mono.Options.CommandSet CommandSet { get; }" />
+ <MemberSignature Language="ILAsm" Value=".property instance class Mono.Options.CommandSet CommandSet" />
+ <MemberType>Property</MemberType>
+ <AssemblyInfo>
+ <AssemblyVersion>0.2.3.0</AssemblyVersion>
+ </AssemblyInfo>
+ <ReturnValue>
+ <ReturnType>Mono.Options.CommandSet</ReturnType>
+ </ReturnValue>
+ <Docs>
+ <summary>
+ A <see cref="T:Mono.Options.CommandSet" /> instance which owns the
+ <c>Command</c>.
+ </summary>
+ <value>
+ A <see cref="T:Mono.Options.CommandSet" /> instance which owns the
+ <c>Command</c>.
+ </value>
+ <remarks>
+ <para>
+ A <c>Command</c> instance may belong to only one
+ <see cref="T:Mono.Options.CommandSet" /> instance.
+ The <c>CommandSet</c> property is set upon calling
+ <see cref="M:Mono.Options.CommandSet.Add(Mono.Options.Command)" />.
+ </para>
+ <para>
+ If the <c>Command</c> instance has not yet been added to a
+ <c>CommandSet</c>, then this property is <see langword="null" />.
+ </para>
+ <para>
+ Use the <c>CommandSet</c> instance from either the
+ <see cref="P:Mono.Options.Command.Run" /> property or an overridden
+ <see cref="M:Mono.Options.Command.Invoke" /> method to access
+ localization facilities through
+ <see cref="P:Mono.Options.CommandSet.MessageLocalizer" />, the
+ preferred message output stream through
+ <see cref="P:Mono.Options.CommandSet.Out" />, and other features.
+ </para>
+ </remarks>
+ </Docs>
+ </Member>
+ <Member MemberName="Help">
+ <MemberSignature Language="C#" Value="public string Help { get; }" />
+ <MemberSignature Language="ILAsm" Value=".property instance string Help" />
+ <MemberType>Property</MemberType>
+ <AssemblyInfo>
+ <AssemblyVersion>0.2.3.0</AssemblyVersion>
+ </AssemblyInfo>
+ <ReturnValue>
+ <ReturnType>System.String</ReturnType>
+ </ReturnValue>
+ <Docs>
+ <summary>
+ A short, one-line, description of the <c>Command</c>.
+ </summary>
+ <value>
+ A <see cref="T:System.String" /> containing the optional help text
+ of the <c>Command</c>.
+ </value>
+ <remarks>
+ <para>
+ The <c>Help</c> property text is shown when the <c>help</c>
+ command is invoked.
+ </para>
+ </remarks>
+ </Docs>
+ </Member>
+ <Member MemberName="Invoke">
+ <MemberSignature Language="C#" Value="public virtual int Invoke (System.Collections.Generic.IEnumerable<string> arguments);" />
+ <MemberSignature Language="ILAsm" Value=".method public hidebysig newslot virtual instance int32 Invoke(class System.Collections.Generic.IEnumerable`1<string> arguments) cil managed" />
+ <MemberType>Method</MemberType>
+ <AssemblyInfo>
+ <AssemblyVersion>0.2.3.0</AssemblyVersion>
+ </AssemblyInfo>
+ <ReturnValue>
+ <ReturnType>System.Int32</ReturnType>
+ </ReturnValue>
+ <Parameters>
+ <Parameter Name="arguments" Type="System.Collections.Generic.IEnumerable<System.String>" />
+ </Parameters>
+ <Docs>
+ <param name="arguments">
+ A <see cref="T:System.Collections.Generic.IEnumerable{System.String}" />
+ which contains the unprocessed command-line arguments.
+ </param>
+ <summary>
+ Invoked by <see cref="M:Mono.Options.CommandSet.Run" /> when a command
+ has been executed.
+ </summary>
+ <returns>
+ A <see cref="T:System.Int32" /> which should be treated as the process
+ exit value.
+ </returns>
+ <remarks>
+ <para>
+ The value returned by <c>Invoke()</c> is the return value of
+ <see cref="M:Mono.Options.CommandSet.Run" />, and should be treated
+ as a possible process exit value.
+ </para>
+ <block subset="none" type="behaviors">
+ <para>
+ If the <c>Invoke()</c> method is not overridden by a subclass,
+ the <c>Invoke()</c> method will use
+ <see cref="P:Mono.Options.Command.Options" /> to parse
+ <paramref name="arguments" />, and pass any un-processed values
+ on to <see cref="P:Mono.Options.Command.Run" />.
+ </para>
+ <para>
+ If the <c>Options</c> property is <see langword="null" />, then no
+ option processing will occur, and <paramref name="arguments" />
+ will be provided to the <c>Run</c> property as-is.
+ </para>
+ <para>
+ If the <c>Run</c> property is <see langword="null" />, then
+ no further processing occurs.
+ </para>
+ </block>
+ <block subset="none" type="overrides">
+ <para>
+ Method overrides do not need to call the base class method.
+ </para>
+ </block>
+ </remarks>
+ </Docs>
+ </Member>
+ <Member MemberName="Name">
+ <MemberSignature Language="C#" Value="public string Name { get; }" />
+ <MemberSignature Language="ILAsm" Value=".property instance string Name" />
+ <MemberType>Property</MemberType>
+ <AssemblyInfo>
+ <AssemblyVersion>0.2.3.0</AssemblyVersion>
+ </AssemblyInfo>
+ <ReturnValue>
+ <ReturnType>System.String</ReturnType>
+ </ReturnValue>
+ <Docs>
+ <summary>
+ The name of the <c>Command</c>, which is used for command invocation.
+ </summary>
+ <value>
+ A <see cref="T:System.String" /> which is the name of the <c>Command</c>.
+ </value>
+ <remarks>
+ <para>
+ The <c>Name</c> value must be unique across all <c>Commmand</c> instances
+ referred to by a <see cref="T:Mono.Options.CommandSet" />.
+ </para>
+ </remarks>
+ </Docs>
+ </Member>
+ <Member MemberName="Options">
+ <MemberSignature Language="C#" Value="public Mono.Options.OptionSet Options { get; set; }" />
+ <MemberSignature Language="ILAsm" Value=".property instance class Mono.Options.OptionSet Options" />
+ <MemberType>Property</MemberType>
+ <AssemblyInfo>
+ <AssemblyVersion>0.2.3.0</AssemblyVersion>
+ </AssemblyInfo>
+ <ReturnValue>
+ <ReturnType>Mono.Options.OptionSet</ReturnType>
+ </ReturnValue>
+ <Docs>
+ <summary>
+ Optional command-line option information.
+ </summary>
+ <value>
+ A <see cref="T:Mono.Options.OptionSet" /> instance which contains the
+ available command-line options for the <c>Command</c>.
+ </value>
+ <remarks>
+ <para>
+ If the <c>Options</c> property is not <see langword="null" /> when
+ the command is processed,
+ <see cref="M:Mono.Options.OptionSet.Parse" /> will be invoked on
+ the <c>Options</c> instance, and the return value of
+ <c>OptionSet.Parse()</c> will be forwarded to
+ <see cref="M:Mono.Options.Command.Invoke" />.
+ </para>
+ </remarks>
+ </Docs>
+ </Member>
+ <Member MemberName="Run">
+ <MemberSignature Language="C#" Value="public Action<System.Collections.Generic.IEnumerable<string>> Run { get; set; }" />
+ <MemberSignature Language="ILAsm" Value=".property instance class System.Action`1<class System.Collections.Generic.IEnumerable`1<string>> Run" />
+ <MemberType>Property</MemberType>
+ <AssemblyInfo>
+ <AssemblyVersion>0.2.3.0</AssemblyVersion>
+ </AssemblyInfo>
+ <ReturnValue>
+ <ReturnType>System.Action<System.Collections.Generic.IEnumerable<System.String>></ReturnType>
+ </ReturnValue>
+ <Docs>
+ <summary>
+ Optional command handler.
+ </summary>
+ <value>
+ A <see cref="T:System.Action{System.Collections.Generic.IEnumerable{System.String}}" />
+ delegate which is executed by
+ <see cref="M:Mono.Options.Command.Invoke" />.
+ </value>
+ <remarks>
+ <para>
+ The <c>Run</c> property is executed by the the
+ <see cref="M:Mono.Options.Command.Invoke" /> method when
+ <see cref="M:Mono.Options.CommandSet.Run" /> dispatches to a
+ <c>Command</c> instance.
+ </para>
+ </remarks>
+ </Docs>
+ </Member>
+ </Members>
+</Type>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<Type Name="CommandSet" FullName="Mono.Options.CommandSet">
+ <TypeSignature Language="C#" Value="public class CommandSet : System.Collections.ObjectModel.KeyedCollection<string,Mono.Options.Command>" />
+ <TypeSignature Language="ILAsm" Value=".class public auto ansi beforefieldinit CommandSet extends System.Collections.ObjectModel.KeyedCollection`2<string, class Mono.Options.Command>" />
+ <AssemblyInfo>
+ <AssemblyName>Mono.Options</AssemblyName>
+ <AssemblyVersion>0.2.3.0</AssemblyVersion>
+ </AssemblyInfo>
+ <ThreadingSafetyStatement>
+ Public <c>static</c> members of this type are thread safe.
+ Any instance members are not guaranteed to be thread safe.
+ </ThreadingSafetyStatement>
+ <Base>
+ <BaseTypeName>System.Collections.ObjectModel.KeyedCollection<System.String,Mono.Options.Command></BaseTypeName>
+ <BaseTypeArguments>
+ <BaseTypeArgument TypeParamName="!0">System.String</BaseTypeArgument>
+ <BaseTypeArgument TypeParamName="!1">Mono.Options.Command</BaseTypeArgument>
+ </BaseTypeArguments>
+ </Base>
+ <Interfaces />
+ <Docs>
+ <summary>
+ A <i>suite</i> of commands, global program options, and associated documentation.
+ </summary>
+ <remarks>
+ <para>
+ A common requirement of some programs are discrete <i>commands</i>.
+ A <c>CommandSet</c> represents a <i>suite</i> of commands, intermixed
+ with suite documentation. Commands are managed by
+ <see cref="T:Mono.Options.Command" /> instances, which have a required
+ <i>name</i> and optional help text, and <c>CommandSet</c> will use the
+ intermixed documentation, options, and commands to produce <c>help</c>
+ command output.
+ </para>
+ <para>
+ To create a <c>CommandSet</c> instance, use the
+ <see cref="C:Mono.Options.CommandSet(System.String, System.Converter, System.IO.TextWriter, System.IO.TextWriter)" />
+ constructor. Only the suite name is required; all other parameters are
+ optional.
+ </para>
+ <para>
+ Once a <c>CommandSet</c> instance has been constructed, use the
+ <see cref="M:Mono.Options.CommandSet.Add" /> methods to add and
+ intermix suite documentation, global options, and commands.
+ Documentation is any string constant, global options are handled
+ by <see cref="T:Mono.Options.Option" /> instances and associated
+ <c>Add()</c> method overloads which implicitly create <c>Option</c>
+ instances, and commands are through <c>Command</c> instances.
+ </para>
+ <para>
+ Once the <c>CommandSet</c> instance has been initialized, call the
+ <see cref="M:Mono.Options.CommandSet.Run(System.String[])" />
+ method to process the arguments provided to <c>Main()</c>.
+ The appropriate <c>Command</c> instance will be determined, it's
+ options parsed, and <see cref="M:Mono.Options.Command.Invoke" />
+ will be executed. The return value of <c>Command.Invoke()</c>
+ is returned from <c>CommandSet.Run()</c>, and should be treated
+ as the process exit value.
+ </para>
+ </remarks>
+ <example>
+ <para>
+ The following <c>commands</c> example demonstrates some simple usage
+ of <see cref="T:Mono.Options.CommandSet" />.
+ </para>
+ <code lang="C#" src="examples/commands.cs">// Sub-commands with Mono.Options.CommandSet
+//
+// Compile as:
+// mcs -r:Mono.Options.dll commands.cs
+
+using System;
+using System.Collections.Generic;
+
+using Mono.Options;
+
+class CommandDemo {
+ public static int Main (string[] args)
+ {
+ var commands = new CommandSet ("commands") {
+ "usage: commands COMMAND [OPTIONS]",
+ "",
+ "Mono.Options.CommandSet sample app.",
+ "",
+ "Global options:",
+ { "v:",
+ "Output verbosity.",
+ (int? n) => Verbosity = n.HasValue ? n.Value : Verbosity + 1 },
+ "",
+ "Available commands:",
+ new Command ("echo", "Echo arguments to the screen") {
+ Run = ca => Console.WriteLine ("{0}", string.Join (" ", ca)),
+ },
+ new RequiresArgs (),
+ };
+ return commands.Run (args);
+ }
+
+ public static int Verbosity;
+}
+
+class RequiresArgs : Command {
+
+ public RequiresArgs ()
+ : base ("requires-args", "Class-based Command subclass")
+ {
+ Options = new OptionSet () {
+ "usage: commands requires-args [OPTIONS]",
+ "",
+ "Class-based Command subclass example.",
+ { "name|n=",
+ "{name} of person to greet.",
+ v => Name = v },
+ { "help|h|?",
+ "Show this message and exit.",
+ v => ShowHelp = v != null },
+ };
+ }
+
+ public bool ShowHelp {get; private set;}
+ public new string Name {get; private set;}
+
+ public override int Invoke (IEnumerable<string> args)
+ {
+ try {
+ var extra = Options.Parse (args);
+ if (ShowHelp) {
+ Options.WriteOptionDescriptions (CommandSet.Out);
+ return 0;
+ }
+ if (string.IsNullOrEmpty (Name)) {
+ Console.Error.WriteLine ("commands: Missing required argument `--name=NAME`.");
+ Console.Error.WriteLine ("commands: Use `commands help requires-args` for details.");
+ return 1;
+ }
+ Console.WriteLine ($"Hello, {Name}!");
+ return 0;
+ }
+ catch (Exception e) {
+ Console.Error.WriteLine ("commands: {0}", CommandDemo.Verbosity >= 1 ? e.ToString () : e.Message);
+ return 1;
+ }
+ }
+}
+</code>
+ <para>
+ The output, under the influence of different command-line arguments, is:
+ </para>
+ <code lang="sh" src="examples/commands.txt">$ mono commands.exe
+Use `commands help` for usage.
+
+$ mono commands.exe --help
+usage: commands COMMAND [OPTIONS]
+
+Mono.Options.CommandSet sample app.
+
+Global options:
+ -v[=VALUE] Output verbosity.
+
+Available commands:
+ echo Echo arguments to the screen
+ requires-args Class-based Command subclass
+
+$ mono commands.exe help
+usage: commands COMMAND [OPTIONS]
+
+Mono.Options.CommandSet sample app.
+
+Global options:
+ -v[=VALUE] Output verbosity.
+
+Available commands:
+ echo Echo arguments to the screen
+ requires-args Class-based Command subclass
+
+$ mono commands.exe help --help
+Usage: commands COMMAND [OPTIONS]
+Use `commands help COMMAND` for help on a specific command.
+
+Available commands:
+
+ echo Echo arguments to the screen
+ requires-args Class-based Command subclass
+ help Show this message and exit
+
+$ mono commands.exe help echo
+--help
+
+$ mono commands.exe echo --help
+--help
+
+$ mono commands.exe echo hello, world
+hello, world
+
+$ mono commands.exe requires-args
+commands: Missing required argument `--name=NAME`.
+commands: Use `commands help requires-args` for details.
+
+$ mono commands.exe help requires-args
+usage: commands requires-args [OPTIONS]
+
+Class-based Command subclass example.
+ --name, -n=name name of person to greet.
+ --help, -h, -? Show this message and exit.
+
+$ mono commands.exe requires-args --help
+usage: commands requires-args [OPTIONS]
+
+Class-based Command subclass example.
+ --name, -n=name name of person to greet.
+ --help, -h, -? Show this message and exit.
+
+$ mono commands.exe requires-args -n World
+Hello, World!
+
+$ mono commands.exe invalid-command
+commands: Unknown command: invalid-command
+commands: Use `commands help` for usage.
+
+$ mono commands.exe help invalid-command
+commands: Unknown command: invalid-command
+commands: Use `commands help` for usage.
+</code>
+ <para>
+ The <c>commands.exe</c> output is short, informing the user that
+ commands are required for use.
+ </para>
+ <para>
+ The <c>commands.exe --help</c> is identical to the <c>commands help</c>
+ output, and shows the provided suite documentation.
+ </para>
+ <para>
+ <c>commands.exe COMMAND --help</c> and <c>commands.exe help COMMAND</c>
+ output is likewise identical, and will attempt to generate documentation
+ for the specified command, if available. This is performed by invoking
+ <see cref="M:Mono.Options.Command.Invoke(System.Collections.Generic.IEnumerable{System.String})" />
+ with the value <c>{ "--help" }</c>. This can be seen in the
+ <c>commands.exe help echo</c> and <c>commands.exe echo --help</c>
+ output, which simply prints <c>--help</c>. If a command wants
+ to partake in <c>help COMMAND</c> support, it needs to explicitly
+ handle the <c>--help</c> option in its associated
+ <see cref="T:Mono.Options.OptionSet" /> instance, referenced by the
+ <see cref="P:Mono.Options.Command.Options" /> property.
+ </para>
+ <para>
+ Finally, if an invalid command is specified, then an error is written
+ to <see cref="P:Mono.Options.CommandSet.Error" />, prefixed with the
+ <see cref="P:Mono.Options.CommandSet.Suite" /> value.
+ </para>
+ </example>
+ </Docs>
+ <Members>
+ <Member MemberName=".ctor">
+ <MemberSignature Language="C#" Value="public CommandSet (string suite, Converter<string,string> localizer = null, System.IO.TextWriter output = null, System.IO.TextWriter error = null);" />
+ <MemberSignature Language="ILAsm" Value=".method public hidebysig specialname rtspecialname instance void .ctor(string suite, class System.Converter`2<string, string> localizer, class System.IO.TextWriter output, class System.IO.TextWriter error) cil managed" />
+ <MemberType>Constructor</MemberType>
+ <AssemblyInfo>
+ <AssemblyVersion>0.2.3.0</AssemblyVersion>
+ </AssemblyInfo>
+ <Parameters>
+ <Parameter Name="suite" Type="System.String" />
+ <Parameter Name="localizer" Type="System.Converter<System.String,System.String>" />
+ <Parameter Name="output" Type="System.IO.TextWriter" />
+ <Parameter Name="error" Type="System.IO.TextWriter" />
+ </Parameters>
+ <Docs>
+ <param name="suite">
+ A <see cref="T:System.String" /> containing the name of the suite.
+ This value is used in default <c>help</c> text output.
+ </param>
+ <param name="localizer">
+ A <see cref="T:System.Converter{System.String,System.String}" />
+ instance that will be used to translate strings.
+ If <see langword="null" />, then no localization is performed.
+ </param>
+ <param name="output">
+ A <see cref="T:System.IO.TextWriter" /> where output messages will be
+ written to. If <see langword="null" />, then the
+ <see cref="P:System.Console.Out" /> property will be used.
+ </param>
+ <param name="error">
+ A <see cref="T:System.IO.TextWriter" /> where error messages will be
+ written to. If <see langword="null" />, then the
+ <see cref="P:System.Console.Error" /> property will be used.
+ </param>
+ <summary>
+ Creates and initializes a new <c>CommandSet</c> instance.
+ </summary>
+ <remarks>
+ <para>
+ This constructor initializes
+ the <see cref="P:Mono.Options.CommandSet.Suite" /> property
+ of the new instance using <paramref name="suite" />,
+ the <see cref="P:Mono.Options.CommandSet.MessageLocalizer" /> property
+ of the new instance using <paramref name="localizer" />,
+ the <see cref="P:Mono.Options.CommandSet.Out" /> property
+ of the new instance using <paramref name="output" />, and
+ the <see cref="P:Mono.Options.CommandSet.Error" /> property
+ of the new instance using <paramref name="error" />.
+ </para>
+ </remarks>
+ <exception cref="T:System.ArgumentNullException">
+ <paramref name="suite" /> is <see langword="null" />.
+ </exception>
+ </Docs>
+ </Member>
+ <Member MemberName="Add">
+ <MemberSignature Language="C#" Value="public Mono.Options.CommandSet Add (Mono.Options.ArgumentSource source);" />
+ <MemberSignature Language="ILAsm" Value=".method public hidebysig instance class Mono.Options.CommandSet Add(class Mono.Options.ArgumentSource source) cil managed" />
+ <MemberType>Method</MemberType>
+ <AssemblyInfo>
+ <AssemblyVersion>0.2.3.0</AssemblyVersion>
+ </AssemblyInfo>
+ <ReturnValue>
+ <ReturnType>Mono.Options.CommandSet</ReturnType>
+ </ReturnValue>
+ <Parameters>
+ <Parameter Name="source" Type="Mono.Options.ArgumentSource" />
+ </Parameters>
+ <Docs>
+ <param name="source">
+ A <see cref="T:Mono.Options.ArgumentSource" /> to register for
+ argument processing.
+ </param>
+ <summary>
+ Registers <paramref name="source" /> so that it may be consulted
+ during argument processing within
+ <see cref="M:Mono.Options.CommandSet.Run(System.Collections.Generic.IEnumerable{System.String})" />.
+ </summary>
+ <returns>
+ The current <see cref="T:Mono.Options.CommandSet" /> instance.
+ This is to permit method chaining.
+ </returns>
+ <remarks>
+ </remarks>
+ <exception cref="T:System.ArgumentNullException">
+ <paramref name="source" /> is <see langword="null" />.
+ </exception>
+ </Docs>
+ </Member>
+ <Member MemberName="Add">
+ <MemberSignature Language="C#" Value="public Mono.Options.CommandSet Add (Mono.Options.Command value);" />
+ <MemberSignature Language="ILAsm" Value=".method public hidebysig instance class Mono.Options.CommandSet Add(class Mono.Options.Command value) cil managed" />
+ <MemberType>Method</MemberType>
+ <AssemblyInfo>
+ <AssemblyVersion>0.2.3.0</AssemblyVersion>
+ </AssemblyInfo>
+ <ReturnValue>
+ <ReturnType>Mono.Options.CommandSet</ReturnType>
+ </ReturnValue>
+ <Parameters>
+ <Parameter Name="value" Type="Mono.Options.Command" />
+ </Parameters>
+ <Docs>
+ <param name="value">
+ A <see cref="T:Mono.Options.Command" /> to add to the suite.
+ </param>
+ <summary>
+ Add a <c>Command</c> to the suite.
+ </summary>
+ <returns>
+ The current <see cref="T:Mono.Options.CommandSet" /> instance.
+ This is to permit method chaining.
+ </returns>
+ <remarks>
+ </remarks>
+ <exception cref="T:System.ArgumentException">
+ <para>
+ A <c>Command</c> with the same value for
+ <c><paramref name="value" />.Name</c>
+ has already been added to the <c>CommandSet</c>.
+ </para>
+ <para>-or-</para>
+ <para>
+ <paramref name="value" /> has been <c>Add()</c>ed to a different
+ <c>CommandSet</c> instance.
+ </para>
+ </exception>
+ <exception cref="T:System.ArgumentNullException">
+ <paramref name="value" /> is <see langword="null" />.
+ </exception>
+ </Docs>
+ </Member>
+ <Member MemberName="Add">
+ <MemberSignature Language="C#" Value="public Mono.Options.CommandSet Add (Mono.Options.Option option);" />
+ <MemberSignature Language="ILAsm" Value=".method public hidebysig instance class Mono.Options.CommandSet Add(class Mono.Options.Option option) cil managed" />
+ <MemberType>Method</MemberType>
+ <AssemblyInfo>
+ <AssemblyVersion>0.2.3.0</AssemblyVersion>
+ </AssemblyInfo>
+ <ReturnValue>
+ <ReturnType>Mono.Options.CommandSet</ReturnType>
+ </ReturnValue>
+ <Parameters>
+ <Parameter Name="option" Type="Mono.Options.Option" />
+ </Parameters>
+ <Docs>
+ <param name="option">
+ The <see cref="T:Mono.Options.Option" /> to register.
+ </param>
+ <summary>
+ Adds <paramref name="option" /> as a global suite option.
+ </summary>
+ <returns>
+ The current <see cref="T:Mono.Options.CommandSet" /> instance.
+ This is to permit method chaining.
+ </returns>
+ <remarks>
+ <para>
+ Registers each option name returned by
+ <see cref="M:Mono.Options.Option.GetNames" />, ensuring that any
+ option with a matching name will be handled by the
+ <paramref name="option" /> instance.
+ </para>
+ </remarks>
+ <exception cref="T:System.ArgumentException">
+ <paramref name="option" /> has an alias (as returned from
+ <see cref="M:Mono.Options.Option.GetNames" />) that conflicts with
+ a previously registered <see cref="T:Mono.Options.Option" />.
+ </exception>
+ <exception cref="T:System.ArgumentNullException">
+ <paramref name="option" /> is <see langword="null" />.
+ </exception>
+ </Docs>
+ </Member>
+ <Member MemberName="Add">
+ <MemberSignature Language="C#" Value="public Mono.Options.CommandSet Add (string header);" />
+ <MemberSignature Language="ILAsm" Value=".method public hidebysig instance class Mono.Options.CommandSet Add(string header) cil managed" />
+ <MemberType>Method</MemberType>
+ <AssemblyInfo>
+ <AssemblyVersion>0.2.3.0</AssemblyVersion>
+ </AssemblyInfo>
+ <ReturnValue>
+ <ReturnType>Mono.Options.CommandSet</ReturnType>
+ </ReturnValue>
+ <Parameters>
+ <Parameter Name="header" Type="System.String" />
+ </Parameters>
+ <Docs>
+ <param name="header">
+ A <see cref="T:System.String" /> containing the header to display
+ during <see cref="M:Mono.Options.CommandSet.Run" /><c>help</c> processing.
+ </param>
+ <summary>
+ Declare a header to be printed during for <c>help</c> output.
+ </summary>
+ <returns>
+ The current <see cref="T:Mono.Options.CommandSet" /> instance.
+ This is to permit method chaining.
+ </returns>
+ <remarks>
+ </remarks>
+ </Docs>
+ </Member>
+ <Member MemberName="Add">
+ <MemberSignature Language="C#" Value="public Mono.Options.CommandSet Add (string prototype, Mono.Options.OptionAction<string,string> action);" />
+ <MemberSignature Language="ILAsm" Value=".method public hidebysig instance class Mono.Options.CommandSet Add(string prototype, class Mono.Options.OptionAction`2<string, string> action) cil managed" />
+ <MemberType>Method</MemberType>
+ <AssemblyInfo>
+ <AssemblyVersion>0.2.3.0</AssemblyVersion>
+ </AssemblyInfo>
+ <ReturnValue>
+ <ReturnType>Mono.Options.CommandSet</ReturnType>
+ </ReturnValue>
+ <Parameters>
+ <Parameter Name="prototype" Type="System.String" />
+ <Parameter Name="action" Type="Mono.Options.OptionAction<System.String,System.String>" />
+ </Parameters>
+ <Docs>
+ <param name="prototype">
+ A <see cref="T:System.String" /> containing all option aliases to
+ register, an (optional) type specifier, and an (optional) value
+ separator list; see
+ <see cref="C:Mono.Options.Option(System.String,System.String,System.Int32)" />
+ for details.
+ </param>
+ <param name="action">
+ A <see cref="T:Mono.Options.OptionAction{System.String,System.String}" />
+ to invoke when an option is parsed.
+ </param>
+ <summary>
+ Registers each alias within <paramref name="prototype" /> so that any
+ options matching the aliases in <paramref name="prototype" /> will be
+ handled by <paramref name="action" /> during any subsequent
+ <see cref="M:Mono.Options.OptionSet.Parse(System.Collections.Generic.IEnumerable{System.String})" />
+ calls.
+ </summary>
+ <returns>
+ The current <see cref="T:Mono.Options.CommandSet" /> instance.
+ This is to permit method chaining.
+ </returns>
+ <remarks>
+ Calls
+ <see cref="M:Mono.Options.CommandSet.Add(System.String,System.String,Mono.Options.OptionAction{System.String,System.String})" />
+ with a <paramref name="description" /> value of
+ <see langword="null" />.
+ </remarks>
+ <altmember cref="M:Mono.Options.CommandSet.Add(System.String,System.String,Mono.Options.OptionAction{System.String,System.String})" />
+ <altmember cref="M:Mono.Options.CommandSet.Add(Mono.Options.Option)" />
+ <exception cref="T:System.ArgumentException">
+ <paramref name="prototype" /> has an alias (as returned from
+ <see cref="M:Mono.Options.Option.GetNames" />) that conflicts with
+ a previously registered <see cref="T:Mono.Options.Option" />.
+ </exception>
+ <exception cref="T:System.ArgumentNullException">
+ <para>
+ <paramref name="prototype" /> is <see langword="null" /></para>
+ <para>-or-</para>
+ <para>
+ <paramref name="action" /> is <see langword="null" /></para>
+ </exception>
+ </Docs>
+ </Member>
+ <Member MemberName="Add">
+ <MemberSignature Language="C#" Value="public Mono.Options.CommandSet Add (string prototype, Action<string> action);" />
+ <MemberSignature Language="ILAsm" Value=".method public hidebysig instance class Mono.Options.CommandSet Add(string prototype, class System.Action`1<string> action) cil managed" />
+ <MemberType>Method</MemberType>
+ <AssemblyInfo>
+ <AssemblyVersion>0.2.3.0</AssemblyVersion>
+ </AssemblyInfo>
+ <ReturnValue>
+ <ReturnType>Mono.Options.CommandSet</ReturnType>
+ </ReturnValue>
+ <Parameters>
+ <Parameter Name="prototype" Type="System.String" />
+ <Parameter Name="action" Type="System.Action<System.String>" />
+ </Parameters>
+ <Docs>
+ <param name="prototype">
+ A <see cref="T:System.String" /> containing all option aliases to
+ register, an (optional) type specifier, and an (optional) value
+ separator list; see
+ <see cref="C:Mono.Options.Option(System.String,System.String,System.Int32)" />
+ for details.
+ </param>
+ <param name="action">
+ A <see cref="T:System.Action{System.String}" />
+ to invoke when an option is parsed.
+ </param>
+ <summary>
+ Registers each alias within <paramref name="prototype" /> so that any
+ options matching the aliases in <paramref name="prototype" /> will be
+ handled by <paramref name="action" /> during any subsequent
+ <see cref="M:Mono.Options.CommandSet.Run(System.Collections.Generic.IEnumerable{System.String})" />
+ calls.
+ </summary>
+ <returns>
+ The current <see cref="T:Mono.Options.CommandSet" /> instance.
+ This is to permit method chaining.
+ </returns>
+ <remarks>
+ Calls
+ <see cref="M:Mono.Options.CommandSet.Add(System.String,System.String,System.Action{System.String})" />
+ with a <paramref name="description" /> value of
+ <see langword="null" />.
+ </remarks>
+ <altmember cref="M:Mono.Options.CommandSet.Add(System.String,System.String,System.Action{System.String})" />
+ <altmember cref="M:Mono.Options.CommandSet.Add(Mono.Options.Option)" />
+ <exception cref="T:System.ArgumentException">
+ <paramref name="prototype" /> has an alias (as returned from
+ <see cref="M:Mono.Options.Option.GetNames" />) that conflicts with
+ a previously registered <see cref="T:Mono.Options.Option" />.
+ </exception>
+ <exception cref="T:System.ArgumentNullException">
+ <para>
+ <paramref name="prototype" /> is <see langword="null" /></para>
+ <para>-or-</para>
+ <para>
+ <paramref name="action" /> is <see langword="null" /></para>
+ </exception>
+ </Docs>
+ </Member>
+ <Member MemberName="Add">
+ <MemberSignature Language="C#" Value="public Mono.Options.CommandSet Add (string prototype, string description, Mono.Options.OptionAction<string,string> action);" />
+ <MemberSignature Language="ILAsm" Value=".method public hidebysig instance class Mono.Options.CommandSet Add(string prototype, string description, class Mono.Options.OptionAction`2<string, string> action) cil managed" />
+ <MemberType>Method</MemberType>
+ <AssemblyInfo>
+ <AssemblyVersion>0.2.3.0</AssemblyVersion>
+ </AssemblyInfo>
+ <ReturnValue>
+ <ReturnType>Mono.Options.CommandSet</ReturnType>
+ </ReturnValue>
+ <Parameters>
+ <Parameter Name="prototype" Type="System.String" />
+ <Parameter Name="description" Type="System.String" />
+ <Parameter Name="action" Type="Mono.Options.OptionAction<System.String,System.String>" />
+ </Parameters>
+ <Docs>
+ <param name="prototype">
+ A <see cref="T:System.String" /> containing all option aliases to
+ register, an (optional) type specifier, and an (optional) value
+ separator list; see
+ <see cref="C:Mono.Options.Option(System.String,System.String,System.Int32)" />
+ for details.
+ </param>
+ <param name="description">
+ A <see cref="T:System.String" /> to be used to initialize
+ the <see cref="P:Mono.Options.Option.Description" /> property.
+ </param>
+ <param name="action">
+ A <see cref="T:Mono.Options.OptionAction{System.String,System.String}" />
+ to invoke when an option is parsed.
+ </param>
+ <summary>
+ Registers each alias within <paramref name="prototype" /> so that any
+ options matching the aliases in <paramref name="prototype" /> will be
+ handled by <paramref name="action" /> during any subsequent
+ <see cref="M:Mono.Options.CommandSet.Run(System.Collections.Generic.IEnumerable{System.String})" />
+ calls.
+ </summary>
+ <returns>
+ The current <see cref="T:Mono.Options.CommandSet" /> instance.
+ This is to permit method chaining.
+ </returns>
+ <remarks>
+ <para>
+ Use this method when <paramref name="prototype" /> should accept
+ two values, generally a key and a value.
+ </para>
+ <block subset="none" type="note">
+ If <paramref name="prototype" /> specifies a
+ <see cref="F:Mono.Options.OptionValueType.Optional" /> option,
+ then it's possible that both the key and the value will be
+ <see langword="null" /> in the callback function.
+ </block>
+ </remarks>
+ <altmember cref="M:Mono.Options.CommandSet.Add(Mono.Options.Option)" />
+ <exception cref="T:System.ArgumentException">
+ <paramref name="prototype" /> has an alias (as returned from
+ <see cref="M:Mono.Options.Option.GetNames" />) that conflicts with
+ a previously registered <see cref="T:Mono.Options.Option" />.
+ </exception>
+ <exception cref="T:System.ArgumentNullException">
+ <para>
+ <paramref name="prototype" /> is <see langword="null" /></para>
+ <para>-or-</para>
+ <para>
+ <paramref name="action" /> is <see langword="null" /></para>
+ </exception>
+ </Docs>
+ </Member>
+ <Member MemberName="Add">
+ <MemberSignature Language="C#" Value="public Mono.Options.CommandSet Add (string prototype, string description, Action<string> action);" />
+ <MemberSignature Language="ILAsm" Value=".method public hidebysig instance class Mono.Options.CommandSet Add(string prototype, string description, class System.Action`1<string> action) cil managed" />
+ <MemberType>Method</MemberType>
+ <AssemblyInfo>
+ <AssemblyVersion>0.2.3.0</AssemblyVersion>
+ </AssemblyInfo>
+ <ReturnValue>
+ <ReturnType>Mono.Options.CommandSet</ReturnType>
+ </ReturnValue>
+ <Parameters>
+ <Parameter Name="prototype" Type="System.String" />
+ <Parameter Name="description" Type="System.String" />
+ <Parameter Name="action" Type="System.Action<System.String>" />
+ </Parameters>
+ <Docs>
+ <param name="prototype">
+ A <see cref="T:System.String" /> containing all option aliases to
+ register, an (optional) type specifier, and an (optional) value
+ separator list; see
+ <see cref="C:Mono.Options.Option(System.String,System.String,System.Int32)" />
+ for details.
+ </param>
+ <param name="description">
+ A <see cref="T:System.String" /> containing to used to initialize
+ the <see cref="P:Mono.Options.Option.Description" /> property.
+ </param>
+ <param name="action">
+ A <see cref="T:System.Action{System.String}" />
+ to invoke when an option is parsed.
+ </param>
+ <summary>
+ Registers each alias within <paramref name="prototype" /> so that any
+ options matching the aliases in <paramref name="prototype" /> will be
+ handled by <paramref name="action" /> during any subsequent
+ <see cref="M:Mono.Options.CommandSet.Run(System.Collections.Generic.IEnumerable{System.String})" />
+ calls.
+ </summary>
+ <returns>
+ The current <see cref="T:Mono.Options.CommandSet" /> instance.
+ This is to permit method chaining.
+ </returns>
+ <remarks>
+ </remarks>
+ <altmember cref="M:Mono.Options.CommandSet.Add(Mono.Options.Option)" />
+ <exception cref="T:System.ArgumentException">
+ <paramref name="option" /> has an alias (as returned from
+ <see cref="M:Mono.Options.Option.GetNames" />) that conflicts with
+ a previously registered <see cref="T:Mono.Options.Option" />.
+ </exception>
+ <exception cref="T:System.ArgumentNullException">
+ <para>
+ <paramref name="prototype" /> is <see langword="null" /></para>
+ <para>-or-</para>
+ <para>
+ <paramref name="action" /> is <see langword="null" /></para>
+ </exception>
+ </Docs>
+ </Member>
+ <Member MemberName="Add">
+ <MemberSignature Language="C#" Value="public Mono.Options.CommandSet Add (string prototype, string description, Mono.Options.OptionAction<string,string> action, bool hidden);" />
+ <MemberSignature Language="ILAsm" Value=".method public hidebysig instance class Mono.Options.CommandSet Add(string prototype, string description, class Mono.Options.OptionAction`2<string, string> action, bool hidden) cil managed" />
+ <MemberType>Method</MemberType>
+ <AssemblyInfo>
+ <AssemblyVersion>0.2.3.0</AssemblyVersion>
+ </AssemblyInfo>
+ <ReturnValue>
+ <ReturnType>Mono.Options.CommandSet</ReturnType>
+ </ReturnValue>
+ <Parameters>
+ <Parameter Name="prototype" Type="System.String" />
+ <Parameter Name="description" Type="System.String" />
+ <Parameter Name="action" Type="Mono.Options.OptionAction<System.String,System.String>" />
+ <Parameter Name="hidden" Type="System.Boolean" />
+ </Parameters>
+ <Docs>
+ <param name="prototype">
+ A <see cref="T:System.String" /> containing all option aliases to
+ register, an (optional) type specifier, and an (optional) value
+ separator list; see
+ <see cref="C:Mono.Options.Option(System.String,System.String,System.Int32)" />
+ for details.
+ </param>
+ <param name="description">
+ A <see cref="T:System.String" /> containing to used to initialize
+ the <see cref="P:Mono.Options.Option.Description" /> property.
+ </param>
+ <param name="action">
+ A <see cref="T:Mono.Options.OptionAction{System.String,System.String}" />
+ to invoke when an option is parsed.
+ </param>
+ <param name="hidden">
+ A <see cref="T:System.Boolean" /> specifying whether or not the
+ Option should be displayed in
+ <see cref="M:Mono.Options.CommandSet.Run" /><c>help</c> output.
+ </param>
+ <summary>
+ Registers each alias within <paramref name="prototype" /> so that any
+ options matching the aliases in <paramref name="prototype" /> will be
+ handled by <paramref name="action" /> during any subsequent
+ <see cref="M:Mono.Options.CommandSet.Run(System.Collections.Generic.IEnumerable{System.String})" />
+ calls.
+ </summary>
+ <returns>
+ The current <see cref="T:Mono.Options.CommandSet" /> instance.
+ This is to permit method chaining.
+ </returns>
+ <remarks>
+ </remarks>
+ <altmember cref="M:Mono.Options.CommandSet.Add(Mono.Options.Option)" />
+ <exception cref="T:System.ArgumentException">
+ <paramref name="option" /> has an alias (as returned from
+ <see cref="M:Mono.Options.Option.GetNames" />) that conflicts with
+ a previously registered <see cref="T:Mono.Options.Option" />.
+ </exception>
+ <exception cref="T:System.ArgumentNullException">
+ <para>
+ <paramref name="prototype" /> is <see langword="null" /></para>
+ <para>-or-</para>
+ <para>
+ <paramref name="action" /> is <see langword="null" /></para>
+ </exception>
+ </Docs>
+ </Member>
+ <Member MemberName="Add">
+ <MemberSignature Language="C#" Value="public Mono.Options.CommandSet Add (string prototype, string description, Action<string> action, bool hidden);" />
+ <MemberSignature Language="ILAsm" Value=".method public hidebysig instance class Mono.Options.CommandSet Add(string prototype, string description, class System.Action`1<string> action, bool hidden) cil managed" />
+ <MemberType>Method</MemberType>
+ <AssemblyInfo>
+ <AssemblyVersion>0.2.3.0</AssemblyVersion>
+ </AssemblyInfo>
+ <ReturnValue>
+ <ReturnType>Mono.Options.CommandSet</ReturnType>
+ </ReturnValue>
+ <Parameters>
+ <Parameter Name="prototype" Type="System.String" />
+ <Parameter Name="description" Type="System.String" />
+ <Parameter Name="action" Type="System.Action<System.String>" />
+ <Parameter Name="hidden" Type="System.Boolean" />
+ </Parameters>
+ <Docs>
+ <param name="prototype">
+ A <see cref="T:System.String" /> containing all option aliases to
+ register, an (optional) type specifier, and an (optional) value
+ separator list; see
+ <see cref="C:Mono.Options.Option(System.String,System.String,System.Int32)" />
+ for details.
+ </param>
+ <param name="description">
+ A <see cref="T:System.String" /> containing to used to initialize
+ the <see cref="P:Mono.Options.Option.Description" /> property.
+ </param>
+ <param name="action">
+ A <see cref="T:System.Action{System.String}" />
+ to invoke when an option is parsed.
+ </param>
+ <param name="hidden">
+ A <see cref="T:System.Boolean" /> specifying whether or not the
+ Option should be displayed in
+ <see cref="M:Mono.Options.CommandSet.Run" /><c>help</c> output.
+ </param>
+ <summary>
+ Registers each alias within <paramref name="prototype" /> so that any
+ options matching the aliases in <paramref name="prototype" /> will be
+ handled by <paramref name="action" /> during any subsequent
+ <see cref="M:Mono.Options.CommandSet.Run(System.Collections.Generic.IEnumerable{System.String})" />
+ calls.
+ </summary>
+ <returns>
+ The current <see cref="T:Mono.Options.CommandSet" /> instance.
+ This is to permit method chaining.
+ </returns>
+ <remarks>
+ </remarks>
+ <altmember cref="M:Mono.Options.OptionSet.Add(Mono.Options.Option)" />
+ <exception cref="T:System.ArgumentException">
+ <paramref name="option" /> has an alias (as returned from
+ <see cref="M:Mono.Options.Option.GetNames" />) that conflicts with
+ a previously registered <see cref="T:Mono.Options.Option" />.
+ </exception>
+ <exception cref="T:System.ArgumentNullException">
+ <para>
+ <paramref name="prototype" /> is <see langword="null" /></para>
+ <para>-or-</para>
+ <para>
+ <paramref name="action" /> is <see langword="null" /></para>
+ </exception>
+ </Docs>
+ </Member>
+ <Member MemberName="Add<T>">
+ <MemberSignature Language="C#" Value="public Mono.Options.CommandSet Add<T> (string prototype, Action<T> action);" />
+ <MemberSignature Language="ILAsm" Value=".method public hidebysig instance class Mono.Options.CommandSet Add<T>(string prototype, class System.Action`1<!!T> action) cil managed" />
+ <MemberType>Method</MemberType>
+ <AssemblyInfo>
+ <AssemblyVersion>0.2.3.0</AssemblyVersion>
+ </AssemblyInfo>
+ <ReturnValue>
+ <ReturnType>Mono.Options.CommandSet</ReturnType>
+ </ReturnValue>
+ <TypeParameters>
+ <TypeParameter Name="T" />
+ </TypeParameters>
+ <Parameters>
+ <Parameter Name="prototype" Type="System.String" />
+ <Parameter Name="action" Type="System.Action<T>" />
+ </Parameters>
+ <Docs>
+ <typeparam name="T">
+ The type of the option to parse and provide to the
+ <paramref name="action" /> callback.
+ </typeparam>
+ <param name="prototype">
+ A <see cref="T:System.String" /> containing all option aliases to
+ register, an (optional) type specifier, and an (optional) value
+ separator list; see
+ <see cref="C:Mono.Options.Option(System.String,System.String,System.Int32)" />
+ for details.
+ </param>
+ <param name="action">
+ A <see cref="T:System.Action{``0}" />
+ to invoke when an option is parsed.
+ </param>
+ <summary>
+ Registers each alias within <paramref name="prototype" /> so that any
+ options matching the aliases in <paramref name="prototype" /> will be
+ handled by <paramref name="action" /> during any subsequent
+ <see cref="M:Mono.Options.CommandSet.Run(System.Collections.Generic.IEnumerable{System.String})" />
+ calls.
+ </summary>
+ <returns>
+ The current <see cref="T:Mono.Options.CommandSet" /> instance.
+ This is to permit method chaining.
+ </returns>
+ <remarks>
+ Calls
+ <see cref="M:Mono.Options.OptionSet.Add``1(System.String,System.String,System.Action{``0})" />
+ with a <paramref name="description" /> value of
+ <see langword="null" />.
+ </remarks>
+ <altmember cref="M:Mono.Options.CommandSet.Add(Mono.Options.Option)" />
+ <altmember cref="M:Mono.Options.CommandSet.Add``1(System.String,System.String,System.Action{``0})" />
+ <exception cref="T:System.ArgumentException">
+ <paramref name="option" /> has an alias (as returned from
+ <see cref="M:Mono.Options.Option.GetNames" />) that conflicts with
+ a previously registered <see cref="T:Mono.Options.Option" />.
+ </exception>
+ </Docs>
+ </Member>
+ <Member MemberName="Add<T>">
+ <MemberSignature Language="C#" Value="public Mono.Options.CommandSet Add<T> (string prototype, string description, Action<T> action);" />
+ <MemberSignature Language="ILAsm" Value=".method public hidebysig instance class Mono.Options.CommandSet Add<T>(string prototype, string description, class System.Action`1<!!T> action) cil managed" />
+ <MemberType>Method</MemberType>
+ <AssemblyInfo>
+ <AssemblyVersion>0.2.3.0</AssemblyVersion>
+ </AssemblyInfo>
+ <ReturnValue>
+ <ReturnType>Mono.Options.CommandSet</ReturnType>
+ </ReturnValue>
+ <TypeParameters>
+ <TypeParameter Name="T" />
+ </TypeParameters>
+ <Parameters>
+ <Parameter Name="prototype" Type="System.String" />
+ <Parameter Name="description" Type="System.String" />
+ <Parameter Name="action" Type="System.Action<T>" />
+ </Parameters>
+ <Docs>
+ <typeparam name="T">
+ The type of the option to parse and provide to the
+ <paramref name="action" /> callback.
+ </typeparam>
+ <param name="prototype">
+ A <see cref="T:System.String" /> containing all option aliases to
+ register, an (optional) type specifier, and an (optional) value
+ separator list; see
+ <see cref="C:Mono.Options.Option(System.String,System.String,System.Int32)" />
+ for details.
+ </param>
+ <param name="description">
+ A <see cref="T:System.String" /> containing to used to initialize
+ the <see cref="P:Mono.Options.Option.Description" /> property.
+ </param>
+ <param name="action">
+ A <see cref="T:System.Action{``0}" />
+ to invoke when an option is parsed.
+ </param>
+ <summary>
+ Registers each alias within <paramref name="prototype" /> so that any
+ options matching the aliases in <paramref name="prototype" /> will be
+ handled by <paramref name="action" /> during any subsequent
+ <see cref="M:Mono.Options.CommandSet.Run(System.Collections.Generic.IEnumerable{System.String})" />
+ calls.
+ </summary>
+ <returns>
+ The current <see cref="T:Mono.Options.CommandSet" /> instance.
+ This is to permit method chaining.
+ </returns>
+ <remarks>
+ <para>
+ Use this typed overload when you want strongly typed option values
+ that correspond to a managed type.
+ <see cref="M:System.ComponentModel.TypeDescriptor.GetConverter(System.Type)" />
+ is used to lookup the
+ <see cref="T:System.ComponentModel.TypeConverter" /> to use when
+ performing the string-to-type conversion.
+ </para>
+ <para>
+ Special support is provided for <see cref="T:System.Nullable{X}" />
+ types; <see cref="T:System.ComponentModel.TypeConverter" />
+ doesn't currently support their use, but if
+ <typeparamref name="T" /> is a nullable type, then this method
+ will instead use the
+ <see cref="T:System.ComponentModel.TypeConverter" /> for the
+ <typeparamref name="X" /> type. This allows straightforward use
+ of nullable types, identical to using any other strongly typed
+ value.
+ </para>
+ <block subset="none" type="note">
+ <para>
+ If <paramref name="prototype" /> specifies an
+ <see cref="F:Mono.Options.OptionValueType.Optional" /> value
+ and the value is not provided, then <c>default(T)</c> is
+ provided as the value to <paramref name="action" />.
+ </para>
+ </block>
+ </remarks>
+ <altmember cref="M:Mono.Options.OptionSet.Add(Mono.Options.Option)" />
+ <exception cref="T:System.ArgumentException">
+ <paramref name="option" /> has an alias (as returned from
+ <see cref="M:Mono.Options.Option.GetNames" />) that conflicts with
+ a previously registered <see cref="T:Mono.Options.Option" />.
+ </exception>
+ <exception cref="T:System.ArgumentNullException">
+ <para>
+ <paramref name="prototype" /> is <see langword="null" /></para>
+ <para>-or-</para>
+ <para>
+ <paramref name="action" /> is <see langword="null" /></para>
+ </exception>
+ </Docs>
+ </Member>
+ <Member MemberName="Add<TKey,TValue>">
+ <MemberSignature Language="C#" Value="public Mono.Options.CommandSet Add<TKey,TValue> (string prototype, Mono.Options.OptionAction<TKey,TValue> action);" />
+ <MemberSignature Language="ILAsm" Value=".method public hidebysig instance class Mono.Options.CommandSet Add<TKey, TValue>(string prototype, class Mono.Options.OptionAction`2<!!TKey, !!TValue> action) cil managed" />
+ <MemberType>Method</MemberType>
+ <AssemblyInfo>
+ <AssemblyVersion>0.2.3.0</AssemblyVersion>
+ </AssemblyInfo>
+ <ReturnValue>
+ <ReturnType>Mono.Options.CommandSet</ReturnType>
+ </ReturnValue>
+ <TypeParameters>
+ <TypeParameter Name="TKey" />
+ <TypeParameter Name="TValue" />
+ </TypeParameters>
+ <Parameters>
+ <Parameter Name="prototype" Type="System.String" />
+ <Parameter Name="action" Type="Mono.Options.OptionAction<TKey,TValue>" />
+ </Parameters>
+ <Docs>
+ <typeparam name="TKey">
+ The type of the first argument to parse and provide to the
+ <paramref name="action" /> callback.
+ </typeparam>
+ <typeparam name="TValue">
+ The type of the second argument to parse and provide to the
+ <paramref name="action" /> callback.
+ </typeparam>
+ <param name="prototype">
+ A <see cref="T:System.String" /> containing all option aliases to
+ register, an (optional) type specifier, and an (optional) value
+ separator list; see
+ <see cref="C:Mono.Options.Option(System.String,System.String,System.Int32)" />
+ for details.
+ </param>
+ <param name="action">
+ A <see cref="T:Mono.Options.OptionAction{TKey,TValue}" />
+ to invoke when an option is parsed.
+ </param>
+ <summary>
+ Registers each alias within <paramref name="prototype" /> so that any
+ options matching the aliases in <paramref name="prototype" /> will be
+ handled by <paramref name="action" /> during any subsequent
+ <see cref="M:Mono.Options.CommandSet.Run(System.Collections.Generic.IEnumerable{System.String})" />
+ calls.
+ </summary>
+ <returns>
+ The current <see cref="T:Mono.Options.CommandSet" /> instance.
+ This is to permit method chaining.
+ </returns>
+ <remarks>
+ Calls
+ <see cref="M:Mono.Options.OptionSet.Add``2(System.String,System.String,Mono.Options.OptionAction{``0,``1})" />
+ with a <paramref name="description" /> value of
+ <see langword="null" />.
+ </remarks>
+ <altmember cref="M:Mono.Options.CommandSet.Add(Mono.Options.Option)" />
+ <altmember cref="M:Mono.Options.CommandSet.Add``2(System.String,System.String,Mono.Options.OptionAction{``0,``1})" />
+ <exception cref="T:System.ArgumentException">
+ <paramref name="prototype" /> has an alias (as returned from
+ <see cref="M:Mono.Options.Option.GetNames" />) that conflicts with
+ a previously registered <see cref="T:Mono.Options.Option" />.
+ </exception>
+ <exception cref="T:System.ArgumentNullException">
+ <para>
+ <paramref name="prototype" /> is <see langword="null" /></para>
+ <para>-or-</para>
+ <para>
+ <paramref name="action" /> is <see langword="null" /></para>
+ </exception>
+ </Docs>
+ </Member>
+ <Member MemberName="Add<TKey,TValue>">
+ <MemberSignature Language="C#" Value="public Mono.Options.CommandSet Add<TKey,TValue> (string prototype, string description, Mono.Options.OptionAction<TKey,TValue> action);" />
+ <MemberSignature Language="ILAsm" Value=".method public hidebysig instance class Mono.Options.CommandSet Add<TKey, TValue>(string prototype, string description, class Mono.Options.OptionAction`2<!!TKey, !!TValue> action) cil managed" />
+ <MemberType>Method</MemberType>
+ <AssemblyInfo>
+ <AssemblyVersion>0.2.3.0</AssemblyVersion>
+ </AssemblyInfo>
+ <ReturnValue>
+ <ReturnType>Mono.Options.CommandSet</ReturnType>
+ </ReturnValue>
+ <TypeParameters>
+ <TypeParameter Name="TKey" />
+ <TypeParameter Name="TValue" />
+ </TypeParameters>
+ <Parameters>
+ <Parameter Name="prototype" Type="System.String" />
+ <Parameter Name="description" Type="System.String" />
+ <Parameter Name="action" Type="Mono.Options.OptionAction<TKey,TValue>" />
+ </Parameters>
+ <Docs>
+ <typeparam name="TKey">
+ The type of the first argument to parse and provide to the
+ <paramref name="action" /> callback.
+ </typeparam>
+ <typeparam name="TValue">
+ The type of the second argument to parse and provide to the
+ <paramref name="action" /> callback.
+ </typeparam>
+ <param name="prototype">
+ A <see cref="T:System.String" /> containing all option aliases to
+ register, an (optional) type specifier, and an (optional) value
+ separator list; see
+ <see cref="C:Mono.Options.Option(System.String,System.String,System.Int32)" />
+ for details.
+ </param>
+ <param name="description">
+ A <see cref="T:System.String" /> to be used to initialize
+ the <see cref="P:Mono.Options.Option.Description" /> property.
+ </param>
+ <param name="action">
+ A <see cref="T:Mono.Options.OptionAction{TKey,TValue}" />
+ to invoke when an option is parsed.
+ </param>
+ <summary>
+ Registers each alias within <paramref name="prototype" /> so that any
+ options matching the aliases in <paramref name="prototype" /> will be
+ handled by <paramref name="action" /> during any subsequent
+ <see cref="M:Mono.Options.CommandSet.Run(System.Collections.Generic.IEnumerable{System.String})" />
+ calls.
+ </summary>
+ <returns>
+ The current <see cref="T:Mono.Options.CommandSet" /> instance.
+ This is to permit method chaining.
+ </returns>
+ <remarks>
+ <para>
+ Use this method when <paramref name="prototype" /> should accept
+ two typed values, generally a key and a value.
+ </para>
+ <block subset="none" type="note">
+ <para>
+ If <paramref name="prototype" /> specifies an
+ <see cref="F:Mono.Options.OptionValueType.Optional" /> value
+ and the value is not provided, then <c>default(TKey)</c> and
+ <c>default(TValue)</c> may be provided as the values to
+ <paramref name="action" />.
+ </para>
+ </block>
+ </remarks>
+ <altmember cref="M:Mono.Options.CommandSet.Add(Mono.Options.Option)" />
+ <exception cref="T:System.ArgumentException">
+ <paramref name="prototype" /> has an alias (as returned from
+ <see cref="M:Mono.Options.Option.GetNames" />) that conflicts with
+ a previously registered <see cref="T:Mono.Options.Option" />.
+ </exception>
+ <exception cref="T:System.ArgumentNullException">
+ <para>
+ <paramref name="prototype" /> is <see langword="null" /></para>
+ <para>-or-</para>
+ <para>
+ <paramref name="action" /> is <see langword="null" /></para>
+ </exception>
+ </Docs>
+ </Member>
+ <Member MemberName="Error">
+ <MemberSignature Language="C#" Value="public System.IO.TextWriter Error { get; }" />
+ <MemberSignature Language="ILAsm" Value=".property instance class System.IO.TextWriter Error" />
+ <MemberType>Property</MemberType>
+ <AssemblyInfo>
+ <AssemblyVersion>0.2.3.0</AssemblyVersion>
+ </AssemblyInfo>
+ <ReturnValue>
+ <ReturnType>System.IO.TextWriter</ReturnType>
+ </ReturnValue>
+ <Docs>
+ <summary>
+ Where <c>CommandSet</c> should write error messages.
+ </summary>
+ <value>
+ A <see cref="T:System.IO.TextWriter" /> where error messages will
+ be written to.
+ </value>
+ <remarks>
+ <para>
+ This value may be set by providing the <paramref name="error" />
+ constructor parameter. If not specified, then
+ <see cref="P:System.Console.Error" /> will be used.
+ </para>
+ <para>
+ Error messages by <c>CommandSet</c> are written to the <c>Error</c>
+ property. <c>Command</c> instances may also choose to write error
+ messages to the <c>CommandSet.Error</c> property. This is suggested
+ to help with unit testing.
+ </para>
+ </remarks>
+ </Docs>
+ </Member>
+ <Member MemberName="GetKeyForItem">
+ <MemberSignature Language="C#" Value="protected override string GetKeyForItem (Mono.Options.Command item);" />
+ <MemberSignature Language="ILAsm" Value=".method familyhidebysig virtual instance string GetKeyForItem(class Mono.Options.Command item) cil managed" />
+ <MemberType>Method</MemberType>
+ <AssemblyInfo>
+ <AssemblyVersion>0.2.3.0</AssemblyVersion>
+ </AssemblyInfo>
+ <ReturnValue>
+ <ReturnType>System.String</ReturnType>
+ </ReturnValue>
+ <Parameters>
+ <Parameter Name="item" Type="Mono.Options.Command" />
+ </Parameters>
+ <Docs>
+ <param name="item">
+ An <see cref="T:Mono.Options.Command" /> to return the key of.
+ </param>
+ <summary>
+ Returns <c><paramref name="item" />.Name</c>.
+ </summary>
+ <returns>
+ A <see cref="T:System.String" /> containing the command name.
+ </returns>
+ <remarks>
+ <para>
+ This is to support the
+ <see cref="T:System.Collections.ObjectModel.KeyedCollection{System.String,Mono.Options.Command}" />
+ infrastructure.
+ </para>
+ </remarks>
+ </Docs>
+ </Member>
+ <Member MemberName="MessageLocalizer">
+ <MemberSignature Language="C#" Value="public Converter<string,string> MessageLocalizer { get; }" />
+ <MemberSignature Language="ILAsm" Value=".property instance class System.Converter`2<string, string> MessageLocalizer" />
+ <MemberType>Property</MemberType>
+ <AssemblyInfo>
+ <AssemblyVersion>0.2.3.0</AssemblyVersion>
+ </AssemblyInfo>
+ <ReturnValue>
+ <ReturnType>System.Converter<System.String,System.String></ReturnType>
+ </ReturnValue>
+ <Docs>
+ <summary>
+ Permits access to the message localization facility.
+ </summary>
+ <value>
+ A <see cref="T:System.Converter{System.String,System.String}" />
+ that can be used to localize messages.
+ </value>
+ <remarks>
+ </remarks>
+ </Docs>
+ </Member>
+ <Member MemberName="Out">
+ <MemberSignature Language="C#" Value="public System.IO.TextWriter Out { get; }" />
+ <MemberSignature Language="ILAsm" Value=".property instance class System.IO.TextWriter Out" />
+ <MemberType>Property</MemberType>
+ <AssemblyInfo>
+ <AssemblyVersion>0.2.3.0</AssemblyVersion>
+ </AssemblyInfo>
+ <ReturnValue>
+ <ReturnType>System.IO.TextWriter</ReturnType>
+ </ReturnValue>
+ <Docs>
+ <summary>
+ Where <c>CommandSet</c> should write output messages.
+ </summary>
+ <value>
+ A <see cref="T:System.IO.TextWriter" /> where output messages will
+ be written to.
+ </value>
+ <remarks>
+ <para>
+ This value may be set by providing the <paramref name="output" />
+ constructor parameter. If not specified, then
+ <see cref="P:System.Console.Out" /> will be used.
+ </para>
+ <para>
+ Output messages by <c>CommandSet</c> are written to the <c>Out</c>
+ property. <c>Command</c> instances may also choose to write output
+ messages to the <c>CommandSet.Out</c> property. This is suggested
+ to help with unit testing.
+ </para>
+ </remarks>
+ </Docs>
+ </Member>
+ <Member MemberName="Run">
+ <MemberSignature Language="C#" Value="public int Run (System.Collections.Generic.IEnumerable<string> arguments);" />
+ <MemberSignature Language="ILAsm" Value=".method public hidebysig instance int32 Run(class System.Collections.Generic.IEnumerable`1<string> arguments) cil managed" />
+ <MemberType>Method</MemberType>
+ <AssemblyInfo>
+ <AssemblyVersion>0.2.3.0</AssemblyVersion>
+ </AssemblyInfo>
+ <ReturnValue>
+ <ReturnType>System.Int32</ReturnType>
+ </ReturnValue>
+ <Parameters>
+ <Parameter Name="arguments" Type="System.Collections.Generic.IEnumerable<System.String>" />
+ </Parameters>
+ <Docs>
+ <param name="arguments">
+ A <see cref="T:System.Collections.Generic.IEnumerable{System.String}" />
+ containing the command-line arguments to process.
+ </param>
+ <summary>
+ Processes command-line arguments and invokes the specified command.
+ </summary>
+ <returns>
+ A <see cref="T:System.Int32" /> containing the command's exit value.
+ Normal Unix process exit values should be used: <c>0</c> for success,
+ non-zero values for failures.
+ </returns>
+ <remarks>
+ <para>
+ Processes <paramref name="arguments" />, parsing global options in the first pass.
+ The first unprocessed argument is treated as a command name, and the
+ <see cref="T:Mono.Options.Command" /> instance with a
+ <see cref="P:Mono.Options.Command.Name" /> value matching the command name
+ has its <see cref="M:Mono.Options.Command.Invoke" /> method invoked with the
+ unprocessed arguments.
+ </para>
+ <block subset="none" type="behaviors">
+ <para>
+ If no command is specified within <paramref name="arguments" /><i>or</i> an invalid command name is specified, then <c>1</c> is returned.
+ Otherwise, the value returned from
+ <see cref="M:Mono.Options.Command.Invoke" /> is returned.
+ </para>
+ </block>
+ <para>
+ If the <c>help</c> command is provided with no arguments, then the
+ suite help text will be written to
+ <see cref="P:Mono.Options.CommandSet.Out" />
+ consisting of the descriptive text ("headers"), options, and
+ <c>Command</c> values provided to
+ <see cref="M:Mono.Options.CommandSet.Add" />.
+ </para>
+ <para>
+ If the <c>help</c> command is provided with <c>--help</c> as an
+ argument, then all registered <c>Command</c> instances are written to
+ <see cref="P:Mono.Options.CommandSet.Out" />.
+ </para>
+ <para>
+ If the <c>help</c> command is provided with any other string, the
+ following value is treated as a command name, and the output of
+ <c>command --help</c> is written to
+ <see cref="P:Mono.Options.CommandSet.Out" />. If the specified
+ command name has not been registered, then an error message is written to
+ <see cref="P:Mono.Options.CommandSet.Error" />.
+ </para>
+ </remarks>
+ </Docs>
+ </Member>
+ <Member MemberName="Suite">
+ <MemberSignature Language="C#" Value="public string Suite { get; }" />
+ <MemberSignature Language="ILAsm" Value=".property instance string Suite" />
+ <MemberType>Property</MemberType>
+ <AssemblyInfo>
+ <AssemblyVersion>0.2.3.0</AssemblyVersion>
+ </AssemblyInfo>
+ <ReturnValue>
+ <ReturnType>System.String</ReturnType>
+ </ReturnValue>
+ <Docs>
+ <summary>
+ The name of the suite.
+ </summary>
+ <value>
+ A <see cref="T:System.String" /> containing the name of the command suite.
+ </value>
+ <remarks>
+ <para>
+ The <c>Suite</c> value is used when no command is specified, or
+ when an unregistered command name is provided.
+ </para>
+ </remarks>
+ </Docs>
+ </Member>
+ </Members>
+</Type>
\ No newline at end of file
--- /dev/null
+<Type Name="HelpCommand" FullName="Mono.Options.HelpCommand">
+ <TypeSignature Language="C#" Value="public class HelpCommand : Mono.Options.Command" />
+ <TypeSignature Language="ILAsm" Value=".class public auto ansi beforefieldinit HelpCommand extends Mono.Options.Command" />
+ <AssemblyInfo>
+ <AssemblyName>Mono.Options</AssemblyName>
+ <AssemblyVersion>0.2.3.0</AssemblyVersion>
+ </AssemblyInfo>
+ <Base>
+ <BaseTypeName>Mono.Options.Command</BaseTypeName>
+ </Base>
+ <Interfaces />
+ <Docs>
+ <summary>To be added.</summary>
+ <remarks>To be added.</remarks>
+ </Docs>
+ <Members>
+ <Member MemberName=".ctor">
+ <MemberSignature Language="C#" Value="public HelpCommand ();" />
+ <MemberSignature Language="ILAsm" Value=".method public hidebysig specialname rtspecialname instance void .ctor() cil managed" />
+ <MemberType>Constructor</MemberType>
+ <AssemblyInfo>
+ <AssemblyVersion>0.2.3.0</AssemblyVersion>
+ </AssemblyInfo>
+ <Parameters />
+ <Docs>
+ <summary>To be added.</summary>
+ <remarks>To be added.</remarks>
+ </Docs>
+ </Member>
+ <Member MemberName="Invoke">
+ <MemberSignature Language="C#" Value="public override int Invoke (System.Collections.Generic.IEnumerable<string> arguments);" />
+ <MemberSignature Language="ILAsm" Value=".method public hidebysig virtual instance int32 Invoke(class System.Collections.Generic.IEnumerable`1<string> arguments) cil managed" />
+ <MemberType>Method</MemberType>
+ <AssemblyInfo>
+ <AssemblyVersion>0.2.3.0</AssemblyVersion>
+ </AssemblyInfo>
+ <ReturnValue>
+ <ReturnType>System.Int32</ReturnType>
+ </ReturnValue>
+ <Parameters>
+ <Parameter Name="arguments" Type="System.Collections.Generic.IEnumerable<System.String>" />
+ </Parameters>
+ <Docs>
+ <param name="arguments">To be added.</param>
+ <summary>To be added.</summary>
+ <returns>To be added.</returns>
+ <remarks>To be added.</remarks>
+ </Docs>
+ </Member>
+ </Members>
+</Type>
<remarks>
</remarks>
<exception cref="T:System.ArgumentNullException">
- <paramref name="option" /> is <see langword="null" />.
+ <paramref name="source" /> is <see langword="null" />.
</exception>
</Docs>
</Member>
</returns>
<remarks>
<para>
- The <c>Add(string)</c> method can be used to provide option groupin
- in the output generatedy by
+ The <c>Add(string)</c> method can be used to provide option grouping
+ in the output generated by
<see cref="M:Mono.Options.OptionSet.WriteOptionDescriptions(System.IO.TextWriter)" />.
</para>
</remarks>
--- /dev/null
+// Sub-commands with Mono.Options.CommandSet
+//
+// Compile as:
+// mcs -r:Mono.Options.dll commands.cs
+
+using System;
+using System.Collections.Generic;
+
+using Mono.Options;
+
+class CommandDemo {
+ public static int Main (string[] args)
+ {
+ var commands = new CommandSet ("commands") {
+ "usage: commands COMMAND [OPTIONS]",
+ "",
+ "Mono.Options.CommandSet sample app.",
+ "",
+ "Global options:",
+ { "v:",
+ "Output verbosity.",
+ (int? n) => Verbosity = n.HasValue ? n.Value : Verbosity + 1 },
+ "",
+ "Available commands:",
+ new Command ("echo", "Echo arguments to the screen") {
+ Run = ca => Console.WriteLine ("{0}", string.Join (" ", ca)),
+ },
+ new RequiresArgs (),
+ };
+ return commands.Run (args);
+ }
+
+ public static int Verbosity;
+}
+
+class RequiresArgs : Command {
+
+ public RequiresArgs ()
+ : base ("requires-args", "Class-based Command subclass")
+ {
+ Options = new OptionSet () {
+ "usage: commands requires-args [OPTIONS]",
+ "",
+ "Class-based Command subclass example.",
+ { "name|n=",
+ "{name} of person to greet.",
+ v => Name = v },
+ { "help|h|?",
+ "Show this message and exit.",
+ v => ShowHelp = v != null },
+ };
+ }
+
+ public bool ShowHelp {get; private set;}
+ public new string Name {get; private set;}
+
+ public override int Invoke (IEnumerable<string> args)
+ {
+ try {
+ var extra = Options.Parse (args);
+ if (ShowHelp) {
+ Options.WriteOptionDescriptions (CommandSet.Out);
+ return 0;
+ }
+ if (string.IsNullOrEmpty (Name)) {
+ Console.Error.WriteLine ("commands: Missing required argument `--name=NAME`.");
+ Console.Error.WriteLine ("commands: Use `commands help requires-args` for details.");
+ return 1;
+ }
+ Console.WriteLine ($"Hello, {Name}!");
+ return 0;
+ }
+ catch (Exception e) {
+ Console.Error.WriteLine ("commands: {0}", CommandDemo.Verbosity >= 1 ? e.ToString () : e.Message);
+ return 1;
+ }
+ }
+}
--- /dev/null
+mono Documentation/en/examples/commands.exe
+
+mono Documentation/en/examples/commands.exe --help
+
+mono Documentation/en/examples/commands.exe help
+
+mono Documentation/en/examples/commands.exe help --help
+
+mono Documentation/en/examples/commands.exe help echo
+
+mono Documentation/en/examples/commands.exe echo --help
+
+mono Documentation/en/examples/commands.exe echo hello, world
+
+mono Documentation/en/examples/commands.exe requires-args
+
+mono Documentation/en/examples/commands.exe help requires-args
+
+mono Documentation/en/examples/commands.exe requires-args --help
+
+mono Documentation/en/examples/commands.exe requires-args -n World
+
+mono Documentation/en/examples/commands.exe invalid-command
+
+mono Documentation/en/examples/commands.exe help invalid-command
--- /dev/null
+$ mono commands.exe
+Use `commands help` for usage.
+
+$ mono commands.exe --help
+usage: commands COMMAND [OPTIONS]
+
+Mono.Options.CommandSet sample app.
+
+Global options:
+ -v[=VALUE] Output verbosity.
+
+Available commands:
+ echo Echo arguments to the screen
+ requires-args Class-based Command subclass
+
+$ mono commands.exe help
+usage: commands COMMAND [OPTIONS]
+
+Mono.Options.CommandSet sample app.
+
+Global options:
+ -v[=VALUE] Output verbosity.
+
+Available commands:
+ echo Echo arguments to the screen
+ requires-args Class-based Command subclass
+
+$ mono commands.exe help --help
+Usage: commands COMMAND [OPTIONS]
+Use `commands help COMMAND` for help on a specific command.
+
+Available commands:
+
+ echo Echo arguments to the screen
+ requires-args Class-based Command subclass
+ help Show this message and exit
+
+$ mono commands.exe help echo
+--help
+
+$ mono commands.exe echo --help
+--help
+
+$ mono commands.exe echo hello, world
+hello, world
+
+$ mono commands.exe requires-args
+commands: Missing required argument `--name=NAME`.
+commands: Use `commands help requires-args` for details.
+
+$ mono commands.exe help requires-args
+usage: commands requires-args [OPTIONS]
+
+Class-based Command subclass example.
+ --name, -n=name name of person to greet.
+ --help, -h, -? Show this message and exit.
+
+$ mono commands.exe requires-args --help
+usage: commands requires-args [OPTIONS]
+
+Class-based Command subclass example.
+ --name, -n=name name of person to greet.
+ --help, -h, -? Show this message and exit.
+
+$ mono commands.exe requires-args -n World
+Hello, World!
+
+$ mono commands.exe invalid-command
+commands: Unknown command: invalid-command
+commands: Use `commands help` for usage.
+
+$ mono commands.exe help invalid-command
+commands: Unknown command: invalid-command
+commands: Use `commands help` for usage.
<Attribute>
<AttributeName>System.Reflection.AssemblyTitle("Mono.Options.dll")</AttributeName>
</Attribute>
+ <Attribute>
+ <AttributeName>System.Runtime.CompilerServices.CompilationRelaxations(8)</AttributeName>
+ </Attribute>
<Attribute>
<AttributeName>System.Runtime.CompilerServices.RuntimeCompatibility(WrapNonExceptionThrows=true)</AttributeName>
</Attribute>
<Types>
<Namespace Name="Mono.Options">
<Type Name="ArgumentSource" Kind="Class" />
+ <Type Name="Command" Kind="Class" />
+ <Type Name="CommandSet" Kind="Class" />
+ <Type Name="HelpCommand" Kind="Class" />
<Type Name="Option" Kind="Class" />
<Type Name="OptionAction`2" DisplayName="OptionAction<TKey,TValue>" Kind="Delegate" />
<Type Name="OptionContext" Kind="Class" />
include ../../build/library.make
+test-local: Mono.Options-PCL.dll
+
+clean-local: clean-pcl
+
+Mono.Options-PCL.dll: Mono.Options.dll.sources $(shell cat Mono.Options.dll.sources)
+ $(CSCOMPILE) -target:library -out:$@ -debug+ -d:PCL -r:../lib/$(PROFILE)/System.dll @$<
+
+clean-pcl:
+ -rm Mono.Options-PCL.dll
+
install-local: install-source
uninstall-local: uninstall-source
DOC_EXAMPLES_OUTPUT = \
Documentation/en/examples/bundling.txt \
+ Documentation/en/examples/commands.txt \
Documentation/en/examples/context.txt \
Documentation/en/examples/greet.txt \
Documentation/en/examples/localization.txt \
Documentation/en/examples/Mono.Options.dll: $(the_lib)
cp $^ $@
- -cp $^.mdb $@.mdb
%.exe: %.cs Documentation/en/examples/Mono.Options.dll
- $(CSCOMPILE) -debug+ -r:Mono.Posix.dll -r:System.Core.dll -lib:Documentation/en/examples -r:Mono.Options.dll -out:$@ $<
+ $(CSCOMPILE) -debug:portable -r:$(topdir)/class/lib/$(PROFILE)/Mono.Posix.dll -r:$(topdir)/class/lib/$(PROFILE)/System.Core.dll -r:$(topdir)/class/lib/$(PROFILE)/System.dll \
+ -r:$(topdir)/class/lib/$(PROFILE)/Mono.Options.dll -out:$@ $<
Documentation/en/examples/locale/es/LC_MESSAGES/localization.mo: Documentation/en/examples/localization-es.po
msgfmt $< -o $@
// Options.cs
//
// Authors:
-// Jonathan Pryor <jpryor@novell.com>
+// Jonathan Pryor <jpryor@novell.com>, <Jonathan.Pryor@microsoft.com>
// Federico Di Gregorio <fog@initd.org>
// Rolf Bjarne Kvinge <rolf@xamarin.com>
//
// Copyright (C) 2008 Novell (http://www.novell.com)
// Copyright (C) 2009 Federico Di Gregorio.
// Copyright (C) 2012 Xamarin Inc (http://www.xamarin.com)
+// Copyright (C) 2017 Microsoft Corporation (http://www.microsoft.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
//
// Compile With:
-// gmcs -debug+ -r:System.Core Options.cs -o:NDesk.Options.dll
-// gmcs -debug+ -d:LINQ -r:System.Core Options.cs -o:NDesk.Options.dll
+// mcs -debug+ -r:System.Core Options.cs -o:Mono.Options.dll
+// mcs -debug+ -d:LINQ -r:System.Core Options.cs -o:Mono.Options.dll
//
// The LINQ version just changes the implementation of
// OptionSet.Parse(IEnumerable<string>), and confers no semantic changes.
//
// A Getopt::Long-inspired option parsing library for C#.
//
-// NDesk.Options.OptionSet is built upon a key/value table, where the
+// Mono.Options.OptionSet is built upon a key/value table, where the
// key is a option format string and the value is a delegate that is
// invoked when the format string is matched.
//
// p.Parse (new string[]{"-a-"}); // sets v == null
//
+//
+// Mono.Options.CommandSet allows easily having separate commands and
+// associated command options, allowing creation of a *suite* along the
+// lines of **git**(1), **svn**(1), etc.
+//
+// CommandSet allows intermixing plain text strings for `--help` output,
+// Option values -- as supported by OptionSet -- and Command instances,
+// which have a name, optional help text, and an optional OptionSet.
+//
+// var suite = new CommandSet ("suite-name") {
+// // Use strings and option values, as with OptionSet
+// "usage: suite-name COMMAND [OPTIONS]+",
+// { "v:", "verbosity", (int? v) => Verbosity = v.HasValue ? v.Value : Verbosity+1 },
+// // Commands may also be specified
+// new Command ("command-name", "command help") {
+// Options = new OptionSet {/*...*/},
+// Run = args => { /*...*/},
+// },
+// new MyCommandSubclass (),
+// };
+// return suite.Run (new string[]{...});
+//
+// CommandSet provides a `help` command, and forwards `help COMMAND`
+// to the registered Command instance by invoking Command.Invoke()
+// with `--help` as an option.
+//
+
using System;
using System.Collections;
using System.Collections.Generic;
? new[]{prototype + this.GetHashCode ()}
: prototype.Split ('|');
- if (this is OptionSet.Category)
+ if (this is OptionSet.Category || this is CommandOption)
return;
this.type = ParsePrototype ();
protected abstract void OnParseComplete (OptionContext c);
+ internal void InvokeOnParseComplete (OptionContext c)
+ {
+ OnParseComplete (c);
+ }
+
public override string ToString ()
{
return Prototype;
public class OptionSet : KeyedCollection<string, Option>
{
public OptionSet ()
- : this (delegate (string f) {return f;})
+ : this (null)
{
}
public OptionSet (MessageLocalizerConverter localizer)
{
+ this.roSources = new ReadOnlyCollection<ArgumentSource> (sources);
this.localizer = localizer;
- this.roSources = new ReadOnlyCollection<ArgumentSource>(sources);
+ if (this.localizer == null) {
+ this.localizer = delegate (string f) {
+ return f;
+ };
+ }
}
MessageLocalizerConverter localizer;
public MessageLocalizerConverter MessageLocalizer {
get {return localizer;}
+ internal set {localizer = value;}
}
List<ArgumentSource> sources = new List<ArgumentSource> ();
private const int Description_FirstWidth = 80 - OptionWidth;
private const int Description_RemWidth = 80 - OptionWidth - 2;
+ static readonly string CommandHelpIndentStart = new string (' ', OptionWidth);
+ static readonly string CommandHelpIndentRemaining = new string (' ', OptionWidth + 2);
+
public void WriteOptionDescriptions (TextWriter o)
{
foreach (Option p in this) {
WriteDescription (o, p.Description, "", 80, 80);
continue;
}
+ CommandOption co = p as CommandOption;
+ if (co != null) {
+ WriteCommandDescription (o, co.Command);
+ continue;
+ }
if (!WriteOptionPrototype (o, p, ref written))
continue;
}
}
+ internal void WriteCommandDescription (TextWriter o, Command c)
+ {
+ var name = new string (' ', 8) + c.Name;
+ if (name.Length < OptionWidth - 1) {
+ WriteDescription (o, name + new string (' ', OptionWidth - name.Length) + c.Help, CommandHelpIndentRemaining, 80, Description_RemWidth);
+ } else {
+ WriteDescription (o, name, "", 80, 80);
+ WriteDescription (o, CommandHelpIndentStart + c.Help, CommandHelpIndentRemaining, 80, Description_RemWidth);
+ }
+ }
+
void WriteDescription (TextWriter o, string value, string prefix, int firstWidth, int remWidth)
{
bool indent = false;
return StringCoda.WrappedLines (description, firstWidth, remWidth);
}
}
+
+ public class Command
+ {
+ public string Name {get;}
+ public string Help {get;}
+
+ public OptionSet Options {get; set;}
+ public Action<IEnumerable<string>> Run {get; set;}
+
+ public CommandSet CommandSet {get; internal set;}
+
+ public Command (string name, string help = null)
+ {
+ if (string.IsNullOrEmpty (name))
+ throw new ArgumentNullException (nameof (name));
+
+ Name = name;
+ Help = help;
+ }
+
+ public virtual int Invoke (IEnumerable<string> arguments)
+ {
+ var rest = Options?.Parse (arguments) ?? arguments;
+ Run?.Invoke (rest);
+ return 0;
+ }
+ }
+
+ class CommandOption : Option
+ {
+ public Command Command {get;}
+
+ // Prototype starts with '=' because this is an invalid prototype
+ // (see Option.ParsePrototype(), and thus it'll prevent Category
+ // instances from being accidentally used as normal options.
+ public CommandOption (Command command, bool hidden = false)
+ : base ("=:Command:= " + command?.Name, command?.Name, maxValueCount: 0, hidden: hidden)
+ {
+ if (command == null)
+ throw new ArgumentNullException (nameof (command));
+ Command = command;
+ }
+
+ protected override void OnParseComplete (OptionContext c)
+ {
+ throw new NotSupportedException ("CommandOption.OnParseComplete should not be invoked.");
+ }
+ }
+
+ class HelpOption : Option
+ {
+ Option option;
+ CommandSet commands;
+
+ public HelpOption (CommandSet commands, Option d)
+ : base (d.Prototype, d.Description, d.MaxValueCount, d.Hidden)
+ {
+ this.commands = commands;
+ this.option = d;
+ }
+
+ protected override void OnParseComplete (OptionContext c)
+ {
+ commands.showHelp = true;
+
+ option?.InvokeOnParseComplete (c);
+ }
+ }
+
+ class CommandOptionSet : OptionSet
+ {
+ CommandSet commands;
+
+ public CommandOptionSet (CommandSet commands, MessageLocalizerConverter localizer)
+ : base (localizer)
+ {
+ this.commands = commands;
+ }
+
+ protected override void SetItem (int index, Option item)
+ {
+ if (ShouldWrapOption (item)) {
+ base.SetItem (index, new HelpOption (commands, item));
+ return;
+ }
+ base.SetItem (index, item);
+ }
+
+ bool ShouldWrapOption (Option item)
+ {
+ if (item == null)
+ return false;
+ var help = item as HelpOption;
+ if (help != null)
+ return false;
+ foreach (var n in item.Names) {
+ if (n == "help")
+ return true;
+ }
+ return false;
+ }
+
+ protected override void InsertItem (int index, Option item)
+ {
+ if (ShouldWrapOption (item)) {
+ base.InsertItem (index, new HelpOption (commands, item));
+ return;
+ }
+ base.InsertItem (index, item);
+ }
+ }
+
+ public class CommandSet : KeyedCollection<string, Command>
+ {
+ readonly OptionSet options;
+ readonly TextWriter outWriter;
+ readonly TextWriter errorWriter;
+ readonly string suite;
+
+ HelpCommand help;
+
+ internal bool showHelp;
+
+ internal OptionSet Options => options;
+
+ public CommandSet (string suite, MessageLocalizerConverter localizer = null, TextWriter output = null, TextWriter error = null)
+ {
+ if (suite == null)
+ throw new ArgumentNullException (nameof (suite));
+ this.suite = suite;
+ options = new CommandOptionSet (this, localizer);
+ outWriter = output ?? Console.Out;
+ errorWriter = error ?? Console.Error;
+ }
+
+ public string Suite => suite;
+ public TextWriter Out => outWriter;
+ public TextWriter Error => errorWriter;
+ public MessageLocalizerConverter MessageLocalizer => options.MessageLocalizer;
+
+ protected override string GetKeyForItem (Command item)
+ {
+ return item?.Name;
+ }
+
+ public new CommandSet Add (Command value)
+ {
+ if (value == null)
+ throw new ArgumentNullException (nameof (value));
+ AddCommand (value);
+ options.Add (new CommandOption (value));
+ return this;
+ }
+
+ void AddCommand (Command value)
+ {
+ if (value.CommandSet != null && value.CommandSet != this) {
+ throw new ArgumentException ("Command instances can only be added to a single CommandSet.", nameof (value));
+ }
+ value.CommandSet = this;
+ if (value.Options != null) {
+ value.Options.MessageLocalizer = options.MessageLocalizer;
+ }
+
+ base.Add (value);
+
+ help = help ?? value as HelpCommand;
+ }
+
+ public CommandSet Add (string header)
+ {
+ options.Add (header);
+ return this;
+ }
+
+ public CommandSet Add (Option option)
+ {
+ options.Add (option);
+ return this;
+ }
+
+ public CommandSet Add (string prototype, Action<string> action)
+ {
+ options.Add (prototype, action);
+ return this;
+ }
+
+ public CommandSet Add (string prototype, string description, Action<string> action)
+ {
+ options.Add (prototype, description, action);
+ return this;
+ }
+
+ public CommandSet Add (string prototype, string description, Action<string> action, bool hidden)
+ {
+ options.Add (prototype, description, action, hidden);
+ return this;
+ }
+
+ public CommandSet Add (string prototype, OptionAction<string, string> action)
+ {
+ options.Add (prototype, action);
+ return this;
+ }
+
+ public CommandSet Add (string prototype, string description, OptionAction<string, string> action)
+ {
+ options.Add (prototype, description, action);
+ return this;
+ }
+
+ public CommandSet Add (string prototype, string description, OptionAction<string, string> action, bool hidden)
+ {
+ options.Add (prototype, description, action, hidden);
+ return this;
+ }
+
+ public CommandSet Add<T> (string prototype, Action<T> action)
+ {
+ options.Add (prototype, null, action);
+ return this;
+ }
+
+ public CommandSet Add<T> (string prototype, string description, Action<T> action)
+ {
+ options.Add (prototype, description, action);
+ return this;
+ }
+
+ public CommandSet Add<TKey, TValue> (string prototype, OptionAction<TKey, TValue> action)
+ {
+ options.Add (prototype, action);
+ return this;
+ }
+
+ public CommandSet Add<TKey, TValue> (string prototype, string description, OptionAction<TKey, TValue> action)
+ {
+ options.Add (prototype, description, action);
+ return this;
+ }
+
+ public CommandSet Add (ArgumentSource source)
+ {
+ options.Add (source);
+ return this;
+ }
+
+ public int Run (IEnumerable<string> arguments)
+ {
+ if (arguments == null)
+ throw new ArgumentNullException (nameof (arguments));
+
+ this.showHelp = false;
+ if (help == null) {
+ help = new HelpCommand ();
+ AddCommand (help);
+ }
+ Action<string> setHelp = v => showHelp = v != null;
+ if (!options.Contains ("help")) {
+ options.Add ("help", "", setHelp, hidden: true);
+ }
+ if (!options.Contains ("?")) {
+ options.Add ("?", "", setHelp, hidden: true);
+ }
+ var extra = options.Parse (arguments);
+ if (extra.Count == 0) {
+ if (showHelp) {
+ return help.Invoke (extra);
+ }
+ Out.WriteLine (options.MessageLocalizer ($"Use `{Suite} help` for usage."));
+ return 1;
+ }
+ var command = Contains (extra [0]) ? this [extra [0]] : null;
+ if (command == null) {
+ help.WriteUnknownCommand (extra [0]);
+ return 1;
+ }
+ extra.RemoveAt (0);
+ if (showHelp) {
+ if (command.Options?.Contains ("help") ?? true) {
+ extra.Add ("--help");
+ return command.Invoke (extra);
+ }
+ command.Options.WriteOptionDescriptions (Out);
+ return 0;
+ }
+ return command.Invoke (extra);
+ }
+ }
+
+ public class HelpCommand : Command
+ {
+ public HelpCommand ()
+ : base ("help", help: "Show this message and exit")
+ {
+ }
+
+ public override int Invoke (IEnumerable<string> arguments)
+ {
+ var extra = new List<string> (arguments ?? new string [0]);
+ var _ = CommandSet.Options.MessageLocalizer;
+ if (extra.Count == 0) {
+ CommandSet.Options.WriteOptionDescriptions (CommandSet.Out);
+ return 0;
+ }
+ var command = CommandSet.Contains (extra [0])
+ ? CommandSet [extra [0]]
+ : null;
+ if (command == this || extra [0] == "--help") {
+ CommandSet.Out.WriteLine (_ ($"Usage: {CommandSet.Suite} COMMAND [OPTIONS]"));
+ CommandSet.Out.WriteLine (_ ($"Use `{CommandSet.Suite} help COMMAND` for help on a specific command."));
+ CommandSet.Out.WriteLine ();
+ CommandSet.Out.WriteLine (_ ($"Available commands:"));
+ CommandSet.Out.WriteLine ();
+ foreach (var c in CommandSet) {
+ CommandSet.Options.WriteCommandDescription (CommandSet.Out, c);
+ }
+ return 0;
+ }
+ if (command == null) {
+ WriteUnknownCommand (extra [0]);
+ return 1;
+ }
+ if (command.Options != null) {
+ command.Options.WriteOptionDescriptions (CommandSet.Out);
+ return 0;
+ }
+ return command.Invoke (new [] { "--help" });
+ }
+
+ internal void WriteUnknownCommand (string unknownCommand)
+ {
+ CommandSet.Error.WriteLine (CommandSet.Options.MessageLocalizer ($"{CommandSet.Suite}: Unknown command: {unknownCommand}"));
+ CommandSet.Error.WriteLine (CommandSet.Options.MessageLocalizer ($"{CommandSet.Suite}: Use `{CommandSet.Suite} help` for usage."));
+ }
+ }
}
Mono.Options/BaseRocksFixture.cs
Mono.Options/CollectionContract.cs
+Mono.Options/CommandSetTest.cs
Mono.Options/ListContract.cs
Mono.Options/OptionContextTest.cs
Mono.Options/OptionSetTest.cs
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>\r
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\r
+ <PropertyGroup>\r
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>\r
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>\r
+ <ProjectGuid>{472A5C45-8331-4849-B89F-A872CF884DA3}</ProjectGuid>\r
+ <OutputType>Library</OutputType>\r
+ <RootNamespace>Mono.Options_Test_net_4_x</RootNamespace>\r
+ <AssemblyName>Mono.Options_Test_net_4_x</AssemblyName>\r
+ <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>\r
+ </PropertyGroup>\r
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">\r
+ <DebugSymbols>true</DebugSymbols>\r
+ <DebugType>full</DebugType>\r
+ <Optimize>false</Optimize>\r
+ <OutputPath>bin\Debug</OutputPath>\r
+ <DefineConstants>DEBUG;</DefineConstants>\r
+ <ErrorReport>prompt</ErrorReport>\r
+ <WarningLevel>4</WarningLevel>\r
+ </PropertyGroup>\r
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">\r
+ <Optimize>true</Optimize>\r
+ <OutputPath>bin\Release</OutputPath>\r
+ <ErrorReport>prompt</ErrorReport>\r
+ <WarningLevel>4</WarningLevel>\r
+ </PropertyGroup>\r
+ <ItemGroup>\r
+ <Reference Include="System" />\r
+ <Reference Include="nunit.framework">\r
+ <HintPath>..\lib\net_4_x\nunit.framework.dll</HintPath>\r
+ </Reference>\r
+ </ItemGroup>\r
+ <ItemGroup>\r
+ <Compile Include="Mono.Options\BaseRocksFixture.cs" />\r
+ <Compile Include="Mono.Options\CategoryTest.cs" />\r
+ <Compile Include="Mono.Options\CollectionContract.cs" />\r
+ <Compile Include="Mono.Options\ListContract.cs" />\r
+ <Compile Include="Mono.Options\OptionContextTest.cs" />\r
+ <Compile Include="Mono.Options\OptionSetTest.cs" />\r
+ <Compile Include="Mono.Options\OptionTest.cs" />\r
+ <Compile Include="Mono.Options\Utils.cs" />\r
+ <Compile Include="Mono.Options\CommandSetTest.cs" />\r
+ <Compile Include="Mono.Options\CommandTest.cs" />\r
+ </ItemGroup>\r
+ <ItemGroup>\r
+ <ProjectReference Include="..\Mono.Options-net_4_x.csproj">\r
+ <Project>{115711B0-D1F2-4E50-83F9-63128E70CE05}</Project>\r
+ <Name>Mono.Options-net_4_x</Name>\r
+ </ProjectReference>\r
+ </ItemGroup>\r
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />\r
+</Project>
\ No newline at end of file
--- /dev/null
+//
+// CommandSetTest.cs
+//
+// Authors:
+// Jonathan Pryor <Jonathan.Pryor@microsoft.com>
+//
+// Copyright (C) 2017 Microsoft (http://www.microsoft.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Globalization;
+using System.IO;
+using System.Linq;
+
+#if NDESK_OPTIONS
+using NDesk.Options;
+#else
+using Mono.Options;
+#endif
+
+using Cadenza.Collections.Tests;
+
+using NUnit.Framework;
+
+#if NDESK_OPTIONS
+namespace Tests.NDesk.Options
+#else
+namespace MonoTests.Mono.Options
+#endif
+{
+ [TestFixture]
+ public class CommandSetTest : ListContract<Command>
+ {
+ protected override ICollection<Command> CreateCollection (IEnumerable<Command> values)
+ {
+ var set = new CommandSet ("test");
+ foreach (var value in values)
+ set.Add (value);
+ return set;
+ }
+
+ protected override Command CreateValueA ()
+ {
+ return new Command (
+ "foo",
+ "foo help");
+ }
+
+ protected override Command CreateValueB ()
+ {
+ return new Command (
+ "bar",
+ "bar help");
+ }
+
+ protected override Command CreateValueC ()
+ {
+ return new Command (
+ "baz",
+ "baz help");
+ }
+
+ static IEnumerable<string> _ (params string [] a)
+ {
+ return a;
+ }
+
+ [Test]
+ public void Constructor_SuiteRequired ()
+ {
+ Assert.Throws<ArgumentNullException> (() => new CommandSet (null));
+ }
+
+ [Test]
+ public void Add_NullCommand ()
+ {
+ var c = new CommandSet ("cs");
+ Assert.Throws<ArgumentNullException> (() => c.Add ((Command)null));
+ }
+
+ [Test]
+ public void Add_CommandCanBeAddedToOnlyOneSet ()
+ {
+ var cs1 = new CommandSet ("cs1");
+ var cs2 = new CommandSet ("cs2");
+ var c = new Command ("command", "help");
+ cs1.Add (c);
+ Assert.Throws<ArgumentException> (() => cs2.Add (c));
+ }
+
+ [Test]
+ public void Add_SetsCommandSet ()
+ {
+ var cs = new CommandSet ("cs");
+ var c = new Command ("command");
+ Assert.IsNull (c.CommandSet);
+ cs.Add (c);
+ Assert.AreSame (cs, c.CommandSet);
+ }
+
+ [Test]
+ public void Add_DuplicateCommand ()
+ {
+ var s = new CommandSet ("set");
+ s.Add (new Command ("value"));
+ Assert.Throws<ArgumentException> (() => s.Add (new Command ("value")));
+ }
+
+ [Test]
+ public void Run_Help ()
+ {
+ var o = new StringWriter ();
+ var e = new StringWriter ();
+
+ var showVersion = false;
+ var showHelp = false;
+
+ var git = new CommandSet ("git", output: o, error: e) {
+ "usage: git [--version] ... <command> [<args>]",
+ "",
+ "Common Options:",
+ { "version",
+ "show version info",
+ v => showVersion = v != null },
+ { "help",
+ "show this message and exit",
+ v => showHelp = v != null },
+ "",
+ "These are common Git commands used in various situations:",
+ "",
+ "start a working area (see also: git help tutorial)",
+ new Command ("clone", "Clone a repository into a new directory"),
+ new Command ("init", "Create an empty Git repository or reinitialize an existing one"),
+ new Command ("thisIsAVeryLongCommandNameInOrderToInduceWrapping", "Create an empty Git repository or reinitialize an existing one. Let's make this really long to cause a line wrap, shall we?"),
+ };
+
+ var expectedHelp = new StringWriter ();
+
+ expectedHelp.WriteLine ("usage: git [--version] ... <command> [<args>]");
+ expectedHelp.WriteLine ("");
+ expectedHelp.WriteLine ("Common Options:");
+ expectedHelp.WriteLine (" --version show version info");
+ expectedHelp.WriteLine (" --help show this message and exit");
+ expectedHelp.WriteLine ("");
+ expectedHelp.WriteLine ("These are common Git commands used in various situations:");
+ expectedHelp.WriteLine ("");
+ expectedHelp.WriteLine ("start a working area (see also: git help tutorial)");
+ expectedHelp.WriteLine (" clone Clone a repository into a new directory");
+ expectedHelp.WriteLine (" init Create an empty Git repository or reinitialize an");
+ expectedHelp.WriteLine (" existing one");
+ expectedHelp.WriteLine (" thisIsAVeryLongCommandNameInOrderToInduceWrapping");
+ expectedHelp.WriteLine (" Create an empty Git repository or reinitialize an");
+ expectedHelp.WriteLine (" existing one. Let's make this really long to");
+ expectedHelp.WriteLine (" cause a line wrap, shall we?");
+
+ Assert.AreEqual (0, git.Run (new [] { "help" }));
+ Assert.AreEqual (expectedHelp.ToString (), o.ToString ());
+
+ var expectedHelpHelp = new StringWriter ();
+ expectedHelpHelp.WriteLine ("Usage: git COMMAND [OPTIONS]");
+ expectedHelpHelp.WriteLine ("Use `git help COMMAND` for help on a specific command.");
+ expectedHelpHelp.WriteLine ();
+ expectedHelpHelp.WriteLine ("Available commands:");
+ expectedHelpHelp.WriteLine ();
+ expectedHelpHelp.WriteLine (" clone Clone a repository into a new directory");
+ expectedHelpHelp.WriteLine (" init Create an empty Git repository or reinitialize an");
+ expectedHelpHelp.WriteLine (" existing one");
+ expectedHelpHelp.WriteLine (" thisIsAVeryLongCommandNameInOrderToInduceWrapping");
+ expectedHelpHelp.WriteLine (" Create an empty Git repository or reinitialize an");
+ expectedHelpHelp.WriteLine (" existing one. Let's make this really long to");
+ expectedHelpHelp.WriteLine (" cause a line wrap, shall we?");
+ expectedHelpHelp.WriteLine (" help Show this message and exit");
+
+ o.GetStringBuilder ().Clear ();
+ Assert.AreEqual (0, git.Run (new [] { "help", "--help" }));
+ Assert.AreEqual (expectedHelpHelp.ToString (), o.ToString ());
+ }
+
+ [Test]
+ public void Run_Command ()
+ {
+ var a = 0;
+ var b = 0;
+ var c = new CommandSet ("set") {
+ new Command ("a") { Run = v => a = v.Count () },
+ new Command ("b") { Run = v => b = v.Count () },
+ };
+ Assert.AreEqual (0, c.Run (new [] { "a", "extra" }));
+ Assert.AreEqual (1, a);
+ Assert.AreEqual (0, b);
+
+ a = b = 0;
+ Assert.AreEqual (0, c.Run (new [] { "b" }));
+ Assert.AreEqual (0, a);
+ Assert.AreEqual (0, b);
+
+ Assert.AreEqual (0, c.Run (new [] { "b", "one", "two" }));
+ Assert.AreEqual (0, a);
+ Assert.AreEqual (2, b);
+ }
+
+ [Test]
+ public void Run_HelpCommandSendsHelpOption ()
+ {
+ var e = new Command ("echo");
+ e.Run = (args) => e.CommandSet.Out.WriteLine (string.Join (" ", args));
+
+ var o = new StringWriter ();
+ var c = new CommandSet ("set", output:o) {
+ e,
+ };
+ Assert.AreEqual (0, c.Run (new [] { "help", "echo" }));
+
+ var expected = $"--help{Environment.NewLine}";
+ var actual = o.ToString ();
+ Assert.AreEqual (expected, actual);
+ }
+
+ [Test]
+ public void Run_NullArgument ()
+ {
+ var c = new CommandSet ("c");
+ Assert.Throws<ArgumentNullException> (() => c.Run (null));
+ }
+ }
+}
+
--- /dev/null
+//
+// CommandSetTest.cs
+//
+// Authors:
+// Jonathan Pryor <Jonathan.Pryor@microsoft.com>
+//
+// Copyright (C) 2017 Microsoft (http://www.microsoft.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Globalization;
+using System.IO;
+using System.Linq;
+
+#if NDESK_OPTIONS
+using NDesk.Options;
+#else
+using Mono.Options;
+#endif
+
+using Cadenza.Collections.Tests;
+
+using NUnit.Framework;
+
+#if NDESK_OPTIONS
+namespace Tests.NDesk.Options
+#else
+namespace MonoTests.Mono.Options
+#endif
+{
+ [TestFixture]
+ public class CommandTest
+ {
+ [Test]
+ public void Constructor_NameRequired ()
+ {
+ Assert.Throws<ArgumentNullException> (() => new Command (name: null, help: null));
+ }
+
+ [Test]
+ public void Constructor ()
+ {
+ var c = new Command ("command", "help");
+ Assert.AreEqual ("command", c.Name);
+ Assert.AreEqual ("help", c.Help);
+ }
+
+ [Test]
+ public void Invoke_CallsRun ()
+ {
+ bool runInvoked = false;
+ var c = new Command ("command") {
+ Run = v => runInvoked = true,
+ };
+ Assert.AreEqual (0, c.Invoke (null));
+ Assert.IsTrue (runInvoked);
+ }
+
+ [Test]
+ public void Invoke_RequiresNothing ()
+ {
+ var c = new Command ("c");
+ Assert.AreEqual (0, c.Invoke (null));
+ }
+
+ [Test]
+ public void Invoke_UsesOptions ()
+ {
+ bool showHelp = false;
+ var c = new Command ("c") {
+ Options = new OptionSet {
+ { "help", v => showHelp = v != null },
+ },
+ };
+ Assert.AreEqual (0, c.Invoke (new [] { "--help" }));
+ Assert.IsTrue (showHelp);
+ }
+ }
+}
+
// Optimization for known colors that were deserialized
// from an MS serialized stream.
if (value == 0 && IsKnownColor) {
- value = KnownColors.FromKnownColor ((KnownColor)knownColor).ToArgb () & 0xFFFFFFFF;
+ value = FromKnownColor ((KnownColor)knownColor).ToArgb () & 0xFFFFFFFF;
}
return value;
}
public static Color FromKnownColor (KnownColor color)
{
- return KnownColors.FromKnownColor (color);
+ Color c;
+ short n = (short)color;
+ if ((n <= 0) || (n >= KnownColors.ArgbValues.Length)) {
+ // This is what it returns!
+ c = FromArgb (0, 0, 0, 0);
+ c.state |= (short) ColorType.Named;
+ } else {
+ c = new Color ();
+ c.state = (short) (ColorType.ARGB | ColorType.Known | ColorType.Named);
+ if ((n < 27) || (n > 169))
+ c.state |= (short) ColorType.System;
+ c.Value = KnownColors.ArgbValues [n];
+ }
+ c.knownColor = n;
+ return c;
}
public static Color FromName (string name)
{
try {
KnownColor kc = (KnownColor) Enum.Parse (typeof (KnownColor), name, true);
- return KnownColors.FromKnownColor (kc);
+ return FromKnownColor (kc);
}
catch {
// This is what it returns!
static public Color Transparent {
- get { return KnownColors.FromKnownColor (KnownColor.Transparent); }
+ get { return FromKnownColor (KnownColor.Transparent); }
}
static public Color AliceBlue {
- get { return KnownColors.FromKnownColor (KnownColor.AliceBlue); }
+ get { return FromKnownColor (KnownColor.AliceBlue); }
}
static public Color AntiqueWhite {
- get { return KnownColors.FromKnownColor (KnownColor.AntiqueWhite); }
+ get { return FromKnownColor (KnownColor.AntiqueWhite); }
}
static public Color Aqua {
- get { return KnownColors.FromKnownColor (KnownColor.Aqua); }
+ get { return FromKnownColor (KnownColor.Aqua); }
}
static public Color Aquamarine {
- get { return KnownColors.FromKnownColor (KnownColor.Aquamarine); }
+ get { return FromKnownColor (KnownColor.Aquamarine); }
}
static public Color Azure {
- get { return KnownColors.FromKnownColor (KnownColor.Azure); }
+ get { return FromKnownColor (KnownColor.Azure); }
}
static public Color Beige {
- get { return KnownColors.FromKnownColor (KnownColor.Beige); }
+ get { return FromKnownColor (KnownColor.Beige); }
}
static public Color Bisque {
- get { return KnownColors.FromKnownColor (KnownColor.Bisque); }
+ get { return FromKnownColor (KnownColor.Bisque); }
}
static public Color Black {
- get { return KnownColors.FromKnownColor (KnownColor.Black); }
+ get { return FromKnownColor (KnownColor.Black); }
}
static public Color BlanchedAlmond {
- get { return KnownColors.FromKnownColor (KnownColor.BlanchedAlmond); }
+ get { return FromKnownColor (KnownColor.BlanchedAlmond); }
}
static public Color Blue {
- get { return KnownColors.FromKnownColor (KnownColor.Blue); }
+ get { return FromKnownColor (KnownColor.Blue); }
}
static public Color BlueViolet {
- get { return KnownColors.FromKnownColor (KnownColor.BlueViolet); }
+ get { return FromKnownColor (KnownColor.BlueViolet); }
}
static public Color Brown {
- get { return KnownColors.FromKnownColor (KnownColor.Brown); }
+ get { return FromKnownColor (KnownColor.Brown); }
}
static public Color BurlyWood {
- get { return KnownColors.FromKnownColor (KnownColor.BurlyWood); }
+ get { return FromKnownColor (KnownColor.BurlyWood); }
}
static public Color CadetBlue {
- get { return KnownColors.FromKnownColor (KnownColor.CadetBlue); }
+ get { return FromKnownColor (KnownColor.CadetBlue); }
}
static public Color Chartreuse {
- get { return KnownColors.FromKnownColor (KnownColor.Chartreuse); }
+ get { return FromKnownColor (KnownColor.Chartreuse); }
}
static public Color Chocolate {
- get { return KnownColors.FromKnownColor (KnownColor.Chocolate); }
+ get { return FromKnownColor (KnownColor.Chocolate); }
}
static public Color Coral {
- get { return KnownColors.FromKnownColor (KnownColor.Coral); }
+ get { return FromKnownColor (KnownColor.Coral); }
}
static public Color CornflowerBlue {
- get { return KnownColors.FromKnownColor (KnownColor.CornflowerBlue); }
+ get { return FromKnownColor (KnownColor.CornflowerBlue); }
}
static public Color Cornsilk {
- get { return KnownColors.FromKnownColor (KnownColor.Cornsilk); }
+ get { return FromKnownColor (KnownColor.Cornsilk); }
}
static public Color Crimson {
- get { return KnownColors.FromKnownColor (KnownColor.Crimson); }
+ get { return FromKnownColor (KnownColor.Crimson); }
}
static public Color Cyan {
- get { return KnownColors.FromKnownColor (KnownColor.Cyan); }
+ get { return FromKnownColor (KnownColor.Cyan); }
}
static public Color DarkBlue {
- get { return KnownColors.FromKnownColor (KnownColor.DarkBlue); }
+ get { return FromKnownColor (KnownColor.DarkBlue); }
}
static public Color DarkCyan {
- get { return KnownColors.FromKnownColor (KnownColor.DarkCyan); }
+ get { return FromKnownColor (KnownColor.DarkCyan); }
}
static public Color DarkGoldenrod {
- get { return KnownColors.FromKnownColor (KnownColor.DarkGoldenrod); }
+ get { return FromKnownColor (KnownColor.DarkGoldenrod); }
}
static public Color DarkGray {
- get { return KnownColors.FromKnownColor (KnownColor.DarkGray); }
+ get { return FromKnownColor (KnownColor.DarkGray); }
}
static public Color DarkGreen {
- get { return KnownColors.FromKnownColor (KnownColor.DarkGreen); }
+ get { return FromKnownColor (KnownColor.DarkGreen); }
}
static public Color DarkKhaki {
- get { return KnownColors.FromKnownColor (KnownColor.DarkKhaki); }
+ get { return FromKnownColor (KnownColor.DarkKhaki); }
}
static public Color DarkMagenta {
- get { return KnownColors.FromKnownColor (KnownColor.DarkMagenta); }
+ get { return FromKnownColor (KnownColor.DarkMagenta); }
}
static public Color DarkOliveGreen {
- get { return KnownColors.FromKnownColor (KnownColor.DarkOliveGreen); }
+ get { return FromKnownColor (KnownColor.DarkOliveGreen); }
}
static public Color DarkOrange {
- get { return KnownColors.FromKnownColor (KnownColor.DarkOrange); }
+ get { return FromKnownColor (KnownColor.DarkOrange); }
}
static public Color DarkOrchid {
- get { return KnownColors.FromKnownColor (KnownColor.DarkOrchid); }
+ get { return FromKnownColor (KnownColor.DarkOrchid); }
}
static public Color DarkRed {
- get { return KnownColors.FromKnownColor (KnownColor.DarkRed); }
+ get { return FromKnownColor (KnownColor.DarkRed); }
}
static public Color DarkSalmon {
- get { return KnownColors.FromKnownColor (KnownColor.DarkSalmon); }
+ get { return FromKnownColor (KnownColor.DarkSalmon); }
}
static public Color DarkSeaGreen {
- get { return KnownColors.FromKnownColor (KnownColor.DarkSeaGreen); }
+ get { return FromKnownColor (KnownColor.DarkSeaGreen); }
}
static public Color DarkSlateBlue {
- get { return KnownColors.FromKnownColor (KnownColor.DarkSlateBlue); }
+ get { return FromKnownColor (KnownColor.DarkSlateBlue); }
}
static public Color DarkSlateGray {
- get { return KnownColors.FromKnownColor (KnownColor.DarkSlateGray); }
+ get { return FromKnownColor (KnownColor.DarkSlateGray); }
}
static public Color DarkTurquoise {
- get { return KnownColors.FromKnownColor (KnownColor.DarkTurquoise); }
+ get { return FromKnownColor (KnownColor.DarkTurquoise); }
}
static public Color DarkViolet {
- get { return KnownColors.FromKnownColor (KnownColor.DarkViolet); }
+ get { return FromKnownColor (KnownColor.DarkViolet); }
}
static public Color DeepPink {
- get { return KnownColors.FromKnownColor (KnownColor.DeepPink); }
+ get { return FromKnownColor (KnownColor.DeepPink); }
}
static public Color DeepSkyBlue {
- get { return KnownColors.FromKnownColor (KnownColor.DeepSkyBlue); }
+ get { return FromKnownColor (KnownColor.DeepSkyBlue); }
}
static public Color DimGray {
- get { return KnownColors.FromKnownColor (KnownColor.DimGray); }
+ get { return FromKnownColor (KnownColor.DimGray); }
}
static public Color DodgerBlue {
- get { return KnownColors.FromKnownColor (KnownColor.DodgerBlue); }
+ get { return FromKnownColor (KnownColor.DodgerBlue); }
}
static public Color Firebrick {
- get { return KnownColors.FromKnownColor (KnownColor.Firebrick); }
+ get { return FromKnownColor (KnownColor.Firebrick); }
}
static public Color FloralWhite {
- get { return KnownColors.FromKnownColor (KnownColor.FloralWhite); }
+ get { return FromKnownColor (KnownColor.FloralWhite); }
}
static public Color ForestGreen {
- get { return KnownColors.FromKnownColor (KnownColor.ForestGreen); }
+ get { return FromKnownColor (KnownColor.ForestGreen); }
}
static public Color Fuchsia {
- get { return KnownColors.FromKnownColor (KnownColor.Fuchsia); }
+ get { return FromKnownColor (KnownColor.Fuchsia); }
}
static public Color Gainsboro {
- get { return KnownColors.FromKnownColor (KnownColor.Gainsboro); }
+ get { return FromKnownColor (KnownColor.Gainsboro); }
}
static public Color GhostWhite {
- get { return KnownColors.FromKnownColor (KnownColor.GhostWhite); }
+ get { return FromKnownColor (KnownColor.GhostWhite); }
}
static public Color Gold {
- get { return KnownColors.FromKnownColor (KnownColor.Gold); }
+ get { return FromKnownColor (KnownColor.Gold); }
}
static public Color Goldenrod {
- get { return KnownColors.FromKnownColor (KnownColor.Goldenrod); }
+ get { return FromKnownColor (KnownColor.Goldenrod); }
}
static public Color Gray {
- get { return KnownColors.FromKnownColor (KnownColor.Gray); }
+ get { return FromKnownColor (KnownColor.Gray); }
}
static public Color Green {
- get { return KnownColors.FromKnownColor (KnownColor.Green); }
+ get { return FromKnownColor (KnownColor.Green); }
}
static public Color GreenYellow {
- get { return KnownColors.FromKnownColor (KnownColor.GreenYellow); }
+ get { return FromKnownColor (KnownColor.GreenYellow); }
}
static public Color Honeydew {
- get { return KnownColors.FromKnownColor (KnownColor.Honeydew); }
+ get { return FromKnownColor (KnownColor.Honeydew); }
}
static public Color HotPink {
- get { return KnownColors.FromKnownColor (KnownColor.HotPink); }
+ get { return FromKnownColor (KnownColor.HotPink); }
}
static public Color IndianRed {
- get { return KnownColors.FromKnownColor (KnownColor.IndianRed); }
+ get { return FromKnownColor (KnownColor.IndianRed); }
}
static public Color Indigo {
- get { return KnownColors.FromKnownColor (KnownColor.Indigo); }
+ get { return FromKnownColor (KnownColor.Indigo); }
}
static public Color Ivory {
- get { return KnownColors.FromKnownColor (KnownColor.Ivory); }
+ get { return FromKnownColor (KnownColor.Ivory); }
}
static public Color Khaki {
- get { return KnownColors.FromKnownColor (KnownColor.Khaki); }
+ get { return FromKnownColor (KnownColor.Khaki); }
}
static public Color Lavender {
- get { return KnownColors.FromKnownColor (KnownColor.Lavender); }
+ get { return FromKnownColor (KnownColor.Lavender); }
}
static public Color LavenderBlush {
- get { return KnownColors.FromKnownColor (KnownColor.LavenderBlush); }
+ get { return FromKnownColor (KnownColor.LavenderBlush); }
}
static public Color LawnGreen {
- get { return KnownColors.FromKnownColor (KnownColor.LawnGreen); }
+ get { return FromKnownColor (KnownColor.LawnGreen); }
}
static public Color LemonChiffon {
- get { return KnownColors.FromKnownColor (KnownColor.LemonChiffon); }
+ get { return FromKnownColor (KnownColor.LemonChiffon); }
}
static public Color LightBlue {
- get { return KnownColors.FromKnownColor (KnownColor.LightBlue); }
+ get { return FromKnownColor (KnownColor.LightBlue); }
}
static public Color LightCoral {
- get { return KnownColors.FromKnownColor (KnownColor.LightCoral); }
+ get { return FromKnownColor (KnownColor.LightCoral); }
}
static public Color LightCyan {
- get { return KnownColors.FromKnownColor (KnownColor.LightCyan); }
+ get { return FromKnownColor (KnownColor.LightCyan); }
}
static public Color LightGoldenrodYellow {
- get { return KnownColors.FromKnownColor (KnownColor.LightGoldenrodYellow); }
+ get { return FromKnownColor (KnownColor.LightGoldenrodYellow); }
}
static public Color LightGreen {
- get { return KnownColors.FromKnownColor (KnownColor.LightGreen); }
+ get { return FromKnownColor (KnownColor.LightGreen); }
}
static public Color LightGray {
- get { return KnownColors.FromKnownColor (KnownColor.LightGray); }
+ get { return FromKnownColor (KnownColor.LightGray); }
}
static public Color LightPink {
- get { return KnownColors.FromKnownColor (KnownColor.LightPink); }
+ get { return FromKnownColor (KnownColor.LightPink); }
}
static public Color LightSalmon {
- get { return KnownColors.FromKnownColor (KnownColor.LightSalmon); }
+ get { return FromKnownColor (KnownColor.LightSalmon); }
}
static public Color LightSeaGreen {
- get { return KnownColors.FromKnownColor (KnownColor.LightSeaGreen); }
+ get { return FromKnownColor (KnownColor.LightSeaGreen); }
}
static public Color LightSkyBlue {
- get { return KnownColors.FromKnownColor (KnownColor.LightSkyBlue); }
+ get { return FromKnownColor (KnownColor.LightSkyBlue); }
}
static public Color LightSlateGray {
- get { return KnownColors.FromKnownColor (KnownColor.LightSlateGray); }
+ get { return FromKnownColor (KnownColor.LightSlateGray); }
}
static public Color LightSteelBlue {
- get { return KnownColors.FromKnownColor (KnownColor.LightSteelBlue); }
+ get { return FromKnownColor (KnownColor.LightSteelBlue); }
}
static public Color LightYellow {
- get { return KnownColors.FromKnownColor (KnownColor.LightYellow); }
+ get { return FromKnownColor (KnownColor.LightYellow); }
}
static public Color Lime {
- get { return KnownColors.FromKnownColor (KnownColor.Lime); }
+ get { return FromKnownColor (KnownColor.Lime); }
}
static public Color LimeGreen {
- get { return KnownColors.FromKnownColor (KnownColor.LimeGreen); }
+ get { return FromKnownColor (KnownColor.LimeGreen); }
}
static public Color Linen {
- get { return KnownColors.FromKnownColor (KnownColor.Linen); }
+ get { return FromKnownColor (KnownColor.Linen); }
}
static public Color Magenta {
- get { return KnownColors.FromKnownColor (KnownColor.Magenta); }
+ get { return FromKnownColor (KnownColor.Magenta); }
}
static public Color Maroon {
- get { return KnownColors.FromKnownColor (KnownColor.Maroon); }
+ get { return FromKnownColor (KnownColor.Maroon); }
}
static public Color MediumAquamarine {
- get { return KnownColors.FromKnownColor (KnownColor.MediumAquamarine); }
+ get { return FromKnownColor (KnownColor.MediumAquamarine); }
}
static public Color MediumBlue {
- get { return KnownColors.FromKnownColor (KnownColor.MediumBlue); }
+ get { return FromKnownColor (KnownColor.MediumBlue); }
}
static public Color MediumOrchid {
- get { return KnownColors.FromKnownColor (KnownColor.MediumOrchid); }
+ get { return FromKnownColor (KnownColor.MediumOrchid); }
}
static public Color MediumPurple {
- get { return KnownColors.FromKnownColor (KnownColor.MediumPurple); }
+ get { return FromKnownColor (KnownColor.MediumPurple); }
}
static public Color MediumSeaGreen {
- get { return KnownColors.FromKnownColor (KnownColor.MediumSeaGreen); }
+ get { return FromKnownColor (KnownColor.MediumSeaGreen); }
}
static public Color MediumSlateBlue {
- get { return KnownColors.FromKnownColor (KnownColor.MediumSlateBlue); }
+ get { return FromKnownColor (KnownColor.MediumSlateBlue); }
}
static public Color MediumSpringGreen {
- get { return KnownColors.FromKnownColor (KnownColor.MediumSpringGreen); }
+ get { return FromKnownColor (KnownColor.MediumSpringGreen); }
}
static public Color MediumTurquoise {
- get { return KnownColors.FromKnownColor (KnownColor.MediumTurquoise); }
+ get { return FromKnownColor (KnownColor.MediumTurquoise); }
}
static public Color MediumVioletRed {
- get { return KnownColors.FromKnownColor (KnownColor.MediumVioletRed); }
+ get { return FromKnownColor (KnownColor.MediumVioletRed); }
}
static public Color MidnightBlue {
- get { return KnownColors.FromKnownColor (KnownColor.MidnightBlue); }
+ get { return FromKnownColor (KnownColor.MidnightBlue); }
}
static public Color MintCream {
- get { return KnownColors.FromKnownColor (KnownColor.MintCream); }
+ get { return FromKnownColor (KnownColor.MintCream); }
}
static public Color MistyRose {
- get { return KnownColors.FromKnownColor (KnownColor.MistyRose); }
+ get { return FromKnownColor (KnownColor.MistyRose); }
}
static public Color Moccasin {
- get { return KnownColors.FromKnownColor (KnownColor.Moccasin); }
+ get { return FromKnownColor (KnownColor.Moccasin); }
}
static public Color NavajoWhite {
- get { return KnownColors.FromKnownColor (KnownColor.NavajoWhite); }
+ get { return FromKnownColor (KnownColor.NavajoWhite); }
}
static public Color Navy {
- get { return KnownColors.FromKnownColor (KnownColor.Navy); }
+ get { return FromKnownColor (KnownColor.Navy); }
}
static public Color OldLace {
- get { return KnownColors.FromKnownColor (KnownColor.OldLace); }
+ get { return FromKnownColor (KnownColor.OldLace); }
}
static public Color Olive {
- get { return KnownColors.FromKnownColor (KnownColor.Olive); }
+ get { return FromKnownColor (KnownColor.Olive); }
}
static public Color OliveDrab {
- get { return KnownColors.FromKnownColor (KnownColor.OliveDrab); }
+ get { return FromKnownColor (KnownColor.OliveDrab); }
}
static public Color Orange {
- get { return KnownColors.FromKnownColor (KnownColor.Orange); }
+ get { return FromKnownColor (KnownColor.Orange); }
}
static public Color OrangeRed {
- get { return KnownColors.FromKnownColor (KnownColor.OrangeRed); }
+ get { return FromKnownColor (KnownColor.OrangeRed); }
}
static public Color Orchid {
- get { return KnownColors.FromKnownColor (KnownColor.Orchid); }
+ get { return FromKnownColor (KnownColor.Orchid); }
}
static public Color PaleGoldenrod {
- get { return KnownColors.FromKnownColor (KnownColor.PaleGoldenrod); }
+ get { return FromKnownColor (KnownColor.PaleGoldenrod); }
}
static public Color PaleGreen {
- get { return KnownColors.FromKnownColor (KnownColor.PaleGreen); }
+ get { return FromKnownColor (KnownColor.PaleGreen); }
}
static public Color PaleTurquoise {
- get { return KnownColors.FromKnownColor (KnownColor.PaleTurquoise); }
+ get { return FromKnownColor (KnownColor.PaleTurquoise); }
}
static public Color PaleVioletRed {
- get { return KnownColors.FromKnownColor (KnownColor.PaleVioletRed); }
+ get { return FromKnownColor (KnownColor.PaleVioletRed); }
}
static public Color PapayaWhip {
- get { return KnownColors.FromKnownColor (KnownColor.PapayaWhip); }
+ get { return FromKnownColor (KnownColor.PapayaWhip); }
}
static public Color PeachPuff {
- get { return KnownColors.FromKnownColor (KnownColor.PeachPuff); }
+ get { return FromKnownColor (KnownColor.PeachPuff); }
}
static public Color Peru {
- get { return KnownColors.FromKnownColor (KnownColor.Peru); }
+ get { return FromKnownColor (KnownColor.Peru); }
}
static public Color Pink {
- get { return KnownColors.FromKnownColor (KnownColor.Pink); }
+ get { return FromKnownColor (KnownColor.Pink); }
}
static public Color Plum {
- get { return KnownColors.FromKnownColor (KnownColor.Plum); }
+ get { return FromKnownColor (KnownColor.Plum); }
}
static public Color PowderBlue {
- get { return KnownColors.FromKnownColor (KnownColor.PowderBlue); }
+ get { return FromKnownColor (KnownColor.PowderBlue); }
}
static public Color Purple {
- get { return KnownColors.FromKnownColor (KnownColor.Purple); }
+ get { return FromKnownColor (KnownColor.Purple); }
}
static public Color Red {
- get { return KnownColors.FromKnownColor (KnownColor.Red); }
+ get { return FromKnownColor (KnownColor.Red); }
}
static public Color RosyBrown {
- get { return KnownColors.FromKnownColor (KnownColor.RosyBrown); }
+ get { return FromKnownColor (KnownColor.RosyBrown); }
}
static public Color RoyalBlue {
- get { return KnownColors.FromKnownColor (KnownColor.RoyalBlue); }
+ get { return FromKnownColor (KnownColor.RoyalBlue); }
}
static public Color SaddleBrown {
- get { return KnownColors.FromKnownColor (KnownColor.SaddleBrown); }
+ get { return FromKnownColor (KnownColor.SaddleBrown); }
}
static public Color Salmon {
- get { return KnownColors.FromKnownColor (KnownColor.Salmon); }
+ get { return FromKnownColor (KnownColor.Salmon); }
}
static public Color SandyBrown {
- get { return KnownColors.FromKnownColor (KnownColor.SandyBrown); }
+ get { return FromKnownColor (KnownColor.SandyBrown); }
}
static public Color SeaGreen {
- get { return KnownColors.FromKnownColor (KnownColor.SeaGreen); }
+ get { return FromKnownColor (KnownColor.SeaGreen); }
}
static public Color SeaShell {
- get { return KnownColors.FromKnownColor (KnownColor.SeaShell); }
+ get { return FromKnownColor (KnownColor.SeaShell); }
}
static public Color Sienna {
- get { return KnownColors.FromKnownColor (KnownColor.Sienna); }
+ get { return FromKnownColor (KnownColor.Sienna); }
}
static public Color Silver {
- get { return KnownColors.FromKnownColor (KnownColor.Silver); }
+ get { return FromKnownColor (KnownColor.Silver); }
}
static public Color SkyBlue {
- get { return KnownColors.FromKnownColor (KnownColor.SkyBlue); }
+ get { return FromKnownColor (KnownColor.SkyBlue); }
}
static public Color SlateBlue {
- get { return KnownColors.FromKnownColor (KnownColor.SlateBlue); }
+ get { return FromKnownColor (KnownColor.SlateBlue); }
}
static public Color SlateGray {
- get { return KnownColors.FromKnownColor (KnownColor.SlateGray); }
+ get { return FromKnownColor (KnownColor.SlateGray); }
}
static public Color Snow {
- get { return KnownColors.FromKnownColor (KnownColor.Snow); }
+ get { return FromKnownColor (KnownColor.Snow); }
}
static public Color SpringGreen {
- get { return KnownColors.FromKnownColor (KnownColor.SpringGreen); }
+ get { return FromKnownColor (KnownColor.SpringGreen); }
}
static public Color SteelBlue {
- get { return KnownColors.FromKnownColor (KnownColor.SteelBlue); }
+ get { return FromKnownColor (KnownColor.SteelBlue); }
}
static public Color Tan {
- get { return KnownColors.FromKnownColor (KnownColor.Tan); }
+ get { return FromKnownColor (KnownColor.Tan); }
}
static public Color Teal {
- get { return KnownColors.FromKnownColor (KnownColor.Teal); }
+ get { return FromKnownColor (KnownColor.Teal); }
}
static public Color Thistle {
- get { return KnownColors.FromKnownColor (KnownColor.Thistle); }
+ get { return FromKnownColor (KnownColor.Thistle); }
}
static public Color Tomato {
- get { return KnownColors.FromKnownColor (KnownColor.Tomato); }
+ get { return FromKnownColor (KnownColor.Tomato); }
}
static public Color Turquoise {
- get { return KnownColors.FromKnownColor (KnownColor.Turquoise); }
+ get { return FromKnownColor (KnownColor.Turquoise); }
}
static public Color Violet {
- get { return KnownColors.FromKnownColor (KnownColor.Violet); }
+ get { return FromKnownColor (KnownColor.Violet); }
}
static public Color Wheat {
- get { return KnownColors.FromKnownColor (KnownColor.Wheat); }
+ get { return FromKnownColor (KnownColor.Wheat); }
}
static public Color White {
- get { return KnownColors.FromKnownColor (KnownColor.White); }
+ get { return FromKnownColor (KnownColor.White); }
}
static public Color WhiteSmoke {
- get { return KnownColors.FromKnownColor (KnownColor.WhiteSmoke); }
+ get { return FromKnownColor (KnownColor.WhiteSmoke); }
}
static public Color Yellow {
- get { return KnownColors.FromKnownColor (KnownColor.Yellow); }
+ get { return FromKnownColor (KnownColor.Yellow); }
}
static public Color YellowGreen {
- get { return KnownColors.FromKnownColor (KnownColor.YellowGreen); }
+ get { return FromKnownColor (KnownColor.YellowGreen); }
}
}
}
//
using System;
-using System.Runtime.Remoting;
using System.Runtime.Serialization;
using System.Runtime.InteropServices;
using System.ComponentModel;
public static Color FromKnownColor (KnownColor kc)
{
- Color c;
- short n = (short)kc;
- if ((n <= 0) || (n >= ArgbValues.Length)) {
- // This is what it returns!
- c = Color.FromArgb (0, 0, 0, 0);
- c.state |= (short) Color.ColorType.Named;
- } else {
- c = new Color ();
- c.state = (short) (Color.ColorType.ARGB | Color.ColorType.Known | Color.ColorType.Named);
- if ((n < 27) || (n > 169))
- c.state |= (short) Color.ColorType.System;
- c.Value = ArgbValues [n];
- }
- c.knownColor = n;
- return c;
+ return Color.FromKnownColor (kc);
}
public static string GetName (short kc)
[SecurityPermission (SecurityAction.Deny, UnmanagedCode = true)]
public class MatrixTest {
- private Matrix default_matrix;
- private Rectangle rect;
- private RectangleF rectf;
-
- [TestFixtureSetUp]
- public void FixtureSetUp ()
- {
- default_matrix = new Matrix ();
- }
-
[Test]
public void Constructor_Default ()
{
[Test]
public void Constructor_Int_Null ()
{
- Assert.Throws<ArgumentNullException> (() => new Matrix (rect, null));
+ Assert.Throws<ArgumentNullException> (() => new Matrix (default (Rectangle), null));
}
[Test]
public void Constructor_Int_Empty ()
{
- Assert.Throws<ArgumentException> (() => new Matrix (rect, new Point[0]));
+ Assert.Throws<ArgumentException> (() => new Matrix (default (Rectangle), new Point[0]));
}
[Test]
public void Constructor_Int_4Point ()
{
- Assert.Throws<ArgumentException> (() => new Matrix (rect, new Point[4]));
+ Assert.Throws<ArgumentException> (() => new Matrix (default (Rectangle), new Point[4]));
}
[Test]
[Test]
public void Constructor_Float_Null ()
{
- Assert.Throws<ArgumentNullException> (() => new Matrix (rectf, null));
+ Assert.Throws<ArgumentNullException> (() => new Matrix (default (RectangleF), null));
}
[Test]
public void Constructor_Float_Empty ()
{
- Assert.Throws<ArgumentException> (() => new Matrix (rectf, new PointF[0]));
+ Assert.Throws<ArgumentException> (() => new Matrix (default (RectangleF), new PointF[0]));
}
[Test]
public void Constructor_Float_2PointF ()
{
- Assert.Throws<ArgumentException> (() => new Matrix (rectf, new PointF[2]));
+ Assert.Throws<ArgumentException> (() => new Matrix (default (RectangleF), new PointF[2]));
}
[Test]
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
+#if !NETCOREAPP2_0
using System.Runtime.Serialization.Formatters.Soap;
+#endif
using System.Security.Cryptography;
using System.Security.Permissions;
using System.Text;
}
}
+#if !NETCOREAPP2_0
private Stream SoapSerialize (object o)
{
MemoryStream ms = new MemoryStream ();
}
}
}
+#endif
[Test]
[Category ("NotWorking")] // http://bugzilla.ximian.com/show_bug.cgi?id=80558
[Test]
public void EqualityOpTest ()
{
+#pragma warning disable 1718 // Comparison made to same variable
Assert.IsTrue (pt1_1 == pt1_1, "#1");
+#pragma warning restore 1718
Assert.IsTrue (pt1_1 == new Point (1, 1), "#2");
Assert.IsTrue (!(pt1_1 == pt1_0), "#3");
Assert.IsTrue (!(pt1_1 == pt0_1), "#4");
[Test]
public void InequalityOpTest ()
{
+#pragma warning disable 1718 // Comparison made to same variable
Assert.IsTrue (!(pt1_1 != pt1_1), "#1");
+#pragma warning restore 1718
Assert.IsTrue (!(pt1_1 != new Point (1, 1)), "#2");
Assert.IsTrue (pt1_1 != pt1_0, "#3");
Assert.IsTrue (pt1_1 != pt0_1, "#4");
try {
// culture == null
ptconv.ConvertTo (null, null, pt, typeof (string));
- } catch (NullReferenceException e) {
+ } catch (NullReferenceException) {
Assert.Fail ("CT#8: must not throw NullReferenceException");
}
}
[Test]
public void TestEqualityOp ()
{
+#pragma warning disable 1718 // Comparison made to same variable
Assert.IsTrue (pt11_99 == pt11_99, "EOP#1");
+#pragma warning restore 1718
Assert.IsTrue (pt11_99 == new PointF (1.1F, 9.9F), "EOP#2");
Assert.IsFalse (pt11_99 == pt11_0, "EOP#3");
Assert.IsFalse (pt11_99 == pt0_11, "EOP#4");
[Test]
public void TestInequalityOp ()
{
+#pragma warning disable 1718 // Comparison made to same variable
Assert.IsFalse (pt11_99 != pt11_99, "IOP#1");
+#pragma warning restore 1718
Assert.IsFalse (pt11_99 != new PointF (1.1F, 9.9F), "IOP#2");
Assert.IsTrue (pt11_99 != pt11_0, "IOP#3");
Assert.IsTrue (pt11_99 != pt0_11, "IOP#4");
[Test]
public void TestEqualityOp ()
{
+#pragma warning disable 1718 // Comparison made to same variable
Assert.IsTrue (sz1_1 == sz1_1, "EOP#1");
+#pragma warning restore 1718
Assert.IsTrue (sz1_1 == new Size (1, 1), "EOP#2");
Assert.IsTrue (! (sz1_1 == sz1_0), "EOP#3");
Assert.IsTrue (! (sz1_1 == sz0_1), "EOP#4");
[Test]
public void TestInequalityOp ()
{
+#pragma warning disable 1718 // Comparison made to same variable
Assert.IsTrue (! (sz1_1 != sz1_1), "IOP#1");
+#pragma warning restore 1718
Assert.IsTrue (! (sz1_1 != new Size (1, 1)), "IOP#2");
Assert.IsTrue (sz1_1 != sz1_0, "IOP#3");
Assert.IsTrue (sz1_1 != sz0_1, "IOP#4");
try {
// culture == null
szconv.ConvertTo (null, null, sz, typeof (string));
- } catch (NullReferenceException e) {
+ } catch (NullReferenceException) {
Assert.Fail ("CT#8: must not throw NullReferenceException");
}
}
[Test]
public void TestEqualityOp ()
{
+#pragma warning disable 1718 // Comparison made to same variable
Assert.IsTrue (sz11_99 == sz11_99, "EOP#1");
+#pragma warning restore 1718
Assert.IsTrue (sz11_99 == new SizeF (1.1F, 9.9F), "EOP#2");
Assert.IsFalse (sz11_99 == sz11_0, "EOP#3");
Assert.IsFalse (sz11_99 == sz0_11, "EOP#4");
[Test]
public void TestInequalityOp ()
{
+#pragma warning disable 1718 // Comparison made to same variable
Assert.IsFalse (sz11_99 != sz11_99, "IOP#1");
+#pragma warning restore 1718
Assert.IsFalse (sz11_99 != new SizeF (1.1F, 9.9F), "IOP#2");
Assert.IsTrue (sz11_99 != sz11_0, "IOP#3");
Assert.IsTrue (sz11_99 != sz0_11, "IOP#4");
{"System.Management", 0},
{"System.Messaging", 0},
{"System.Net", 2},
- {"System.Net.Http", 3},
+ {"System.Net.Http", 4},
{"System.Numerics.Vectors", 3},
{"System.Runtime.InteropServices.RuntimeInformation", 2},
{"System.Runtime.Remoting", 0},
typedef struct {
const char runtime_version [12];
const char framework_version [4];
- const AssemblyVersionSet version_sets [4];
+ const AssemblyVersionSet version_sets [5];
} MonoRuntimeInfo;
#define mono_domain_assemblies_lock(domain) mono_locks_os_acquire(&(domain)->assemblies_lock, DomainAssembliesLock)
static const MonoRuntimeInfo *current_runtime = NULL;
+#define NOT_AVAIL {0xffffU,0xffffU,0xffffU,0xffffU}
+
/* This is the list of runtime versions supported by this JIT.
*/
static const MonoRuntimeInfo supported_runtimes[] = {
- {"v4.0.30319","4.5", { {4,0,0,0}, {10,0,0,0}, {4,0,0,0}, {4,0,0,0} } },
- {"mobile", "2.1", { {2,0,5,0}, {10,0,0,0}, {2,0,5,0}, {2,0,5,0} } },
- {"moonlight", "2.1", { {2,0,5,0}, { 9,0,0,0}, {3,5,0,0}, {3,0,0,0} } },
+ {"v4.0.30319","4.5", { {4,0,0,0}, {10,0,0,0}, {4,0,0,0}, {4,0,0,0}, {4,0,0,0} } },
+ {"mobile", "2.1", { {2,0,5,0}, {10,0,0,0}, {2,0,5,0}, {2,0,5,0}, {4,0,0,0} } },
+ {"moonlight", "2.1", { {2,0,5,0}, { 9,0,0,0}, {3,5,0,0}, {3,0,0,0}, NOT_AVAIL } },
};
+#undef NOT_AVAIL
+
/* The stable runtime version */
#define DEFAULT_RUNTIME_VERSION "v4.0.30319"
$(monodir)/mono/utils/libmonoutils.la \
$(GLIB_LIBS) $(LIBICONV)
+if FULL_AOT_TESTS
+# if the tests are going to run with framework assemblies compiled with
+# -d:MOBILE, tell the runtime to remap framework assemblies using the mobile
+# runtime info
+MOBILE_RUNTIME_ARG=--runtime=mobile
+else
+MOBILE_RUNTIME_ARG=
+endif
+
CLASS=$(mcs_topdir)/class/lib/$(DEFAULT_PROFILE)
RUNTIME_EXECUTABLE = $(if $(BOEHM),$(top_builddir)/mono/mini/mono-boehm,$(top_builddir)/runtime/mono-wrapper)
-MINI_RUNTIME = MONO_PATH=$(CLASS) $(RUNTIME_EXECUTABLE)
+MINI_RUNTIME = MONO_PATH=$(CLASS) $(RUNTIME_EXECUTABLE) $(MOBILE_RUNTIME_ARG)
TOOLS_RUNTIME = MONO_PATH=$(mcs_topdir)/class/lib/build $(top_builddir)/runtime/mono-wrapper
INTERP_RUNTIME = $(MINI_RUNTIME) --interpreter
RUNTIME_AOTCHECK = MONO_PATH="$(CLASS)$(PLATFORM_PATH_SEPARATOR)." $(RUNTIME_EXECUTABLE)
mkdir $(FULLAOT_TMP_DIR)
$(MAKE) fullaot-libs AOT_FLAGS="full,$(MONO_FULLAOT_ADDITIONAL_ARGS)$(INVARIANT_AOT_OPTIONS)" GSHAREDVT=$(GSHAREDVT)
cp $(regtests) $(fullaot_regtests) generics-variant-types.dll TestDriver.dll $(FULLAOT_TMP_DIR)/
- MONO_PATH=$(FULLAOT_TMP_DIR) $(top_builddir)/runtime/mono-wrapper $(LLVM_AOT_RUNTIME_OPTS) $(GSHAREDVT_RUNTIME_OPTS) --aot="full,$(MONO_FULLAOT_ADDITIONAL_ARGS)$(INVARIANT_AOT_OPTIONS)" $(FULLAOT_TMP_DIR)/{generics-variant-types.dll,TestDriver.dll,*.exe} || exit 1
+ MONO_PATH=$(FULLAOT_TMP_DIR) $(top_builddir)/runtime/mono-wrapper $(MOBILE_RUNTIME_ARG) $(LLVM_AOT_RUNTIME_OPTS) $(GSHAREDVT_RUNTIME_OPTS) --aot="full,$(MONO_FULLAOT_ADDITIONAL_ARGS)$(INVARIANT_AOT_OPTIONS)" $(FULLAOT_TMP_DIR)/{generics-variant-types.dll,TestDriver.dll,*.exe} || exit 1
ln -s $(if $(MONO_EXECUTABLE),$(MONO_EXECUTABLE),$$PWD/mono) $(FULLAOT_TMP_DIR)/
- for i in $(fullaot_regtests); do echo $$i; MONO_PATH=$(FULLAOT_TMP_DIR) $(top_builddir)/runtime/mono-wrapper --full-aot $(FULLAOT_TMP_DIR)/$$i --exclude '!FULLAOT' $(ARCH_FULLAOT_EXCLUDE) || exit 1; done
+ for i in $(fullaot_regtests); do echo $$i; MONO_PATH=$(FULLAOT_TMP_DIR) $(top_builddir)/runtime/mono-wrapper $(MOBILE_RUNTIME_ARG) --full-aot $(FULLAOT_TMP_DIR)/$$i --exclude '!FULLAOT' $(ARCH_FULLAOT_EXCLUDE) || exit 1; done
# This can run in parallel
fullaot-libs: $(patsubst %,fullaot-tmp/%.dylib,$(FULLAOT_LIBS))
fullaot-tmp/%.dylib: $(CLASS)/%
cp $(CLASS)/$* fullaot-tmp/
mkdir fullaot-tmp/$*-tmp
- MONO_PATH="fullaot-tmp/$(PLATFORM_PATH_SEPARATOR)$(CLASS)" $(top_builddir)/runtime/mono-wrapper $(if $(GSHAREDVT),-O=gsharedvt) --aot=$(AOT_FLAGS),temp-path=fullaot-tmp/$*-tmp fullaot-tmp/$*
+ MONO_PATH="fullaot-tmp/$(PLATFORM_PATH_SEPARATOR)$(CLASS)" $(top_builddir)/runtime/mono-wrapper $(MOBILE_RUNTIME_ARG) $(if $(GSHAREDVT),-O=gsharedvt) --aot=$(AOT_FLAGS),temp-path=fullaot-tmp/$*-tmp fullaot-tmp/$*
rm -rf fullaot-tmp/$*-tmp
llvmfullaotcheck:
mkdir fullaot-tmp
$(MAKE) fullaot-libs AOT_FLAGS="llvmonly,$(MONO_FULLAOT_ADDITIONAL_ARGS)$(INVARIANT_AOT_OPTIONS)"
cp $(llvmonly_regtests) generics-variant-types.dll TestDriver.dll fullaot-tmp/
- MONO_PATH=fullaot-tmp $(top_builddir)/runtime/mono-wrapper --aot=llvmonly fullaot-tmp/{generics-variant-types.dll,TestDriver.dll,*.exe} || exit 1
+ MONO_PATH=fullaot-tmp $(top_builddir)/runtime/mono-wrapper $(MOBILE_RUNTIME_ARG) --aot=llvmonly fullaot-tmp/{generics-variant-types.dll,TestDriver.dll,*.exe} || exit 1
ln -s $$PWD/mono fullaot-tmp/
- for i in $(llvmonly_regtests); do echo $$i; MONO_PATH=fullaot-tmp $(top_builddir)/runtime/mono-wrapper --llvmonly fullaot-tmp/$$i --exclude '!BITCODE' || exit 1; done
+ for i in $(llvmonly_regtests); do echo $$i; MONO_PATH=fullaot-tmp $(top_builddir)/runtime/mono-wrapper $(MOBILE_RUNTIME_ARG) --llvmonly fullaot-tmp/$$i --exclude '!BITCODE' || exit 1; done
gccheck: gc-test.exe
MONO_GC_PARAMS=stack-mark=precise MONO_GC_DEBUG=clear-at-gc ./mono-sgen gc-test.exe
-nowarn:0169 -nowarn:1690 -nowarn:0649 -nowarn:0612 -nowarn:3021 \
-nowarn:0197 $(PROFILE_MCS_FLAGS)
-MCS = $(MCS_NO_LIB) -lib:$(CLASS)
+MCS = $(MCS_NO_LIB)
ILASM = $(TOOLS_RUNTIME) $(mcs_topdir)/class/lib/build/ilasm.exe
$(ILASM) -out:$@ $<
if !FULL_AOT_TESTS
-TEST_DRIVER_HARD_KILL_FEATURE=-r:Mono.Posix.dll
+TEST_DRIVER_HARD_KILL_FEATURE=-r:$(CLASS)/Mono.Posix.dll
endif
if FULL_AOT_TESTS
endif
%.exe: %.cs $(TEST_DRIVER_DEPEND)
+ $(MCS) -r:$(CLASS)/System.dll -r:$(CLASS)/System.Xml.dll -r:$(CLASS)/System.Core.dll -r:TestDriver.dll $(TEST_DRIVER_HARD_KILL_FEATURE) -out:$@ $<
+
+# N.B. test-runner.exe references the TOOLS_RUNTIME versions of the framework assemblies
+test-runner.exe: test-runner.cs $(TEST_DRIVER_DEPEND)
$(MCS) -r:System.dll -r:System.Xml.dll -r:System.Core.dll -r:TestDriver.dll $(TEST_DRIVER_HARD_KILL_FEATURE) -out:$@ $<
%.dll: %.cs
- $(MCS) -r:System.dll -target:library -out:$@ $<
+ $(MCS) -r:$(CLASS)/System.dll -target:library -out:$@ $<
reference-loader.exe: reference-loader.cs TestingReferenceAssembly.dll TestingReferenceReferenceAssembly.dll $(TEST_DRIVER_DEPEND)
- $(MCS) -r:System.dll -r:TestDriver.dll -r:TestingReferenceAssembly.dll -r:TestingReferenceReferenceAssembly.dll $(TEST_DRIVER_HARD_KILL_FEATURE) -out:$@ $(srcdir)/reference-loader.cs
+ $(MCS) -r:$(CLASS)/System.dll -r:TestDriver.dll -r:TestingReferenceAssembly.dll -r:TestingReferenceReferenceAssembly.dll $(TEST_DRIVER_HARD_KILL_FEATURE) -out:$@ $(srcdir)/reference-loader.cs
TestingReferenceAssembly.dll: TestingReferenceAssembly.cs
$(MCS) -target:library -out:$@ $<
# We use 'test-support-files' to handle an ordering issue between the 'mono/' and 'runtime/' directories
bug-80307.exe: $(srcdir)/bug-80307.cs
- $(MCS) -r:System.Web.dll -out:$@ $(srcdir)/bug-80307.cs
+ $(MCS) -r:$(CLASS)/System.Web.dll -out:$@ $(srcdir)/bug-80307.cs
cd $(top_builddir)/runtime && $(MAKE) test-support-files
EXTRA_DIST += bug-81673-interface.cs
$(MCS) -r:generic-delegate2-lib.2.dll -out:$@ $(srcdir)/generic-delegate2.2.cs
bug-3903.exe: bug-3903.cs
- $(MCS_NO_LIB) -lib:$(srcdir)/../../external/binary-reference-assemblies/v2.0/ $(srcdir)/bug-3903.cs -r:System.Core.dll -out:$@
+ $(MCS_NO_LIB) $(srcdir)/bug-3903.cs -r:$(srcdir)/../../external/binary-reference-assemblies/v2.0/System.Core.dll -out:$@
gshared: test-generic-sharing
mono_perfcounters_init ();
#endif
mono_counters_init ();
+ mono_tls_init_runtime_keys ();
mono_metadata_init ();
mono_images_init ();
mono_assemblies_init ();
if (verify_pe || run_new_metadata_verifier) {
run_new_metadata_verifier = 1;
}
-
+
if (run_new_metadata_verifier) {
mono_verifier_set_mode (verifier_mode);