Skip to content

proxying generic interface with open generic type parameters throws vague ArgumentException #39

@blairconrad

Description

@blairconrad

Found while writing characterization tests before starting on #34 proper.

Consider this test:

[Test]
public void Cannot_proxy_generic_type_with_open_generic_type_parameter()
{
    var innerType = typeof(IList<>);
    var targetType = innerType.MakeGenericType(typeof(IList<>));
    generator.CreateInterfaceProxyWithoutTarget(targetType, new IInterceptor[0]);
}

which corresponds to trying to proxy an IList<IList<>>.

It fails with

Test 'Castle.DynamicProxy.Tests.BasicInterfaceProxyTestCase.Cannot_proxy_generic_type_with_open_generic_type_parameter' failed:
    System.ArgumentException : Cannot build type parameter for custom attribute with a type that does not support the AssemblyQualifiedName property. The type instance supplied was of type 'System.RuntimeType'.

Compare this to the attempt to make proxy an IList<>, which returns an ArgumentException with the message

You can't specify a generic type definition.
Parameter name: interfaceToProxy

This is not a big deal for FakeItEasy, I don't think, and probably less of a problem overall than #34, but if there's interest, I can look into it alongside or after the fix for #34.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions