1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-13 14:12:56 +08:00

Merge pull request #9725 from smoogipoo/fix-dynamic-ruleset-load

This commit is contained in:
Dean Herbert 2020-07-31 16:51:46 +09:00 committed by GitHub
commit 533be74a38
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -65,11 +65,15 @@ namespace osu.Game.Rulesets
// the requesting assembly may be located out of the executable's base directory, thus requiring manual resolving of its dependencies.
// this attempts resolving the ruleset dependencies on game core and framework assemblies by returning assemblies with the same assembly name
// already loaded in the AppDomain.
foreach (var curAsm in AppDomain.CurrentDomain.GetAssemblies())
{
if (asm.Name.Equals(curAsm.GetName().Name, StringComparison.Ordinal))
return curAsm;
}
var domainAssembly = AppDomain.CurrentDomain.GetAssemblies()
// Given name is always going to be equally-or-more qualified than the assembly name.
.Where(a => args.Name.Contains(a.GetName().Name, StringComparison.Ordinal))
// Pick the greatest assembly version.
.OrderByDescending(a => a.GetName().Version)
.FirstOrDefault();
if (domainAssembly != null)
return domainAssembly;
return loadedAssemblies.Keys.FirstOrDefault(a => a.FullName == asm.FullName);
}