Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitbd264cf

Browse files
authored
Fix or disable warnings in Python.Runtime (#1318)
The only tricky one here is the `LookupType` obsoletion, since we arestill not handling name conflicts.
1 parentd2685a1 commitbd264cf

File tree

7 files changed

+23
-27
lines changed

7 files changed

+23
-27
lines changed

‎src/runtime/BorrowedReference.cs

Lines 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
publicstaticbooloperator!=(BorrowedReferencea,BorrowedReferenceb)
2929
=>a.pointer!=b.pointer;
30+
31+
publicoverrideboolEquals(objectobj){
32+
if(objisIntPtrptr)
33+
returnptr==pointer;
34+
35+
returnfalse;
36+
}
37+
38+
publicoverrideintGetHashCode()=>pointer.GetHashCode();
3039
}
3140
}

‎src/runtime/assemblymanager.cs

Lines 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
privatestaticConcurrentDictionary<string,ConcurrentDictionary<Assembly,string>>namespaces=
@@ -365,25 +365,6 @@ public static List<string> GetNames(string nsname)
365365
returnnames;
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-
publicstaticTypeLookupType(stringqname)
375-
{
376-
foreach(Assemblyassemblyinassemblies)
377-
{
378-
Typetype=assembly.GetType(qname);
379-
if(type!=null&&IsExported(type))
380-
{
381-
returntype;
382-
}
383-
}
384-
returnnull;
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

‎src/runtime/classobject.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
usingSystem.Linq;
12
usingSystem;
23
usingSystem.Reflection;
34

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

146-
Typegtype=AssemblyManager.LookupType($"{type.FullName}`{types.Length}");
147+
Typegtype=AssemblyManager.LookupTypes($"{type.FullName}`{types.Length}").FirstOrDefault();
147148
if(gtype!=null)
148149
{
149150
varg=ClassManager.GetClass(gtype)asGenericType;

‎src/runtime/finalizer.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,9 @@ public IncorrectRefCountException(IntPtr ptr)
6262
}
6363

6464
publicdelegateboolIncorrectRefCntHandler(objectsender,IncorrectFinalizeArgse);
65-
publiceventIncorrectRefCntHandlerIncorrectRefCntResolver;
65+
#pragma warning disable414
66+
publiceventIncorrectRefCntHandlerIncorrectRefCntResolver=null;
67+
#pragma warning restore414
6668
publicboolThrowIfUnhandleIncorrectRefCount{get;set;}=true;
6769

6870
#endregion

‎src/runtime/genericutil.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
usingSystem.Linq;
12
usingSystem;
23
usingSystem.Collections.Generic;
34
usingSystem.Resources;
@@ -124,7 +125,7 @@ public static List<Type> GenericsByName(string ns, string basename)
124125
foreach(stringnameinnames)
125126
{
126127
stringqname=ns+"."+name;
127-
Typeo=AssemblyManager.LookupType(qname);
128+
Typeo=AssemblyManager.LookupTypes(qname).FirstOrDefault();
128129
if(o!=null)
129130
{
130131
result.Add(o);

‎src/runtime/interop.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ internal static class ManagedDataOffsets
8080

8181
staticclassDataOffsets
8282
{
83-
publicstaticreadonlyintob_data;
84-
publicstaticreadonlyintob_dict;
83+
publicstaticreadonlyintob_data=0;
84+
publicstaticreadonlyintob_dict=0;
8585

8686
staticDataOffsets()
8787
{

‎src/testing/eventtest.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ namespace Python.Test
88
publicdelegatevoidEventHandlerTest(objectsender,EventArgsTeste);
99

1010

11+
#pragma warning disable67// Unused events, these are only accessed from Python
1112
publicclassEventTest
1213
{
1314
publicstaticeventEventHandlerTestPublicStaticEvent;
@@ -100,6 +101,7 @@ public static void ShutUpCompiler()
100101
e.PrivateEvent+=f;
101102
}
102103
}
104+
#pragma warning restore67
103105

104106

105107
publicclassEventArgsTest:EventArgs

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp