Skip to content

Commit

Permalink
Remove attribute in DSC (#4932)
Browse files Browse the repository at this point in the history
## Change
Removes the attribute `ValidateNotNullOrWhiteSpace` as it is only
available starting in 7.4. The attributes also only validate when the
value is assigned, so enforcing that a value is set is more complete.

## Validation
Loads in PS 7.2.8 now.
  • Loading branch information
JohnMcPMS authored Oct 31, 2024
1 parent cdd4b08 commit 03587c2
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/PowerShell/Microsoft.WinGet.DSC/Microsoft.WinGet.DSC.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,6 @@ class WinGetAdminSettings
class WinGetSource
{
[DscProperty(Key, Mandatory)]
[ValidateNotNullOrWhiteSpace()]
[string]$Name

[DscProperty(Mandatory)]
Expand All @@ -210,6 +209,11 @@ class WinGetSource

[WinGetSource] Get()
{
if ([String]::IsNullOrWhiteSpace($this.Name))
{
throw "A value must be provided for WinGetSource::Name"
}

$currentSource = $null

try {
Expand Down Expand Up @@ -446,7 +450,6 @@ class WinGetPackageManager
class WinGetPackage
{
[DscProperty(Key, Mandatory)]
[ValidateNotNullOrWhiteSpace()]
[string]$Id

[DscProperty(Key)]
Expand All @@ -471,6 +474,11 @@ class WinGetPackage

[WinGetPackage] Get()
{
if ([String]::IsNullOrWhiteSpace($this.Id))
{
throw "A value must be provided for WinGetPackage::Id"
}

$result = [WinGetPackage]::new()

$hashArgs = @{
Expand Down

0 comments on commit 03587c2

Please sign in to comment.