Skip to content

Commit

Permalink
Fix SA1135 getting reported for top-level namespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
sharwell committed Feb 6, 2019
1 parent b40215f commit feddb3e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -307,5 +307,17 @@ namespace Test

await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false);
}

[Fact]
public async Task TestFullyQualifiedTopLevelNamespaceAsync()
{
var testCode = @"
namespace MyNamespace {
using System;
}
";

await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,14 @@ private static void AppendQualifiedSymbolName(StringBuilder builder, ISymbol sym
break;

default:
builder
.Append(symbol.ContainingNamespace.ToDisplayString())
.Append(".")
.Append(symbol.Name);
if (!symbol.ContainingNamespace.IsGlobalNamespace)
{
builder
.Append(symbol.ContainingNamespace.ToDisplayString())
.Append(".");
}

builder.Append(symbol.Name);
break;
}
}
Expand Down

0 comments on commit feddb3e

Please sign in to comment.