@@ -21,9 +21,9 @@ public sealed class MarkerCorrection
2121 public string Name { get ; set ; }
2222
2323 /// <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.
2525 /// </summary>
26- public ScriptRegion [ ] Edits { get ; set ; }
26+ public ScriptRegion Edit { get ; set ; }
2727 }
2828
2929 /// <summary>
@@ -79,9 +79,9 @@ public class ScriptFileMarker
7979 public ScriptRegion ScriptRegion { get ; set ; }
8080
8181 /// <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.
8383 /// </summary>
84- public MarkerCorrection Correction { get ; set ; }
84+ public IEnumerable < MarkerCorrection > Corrections { get ; set ; }
8585
8686 /// <summary>
8787 /// Gets or sets the name of the marker's source like "PowerShell"
@@ -110,7 +110,6 @@ internal static ScriptFileMarker FromParseError(
110110 internal static ScriptFileMarker FromDiagnosticRecord ( PSObject psObject )
111111 {
112112 Validate . IsNotNull ( nameof ( psObject ) , psObject ) ;
113- MarkerCorrection correction = null ;
114113
115114 // make sure psobject is of type DiagnosticRecord
116115 if ( ! psObject . TypeNames . Contains (
@@ -124,32 +123,25 @@ internal static ScriptFileMarker FromDiagnosticRecord(PSObject psObject)
124123 // the diagnostic record's properties directly i.e. <instance>.<propertyName>
125124 // without having to go through PSObject's Members property.
126125 dynamic diagnosticRecord = psObject ;
127-
126+ List < MarkerCorrection > markerCorrections = new ( ) ;
128127 if ( diagnosticRecord . SuggestedCorrections != null )
129128 {
130- List < ScriptRegion > editRegions = new ( ) ;
131- string correctionMessage = null ;
132129 foreach ( dynamic suggestedCorrection in diagnosticRecord . SuggestedCorrections )
133130 {
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+ } ) ;
146144 }
147-
148- correction = new MarkerCorrection
149- {
150- Name = correctionMessage ?? diagnosticRecord . Message ,
151- Edits = editRegions . ToArray ( )
152- } ;
153145 }
154146
155147 string severity = diagnosticRecord . Severity . ToString ( ) ;
@@ -166,7 +158,7 @@ internal static ScriptFileMarker FromDiagnosticRecord(PSObject psObject)
166158 RuleName = diagnosticRecord . RuleName as string ?? string . Empty ,
167159 Level = level ,
168160 ScriptRegion = ScriptRegion . Create ( diagnosticRecord . Extent as IScriptExtent ) ,
169- Correction = correction ,
161+ Corrections = markerCorrections ,
170162 Source = "PSScriptAnalyzer"
171163 } ;
172164 }
0 commit comments