Fix class member completion for classes with base types (#19179)

This commit is contained in:
MartinGC94
2023-02-22 22:10:22 +05:00
committed by GitHub
parent 91d8fb0367
commit 290fe28104
2 changed files with 23 additions and 1 deletions
@@ -322,7 +322,18 @@ namespace System.Management.Automation
}
var baseTypeDefinitionAst = baseTypeName._typeDefinitionAst;
results.AddRange(GetMembersByInferredType(new PSTypeName(baseTypeDefinitionAst), isStatic, filterToCall));
if (baseTypeDefinitionAst is null)
{
var baseReflectionType = baseTypeName.GetReflectionType();
if (baseReflectionType is not null)
{
results.AddRange(GetMembersByInferredType(new PSTypeName(baseReflectionType), isStatic, filterToCall));
}
}
else
{
results.AddRange(GetMembersByInferredType(new PSTypeName(baseTypeDefinitionAst), isStatic, filterToCall));
}
}
// Add stuff from our base class System.Object.
@@ -843,6 +843,17 @@ Verb-Noun -Param1 Hello ^
$res.CompletionMatches[0].CompletionText | Should -Be "Attributes"
}
it 'Should complete base class members of types without type definition AST' {
$res = TabExpansion2 -inputScript @'
class InheritedClassTest : System.Attribute
{
[void] TestMethod()
{
$this.
'@
$res.CompletionMatches.CompletionText | Should -Contain 'TypeId'
}
Context "Script name completion" {
BeforeAll {
Setup -f 'install-powershell.ps1' -Content ""