chocolatey / chocolatey/choco

Simplify IoC registrations to make it easier to use Chocolatey.Lib without having to register everything

Open
#3,093 0 comments 0 reactions 0 assignees View on GitHub
0 - Triaging Enhancement
Dominant language
C#
Stars
11.5k
Forks
960
PR merge metrics
No merged PRs in 30d

Description

### Checklist

- [X] I have verified this is the correct repository for opening this issue.
- [X] I have verified no other issues exist related to my request.

### Is Your Feature Request Related To A Problem? Please describe.

When attempting to use Chocolatey.Lib within another application, it is sometimes necessary to retrieve instances of some interfaces, for example `IXmlService`, or `IFileSystem`, etc. Within Chocolatey.Lib, there is a static instance of the SimpleInjector container that can be used, for example:

```
SimpleInjectorContainer.Container.GetInstance()
```

This has the desired effect, but it also has the side effect of setting up "everything" for a complete execution of Chocolatey, which may, or may not be required, and may cause unintended consequences.

### Describe The Solution. Why is it needed?

A potential solution here would be to allow for "staged" registrations of the IoC container, for example:

* Base classes
* Commands
* Source Runners
* etc

That way, depending on what type of registration is being retrieved from the IoC container, only the required registrations/configuration have been completed in order to facilitate the retrieval.

### Additional Context

_No response_

### Related Issues

_No response_

Contributor guide

Open the contributing guide

Research direction

Start by tracing SimpleInjectorContainer.Container and how it registers services such as IXmlService and IFileSystem. Review the existing registration flow and determine how the requested staged registrations would fit. Done means consumers can retrieve selected interfaces without initializing every Chocolatey registration, while complete execution still has the registrations it needs.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
cli
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.