File tree Expand file tree Collapse file tree 2 files changed +32
-3
lines changed
StyleCop.Analyzers.Test.CSharp12/LayoutRules
StyleCop.Analyzers/LayoutRules Expand file tree Collapse file tree 2 files changed +32
-3
lines changed Original file line number Diff line number Diff line change 33
44namespace StyleCop . Analyzers . Test . CSharp12 . LayoutRules
55{
6+ using System . Threading ;
7+ using System . Threading . Tasks ;
8+ using Microsoft . CodeAnalysis . Testing ;
69 using StyleCop . Analyzers . Test . CSharp11 . LayoutRules ;
10+ using Xunit ;
11+
12+ using static StyleCop . Analyzers . Test . Verifiers . StyleCopCodeFixVerifier <
13+ StyleCop . Analyzers . LayoutRules . SA1515SingleLineCommentMustBePrecededByBlankLine ,
14+ StyleCop . Analyzers . LayoutRules . SA1515CodeFixProvider > ;
715
816 public partial class SA1515CSharp12UnitTests : SA1515CSharp11UnitTests
917 {
18+ [ Fact ]
19+ [ WorkItem ( 3766 , "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3766" ) ]
20+ public async Task TestFirstInCollectionExpressionAsync ( )
21+ {
22+ var testCode = @"
23+ public class TestClass
24+ {
25+ private string[] elements =
26+ [
27+ // Hydrogen
28+ ""H"",
29+
30+ // Helium
31+ ""He"",
32+ ];
33+ }
34+ " ;
35+
36+ await VerifyCSharpDiagnosticAsync ( testCode , DiagnosticResult . EmptyDiagnosticResults , CancellationToken . None ) . ConfigureAwait ( false ) ;
37+ }
1038 }
1139}
Original file line number Diff line number Diff line change @@ -266,9 +266,10 @@ private static bool IsAtStartOfScope(SyntaxTrivia trivia)
266266
267267 var prevToken = token . GetPreviousToken ( ) ;
268268 return prevToken . IsKind ( SyntaxKind . OpenBraceToken )
269- || prevToken . Parent . IsKind ( SyntaxKind . CaseSwitchLabel )
270- || prevToken . Parent . IsKind ( SyntaxKindEx . CasePatternSwitchLabel )
271- || prevToken . Parent . IsKind ( SyntaxKind . DefaultSwitchLabel ) ;
269+ || ( prevToken . IsKind ( SyntaxKind . OpenBracketToken ) && prevToken . Parent . IsKind ( SyntaxKindEx . CollectionExpression ) )
270+ || prevToken . Parent . IsKind ( SyntaxKind . CaseSwitchLabel )
271+ || prevToken . Parent . IsKind ( SyntaxKindEx . CasePatternSwitchLabel )
272+ || prevToken . Parent . IsKind ( SyntaxKind . DefaultSwitchLabel ) ;
272273 }
273274
274275 private static bool IsPrecededByDirectiveTrivia < T > ( T triviaList , int triviaIndex )
You can’t perform that action at this time.
0 commit comments