File tree Expand file tree Collapse file tree 1 file changed +20
-2
lines changed Expand file tree Collapse file tree 1 file changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -156,9 +156,27 @@ public void Initialize()
156
156
runspacePool . SetMaxRunspaces ( 3 ) ;
157
157
runspacePool . Open ( ) ;
158
158
159
- IEnumerable < CommandInfo > aliases = this . invokeCommand . GetCommands ( "*" , CommandTypes . Alias , true ) ;
159
+ // set up command info cache
160
+ foreach ( var cmdInfo in this . invokeCommand . GetCommands ( "*" , CommandTypes . All , true ) )
161
+ {
162
+ if ( ! commandInfoCache . ContainsKey ( cmdInfo . Name ) )
163
+ {
164
+ commandInfoCache . AddOrUpdate ( cmdInfo . Name , key => cmdInfo , ( key , value ) => cmdInfo ) ;
165
+ }
166
+ else
167
+ {
168
+ var version = commandInfoCache [ cmdInfo . Name ] . Version ;
169
+ if ( cmdInfo . Version != null
170
+ && ( version == null
171
+ || cmdInfo . Version > commandInfoCache [ cmdInfo . Name ] . Version ) )
172
+ {
173
+ commandInfoCache [ cmdInfo . Name ] = cmdInfo ;
174
+ }
175
+ }
176
+ }
160
177
161
- foreach ( AliasInfo aliasInfo in aliases )
178
+ // set up alias cache
179
+ foreach ( AliasInfo aliasInfo in commandInfoCache . Values . Where ( cmdInfo => cmdInfo . CommandType == CommandTypes . Alias ) )
162
180
{
163
181
if ( ! CmdletToAliasDictionary . ContainsKey ( aliasInfo . Definition ) )
164
182
{
You can’t perform that action at this time.
0 commit comments