From a37c97c64ee16fc525db237be4c722c29a4bbc18 Mon Sep 17 00:00:00 2001 From: JohnMcPMS Date: Thu, 31 Oct 2024 15:51:39 -0700 Subject: [PATCH] Remove attribute in DSC (#4932) ## 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. --- .../Microsoft.WinGet.DSC/Microsoft.WinGet.DSC.psm1 | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/PowerShell/Microsoft.WinGet.DSC/Microsoft.WinGet.DSC.psm1 b/src/PowerShell/Microsoft.WinGet.DSC/Microsoft.WinGet.DSC.psm1 index 9873bfa4b8..96938c707a 100644 --- a/src/PowerShell/Microsoft.WinGet.DSC/Microsoft.WinGet.DSC.psm1 +++ b/src/PowerShell/Microsoft.WinGet.DSC/Microsoft.WinGet.DSC.psm1 @@ -190,7 +190,6 @@ class WinGetAdminSettings class WinGetSource { [DscProperty(Key, Mandatory)] - [ValidateNotNullOrWhiteSpace()] [string]$Name [DscProperty(Mandatory)] @@ -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 { @@ -446,7 +450,6 @@ class WinGetPackageManager class WinGetPackage { [DscProperty(Key, Mandatory)] - [ValidateNotNullOrWhiteSpace()] [string]$Id [DscProperty(Key)] @@ -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 = @{