Repository navigation
Warn when -GroupProvider outputs more than one value in a call - #105
Merged
Merged
Conversation
Several values in one call (a stray ArrayList.Add index next to the group, or a list returned without the leading comma) are taken together as one group, as before, but now with a warning once per run that says how many values arrived. The provider's output is counted as it comes down the pipeline, since collecting it by assignment can't tell one list from several values. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Count -GroupProvider's values with @() instead of passing each through a .NET list, whose Add() unwrapped a value's PSObject and lost any note property on it. The harness's static guard check accepts the @(do { } while ($false)) form.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Merged
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.
-GroupProvideris meant to output one value per call: the group, or$nullto end. When a call output more than one value, they were silently taken together as one group. That covers a stray value next to the group (the indexArrayList.Addreturns, say) and a list returned without the leading comma. Nothing said so.The dispatcher now warns, once per run, when a call outputs more than one value. The warning names
-GroupProvider, says how many values arrived, and suggests$null = ...for a stray value orreturn ,$listfor a list group. The group itself is unchanged:return @('a', 'b', 'c')is still one three-item group, and a stray index is still part of the group it came with. Output ending in$nullkeeps its existing warning and isn't warned about twice.To tell the two apart, the provider's output is now collected with
@(...), which keeps one element per value output, instead of by plain assignment, which turns one list and several separate values into the same array. The call keeps thecontinue/breakguard every callback has, inlined, and the harness's static guard check now recognizes that@(do { } while ($false))form. Each value comes through exactly as before, PSObject wrapper and note properties included. A.NETlist'sAdd()would have dropped them.Testing
New tests in harness section AT: one value,
$null, no output, a list with the comma (two items and one), a stray value plus the group, and a list returned without the comma. The last two warn once per run, with the count; the rest don't. A further test checks a group value keeps a note property.Against the code before this change, on Windows PowerShell 5.1, the two warning cases failed and the rest passed (2 failed, 13 passed in that section). With it:
-AsModule -Section MODULECost, 5,000 groups with no jobs (median of 5): 5.1 went from 437 to 394 µs per group, and 7 from 129 to 102. The provider is no longer called through a separate function.
🤖 Generated with Claude Code