Skip to content

Instantly share code, notes, and snippets.

@shiftkey
Created October 28, 2011 03:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shiftkey/1321588 to your computer and use it in GitHub Desktop.
Save shiftkey/1321588 to your computer and use it in GitHub Desktop.
Repro - Open Generics Not Supported in MEF v2 Preview 4?
using System.ComponentModel.Composition.Hosting;
using System.ComponentModel.Composition.Registration;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace System.ComponentModel.Composition
{
[TestClass]
public class RegistrationBuilderTestBF
{
public interface IRepository<out T> {
T Get();
}
public class SomeModel { }
public class Repository<T> : IRepository<T> {
public T Get()
{
return default(T);
}
}
public class SomeController
{
public SomeController(IRepository<SomeModel> someModel) {
}
}
[TestMethod]
public void RegistrationBuilder_WithOpenGeneric_ShouldCreateType()
{
var rb = new RegistrationBuilder();
rb.ForType<SomeController>().Export();
rb.ForTypesDerivedFrom(typeof(IRepository<>)).Export();
var newCatalog = new AssemblyCatalog(typeof(RegistrationBuilderTestBF).Assembly, rb);
var provider = new CatalogExportProvider(newCatalog);
Assert.IsNotNull(provider.GetExport<SomeController>());
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment