mono: Prefer trying to load portable PDBs generated by the modern roslyn compiler

This commit is contained in:
UnknownShadow200 2025-08-29 06:53:56 +10:00
parent f576adabd1
commit 5ff6d5f2a4

View File

@ -51,7 +51,7 @@ namespace MCGalaxy.Scripting
} }
// only used for resolving plugin DLLs depending on other plugin DLLs // 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 #if !NET_20
// This property only exists in .NET framework 4.0 and later // This property only exists in .NET framework 4.0 and later
Assembly requestingAssembly = args.RequestingAssembly; Assembly requestingAssembly = args.RequestingAssembly;
@ -65,11 +65,11 @@ namespace MCGalaxy.Scripting
if (!IsPluginDLL(assem)) continue; if (!IsPluginDLL(assem)) continue;
if (args.Name == assem.FullName) return assem; if (args.Name == assem.FullName) return assem;
} }
Assembly coreRef = DotNetBackend.ResolvePluginReference(args.Name); Assembly coreRef = DotNetBackend.ResolvePluginReference(args.Name);
if (coreRef != null) return coreRef; if (coreRef != null) return coreRef;
Logger.Log(LogType.Warning, "Custom command/plugin [{0}] tried to load [{1}], but it could not be found", Logger.Log(LogType.Warning, "Custom command/plugin [{0}] tried to load [{1}], but it could not be found",
requestingAssembly.FullName, args.Name); requestingAssembly.FullName, args.Name);
#endif #endif
@ -106,21 +106,27 @@ namespace MCGalaxy.Scripting
} }
static byte[] GetDebugData(string path) { static byte[] GetDebugData(string path) {
if (Server.RunningOnMono()) { // Cmdtest.dll -> Cmdtest.pdb
// Cmdtest.dll -> Cmdtest.dll.mdb string pdb_path = Path.ChangeExtension(path, ".pdb");
path += ".mdb";
} else {
// Cmdtest.dll -> Cmdtest.pdb
path = Path.ChangeExtension(path, ".pdb");
}
if (!File.Exists(path)) return null;
try { try {
return File.ReadAllBytes(path); return File.ReadAllBytes(pdb_path);
} catch (FileNotFoundException) {
} catch (Exception ex) { } catch (Exception ex) {
Logger.LogError("Error loading .pdb " + path, ex); Logger.LogError("Error loading .pdb " + pdb_path, ex);
return null; 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;
} }