@@ -79,20 +79,21 @@ public ApiActionDescriptor(MethodInfo method, Type? interfaceType = default)
7979 throw new ArgumentNullException ( nameof ( method ) ) ;
8080 }
8181
82+ if ( interfaceType == null )
83+ {
84+ interfaceType = method . DeclaringType ;
85+ }
86+
8287 var methodAttributes = method . GetAttributes < IApiActionAttribute > ( false ) ;
83-
84- var interfaceAttributes = interfaceType == null
85- ? Enumerable . Empty < IApiActionAttribute > ( )
86- : interfaceType . GetAttributes < IApiActionAttribute > ( false ) ;
87-
88- var decalringAttributes = method . DeclaringType == null
88+ var interfaceAttributes = interfaceType . GetAttributes < IApiActionAttribute > ( false ) ;
89+ var declaringInterfaceAttributes = interfaceType == method . DeclaringType
8990 ? Enumerable . Empty < IApiActionAttribute > ( )
9091 : method . DeclaringType . GetAttributes < IApiActionAttribute > ( false ) ;
9192
9293 // 接口特性优先于方法所在类型的特性
9394 var actionAttributes = methodAttributes
9495 . Concat ( interfaceAttributes )
95- . Concat ( decalringAttributes )
96+ . Concat ( declaringInterfaceAttributes )
9697 . Distinct ( MultiplableComparer < IApiActionAttribute > . Default )
9798 . OrderBy ( item => item . OrderIndex )
9899 . ToReadOnlyList ( ) ;
@@ -105,7 +106,7 @@ public ApiActionDescriptor(MethodInfo method, Type? interfaceType = default)
105106 . ToReadOnlyList ( ) ;
106107
107108 this . Id = Guid . NewGuid ( ) . ToString ( ) ;
108- this . InterfaceType = interfaceType ?? ( method . DeclaringType ?? throw new ArgumentException ( nameof ( method ) ) ) ;
109+ this . InterfaceType = interfaceType ;
109110
110111 this . Member = method ;
111112 this . Name = method . Name ;
0 commit comments