Skip to content

Commit

Permalink
Fix analyzer RCS1181 (#1526)
Browse files Browse the repository at this point in the history
  • Loading branch information
josefpihrt committed Sep 16, 2024
1 parent 9335c71 commit e07914c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
1 change: 1 addition & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Fix analyzer [RCS0053](https://josefpihrt.github.io/docs/roslynator/analyzers/RCS0053) ([PR](https://github.com/dotnet/roslynator/pull/1518))
- Fix analyzer [RCS0056](https://josefpihrt.github.io/docs/roslynator/analyzers/RCS0056) ([PR](https://github.com/dotnet/roslynator/pull/1521))
- Fix analyzer [RCS1181](https://josefpihrt.github.io/docs/roslynator/analyzers/RCS1181) ([PR](https://github.com/dotnet/roslynator/pull/1526))

## [4.12.5] - 2024-09-13

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ public override void Initialize(AnalysisContext context)
{
base.Initialize(context);

context.RegisterSyntaxNodeAction(f => AnalyzeNamespaceDeclaration(f), SyntaxKind.NamespaceDeclaration);
context.RegisterSyntaxNodeAction(f => AnalyzeClassDeclaration(f), SyntaxKind.ClassDeclaration);
context.RegisterSyntaxNodeAction(f => AnalyzeStructDeclaration(f), SyntaxKind.StructDeclaration);
#if ROSLYN_4_0
Expand All @@ -53,18 +52,6 @@ public override void Initialize(AnalysisContext context)
context.RegisterSyntaxNodeAction(f => AnalyzeEventDeclaration(f), SyntaxKind.EventDeclaration);
}

private static void AnalyzeNamespaceDeclaration(SyntaxNodeAnalysisContext context)
{
if (AnalyzeLeading(context))
return;

var namespaceDeclaration = (NamespaceDeclarationSyntax)context.Node;

TrailingAnalysis? analysis = AnalyzeTrailing(namespaceDeclaration.Name);

ReportDiagnostic(context, analysis);
}

private static void AnalyzeClassDeclaration(SyntaxNodeAnalysisContext context)
{
if (AnalyzeLeading(context))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,4 +330,16 @@ void M1() //x
}
");
}

[Fact, Trait(Traits.Analyzer, DiagnosticIdentifiers.ConvertCommentToDocumentationComment)]
public async Task TestNoDiagnostic_NamespaceDeclaration()
{
await VerifyNoDiagnosticAsync(@"
namespace N // Some comment
{
class C
{
}
}");
}
}

0 comments on commit e07914c

Please sign in to comment.