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

(#3539) Add design documentation for C# cmdlets #3601

Open
wants to merge 1 commit into
base: feature/cmdlets
Choose a base branch
from

Conversation

vexx32
Copy link
Member

@vexx32 vexx32 commented Jan 15, 2025

Description Of Changes

  • Added CONTRIBUTING.md document to the Chocolatey.PowerShell project.

Motivation and Context

Given we use some slightly custom bits in Chocolatey.PowerShell that will alter how contributors are expected to work with the cmdlets in this project compared to how more bare-bones projects handle C# cmdlets, this document outlines some of the more notable changes as well as the common design practices we will be using here.

Testing

N/A, doc only.

Operating Systems Testing

N/A

Change Types Made

  • Bug fix (non-breaking change).
  • Feature / Enhancement (non-breaking change).
  • Breaking change (fix or feature that could cause existing functionality to change).
  • Documentation changes.
  • PowerShell code changes.

Change Checklist

  • Requires a change to the documentation.
  • Documentation has been updated.
  • Tests to cover my changes, have been added.
  • All new and existing tests passed?
  • PowerShell code changes: PowerShell v3 compatibility checked?

Related Issue

Fixes #3539

@vexx32 vexx32 requested review from gep13 and corbob January 15, 2025 21:02
Copy link
Member

@corbob corbob left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall I think this looks good, just have a few clarifying questions, at least one I think requires changes.

src/Chocolatey.PowerShell/CONTRIBUTING.md Outdated Show resolved Hide resolved
src/Chocolatey.PowerShell/CONTRIBUTING.md Show resolved Hide resolved
src/Chocolatey.PowerShell/CONTRIBUTING.md Outdated Show resolved Hide resolved
@corbob
Copy link
Member

corbob commented Jan 16, 2025

One other thing that's occurred to me: Should we consider linking to this from the higher up contributing document? I'm a little concerned about the discoverability of the document if it's just a file in a directory where you might not look for it as you're in Visual Studio...

@vexx32
Copy link
Member Author

vexx32 commented Jan 16, 2025

Should we consider linking to this from the higher up contributing document?

That's something I thought about and... am not really sure about. I suppose it can't hurt, I did have a bit of a difficult time trying to figure out a sensible place in the main CONTRIBUTING doc to reference it, but I can always add a new section...

It also should probably be put into the sln file just to make it more visible in VS, I think. I'll do both.

Copy link
Member

@gep13 gep13 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@gep13
Copy link
Member

gep13 commented Jan 20, 2025

@vexx32 just had a read through this, and this reads really well to me, and it covers the things that we have spoken about, so I would be happy to see this merged in.

I will leave @corbob to come back and confirm based on any changes that he asked for.

Copy link
Member

@corbob corbob left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few minor suggestions.

src/Chocolatey.PowerShell/CONTRIBUTING.md Outdated Show resolved Hide resolved
src/Chocolatey.PowerShell/CONTRIBUTING.md Outdated Show resolved Hide resolved
@vexx32 vexx32 force-pushed the design-doc branch 3 times, most recently from 411b3ac to a7ea3de Compare January 21, 2025 16:04
@vexx32
Copy link
Member Author

vexx32 commented Jan 21, 2025

@corbob I have incorporated your suggestions, and added a section about helpers to indicate they should not be directly writing to PowerShell output/error streams and suggest a common pattern to be used for those cases.

Given we use some slightly custom bits in Chocolatey.PowerShell that
will alter how contributors are expected to work with the cmdlets in
this project compared to how more bare-bones projects handle C# cmdlets,
this document outlines some of the more notable changes as well as the
common design practices we will be using here.
Copy link
Member

@corbob corbob left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes look good to me. I've tagged @gep13 on the headings of the sections that are new since his review.

> To facilitate this, we can put the core logic of `Install-ChocolateyInstallPackage` into a helper class, and the actual `InstallChocolateyInstallPackageCommand` class we would write would only define parameters, then call into the helper class.
> Then, when we write the `InstallChocolateyPackageCommand`, it can download files and then call into the same helper class to run the other cmdlet's logic seamlessly.

### Helpers should return data or throw exceptions, not write output or errors
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For completeness @gep13 could you review this section as it was added after your approval.

Additionally, since all cmdlets are initialised by the PowerShell runtime, we cannot use a dependency injection framework to make things work.
As a result, many of the helpers will be a little more bare-bones and not make as heavy use of interfaces as other code areas in this repository.

## Interop with Chocolatey CLI
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For completeness @gep13 could you review this section as it was added after your approval.

@corbob corbob requested a review from gep13 January 21, 2025 17:19
Copy link
Member

@gep13 gep13 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants