Skip to content

Commit

Permalink
fix: check null for injected method
Browse files Browse the repository at this point in the history
  • Loading branch information
labbbirder committed Sep 27, 2023
1 parent 835d6d5 commit 191b012
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions Editor/InjectHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ internal static bool InjectAssembly(InjectionInfo[] injections, string inputAsse
foreach (var group in injections.GroupBy(inj=>inj.InjectedMethod))
{
var injectedMethod = group.Key;
if(injectedMethod is null) continue;
var type = injectedMethod.DeclaringType;
var methodName = injectedMethod.Name;
var targetType = GetCorrespondingType(targetAssembly.MainModule, type);
Expand Down
6 changes: 5 additions & 1 deletion Editor/UnityInjectUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,12 @@ public static void InjectEditor(Assembly[] assemblies)
var allInjections = FixHelper.allInjections;
var freshInjections = FixHelper.GetAllInjections(assemblies);
var freshAssemblies = freshInjections
.Where(inj=>inj.InjectedMethod != null)
.Select(inj => inj.InjectedMethod.DeclaringType.Assembly)
.Distinct().
ToHashSet();
var outcomeInjections = allInjections
.Where(inj=>inj.InjectedMethod != null)
.Where(inj => freshAssemblies.Contains(inj.InjectedMethod.DeclaringType.Assembly))
.ToArray();
Debug.Log($"auto inject {allInjections.Length} injections, {outcomeInjections.Length} to inject");
Expand All @@ -139,7 +141,9 @@ public static void InjectRuntime()

static bool InjectTargetMode(InjectionInfo[] injections, bool isEditor, BuildTarget buildTarget)
{
var group = injections.GroupBy(inj => inj.InjectedMethod.DeclaringType.Assembly);
var group = injections
.Where(inj=>inj.InjectedMethod != null)
.GroupBy(inj => inj.InjectedMethod.DeclaringType.Assembly);
var isWritten = false;
foreach (var g in group)
{
Expand Down

0 comments on commit 191b012

Please sign in to comment.