File tree Expand file tree Collapse file tree 1 file changed +8
-13
lines changed Expand file tree Collapse file tree 1 file changed +8
-13
lines changed Original file line number Diff line number Diff line change 21
21
using System . Text . RegularExpressions ;
22
22
using Microsoft . Windows . PowerShell . ScriptAnalyzer . Generic ;
23
23
24
- using Newtonsoft . Json ;
24
+ using Newtonsoft . Json . Linq ;
25
25
26
26
namespace Microsoft . Windows . PowerShell . ScriptAnalyzer . BuiltinRules
27
27
{
@@ -209,28 +209,23 @@ private void ProcessDirectory(string path)
209
209
continue ;
210
210
}
211
211
212
- psCmdletMap [ fileNameWithoutExt ] = GetCmdletsFromData ( JsonConvert . DeserializeObject ( File . ReadAllText ( filePath ) ) ) ;
212
+ psCmdletMap [ fileNameWithoutExt ] = GetCmdletsFromData ( JObject . Parse ( File . ReadAllText ( filePath ) ) ) ;
213
213
}
214
214
}
215
215
216
216
private HashSet < string > GetCmdletsFromData ( dynamic deserializedObject )
217
217
{
218
218
var cmdlets = new HashSet < string > ( StringComparer . OrdinalIgnoreCase ) ;
219
- foreach ( var module in deserializedObject )
219
+ dynamic modules = deserializedObject . Modules ;
220
+ foreach ( var module in modules )
220
221
{
221
- if ( module . HasValues == false )
222
+ foreach ( var cmdlet in module . ExportedCommands )
222
223
{
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 ) ;
232
226
}
233
227
}
228
+
234
229
return cmdlets ;
235
230
}
236
231
You can’t perform that action at this time.
0 commit comments