mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Improve cim ETS member inference completion
This commit is contained in:
committed by
Patrick Meinecke
parent
7cc8a9ad32
commit
1452374fbf
@@ -195,7 +195,14 @@ namespace System.Management.Automation
|
||||
// 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"
|
||||
Match match = Regex.Match(typename.Name, "(Microsoft\\.Management\\.Infrastructure\\.CimInstance#)(.+\\/)(.+$)");
|
||||
|
||||
ConsolidatedString consolidatedString = match.Success
|
||||
? new ConsolidatedString(new[] { typename.Name, match.Groups[1].Value + match.Groups[3].Value })
|
||||
: new ConsolidatedString(new[] { typename.Name });
|
||||
results.AddRange(ExecutionContext.TypeTable.GetMembers<PSMemberInfo>(consolidatedString));
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user