Open WiredSharp opened 3 years ago
The problem is quite simple. Get-Dependency.ps1
, line:283:
elseif( $DependencyHash -is [string] -and
$Dependency -notmatch '/' -and
-not $DependencyType -or
$DependencyType -eq 'PSGalleryModule')
This condition evaluates to $true
even when $DependencyHash
is hashtable
and $DependencyType
is PSGalleryModule
, because of not using parenthesis in complex conditions. The fix is quite simple also:
elseif( $DependencyHash -is [string] -and
$Dependency -notmatch '/' -and
(-not $DependencyType -or $DependencyType -eq 'PSGalleryModule'))
There are multiple places having this bug for different dependency types in the file.
Actually I wanted to use this Package... I have not found any good alternatives to PSDepend. And I would like to submit a PR with the fix... But, it seems, the project is dead. The latest Package update on PSGallery was more than 1 year ago. And I'm not sure that new fixes will be available on PSGallery soon. That's really sad.
The problem is quite simple.
Get-Dependency.ps1
, line:283:elseif( $DependencyHash -is [string] -and $Dependency -notmatch '/' -and -not $DependencyType -or $DependencyType -eq 'PSGalleryModule')
This condition evaluates to
$true
even when$DependencyHash
ishashtable
and$DependencyType
isPSGalleryModule
, because of not using parenthesis in complex conditions. The fix is quite simple also:elseif( $DependencyHash -is [string] -and $Dependency -notmatch '/' -and (-not $DependencyType -or $DependencyType -eq 'PSGalleryModule'))
There are multiple places having this bug for different dependency types in the file.
Actually I wanted to use this Package... I have not found any good alternatives to PSDepend. And I would like to submit a PR with the fix... But, it seems, the project is dead. The latest Package update on PSGallery was more than 1 year ago. And I'm not sure that new fixes will be available on PSGallery soon. That's really sad.
Any thoughts on someone Publishing a new PSDepend module from a fork that is maintained? o.O
Considering the following dependencies:
If you call
Get-Dependency -InputObject $dependencies
Parsed dependency is:
As you can see, the whole hashtable is used as version field value. Indeed the
Parse-Dependency
function in Get-Dependency.ps1 considers that when DependencyType is set to 'PSGalleryModule' in PSDependOptions, the dependency value is a string. A solution is to always take into account the type of the $Dependencyhash variable.