diff --git a/appveyor.yml b/appveyor.yml
index a3b73034..c7979afb 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -1,6 +1,8 @@
#version should be only changed with RELEASE eminent, see RELEASE.md
version: 2.4.{build}
+image: Visual Studio 2017
+
clone_depth: 1
pull_requests:
do_not_increment_build_number: true
diff --git a/src/CommandLine/CommandLine.csproj b/src/CommandLine/CommandLine.csproj
index 46e6d82d..3764bcb6 100644
--- a/src/CommandLine/CommandLine.csproj
+++ b/src/CommandLine/CommandLine.csproj
@@ -14,7 +14,7 @@
gsscoder;nemec;ericnewton76
Command Line Parser Library
$(VersionSuffix)
- 2.4.0
+ 0.0.0
Terse syntax C# command line parser for .NET. For FSharp support see CommandLineParser.FSharp. The Command Line Parser Library offers to CLR applications a clean and concise API for manipulating command line arguments and related tasks.
Terse syntax C# command line parser for .NET with F# support. The Command Line Parser Library offers to CLR applications a clean and concise API for manipulating command line arguments and related tasks.
Copyright (c) 2005 - 2018 Giacomo Stelluti Scala & Contributors
@@ -35,7 +35,7 @@
-
+
diff --git a/src/CommandLine/Core/ReflectionExtensions.cs b/src/CommandLine/Core/ReflectionExtensions.cs
index 2f4faf0f..70f1afc5 100644
--- a/src/CommandLine/Core/ReflectionExtensions.cs
+++ b/src/CommandLine/Core/ReflectionExtensions.cs
@@ -93,10 +93,6 @@ public static IEnumerable SetProperties(
private static IEnumerable SetValue(this SpecificationProperty specProp, T instance, object value)
{
- Action fail = inner => {
- throw new InvalidOperationException(CannotSetValueToTargetInstance, inner);
- };
-
try
{
specProp.Property.SetValue(instance, value, null);
@@ -106,17 +102,16 @@ private static IEnumerable SetValue(this SpecificationProperty specPro
{
return new[] { new SetValueExceptionError(specProp.Specification.FromSpecification(), e.InnerException, value) };
}
- catch (Exception e)
+ catch (ArgumentException e)
{
- return new[] { new SetValueExceptionError(specProp.Specification.FromSpecification(), e, value) };
+ var argEx = new ArgumentException(InvalidAttributeConfigurationError.ErrorMessage, e);
+
+ return new[] { new SetValueExceptionError(specProp.Specification.FromSpecification(), argEx, value) };
}
- catch(ArgumentException e)
+ catch (Exception e)
{
- var argEx = new ArgumentException(InvalidAttributeConfigurationError.ErrorMessage, e);
- fail(argEx);
+ return new[] { new SetValueExceptionError(specProp.Specification.FromSpecification(), e, value) };
}
-
- return instance;
}
public static object CreateEmptyArray(this Type type)
@@ -215,4 +210,4 @@ public static bool IsPrimitiveEx(this Type type)
|| Convert.GetTypeCode(type) != TypeCode.Object;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/CommandLine/Error.cs b/src/CommandLine/Error.cs
index b1bc3e94..5a562689 100644
--- a/src/CommandLine/Error.cs
+++ b/src/CommandLine/Error.cs
@@ -64,8 +64,7 @@ public enum ErrorType
///
/// Value of type.
///
- SetValueExceptionError
- VersionRequestedError,
+ SetValueExceptionError,
///
/// Value of type.
///
@@ -511,6 +510,18 @@ public object Value
{
get { return value; }
}
+ }
+ ///
+ /// Models an error generated when an invalid token is detected.
+ ///
+ public sealed class InvalidAttributeConfigurationError : Error
+ {
+ public const string ErrorMessage = "Check if Option or Value attribute values are set properly for the given type.";
+
+ internal InvalidAttributeConfigurationError()
+ : base(ErrorType.InvalidAttributeConfigurationError, true)
+ {
+ }
}
-}
\ No newline at end of file
+}
diff --git a/tests/CommandLine.Tests/Unit/Core/InstanceBuilderTests.cs b/tests/CommandLine.Tests/Unit/Core/InstanceBuilderTests.cs
index eef9a674..c6234089 100644
--- a/tests/CommandLine.Tests/Unit/Core/InstanceBuilderTests.cs
+++ b/tests/CommandLine.Tests/Unit/Core/InstanceBuilderTests.cs
@@ -1007,6 +1007,22 @@ public void Parse_option_with_exception_thrown_from_setter_generates_SetValueExc
// Teardown
}
+ [Fact]
+ public void Parse_default_bool_type_string_SetValueExceptionError()
+ {
+ // Fixture setup
+ string name = nameof(Options_With_InvalidDefaults.FileName).ToLower();
+ var expectedResult = new[] { new SetValueExceptionError(new NameInfo("", name),
+ new ArgumentException(InvalidAttributeConfigurationError.ErrorMessage), "bad") };
+
+ // Exercize system
+ var result = InvokeBuild(
+ new[] { name, "bad" });
+
+ // Verify outcome
+ ((NotParsed)result).Errors.Should().BeEquivalentTo(expectedResult);
+ }
+
[Theory]
[InlineData(new[] { "--stringvalue", "x-" }, "x-")]
@@ -1133,20 +1149,6 @@ public void Parse_TimeSpan()
// Teardown
}
- [Fact]
- public void Build_DefaultBoolTypeString_ThrowsInvalidOperationException()
- {
- // Exercize system
- Action test = () => InvokeBuild(
- new string[] { });
-
- // Verify outcome
- test.ShouldThrow()
- .WithMessage(ReflectionExtensions.CannotSetValueToTargetInstance)
- .WithInnerException()
- .WithInnerMessage(InvalidAttributeConfigurationError.ErrorMessage);
- }
-
[Fact]
public void OptionClass_IsImmutable_HasNoCtor()
@@ -1163,7 +1165,7 @@ private class ValueWithNoSetterOptions
}
- public static IEnumerable