You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What steps will reproduce the problem? Here is the situation with 2 failing tests :
public interface IConstraint<T> { }
public class Constrained<T1, T2>
where T2 : IConstraint<T1>
{
}
public interface IConstraintWithAddedArgument<T2, T1> : IConstraint<T1> { }
[Test]
public void CanResolveComponentWhenConstrainedArgumentIsGenericTypeWithMoreArgumentsThanGenericConstraint()
{
var builder = new ContainerBuilder();
builder.RegisterGeneric(typeof(Constrained<,>));
var container = builder.Build();
Assert.That(container.IsRegistered<Constrained<int, IConstraintWithAddedArgument<string, int>>>());
}
public interface IConstrainedConstraint<T>
where T : IEquatable<int> { }
public interface IConstrainedConstraintWithAddedArgument<T1, T2> : IConstrainedConstraint<T2>
where T2 : IEquatable<int>
{ }
public interface IConstrainedConstraintWithOnlyAddedArgument<T1> : IConstrainedConstraintWithAddedArgument<T1, int>
{ }
public class MultiConstrained<T1, T2>
where T1 : IEquatable<int>
where T2 : IConstrainedConstraint<T1>
{
}
[Test]
public void CanResolveComponentWhenConstraintsAreNested()
{
var builder = new ContainerBuilder();
builder.RegisterGeneric(typeof(MultiConstrained<,>));
var container = builder.Build();
Assert.That(container.IsRegistered<MultiConstrained<int, IConstrainedConstraintWithOnlyAddedArgument<string>>>());
} What is the expected output? What do you see instead? The requested services should be registred, but the following exceptions is thrown :
Autofac.Tests.Features. OpenGenerics .ComplexGenericsTests.CanResolveComponentWhenConstrainedArgumentIsGenericTypeWithMoreArgumentsThanGenericConstraint:
System.ArgumentException : The number of generic arguments provided doesn't equal the arity of the generic type definition.
Parameter name: instantiation
or
Autofac.Tests.Features. OpenGenerics .ComplexGenericsTests.CanResolveComponentWhenConstraintsAreNested:
System.ArgumentException : GenericArguments[0], 'System.String', on 'Autofac.Tests.Features. OpenGenerics .ComplexGenericsTests+IConstrainedConstraint1[T]' violates the constraint of type 'T'. ----> System.TypeLoadException : GenericArguments[0], 'System.String', on 'Autofac.Tests.Features. OpenGenerics .ComplexGenericsTests+IConstrainedConstraint1[T]' violates the constraint of type parameter 'T'.
The problem is in ParameterEqualsConstraint in TypeExtensions.cs. It's missing test cases.
Checking number of arguments and catching all others, all works correctly.
From [email protected] on April 03, 2013 22:44:08
What steps will reproduce the problem? Here is the situation with 2 failing tests :
Autofac.Tests.Features. OpenGenerics .ComplexGenericsTests.CanResolveComponentWhenConstrainedArgumentIsGenericTypeWithMoreArgumentsThanGenericConstraint:
System.ArgumentException : The number of generic arguments provided doesn't equal the arity of the generic type definition.
Parameter name: instantiation
or
Autofac.Tests.Features. OpenGenerics .ComplexGenericsTests.CanResolveComponentWhenConstraintsAreNested:
System.ArgumentException : GenericArguments[0], 'System.String', on 'Autofac.Tests.Features. OpenGenerics .ComplexGenericsTests+IConstrainedConstraint
1[T]' violates the constraint of type 'T'. ----> System.TypeLoadException : GenericArguments[0], 'System.String', on 'Autofac.Tests.Features. OpenGenerics .ComplexGenericsTests+IConstrainedConstraint
1[T]' violates the constraint of type parameter 'T'.The problem is in ParameterEqualsConstraint in TypeExtensions.cs. It's missing test cases.
Checking number of arguments and catching all others, all works correctly.
Attachment: ComplexGenericsTests.cs.patch TypeExtensions.cs.patch
Original issue: http://code.google.com/p/autofac/issues/detail?id=421
The text was updated successfully, but these errors were encountered: