Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert PowerShell Functions to C# CmdLets #3477

Open
7 of 41 tasks
gep13 opened this issue Jul 3, 2024 · 5 comments
Open
7 of 41 tasks

Convert PowerShell Functions to C# CmdLets #3477

gep13 opened this issue Jul 3, 2024 · 5 comments

Comments

@gep13
Copy link
Member

gep13 commented Jul 3, 2024

Checklist

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

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

Tasks

@gep13
Copy link
Member Author

gep13 commented Jul 3, 2024

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
Copy link
Member Author

gep13 commented Jul 3, 2024

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 added a commit to vexx32/choco that referenced this issue Oct 3, 2024
This command replaces the Get-ChecksumValid helper function, adding an
alias for compatibility purposes.
vexx32 added a commit to vexx32/choco that referenced this issue Oct 3, 2024
Add tests to ensure the behaviour of rewritten command matches the
original behaviour.
vexx32 added a commit to vexx32/choco that referenced this issue Oct 4, 2024
This command replaces the Get-ChecksumValid helper function, adding an
alias for compatibility purposes.
vexx32 added a commit to vexx32/choco that referenced this issue Oct 4, 2024
Add tests to ensure the behaviour of rewritten command matches the
original behaviour.
vexx32 added a commit to vexx32/choco that referenced this issue Oct 4, 2024
This command replaces the Get-ChecksumValid helper function, adding an
alias for compatibility purposes.
vexx32 added a commit to vexx32/choco that referenced this issue Oct 4, 2024
Add tests to ensure the behaviour of rewritten command matches the
original behaviour.
@vexx32
Copy link
Member

vexx32 commented Oct 4, 2024

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

@vexx32
Copy link
Member

vexx32 commented Oct 7, 2024

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
Copy link
Member

vexx32 commented Oct 7, 2024

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.

vexx32 added a commit to vexx32/choco that referenced this issue Oct 15, 2024
This command replaces the Get-ChecksumValid helper function, adding an
alias for compatibility purposes.
vexx32 added a commit to vexx32/choco that referenced this issue Oct 15, 2024
Add tests to ensure the behaviour of rewritten command matches the
original behaviour.
vexx32 added a commit to vexx32/choco that referenced this issue Oct 15, 2024
This command replaces the Get-ChecksumValid helper function, adding an
alias for compatibility purposes.
vexx32 added a commit to vexx32/choco that referenced this issue Oct 15, 2024
Add tests to ensure the behaviour of rewritten command matches the
original behaviour.
vexx32 added a commit to vexx32/choco that referenced this issue Oct 15, 2024
This command replaces the Get-ChecksumValid helper function, adding an
alias for compatibility purposes.
vexx32 added a commit to vexx32/choco that referenced this issue Oct 15, 2024
Add tests to ensure the behaviour of rewritten command matches the
original behaviour.
vexx32 added a commit to vexx32/choco that referenced this issue Oct 18, 2024
Some cmdlets should support ShouldProcess, this change ensures that they
do correctly support it, along with adding checks to the underlying
methods to make it work as users will expect.

As Chocolatey CLI already supports --dry-run itself, this is primarily
going to be useful for effectively unit testing the commands.
vexx32 added a commit to vexx32/choco that referenced this issue Oct 21, 2024
Some cmdlets should support ShouldProcess, this change ensures that they
do correctly support it, along with adding checks to the underlying
methods to make it work as users will expect.

As Chocolatey CLI already supports --dry-run itself, this is primarily
going to be useful for effectively unit testing the commands.
vexx32 added a commit to vexx32/choco that referenced this issue Oct 21, 2024
Update-SessionEnvironment, Set-EnvironmentVariable, and
(Un)Install-ChocolateyPath implement ShouldProcess, so we can use
-WhatIf to verify their behaviour with unit tests.
vexx32 added a commit to vexx32/choco that referenced this issue Oct 21, 2024
Update-SessionEnvironment, Set-EnvironmentVariable, and
(Un)Install-ChocolateyPath implement ShouldProcess, so we can use
-WhatIf to verify their behaviour with unit tests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants