Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed

- Fix analyzer [RCS1060](https://josefpihrt.github.io/docs/roslynator/analyzers/RCS1060) to ignore classes marked with `file` modifier ([PR](https://github.com/dotnet/roslynator/pull/1777) by @cbersch)
- Fix enum contained flags check for partial matches in [RCS1258](https://josefpihrt.github.io/docs/roslynator/analyzers/RCS1258) ([PR](https://github.com/dotnet/roslynator/pull/1740) by @ovska)
- Fix analyzer [RCS1146](https://josefpihrt.github.io/docs/roslynator/analyzers/RCS1146) ([PR](https://github.com/dotnet/roslynator/pull/1747))
- Fix analyzer [RCS1194](https://josefpihrt.github.io/docs/roslynator/analyzers/RCS1194) ([PR](https://github.com/dotnet/roslynator/pull/1733))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ void Analyze(SyntaxList<MemberDeclarationSyntax> members)
{
Analyze(namespaceDeclaration.Members);
}
else if (SyntaxFacts.IsTypeDeclaration(member.Kind()))
else if (SyntaxFacts.IsTypeDeclaration(member.Kind()) && !member.Modifiers.Contains(SyntaxKind.FileKeyword))
Comment thread
cbersch marked this conversation as resolved.
Outdated
{
if (firstTypeDeclaration is null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,45 +16,69 @@ public class RCS1060DeclareEachTypeInSeparateFileTests : AbstractCSharpDiagnosti
public async Task Test_Namespace()
{
await VerifyDiagnosticAndFixAsync("""
namespace N
{
public class [|C1|]
{
}
namespace N
Comment thread
cbersch marked this conversation as resolved.
Outdated
{
public class [|C1|]
{
}

public class [|C2|]
{
}
}
""", """
namespace N
{
public class C2
{
}
}
""");
public class [|C2|]
{
}
}
""", """
namespace N
{
public class C2
{
}
}
""");
}

[Fact, Trait(Traits.Analyzer, DiagnosticIdentifiers.DeclareEachTypeInSeparateFile)]
public async Task Test_FileScopedNamespace()
{
await VerifyDiagnosticAndFixAsync("""
namespace N;
namespace N;

public class [|C1|]
{
}
public class [|C1|]
{
}

public class [|C2|]
{
}
""", """
namespace N;
public class [|C2|]
{
}
""", """
namespace N;

public class C2
{
}
""");
public class C2
{
}
""");
}

[Fact, Trait(Traits.Analyzer, DiagnosticIdentifiers.DeclareEachTypeInSeparateFile)]
public async Task Test_FirstClassWithFileKeyword_NoDiagnostic()
{
await VerifyNoDiagnosticAsync("""
namespace N
{
file class C1;
public class C2;
}
""");
}

[Fact, Trait(Traits.Analyzer, DiagnosticIdentifiers.DeclareEachTypeInSeparateFile)]
public async Task Test_LastClassWithFileKeyword_NoDiagnostic()
{
await VerifyNoDiagnosticAsync("""
namespace N
{
public class C1;
file class C2;
}
""");
}
}
Loading