File tree Expand file tree Collapse file tree
StyleCop.Analyzers.Test.CSharp9/ReadabilityRules Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33
44namespace StyleCop . Analyzers . Test . CSharp9 . ReadabilityRules
55{
6+ using System . Threading . Tasks ;
7+ using Microsoft . CodeAnalysis . Testing ;
68 using StyleCop . Analyzers . Test . CSharp8 . ReadabilityRules ;
9+ using Xunit ;
10+ using static StyleCop . Analyzers . Test . Verifiers . StyleCopCodeFixVerifier <
11+ StyleCop . Analyzers . ReadabilityRules . SA1137ElementsShouldHaveTheSameIndentation ,
12+ StyleCop . Analyzers . ReadabilityRules . IndentationCodeFixProvider > ;
713
814 public class SA1137CSharp9UnitTests : SA1137CSharp8UnitTests
915 {
16+ [ Fact ]
17+ [ WorkItem ( 3668 , "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3668" ) ]
18+ public async Task TestInitAccessorAttributeListAsync ( )
19+ {
20+ string testCode = @"
21+ using System;
22+
23+ class TestClass
24+ {
25+ int Property
26+ {
27+ [My]
28+ [| |][My]
29+ init { }
30+ }
31+ }
32+
33+ [AttributeUsage(AttributeTargets.All, AllowMultiple = true)]
34+ class MyAttribute : Attribute { }
35+ " ;
36+
37+ string fixedCode = @"
38+ using System;
39+
40+ class TestClass
41+ {
42+ int Property
43+ {
44+ [My]
45+ [My]
46+ init { }
47+ }
48+ }
49+
50+ [AttributeUsage(AttributeTargets.All, AllowMultiple = true)]
51+ class MyAttribute : Attribute { }
52+ " ;
53+
54+ var test = new CSharpTest
55+ {
56+ ReferenceAssemblies = ReferenceAssemblies . Net . Net50 ,
57+ TestCode = testCode ,
58+ FixedCode = fixedCode ,
59+ } ;
60+ await test . RunAsync ( ) . 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