You've already forked linux-packaging-mono
Imported Upstream version 4.6.0.125
Former-commit-id: a2155e9bd80020e49e72e86c44da02a8ac0e57a4
This commit is contained in:
parent
a569aebcfd
commit
e79aa3c0ed
@@ -1,6 +0,0 @@
|
||||
2008-10-13 Jonathan Pryor <jpryor@novell.com>
|
||||
|
||||
* ChangeLog: Started.
|
||||
* AssemblyInfo.cs: Added; assembly-level attributes for
|
||||
Mono.Options.dll.
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
2010-06-09 Jonathan Pryor <jpryor@novell.com>
|
||||
|
||||
* Mono.Options_test.dll.sources: Add additional sources.
|
||||
|
||||
2008-10-22 Jonathan Pryor <jpryor@novell.com>
|
||||
|
||||
* Documentation/en/**/*.xml: s/NDesk.Options/Mono.Options/g (How'd I
|
||||
miss this earlier?).
|
||||
|
||||
2008-10-22 Jonathan Pryor <jpryor@novell.com>
|
||||
|
||||
* Documentation/en/Mono.Options/OptionSet.xml: Document the support for
|
||||
nullable types.
|
||||
|
||||
2008-10-17 Jonathan Pryor <jpryor@novell.com>
|
||||
|
||||
* Makefile: Use NO_INSTALL to prevent installation instead of using
|
||||
do-install and do-uninstall.
|
||||
|
||||
2008-10-17 Jonathan Pryor <jpryor@novell.com>
|
||||
|
||||
* Makefile: Add fixup-docs target, to simplify importing NDesk.Options
|
||||
documentation for use in Mono.Options
|
||||
|
||||
2008-10-14 Jonathan Pryor <jpryor@novell.com>
|
||||
|
||||
* Makefile: Don't bother installing Mono.Options.dll into the GAC (or
|
||||
anywhere else), instead just follow a subset of the App Deployment
|
||||
Guidelines and install just the source into $prefix/lib/mono-options.
|
||||
|
||||
2008-10-14 Jonathan Pryor <jpryor@novell.com>
|
||||
|
||||
* Makefile: Install Options.cs into the GAC, so that mono-options.pc
|
||||
can perform source install (as suggeted by App Deployment Guidelines).
|
||||
|
||||
2008-10-13 Jonathan Pryor <jpryor@novell.com>
|
||||
|
||||
* ChangeLog: Started.
|
||||
* Makefile: Added; build Mono.Options; do NOT install as an ABI-stable
|
||||
package.
|
||||
* Mono.Options.dll.sources: Added; sources for Mono.Options.dll.
|
||||
* Mono.Options_test.dll.sources: Added; Test sources.
|
||||
|
||||
@@ -8,8 +8,9 @@ LIBRARY_PACKAGE = none
|
||||
NO_INSTALL = yes
|
||||
|
||||
LIB_REFS = System
|
||||
LIB_MCS_FLAGS = /r:$(corlib)
|
||||
TEST_MCS_FLAGS = /r:Mono.Posix.dll /r:System.dll /r:System.Core.dll
|
||||
LIB_MCS_FLAGS =
|
||||
TEST_MCS_FLAGS =
|
||||
TEST_LIB_REFS = Mono.Posix System System.Core
|
||||
|
||||
mono_sourcelibs_DIR = $(DESTDIR)$(mono_libdir)/mono-source-libs
|
||||
mono_options_DATA = Mono.Options/Options.cs
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
2010-06-09 Jonathan Pryor <jpryor@novell.com>
|
||||
|
||||
* Options.cs: Remove use of 'var' so that C# 2.0 can be used.
|
||||
|
||||
2010-06-09 Jonathan Pryor <jpryor@novell.com>
|
||||
|
||||
* Options.cs: Fix RemoveItem() and SetItem() so that removing by index
|
||||
and using the numeric indexer work as expected.
|
||||
|
||||
2010-06-08 Jonathan Pryor <jpryor@novell.com>
|
||||
|
||||
* Options.cs: Don't overly split option values, only split to obtain
|
||||
the maximum number of desired values. This better supports e.g. DOS
|
||||
paths in multi-value values, e.g. '-DPATH=C:\tmp' would now create
|
||||
the values {"PATH", "C:\tmp"} instead of {"PATH", "C", "\tmp"}.
|
||||
|
||||
2009-04-18 Jonathan Pryor <jpryor@novell.com>
|
||||
|
||||
* Options.cs: "Code sharing": Use StringCodea.WrappedLines() from
|
||||
Cadenza for the line wrapping algorithm. (Only fitting as
|
||||
WrappedLines() came from Mono.Options in the first place!)
|
||||
Patch thanks to Federico Di Gregorio.
|
||||
|
||||
2009-04-18 Jonathan Pryor <jpryor@novell.com>
|
||||
|
||||
* Options.cs: GetLineEnd() shouldn't skip the start character, as it
|
||||
may contain '\n' (thus preventing the following text from being
|
||||
properly indented).
|
||||
|
||||
2009-04-17 Jonathan Pryor <jpryor@novell.com>
|
||||
|
||||
* Options.cs: Viktor Lundgren reported that Option.Description text of
|
||||
`"aaa." . "a" x 64` (that is, "aaa." followed by 64 "a"s) would cause
|
||||
GetLines() to go into an infinite loop and (eventually) die from an
|
||||
OutOfMemoryException. Oops. Fix this, simplify the logic, and turn
|
||||
GetLines() into an IEnumerable<string>.
|
||||
|
||||
2008-10-23 Jonathan Pryor <jpryor@novell.com>
|
||||
|
||||
* Options.cs: Options.cs: Use the underlying target type in the error
|
||||
message, because "Could not convert string `' to type Nullable`1..."
|
||||
is not nearly as helpful as "Could not convert string `' to type
|
||||
Int32...".
|
||||
|
||||
2008-10-22 Jonathan Pryor <jpryor@novell.com>
|
||||
|
||||
* Option.cs: Add support for nullable types to Options.Parse<T>().
|
||||
Namespace "harmonization" with NDesk.Options so that the same source
|
||||
file can be used in each project.
|
||||
|
||||
2008-10-13 Jonathan Pryor <jpryor@novell.com>
|
||||
|
||||
* ChangeLog: Started.
|
||||
* Options.cs: Added; Command line option parser. A (renamed) copy of
|
||||
NDesk.Options 0.2.1 (see git repo for prior history).
|
||||
|
||||
@@ -135,7 +135,11 @@ using System.ComponentModel;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Runtime.Serialization;
|
||||
#if PCL
|
||||
using System.Reflection;
|
||||
#else
|
||||
using System.Security.Permissions;
|
||||
#endif
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
@@ -147,6 +151,12 @@ using System.Linq;
|
||||
using NDesk.Options;
|
||||
#endif
|
||||
|
||||
#if PCL
|
||||
using MessageLocalizerConverter = System.Func<string, string>;
|
||||
#else
|
||||
using MessageLocalizerConverter = System.Converter<string, string>;
|
||||
#endif
|
||||
|
||||
#if NDESK_OPTIONS
|
||||
namespace NDesk.Options
|
||||
#else
|
||||
@@ -448,15 +458,34 @@ namespace Mono.Options
|
||||
protected static T Parse<T> (string value, OptionContext c)
|
||||
{
|
||||
Type tt = typeof (T);
|
||||
bool nullable = tt.IsValueType && tt.IsGenericType &&
|
||||
!tt.IsGenericTypeDefinition &&
|
||||
tt.GetGenericTypeDefinition () == typeof (Nullable<>);
|
||||
Type targetType = nullable ? tt.GetGenericArguments () [0] : typeof (T);
|
||||
TypeConverter conv = TypeDescriptor.GetConverter (targetType);
|
||||
#if PCL
|
||||
TypeInfo ti = tt.GetTypeInfo ();
|
||||
#else
|
||||
Type ti = tt;
|
||||
#endif
|
||||
bool nullable =
|
||||
ti.IsValueType &&
|
||||
ti.IsGenericType &&
|
||||
!ti.IsGenericTypeDefinition &&
|
||||
ti.GetGenericTypeDefinition () == typeof (Nullable<>);
|
||||
#if PCL
|
||||
Type targetType = nullable ? tt.GenericTypeArguments [0] : tt;
|
||||
#else
|
||||
Type targetType = nullable ? tt.GetGenericArguments () [0] : tt;
|
||||
#endif
|
||||
T t = default (T);
|
||||
try {
|
||||
if (value != null)
|
||||
if (value != null) {
|
||||
#if PCL
|
||||
if (targetType.GetTypeInfo ().IsEnum)
|
||||
t = (T) Enum.Parse (targetType, value, true);
|
||||
else
|
||||
t = (T) Convert.ChangeType (value, targetType);
|
||||
#else
|
||||
TypeConverter conv = TypeDescriptor.GetConverter (targetType);
|
||||
t = (T) conv.ConvertFromString (value);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new OptionException (
|
||||
@@ -572,10 +601,12 @@ namespace Mono.Options
|
||||
public abstract string Description { get; }
|
||||
public abstract bool GetArguments (string value, out IEnumerable<string> replacement);
|
||||
|
||||
#if !PCL
|
||||
public static IEnumerable<string> GetArgumentsFromFile (string file)
|
||||
{
|
||||
return GetArguments (File.OpenText (file), true);
|
||||
}
|
||||
#endif
|
||||
|
||||
public static IEnumerable<string> GetArguments (TextReader reader)
|
||||
{
|
||||
@@ -621,11 +652,12 @@ namespace Mono.Options
|
||||
}
|
||||
finally {
|
||||
if (close)
|
||||
reader.Close ();
|
||||
reader.Dispose ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if !PCL
|
||||
public class ResponseFileSource : ArgumentSource {
|
||||
|
||||
public override string[] GetNames ()
|
||||
@@ -647,8 +679,11 @@ namespace Mono.Options
|
||||
return true;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !PCL
|
||||
[Serializable]
|
||||
#endif
|
||||
public class OptionException : Exception {
|
||||
private string option;
|
||||
|
||||
@@ -668,16 +703,19 @@ namespace Mono.Options
|
||||
this.option = optionName;
|
||||
}
|
||||
|
||||
#if !PCL
|
||||
protected OptionException (SerializationInfo info, StreamingContext context)
|
||||
: base (info, context)
|
||||
{
|
||||
this.option = info.GetString ("OptionName");
|
||||
}
|
||||
#endif
|
||||
|
||||
public string OptionName {
|
||||
get {return this.option;}
|
||||
}
|
||||
|
||||
#if !PCL
|
||||
#pragma warning disable 618 // SecurityPermissionAttribute is obsolete
|
||||
[SecurityPermission (SecurityAction.LinkDemand, SerializationFormatter = true)]
|
||||
#pragma warning restore 618
|
||||
@@ -686,6 +724,7 @@ namespace Mono.Options
|
||||
base.GetObjectData (info, context);
|
||||
info.AddValue ("OptionName", option);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
public delegate void OptionAction<TKey, TValue> (TKey key, TValue value);
|
||||
@@ -697,15 +736,15 @@ namespace Mono.Options
|
||||
{
|
||||
}
|
||||
|
||||
public OptionSet (Converter<string, string> localizer)
|
||||
public OptionSet (MessageLocalizerConverter localizer)
|
||||
{
|
||||
this.localizer = localizer;
|
||||
this.roSources = new ReadOnlyCollection<ArgumentSource>(sources);
|
||||
}
|
||||
|
||||
Converter<string, string> localizer;
|
||||
MessageLocalizerConverter localizer;
|
||||
|
||||
public Converter<string, string> MessageLocalizer {
|
||||
public MessageLocalizerConverter MessageLocalizer {
|
||||
get {return localizer;}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
2010-06-09 Jonathan Pryor <jpryor@novell.com>
|
||||
|
||||
* OptionSetTest.cs: Make OptionSetTest inherit from ListContract so
|
||||
that the IList<T> and ICollection<T> interfaces are fully tested.
|
||||
* BaseRocksFixture.cs, CollectionContract.cs, ListContract.cs: Added;
|
||||
interface contract tests from Cadenza.
|
||||
|
||||
2010-06-08 Jonathan Pryor <jpryor@novell.com>
|
||||
|
||||
* OptionSetTest.cs: Add tests for constrained value splitting.
|
||||
|
||||
2008-04-18 Jonathan Pryor <jpryor@novell.com>
|
||||
|
||||
* OptionSetTest.cs: Update WriteOptionDescriptions() for new,
|
||||
better-defined line-wrapping semantics.
|
||||
|
||||
2008-04-18 Jonathan Pryor <jpryor@novell.com>
|
||||
|
||||
* OptionSetTest.cs: Add test to check \n\n Option.Description handling.
|
||||
|
||||
2008-04-17 Jonathan Pryor <jpryor@novell.com>
|
||||
|
||||
* OptionSetTest.cs: Add additional line breaking tests.
|
||||
Remove [Category("NotWorking")], as they work for me.
|
||||
|
||||
2008-11-10 Raja R Harinath <harinath@hurrynot.org>
|
||||
|
||||
* OptionContextTest.cs: Fix syntax error.
|
||||
* OptionTest.cs: Likewise.
|
||||
* OptionSetTest.cs: Likewise.
|
||||
(OptionalValues, CombinationPlatter, Exceptions): Disable for now.
|
||||
|
||||
2008-10-23 Jonathan Pryor <jpryor@novell.com>
|
||||
|
||||
* OptionSetTest.cs: Add a test for the underlying target type within
|
||||
the exception message.
|
||||
|
||||
2008-10-22 Jonathan Pryor <jpryor@novell.com>
|
||||
|
||||
* OptionContextTest.cs, OptionSetTest.cs, OptionTest.cs, Utils.cs:
|
||||
Namespace "harmonization" with Mono.Options, so that we can use
|
||||
identical source in each place, thus minimizing the maintenance
|
||||
burden.
|
||||
* OptionSetTest.cs: Add tests for nullable type support.
|
||||
|
||||
2008-10-13 Jonathan Pryor <jpryor@novell.com>
|
||||
|
||||
* ChangeLog: Started.
|
||||
* OptionContextTest.cs, OptionSetTest.cs, OptionTest.cs, Utils.cs:
|
||||
Added; unit tests for Mono.Options 0.2.1.
|
||||
|
||||
@@ -269,6 +269,26 @@ namespace MonoTests.Mono.Options
|
||||
p, v => { v.Parse (_("-n=")); });
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void EnumValues ()
|
||||
{
|
||||
DayOfWeek a = 0;
|
||||
OptionSet p = new OptionSet () {
|
||||
{ "a=", (DayOfWeek v) => a = v },
|
||||
};
|
||||
p.Parse (_ ("-a=Monday"));
|
||||
Assert.AreEqual (a, DayOfWeek.Monday);
|
||||
p.Parse (_ ("-a=tuesday"));
|
||||
Assert.AreEqual (a, DayOfWeek.Tuesday);
|
||||
p.Parse (_ ("-a=3"));
|
||||
Assert.AreEqual (a, DayOfWeek.Wednesday);
|
||||
p.Parse (_ ("-a=Monday,Tuesday"));
|
||||
Assert.AreEqual (a, DayOfWeek.Monday | DayOfWeek.Tuesday);
|
||||
Utils.AssertException (typeof (OptionException),
|
||||
"Could not convert string `Noday' to type DayOfWeek for option `-a'.",
|
||||
p, v => { v.Parse (_ ("-a=Noday")); });
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void BooleanValues ()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user