Skip to content

EnableDebugDiagnostic always throws when using InjectionMethod #180

@petedavis

Description

@petedavis

Description

Using 5.11.1

No matter what the method name is, enabling diagnostics will always throw an ambiguous name exception.

{"Method MyCompletelyUnambiguousInitializeMethod(True) is ambiguous, it could be matched with more than one method on type MyInitializableType.\r\n\r\n  Error in:  RegisterType<MyInitializableType>(Lifetime:Hierarchical, Invoke.Method('MyCompletelyUnambiguousInitializeMethod', True))\r\n"}

To Reproduce

[TestMethod]
public void SomeDescriptiveName()
{
    var container = new UnityContainer();
    container.EnableDebugDiagnostic();

    container.RegisterType<MyInitializableType>(new HierarchicalLifetimeManager(),
                new InjectionMethod(nameof(MyInitializableType.MyCompletelyUnambiguousInitializeMethod), true));

    var res = container.Resolve<MyInitializableType>();
    
    Assert.IsNotNull(res);
}

    public class MyInitializableType
    {
        public void MyCompletelyUnambiguousInitializeMethod(bool arg)
        {
            Console.WriteLine($"Initialized: {arg}");
        }
    }

Metadata

Metadata

Assignees

Labels

releaseRelease branch

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions