mirror of
https://github.com/aphrody-labs/PowerShell.git
synced 2026-10-14 05:39:11 +00:00
Fix completion for PSCustomObject variable properties (#18682)
This commit is contained in:
1 parent
6e408649c4
commit
e6655d1f17
2 files changed
+30
-1
No files matched your search
@@ -427,7 +427,29 @@ namespace System.Management.Automation
|
||||
value = PSObject.Base(value);
|
||||
if (value != null)
|
||||
{
|
||||
type = new PSTypeName(value.GetType());
|
||||
var typeObject = value.GetType();
|
||||
|
||||
if (typeObject.FullName.Equals("System.Management.Automation.PSObject", StringComparison.Ordinal))
|
||||
{
|
||||
var psobjectPropertyList = new List<PSMemberNameAndType>();
|
||||
foreach (var property in ((PSObject)value).Properties)
|
||||
{
|
||||
if (property.IsHidden)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var propertyTypeName = new PSTypeName(property.TypeNameOfValue);
|
||||
psobjectPropertyList.Add(new PSMemberNameAndType(property.Name, propertyTypeName, property.Value));
|
||||
}
|
||||
|
||||
type = PSSyntheticTypeName.Create(typeObject, psobjectPropertyList);
|
||||
}
|
||||
else
|
||||
{
|
||||
type = new PSTypeName(typeObject);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -633,6 +633,13 @@ ConstructorTestClass(int i, bool b)
|
||||
$res.CompletionMatches[0].CompletionText | Should -BeExactly 'Length'
|
||||
}
|
||||
|
||||
It 'Should complete psobject members for variable' {
|
||||
$TestVar = Get-Command Get-Command | Select-Object CommandType
|
||||
$res = TabExpansion2 -inputScript '$TestVar | ForEach-Object {$_.commandtype'
|
||||
$res | Should -HaveCount 1
|
||||
$res.CompletionMatches[0].CompletionText | Should -BeExactly 'CommandType'
|
||||
}
|
||||
|
||||
Context "Format cmdlet's View paramter completion" {
|
||||
BeforeAll {
|
||||
$viewDefinition = @'
|
||||
|
||||
Reference in new issue
Block a user