Skip to content

Commit

Permalink
Merge pull request #2874 from sharwell/fix-global-namespace
Browse files Browse the repository at this point in the history
Fix SA1135 getting reported for top-level namespaces
  • Loading branch information
sharwell authored Feb 6, 2019
2 parents b40215f + feddb3e commit cef4b3a
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 cef4b3a

Please sign in to comment.