Skip to content

fix #1360 #1458

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace System.CommandLine.Tests.Binding
public partial class ModelBindingCommandHandlerTests
{
[Theory]
[InlineData(typeof(string), "")]
[InlineData(typeof(string), null)]
[InlineData(typeof(FileInfo), null)]
[InlineData(typeof(int), 0)]
[InlineData(typeof(int?), null)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace System.CommandLine.Tests.Binding
public class ParameterDescriptorTests
{
[Theory]
[InlineData(typeof(string), "")]
[InlineData(typeof(string), null)]
[InlineData(typeof(int), 0)]
[InlineData(typeof(int?), null)]
public void GetDefaultValue_returns_the_default_for_the_type(Type type, object defaultValue)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace System.CommandLine.Tests.Binding
public class PropertyDescriptorTests
{
[Theory]
[InlineData(typeof(string), "")]
[InlineData(typeof(string), null)]
[InlineData(typeof(int), 0)]
[InlineData(typeof(int?), null)]
public void GetDefaultValue_returns_the_default_for_the_type(Type type, object defaultValue)
Expand Down
2 changes: 1 addition & 1 deletion src/System.CommandLine.Tests/CommandTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ public void Command_argument_of_string_defaults_to_empty_when_not_specified()
var result = command.Parse("mycommand");
result.GetValueForArgument(argument)
.Should()
.BeEmpty();
.BeNull();
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ void Execute(string name, int age)

await command.InvokeAsync("command", _console);

boundName.Should().Be("");
boundName.Should().BeNull();
boundAge.Should().Be(0);
}

Expand Down
4 changes: 2 additions & 2 deletions src/System.CommandLine.Tests/OptionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ public void Option_T_default_value_is_validated()
}

[Fact]
public void Option_of_string_defaults_to_empty_when_not_specified()
public void Option_of_string_defaults_to_null_when_not_specified()
{
var option = new Option<string>("-x");

Expand All @@ -331,7 +331,7 @@ public void Option_of_string_defaults_to_empty_when_not_specified()
.BeFalse();
result.GetValueForOption(option)
.Should()
.BeEmpty();
.BeNull();
}

[Fact]
Expand Down
5 changes: 0 additions & 5 deletions src/System.CommandLine/Binding/Binder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,6 @@ internal static bool CanBeBoundFromScalarValue(this Type type)

internal static object? GetDefaultValue(Type type)
{
if (type == typeof(string))
{
return "";
}

if (GetItemTypeIfEnumerable(type) is { } itemType)
{
if (type.IsArray)
Expand Down