From 7c13b0b87757c077a75d3014dc4b13a32dcbe7ba Mon Sep 17 00:00:00 2001 From: gpetrou Date: Sat, 28 Sep 2019 19:15:10 +0100 Subject: [PATCH] Remove the usage of some ReflectionUtils methods --- .../Compiler/UncollectableCompilationMode.cs | 8 +++--- .../Runtime/Binding/BindingHelpers.cs | 2 +- .../Runtime/Binding/ConversionBinder.cs | 6 ++-- .../Runtime/Binding/MetaBuiltinFunction.cs | 18 ++++++------ .../Runtime/Binding/MetaPythonType.Calls.cs | 4 +-- .../Runtime/Binding/MetaUserObject.Members.cs | 2 +- .../Runtime/Binding/MetaUserObject.cs | 2 +- .../Binding/PythonBinaryOperationBinder.cs | 8 +++--- .../Runtime/Binding/PythonBinder.cs | 10 +++---- .../Runtime/Binding/PythonExtensionBinder.cs | 2 +- .../Runtime/Binding/PythonGetMemberBinder.cs | 4 +-- .../Runtime/Binding/PythonOverloadResolver.cs | 4 +-- .../Binding/PythonProtocol.Operations.cs | 2 +- Src/IronPython/Runtime/ClrModule.cs | 4 +-- Src/IronPython/Runtime/Converter.cs | 16 +++++------ .../Runtime/Operations/InstanceOps.cs | 8 +++--- .../Runtime/Operations/ObjectOps.cs | 4 +-- .../Runtime/Operations/PythonOps.cs | 4 +-- .../Runtime/Operations/PythonTypeOps.cs | 12 ++++---- .../Runtime/PythonDocumentationProvider.cs | 4 +-- .../Runtime/Types/BuiltinFunction.cs | 2 +- Src/IronPython/Runtime/Types/NewTypeInfo.cs | 4 +-- Src/IronPython/Runtime/Types/NewTypeMaker.cs | 22 +++++++-------- Src/IronPython/Runtime/Types/PythonType.cs | 28 +++++++++---------- .../Runtime/Types/PythonTypeInfo.cs | 28 +++++++++---------- .../Runtime/Types/ReflectedField.cs | 4 +-- 26 files changed, 106 insertions(+), 106 deletions(-) diff --git a/Src/IronPython/Compiler/UncollectableCompilationMode.cs b/Src/IronPython/Compiler/UncollectableCompilationMode.cs index ef2207159..26d5d22a4 100644 --- a/Src/IronPython/Compiler/UncollectableCompilationMode.cs +++ b/Src/IronPython/Compiler/UncollectableCompilationMode.cs @@ -55,7 +55,7 @@ public override LightLambdaExpression ReduceAst(PythonAst instance, string name) // going to a call site which can be strongly typed. We need to coordinate // more with whoever consumes the values. if (CompilerHelpers.CanEmitConstant(value, CompilerHelpers.GetType(value)) && - !CompilerHelpers.GetType(value).IsValueType()) { + !CompilerHelpers.GetType(value).IsValueType) { return Utils.Constant(value); } @@ -71,7 +71,7 @@ public override LightLambdaExpression ReduceAst(PythonAst instance, string name) } public override Type GetConstantType(object value) { - if (value == null || value.GetType().IsValueType()) { + if (value == null || value.GetType().IsValueType) { return typeof(object); } @@ -429,7 +429,7 @@ public override int FieldCount { public override Type/*!*/ Type { get { Type returnType = _value.GetType(); - if (!returnType.IsValueType()) { + if (!returnType.IsValueType) { return returnType; } else { return typeof(object); @@ -444,7 +444,7 @@ public object Value { } public override MSAst.Expression Reduce() { - if (_value.GetType().IsValueType()) { + if (_value.GetType().IsValueType) { return base.Reduce(); } else { return MSAst.Expression.Convert(base.Reduce(), _value.GetType()); diff --git a/Src/IronPython/Runtime/Binding/BindingHelpers.cs b/Src/IronPython/Runtime/Binding/BindingHelpers.cs index 6eec16738..2f1a8d418 100644 --- a/Src/IronPython/Runtime/Binding/BindingHelpers.cs +++ b/Src/IronPython/Runtime/Binding/BindingHelpers.cs @@ -388,7 +388,7 @@ internal static bool IsDataMember(object p) { } internal static DynamicMetaObject AddPythonBoxing(DynamicMetaObject res) { - if (res.Expression.Type.IsValueType()) { + if (res.Expression.Type.IsValueType) { // Use Python boxing rules if we're return a value type res = new DynamicMetaObject( AddPythonBoxing(res.Expression), diff --git a/Src/IronPython/Runtime/Binding/ConversionBinder.cs b/Src/IronPython/Runtime/Binding/ConversionBinder.cs index 53325356b..6e48eaf13 100644 --- a/Src/IronPython/Runtime/Binding/ConversionBinder.cs +++ b/Src/IronPython/Runtime/Binding/ConversionBinder.cs @@ -95,7 +95,7 @@ public override Type ReturnType { return (_kind == ConversionResultKind.ExplicitCast || _kind == ConversionResultKind.ImplicitCast) ? Type : - _type.IsValueType() ? + _type.IsValueType ? typeof(object) : _type; } @@ -203,7 +203,7 @@ internal DynamicMetaObject FallbackConvert(Type returnType, DynamicMetaObject se break; } - if (type.IsEnum() && Enum.GetUnderlyingType(type) == self.GetLimitType()) { + if (type.IsEnum && Enum.GetUnderlyingType(type) == self.GetLimitType()) { // numeric type to enum, this is ok if the value is zero object value = Activator.CreateInstance(type); @@ -677,7 +677,7 @@ private DynamicMetaObject TryToCharConversion(DynamicMetaObject/*!*/ self) { } else if (typeof(IStrongBox).IsAssignableFrom(self.GetLimitType())) { // Explictly block conversion of References to bool res = MakeStrongBoxToBoolConversionError(self); - } else if (self.GetLimitType().IsPrimitive() || self.GetLimitType().IsEnum()) { + } else if (self.GetLimitType().IsPrimitive || self.GetLimitType().IsEnum) { // optimization - rather than doing a method call for primitives and enums generate // the comparison to zero directly. res = MakePrimitiveToBoolComparison(self); diff --git a/Src/IronPython/Runtime/Binding/MetaBuiltinFunction.cs b/Src/IronPython/Runtime/Binding/MetaBuiltinFunction.cs index 1de325071..fb0c4846d 100644 --- a/Src/IronPython/Runtime/Binding/MetaBuiltinFunction.cs +++ b/Src/IronPython/Runtime/Binding/MetaBuiltinFunction.cs @@ -214,7 +214,7 @@ out target if (CompilerHelpers.IsStrongBox(instanceValue)) { instance = ReadStrongBoxValue(instance); instanceValue = ((IStrongBox)instanceValue).Value; - } else if (!testType.IsEnum()) { + } else if (!testType.IsEnum) { // We need to deal w/ wierd types like MarshalByRefObject. // We could have an MBRO whos DeclaringType is completely different. // Therefore we special case it here and cast to the declaring type @@ -222,15 +222,15 @@ out target Type selfType = CompilerHelpers.GetType(Value.BindingSelf); selfType = CompilerHelpers.GetVisibleType(selfType); - if (selfType == typeof(object) && Value.DeclaringType.IsInterface()) { + if (selfType == typeof(object) && Value.DeclaringType.IsInterface) { selfType = Value.DeclaringType; Type genericTypeDefinition = null; // the behavior is different on Mono, it sets FullName for the DeclaringType - if (Value.DeclaringType.IsGenericType() && + if (Value.DeclaringType.IsGenericType && (ClrModule.IsMono || Value.DeclaringType.FullName == null) && - Value.DeclaringType.ContainsGenericParameters() && - !Value.DeclaringType.IsGenericTypeDefinition()) { + Value.DeclaringType.ContainsGenericParameters && + !Value.DeclaringType.IsGenericTypeDefinition) { // from MSDN: If the current type contains generic type parameters that have not been replaced by // specific types (that is, the ContainsGenericParameters property returns true), but the type // is not a generic type definition (that is, the IsGenericTypeDefinition property returns false), @@ -249,7 +249,7 @@ out target if (hasOnlyGenerics) { genericTypeDefinition = Value.DeclaringType.GetGenericTypeDefinition(); } - } else if (Value.DeclaringType.IsGenericTypeDefinition()) { + } else if (Value.DeclaringType.IsGenericTypeDefinition) { genericTypeDefinition = Value.DeclaringType; } @@ -259,7 +259,7 @@ out target // the concrete selfType. var interfaces = CompilerHelpers.GetType(Value.BindingSelf).GetInterfaces(); foreach (var iface in interfaces) { - if (iface.IsGenericType() && iface.GetGenericTypeDefinition() == genericTypeDefinition) { + if (iface.IsGenericType && iface.GetGenericTypeDefinition() == genericTypeDefinition) { selfType = iface; break; } @@ -267,11 +267,11 @@ out target } } - if (Value.DeclaringType.IsInterface() && selfType.IsValueType()) { + if (Value.DeclaringType.IsInterface && selfType.IsValueType) { // explicit interface implementation dispatch on a value type, don't // unbox the value type before the dispatch. instance = AstUtils.Convert(instance, Value.DeclaringType); - } else if (selfType.IsValueType()) { + } else if (selfType.IsValueType) { // We might be calling a a mutating method (like // Rectangle.Intersect). If so, we want it to mutate // the boxed value directly diff --git a/Src/IronPython/Runtime/Binding/MetaPythonType.Calls.cs b/Src/IronPython/Runtime/Binding/MetaPythonType.Calls.cs index 099cc135f..b4042644b 100644 --- a/Src/IronPython/Runtime/Binding/MetaPythonType.Calls.cs +++ b/Src/IronPython/Runtime/Binding/MetaPythonType.Calls.cs @@ -109,7 +109,7 @@ internal partial class MetaPythonType : MetaPythonObject, IPythonInvokable { ); } else { string msg; - if (Value.UnderlyingSystemType.IsAbstract()) { + if (Value.UnderlyingSystemType.IsAbstract) { msg = String.Format("Cannot create instances of {0} because it is abstract", Value.Name); }else{ msg = String.Format("Cannot create instances of {0} because it has no public constructors", Value.Name); @@ -146,7 +146,7 @@ internal partial class MetaPythonType : MetaPythonObject, IPythonInvokable { if (TooManyArgsForDefaultNew(call, args)) { return MakeIncorrectArgumentsForCallError(call, ai, valInfo); - } else if (Value.UnderlyingSystemType.IsGenericTypeDefinition()) { + } else if (Value.UnderlyingSystemType.IsGenericTypeDefinition) { return MakeGenericTypeDefinitionError(call, ai, valInfo); } else if (Value.HasAbstractMethods(PythonContext.GetPythonContext(call).SharedContext)) { return MakeAbstractInstantiationError(call, ai, valInfo); diff --git a/Src/IronPython/Runtime/Binding/MetaUserObject.Members.cs b/Src/IronPython/Runtime/Binding/MetaUserObject.Members.cs index e318f4981..4dad9aeec 100644 --- a/Src/IronPython/Runtime/Binding/MetaUserObject.Members.cs +++ b/Src/IronPython/Runtime/Binding/MetaUserObject.Members.cs @@ -969,7 +969,7 @@ protected override DynamicMetaObject Finish() { _target.Restrict(Instance.GetType()).Restrictions.Merge(_result.Restrictions) ); - Debug.Assert(!_result.Expression.Type.IsValueType()); + Debug.Assert(!_result.Expression.Type.IsValueType); return BindingHelpers.AddDynamicTestAndDefer( _info.Action, diff --git a/Src/IronPython/Runtime/Binding/MetaUserObject.cs b/Src/IronPython/Runtime/Binding/MetaUserObject.cs index 1dd87ca5f..0c045a311 100644 --- a/Src/IronPython/Runtime/Binding/MetaUserObject.cs +++ b/Src/IronPython/Runtime/Binding/MetaUserObject.cs @@ -171,7 +171,7 @@ private DynamicMetaObject InvokeFallback(DynamicMetaObjectBinder action, Express #region Conversions private DynamicMetaObject TryPythonConversion(DynamicMetaObjectBinder conversion, Type type) { - if (!type.IsEnum()) { + if (!type.IsEnum) { switch (type.GetTypeCode()) { case TypeCode.Object: if (type == typeof(Complex)) { diff --git a/Src/IronPython/Runtime/Binding/PythonBinaryOperationBinder.cs b/Src/IronPython/Runtime/Binding/PythonBinaryOperationBinder.cs index 638fbf62d..aac30ff27 100644 --- a/Src/IronPython/Runtime/Binding/PythonBinaryOperationBinder.cs +++ b/Src/IronPython/Runtime/Binding/PythonBinaryOperationBinder.cs @@ -272,7 +272,7 @@ private T BindAdd(CallSite site, object[] args) where T : class { return (T)(object)new Func(TupleAdd); } - } else if (!t.IsEnum()) { + } else if (!t.IsEnum) { switch (t.GetTypeCode()) { case TypeCode.Double: if(typeof(T) == typeof(Func)) { @@ -295,7 +295,7 @@ private T BindAdd(CallSite site, object[] args) where T : class { private T BindSubtract(CallSite site, object[] args) where T : class { Type t = args[0].GetType(); - if (!t.IsEnum()) { + if (!t.IsEnum) { switch (t.GetTypeCode()) { case TypeCode.Double: if (typeof(T) == typeof(Func)) { @@ -326,7 +326,7 @@ private T BindEqual(CallSite site, object[] args) where T : class { } else if (typeof(T) == typeof(Func)) { return (T)(object)new Func(StringEqual); } - } else if (!t.IsEnum() && typeof(T) == typeof(Func)) { + } else if (!t.IsEnum && typeof(T) == typeof(Func)) { switch (t.GetTypeCode()) { case TypeCode.Double: return (T)(object)new Func(DoubleEqual); @@ -347,7 +347,7 @@ private T BindNotEqual(CallSite site, object[] args) where T : class { } else if (typeof(T) == typeof(Func)) { return (T)(object)new Func(StringNotEqual); } - } else if (!t.IsEnum() && typeof(T) == typeof(Func)) { + } else if (!t.IsEnum && typeof(T) == typeof(Func)) { switch (t.GetTypeCode()) { case TypeCode.Double: return (T)(object)new Func(DoubleNotEqual); diff --git a/Src/IronPython/Runtime/Binding/PythonBinder.cs b/Src/IronPython/Runtime/Binding/PythonBinder.cs index 19aaa2857..0bd06f4d0 100644 --- a/Src/IronPython/Runtime/Binding/PythonBinder.cs +++ b/Src/IronPython/Runtime/Binding/PythonBinder.cs @@ -68,7 +68,7 @@ public PythonBinder(PythonBinder binder) { Type exprType = expr.Type; if (toType == typeof(object)) { - if (exprType.IsValueType()) { + if (exprType.IsValueType) { return AstUtils.Convert(expr, toType); } else { return expr; @@ -99,8 +99,8 @@ public PythonBinder(PythonBinder binder) { } internal static MethodInfo GetGenericConvertMethod(Type toType) { - if (toType.IsValueType()) { - if (toType.IsGenericType() && toType.GetGenericTypeDefinition() == typeof(Nullable<>)) { + if (toType.IsValueType) { + if (toType.IsGenericType && toType.GetGenericTypeDefinition() == typeof(Nullable<>)) { return typeof(Converter).GetMethod(nameof(Converter.ConvertToNullableType)); } else { return typeof(Converter).GetMethod(nameof(Converter.ConvertToValueType)); @@ -416,7 +416,7 @@ private void AddExtensionTypes(Type t, List list) { } } - if (t.IsGenericType()) { + if (t.IsGenericType) { // search for generic extensions, e.g. ListOfTOps for List, // we then make a new generic type out of the extension type. Type typeDef = t.GetGenericTypeDefinition(); @@ -822,7 +822,7 @@ private void DomainManager_AssemblyLoaded(object sender, AssemblyLoadedEventArgs if (attrs.Any()) { lock (_dlrExtensionTypes) { foreach (ExtensionTypeAttribute attr in attrs) { - if (attr.Extends.IsInterface()) { + if (attr.Extends.IsInterface) { _registeredInterfaceExtensions = true; } diff --git a/Src/IronPython/Runtime/Binding/PythonExtensionBinder.cs b/Src/IronPython/Runtime/Binding/PythonExtensionBinder.cs index bc7f0de69..73b21e5d4 100644 --- a/Src/IronPython/Runtime/Binding/PythonExtensionBinder.cs +++ b/Src/IronPython/Runtime/Binding/PythonExtensionBinder.cs @@ -47,7 +47,7 @@ public override MemberGroup GetMember(MemberRequestKind actionKind, Type type, s internal static bool IsApplicableExtensionMethod(Type instanceType, Type extensionMethodThisType) { - if (extensionMethodThisType.ContainsGenericParameters()) { + if (extensionMethodThisType.ContainsGenericParameters) { Dictionary binding = new Dictionary(); if (extensionMethodThisType.IsArray) { diff --git a/Src/IronPython/Runtime/Binding/PythonGetMemberBinder.cs b/Src/IronPython/Runtime/Binding/PythonGetMemberBinder.cs index d54f08f07..9fae8cbdb 100644 --- a/Src/IronPython/Runtime/Binding/PythonGetMemberBinder.cs +++ b/Src/IronPython/Runtime/Binding/PythonGetMemberBinder.cs @@ -331,7 +331,7 @@ private Func MakeGetMemberTarget args public override bool CanConvertFrom(Type fromType, DynamicMetaObject fromArg, ParameterWrapper toParameter, NarrowingLevel level) { if ((fromType == typeof(PythonList) || fromType.IsSubclassOf(typeof(PythonList)))) { - if (toParameter.Type.IsGenericType() && + if (toParameter.Type.IsGenericType && toParameter.Type.GetGenericTypeDefinition() == typeof(IList<>) && toParameter.ParameterInfo.IsDefined(typeof(BytesConversionAttribute), false)) { return false; @@ -127,7 +127,7 @@ public override Type GetGenericInferenceType(DynamicMetaObject dynamicObject) { Type res = PythonTypeOps.GetFinalSystemType(dynamicObject.LimitType); if (res == typeof(ExtensibleString) || res == typeof(ExtensibleComplex) || - (res.IsGenericType() && res.GetGenericTypeDefinition() == typeof(Extensible<>))) { + (res.IsGenericType && res.GetGenericTypeDefinition() == typeof(Extensible<>))) { return typeof(object); } diff --git a/Src/IronPython/Runtime/Binding/PythonProtocol.Operations.cs b/Src/IronPython/Runtime/Binding/PythonProtocol.Operations.cs index bd9443ff7..488f86089 100644 --- a/Src/IronPython/Runtime/Binding/PythonProtocol.Operations.cs +++ b/Src/IronPython/Runtime/Binding/PythonProtocol.Operations.cs @@ -1134,7 +1134,7 @@ private static void MakeSlotCallWorker(PythonContext/*!*/ state, PythonTypeSlot/ AstUtils.Constant(0), BindingRestrictions.Combine(types) ); - } else if (yType.UnderlyingSystemType.IsPrimitive() || yType.UnderlyingSystemType == typeof(BigInteger)) { + } else if (yType.UnderlyingSystemType.IsPrimitive || yType.UnderlyingSystemType == typeof(BigInteger)) { return new DynamicMetaObject( AstUtils.Constant(-1), BindingRestrictions.Combine(types) diff --git a/Src/IronPython/Runtime/ClrModule.cs b/Src/IronPython/Runtime/ClrModule.cs index e00b7c3c9..27e47c492 100644 --- a/Src/IronPython/Runtime/ClrModule.cs +++ b/Src/IronPython/Runtime/ClrModule.cs @@ -977,11 +977,11 @@ public static PythonTuple GetSubclassedTypes() { Type clrBaseType = info.BaseType; Type tempType = clrBaseType; while (tempType != null) { - if (tempType.IsGenericType() && tempType.GetGenericTypeDefinition() == typeof(Extensible<>)) { + if (tempType.IsGenericType && tempType.GetGenericTypeDefinition() == typeof(Extensible<>)) { clrBaseType = tempType.GetGenericArguments()[0]; break; } - tempType = tempType.GetBaseType(); + tempType = tempType.BaseType; } PythonType baseType = DynamicHelpers.GetPythonTypeFromType(clrBaseType); diff --git a/Src/IronPython/Runtime/Converter.cs b/Src/IronPython/Runtime/Converter.cs index d55a53a20..ed6cf91f6 100644 --- a/Src/IronPython/Runtime/Converter.cs +++ b/Src/IronPython/Runtime/Converter.cs @@ -279,8 +279,8 @@ internal static object Convert(object value, Type to) { } object res = site.Target(site, value); - if (to.IsValueType() && res == null && - (!to.IsGenericType() || to.GetGenericTypeDefinition() != typeof(Nullable<>))) { + if (to.IsValueType && res == null && + (!to.IsGenericType || to.GetGenericTypeDefinition() != typeof(Nullable<>))) { throw MakeTypeError(to, value); } return res; @@ -556,7 +556,7 @@ private static TypeConverter GetTypeConverter(TypeConverterAttribute tca) { #endif private static bool HasImplicitNumericConversion(Type fromType, Type toType) { - if (fromType.IsEnum()) return false; + if (fromType.IsEnum) return false; if (fromType == typeof(BigInteger)) { if (toType == typeof(double)) return true; @@ -795,7 +795,7 @@ private static bool HasNarrowingConversion(Type fromType, Type toType, Narrowing if (toType == typeof(IEnumerator)) { if (IsPythonType(fromType)) return true; - } else if (toType.IsGenericType()) { + } else if (toType.IsGenericType) { Type genTo = toType.GetGenericTypeDefinition(); if (genTo == IEnumerableOfTType) { return IEnumerableOfObjectType.IsAssignableFrom(fromType) || @@ -814,7 +814,7 @@ private static bool HasNarrowingConversion(Type fromType, Type toType, Narrowing if (toType == BigIntegerType && HasPythonProtocol(fromType, "__long__")) return true; } - if (toType.IsGenericType()) { + if (toType.IsGenericType) { Type genTo = toType.GetGenericTypeDefinition(); if (genTo == IListOfTType) { return IListOfObjectType.IsAssignableFrom(fromType); @@ -828,7 +828,7 @@ private static bool HasNarrowingConversion(Type fromType, Type toType, Narrowing } if (fromType == BigIntegerType && toType == Int64Type) return true; - if (toType.IsEnum() && fromType == Enum.GetUnderlyingType(toType)) return true; + if (toType.IsEnum && fromType == Enum.GetUnderlyingType(toType)) return true; return false; } @@ -848,7 +848,7 @@ private static bool HasImplicitConversionWorker(Type lookupType, Type fromType, return true; } } - lookupType = lookupType.GetBaseType(); + lookupType = lookupType.BaseType; } return false; } @@ -886,7 +886,7 @@ private static bool HasImplicitConversionWorker(Type lookupType, Type fromType, } internal static bool IsNumeric(Type t) { - if (t.IsEnum()) return false; + if (t.IsEnum) return false; switch (t.GetTypeCode()) { case TypeCode.DateTime: diff --git a/Src/IronPython/Runtime/Operations/InstanceOps.cs b/Src/IronPython/Runtime/Operations/InstanceOps.cs index 9b61372b0..e9bc70f99 100644 --- a/Src/IronPython/Runtime/Operations/InstanceOps.cs +++ b/Src/IronPython/Runtime/Operations/InstanceOps.cs @@ -227,7 +227,7 @@ public static PythonList DynamicDir(CodeContext/*!*/ context, IDynamicMetaObject // add in the non-dynamic members from the dynamic objects base class. Type t = self.GetType(); while (typeof(IDynamicMetaObjectProvider).IsAssignableFrom(t)) { - t = t.GetBaseType(); + t = t.BaseType; } res.extend(DynamicHelpers.GetPythonTypeFromType(t).GetMemberNames(context)); @@ -690,7 +690,7 @@ public static void ExitMethod(IDisposable/*!*/ self, object exc_type, object exc [PropertyMethod, StaticExtensionMethod] public static PythonList/*!*/ Get__all__(CodeContext/*!*/ context) { - Debug.Assert(typeof(T).IsSealed() && typeof(T).IsAbstract(), "__all__ should only be produced for static members"); + Debug.Assert(typeof(T).IsSealed && typeof(T).IsAbstract, "__all__ should only be produced for static members"); PythonType pt = DynamicHelpers.GetPythonTypeFromType(typeof(T)); @@ -729,13 +729,13 @@ private static bool IsStaticTypeMemberInAll(CodeContext/*!*/ context, PythonType } BuiltinMethodDescriptor method = pts as BuiltinMethodDescriptor; - if (method != null && (!method.DeclaringType.IsSealed() || !method.DeclaringType.IsAbstract())) { + if (method != null && (!method.DeclaringType.IsSealed || !method.DeclaringType.IsAbstract)) { // inherited object member on a static class (GetHashCode, Equals, etc...) return false; } BuiltinFunction bf = pts as BuiltinFunction; - if (bf != null && (!bf.DeclaringType.IsSealed() || !bf.DeclaringType.IsAbstract())) { + if (bf != null && (!bf.DeclaringType.IsSealed || !bf.DeclaringType.IsAbstract)) { // __new__/ReferenceEquals inherited from object return false; } diff --git a/Src/IronPython/Runtime/Operations/ObjectOps.cs b/Src/IronPython/Runtime/Operations/ObjectOps.cs index d94efff31..9e69cd251 100644 --- a/Src/IronPython/Runtime/Operations/ObjectOps.cs +++ b/Src/IronPython/Runtime/Operations/ObjectOps.cs @@ -202,9 +202,9 @@ private static int GetTypeSize(Type t) { FieldInfo[] fields = t.GetFields(System.Reflection.BindingFlags.FlattenHierarchy | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Public); int res = 0; foreach (FieldInfo fi in fields) { - if (fi.FieldType.IsClass() || fi.FieldType.IsInterface()) { + if (fi.FieldType.IsClass() || fi.FieldType.IsInterface) { res += AdjustPointerSize(4); - } else if (fi.FieldType.IsPrimitive()) { + } else if (fi.FieldType.IsPrimitive) { return System.Runtime.InteropServices.Marshal.SizeOf(fi.FieldType); } else { res += GetTypeSize(fi.FieldType); diff --git a/Src/IronPython/Runtime/Operations/PythonOps.cs b/Src/IronPython/Runtime/Operations/PythonOps.cs index b35b17bca..cc332985c 100644 --- a/Src/IronPython/Runtime/Operations/PythonOps.cs +++ b/Src/IronPython/Runtime/Operations/PythonOps.cs @@ -1841,8 +1841,8 @@ public static void ImportStar(CodeContext/*!*/ context, string fullName, int lev PythonType pt = newmod as PythonType; if (pt != null && - !pt.UnderlyingSystemType.IsEnum() && - (!pt.UnderlyingSystemType.IsAbstract() || !pt.UnderlyingSystemType.IsSealed())) { + !pt.UnderlyingSystemType.IsEnum && + (!pt.UnderlyingSystemType.IsAbstract || !pt.UnderlyingSystemType.IsSealed)) { // from type import * only allowed on static classes (and enums) throw PythonOps.ImportError("no module named {0}", pt.Name); } diff --git a/Src/IronPython/Runtime/Operations/PythonTypeOps.cs b/Src/IronPython/Runtime/Operations/PythonTypeOps.cs index 9aa1c8881..ecc5d83bc 100644 --- a/Src/IronPython/Runtime/Operations/PythonTypeOps.cs +++ b/Src/IronPython/Runtime/Operations/PythonTypeOps.cs @@ -318,7 +318,7 @@ private static BuiltinFunction GetConstructorFunction(Type t, bool privateBindin internal static MethodBase[] GetConstructors(Type t, bool privateBinding, bool includeProtected = false) { MethodBase[] ctors = CompilerHelpers.GetConstructors(t, privateBinding, includeProtected); - if (t.IsEnum()) { + if (t.IsEnum) { var enumCtor = typeof(PythonTypeOps).GetDeclaredMethods(nameof(CreateEnum)).Single().MakeGenericMethod(t); ctors = ctors.Concat(new[] { enumCtor }).ToArray(); } @@ -369,7 +369,7 @@ internal static BuiltinFunction GetConstructorFunction(Type type, string name) { } } - if (type.IsValueType() && !hasDefaultConstructor && type != typeof(void)) { + if (type.IsValueType && !hasDefaultConstructor && type != typeof(void)) { try { methods.Add(typeof(ScriptingRuntimeHelpers).GetMethod(nameof(ScriptingRuntimeHelpers.CreateInstance), ReflectionUtils.EmptyTypes).MakeGenericMethod(type)); } catch (BadImageFormatException) { @@ -522,8 +522,8 @@ private static Type GetCommonBaseType(Type xType, Type yType) { return xType; } - Type xBase = xType.GetBaseType(); - Type yBase = yType.GetBaseType(); + Type xBase = xType.BaseType; + Type yBase = yType.BaseType; if (xBase != null) { Type res = GetCommonBaseType(xBase, yType); if (res != null) { @@ -884,7 +884,7 @@ internal static PythonTuple EnsureBaseType(PythonTuple bases) { foreach (object baseClass in bases) { PythonType dt = baseClass as PythonType; - if (!dt.UnderlyingSystemType.IsInterface()) { + if (!dt.UnderlyingSystemType.IsInterface) { return bases; } else { hasInterface = true; @@ -901,7 +901,7 @@ internal static PythonTuple EnsureBaseType(PythonTuple bases) { internal static Type GetFinalSystemType(Type type) { while (typeof(IPythonObject).IsAssignableFrom(type) && !type.IsDefined(typeof(DynamicBaseTypeAttribute), false)) { - type = type.GetBaseType(); + type = type.BaseType; } return type; } diff --git a/Src/IronPython/Runtime/PythonDocumentationProvider.cs b/Src/IronPython/Runtime/PythonDocumentationProvider.cs index 2c29ce9dc..6a61073cc 100644 --- a/Src/IronPython/Runtime/PythonDocumentationProvider.cs +++ b/Src/IronPython/Runtime/PythonDocumentationProvider.cs @@ -91,7 +91,7 @@ private static MemberDoc MakeMemberDoc(string name, object value, bool fromClass kind = MemberKind.Method; } else if (value is PythonType) { var pt = value as PythonType; - if (pt.IsSystemType && pt.UnderlyingSystemType.IsEnum()) { + if (pt.IsSystemType && pt.UnderlyingSystemType.IsEnum) { kind = MemberKind.Enum; } else { kind = MemberKind.Class; @@ -104,7 +104,7 @@ private static MemberDoc MakeMemberDoc(string name, object value, bool fromClass kind = MemberKind.Event; } else if (value is ReflectedField) { kind = MemberKind.Field; - } else if (value != null && value.GetType().IsEnum()) { + } else if (value != null && value.GetType().IsEnum) { kind = MemberKind.EnumMember; } else if (value is PythonType) { kind = MemberKind.Class; diff --git a/Src/IronPython/Runtime/Types/BuiltinFunction.cs b/Src/IronPython/Runtime/Types/BuiltinFunction.cs index ead25aa5f..8854f89b7 100644 --- a/Src/IronPython/Runtime/Types/BuiltinFunction.cs +++ b/Src/IronPython/Runtime/Types/BuiltinFunction.cs @@ -440,7 +440,7 @@ public BindingResult(BindingTarget target, DynamicMetaObject meta) { // The function can return something typed to boolean or int. // If that happens, we need to apply Python's boxing rules. - if (res.Expression.Type.IsValueType()) { + if (res.Expression.Type.IsValueType) { res = BindingHelpers.AddPythonBoxing(res); } else if (res.Expression.Type == typeof(void)) { res = new DynamicMetaObject( diff --git a/Src/IronPython/Runtime/Types/NewTypeInfo.cs b/Src/IronPython/Runtime/Types/NewTypeInfo.cs index 55de05f25..b7601761d 100644 --- a/Src/IronPython/Runtime/Types/NewTypeInfo.cs +++ b/Src/IronPython/Runtime/Types/NewTypeInfo.cs @@ -60,11 +60,11 @@ public static NewTypeInfo GetTypeInfo(string typeName, PythonTuple bases) { if (curTypeToExtend == null || typeof(BuiltinFunction).IsAssignableFrom(curTypeToExtend) || typeof(PythonFunction).IsAssignableFrom(curTypeToExtend)) throw PythonOps.TypeError(typeName + ": {0} is not an acceptable base type", curBasePythonType.Name); - if (curTypeToExtend.ContainsGenericParameters()) + if (curTypeToExtend.ContainsGenericParameters) throw PythonOps.TypeError(typeName + ": cannot inhert from open generic instantiation {0}. Only closed instantiations are supported.", curBasePythonType); foreach (Type interfaceType in baseInterfaces) { - if (interfaceType.ContainsGenericParameters()) + if (interfaceType.ContainsGenericParameters) throw PythonOps.TypeError(typeName + ": cannot inhert from open generic instantiation {0}. Only closed instantiations are supported.", interfaceType); // collecting all the interfaces because we override them all. diff --git a/Src/IronPython/Runtime/Types/NewTypeMaker.cs b/Src/IronPython/Runtime/Types/NewTypeMaker.cs index f33ac52a6..9f548478e 100644 --- a/Src/IronPython/Runtime/Types/NewTypeMaker.cs +++ b/Src/IronPython/Runtime/Types/NewTypeMaker.cs @@ -86,9 +86,9 @@ private NewTypeMaker(NewTypeInfo typeInfo) { NewTypeInfo typeInfo = NewTypeInfo.GetTypeInfo(typeName, bases); - if (typeInfo.BaseType.IsValueType()) { + if (typeInfo.BaseType.IsValueType) { throw PythonOps.TypeError("cannot derive from {0} because it is a value type", typeInfo.BaseType.FullName); - } else if (typeInfo.BaseType.IsSealed()) { + } else if (typeInfo.BaseType.IsSealed) { throw PythonOps.TypeError("cannot derive from {0} because it is sealed", typeInfo.BaseType.FullName); } @@ -207,7 +207,7 @@ public static void LoadNewTypes(Assembly/*!*/ asm) { var typeInfo = (CachedNewTypeInfo[])mi.Invoke(null, new object[0]); foreach (var v in typeInfo) { _newTypes.GetOrCreateValue( - new NewTypeInfo(v.Type.GetBaseType(), v.InterfaceTypes), + new NewTypeInfo(v.Type.BaseType, v.InterfaceTypes), () => { // type wasn't already created, go ahead and publish // the info and return the type. @@ -226,7 +226,7 @@ public static bool IsInstanceType(Type type) { return type.FullName.IndexOf(NewTypeMaker.TypePrefix) == 0 || // Users can create sub-types of instance-types using __clrtype__ without using // NewTypeMaker.TypePrefix - ((type.GetBaseType() != null) && IsInstanceType(type.GetBaseType())); + ((type.BaseType != null) && IsInstanceType(type.BaseType)); } #endregion @@ -903,7 +903,7 @@ private void OverrideMethods(Type type, Dictionary specialName } } - if (type.IsAbstract() && !type.IsInterface()) { + if (type.IsAbstract && !type.IsInterface) { // abstract types can define interfaces w/o implementations foreach (Type iface in type.GetInterfaces()) { InterfaceMapping mapping = type.GetInterfaceMap(iface); @@ -1105,7 +1105,7 @@ private PythonType GetBaseTypeForMethod(MethodInfo mi) { basePythonType = DynamicHelpers.GetPythonTypeFromType(_baseType); } else { // We must be inherting from an interface - Debug.Assert(mi.DeclaringType.IsInterface()); + Debug.Assert(mi.DeclaringType.IsInterface); basePythonType = DynamicHelpers.GetPythonTypeFromType(mi.DeclaringType); } return basePythonType; @@ -1528,7 +1528,7 @@ private sealed class ReturnFixer { private readonly int _index; private ReturnFixer(LocalBuilder reference, ParameterInfo parameter, int index) { - Debug.Assert(reference.LocalType.IsGenericType() && reference.LocalType.GetGenericTypeDefinition() == typeof(StrongBox<>)); + Debug.Assert(reference.LocalType.IsGenericType && reference.LocalType.GetGenericTypeDefinition() == typeof(StrongBox<>)); Debug.Assert(parameter.ParameterType.IsByRef); _parameter = parameter; @@ -1606,7 +1606,7 @@ private static void AddBaseMethods(Type finishedType, Dictionary 0, String.Format("{0} from {1}", newName, baseType.Name)); @@ -1701,7 +1701,7 @@ private static void StoreOverriddenMethod(MethodInfo mi, string newName) { } private static void StoreOverriddenProperty(MethodInfo mi, string newName) { - Type baseType = mi.DeclaringType.GetBaseType(); + Type baseType = mi.DeclaringType.BaseType; lock (PythonTypeOps._propertyCache) { string propName = newName.Substring(4); // get_ or set_ @@ -1778,7 +1778,7 @@ internal static IList GetOverriddenMethods(Type type, string name) { } } } - curType = curType.GetBaseType(); + curType = curType.BaseType; } if (res != null) { return res; diff --git a/Src/IronPython/Runtime/Types/PythonType.cs b/Src/IronPython/Runtime/Types/PythonType.cs index c775e67d7..27ea879bf 100644 --- a/Src/IronPython/Runtime/Types/PythonType.cs +++ b/Src/IronPython/Runtime/Types/PythonType.cs @@ -603,7 +603,7 @@ public PythonType this[params Type[] args] { throw PythonOps.TypeError("expected one argument to make array type, got {0}", args.Length); } - if (!UnderlyingSystemType.IsGenericTypeDefinition()) { + if (!UnderlyingSystemType.IsGenericTypeDefinition) { throw new InvalidOperationException("MakeGenericType on non-generic type"); } @@ -754,7 +754,7 @@ public virtual bool __subclasscheck__(PythonType sub) { } private bool SubclassImpl(PythonType sub) { - if (UnderlyingSystemType.IsInterface()) { + if (UnderlyingSystemType.IsInterface) { // interfaces aren't in bases, and therefore IsSubclassOf doesn't do this check. if (UnderlyingSystemType.IsAssignableFrom(sub.UnderlyingSystemType)) { return true; @@ -1055,7 +1055,7 @@ internal Type/*!*/ FinalSystemType { /// internal Type/*!*/ ExtensionType { get { - if (!_underlyingSystemType.IsEnum()) { + if (!_underlyingSystemType.IsEnum) { switch (_underlyingSystemType.GetTypeCode()) { case TypeCode.String: return typeof(ExtensibleString); case TypeCode.Int32: return typeof(Extensible); @@ -1117,7 +1117,7 @@ internal bool IsSubclassOf(PythonType other) { } //Python doesn't have value types inheriting from ValueType, but we fake this for interop - if (other.UnderlyingSystemType == typeof(ValueType) && UnderlyingSystemType.IsValueType()) { + if (other.UnderlyingSystemType == typeof(ValueType) && UnderlyingSystemType.IsValueType) { return true; } @@ -1281,7 +1281,7 @@ internal bool TryResolveSlot(CodeContext context, string name, out PythonTypeSlo // don't look at interfaces - users can inherit from them, but we resolve members // via methods implemented on types and defined by Python. - if (dt.IsSystemType && !dt.UnderlyingSystemType.IsInterface()) { + if (dt.IsSystemType && !dt.UnderlyingSystemType.IsInterface) { return PythonBinder.GetBinder(context).TryResolveSlot(context, dt, this, name, out slot); } @@ -1290,7 +1290,7 @@ internal bool TryResolveSlot(CodeContext context, string name, out PythonTypeSlo } } - if (UnderlyingSystemType.IsInterface()) { + if (UnderlyingSystemType.IsInterface) { return TypeCache.Object.TryResolveSlot(context, name, out slot); } @@ -2307,20 +2307,20 @@ private void AddSystemBases() { List mro = new List(); mro.Add(this); - if (_underlyingSystemType.GetBaseType() != null) { + if (_underlyingSystemType.BaseType != null) { Type baseType; if (_underlyingSystemType == typeof(bool)) { // bool inherits from int in python baseType = typeof(int); - } else if (_underlyingSystemType.GetBaseType() == typeof(ValueType)) { + } else if (_underlyingSystemType.BaseType == typeof(ValueType)) { // hide ValueType, it doesn't exist in Python baseType = typeof(object); } else { - baseType = _underlyingSystemType.GetBaseType(); + baseType = _underlyingSystemType.BaseType; } while (baseType.IsDefined(typeof(PythonHiddenBaseClassAttribute), false)) { - baseType = baseType.GetBaseType(); + baseType = baseType.BaseType; } _bases = new PythonType[] { GetPythonType(baseType) }; @@ -2333,13 +2333,13 @@ private void AddSystemBases() { } else if(!curType.IsDefined(typeof(PythonHiddenBaseClassAttribute), false)) { mro.Add(DynamicHelpers.GetPythonTypeFromType(curType)); } - curType = curType.GetBaseType(); + curType = curType.BaseType; } if (!IsPythonType) { AddSystemInterfaces(mro); } - } else if (_underlyingSystemType.IsInterface()) { + } else if (_underlyingSystemType.IsInterface) { // add interfaces to MRO & create bases list Type[] interfaces = _underlyingSystemType.GetInterfaces(); PythonType[] bases = new PythonType[interfaces.Length]; @@ -2434,7 +2434,7 @@ private void AddSystemInterfaces(List mro) { if (hasExplicitIface) { // add any non-colliding interfaces into the MRO foreach (Type t in nonCollidingInterfaces) { - Debug.Assert(t.IsInterface()); + Debug.Assert(t.IsInterface); mro.Add(DynamicHelpers.GetPythonTypeFromType(t)); } @@ -2454,7 +2454,7 @@ private void AddSystemConstructors() { _underlyingSystemType ) ); - } else if (!_underlyingSystemType.IsAbstract()) { + } else if (!_underlyingSystemType.IsAbstract) { BuiltinFunction reflectedCtors = GetConstructors(); if (reflectedCtors == null) { return; // no ctors, no __new__ diff --git a/Src/IronPython/Runtime/Types/PythonTypeInfo.cs b/Src/IronPython/Runtime/Types/PythonTypeInfo.cs index d626c8ecb..0da449340 100644 --- a/Src/IronPython/Runtime/Types/PythonTypeInfo.cs +++ b/Src/IronPython/Runtime/Types/PythonTypeInfo.cs @@ -341,7 +341,7 @@ public ComparisonResolver(Type/*!*/ comparable, string/*!*/ helperPrefix) { // Do not map IComparable if this is a primitive builtin type. if (_excludePrimitiveTypes) { - if (type.IsPrimitive() || type == typeof(BigInteger) || + if (type.IsPrimitive || type == typeof(BigInteger) || type == typeof(string) || type == typeof(decimal)) { return MemberGroup.EmptyGroup; } @@ -366,7 +366,7 @@ public ComparisonResolver(Type/*!*/ comparable, string/*!*/ helperPrefix) { /// private class OperatorResolver : MemberResolver { public override MemberGroup/*!*/ ResolveMember(MemberBinder/*!*/ binder, MemberRequestKind/*!*/ action, Type/*!*/ type, string/*!*/ name) { - if (type.IsSealed() && type.IsAbstract()) { + if (type.IsSealed && type.IsAbstract) { // static types don't have PythonOperationKind return MemberGroup.EmptyGroup; } @@ -805,7 +805,7 @@ private class ProtectedMemberResolver : MemberResolver { // __repr__ for normal .NET types is special, if we're a Python type then // we'll use one of the built-in reprs (from object or from the type) if (!PythonBinder.IsPythonType(type) && - (!type.IsSealed() || !type.IsAbstract())) { // static types don't get __repr__ + (!type.IsSealed || !type.IsAbstract)) { // static types don't get __repr__ // check and see if __repr__ has been overridden by the base type. foreach (Type t in binder.GetContributingTypes(type)) { if (t == typeof(ObjectOps) && type != typeof(object)) { @@ -865,7 +865,7 @@ private static bool TypeOverridesMethod(MemberBinder/*!*/ binder, Type/*!*/ typ /// then IValueEquality.GetValueHashCode. /// private static MemberGroup/*!*/ HashResolver(MemberBinder/*!*/ binder, Type/*!*/ type) { - if (typeof(IStructuralEquatable).IsAssignableFrom(type) && !type.IsInterface()) { + if (typeof(IStructuralEquatable).IsAssignableFrom(type) && !type.IsInterface) { // check and see if __hash__ has been overridden by the base type. foreach (Type t in binder.GetContributingTypes(type)) { @@ -895,7 +895,7 @@ private static bool TypeOverridesMethod(MemberBinder/*!*/ binder, Type/*!*/ typ /// TODO: Can we just always fallback to object.__new__? If not why not? /// private static MemberGroup/*!*/ NewResolver(MemberBinder/*!*/ binder, Type/*!*/ type) { - if (type.IsSealed() && type.IsAbstract()) { + if (type.IsSealed && type.IsAbstract) { // static types don't have __new__ return MemberGroup.EmptyGroup; } @@ -968,7 +968,7 @@ internal static MemberGroup GetExtensionMemberGroup(Type type, MemberInfo[] news } foreach (Type t in binder.GetInterfaces(type)) { - if (t.IsGenericType() && t.GetGenericTypeDefinition() == typeof(ICollection<>)) { + if (t.IsGenericType && t.GetGenericTypeDefinition() == typeof(ICollection<>)) { MethodInfo genMeth = typeof(InstanceOps).GetMethod(nameof(InstanceOps.GenericLengthMethod)); return new MemberGroup( MethodTracker.FromMemberInfo(genMeth.MakeGenericMethod(t.GetGenericArguments()), type) @@ -1054,7 +1054,7 @@ internal static MemberGroup GetExtensionMemberGroup(Type type, MemberInfo[] news private static MemberGroup/*!*/ AllResolver(MemberBinder/*!*/ binder, Type/*!*/ type) { // static types are like modules and define __all__. - if (type.IsAbstract() && type.IsSealed()) { + if (type.IsAbstract && type.IsSealed) { return new MemberGroup(new ExtensionPropertyTracker("__all__", typeof(InstanceOps).GetMethod("Get__all__").MakeGenericMethod(type), null, null, type)); } @@ -1166,7 +1166,7 @@ internal override bool TrySetValue(CodeContext context, object instance, PythonT // search for IDictionary first because it's ICollection> and we want to call ContainsKey foreach (Type t in intf) { - if (t.IsGenericType() && t.GetGenericTypeDefinition() == typeof(IDictionary<,>)) { + if (t.IsGenericType && t.GetGenericTypeDefinition() == typeof(IDictionary<,>)) { if (t.GetGenericArguments()[0] == typeof(object)) { hasObjectContains = true; } @@ -1182,7 +1182,7 @@ internal override bool TrySetValue(CodeContext context, object instance, PythonT if (containsMembers == null) { // then look for ICollection for generic __contains__ first if we're not an IDictionary foreach (Type t in intf) { - if (t.IsGenericType() && t.GetGenericTypeDefinition() == typeof(ICollection<>)) { + if (t.IsGenericType && t.GetGenericTypeDefinition() == typeof(ICollection<>)) { if (t.GetGenericArguments()[0] == typeof(object)) { hasObjectContains = true; } @@ -1232,7 +1232,7 @@ internal override bool TrySetValue(CodeContext context, object instance, PythonT /// private static void GetEnumeratorContains(Type type, IList intf, ref List containsMembers, ref bool hasObjectContains, Type ienumOfT, Type ienum, string name) { foreach (Type t in intf) { - if (t.IsGenericType() && t.GetGenericTypeDefinition() == ienumOfT) { + if (t.IsGenericType && t.GetGenericTypeDefinition() == ienumOfT) { if (t.GetGenericArguments()[0] == typeof(object)) { hasObjectContains = true; } @@ -1273,7 +1273,7 @@ public OneOffOperatorBinder(string/*!*/ methodName, string/*!*/ pythonName, Pyth } public MemberGroup/*!*/ Resolver(MemberBinder/*!*/ binder, Type/*!*/ type) { - if (type.IsSealed() && type.IsAbstract()) { + if (type.IsSealed && type.IsAbstract) { // static types don't have PythonOperationKind return MemberGroup.EmptyGroup; } @@ -1300,7 +1300,7 @@ public OneOffPowerBinder(string/*!*/ pythonName, PythonOperationKind op) { } public MemberGroup/*!*/ Resolver(MemberBinder/*!*/ binder, Type/*!*/ type) { - if (type.IsSealed() && type.IsAbstract()) { + if (type.IsSealed && type.IsAbstract) { // static types don't have PythonOperationKind return MemberGroup.EmptyGroup; } @@ -1470,7 +1470,7 @@ public ResolveBinder(PythonBinder/*!*/ binder) res.AddRange(Binder.GetExtensionTypesInternal(pt.UnderlyingSystemType)); } - if (t.IsInterface()) { + if (t.IsInterface) { foreach (Type iface in t.GetInterfaces()) { res.Add(iface); } @@ -1493,7 +1493,7 @@ public LookupBinder(PythonBinder/*!*/ binder) } public override IList/*!*/ GetInterfaces(Type/*!*/ t) { - if (t.IsInterface()) { + if (t.IsInterface) { return t.GetInterfaces(); } diff --git a/Src/IronPython/Runtime/Types/ReflectedField.cs b/Src/IronPython/Runtime/Types/ReflectedField.cs index 2a965891a..9a0caea81 100644 --- a/Src/IronPython/Runtime/Types/ReflectedField.cs +++ b/Src/IronPython/Runtime/Types/ReflectedField.cs @@ -163,7 +163,7 @@ internal override bool IsAlwaysVisible { } internal override void MakeGetExpression(PythonBinder/*!*/ binder, Expression/*!*/ codeContext, DynamicMetaObject instance, DynamicMetaObject/*!*/ owner, ConditionalBuilder/*!*/ builder) { - if (!_info.IsPublic || _info.DeclaringType.ContainsGenericParameters()) { + if (!_info.IsPublic || _info.DeclaringType.ContainsGenericParameters) { // fallback to reflection base.MakeGetExpression(binder, codeContext, instance, owner, builder); } else if (instance == null) { @@ -198,7 +198,7 @@ private void DoSet(CodeContext context, object instance, object val, bool suppre PerfTrack.NoteEvent(PerfTrack.Categories.Fields, this); if (_info.IsInitOnly || _info.IsLiteral) { throw PythonOps.AttributeErrorForReadonlyAttribute(_info.DeclaringType.Name, _info.Name); - } else if (!suppressWarning && instance != null && instance.GetType().IsValueType()) { + } else if (!suppressWarning && instance != null && instance.GetType().IsValueType) { PythonOps.Warn(context, PythonExceptions.RuntimeWarning, UpdateValueTypeFieldWarning, _info.Name, _info.DeclaringType.Name); }