@@ -112,6 +112,53 @@ public void EnsureProxyHasAttributesOnGenericArgument()
112112 Assert . IsTrue ( nameProperty . IsDefined ( typeof ( NonInheritableAttribute ) , false ) ) ;
113113 }
114114
115+ [ Test ]
116+ public void EnsureProxyHasNestedAttributesOnClassAndMethods ( )
117+ {
118+ var instance = ( HasNestedNonInheritableAttribute ) generator . CreateClassProxy ( typeof ( HasNestedNonInheritableAttribute ) , new StandardInterceptor ( ) ) ;
119+
120+ object [ ] attributes = instance . GetType ( ) . GetCustomAttributes ( typeof ( Nested . NonInheritableAttribute ) , false ) . ToArray ( ) ;
121+ Assert . AreEqual ( 1 , attributes . Length ) ;
122+ Assert . IsInstanceOf ( typeof ( Nested . NonInheritableAttribute ) , attributes [ 0 ] ) ;
123+
124+ attributes = instance . GetType ( ) . GetMethod ( "OnMethod" ) . GetCustomAttributes ( typeof ( Nested . NonInheritableAttribute ) , false ) . ToArray ( ) ;
125+ Assert . AreEqual ( 1 , attributes . Length ) ;
126+ Assert . IsInstanceOf ( typeof ( Nested . NonInheritableAttribute ) , attributes [ 0 ] ) ;
127+ }
128+
129+ [ Test ]
130+ public void EnsureProxyHasNestedAttributesOnProperties ( )
131+ {
132+ var proxy = generator . CreateClassProxy < HasNestedNonInheritableAttribute > ( ) ;
133+ var nameProperty = proxy . GetType ( ) . GetProperty ( "OnProperty" ) ;
134+ Assert . IsTrue ( nameProperty . IsDefined ( typeof ( Nested . NonInheritableAttribute ) , false ) ) ;
135+ }
136+
137+ [ Test , Ignore ( "Not supported. Is it possible? There seems to be no API to allow that." ) ]
138+ public void EnsureProxyHasNestedAttributesOnOnReturn ( )
139+ {
140+ var proxy = generator . CreateClassProxy < HasNestedNonInheritableAttribute > ( ) ;
141+ var nameProperty = proxy . GetType ( ) . GetMethod ( "OnReturn" ) . ReturnParameter ;
142+ Assert . IsTrue ( nameProperty . IsDefined ( typeof ( Nested . NonInheritableAttribute ) , false ) ) ;
143+ }
144+
145+ [ Test ]
146+ public void EnsureProxyHasNestedAttributesOnParameter ( )
147+ {
148+ var proxy = generator . CreateClassProxy < HasNestedNonInheritableAttribute > ( ) ;
149+ ParameterInfo nameProperty = proxy . GetType ( ) . GetMethod ( "OnParameter" ) . GetParameters ( ) . Single ( ) ;
150+ Assert . IsTrue ( nameProperty . IsDefined ( typeof ( Nested . NonInheritableAttribute ) , false ) ) ;
151+ }
152+
153+ [ Test ]
154+ [ Platform ( Exclude = "Mono" , Reason = "Mono does not currently emit custom attributes on generic type parameters of methods. See https://github.com/mono/mono/issues/8512." ) ]
155+ public void EnsureProxyHasNestedAttributesOnGenericArgument ( )
156+ {
157+ var proxy = generator . CreateClassProxy < HasNestedNonInheritableAttribute > ( ) ;
158+ var nameProperty = proxy . GetType ( ) . GetMethod ( "OnGenericArgument" ) . GetGenericArguments ( ) . Single ( ) ;
159+ Assert . IsTrue ( nameProperty . IsDefined ( typeof ( Nested . NonInheritableAttribute ) , false ) ) ;
160+ }
161+
115162 [ Test ]
116163 public void Can_proxy_type_with_non_inheritable_attribute_depending_on_array_of_something_via_property ( )
117164 {
0 commit comments