From 1651e9988a1aba724246feff56302c03d1b5c0f0 Mon Sep 17 00:00:00 2001 From: Tobey Blaber Date: Sat, 8 Apr 2023 17:38:45 +0100 Subject: [PATCH] bugfix: ignore non-.NET assemblies --- Patcher/Patcher.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Patcher/Patcher.cs b/Patcher/Patcher.cs index 451c51f..a4c891b 100644 --- a/Patcher/Patcher.cs +++ b/Patcher/Patcher.cs @@ -103,7 +103,17 @@ private static bool HasUnityAudioReferences() .Distinct() .Where(path => excludedAssemblyPrefixes.All(prefix => !Path.GetFileNameWithoutExtension(path).StartsWith(prefix))) .Where(path => ExcludedAssemblies.All(assembly => Path.GetFileNameWithoutExtension(assembly) != Path.GetFileNameWithoutExtension(path))) - .SelectMany(path => AssemblyDefinition.ReadAssembly(path).Modules) + .SelectMany(path => + { + try + { + return AssemblyDefinition.ReadAssembly(path).Modules; + } + catch + { // if we couldn't read the assembly it's probably not a .NET assembly anyway, so just ignore it + return Enumerable.Empty(); + } + }) .SelectMany(module => module.GetTypeReferences()) .Select(typeRef => typeRef.FullName) .Any(typeRefName => typeRefName.StartsWith("UnityEngine.Audio") || AdditionalTypeNames.Contains(typeRefName));