@@ -15,7 +15,7 @@ public class EmitHttpApiActivator<
1515#if NET5_0_OR_GREATER
1616 [ System . Diagnostics . CodeAnalysis . DynamicallyAccessedMembers ( System . Diagnostics . CodeAnalysis . DynamicallyAccessedMemberTypes . PublicConstructors ) ]
1717#endif
18- THttpApi > : IHttpApiActivator < THttpApi >
18+ THttpApi > : IHttpApiActivator < THttpApi >
1919 {
2020 private readonly ApiActionInvoker [ ] actionInvokers ;
2121 private readonly Func < IHttpApiInterceptor , ApiActionInvoker [ ] , THttpApi > activator ;
@@ -151,17 +151,19 @@ private static void BuildCtor(TypeBuilder builder, FieldBuilder fieldApiIntercep
151151 /// <param name="fieldActionInvokers">action执行器字段</param>
152152 private static void BuildMethods ( TypeBuilder builder , MethodInfo [ ] actionMethods , FieldBuilder fieldApiInterceptor , FieldBuilder fieldActionInvokers )
153153 {
154- const MethodAttributes implementAttribute = MethodAttributes . Public | MethodAttributes . Virtual | MethodAttributes . Final | MethodAttributes . NewSlot | MethodAttributes . HideBySig ;
154+ // private final hidebysig newslot virtual
155+ const MethodAttributes implementAttribute = MethodAttributes . Private | MethodAttributes . Final | MethodAttributes . HideBySig | MethodAttributes . NewSlot | MethodAttributes . Virtual ;
155156
156157 for ( var i = 0 ; i < actionMethods . Length ; i ++ )
157158 {
158159 var actionMethod = actionMethods [ i ] ;
159160 var actionParameters = actionMethod . GetParameters ( ) ;
160161 var parameterTypes = actionParameters . Select ( p => p . ParameterType ) . ToArray ( ) ;
162+ var actionMethodName = $ "{ actionMethod . DeclaringType ? . FullName } .{ actionMethod . Name } ";
161163
162- var iL = builder
163- . DefineMethod ( actionMethod . Name , implementAttribute , CallingConventions . Standard , actionMethod . ReturnType , parameterTypes )
164- . GetILGenerator ( ) ;
164+ var methodBuilder = builder . DefineMethod ( actionMethodName , implementAttribute , CallingConventions . Standard , actionMethod . ReturnType , parameterTypes ) ;
165+ builder . DefineMethodOverride ( methodBuilder , actionMethod ) ;
166+ var iL = methodBuilder . GetILGenerator ( ) ;
165167
166168 // this.apiInterceptor
167169 iL . Emit ( OpCodes . Ldarg_0 ) ;
0 commit comments