diff --git a/src/runtime/BorrowedReference.cs b/src/runtime/BorrowedReference.cs index d82763d40..a9ea327e9 100644 --- a/src/runtime/BorrowedReference.cs +++ b/src/runtime/BorrowedReference.cs @@ -27,5 +27,14 @@ public BorrowedReference(IntPtr pointer) => a.pointer == b.pointer; public static bool operator !=(BorrowedReference a, BorrowedReference b) => a.pointer != b.pointer; + + public override bool Equals(object obj) { + if (obj is IntPtr ptr) + return ptr == pointer; + + return false; + } + + public override int GetHashCode() => pointer.GetHashCode(); } } diff --git a/src/runtime/assemblymanager.cs b/src/runtime/assemblymanager.cs index 01ccf6957..0387d2dfc 100644 --- a/src/runtime/assemblymanager.cs +++ b/src/runtime/assemblymanager.cs @@ -20,9 +20,9 @@ internal class AssemblyManager // therefore this should be a ConcurrentDictionary // // WARNING: Dangerous if cross-app domain usage is ever supported - // Reusing the dictionary with assemblies accross multiple initializations is problematic. - // Loading happens from CurrentDomain (see line 53). And if the first call is from AppDomain that is later unloaded, - // than it can end up referring to assemblies that are already unloaded (default behavior after unload appDomain - + // Reusing the dictionary with assemblies accross multiple initializations is problematic. + // Loading happens from CurrentDomain (see line 53). And if the first call is from AppDomain that is later unloaded, + // than it can end up referring to assemblies that are already unloaded (default behavior after unload appDomain - // unless LoaderOptimization.MultiDomain is used); // So for multidomain support it is better to have the dict. recreated for each app-domain initialization private static ConcurrentDictionary> namespaces = @@ -365,25 +365,6 @@ public static List GetNames(string nsname) return names; } - /// - /// Returns the System.Type object for a given qualified name, - /// looking in the currently loaded assemblies for the named - /// type. Returns null if the named type cannot be found. - /// - [Obsolete("Use LookupTypes and handle name conflicts")] - public static Type LookupType(string qname) - { - foreach (Assembly assembly in assemblies) - { - Type type = assembly.GetType(qname); - if (type != null && IsExported(type)) - { - return type; - } - } - return null; - } - /// /// Returns the objects for the given qualified name, /// looking in the currently loaded assemblies for the named diff --git a/src/runtime/classobject.cs b/src/runtime/classobject.cs index 18816781f..355cf744a 100644 --- a/src/runtime/classobject.cs +++ b/src/runtime/classobject.cs @@ -1,3 +1,4 @@ +using System.Linq; using System; using System.Reflection; @@ -143,7 +144,7 @@ public override IntPtr type_subscript(IntPtr idx) return Exceptions.RaiseTypeError("type(s) expected"); } - Type gtype = AssemblyManager.LookupType($"{type.FullName}`{types.Length}"); + Type gtype = AssemblyManager.LookupTypes($"{type.FullName}`{types.Length}").FirstOrDefault(); if (gtype != null) { var g = ClassManager.GetClass(gtype) as GenericType; diff --git a/src/runtime/finalizer.cs b/src/runtime/finalizer.cs index 3861ec6cb..fe2e46aac 100644 --- a/src/runtime/finalizer.cs +++ b/src/runtime/finalizer.cs @@ -62,7 +62,9 @@ public IncorrectRefCountException(IntPtr ptr) } public delegate bool IncorrectRefCntHandler(object sender, IncorrectFinalizeArgs e); - public event IncorrectRefCntHandler IncorrectRefCntResolver; + #pragma warning disable 414 + public event IncorrectRefCntHandler IncorrectRefCntResolver = null; + #pragma warning restore 414 public bool ThrowIfUnhandleIncorrectRefCount { get; set; } = true; #endregion diff --git a/src/runtime/genericutil.cs b/src/runtime/genericutil.cs index df78d9899..c583e64e2 100644 --- a/src/runtime/genericutil.cs +++ b/src/runtime/genericutil.cs @@ -1,3 +1,4 @@ +using System.Linq; using System; using System.Collections.Generic; using System.Resources; @@ -124,7 +125,7 @@ public static List GenericsByName(string ns, string basename) foreach (string name in names) { string qname = ns + "." + name; - Type o = AssemblyManager.LookupType(qname); + Type o = AssemblyManager.LookupTypes(qname).FirstOrDefault(); if (o != null) { result.Add(o); diff --git a/src/runtime/interop.cs b/src/runtime/interop.cs index a8330619b..10b6ee476 100644 --- a/src/runtime/interop.cs +++ b/src/runtime/interop.cs @@ -80,8 +80,8 @@ internal static class ManagedDataOffsets static class DataOffsets { - public static readonly int ob_data; - public static readonly int ob_dict; + public static readonly int ob_data = 0; + public static readonly int ob_dict = 0; static DataOffsets() { diff --git a/src/testing/eventtest.cs b/src/testing/eventtest.cs index 4c701d488..dfbd5c881 100644 --- a/src/testing/eventtest.cs +++ b/src/testing/eventtest.cs @@ -8,6 +8,7 @@ namespace Python.Test public delegate void EventHandlerTest(object sender, EventArgsTest e); + #pragma warning disable 67 // Unused events, these are only accessed from Python public class EventTest { public static event EventHandlerTest PublicStaticEvent; @@ -100,6 +101,7 @@ public static void ShutUpCompiler() e.PrivateEvent += f; } } + #pragma warning restore 67 public class EventArgsTest : EventArgs