-
Notifications
You must be signed in to change notification settings - Fork 468
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Failure proxying type that has a non-inheritable custom attribute type applied where null
argument is given for array parameter
#637
Comments
This was referenced Dec 12, 2022
If #639 gets merged, we can half the number of test cases here, because the distinction between nested / non-nested attribute types will no longer be relevant. If we additionally eliminate the distinction between inheritable / non-inheritable attributes (since DynamicProxy generally won't replicate the former), we can reduce the tests for this issue to just this: namespace Castle.DynamicProxy.Tests;
using System;
using NUnit.Framework;
[TestFixture]
public class Tests : BasePEVerifyTestCase
{
[TestCase(typeof(I3))]
[TestCase(typeof(I4))]
public void Can_proxy_type(Type interfaceTypeToProxy)
{
_ = generator.CreateInterfaceProxyWithoutTarget(interfaceTypeToProxy);
}
[NonInheritedAttributeWithOnePositionalArrayParameter(null)]
public interface I3 { }
[NonInheritedAttributeWithOnePositionalArrayParameter(new object[0])]
public interface I4 { }
[AttributeUsage(AttributeTargets.Interface, Inherited = false)]
public sealed class NonInheritedAttributeWithOnePositionalArrayParameterAttribute : Attribute
{
public NonInheritedAttributeWithOnePositionalArrayParameterAttribute(object[] arg) { }
}
} |
stakx
changed the title
Failure proxying type that has a non-inheritable, non-nested custom attribute type applied where
Failure proxying type that has a non-inheritable custom attribute type applied where Dec 12, 2022
null
argument is given for array parameternull
argument is given for array parameter
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@kimbirkelund made a bug report over at the Moq 4 repository that boils down to a problem with how DynamicProxy processes array parameters of custom attributes. Given the following test code:
The test case using
I7
fails with:That is, the error surfaces only when the following conditions are met:
null
is used as the argument value.I haven't studied this in more detail yet, but it seems something goes wrong in the "special case for handling arrays in attributes" logic here.
The text was updated successfully, but these errors were encountered: