mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-06-19 13:28:16 +08:00
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:
@ -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")]
|
||||
|
@ -989,6 +989,7 @@ public sealed partial class CommandAppTests
|
||||
{
|
||||
horse.Legs.ShouldBe(4);
|
||||
horse.Name.ShouldBe("Arkle");
|
||||
horse.File.Name.ShouldBe("food.txt");
|
||||
});
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user