Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -36,6 +36,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fix refactoring ([RR0180](https://github.com/JosefPihrt/Roslynator/blob/main/docs/analyzers/RR0180.md)) ([#988](https://github.com/josefpihrt/roslynator/pull/988)).
- Recognize `ArgumentNullException.ThrowIfNull` ([RCS1227](https://github.com/JosefPihrt/Roslynator/blob/main/docs/analyzers/RCS1227.md)) ([#992](https://github.com/josefpihrt/roslynator/pull/992)).
- Detect pattern matching in [RCS1146](https://github.com/JosefPihrt/Roslynator/blob/main/docs/analyzers/RCS1146.md) ([#999](https://github.com/josefpihrt/roslynator/pull/999)).
- Handle `using` directive that starts with `global::` [RCS0015](https://github.com/JosefPihrt/Roslynator/blob/main/docs/analyzers/RCS0015.md) ([#1000](https://github.com/josefpihrt/roslynator/pull/1000)).

## [4.1.2] - 2022-10-31

Expand Down
11 changes: 8 additions & 3 deletions src/CSharp/CSharp/Extensions/SyntaxExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4211,10 +4211,15 @@ public static bool IsVoid(this TypeSyntax type)
#region UsingDirectiveSyntax
internal static IdentifierNameSyntax GetRootNamespace(this UsingDirectiveSyntax usingDirective)
{
if (usingDirective.Name is IdentifierNameSyntax identifierName)
NameSyntax name = usingDirective.Name;

if (name is AliasQualifiedNameSyntax aliasQualifiedName)
name = aliasQualifiedName.Name;

if (name is IdentifierNameSyntax identifierName)
return identifierName;

if (usingDirective.Name is QualifiedNameSyntax qualifiedName)
if (name is QualifiedNameSyntax qualifiedName)
{
NameSyntax left;

Expand All @@ -4233,7 +4238,7 @@ internal static IdentifierNameSyntax GetRootNamespace(this UsingDirectiveSyntax
}
else
{
SyntaxDebug.Fail(usingDirective.Name);
SyntaxDebug.Fail(name);
}

return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,30 @@ class C

using System.Threading;

class C
{
}
", options: Options.AddConfigOption(ConfigOptionKeys.BlankLineBetweenUsingDirectives, ConfigOptionValues.BlankLineBetweenUsingDirectives_SeparateGroups));
}

[Fact, Trait(Traits.Analyzer, DiagnosticIdentifiers.BlankLineBetweenUsingDirectives)]
public async Task Test_AddEmptyLine_GlobalAlias()
{
await VerifyDiagnosticAndFixAsync(@"
using global::System;[||]
using Microsoft.CodeAnalysis;[||]
using System.Threading;

class C
{
}
", @"
using global::System;

using Microsoft.CodeAnalysis;

using System.Threading;

class C
{
}
Expand Down