File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2121using System . Text . RegularExpressions ;
2222using Microsoft . Windows . PowerShell . ScriptAnalyzer . Generic ;
2323
24- using Newtonsoft . Json ;
24+ using Newtonsoft . Json . Linq ;
2525
2626namespace Microsoft . Windows . PowerShell . ScriptAnalyzer . BuiltinRules
2727{
@@ -209,28 +209,23 @@ private void ProcessDirectory(string path)
209209 continue ;
210210 }
211211
212- psCmdletMap [ fileNameWithoutExt ] = GetCmdletsFromData ( JsonConvert . DeserializeObject ( File . ReadAllText ( filePath ) ) ) ;
212+ psCmdletMap [ fileNameWithoutExt ] = GetCmdletsFromData ( JObject . Parse ( File . ReadAllText ( filePath ) ) ) ;
213213 }
214214 }
215215
216216 private HashSet < string > GetCmdletsFromData ( dynamic deserializedObject )
217217 {
218218 var cmdlets = new HashSet < string > ( StringComparer . OrdinalIgnoreCase ) ;
219- foreach ( var module in deserializedObject )
219+ dynamic modules = deserializedObject . Modules ;
220+ foreach ( var module in modules )
220221 {
221- if ( module . HasValues == false )
222+ foreach ( var cmdlet in module . ExportedCommands )
222223 {
223- continue ;
224- }
225-
226- foreach ( var cmdlet in module . Value )
227- {
228- if ( cmdlet . Name != null )
229- {
230- cmdlets . Add ( cmdlet . Name ) ;
231- }
224+ var name = cmdlet . Name . Value as string ;
225+ cmdlets . Add ( name ) ;
232226 }
233227 }
228+
234229 return cmdlets ;
235230 }
236231
You can’t perform that action at this time.
0 commit comments