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
#637 incidentally revealed that custom attributes do not get replicated if their custom attribute type is a nested type. Given these two tests:
namespace Castle.DynamicProxy.Tests;using System;using NUnit.Framework;[TestFixture]publicclassTests:BasePEVerifyTestCase{[Test]publicvoidNested_non_inherited_attribute_is_replicated(){varproxy= generator.CreateInterfaceProxyWithoutTarget<IHasNestedNonInheritedAttribute>();varproxyType= proxy.GetType();varcustomAttributesOnProxyType= proxyType.GetCustomAttributes(typeof(NestedNonInheritedAttribute), inherit:false);
CollectionAssert.IsNotEmpty(customAttributesOnProxyType);}[Test]publicvoidNon_nested_non_inherited_attribute_is_replicated(){varproxy= generator.CreateInterfaceProxyWithoutTarget<IHasNonNestedNonInheritedAttribute>();varproxyType= proxy.GetType();varcustomAttributesOnProxyType= proxyType.GetCustomAttributes(typeof(NonNestedNonInheritedAttribute), inherit:false);
CollectionAssert.IsNotEmpty(customAttributesOnProxyType);}[NestedNonInherited]publicinterfaceIHasNestedNonInheritedAttribute{}[NonNestedNonInherited]publicinterfaceIHasNonNestedNonInheritedAttribute{}[AttributeUsage(AttributeTargets.Interface, Inherited =false)]publicsealedclassNestedNonInheritedAttribute:Attribute{}}// NOTE: it is relevant to the above tests that the following type not be a nested type![AttributeUsage(AttributeTargets.Interface, Inherited =false)]publicsealedclassNonNestedNonInheritedAttribute:Attribute{}
Only of of the tests fails, more specifically, Nested_non_inherited_attribute_is_replicated.
#637 incidentally revealed that custom attributes do not get replicated if their custom attribute type is a nested type. Given these two tests:
Only of of the tests fails, more specifically,
Nested_non_inherited_attribute_is_replicated
.The problem is likely caused here:
Core/src/Castle.Core/DynamicProxy/Internal/AttributeUtil.cs
Line 188 in c6d7a16
We should probably augment this test with an additional condition
... && attribute.IsNestedPublic == false
.... or was there a specific reason against replicating nested custom attribute types?
The text was updated successfully, but these errors were encountered: