chocolatey / choco

Chocolatey - the package manager for Windows
https://chocolatey.org
Other
10.36k stars 903 forks source link

Convert PowerShell Functions to C# CmdLets #3477

Open gep13 opened 4 months ago

gep13 commented 4 months ago

Checklist

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

Within the Chocolatey Licensed Extension, we extend the functionality that is provided by some of the Chocolatey PowerShell functions, for example for the Package Throttle feature, which means changing how the Get-WebFile function works.

Extending this functionality can be problematic as it deals with switching between PowerShell and C#, and there are no direct entry points to provide this additional functionality.

Describe The Solution. Why is it needed?

We should convert all the Chocolatey PowerShell Functions, i.e. the Install-ChocolateyPath.ps1 to be a C# CmdLets.

This will allow for better inheritance/overloading of Chocolatey functionality within things like the Chocolatey Licensed Extension, as well as providing the necessary entry points to extend the functionality as/when required.

In addition, this will prevent duplication of code between Chocolatey CLI and CLE.

Additional Context

N/A

Related Issues

gep13 commented 4 months ago

Some of the above work was completed in the 2.3.0 release of Chocolatey CLI, where we introduced the concept of the Uninstall-ChocolateyPath CmdLet. At the time, it made sense to convert the Install-ChocolateyPath Function from PowerShell to a C# CmdLet, so that there was consistency in how they operated. It also gave us the opportunity to test/validate that everything worked as expected within the Chocolatey Licensed Extension, when changing the dependency to use 2.3.0 of CLI.

gep13 commented 4 months ago

I have marked this issue as a Breaking Change, as it does have the potential to have an impact on how some other systems work with Chocolatey CLI.

vexx32 commented 1 month ago

@gep13 since it's been agreed this will be a breaking change, should we put this in the 3.0 milestone?

vexx32 commented 1 month ago

Before this issue is closed out completely, we should look to update the Chocolatey.PowerShell.dll-help.xml file in the repository here. And for that to be done, we will need to merge the draft PRs in the docs repository.

I'll add an entry to the task list here to track this as well.

vexx32 commented 1 month ago

Additionally, I'm checking off Write-FunctionCallLogMessage for two reasons: first, it is one of the "internal use only" commands that was never meant to be part of the public API, as documented in its help information; second, it has already been incorporated into the ChocolateyCmdlet functionality and embedded into the BeginProcessing() override method defined on that base cmdlet.