From c239af7f3cfe1a62137a1c24a4228a69dd2df654 Mon Sep 17 00:00:00 2001 From: Ben Adams Date: Sun, 6 Jan 2019 05:25:02 +0100 Subject: Remove redundant casts in TypeBuilder.CreateTypeNoLock (#21824) --- .../src/System/Reflection/Emit/TypeBuilder.cs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/System.Private.CoreLib/src/System/Reflection/Emit/TypeBuilder.cs b/src/System.Private.CoreLib/src/System/Reflection/Emit/TypeBuilder.cs index 1c063ac0c1..7b96786a4b 100644 --- a/src/System.Private.CoreLib/src/System/Reflection/Emit/TypeBuilder.cs +++ b/src/System.Private.CoreLib/src/System/Reflection/Emit/TypeBuilder.cs @@ -2033,17 +2033,19 @@ namespace System.Reflection.Emit { // Check for global typebuilder if (((m_tdType.Token & 0x00FFFFFF) != 0) && ((tkParent & 0x00FFFFFF) != 0)) + { SetParentType(m_module.GetNativeHandle(), m_tdType.Token, tkParent); + } if (m_inst != null) - foreach (Type tb in m_inst) - if (tb is GenericTypeParameterBuilder) - ((GenericTypeParameterBuilder)tb).m_type.CreateType(); + { + foreach (GenericTypeParameterBuilder tb in m_inst) + { + tb.m_type.CreateType(); + } + } } - byte[] body; - MethodAttributes methodAttrs; - if (!m_isHiddenGlobalType) { // create a public default constructor if this class has no constructor. @@ -2060,11 +2062,10 @@ namespace System.Reflection.Emit { MethodBuilder meth = m_listMethods[i]; - if (meth.IsGenericMethodDefinition) meth.GetToken(); // Doubles as "CreateMethod" for MethodBuilder -- analogous to CreateType() - methodAttrs = meth.Attributes; + MethodAttributes methodAttrs = meth.Attributes; // Any of these flags in the implemenation flags is set, we will not attach the IL method body if (((meth.GetMethodImplementationFlags() & (MethodImplAttributes.CodeTypeMask | MethodImplAttributes.PreserveSig | MethodImplAttributes.Unmanaged)) != MethodImplAttributes.IL) || @@ -2073,8 +2074,7 @@ namespace System.Reflection.Emit continue; } - int sigLength; - byte[] localSig = meth.GetLocalSignature(out sigLength); + byte[] localSig = meth.GetLocalSignature(out int sigLength); // Check that they haven't declared an abstract method on a non-abstract class if (((methodAttrs & MethodAttributes.Abstract) != 0) && ((m_iAttr & TypeAttributes.Abstract) == 0)) @@ -2082,7 +2082,7 @@ namespace System.Reflection.Emit throw new InvalidOperationException(SR.InvalidOperation_BadTypeAttributesNotAbstract); } - body = meth.GetBody(); + byte[] body = meth.GetBody(); // If this is an abstract method or an interface, we don't need to set the IL. -- cgit v1.2.3