|
|
|
@ -31,6 +31,9 @@ public class IocValidatorTest |
|
|
|
|
|
|
|
|
|
|
|
[UsedImplicitly] |
|
|
|
[UsedImplicitly] |
|
|
|
public interface IConstraint; |
|
|
|
public interface IConstraint; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[UsedImplicitly] |
|
|
|
|
|
|
|
public class Constraint : IConstraint; |
|
|
|
|
|
|
|
|
|
|
|
[UsedImplicitly] |
|
|
|
[UsedImplicitly] |
|
|
|
public interface IGenericTest<T> where T : IConstraint, new(); |
|
|
|
public interface IGenericTest<T> where T : IConstraint, new(); |
|
|
|
@ -44,6 +47,18 @@ public class IocValidatorTest |
|
|
|
IGenericTest<T> Create<T>() where T : IConstraint, new(); |
|
|
|
IGenericTest<T> Create<T>() where T : IConstraint, new(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[UsedImplicitly] |
|
|
|
|
|
|
|
public interface IGenericParameter; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[UsedImplicitly] |
|
|
|
|
|
|
|
public class GenericParameter : IGenericParameter |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
public GenericParameter(IGenericTest<Constraint> test) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[UsedImplicitly] |
|
|
|
[UsedImplicitly] |
|
|
|
private class TestViewModelDontIgnoreDesignTimeCtor : ITest |
|
|
|
private class TestViewModelDontIgnoreDesignTimeCtor : ITest |
|
|
|
{ |
|
|
|
{ |
|
|
|
@ -286,6 +301,17 @@ public class IocValidatorTest |
|
|
|
validator.Validate(); |
|
|
|
validator.Validate(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Test] |
|
|
|
|
|
|
|
public void TestValidateOpenGenericTypeAsParameter() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
IocContainer iocContainer = new(); |
|
|
|
|
|
|
|
iocContainer.Register(r => r.AddOpenGenerics(typeof(IGenericTest<>), typeof(GenericTest<>))); |
|
|
|
|
|
|
|
iocContainer.Register(r => r.Add<IGenericParameter, GenericParameter>()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IocValidator validator = new(iocContainer); |
|
|
|
|
|
|
|
validator.Validate(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void AssertNoMatchingConstructorFoundForType<T>(AggregateException aggregateException) |
|
|
|
private void AssertNoMatchingConstructorFoundForType<T>(AggregateException aggregateException) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Exception exception = aggregateException?.InnerExceptions[0]; |
|
|
|
Exception exception = aggregateException?.InnerExceptions[0]; |
|
|
|
|