mirror of
https://github.com/knah/VRCMelonAssistant.git
synced 2024-05-18 03:12:18 +12:00
Fix mod list failing to load if mods directory has non-mod dlls
This commit is contained in:
parent
3a9b80afdb
commit
9d453e7419
|
@ -18,6 +18,7 @@ using System.Windows.Navigation;
|
||||||
using Mono.Cecil;
|
using Mono.Cecil;
|
||||||
using VRCMelonAssistant.Libs;
|
using VRCMelonAssistant.Libs;
|
||||||
using static VRCMelonAssistant.Http;
|
using static VRCMelonAssistant.Http;
|
||||||
|
using MessageBox = System.Windows.MessageBox;
|
||||||
using TextBox = System.Windows.Controls.TextBox;
|
using TextBox = System.Windows.Controls.TextBox;
|
||||||
|
|
||||||
namespace VRCMelonAssistant.Pages
|
namespace VRCMelonAssistant.Pages
|
||||||
|
@ -220,12 +221,37 @@ namespace VRCMelonAssistant.Pages
|
||||||
|
|
||||||
private (string ModName, string ModVersion) ExtractModVersions(string dllPath)
|
private (string ModName, string ModVersion) ExtractModVersions(string dllPath)
|
||||||
{
|
{
|
||||||
using var asmdef = AssemblyDefinition.ReadAssembly(dllPath);
|
try
|
||||||
foreach (var attr in asmdef.CustomAttributes)
|
{
|
||||||
if (attr.AttributeType.Name == "MelonInfoAttribute" || attr.AttributeType.Name == "MelonModInfoAttribute")
|
using var asmdef = AssemblyDefinition.ReadAssembly(dllPath);
|
||||||
return ((string) attr.ConstructorArguments[1].Value, (string) attr.ConstructorArguments[2].Value);
|
foreach (var attr in asmdef.CustomAttributes)
|
||||||
|
if (attr.AttributeType.Name == "MelonInfoAttribute" ||
|
||||||
|
attr.AttributeType.Name == "MelonModInfoAttribute")
|
||||||
|
return ((string) attr.ConstructorArguments[1].Value,
|
||||||
|
(string) attr.ConstructorArguments[2].Value);
|
||||||
|
|
||||||
return (null, null);
|
return (null, null);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
var result = MessageBox.Show(
|
||||||
|
$"A mod in {Path.GetFileName(dllPath)} is invalid. Would you like to delete it to avoid this error in the future?",
|
||||||
|
"Invalid mod", MessageBoxButton.YesNo, MessageBoxImage.Warning);
|
||||||
|
|
||||||
|
if (result == MessageBoxResult.Yes)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
File.Delete(dllPath);
|
||||||
|
}
|
||||||
|
catch (Exception ex2)
|
||||||
|
{
|
||||||
|
Utils.ShowErrorMessageBox($"Unable to delete file {dllPath}", ex2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (null, null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task PopulateModsList()
|
public async Task PopulateModsList()
|
||||||
|
|
Loading…
Reference in a new issue