mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-04-16 00:42:51 +08:00

When subclassing `Command<TSettings>` which has the [NotNull] attributes, Rider/ReSharper gives this warning: > Nullability of type of parameter 'context' in method does not match overridden member `int Spectre.Console.Cli.Command<TSettings>.Execute(CommandContext, TSettings)` (possibly because of nullability attributes) When subclassing `Command<TSettings>` which does not have the [NotNull] attributes, Rider/ReSharper gives this warning: > The nullability attribute has no effect and can be safely removed The solution is simply to remove the [NotNull] attributes. Since `<Nullable>enable</Nullable>` is set in the project, they are actually not necessary. By the way, the non-generic `Command` class does not have the [NotNull] attributes.
17 lines
441 B
C#
17 lines
441 B
C#
using Spectre.Console;
|
|
|
|
public class GreeterCommand : Command<OptionalArgumentWithDefaultValueSettings>
|
|
{
|
|
private readonly IAnsiConsole _console;
|
|
|
|
public GreeterCommand(IAnsiConsole console)
|
|
{
|
|
_console = console;
|
|
}
|
|
|
|
public override int Execute(CommandContext context, OptionalArgumentWithDefaultValueSettings settings)
|
|
{
|
|
_console.WriteLine(settings.Greeting);
|
|
return 0;
|
|
}
|
|
} |