@@ -33,20 +33,22 @@ public class MarkerCorrection
33
33
/// </summary>
34
34
public enum ScriptFileMarkerLevel
35
35
{
36
- /// <summary>
37
- /// The marker represents an informational message.
38
- /// </summary>
39
- Information = 0 ,
40
-
41
- /// <summary>
42
- /// The marker represents a warning message.
43
- /// </summary>
44
- Warning ,
45
-
46
- /// <summary>
47
- /// The marker represents an error message.
48
- /// </summary>
49
- Error
36
+ /// <summary>
37
+ /// Information: This warning is trivial, but may be useful. They are recommended by PowerShell best practice.
38
+ /// </summary>
39
+ Information = 0 ,
40
+ /// <summary>
41
+ /// WARNING: This warning may cause a problem or does not follow PowerShell's recommended guidelines.
42
+ /// </summary>
43
+ Warning = 1 ,
44
+ /// <summary>
45
+ /// ERROR: This warning is likely to cause a problem or does not follow PowerShell's required guidelines.
46
+ /// </summary>
47
+ Error = 2 ,
48
+ /// <summary>
49
+ /// ERROR: This diagnostic is caused by an actual parsing error, and is generated only by the engine.
50
+ /// </summary>
51
+ ParseError = 3
50
52
} ;
51
53
52
54
/// <summary>
@@ -62,7 +64,7 @@ public class ScriptFileMarker
62
64
/// Gets or sets the marker's message string.
63
65
/// </summary>
64
66
public string Message { get ; set ; }
65
-
67
+
66
68
/// <summary>
67
69
/// Gets or sets the ruleName associated with this marker.
68
70
/// </summary>
@@ -176,21 +178,16 @@ internal static ScriptFileMarker FromDiagnosticRecord(PSObject psObject)
176
178
private static ScriptFileMarkerLevel GetMarkerLevelFromDiagnosticSeverity (
177
179
string diagnosticSeverity )
178
180
{
179
- switch ( diagnosticSeverity )
181
+ if ( Enum . TryParse ( diagnosticSeverity , out ScriptFileMarkerLevel level ) )
180
182
{
181
- case "Information" :
182
- return ScriptFileMarkerLevel . Information ;
183
- case "Warning" :
184
- return ScriptFileMarkerLevel . Warning ;
185
- case "Error" :
186
- return ScriptFileMarkerLevel . Error ;
187
- default :
188
- throw new ArgumentException (
189
- string . Format (
190
- "The provided DiagnosticSeverity value '{0}' is unknown." ,
191
- diagnosticSeverity ) ,
192
- "diagnosticSeverity" ) ;
183
+ return level ;
193
184
}
185
+
186
+ throw new ArgumentException (
187
+ string . Format (
188
+ "The provided DiagnosticSeverity value '{0}' is unknown." ,
189
+ diagnosticSeverity ) ,
190
+ "diagnosticSeverity" ) ;
194
191
}
195
192
#endregion
196
193
}
0 commit comments