Skip to content

Commit

Permalink
bugfix: ignore non-.NET assemblies
Browse files Browse the repository at this point in the history
  • Loading branch information
toebeann committed Apr 8, 2023
1 parent 3dfd18b commit 1651e99
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion Patcher/Patcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<ModuleDefinition>();
}
})
.SelectMany(module => module.GetTypeReferences())
.Select(typeRef => typeRef.FullName)
.Any(typeRefName => typeRefName.StartsWith("UnityEngine.Audio") || AdditionalTypeNames.Contains(typeRefName));
Expand Down

0 comments on commit 1651e99

Please sign in to comment.