Skip to content

Commit e626f9d

Browse files
authored
Merge pull request #194 from ohadschn/master
Change string argument default to null
2 parents 7aa501d + a390ddb commit e626f9d

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

src/CommandLine/Core/ReflectionExtensions.cs

-4
Original file line numberDiff line numberDiff line change
@@ -153,10 +153,6 @@ public static bool IsMutable(this Type type)
153153

154154
public static object CreateDefaultForImmutable(this Type type)
155155
{
156-
if (type == typeof(string))
157-
{
158-
return string.Empty;
159-
}
160156
if (type.GetTypeInfo().IsGenericType && type.GetTypeInfo().GetGenericTypeDefinition() == typeof(IEnumerable<>))
161157
{
162158
return type.GetTypeInfo().GetGenericArguments()[0].CreateEmptyArray();

tests/CommandLine.Tests/Unit/Core/InstanceBuilderTests.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1052,11 +1052,11 @@ public static IEnumerable<object> ImmutableInstanceData
10521052
{
10531053
get
10541054
{
1055-
yield return new object[] { new string[] { }, new Immutable_Simple_Options("", new int[] { }, default(bool), default(long)) };
1055+
yield return new object[] { new string[] { }, new Immutable_Simple_Options(null, new int[] { }, default(bool), default(long)) };
10561056
yield return new object[] { new[] { "--stringvalue=strval0" }, new Immutable_Simple_Options("strval0", new int[] { }, default(bool), default(long)) };
1057-
yield return new object[] { new[] { "-i", "9", "7", "8" }, new Immutable_Simple_Options("", new[] { 9, 7, 8 }, default(bool), default(long)) };
1058-
yield return new object[] { new[] { "-x" }, new Immutable_Simple_Options("", new int[] { }, true, default(long)) };
1059-
yield return new object[] { new[] { "9876543210" }, new Immutable_Simple_Options("", new int[] { }, default(bool), 9876543210L) };
1057+
yield return new object[] { new[] { "-i", "9", "7", "8" }, new Immutable_Simple_Options(null, new[] { 9, 7, 8 }, default(bool), default(long)) };
1058+
yield return new object[] { new[] { "-x" }, new Immutable_Simple_Options(null, new int[] { }, true, default(long)) };
1059+
yield return new object[] { new[] { "9876543210" }, new Immutable_Simple_Options(null, new int[] { }, default(bool), 9876543210L) };
10601060
yield return new object[] { new[] { "--stringvalue=strval0", "-i", "9", "7", "8", "-x", "9876543210" }, new Immutable_Simple_Options("strval0", new[] { 9, 7, 8 }, true, 9876543210L) };
10611061
}
10621062
}

0 commit comments

Comments
 (0)