-
Notifications
You must be signed in to change notification settings - Fork 643
Description
Information
- OS: Windows
- Version: 11 23H2
- Terminal: Windows Terminal
Describe the bug
After upgrading Spectre.Console.Cli from 0.48.0 to 0.49.1 (gitfool/BoardGame.Dungeon#240) I see that dependency injection service provider validation now fails when running a debug build with the "development" environment:
System.InvalidOperationException
HResult=0x80131509
Message=Error while validating the service descriptor 'ServiceType: Spectre.Console.Cli.ExplainCommand+Settings Lifetime: Singleton ImplementationType: Spectre.Console.Cli.ExplainCommand+Settings': Unable to resolve service for type 'System.String[]' while attempting to activate 'Spectre.Console.Cli.ExplainCommand+Settings'.
Source=Microsoft.Extensions.DependencyInjection
StackTrace:
at Microsoft.Extensions.DependencyInjection.ServiceProvider.ValidateService(ServiceDescriptor descriptor) in Microsoft.Extensions.DependencyInjection\ServiceProvider.cs:line 198
This exception was originally thrown at this call stack:
Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateArgumentCallSites(Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceIdentifier, System.Type, Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteChain, System.Reflection.ParameterInfo[], bool) in CallSiteFactory.cs
Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateConstructorCallSite(Microsoft.Extensions.DependencyInjection.ServiceLookup.ResultCache, Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceIdentifier, System.Type, Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteChain) in CallSiteFactory.cs
Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.TryCreateExact(Microsoft.Extensions.DependencyInjection.ServiceDescriptor, Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceIdentifier, Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteChain, int) in CallSiteFactory.cs
Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.GetCallSite(Microsoft.Extensions.DependencyInjection.ServiceDescriptor, Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteChain) in CallSiteFactory.cs
Microsoft.Extensions.DependencyInjection.ServiceProvider.ValidateService(Microsoft.Extensions.DependencyInjection.ServiceDescriptor) in ServiceProvider.cs
Inner Exception 1:
InvalidOperationException: Unable to resolve service for type 'System.String[]' while attempting to activate 'Spectre.Console.Cli.ExplainCommand+Settings'.
To Reproduce
Clone https://github.com/gitfool/BoardGameGeek.Dungeon then run a debug build with the "development" environment.
Expected behavior
This previously did not and now should not fail validation.
Additional context
It does not fail when running a debug build with the "production" environment since validation is then disabled.
This seems to be due to the ExplainCommand+Settings ctor; is there a reason for this ctor or can it be removed?
spectre.console/src/Spectre.Console.Cli/Internal/Commands/ExplainCommand.cs
Lines 18 to 23
in
5d4b2c8
public Settings(string[]? commands, bool? detailed, bool includeHidden)
{
Commands = commands;
Detailed = detailed;
IncludeHidden = includeHidden;
}
spectre.console/src/Spectre.Console.Cli/Internal/Commands/ExplainCommand.cs
Lines 18 to 23 in 5d4b2c8
| public Settings(string[]? commands, bool? detailed, bool includeHidden) | |
| { | |
| Commands = commands; | |
| Detailed = detailed; | |
| IncludeHidden = includeHidden; | |
| } |
Please upvote 👍 this issue if you are interested in it.