-
-
Notifications
You must be signed in to change notification settings - Fork 72
Closed
Labels
masterIssue has been merged into ‘master’Issue has been merged into ‘master’releaseRelease branchRelease branch
Milestone
Description
Description
When using Diagnostic container extension resolving class that requires IEnumerable of dependencies registered by name failes with AccessViolationException.
Observed in Unity 5.11.1
To Reproduce
public class ResolutionTests
{
[Fact]
public void Resolve_Multiple_With_Diagnostics_Enabled()
{
var container = new UnityContainer();
container.AddNewExtension<Diagnostic>();
container.RegisterType<IInterface, Implementation1>("strategy1");
container.RegisterType<IInterface, Implementation2>("strategy2");
container.RegisterType<IConsumer, Consumer>();
container.Resolve<IConsumer>().Consume();
}
}
public interface IInterface
{
}
public class Implementation2 : IInterface
{
}
public class Implementation1: IInterface
{
}
public interface IConsumer
{
void Consume();
}
public class Consumer : IConsumer
{
private readonly IEnumerable<IInterface> _interfaces;
public Consumer(IEnumerable<IInterface> interfaces)
{
_interfaces = interfaces;
}
public void Consume()
{
_interfaces.ToArray();
}
}Additional context
Depending on container configuration other possible exceptions can occur: NullReferenceException, StackOverflowException has also been observed.
karelkral, anlau and mark-monteiro
Metadata
Metadata
Assignees
Labels
masterIssue has been merged into ‘master’Issue has been merged into ‘master’releaseRelease branchRelease branch