mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-04-14 16:02:50 +08:00
Remove unnecessary [NotNull] attributes
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.
This commit is contained in:
parent
83afa97017
commit
2af901a814
@ -14,7 +14,7 @@ public abstract class Command<TSettings> : ICommand<TSettings>
|
||||
/// <param name="context">The command context.</param>
|
||||
/// <param name="settings">The settings.</param>
|
||||
/// <returns>The validation result.</returns>
|
||||
public virtual ValidationResult Validate([NotNull] CommandContext context, [NotNull] TSettings settings)
|
||||
public virtual ValidationResult Validate(CommandContext context, TSettings settings)
|
||||
{
|
||||
return ValidationResult.Success();
|
||||
}
|
||||
@ -25,7 +25,7 @@ public abstract class Command<TSettings> : ICommand<TSettings>
|
||||
/// <param name="context">The command context.</param>
|
||||
/// <param name="settings">The settings.</param>
|
||||
/// <returns>An integer indicating whether or not the command executed successfully.</returns>
|
||||
public abstract int Execute([NotNull] CommandContext context, [NotNull] TSettings settings);
|
||||
public abstract int Execute(CommandContext context, TSettings settings);
|
||||
|
||||
/// <inheritdoc/>
|
||||
ValidationResult ICommand.Validate(CommandContext context, CommandSettings settings)
|
||||
|
@ -34,7 +34,7 @@ internal sealed class ExplainCommand : Command<ExplainCommand.Settings>
|
||||
public bool IncludeHidden { get; }
|
||||
}
|
||||
|
||||
public override int Execute([NotNull] CommandContext context, [NotNull] Settings settings)
|
||||
public override int Execute(CommandContext context, Settings settings)
|
||||
{
|
||||
var tree = new Tree("CLI Configuration");
|
||||
tree.AddNode(ValueMarkup("Application Name", _commandModel.ApplicationName, "no application name"));
|
||||
|
@ -15,7 +15,7 @@ internal sealed class VersionCommand : Command<VersionCommand.Settings>
|
||||
{
|
||||
}
|
||||
|
||||
public override int Execute([NotNull] CommandContext context, [NotNull] Settings settings)
|
||||
public override int Execute(CommandContext context, Settings settings)
|
||||
{
|
||||
_writer.MarkupLine(
|
||||
"[yellow]Spectre.Cli[/] version [aqua]{0}[/]",
|
||||
|
@ -17,7 +17,7 @@ internal sealed class XmlDocCommand : Command<XmlDocCommand.Settings>
|
||||
{
|
||||
}
|
||||
|
||||
public override int Execute([NotNull] CommandContext context, [NotNull] Settings settings)
|
||||
public override int Execute(CommandContext context, Settings settings)
|
||||
{
|
||||
_writer.Write(Serialize(_model), Style.Plain);
|
||||
return 0;
|
||||
|
@ -9,7 +9,7 @@ public class GreeterCommand : Command<OptionalArgumentWithDefaultValueSettings>
|
||||
_console = console;
|
||||
}
|
||||
|
||||
public override int Execute([NotNull] CommandContext context, [NotNull] OptionalArgumentWithDefaultValueSettings settings)
|
||||
public override int Execute(CommandContext context, OptionalArgumentWithDefaultValueSettings settings)
|
||||
{
|
||||
_console.WriteLine(settings.Greeting);
|
||||
return 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user