@@ -69,6 +69,34 @@ private sealed class AnotherUnwrapWithAttribute(int step) :
6969 public override Type GetHandlerType ( ) => typeof ( object ) ;
7070 }
7171
72+ // Deeply inherited attributes (two levels of inheritance)
73+ private class BaseRequestHandlerAttribute ( int step ) :
74+ RequestHandlerAttribute ( step )
75+ {
76+ public override Type GetHandlerType ( ) => typeof ( object ) ;
77+ }
78+
79+ private sealed class DerivedRequestHandlerAttribute ( int step ) :
80+ BaseRequestHandlerAttribute ( step ) ;
81+
82+ private class BaseWrapWithAttribute( int step ) :
83+ WrapWithAttribute ( step )
84+ {
85+ public override Type GetHandlerType ( ) => typeof ( object ) ;
86+ }
87+
88+ private sealed class DerivedWrapWithAttribute ( int step ) :
89+ BaseWrapWithAttribute ( step ) ;
90+
91+ private class BaseUnwrapWithAttribute( int step ) :
92+ UnwrapWithAttribute ( step )
93+ {
94+ public override Type GetHandlerType ( ) => typeof ( object ) ;
95+ }
96+
97+ private sealed class DerivedUnwrapWithAttribute ( int step ) :
98+ BaseUnwrapWithAttribute ( step ) ;
99+
72100 private sealed class NoAttributesHandler
73101 {
74102 public void Handle ( ) { }
@@ -140,6 +168,25 @@ private sealed class MixedAttributesHandler
140168 public void Handle ( ) { }
141169 }
142170
171+ // Handlers with deeply inherited attributes
172+ private sealed class DeeplyInheritedRequestHandlerAttributeHandler
173+ {
174+ [ DerivedRequestHandler ( 1 ) ]
175+ public void Handle ( ) { }
176+ }
177+
178+ private sealed class DeeplyInheritedWrapWithAttributeMapper
179+ {
180+ [ DerivedWrapWith ( 1 ) ]
181+ public void MapToMessage ( ) { }
182+ }
183+
184+ private sealed class DeeplyInheritedUnwrapWithAttributeMapper
185+ {
186+ [ DerivedUnwrapWith ( 1 ) ]
187+ public void MapToRequest ( ) { }
188+ }
189+
143190 [ Fact ]
144191 public void When_method_has_no_attributes_should_return_empty ( )
145192 {
@@ -188,6 +235,18 @@ public void When_method_has_non_request_handler_attributes_should_not_return_the
188235 Assert . IsType < TestRequestHandlerAttribute > ( result [ 0 ] ) ;
189236 }
190237
238+ [ Fact ]
239+ public void When_method_has_deeply_inherited_request_handler_attribute_should_return_it ( )
240+ {
241+ var method = typeof ( DeeplyInheritedRequestHandlerAttributeHandler )
242+ . GetMethod ( nameof ( DeeplyInheritedRequestHandlerAttributeHandler . Handle ) ) ! ;
243+
244+ var result = method . GetOtherHandlersInPipeline ( ) . ToList ( ) ;
245+
246+ Assert . Single ( result ) ;
247+ Assert . IsType < DerivedRequestHandlerAttribute > ( result [ 0 ] ) ;
248+ }
249+
191250 [ Fact ]
192251 public void When_method_has_no_wrap_attributes_should_return_empty ( )
193252 {
@@ -236,6 +295,18 @@ public void When_method_has_non_wrap_attributes_should_not_return_them()
236295 Assert . IsType < TestWrapWithAttribute > ( result [ 0 ] ) ;
237296 }
238297
298+ [ Fact ]
299+ public void When_method_has_deeply_inherited_wrap_attribute_should_return_it ( )
300+ {
301+ var method = typeof ( DeeplyInheritedWrapWithAttributeMapper )
302+ . GetMethod ( nameof ( DeeplyInheritedWrapWithAttributeMapper . MapToMessage ) ) ! ;
303+
304+ var result = method . GetOtherWrapsInPipeline ( ) . ToList ( ) ;
305+
306+ Assert . Single ( result ) ;
307+ Assert . IsType < DerivedWrapWithAttribute > ( result [ 0 ] ) ;
308+ }
309+
239310 [ Fact ]
240311 public void When_method_has_no_unwrap_attributes_should_return_empty ( )
241312 {
@@ -284,6 +355,18 @@ public void When_method_has_non_unwrap_attributes_should_not_return_them()
284355 Assert . IsType < TestUnwrapWithAttribute > ( result [ 0 ] ) ;
285356 }
286357
358+ [ Fact ]
359+ public void When_method_has_deeply_inherited_unwrap_attribute_should_return_it ( )
360+ {
361+ var method = typeof ( DeeplyInheritedUnwrapWithAttributeMapper )
362+ . GetMethod ( nameof ( DeeplyInheritedUnwrapWithAttributeMapper . MapToRequest ) ) ! ;
363+
364+ var result = method . GetOtherUnwrapsInPipeline ( ) . ToList ( ) ;
365+
366+ Assert . Single ( result ) ;
367+ Assert . IsType < DerivedUnwrapWithAttribute > ( result [ 0 ] ) ;
368+ }
369+
287370 [ Fact ]
288371 public void When_method_has_no_inbox_attribute_should_return_true ( )
289372 {
0 commit comments