X Tutup
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4691,6 +4691,12 @@ internal static PSObject SetObjectProperties(object o, IDictionary properties, T
}
}

// treat AutomationNull.Value as null for consistency
if (propValue == AutomationNull.Value)
{
propValue = null;
}

property.Value = propValue;
}
else
Expand Down
12 changes: 12 additions & 0 deletions test/powershell/Language/Scripting/Scripting.Followup.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,18 @@ Describe "Scripting.Followup.Tests" -Tags "CI" {
$arraylist.Count | Should -Be 0
}

It 'AutomationNull should be same as null for type conversion' {
$result = pwsh -noprofile -command {
class Example {
[string[]]$LogMessage
}

[Example] @{ LogMessage = [System.Management.Automation.Internal.AutomationNull]::Value }
}

$result.LogMessage | Should -BeNullOrEmpty
}

## fix https://github.com/PowerShell/PowerShell/issues/17165
It "([bool] `$var = 42) should return the varaible value" {
([bool]$var = 42).GetType().FullName | Should -Be "System.Boolean"
Expand Down
X Tutup