Skip to content

Commit

Permalink
Fix RCS1056 (#1154)
Browse files Browse the repository at this point in the history
Co-authored-by: Josef Pihrt <josef@pihrt.net>
  • Loading branch information
jamesHargreaves12 and josefpihrt authored Aug 11, 2023
1 parent e8e5d11 commit b58e8d0
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Add SECURITY.md ([#1147](https://github.com/josefpihrt/roslynator/pull/1147))

### Fixed

- Fix [RCS1056](https://github.com/JosefPihrt/Roslynator/blob/main/docs/analyzers/RCS1056.md) ([#1154](https://github.com/JosefPihrt/Roslynator/pull/1154)).

## [4.4.0] - 2023-08-01

### Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,20 @@ void M()
");
}

[Fact, Trait(Traits.Analyzer, DiagnosticIdentifiers.AvoidUsageOfUsingAliasDirective)]
public async Task Test_AliasQualifiedName()
{
await VerifyDiagnosticAndFixAsync(@"
[|using s = System;|]
class X : s::Object
{
}", @"
class X : object
{
}");
}

[Fact, Trait(Traits.Analyzer, DiagnosticIdentifiers.AvoidUsageOfUsingAliasDirective)]
public async Task Test_BlockNamespaces()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,19 @@ public Rewriter(IAliasSymbol aliasSymbol, TypeSyntax replacement, SemanticModel

public CancellationToken CancellationToken { get; }

public override SyntaxNode VisitAliasQualifiedName(AliasQualifiedNameSyntax node)
{
IAliasSymbol aliasSymbol = SemanticModel.GetAliasInfo(node.Alias, CancellationToken);
if (SymbolEqualityComparer.Default.Equals(aliasSymbol, AliasSymbol))
{
return SyntaxFactory.QualifiedName((NameSyntax)Replacement, node.Name)
.WithTriviaFrom(node)
.WithSimplifierAnnotation();
}

return base.VisitAliasQualifiedName(node);
}

public override SyntaxNode VisitIdentifierName(IdentifierNameSyntax node)
{
IAliasSymbol aliasSymbol = SemanticModel.GetAliasInfo(node, CancellationToken);
Expand Down

0 comments on commit b58e8d0

Please sign in to comment.