You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
No response
Describe The Solution. Why is it needed?
We need to amend the contribution documentation in this repository to include some information about how we tend to author C# cmdlets, classes and design patterns to make use of and those to avoid as well.
Specifically, we should include the following information:
Cmdlets should inherit from ChocolateyCmdlet and notCmdlet or PSCmdlet
When and how to make use of SupportsShouldProcess aka -WhatIf / -Confirm
Cmdlets should contain minimal to no core logic, anything that other cmdlets need to make use of should be provided as part of a helper class, since calling into other C# cmdlets is not something that can or should really be done directly.
Usage and extension of existing helpers like PSHelper or ChocolateyCmdlet and so forth
How to manage error handling, and where
Exceptions should be thrown in core logic, caught and rethrown using ThrowTerminatingError() or WriteError() in the cmdlet layer itself
Dependency injection must be avoided, at least in anything that's in the cmdlet layer itself (inheriting ChocolateyCmdlet) as PowerShell does not support this.
Some guidance on communication between Chocolatey CLI and cmdlets, which is typically mediated with environment variables.
Under no circumstances should there be a direct dependency on CLI code from the cmdlets project, they need to remain separate.
Checklist
Is Your Feature Request Related To A Problem? Please describe.
No response
Describe The Solution. Why is it needed?
We need to amend the contribution documentation in this repository to include some information about how we tend to author C# cmdlets, classes and design patterns to make use of and those to avoid as well.
Specifically, we should include the following information:
ChocolateyCmdlet
and notCmdlet
orPSCmdlet
SupportsShouldProcess
aka-WhatIf
/-Confirm
PSHelper
orChocolateyCmdlet
and so forthThrowTerminatingError()
orWriteError()
in the cmdlet layer itselfChocolateyCmdlet
) as PowerShell does not support this.Additional Context
No response
Related Issues
The text was updated successfully, but these errors were encountered: