[Mono.Options] CommandSet and PCL/NetStandard Support (#4719)
authorMatthew Leibowitz <mattleibow@live.com>
Thu, 20 Apr 2017 20:28:05 +0000 (22:28 +0200)
committerJonathan Pryor <jonpryor@vt.edu>
Thu, 20 Apr 2017 20:28:05 +0000 (16:28 -0400)
commit7e2571ed334e9cee3f0d3bafeef02852310f4d3b
tree3341c26c0ba6edf641dd13dd647abf6ef02b0d80
parentca2292b6c23608960c80af30e28d69d2e6ee9e0a
[Mono.Options] CommandSet and PCL/NetStandard Support (#4719)

When `PCL` is defined, the intent is that the resulting
`Mono.Options.dll` assembly will be usable on all PCL profiles.
This includes "silly" profiles such as Profile259, which lacks the
`System.Console` type, meaning e.g. `Console.Out` doesn't exist.

Unfortunately, the
`CommandSet(string, Converter<string, string, TextWriter, TextWriter)`
constructor would use `Console.Out` and `Console.Error` when the
`TextWriter` parameters were `null`, meaning this constructor can't
be provided for all PCL profiles.

Altering the constructor to instead use `TextWriter.Null` would allow
the constructor to be provided, but would be a *worse* experience,
IMHO: anybody (everybody!) expecting the default values to
"do something useful" will be sorely disappointed, as output and
error messages would instead be dropped. :-(

Instead, remove this constructor:

public CommandSet (string suite, MessageLocalizerConverter localizer = null, TextWriter output = null, TextWriter error = null);

and replace it with these *two* constructors:

public CommandSet (string suite, MessageLocalizerConverter localizer = null)
public CommandSet (string suite, TextWriter output, TextWriter error, MessageLocalizerConverter localizer = null)

The first constructor, which accepts no `TextWriter` parameters, is
only provided in non-PCL builds, allowing it to use `Console.Out`.

The second constructor is available in PCL profiles, and *requires*
that `output` and `error` be non-`null`.

Documentation has been updated accordingly.
mcs/class/Mono.Options/Documentation/en/Mono.Options/CommandSet.xml
mcs/class/Mono.Options/Mono.Options/Options.cs