spectreconsole / spectre.console

A .NET library that makes it easier to create beautiful console applications.
https://spectreconsole.net
MIT License
9.19k stars 474 forks source link

Nullability in overridden Execute method in extended Command class. #1355

Closed stormwulfren closed 10 months ago

stormwulfren commented 10 months ago

Information

Describe the bug Behaviour as described in this PR is occurring in my instance. https://github.com/spectreconsole/spectre.console/pull/1255

To Reproduce

using Spectre.Console.Cli;
internal sealed class Cli : Command<Cli.Settings>
{
    internal sealed class Settings : CommandSettings
    {
    }

    public override int Execute(CommandContext context, Settings settings)
    {
        return 0;
    }
}

Nullability of type of parameter 'context' in method does not match overridden member 'int Spectre.Console.Cli.Command.Execute(CommandContext, TSettings)' (possibly because of nullability attributes)

Nullability of type of parameter 'settings' in method does not match overridden member 'int Spectre.Console.Cli.Command.Execute(CommandContext, TSettings)' (possibly because of nullability attributes)

Error remains regardless if params have the [NotNull] annotation or not.

Edit: Interestingly, I'm using version 0.47.0 (pulled this morning), but the referenced file CommandOfT.cs doesn't look like the one in main branch. The version I have does indeed have [NotNull] attributes on the Execute and Validate methods. Not sure what's going on here ...

stormwulfren commented 10 months ago

Apologies. User error, I'm using stable. I see it's fixed in prerelease.