PowershellFrameworkCollective/psframework

Error in Register-PSFConfig after updating to 1.9.308

Closed this issue · 2 comments

i have a module that registers a configuration item in the module script upon import.
the following works with PSFramework 1.7.270, but fails in azure pipeline build when importing the module with the following error using 1.9.308:

##[error]Resolve-ConfigItem : Cannot convert argument "c", with value: "x,y.z", for "AddRange" to
type "System.Collections.ICollection": "Cannot convert the "x.y.z" value of type
"System.String" to type "System.Collections.ICollection"."
At C:\Program Files\WindowsPowerShell\Modules\PSFramework\1.9.308\PSFramework.psm1:3467 char:18
+ ... nfigItems = Resolve-ConfigItem -Config $Config -FullName $FullName -M ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Resolve-ConfigItem], MethodException
+ FullyQualifiedErrorId : MethodArgumentConversionInvalidCastArgument,Resolve-ConfigItem
##[error]PowerShell exited with code '1'.

i can reproduce this in PS5.1 and PS7 with the following command line:

Powershell 5.1:

> set-psfconfig -module x -name 'y.z' -value 'foo' -initialize -validation string -description 'set x.y.z' -PassThru | register-psfconfig;
Cannot convert argument "c", with value: "x.y.z", for "AddRange" to type "System.Collections.ICollection": "Cannot convert the "x.y.z" value of
type "System.String" to type "System.Collections.ICollection"."
At C:\Program Files\WindowsPowerShell\Modules\PSFramework\1.9.308\PSFramework.psm1:3354 char:5
+                 $null = $names.AddRange($Config.FullName)
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodException
    + FullyQualifiedErrorId : MethodArgumentConversionInvalidCastArgument

Powershell 7.3.6:

❯ set-psfconfig -module x -name 'y.z' -value 'foo' -initialize -validation string -description 'set x.y.z' -PassThru | register-psfconfig;
MethodException: Cannot convert argument "c", with value: "x.y.z", for "AddRange" to type "System.Collections.ICollection": "Cannot
convert the "x.y.z" value of type "System.String" to type "System.Collections.ICollection"."

Thanks for finding that, should never have happened.
Will fix that ASAP and figure out (and fix) why my tests did not catch this

Resolved in 1.9.310