diff --git a/src/libraries/System.Private.CoreLib/src/System/Reflection/Emit/DynamicMethod.cs b/src/libraries/System.Private.CoreLib/src/System/Reflection/Emit/DynamicMethod.cs index c5b926c4b21f3..ea697790082f8 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Reflection/Emit/DynamicMethod.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Reflection/Emit/DynamicMethod.cs @@ -179,25 +179,6 @@ public DynamicMethod(string name, false); } - // helpers for initialization - - private static void CheckConsistency(MethodAttributes attributes, CallingConventions callingConvention) - { - // only public static for method attributes - if ((attributes & ~MethodAttributes.MemberAccessMask) != MethodAttributes.Static) - throw new NotSupportedException(SR.NotSupported_DynamicMethodFlags); - if ((attributes & MethodAttributes.MemberAccessMask) != MethodAttributes.Public) - throw new NotSupportedException(SR.NotSupported_DynamicMethodFlags); - - // only standard or varargs supported - if (callingConvention != CallingConventions.Standard && callingConvention != CallingConventions.VarArgs) - throw new NotSupportedException(SR.NotSupported_DynamicMethodFlags); - - // vararg is not supported at the moment - if (callingConvention == CallingConventions.VarArgs) - throw new NotSupportedException(SR.NotSupported_DynamicMethodFlags); - } - // We create a transparent assembly to host DynamicMethods. Since the assembly does not have any // non-public fields (or any fields at all), it is a safe anonymous assembly to host DynamicMethods private static Module GetDynamicMethodsModule() @@ -242,7 +223,8 @@ private void Init(string name, { ArgumentNullException.ThrowIfNull(name); - CheckConsistency(attributes, callingConvention); + if (attributes != (MethodAttributes.Static | MethodAttributes.Public) || callingConvention != CallingConventions.Standard) + throw new NotSupportedException(SR.NotSupported_DynamicMethodFlags); // check and store the signature if (signature != null)