@@ -21,9 +21,9 @@ public sealed class MarkerCorrection
21
21
public string Name { get ; set ; }
22
22
23
23
/// <summary>
24
- /// Gets or sets the list of ScriptRegions that define the edits to be made by the correction.
24
+ /// Gets or sets the ScriptRegion that define the edit to be made by the correction.
25
25
/// </summary>
26
- public ScriptRegion [ ] Edits { get ; set ; }
26
+ public ScriptRegion Edit { get ; set ; }
27
27
}
28
28
29
29
/// <summary>
@@ -79,9 +79,9 @@ public class ScriptFileMarker
79
79
public ScriptRegion ScriptRegion { get ; set ; }
80
80
81
81
/// <summary>
82
- /// Gets or sets an optional code correction that can be applied based on this marker.
82
+ /// Gets or sets a optional code corrections that can be applied based on its marker.
83
83
/// </summary>
84
- public MarkerCorrection Correction { get ; set ; }
84
+ public IEnumerable < MarkerCorrection > Corrections { get ; set ; }
85
85
86
86
/// <summary>
87
87
/// Gets or sets the name of the marker's source like "PowerShell"
@@ -110,7 +110,6 @@ internal static ScriptFileMarker FromParseError(
110
110
internal static ScriptFileMarker FromDiagnosticRecord ( PSObject psObject )
111
111
{
112
112
Validate . IsNotNull ( nameof ( psObject ) , psObject ) ;
113
- MarkerCorrection correction = null ;
114
113
115
114
// make sure psobject is of type DiagnosticRecord
116
115
if ( ! psObject . TypeNames . Contains (
@@ -124,32 +123,25 @@ internal static ScriptFileMarker FromDiagnosticRecord(PSObject psObject)
124
123
// the diagnostic record's properties directly i.e. <instance>.<propertyName>
125
124
// without having to go through PSObject's Members property.
126
125
dynamic diagnosticRecord = psObject ;
127
-
126
+ List < MarkerCorrection > markerCorrections = new ( ) ;
128
127
if ( diagnosticRecord . SuggestedCorrections != null )
129
128
{
130
- List < ScriptRegion > editRegions = new ( ) ;
131
- string correctionMessage = null ;
132
129
foreach ( dynamic suggestedCorrection in diagnosticRecord . SuggestedCorrections )
133
130
{
134
- editRegions . Add (
135
- new ScriptRegion (
136
- diagnosticRecord . ScriptPath ,
137
- suggestedCorrection . Text ,
138
- startLineNumber : suggestedCorrection . StartLineNumber ,
139
- startColumnNumber : suggestedCorrection . StartColumnNumber ,
140
- endLineNumber : suggestedCorrection . EndLineNumber ,
141
- endColumnNumber : suggestedCorrection . EndColumnNumber ,
142
- startOffset : - 1 ,
143
- endOffset : - 1 ) ) ;
144
-
145
- correctionMessage = suggestedCorrection . Description ;
131
+ markerCorrections . Add ( new MarkerCorrection
132
+ {
133
+ Name = suggestedCorrection . Description ?? diagnosticRecord . Message ,
134
+ Edit = new ScriptRegion (
135
+ diagnosticRecord . ScriptPath ,
136
+ suggestedCorrection . Text ,
137
+ startLineNumber : suggestedCorrection . StartLineNumber ,
138
+ startColumnNumber : suggestedCorrection . StartColumnNumber ,
139
+ startOffset : - 1 ,
140
+ endLineNumber : suggestedCorrection . EndLineNumber ,
141
+ endColumnNumber : suggestedCorrection . EndColumnNumber ,
142
+ endOffset : - 1 ) ,
143
+ } ) ;
146
144
}
147
-
148
- correction = new MarkerCorrection
149
- {
150
- Name = correctionMessage ?? diagnosticRecord . Message ,
151
- Edits = editRegions . ToArray ( )
152
- } ;
153
145
}
154
146
155
147
string severity = diagnosticRecord . Severity . ToString ( ) ;
@@ -166,7 +158,7 @@ internal static ScriptFileMarker FromDiagnosticRecord(PSObject psObject)
166
158
RuleName = diagnosticRecord . RuleName as string ?? string . Empty ,
167
159
Level = level ,
168
160
ScriptRegion = ScriptRegion . Create ( diagnosticRecord . Extent as IScriptExtent ) ,
169
- Correction = correction ,
161
+ Corrections = markerCorrections ,
170
162
Source = "PSScriptAnalyzer"
171
163
} ;
172
164
}
0 commit comments