File tree Expand file tree Collapse file tree 3 files changed +54
-0
lines changed
StyleCop.Analyzers.Test.CSharp9/ReadabilityRules Expand file tree Collapse file tree 3 files changed +54
-0
lines changed Original file line number Diff line number Diff line change 33
44namespace StyleCop . Analyzers . Test . CSharp9 . ReadabilityRules
55{
6+ using System . Threading ;
7+ using System . Threading . Tasks ;
8+ using Microsoft . CodeAnalysis . Testing ;
69 using StyleCop . Analyzers . Test . CSharp8 . ReadabilityRules ;
10+ using Xunit ;
11+ using static StyleCop . Analyzers . Test . Verifiers . StyleCopCodeFixVerifier <
12+ StyleCop . Analyzers . ReadabilityRules . SA1137ElementsShouldHaveTheSameIndentation ,
13+ StyleCop . Analyzers . ReadabilityRules . IndentationCodeFixProvider > ;
714
815 public class SA1137CSharp9UnitTests : SA1137CSharp8UnitTests
916 {
17+ [ Fact ]
18+ [ WorkItem ( 3668 , "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3668" ) ]
19+ public async Task TestInitAccessorAttributeListAsync ( )
20+ {
21+ string testCode = @"
22+ using System;
23+
24+ class TestClass
25+ {
26+ int Property
27+ {
28+ [My]
29+ [| |][My]
30+ init { }
31+ }
32+ }
33+
34+ [AttributeUsage(AttributeTargets.All, AllowMultiple = true)]
35+ class MyAttribute : Attribute { }
36+ " ;
37+
38+ string fixedCode = @"
39+ using System;
40+
41+ class TestClass
42+ {
43+ int Property
44+ {
45+ [My]
46+ [My]
47+ init { }
48+ }
49+ }
50+
51+ [AttributeUsage(AttributeTargets.All, AllowMultiple = true)]
52+ class MyAttribute : Attribute { }
53+ " ;
54+
55+ await new CSharpTest
56+ {
57+ ReferenceAssemblies = ReferenceAssemblies . Net . Net50 ,
58+ TestCode = testCode ,
59+ FixedCode = fixedCode ,
60+ } . RunAsync ( CancellationToken . None ) . ConfigureAwait ( false ) ;
61+ }
1062 }
1163}
Original file line number Diff line number Diff line change @@ -62,6 +62,7 @@ internal static class SyntaxKindEx
6262 public const SyntaxKind NullableDirectiveTrivia = ( SyntaxKind ) 9055 ;
6363 public const SyntaxKind FunctionPointerType = ( SyntaxKind ) 9056 ;
6464 public const SyntaxKind FunctionPointerParameter = ( SyntaxKind ) 9057 ;
65+ public const SyntaxKind InitAccessorDeclaration = ( SyntaxKind ) 9060 ;
6566 public const SyntaxKind WithExpression = ( SyntaxKind ) 9061 ;
6667 public const SyntaxKind WithInitializerExpression = ( SyntaxKind ) 9062 ;
6768 public const SyntaxKind RecordDeclaration = ( SyntaxKind ) 9063 ;
Original file line number Diff line number Diff line change @@ -336,6 +336,7 @@ private static void AddMemberAndAttributes(ImmutableList<SyntaxNode>.Builder ele
336336
337337 case SyntaxKind . GetAccessorDeclaration :
338338 case SyntaxKind . SetAccessorDeclaration :
339+ case SyntaxKindEx . InitAccessorDeclaration :
339340 case SyntaxKind . AddAccessorDeclaration :
340341 case SyntaxKind . RemoveAccessorDeclaration :
341342 case SyntaxKind . UnknownAccessorDeclaration :
You can’t perform that action at this time.
0 commit comments