Concrete types nested more than one level deep do not auto-resolve.
This one took me a bit to figure out what was happening and was due to an extra level of nesting I hadn't intended. I thought I should create an issue to at least document the case, though a workaround exists (don't nest this deep).
Repro:
using Lamar;
namespace Throwaway;
public class LamarConcreteTypeResolutionAssumptions
{
public class Nested1
{
public class Nested2
{
}
}
// passes
[Fact]
public void resolves_nested1()
{
var container = new Container( _ => { } );
var actual = container.GetInstance<Nested1>();
Assert.NotNull( actual );
}
// fails
[Fact]
public void resolves_nested2()
{
var container = new Container( _ => { } );
var actual = container.GetInstance<Nested1.Nested2>();
/*
Lamar.IoC.LamarMissingRegistrationException
No service registrations exist or can be derived for Throwaway.LamarConcreteTypeResolutionAssumptions.Nested1.Nested2
at Lamar.IoC.Scope.GetInstance(Type serviceType)
at Lamar.IoC.Scope.GetInstance[T]()
at Throwaway.LamarConcreteTypeResolutionAssumptions.resolves_nested2()
*/
Assert.NotNull( actual );
}
}
Concrete types nested more than one level deep do not auto-resolve.
This one took me a bit to figure out what was happening and was due to an extra level of nesting I hadn't intended. I thought I should create an issue to at least document the case, though a workaround exists (don't nest this deep).
Repro: