diff --git a/src/Compilers/CSharp/Portable/Compiler/NamespaceScopeBuilder.cs b/src/Compilers/CSharp/Portable/Compiler/NamespaceScopeBuilder.cs index 28ca968ce61811819e5ea77478b382df47100018..441c6001e29cced4aeb4e22c6c43e393586bd52a 100644 --- a/src/Compilers/CSharp/Portable/Compiler/NamespaceScopeBuilder.cs +++ b/src/Compilers/CSharp/Portable/Compiler/NamespaceScopeBuilder.cs @@ -155,14 +155,15 @@ private string GuessExternAlias(NamespaceSymbol @namespace, HashSet vali ImmutableArray aliases = reference.Properties.Aliases; if (!aliases.IsDefaultOrEmpty) { + if (aliases.Contains(MetadataReferenceProperties.GlobalAlias)) + { + // If the namespace can be referenced without alias qualification, don't use any. + return null; + } + foreach (string alias in aliases) { - if (alias == MetadataReferenceProperties.GlobalAlias) - { - // Don't bother explicitly emitting "global". - return null; - } - else if (validAliases.Contains(alias)) + if (validAliases.Contains(alias)) { // CONSIDER: Dev12 uses the one that appeared in source, whereas we use // the first one that COULD have appeared in source. (DevDiv #913022) diff --git a/src/Compilers/CSharp/Test/Emit/PDB/PDBUsingTests.cs b/src/Compilers/CSharp/Test/Emit/PDB/PDBUsingTests.cs index 8c23d20d1cbcae4cea7a697291c1b80a75730115..da12dda716735436ec8911db9d0697494205f79e 100644 --- a/src/Compilers/CSharp/Test/Emit/PDB/PDBUsingTests.cs +++ b/src/Compilers/CSharp/Test/Emit/PDB/PDBUsingTests.cs @@ -516,7 +516,7 @@ class C { void M() { } } - +