mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Fix member completion for PowerShell Enum class (#19740)
This commit is contained in:
@@ -364,7 +364,22 @@ namespace System.Management.Automation
|
||||
filterToCall = filter;
|
||||
}
|
||||
|
||||
results.AddRange(GetMembersByInferredType(new PSTypeName(typeof(object)), isStatic, filterToCall));
|
||||
PSTypeName baseMembersType;
|
||||
if (typename.TypeDefinitionAst.IsEnum)
|
||||
{
|
||||
if (!isStatic)
|
||||
{
|
||||
results.Add(new PSInferredProperty("value__", new PSTypeName(typeof(int))));
|
||||
}
|
||||
|
||||
baseMembersType = new PSTypeName(typeof(Enum));
|
||||
}
|
||||
else
|
||||
{
|
||||
baseMembersType = new PSTypeName(typeof(object));
|
||||
}
|
||||
|
||||
results.AddRange(GetMembersByInferredType(baseMembersType, isStatic, filterToCall));
|
||||
}
|
||||
|
||||
internal void AddMembersByInferredTypeCimType(PSTypeName typename, List<object> results, Func<object, bool> filterToCall)
|
||||
|
||||
@@ -961,6 +961,12 @@ class InheritedClassTest : System.Attribute
|
||||
$res.CompletionMatches.CompletionText | Should -Contain '-ProgressAction'
|
||||
}
|
||||
|
||||
it 'Should complete enum class members for Enums in script text' {
|
||||
$res = TabExpansion2 -inputScript 'enum Test1 {Val1};([Test1]"").'
|
||||
$res.CompletionMatches.CompletionText[0] | Should -Be 'value__'
|
||||
$res.CompletionMatches.CompletionText | Should -Contain 'HasFlag('
|
||||
}
|
||||
|
||||
Context "Script name completion" {
|
||||
BeforeAll {
|
||||
Setup -f 'install-powershell.ps1' -Content ""
|
||||
|
||||
Reference in New Issue
Block a user