Repository navigation
3.0 parameter cleanup: -Dispose switch, checked -Level, -PollCallback - #43
Merged
Merged
Conversation
-Dispose was a [bool], so disposing took -Dispose $true. It's now a switch: write -Dispose. Only -Job binds by position, so the old -Dispose $true is an error ("A positional parameter cannot be found that accepts argument 'True'") instead of quietly handing $true to -StreamTimeoutMs as 1 ms and cutting the output off. The same goes for a -StreamTimeoutMs given by position.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
-Level took any string and passed it straight to the message handler. It now takes Info, Warn, Error or Warning; anything else is an error. Warning arrives as Warn, and the case is normalized, so a handler only ever sees Info, Warn or Error, from a worker too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
It runs on every loop pass, not just during an abort, and the runspace engine already calls the same role -PollCallback. -AbortPollCallback stays as an alias, so existing scripts keep working. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Three parameter changes for 3.0, one commit each.
1.
Complete-PkProcess -Disposeis a switch (breaking)It was a
[bool], so disposing took-Dispose $true. Now it's just-Dispose. Only-Jobbinds by position, so the old form is an error ("A positional parameter cannot be found that accepts argument 'True'"). Without that, a plain switch would have quietly handed the leftover$trueto-StreamTimeoutMsas 1 ms and cut the output off with no error. Tested on 5.1 and 7.What scripts must change:
Complete-PkProcess -Job $job -Dispose $truebecomesComplete-PkProcess -Job $job -Dispose. A-StreamTimeoutMsgiven by position (Complete-PkProcess $job 5000) must be named:-StreamTimeoutMs 5000.2.
Write-PkMessage -Levelis checked (breaking)It took any string and passed it straight to the message handler. It now takes
Info,Warn,ErrororWarning.Warningarrives asWarn, and the case is normalized, so a handler only ever seesInfo,WarnorError, from a worker too.What scripts must change: any other
-Levelvalue (Debug,Verbose, say) is now an error. Use one of the four.3. The dispatcher's
-AbortPollCallbackis now-PollCallback(not breaking)It runs on every loop pass, not just during an abort, and the runspace engine already calls the same role
-PollCallback.-AbortPollCallbackstays as an alias, so existing scripts keep working.How it was tested
New harness section AK covers:
-Dispose $trueand a positional-StreamTimeoutMsare errors, andComplete-PkProcess $job -Disposeworks.-Levelcomes through asInfo/Warn/Error, on the main thread and from a worker, and an unknown level is an error.-PollCallbackand-AbortPollCallback.The harness's own
-Dispose $trueand-AbortPollCallbackcalls use the new forms. The new checks failed before their change. The harness passes on Windows PowerShell 5.1 and PowerShell 7 (453 assertions each).🤖 Generated with Claude Code