mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Fix class member completion for classes with base types (#19179)
This commit is contained in:
@@ -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 ""
|
||||
|
||||
Reference in New Issue
Block a user