Skip to content

Commit 3b18b78

Browse files
committed
Populate SuggestedCorrections when using scriptule and make it public for easier construction in PowerShell
1 parent a035491 commit 3b18b78

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

Engine/Generic/DiagnosticRecord.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public class DiagnosticRecord
1818
private DiagnosticSeverity severity;
1919
private string scriptPath;
2020
private string ruleSuppressionId;
21-
private List<CorrectionExtent> suggestedCorrections;
21+
private IEnumerable<CorrectionExtent> suggestedCorrections;
2222

2323
/// <summary>
2424
/// Represents a string from the rule about why this diagnostic was created.
@@ -89,6 +89,7 @@ public string RuleSuppressionID
8989
public IEnumerable<CorrectionExtent> SuggestedCorrections
9090
{
9191
get { return suggestedCorrections; }
92+
set { suggestedCorrections = value; }
9293
}
9394

9495
/// <summary>

Engine/ScriptAnalyzer.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1267,6 +1267,7 @@ internal IEnumerable<DiagnosticRecord> GetExternalRecord(Ast ast, Token[] token,
12671267
IScriptExtent extent;
12681268
string message = string.Empty;
12691269
string ruleName = string.Empty;
1270+
IEnumerable<CorrectionExtent> suggestedCorrections;
12701271

12711272
if (psobject != null && psobject.ImmediateBaseObject != null)
12721273
{
@@ -1286,6 +1287,7 @@ internal IEnumerable<DiagnosticRecord> GetExternalRecord(Ast ast, Token[] token,
12861287
message = psobject.Properties["Message"].Value.ToString();
12871288
extent = (IScriptExtent)psobject.Properties["Extent"].Value;
12881289
ruleName = psobject.Properties["RuleName"].Value.ToString();
1290+
suggestedCorrections = (IEnumerable<CorrectionExtent>)psobject.Properties["SuggestedCorrections"].Value;
12891291
}
12901292
catch (Exception ex)
12911293
{
@@ -1295,7 +1297,7 @@ internal IEnumerable<DiagnosticRecord> GetExternalRecord(Ast ast, Token[] token,
12951297

12961298
if (!string.IsNullOrEmpty(message))
12971299
{
1298-
diagnostics.Add(new DiagnosticRecord(message, extent, ruleName, severity, filePath));
1300+
diagnostics.Add(new DiagnosticRecord(message, extent, ruleName, severity, filePath) { SuggestedCorrections = suggestedCorrections });
12991301
}
13001302
}
13011303
}

0 commit comments

Comments
 (0)