@@ -52,11 +52,6 @@ public class AnalysisService : IDisposable
52
52
/// </summary>
53
53
private static readonly PSObject [ ] s_emptyDiagnosticResult = new PSObject [ 0 ] ;
54
54
55
- /// <summary>
56
- /// An empty script marker result to return when no script markers can be returned.
57
- /// </summary>
58
- private static readonly ScriptFileMarker [ ] s_emptyScriptMarkerResult = new ScriptFileMarker [ 0 ] ;
59
-
60
55
private static readonly string [ ] s_emptyGetRuleResult = new string [ 0 ] ;
61
56
62
57
/// <summary>
@@ -266,7 +261,7 @@ public static Hashtable GetPSSASettingsHashtable(IDictionary<string, Hashtable>
266
261
/// </summary>
267
262
/// <param name="file">The ScriptFile which will be analyzed for semantic markers.</param>
268
263
/// <returns>An array of ScriptFileMarkers containing semantic analysis results.</returns>
269
- public async Task < ScriptFileMarker [ ] > GetSemanticMarkersAsync ( ScriptFile file )
264
+ public async Task < List < ScriptFileMarker > > GetSemanticMarkersAsync ( ScriptFile file )
270
265
{
271
266
return await GetSemanticMarkersAsync < string > ( file , ActiveRules , SettingsPath ) ;
272
267
}
@@ -277,7 +272,7 @@ public async Task<ScriptFileMarker[]> GetSemanticMarkersAsync(ScriptFile file)
277
272
/// <param name="file">The ScriptFile to be analyzed.</param>
278
273
/// <param name="settings">ScriptAnalyzer settings</param>
279
274
/// <returns></returns>
280
- public async Task < ScriptFileMarker [ ] > GetSemanticMarkersAsync ( ScriptFile file , Hashtable settings )
275
+ public async Task < List < ScriptFileMarker > > GetSemanticMarkersAsync ( ScriptFile file , Hashtable settings )
281
276
{
282
277
return await GetSemanticMarkersAsync < Hashtable > ( file , null , settings ) ;
283
278
}
@@ -288,7 +283,7 @@ public async Task<ScriptFileMarker[]> GetSemanticMarkersAsync(ScriptFile file, H
288
283
/// <param name="scriptContent">The script content to be analyzed.</param>
289
284
/// <param name="settings">ScriptAnalyzer settings</param>
290
285
/// <returns></returns>
291
- public async Task < ScriptFileMarker [ ] > GetSemanticMarkersAsync (
286
+ public async Task < List < ScriptFileMarker > > GetSemanticMarkersAsync (
292
287
string scriptContent ,
293
288
Hashtable settings )
294
289
{
@@ -379,7 +374,7 @@ public async Task<string> Format(
379
374
380
375
#region Private Methods
381
376
382
- private async Task < ScriptFileMarker [ ] > GetSemanticMarkersAsync < TSettings > (
377
+ private async Task < List < ScriptFileMarker > > GetSemanticMarkersAsync < TSettings > (
383
378
ScriptFile file ,
384
379
string [ ] rules ,
385
380
TSettings settings ) where TSettings : class
@@ -394,11 +389,11 @@ private async Task<ScriptFileMarker[]> GetSemanticMarkersAsync<TSettings>(
394
389
else
395
390
{
396
391
// Return an empty marker list
397
- return s_emptyScriptMarkerResult ;
392
+ return new List < ScriptFileMarker > ( ) ;
398
393
}
399
394
}
400
395
401
- private async Task < ScriptFileMarker [ ] > GetSemanticMarkersAsync < TSettings > (
396
+ private async Task < List < ScriptFileMarker > > GetSemanticMarkersAsync < TSettings > (
402
397
string scriptContent ,
403
398
string [ ] rules ,
404
399
TSettings settings ) where TSettings : class
@@ -407,12 +402,12 @@ private async Task<ScriptFileMarker[]> GetSemanticMarkersAsync<TSettings>(
407
402
&& ( rules != null || settings != null ) )
408
403
{
409
404
var scriptFileMarkers = await GetDiagnosticRecordsAsync ( scriptContent , rules , settings ) ;
410
- return scriptFileMarkers . Select ( ScriptFileMarker . FromDiagnosticRecord ) . ToArray ( ) ;
405
+ return scriptFileMarkers . Select ( ScriptFileMarker . FromDiagnosticRecord ) . ToList ( ) ;
411
406
}
412
407
else
413
408
{
414
409
// Return an empty marker list
415
- return s_emptyScriptMarkerResult ;
410
+ return new List < ScriptFileMarker > ( ) ;
416
411
}
417
412
}
418
413
@@ -514,7 +509,9 @@ private async Task<PSObject[]> GetDiagnosticRecordsAsync<TSettings>(
514
509
new Dictionary < string , object >
515
510
{
516
511
{ "ScriptDefinition" , scriptContent } ,
517
- { settingParameter , settingArgument }
512
+ { settingParameter , settingArgument } ,
513
+ // We ignore ParseErrors from PSSA because we already send them when we parse the file.
514
+ { "Severity" , new [ ] { ScriptFileMarkerLevel . Error , ScriptFileMarkerLevel . Information , ScriptFileMarkerLevel . Warning } }
518
515
} ) ;
519
516
520
517
diagnosticRecords = result ? . Output ;
0 commit comments