-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Closed
Labels
area-System.Compositionbughelp wanted[up-for-grabs] Good issue for external contributors[up-for-grabs] Good issue for external contributors
Milestone
Description
See this test:
[Test]
public void SystemComposition_generic_export_with_ctor_dependency()
{
var conventions = new ConventionBuilder();
conventions
.ForType<Dependency>()
.Export<Dependency>();
conventions
.ForType(typeof(MoreOpenWithDependency<>))
.ExportInterfaces(
i => i.GetGenericTypeDefinition() == typeof(IOpen<>),
(type, builder) => builder.AsContractType(typeof(IOpen<>)))
.SelectConstructor(ctors => ctors.First());
var configuration = new ContainerConfiguration()
.WithParts(new[] { typeof(IOpen<>), typeof(MoreOpenWithDependency<>) })
.WithAssembly(this.GetType().Assembly, conventions);
using (var container = configuration.CreateContainer())
{
var myService = container.GetExport(typeof(IOpen<object>));
}
}
public class MoreOpenWithDependency<T> : IOpen<T>
{
// [ImportingConstructor]
public MoreOpenWithDependency(Dependency dep) { }
}
public class Dependency { }When explicitly adding the [ImportingConstructor] attribute, everything works fine, but without it, even if indicating the constructor in the conventions, it throws an:
System.Composition.Hosting.CompositionFailedException : No importing constructor was found on type 'Kephas.Tests.Composition.Mef.MefAmbientServicesBuilderExtensionsTest+MoreOpenWithDependency`1
Due to an automatic parts registration using implicit conventions it is not possible to add the [ImportingConstructor] attribute.
Metadata
Metadata
Assignees
Labels
area-System.Compositionbughelp wanted[up-for-grabs] Good issue for external contributors[up-for-grabs] Good issue for external contributors