浏览代码

Fixes #4228. Init crashes if there are assemblies that have load issues (#4230)

BDisp 1 周之前
父节点
当前提交
1a0f5a88b7
共有 1 个文件被更改,包括 7 次插入6 次删除
  1. 7 6
      Terminal.Gui/App/Application.Initialization.cs

+ 7 - 6
Terminal.Gui/App/Application.Initialization.cs

@@ -212,14 +212,15 @@ public static partial class Application // Initialization (Init/Shutdown)
         // use reflection to get the list of drivers
         List<Type?> driverTypes = new ();
 
-        foreach (Assembly asm in AppDomain.CurrentDomain.GetAssemblies ())
+        // Only inspect the IConsoleDriver assembly
+        var asm = typeof (IConsoleDriver).Assembly;
+
+        foreach (Type? type in asm.GetTypes ())
         {
-            foreach (Type? type in asm.GetTypes ())
+            if (typeof (IConsoleDriver).IsAssignableFrom (type) &&
+                type is { IsAbstract: false, IsClass: true })
             {
-                if (typeof (IConsoleDriver).IsAssignableFrom (type) && !type.IsAbstract && type.IsClass)
-                {
-                    driverTypes.Add (type);
-                }
+                driverTypes.Add (type);
             }
         }