chocolatey / chocolatey/choco

Simplify the ability to resolve available commands

Open
#3,842 1 comment 1 reaction 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 acquire commands to re-use in the application, we need to resolve all commands and use reflection to iterate through them to be able to find the command that we are interested in.

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

We need to determine what simplify means in this context.

We need to either extract the logic of finding the commands to its own extension method (possibly an extension on the IoC container) so that we do not have mixed logic between different places, and to ensure that we are consistent in how it is used.

Alternatively, we can look into if there are better ways of trying to find the command classes that we want, to try to avoid using reflections. One idea here is to maybe register each command class directly, and then have it added to an entire collection if we need to.
This could potentially be solved by making use of keyed names when registering as well.

### User Story

As a maintainer of the application, or as an extension maintainer that needs to call other commands we need to currently duplicate the behaviour, and use reflection.
This is error prone, and can lead to runtime errors if done incorrectly.
I want to have the ability to re-use the logic of resolving commands in a standard, tested and simplified matter to avoid runtime errors from happening.

### Additional Context

_No response_

### Acceptance Criteria

- [ ] Resolving commands has been simplified and/or standardized.
- [ ] No behaviour runtime changes introduced (Run all unit/integration and e2e tests).

### Related Issues

_No response_

Contributor guide

Open the contributing guide

Research direction

Start by tracing the duplicated command-resolution logic and its reflection-based command lookup across the application. Compare the proposed extraction or registration approaches, then run the unit, integration, and end-to-end tests; done means command resolution is standardized without runtime behavior changes.

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.