@@ -28,7 +28,7 @@ public class Helper
28
28
private readonly static Version minSupportedPSVersion = new Version ( 3 , 0 ) ;
29
29
private Dictionary < string , Dictionary < string , object > > ruleArguments ;
30
30
private PSVersionTable psVersionTable ;
31
- private Dictionary < string , CommandInfo > commandInfoCache ;
31
+ private Dictionary < CommandLookupKey , CommandInfo > commandInfoCache ;
32
32
33
33
#endregion
34
34
@@ -142,7 +142,7 @@ public void Initialize()
142
142
ruleArguments = new Dictionary < string , Dictionary < string , object > > ( StringComparer . OrdinalIgnoreCase ) ;
143
143
if ( commandInfoCache == null )
144
144
{
145
- commandInfoCache = new Dictionary < string , CommandInfo > ( StringComparer . OrdinalIgnoreCase ) ;
145
+ commandInfoCache = new Dictionary < CommandLookupKey , CommandInfo > ( ) ;
146
146
}
147
147
148
148
IEnumerable < CommandInfo > aliases = this . invokeCommand . GetCommands ( "*" , CommandTypes . Alias , true ) ;
@@ -700,15 +700,16 @@ public CommandInfo GetCommandInfoLegacy(string name, CommandTypes? commandType =
700
700
cmdletName = name ;
701
701
}
702
702
703
+ var key = new CommandLookupKey ( name , commandType ) ;
703
704
lock ( getCommandLock )
704
705
{
705
- if ( commandInfoCache . ContainsKey ( cmdletName ) )
706
+ if ( commandInfoCache . ContainsKey ( key ) )
706
707
{
707
- return commandInfoCache [ cmdletName ] ;
708
+ return commandInfoCache [ key ] ;
708
709
}
709
710
710
711
var commandInfo = GetCommandInfoInternal ( cmdletName , commandType ) ;
711
- commandInfoCache . Add ( cmdletName , commandInfo ) ;
712
+ commandInfoCache . Add ( key , commandInfo ) ;
712
713
return commandInfo ;
713
714
}
714
715
}
@@ -726,15 +727,16 @@ public CommandInfo GetCommandInfo(string name, CommandTypes? commandType = null)
726
727
return null ;
727
728
}
728
729
730
+ var key = new CommandLookupKey ( name , commandType ) ;
729
731
lock ( getCommandLock )
730
732
{
731
- if ( commandInfoCache . ContainsKey ( name ) )
733
+ if ( commandInfoCache . ContainsKey ( key ) )
732
734
{
733
- return commandInfoCache [ name ] ;
735
+ return commandInfoCache [ key ] ;
734
736
}
735
737
736
738
var commandInfo = GetCommandInfoInternal ( name , commandType ) ;
737
-
739
+ commandInfoCache . Add ( key , commandInfo ) ;
738
740
return commandInfo ;
739
741
}
740
742
}
0 commit comments