Skip to content

Commit

Permalink
Fixed Dependency Graph Assembly Resolving
Browse files Browse the repository at this point in the history
  • Loading branch information
HerpDerpinstine committed Sep 12, 2024
1 parent 2177062 commit 679d468
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion MelonLoader/InternalUtils/DependencyGraph.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ private DependencyGraph(IList<T> melons)
dependencyVertex.dependents.Add(melonVertex);
}
else if (!TryLoad(dependency)
&& !TryResolve(dependency)
&& !optionalDependencies.Contains(dependency.Name)
&& !missingDependencies.Contains(dependency))
missingDependencies.Add(dependency);
Expand All @@ -116,6 +117,7 @@ private DependencyGraph(IList<T> melons)
dependencyVertex.dependents.Add(melonVertex);
}
else if (!TryLoad(dependency)
&& !TryResolve(dependency)
&& !missingDependencies.Contains(dependency))
missingDependencies.Add(dependency);
}
Expand All @@ -140,6 +142,24 @@ private DependencyGraph(IList<T> melons)

// Returns true if 'assembly' was already loaded or could be loaded, false if the required assembly was missing.
private static bool TryLoad(AssemblyName assembly)
{
try
{
Assembly asm = Assembly.Load(assembly);
if (asm == null)
return false;
return true;
}
catch (FileNotFoundException) { return false; }
catch (Exception ex)
{
MelonLogger.Error("Loading Melon Dependency Failed: " + ex);
return false;
}
}

// Returns true if 'assembly' was already resolved or could be resolved, false if the required assembly was missing.
private static bool TryResolve(AssemblyName assembly)
{
try
{
Expand All @@ -155,7 +175,7 @@ private static bool TryLoad(AssemblyName assembly)
catch (FileNotFoundException) { return false; }
catch (Exception ex)
{
MelonLogger.Error("Loading Melon Dependency Failed: " + ex);
MelonLogger.Error("Resolving Melon Dependency Failed: " + ex);
return false;
}
}
Expand Down

0 comments on commit 679d468

Please sign in to comment.