File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed
StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -232,6 +232,25 @@ public async Task TestLambdaExpressionWithNoSpaceAfterClosingParenthesisAsync()
232232 await this . TestWhitespaceInStatementOrDeclAsync ( invalidStatement , validStatement , expected ) . ConfigureAwait ( false ) ;
233233 }
234234
235+ /// <summary>
236+ /// This is a regression test for DotNetAnalyzers/StyleCopAnalyzers#255 and
237+ /// DotNetAnalyzers/StyleCopAnalyzers#256.
238+ /// </summary>
239+ /// <param name="operatorToken">The operator to test.</param>
240+ /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
241+ [ Theory ]
242+ [ InlineData ( "+" ) ]
243+ [ InlineData ( "-" ) ]
244+ public async Task TestNotReportedWhenFollowedByUnaryPlusOrMinusAsync ( string operatorToken )
245+ {
246+ // This will be reported as SA1021 or SA1022
247+ var ignoredStatement = $ "var i = (int) { operatorToken } 2;";
248+ var correctStatement = $ "var i = (int){ operatorToken } 2;";
249+
250+ await this . TestWhitespaceInStatementOrDeclAsync ( ignoredStatement , string . Empty , EmptyDiagnosticResults ) . ConfigureAwait ( false ) ;
251+ await this . TestWhitespaceInStatementOrDeclAsync ( correctStatement , string . Empty , EmptyDiagnosticResults ) . ConfigureAwait ( false ) ;
252+ }
253+
235254 [ Fact ]
236255 public async Task TestSpaceBeforeParenthisInIncrementingForLoopAsync ( )
237256 {
You can’t perform that action at this time.
0 commit comments