Skip to content

fix(PropertySet): AddProperty throws on every call — wrong hashtable.Add signature #11

@HeyItsGilbert

Description

@HeyItsGilbert

Summary

PropertySet.AddProperty calls $this.Properties.Add($Property) with a single argument. Hashtable.Add requires two arguments (key, value). This throws at runtime. The method has never been successfully invoked.

File

Gatekeeper/Classes/Property.ps1:148-151

Reproduction

$ps   = [PropertySet]::new('Test')
$prop = [PropertyDefinition]::new('Env', @{ Type = 'string' })
$ps.AddProperty($prop)
# Throws: Method invocation failed because [System.Collections.Hashtable] does not
#         contain a method named 'Add' with 1 argument

Fix

[PropertySet]AddProperty([PropertyDefinition]$Property) {
    $this.Properties.Add($Property.Name, $Property)   # was: .Add($Property)
    return $this
}

Notes

  • Good first issue — single-line fix
  • Found by Jordan B., Sage Nakamura, Chip Torres, and Glenn

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions