File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed
StyleCop.Analyzers.Test.CSharp9/ReadabilityRules
StyleCop.Analyzers/ReadabilityRules Expand file tree Collapse file tree 2 files changed +22
-1
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 . CSharp ;
9+ using Microsoft . CodeAnalysis . Testing ;
610 using StyleCop . Analyzers . Test . CSharp8 . ReadabilityRules ;
11+ using Xunit ;
12+ using static StyleCop . Analyzers . Test . Verifiers . StyleCopCodeFixVerifier <
13+ StyleCop . Analyzers . ReadabilityRules . SA1106CodeMustNotContainEmptyStatements ,
14+ StyleCop . Analyzers . ReadabilityRules . SA1106CodeFixProvider > ;
715
816 public class SA1106CSharp9UnitTests : SA1106CSharp8UnitTests
917 {
18+ [ Fact ]
19+ [ WorkItem ( 3267 , "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3267" ) ]
20+ public async Task TestNoDiagnosticForEmptyRecordDeclarationAsync ( )
21+ {
22+ var testCode = @"public record Result(int Value);" ;
23+
24+ await new CSharpTest ( LanguageVersion . CSharp9 )
25+ {
26+ ReferenceAssemblies = ReferenceAssemblies . Net . Net50 ,
27+ TestCode = testCode ,
28+ } . RunAsync ( CancellationToken . None ) . ConfigureAwait ( false ) ;
29+ }
1030 }
1131}
Original file line number Diff line number Diff line change @@ -56,7 +56,8 @@ private static void HandleBaseTypeDeclaration(SyntaxNodeAnalysisContext context)
5656 {
5757 var declaration = ( BaseTypeDeclarationSyntax ) context . Node ;
5858
59- if ( declaration . SemicolonToken . IsKind ( SyntaxKind . SemicolonToken ) )
59+ if ( declaration . SemicolonToken . IsKind ( SyntaxKind . SemicolonToken )
60+ && ! declaration . OpenBraceToken . IsKind ( SyntaxKind . None ) )
6061 {
6162 context . ReportDiagnostic ( Diagnostic . Create ( Descriptor , declaration . SemicolonToken . GetLocation ( ) ) ) ;
6263 }
You can’t perform that action at this time.
0 commit comments