Skip to content
This repository has been archived by the owner on Dec 18, 2017. It is now read-only.

Commit

Permalink
Fixed generic assembly neutral interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
davidfowl committed Jan 28, 2015
1 parent 0c81a2d commit 1f8171a
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ public string AssemblyName
{
get
{
// TODO: Fix this to generate proper names (seems that the generic type's arity isn't captured here)
return TypeSymbol.ContainingNamespace + "." + TypeSymbol.Name;
return TypeSymbol.ContainingNamespace + "." + TypeSymbol.MetadataName;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,43 @@ public class AssemblyNeutralAttribute : System.Attribute { }
Assert.Equal("Something.IDataObjectProvider", compilations[2].AssemblyName);
}

[Fact]
public void GenericAndNonGenericWithSameName()
{
var worker = DoAssemblyNeutralCompilation(
@"
namespace Something
{
[AssemblyNeutral]
public interface ILogger { void Log(string message); }
}",
@"
namespace Something
{
[AssemblyNeutral]
public interface ILogger<T> : ILogger
{
}
}",
@"
namespace Something
{
[AssemblyNeutral]
public class AssemblyNeutralAttribute : System.Attribute { }
}
");

var diagnostics = worker.GenerateTypeCompilations();
var compilations = worker.TypeCompilations.OrderBy(c => c.AssemblyName).ToList();

Assert.Equal(0, diagnostics.Count);
Assert.Equal(3, compilations.Count());
Assert.Equal("Something.AssemblyNeutralAttribute", compilations[0].AssemblyName);
Assert.Equal("Something.ILogger", compilations[1].AssemblyName);
Assert.Equal("Something.ILogger`1", compilations[2].AssemblyName);
}

[Fact]
public void GenericAssemblyNeutralMembersWithPrimitiveTypeParams()
{
Expand Down Expand Up @@ -182,9 +219,9 @@ public class AssemblyNeutralAttribute : System.Attribute { }
Assert.Equal(0, diagnostics.Count);
Assert.Equal(4, compilations.Count());
Assert.Equal("Something.AssemblyNeutralAttribute", compilations[0].AssemblyName);
Assert.Equal("Something.IDataObject", compilations[1].AssemblyName);
Assert.Equal("Something.IDataObject`1", compilations[1].AssemblyName);
Assert.Equal("Something.IDataObjectProvider", compilations[2].AssemblyName);
Assert.Equal("Something.IDataValue", compilations[3].AssemblyName);
Assert.Equal("Something.IDataValue`1", compilations[3].AssemblyName);
}

private AssemblyNeutralWorker DoAssemblyNeutralCompilation(params string[] fileContents)
Expand Down

0 comments on commit 1f8171a

Please sign in to comment.