@@ -179,25 +179,6 @@ public DynamicMethod(string name,
179179 false ) ;
180180 }
181181
182- // helpers for initialization
183-
184- private static void CheckConsistency ( MethodAttributes attributes , CallingConventions callingConvention )
185- {
186- // only public static for method attributes
187- if ( ( attributes & ~ MethodAttributes . MemberAccessMask ) != MethodAttributes . Static )
188- throw new NotSupportedException ( SR . NotSupported_DynamicMethodFlags ) ;
189- if ( ( attributes & MethodAttributes . MemberAccessMask ) != MethodAttributes . Public )
190- throw new NotSupportedException ( SR . NotSupported_DynamicMethodFlags ) ;
191-
192- // only standard or varargs supported
193- if ( callingConvention != CallingConventions . Standard && callingConvention != CallingConventions . VarArgs )
194- throw new NotSupportedException ( SR . NotSupported_DynamicMethodFlags ) ;
195-
196- // vararg is not supported at the moment
197- if ( callingConvention == CallingConventions . VarArgs )
198- throw new NotSupportedException ( SR . NotSupported_DynamicMethodFlags ) ;
199- }
200-
201182 // We create a transparent assembly to host DynamicMethods. Since the assembly does not have any
202183 // non-public fields (or any fields at all), it is a safe anonymous assembly to host DynamicMethods
203184 private static Module GetDynamicMethodsModule ( )
@@ -242,7 +223,8 @@ private void Init(string name,
242223 {
243224 ArgumentNullException . ThrowIfNull ( name ) ;
244225
245- CheckConsistency ( attributes , callingConvention ) ;
226+ if ( attributes != ( MethodAttributes . Static | MethodAttributes . Public ) || callingConvention != CallingConventions . Standard )
227+ throw new NotSupportedException ( SR . NotSupported_DynamicMethodFlags ) ;
246228
247229 // check and store the signature
248230 if ( signature != null )
0 commit comments