refactor: extract build configuration factory#197
refactor: extract build configuration factory#197PrzemyslawKlys wants to merge 1 commit intocodex/thin-cmdlets-project-versioningfrom
Conversation
Code Review - PR #197: refactor: extract build configuration factory |
|
Test: can we post? |
|
Deleting test comment - full review follows |
|
Code Review - PR 197 refactor extract build configuration factory Good refactoring overall. Extracting the factory makes the logic unit-testable without standing up a full PSCmdlet, and the new tests cover the most important validation paths. A few issues worth addressing before merging. POTENTIAL BUGS
The PFX password check in CreateSigningSegment only verifies the parameter was bound via CertificatePFXPasswordSpecified, not that it is non-empty. If a caller passes an empty string for -CertificatePFXPassword, the validation passes silently while an empty password proceeds into signing. This is inconsistent with the credential check just above it, which correctly uses string.IsNullOrWhiteSpace. Suggested fix: also check string.IsNullOrWhiteSpace on request.CertificatePFXPassword.
File.ReadAllText will throw a raw FileNotFoundException or IOException if the path is invalid, with no indication of which parameter caused it. Wrapping and re-throwing as ArgumentException with the file path in the message would give users clearer diagnostics.
Both CreateBuildModuleSegment and CreateSigningSegment use else-if chains for mutually exclusive parameters. If a caller specifies more than one, extras are silently ignored. Now that this logic is in a focused factory, it would be worth documenting the priority order in an XML doc comment on Create, or throwing ArgumentException for ambiguous combinations. MISSING TEST COVERAGE
Create_throws_when_pfx_path_has_no_password covers only the CertificatePFXPath branch. The identical validation guard in the CertificatePFXBase64 branch has no test. A parallel test case for CertificatePFXBase64Specified without CertificatePFXPasswordSpecified would close the gap.
A test passing a non-existent path to InstallMissingModulesCredentialSecretFilePath would document expected behavior and catch regressions if error handling is later improved. MINOR NOTES
In CreateBuildLibrariesSegment, buildLibraries.Enable = true only fires when NETConfiguration or NETFramework is specified. Other NET properties such as NETProjectName and NETBinaryModule do not activate Enable. If intentional, a comment explaining the invariant would help future readers.
CreateBuildModuleSegment checks string.IsNullOrWhiteSpace on the username value but never reads the Specified flag. The test Create_reads_missing_module_secret_from_file sets InstallMissingModulesCredentialUserNameSpecified = true, which is harmless but misleading. SUMMARY Refactoring intent: Good - clean separation of concerns The factory pattern is the right approach and the PR is in good shape. Items 1-3 are real bugs worth fixing before merge; items 4-5 are test gaps that would improve confidence. Items 6-7 are low-priority nits. |
Summary
Validation
Stack