| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -27,5 +27,14 @@ public BorrowedReference(IntPtr pointer) | |||
| 27 | 27 | => a.pointer == b.pointer; | |
| 28 | 28 | public static bool operator !=(BorrowedReference a, BorrowedReference b) | |
| 29 | 29 | => a.pointer != b.pointer; | |
| 30 | + | ||
| 31 | + public override bool Equals(object obj) { | ||
| 32 | + if (obj is IntPtr ptr) | ||
| 33 | + return ptr == pointer; | ||
| 34 | + | ||
| 35 | + return false; | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | + public override int GetHashCode() => pointer.GetHashCode(); | ||
| 30 | 39 | } | |
| 31 | 40 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -20,9 +20,9 @@ internal class AssemblyManager | |||
| 20 | 20 | // therefore this should be a ConcurrentDictionary | |
| 21 | 21 | // | |
| 22 | 22 | // WARNING: Dangerous if cross-app domain usage is ever supported | |
| 23 | - // Reusing the dictionary with assemblies accross multiple initializations is problematic. | ||
| 24 | - // Loading happens from CurrentDomain (see line 53). And if the first call is from AppDomain that is later unloaded, | ||
| 25 | - // than it can end up referring to assemblies that are already unloaded (default behavior after unload appDomain - | ||
| 23 | + // Reusing the dictionary with assemblies accross multiple initializations is problematic. | ||
| 24 | + // Loading happens from CurrentDomain (see line 53). And if the first call is from AppDomain that is later unloaded, | ||
| 25 | + // than it can end up referring to assemblies that are already unloaded (default behavior after unload appDomain - | ||
| 26 | 26 | // unless LoaderOptimization.MultiDomain is used); | |
| 27 | 27 | // So for multidomain support it is better to have the dict. recreated for each app-domain initialization | |
| 28 | 28 | private static ConcurrentDictionary<string, ConcurrentDictionary<Assembly, string>> namespaces = | |
@@ -365,25 +365,6 @@ public static List<string> GetNames(string nsname) | |||
| 365 | 365 | return names; | |
| 366 | 366 | } | |
| 367 | 367 | ||
| 368 | - /// <summary> | ||
| 369 | - /// Returns the System.Type object for a given qualified name, | ||
| 370 | - /// looking in the currently loaded assemblies for the named | ||
| 371 | - /// type. Returns null if the named type cannot be found. | ||
| 372 | - /// </summary> | ||
| 373 | - [Obsolete("Use LookupTypes and handle name conflicts")] | ||
| 374 | - public static Type LookupType(string qname) | ||
| 375 | - { | ||
| 376 | - foreach (Assembly assembly in assemblies) | ||
| 377 | - { | ||
| 378 | - Type type = assembly.GetType(qname); | ||
| 379 | - if (type != null && IsExported(type)) | ||
| 380 | - { | ||
| 381 | - return type; | ||
| 382 | - } | ||
| 383 | - } | ||
| 384 | - return null; | ||
| 385 | - } | ||
| 386 | - | ||
| 387 | 368 | /// <summary> | |
| 388 | 369 | /// Returns the <see cref="Type"/> objects for the given qualified name, | |
| 389 | 370 | /// looking in the currently loaded assemblies for the named | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,3 +1,4 @@ | |||
| 1 | + using System.Linq; | ||
| 1 | 2 | using System; | |
| 2 | 3 | using System.Reflection; | |
| 3 | 4 | ||
@@ -143,7 +144,7 @@ public override IntPtr type_subscript(IntPtr idx) | |||
| 143 | 144 | return Exceptions.RaiseTypeError("type(s) expected"); | |
| 144 | 145 | } | |
| 145 | 146 | ||
| 146 | - Type gtype = AssemblyManager.LookupType($"{type.FullName}`{types.Length}"); | ||
| 147 | + Type gtype = AssemblyManager.LookupTypes($"{type.FullName}`{types.Length}").FirstOrDefault(); | ||
| 147 | 148 | if (gtype != null) | |
| 148 | 149 | { | |
| 149 | 150 | var g = ClassManager.GetClass(gtype) as GenericType; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -62,7 +62,9 @@ public IncorrectRefCountException(IntPtr ptr) | |||
| 62 | 62 | } | |
| 63 | 63 | ||
| 64 | 64 | public delegate bool IncorrectRefCntHandler(object sender, IncorrectFinalizeArgs e); | |
| 65 | - public event IncorrectRefCntHandler IncorrectRefCntResolver; | ||
| 65 | + #pragma warning disable 414 | ||
| 66 | + public event IncorrectRefCntHandler IncorrectRefCntResolver = null; | ||
| 67 | + #pragma warning restore 414 | ||
| 66 | 68 | public bool ThrowIfUnhandleIncorrectRefCount { get; set; } = true; | |
| 67 | 69 | ||
| 68 | 70 | #endregion | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,3 +1,4 @@ | |||
| 1 | + using System.Linq; | ||
| 1 | 2 | using System; | |
| 2 | 3 | using System.Collections.Generic; | |
| 3 | 4 | using System.Resources; | |
@@ -124,7 +125,7 @@ public static List<Type> GenericsByName(string ns, string basename) | |||
| 124 | 125 | foreach (string name in names) | |
| 125 | 126 | { | |
| 126 | 127 | string qname = ns + "." + name; | |
| 127 | - Type o = AssemblyManager.LookupType(qname); | ||
| 128 | + Type o = AssemblyManager.LookupTypes(qname).FirstOrDefault(); | ||
| 128 | 129 | if (o != null) | |
| 129 | 130 | { | |
| 130 | 131 | result.Add(o); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -80,8 +80,8 @@ internal static class ManagedDataOffsets | |||
| 80 | 80 | ||
| 81 | 81 | static class DataOffsets | |
| 82 | 82 | { | |
| 83 | - public static readonly int ob_data; | ||
| 84 | - public static readonly int ob_dict; | ||
| 83 | + public static readonly int ob_data = 0; | ||
| 84 | + public static readonly int ob_dict = 0; | ||
| 85 | 85 | ||
| 86 | 86 | static DataOffsets() | |
| 87 | 87 | { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -8,6 +8,7 @@ namespace Python.Test | |||
| 8 | 8 | public delegate void EventHandlerTest(object sender, EventArgsTest e); | |
| 9 | 9 | ||
| 10 | 10 | ||
| 11 | + #pragma warning disable 67 // Unused events, these are only accessed from Python | ||
| 11 | 12 | public class EventTest | |
| 12 | 13 | { | |
| 13 | 14 | public static event EventHandlerTest PublicStaticEvent; | |
@@ -100,6 +101,7 @@ public static void ShutUpCompiler() | |||
| 100 | 101 | e.PrivateEvent += f; | |
| 101 | 102 | } | |
| 102 | 103 | } | |
| 104 | + #pragma warning restore 67 | ||
| 103 | 105 | ||
| 104 | 106 | ||
| 105 | 107 | public class EventArgsTest : EventArgs | |
| Back | FazBrowse Home | New Git URL |
0 commit comments