Skip to content

Commit b8f56fa

Browse files
Add new PSSA 1.18 ParseError Severity
1 parent 40cacf6 commit b8f56fa

File tree

1 file changed

+25
-28
lines changed

1 file changed

+25
-28
lines changed

src/PowerShellEditorServices/Workspace/ScriptFileMarker.cs

+25-28
Original file line numberDiff line numberDiff line change
@@ -33,20 +33,22 @@ public class MarkerCorrection
3333
/// </summary>
3434
public enum ScriptFileMarkerLevel
3535
{
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
5052
};
5153

5254
/// <summary>
@@ -62,7 +64,7 @@ public class ScriptFileMarker
6264
/// Gets or sets the marker's message string.
6365
/// </summary>
6466
public string Message { get; set; }
65-
67+
6668
/// <summary>
6769
/// Gets or sets the ruleName associated with this marker.
6870
/// </summary>
@@ -176,21 +178,16 @@ internal static ScriptFileMarker FromDiagnosticRecord(PSObject psObject)
176178
private static ScriptFileMarkerLevel GetMarkerLevelFromDiagnosticSeverity(
177179
string diagnosticSeverity)
178180
{
179-
switch (diagnosticSeverity)
181+
if(Enum.TryParse(diagnosticSeverity, out ScriptFileMarkerLevel level))
180182
{
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;
193184
}
185+
186+
throw new ArgumentException(
187+
string.Format(
188+
"The provided DiagnosticSeverity value '{0}' is unknown.",
189+
diagnosticSeverity),
190+
"diagnosticSeverity");
194191
}
195192
#endregion
196193
}

0 commit comments

Comments
 (0)