@@ -41,6 +41,7 @@ public class UseCompatibleCmdlets : AstVisitor, IScriptRule
41
41
private Dictionary < string , dynamic > platformSpecMap ;
42
42
private string scriptPath ;
43
43
private bool IsInitialized ;
44
+ private bool hasInitializationError ;
44
45
private string referenceFile ;
45
46
private readonly string defaultReferenceFile = "desktop-5.1.14393.206-windows.json" ;
46
47
@@ -126,6 +127,11 @@ public IEnumerable<DiagnosticRecord> AnalyzeScript(Ast ast, string fileName)
126
127
Initialize ( ) ;
127
128
}
128
129
130
+ if ( hasInitializationError )
131
+ {
132
+ yield break ;
133
+ }
134
+
129
135
if ( ast == null )
130
136
{
131
137
throw new ArgumentNullException ( "ast" ) ;
@@ -217,6 +223,9 @@ private void Initialize()
217
223
/// </summary>
218
224
private void SetupCmdletsDictionary ( )
219
225
{
226
+ // If the method encounters any error, it returns early
227
+ // which implies there is an initialization error
228
+ hasInitializationError = true ;
220
229
Dictionary < string , object > ruleArgs = Helper . Instance . GetRuleArguments ( GetName ( ) ) ;
221
230
if ( ruleArgs == null )
222
231
{
@@ -316,6 +325,9 @@ private void SetupCmdletsDictionary()
316
325
}
317
326
318
327
ProcessDirectory ( settingsPath ) ;
328
+
329
+ // reached this point, so no error
330
+ hasInitializationError = false ;
319
331
}
320
332
321
333
/// <summary>
0 commit comments