The previous commit made a sequence whose enumerator throws in Dispose after
the second element count as a list, and left every other count to the catch,
which hands the collection to the conversion of PowerShell. A sequence of one
element whose enumerator fails in Dispose therefore got through when that
element was a comma list or an array of two values: PowerShell combined the
numbers bit by bit and the entry was created with a value that nobody named.
The reading is done with an explicit enumerator that is released in its own
guard now, so a failing release changes nothing of what was read, whatever the
number of elements. The catch is back to what it was: a reading that fails
leaves the collection to the conversion, which rejects it with its own error.
Tests, written first: 8 rows failed on the previous commit in all four
configurations and none fails now (a compiled stand-in whose enumerator throws
in Dispose; a sequence of one comma list and of one array of two values, for
AccessType and AppliesTo, named and piped). Two rows pin that a sequence of
one valid value stays valid.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: AI Assistant <ai@example.com>