Skip to content

Commit

Permalink
EE: Fix portable imports grouping (dotnet#21863)
Browse files Browse the repository at this point in the history
  • Loading branch information
tmat authored Sep 7, 2017
1 parent bd0d7b7 commit ca3f2f0
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,42 @@ void M()
});
}

[Fact, WorkItem(21386, "https://github.com/dotnet/roslyn/issues/21386")]
public void Gaps()
{
var source = @"
using System;
namespace N1
{
namespace N2
{
using System.Collections;
namespace N3
{
class C { void M() { } }
}
}
}
";
var comp = CreateStandardCompilation(source);
WithRuntimeInstance(comp, runtime =>
{
GetMethodDebugInfo(runtime, "N1.N2.N3.C.M").ImportRecordGroups.Verify(@"
{
}
{
Namespace: string='System.Collections'
}
{
}
{
Namespace: string='System'
}");
});
}

[Fact]
public void NestedScopes()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

using System;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Linq;
using System.Reflection.Metadata;
using System.Reflection.Metadata.Ecma335;
Expand Down Expand Up @@ -258,13 +259,20 @@ private static void PopulateImports(
// ignore invalid imports
}

// VB always expects two import groups (even if they are empty).
// TODO: consider doing this for C# as well and handle empty groups in the binder.
if (isVisualBasicMethod || importGroupBuilder.Count > 0)
// Portable PDBs represent project-level scope as the root of the chain of scopes.
// This scope might contain aliases for assembly references, but is not considered
// to be part of imports groups.
if (isVisualBasicMethod || !importScope.Parent.IsNil)
{
importGroupsBuilder.Add(importGroupBuilder.ToImmutable());
importGroupBuilder.Clear();
}
else
{
// C# currently doesn't support global imports in PDBs
// https://github.com/dotnet/roslyn/issues/21862
Debug.Assert(importGroupBuilder.Count == 0);
}

handle = importScope.Parent;
}
Expand Down

0 comments on commit ca3f2f0

Please sign in to comment.