mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-07-01 10:28:16 +08:00
Fix issues with nullability and netstandard2.0
This commit is contained in:

committed by
Patrik Svensson

parent
7dce4af552
commit
a70cc90797
@ -85,7 +85,7 @@ internal static class CommandValueResolver
|
||||
}
|
||||
|
||||
// Assign the value to the parameter.
|
||||
binder.Bind(mapped.Parameter, resolver, converter.ConvertFromInvariantString(mapped.Value));
|
||||
binder.Bind(mapped.Parameter, resolver, converter.ConvertFromInvariantString(mapped.Value ?? string.Empty));
|
||||
}
|
||||
}
|
||||
|
||||
@ -130,7 +130,13 @@ internal static class CommandValueResolver
|
||||
if (parameter.ParameterType.IsArray)
|
||||
{
|
||||
// Return a converter for each array item (not the whole array)
|
||||
return TypeDescriptor.GetConverter(parameter.ParameterType.GetElementType());
|
||||
var elementType = parameter.ParameterType.GetElementType();
|
||||
if (elementType == null)
|
||||
{
|
||||
throw new InvalidOperationException("Could not get element type");
|
||||
}
|
||||
|
||||
return TypeDescriptor.GetConverter(elementType);
|
||||
}
|
||||
|
||||
if (parameter.IsFlagValue())
|
||||
|
@ -29,13 +29,13 @@ internal static class HelpWriter
|
||||
|
||||
private sealed class HelpOption
|
||||
{
|
||||
public string Short { get; }
|
||||
public string Long { get; }
|
||||
public string? Short { get; }
|
||||
public string? Long { get; }
|
||||
public string? Value { get; }
|
||||
public bool? ValueIsOptional { get; }
|
||||
public string? Description { get; }
|
||||
|
||||
public HelpOption(string @short, string @long, string? @value, bool? valueIsOptional, string? description)
|
||||
public HelpOption(string? @short, string? @long, string? @value, bool? valueIsOptional, string? description)
|
||||
{
|
||||
Short = @short;
|
||||
Long = @long;
|
||||
|
Reference in New Issue
Block a user