@@ -1401,6 +1401,60 @@ public void Bar()
14011401 await this . VerifyCSharpFixAsync ( testCode , fixedCode ) . ConfigureAwait ( false ) ;
14021402 }
14031403
1404+ /// <summary>
1405+ /// Verifies that a preprocessor statement with unnecessary parenthesis is handled correctly.
1406+ /// Regression test for #2069
1407+ /// </summary>
1408+ /// <returns>A <see cref="Task"/> representing the asynchronous unit test.</returns>
1409+ [ Fact ]
1410+ public async Task VerifyThatPreprocessorStatementIsHandledCorrectlyAsync ( )
1411+ {
1412+ string testCode = @"
1413+ public class Program
1414+ {
1415+ public static void Main(string[] args)
1416+ {
1417+ #if(DEBUG)
1418+
1419+ #endif
1420+
1421+ #if (DEBUG)
1422+
1423+ #endif
1424+ }
1425+ }
1426+ " ;
1427+
1428+ string fixedCode = @"
1429+ public class Program
1430+ {
1431+ public static void Main(string[] args)
1432+ {
1433+ #if DEBUG
1434+
1435+ #endif
1436+
1437+ #if DEBUG
1438+
1439+ #endif
1440+ }
1441+ }
1442+ " ;
1443+ DiagnosticResult [ ] expected =
1444+ {
1445+ this . CSharpDiagnostic ( DiagnosticId ) . WithLocation ( 6 , 4 ) ,
1446+ this . CSharpDiagnostic ( ParenthesesDiagnosticId ) . WithLocation ( 6 , 4 ) ,
1447+ this . CSharpDiagnostic ( ParenthesesDiagnosticId ) . WithLocation ( 6 , 10 ) ,
1448+ this . CSharpDiagnostic ( DiagnosticId ) . WithLocation ( 10 , 5 ) ,
1449+ this . CSharpDiagnostic ( ParenthesesDiagnosticId ) . WithLocation ( 10 , 5 ) ,
1450+ this . CSharpDiagnostic ( ParenthesesDiagnosticId ) . WithLocation ( 10 , 11 ) ,
1451+ } ;
1452+
1453+ await this . VerifyCSharpDiagnosticAsync ( testCode , expected , CancellationToken . None ) . ConfigureAwait ( false ) ;
1454+ await this . VerifyCSharpDiagnosticAsync ( fixedCode , EmptyDiagnosticResults , CancellationToken . None ) . ConfigureAwait ( false ) ;
1455+ await this . VerifyCSharpFixAsync ( testCode , fixedCode ) . ConfigureAwait ( false ) ;
1456+ }
1457+
14041458 /// <inheritdoc/>
14051459 protected override IEnumerable < DiagnosticAnalyzer > GetCSharpDiagnosticAnalyzers ( )
14061460 {
0 commit comments