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 @@ -364,7 +364,22 @@ internal void AddMembersByInferredTypeDefinitionAst(
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)
Expand Down
6 changes: 6 additions & 0 deletions test/powershell/Host/TabCompletion/TabCompletion.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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 ""
Expand Down