patriksvensson / cupboard

A framework for provisioning local environments to a desired state, using the .NET SDK.
MIT License
761 stars 19 forks source link

CupboardFixture dependency injection should be open for extension. #37

Open jetersen opened 2 years ago

jetersen commented 2 years ago

At the moment CupboardFixture does not have a way to add more dependencies.

I can of course copy my own cupboard fixture, but would be nice if it was possible to extend.

jetersen commented 2 years ago

Seems like I cannot run the cupboard fixture in another project because RunCommands is internal 😓 https://github.com/patriksvensson/cupboard/blob/e78c91af009089a331243010e7903689db17f028/src/Cupboard/Cli/RunCommand.cs#L12

Spectre.Console.Cli.CommandRuntimeException: Could not resolve type 'Cupboard.Internal.RunCommand'.

Spectre.Console.Cli.CommandRuntimeException
Could not resolve type 'Cupboard.Internal.RunCommand'.
   at Spectre.Console.Cli.TypeResolverAdapter.Resolve(Type type) in /_/src/Spectre.Console/Cli/Internal/TypeResolverAdapter.cs:line 43
   at Spectre.Console.Cli.CommandTree.CreateCommand(ITypeResolver resolver) in /_/src/Spectre.Console/Cli/Internal/Parsing/CommandTree.cs:line 29
   at Spectre.Console.Cli.CommandExecutor.Execute(CommandTree leaf, CommandTree tree, CommandContext context, ITypeResolver resolver, IConfiguration configuration) in /_/src/Spectre.Console/Cli/Internal/CommandExecutor.cs:line 107
   at Spectre.Console.Cli.CommandExecutor.Execute(IConfiguration configuration, IEnumerable`1 args) in /_/src/Spectre.Console/Cli/Internal/CommandExecutor.cs:line 84
   at Spectre.Console.Cli.CommandApp.RunAsync(IEnumerable`1 args) in /_/src/Spectre.Console/Cli/CommandApp.cs:line 87
   at Spectre.Console.Cli.CommandApp.Run(IEnumerable`1 args) in /_/src/Spectre.Console/Cli/CommandApp.cs:line 61
   at Spectre.Console.Cli.CommandApp`1.Run(IEnumerable`1 args) in /_/src/Spectre.Console/Cli/CommandAppOfT.cs:line 42
   at Cupboard.CupboardHost.Run(String[] args) in /_/src/Cupboard/CupboardHost.cs:line 32
   at UnitTests.CupboardFixture.Run(String[] args)
patriksvensson commented 2 years ago

Not at a computer tonight but will take a look tomorrow.

patriksvensson commented 2 years ago

@jetersen Perhaps we could add a ConfigureServices(Action<IServiceProvider>) method to CupboardFixture where custom registrations could be made?

jetersen commented 2 years ago

@patriksvensson sounds good to me