Use TryParseAssemblyName wherever possible

Rebase of 911375a
This commit is contained in:
Bepis committed 2020-11-06 11:47:04 +11:00
1 parent a3e7b0edf6
commit eda196fda8
4 files changed
+12 -17

No files matched your search

@@ -250,19 +250,6 @@ namespace BepInEx.Preloader.Core
PatcherPlugins.Clear();
}
private static string GetAssemblyName(string fullName)
{
// We need to manually parse full name to avoid issues with encoding on mono
try
{
return new AssemblyName(fullName).Name;
}
catch (Exception)
{
return fullName;
}
}
/// <summary>
/// Applies patchers to all assemblies in the given directory and loads patched assemblies into memory.
/// </summary>
@@ -316,7 +303,8 @@ namespace BepInEx.Preloader.Core
foreach (var resolvedAss in AppDomain.CurrentDomain.GetAssemblies())
{
var name = GetAssemblyName(resolvedAss.FullName);
var name = Utility.TryParseAssemblyName(resolvedAss.FullName, out var assName) ? assName.Name : resolvedAss.FullName;
// Report only the first type that caused the assembly to load, because any subsequent ones can be false positives
if (!resolvedAssemblies.ContainsKey(name))
resolvedAssemblies[name] = assemblyPatcher.TypeName;