GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Fix or disable warnings in Python.Runtime (#1318) · pythonnet/pythonnet@bd264cf

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • src
    • runtime
      • BorrowedReference.cs
      • assemblymanager.cs
      • classobject.cs
      • finalizer.cs
      • genericutil.cs
      • interop.cs
    • testing
      • eventtest.cs
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/runtime/BorrowedReference.cs‎

Copy file name to clipboardExpand all lines: src/runtime/BorrowedReference.cs
+9Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,14 @@ public BorrowedReference(IntPtr pointer)
2727
=> a.pointer == b.pointer;
2828
public static bool operator !=(BorrowedReference a, BorrowedReference b)
2929
=> 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();
3039
}
3140
}
Collapse file

‎src/runtime/assemblymanager.cs‎

Copy file name to clipboardExpand all lines: src/runtime/assemblymanager.cs
+3-22Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ internal class AssemblyManager
2020
// therefore this should be a ConcurrentDictionary
2121
//
2222
// 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 -
2626
// unless LoaderOptimization.MultiDomain is used);
2727
// So for multidomain support it is better to have the dict. recreated for each app-domain initialization
2828
private static ConcurrentDictionary<string, ConcurrentDictionary<Assembly, string>> namespaces =
@@ -365,25 +365,6 @@ public static List<string> GetNames(string nsname)
365365
return names;
366366
}
367367

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-
387368
/// <summary>
388369
/// Returns the <see cref="Type"/> objects for the given qualified name,
389370
/// looking in the currently loaded assemblies for the named
Collapse file

‎src/runtime/classobject.cs‎

Copy file name to clipboardExpand all lines: src/runtime/classobject.cs
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System.Linq;
12
using System;
23
using System.Reflection;
34

@@ -143,7 +144,7 @@ public override IntPtr type_subscript(IntPtr idx)
143144
return Exceptions.RaiseTypeError("type(s) expected");
144145
}
145146

146-
Type gtype = AssemblyManager.LookupType($"{type.FullName}`{types.Length}");
147+
Type gtype = AssemblyManager.LookupTypes($"{type.FullName}`{types.Length}").FirstOrDefault();
147148
if (gtype != null)
148149
{
149150
var g = ClassManager.GetClass(gtype) as GenericType;
Collapse file

‎src/runtime/finalizer.cs‎

Copy file name to clipboardExpand all lines: src/runtime/finalizer.cs
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,9 @@ public IncorrectRefCountException(IntPtr ptr)
6262
}
6363

6464
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
6668
public bool ThrowIfUnhandleIncorrectRefCount { get; set; } = true;
6769

6870
#endregion
Collapse file

‎src/runtime/genericutil.cs‎

Copy file name to clipboardExpand all lines: src/runtime/genericutil.cs
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System.Linq;
12
using System;
23
using System.Collections.Generic;
34
using System.Resources;
@@ -124,7 +125,7 @@ public static List<Type> GenericsByName(string ns, string basename)
124125
foreach (string name in names)
125126
{
126127
string qname = ns + "." + name;
127-
Type o = AssemblyManager.LookupType(qname);
128+
Type o = AssemblyManager.LookupTypes(qname).FirstOrDefault();
128129
if (o != null)
129130
{
130131
result.Add(o);
Collapse file

‎src/runtime/interop.cs‎

Copy file name to clipboardExpand all lines: src/runtime/interop.cs
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ internal static class ManagedDataOffsets
8080

8181
static class DataOffsets
8282
{
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;
8585

8686
static DataOffsets()
8787
{
Collapse file

‎src/testing/eventtest.cs‎

Copy file name to clipboardExpand all lines: src/testing/eventtest.cs
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ namespace Python.Test
88
public delegate void EventHandlerTest(object sender, EventArgsTest e);
99

1010

11+
#pragma warning disable 67 // Unused events, these are only accessed from Python
1112
public class EventTest
1213
{
1314
public static event EventHandlerTest PublicStaticEvent;
@@ -100,6 +101,7 @@ public static void ShutUpCompiler()
100101
e.PrivateEvent += f;
101102
}
102103
}
104+
#pragma warning restore 67
103105

104106

105107
public class EventArgsTest : EventArgs

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.