@@ -31,6 +31,7 @@ public sealed class ScriptAnalyzer
31
31
32
32
private IOutputWriter outputWriter ;
33
33
private Dictionary < string , object > settings ;
34
+ private readonly Regex s_aboutHelpRegex = new Regex ( "^about_.*help\\ .txt$" , RegexOptions . IgnoreCase | RegexOptions . Compiled ) ;
34
35
#if ! CORECLR
35
36
private CompositionContainer container ;
36
37
#endif // !CORECLR
@@ -1526,20 +1527,19 @@ public IEnumerable<DiagnosticRecord> AnalyzeScriptDefinition(string scriptDefini
1526
1527
1527
1528
var relevantParseErrors = RemoveTypeNotFoundParseErrors ( errors , out List < DiagnosticRecord > diagnosticRecords ) ;
1528
1529
1529
- int emitParseErrors = severity == null ? 1 : severity . Count ( item => item == "ParseError" ) ;
1530
1530
// Add parse errors first if requested!
1531
- if ( relevantParseErrors != null && emitParseErrors == 1 )
1531
+ if ( relevantParseErrors != null && ( severity == null || severity . Contains ( "ParseError" , StringComparer . OrdinalIgnoreCase ) ) )
1532
1532
{
1533
- List < DiagnosticRecord > results = new List < DiagnosticRecord > ( ) ;
1534
- foreach ( var parseError in relevantParseErrors )
1533
+ var results = new List < DiagnosticRecord > ( ) ;
1534
+ foreach ( ParseError parseError in relevantParseErrors )
1535
1535
{
1536
1536
string parseErrorMessage = String . Format ( CultureInfo . CurrentCulture , Strings . ParseErrorFormatForScriptDefinition , parseError . Message . TrimEnd ( '.' ) , parseError . Extent . StartLineNumber , parseError . Extent . StartColumnNumber ) ;
1537
1537
results . Add ( new DiagnosticRecord (
1538
1538
parseError . Message ,
1539
1539
parseError . Extent ,
1540
1540
parseError . ErrorId . ToString ( ) ,
1541
1541
DiagnosticSeverity . ParseError ,
1542
- "" // no script file
1542
+ String . Empty // no script file
1543
1543
)
1544
1544
) ;
1545
1545
}
@@ -1855,7 +1855,7 @@ private IEnumerable<DiagnosticRecord> AnalyzeFile(string filePath)
1855
1855
1856
1856
// short-circuited processing for a help file
1857
1857
// no parsing can really be done, but there are other rules to run (specifically encoding).
1858
- if ( Regex . Matches ( Path . GetFileName ( filePath ) , @"^about_.*help.txt$" , RegexOptions . IgnoreCase ) . Count != 0 )
1858
+ if ( s_aboutHelpRegex . IsMatch ( Path . GetFileName ( filePath ) ) )
1859
1859
{
1860
1860
return diagnosticRecords . Concat ( this . AnalyzeSyntaxTree ( scriptAst , scriptTokens , filePath ) ) ;
1861
1861
}
@@ -1877,14 +1877,13 @@ private IEnumerable<DiagnosticRecord> AnalyzeFile(string filePath)
1877
1877
scriptAst = Parser . ParseFile ( filePath , out scriptTokens , out errors ) ;
1878
1878
}
1879
1879
#endif //!PSV3
1880
- var relevantParseErrors = RemoveTypeNotFoundParseErrors ( errors , out diagnosticRecords ) ;
1880
+ IEnumerable < ParseError > relevantParseErrors = RemoveTypeNotFoundParseErrors ( errors , out diagnosticRecords ) ;
1881
1881
1882
1882
// First, add all parse errors if they've been requested
1883
- int emitParseErrors = severity == null ? 1 : severity . Count ( item => item == "ParseError" ) ;
1884
- if ( relevantParseErrors != null && emitParseErrors == 1 )
1883
+ if ( relevantParseErrors != null && ( severity == null || severity . Contains ( "ParseError" , StringComparer . OrdinalIgnoreCase ) ) )
1885
1884
{
1886
1885
List < DiagnosticRecord > results = new List < DiagnosticRecord > ( ) ;
1887
- foreach ( var parseError in relevantParseErrors )
1886
+ foreach ( ParseError parseError in relevantParseErrors )
1888
1887
{
1889
1888
string parseErrorMessage = String . Format ( CultureInfo . CurrentCulture , Strings . ParseErrorFormatForScriptDefinition , parseError . Message . TrimEnd ( '.' ) , parseError . Extent . StartLineNumber , parseError . Extent . StartColumnNumber ) ;
1890
1889
results . Add ( new DiagnosticRecord (
0 commit comments