Fix DefaultValue for FileInfo and DirectoryInfo (#1238)

Commit d3f4f5f208 introduced automatic conversion to FileInfo and DirectoryInfo but failed to properly handle the conversion if the value comes from the [DefaultValue] attribute.

Using both `var (converter, stringConstructor) = GetConverter(...)` and `var (converter, _) = GetConverter(...)` should have been a red flag!
This commit is contained in:
Cédric Luthi
2023-09-21 13:05:42 +02:00
committed by GitHub
parent 943c045fab
commit 5296e56b1c
3 changed files with 51 additions and 32 deletions

View File

@ -8,6 +8,7 @@ public class HorseSettings : MammalSettings
public DayOfWeek Day { get; set; }
[CommandOption("--file")]
[DefaultValue("food.txt")]
public FileInfo File { get; set; }
[CommandOption("--directory")]

View File

@ -989,6 +989,7 @@ public sealed partial class CommandAppTests
{
horse.Legs.ShouldBe(4);
horse.Name.ShouldBe("Arkle");
horse.File.Name.ShouldBe("food.txt");
});
}