From 5ff6d5f2a456263400808e8686dc8902a0df1326 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Fri, 29 Aug 2025 06:53:56 +1000 Subject: [PATCH] mono: Prefer trying to load portable PDBs generated by the modern roslyn compiler --- MCGalaxy/Scripting/Scripting.cs | 40 +++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/MCGalaxy/Scripting/Scripting.cs b/MCGalaxy/Scripting/Scripting.cs index beba77d11..4b6d4c96b 100644 --- a/MCGalaxy/Scripting/Scripting.cs +++ b/MCGalaxy/Scripting/Scripting.cs @@ -51,7 +51,7 @@ namespace MCGalaxy.Scripting } // only used for resolving plugin DLLs depending on other plugin DLLs - static Assembly ResolvePluginAssembly(object sender, ResolveEventArgs args) { + static Assembly ResolvePluginAssembly(object sender, ResolveEventArgs args) { #if !NET_20 // This property only exists in .NET framework 4.0 and later Assembly requestingAssembly = args.RequestingAssembly; @@ -65,11 +65,11 @@ namespace MCGalaxy.Scripting if (!IsPluginDLL(assem)) continue; if (args.Name == assem.FullName) return assem; - } - - Assembly coreRef = DotNetBackend.ResolvePluginReference(args.Name); - if (coreRef != null) return coreRef; - + } + + Assembly coreRef = DotNetBackend.ResolvePluginReference(args.Name); + if (coreRef != null) return coreRef; + Logger.Log(LogType.Warning, "Custom command/plugin [{0}] tried to load [{1}], but it could not be found", requestingAssembly.FullName, args.Name); #endif @@ -106,21 +106,27 @@ namespace MCGalaxy.Scripting } static byte[] GetDebugData(string path) { - if (Server.RunningOnMono()) { - // Cmdtest.dll -> Cmdtest.dll.mdb - path += ".mdb"; - } else { - // Cmdtest.dll -> Cmdtest.pdb - path = Path.ChangeExtension(path, ".pdb"); - } - - if (!File.Exists(path)) return null; + // Cmdtest.dll -> Cmdtest.pdb + string pdb_path = Path.ChangeExtension(path, ".pdb"); try { - return File.ReadAllBytes(path); + return File.ReadAllBytes(pdb_path); + } catch (FileNotFoundException) { } catch (Exception ex) { - Logger.LogError("Error loading .pdb " + path, ex); + Logger.LogError("Error loading .pdb " + pdb_path, ex); return null; } + + if (!Server.RunningOnMono()) return null; + + // Cmdtest.dll -> Cmdtest.dll.mdb + string mdb_path = path + ".mdb"; + try { + return File.ReadAllBytes(mdb_path); + } catch (FileNotFoundException) { + } catch (Exception ex) { + Logger.LogError("Error loading .mdb " + mdb_path, ex); + } + return null; }