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 @@ -195,7 +195,25 @@ internal IList<object> GetMembersByInferredType(PSTypeName typename, bool isStat
// Look in the type table first.
if (!isStatic)
{
var consolidatedString = new ConsolidatedString(new[] { typename.Name });
// The Ciminstance type adapter adds the full typename with and without a namespace to the list of type names.
// So if we see one with a full typename we need to also get the types for the short version.
// For example: "CimInstance#root/standardcimv2/MSFT_NetFirewallRule" and "CimInstance#MSFT_NetFirewallRule"
int namespaceSeparator = typename.Name.LastIndexOf('/');
ConsolidatedString consolidatedString;
if (namespaceSeparator != -1
&& typename.Name.StartsWith("Microsoft.Management.Infrastructure.CimInstance#", StringComparison.OrdinalIgnoreCase))
{
consolidatedString = new ConsolidatedString(new[]
{
typename.Name,
string.Concat("Microsoft.Management.Infrastructure.CimInstance#", typename.Name.AsSpan(namespaceSeparator + 1))
});
}
else
{
consolidatedString = new ConsolidatedString(new[] { typename.Name });
}

results.AddRange(ExecutionContext.TypeTable.GetMembers<PSMemberInfo>(consolidatedString));
}

Expand Down
5 changes: 5 additions & 0 deletions test/powershell/Host/TabCompletion/TabCompletion.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,11 @@ ConstructorTestClass(int i, bool b)
$res.CompletionMatches[0].CompletionText | Should -BeExactly Cat
}

It 'Should complete cim ETS member added by shortname' -Skip:(!$IsWindows) {
$res = TabExpansion2 -inputScript '(Get-NetFirewallRule).Nam'
$res.CompletionMatches[0].CompletionText | Should -BeExactly 'Name'
}

It 'Should complete variable assigned with Data statement' {
$TestString = 'data MyDataVar {"Hello"};$MyDatav'
$res = TabExpansion2 -inputScript $TestString
Expand Down