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
System.NullReferenceException : Object reference not set to an instance of an object.
Stack Trace:
AttributeUtil.GetArguments(IList`1 constructorArguments) line 68
AttributeUtil.ReadAttributeValue(CustomAttributeTypedArgument argument) line 85
AttributeUtil.GetArguments(IList`1 constructorArguments, Type[]& constructorArgTypes, Object[]& constructorArgs) line 62
AttributeUtil.CreateInfo(CustomAttributeData attribute) line 35
AttributeUtil.GetNonInheritableAttributes(MemberInfo member)+MoveNext() line 135
NonInheritableAttributesContributor.Generate(ClassEmitter emitter) line 37
BaseInterfaceProxyGenerator.GenerateType(String typeName, INamingScope namingScope) line 136
<>c__DisplayClass13_0.<GetProxyType>b__0(CacheKey cacheKey) line 85
SynchronizedDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory) line 68
BaseProxyGenerator.GetProxyType() line 77
DefaultProxyBuilder.CreateInterfaceProxyTypeWithoutTarget(Type interfaceToProxy, Type[] additionalInterfacesToProxy, ProxyGenerationOptions options) line 115
ProxyGenerator.CreateInterfaceProxyTypeWithoutTarget(Type interfaceToProxy, Type[] additionalInterfacesToProxy, ProxyGenerationOptions options) line 1558
ProxyGenerator.CreateInterfaceProxyWithoutTarget(Type interfaceToProxy, Type[] additionalInterfacesToProxy, ProxyGenerationOptions options, IInterceptor[] interceptors) line 835
ProxyGenerator.CreateInterfaceProxyWithoutTarget(Type interfaceToProxy, IInterceptor[] interceptors) line 728
...
That is, the error surfaces only when the following conditions are met:
The applied custom attribute is a non-nested type.
The applied custom attribute is a non-inherited one.
The applied custom attribute's has an array parameter, for which 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:
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:
stakx
changed the title
Failure proxying type that has a non-inheritable, non-nested custom attribute type applied where null argument is given for array parameter
Failure proxying type that has a non-inheritable custom attribute type applied where null argument is given for array parameter
Dec 12, 2022
@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: