From 7b5c912ebd5728849c97eba0205001702cd789ba Mon Sep 17 00:00:00 2001 From: Mikhail <99481254+DCFApixels@users.noreply.github.com> Date: Tue, 13 Jun 2023 15:55:44 +0800 Subject: [PATCH] add inject null check --- src/Builtin/InjectSystem.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Builtin/InjectSystem.cs b/src/Builtin/InjectSystem.cs index 2663a20..6ecfa92 100644 --- a/src/Builtin/InjectSystem.cs +++ b/src/Builtin/InjectSystem.cs @@ -2,6 +2,7 @@ using DCFApixels.DragonECS.RunnersCore; using System; using System.Linq; +using System.Runtime.CompilerServices; namespace DCFApixels.DragonECS { @@ -58,9 +59,12 @@ namespace DCFApixels.DragonECS private EcsBaseTypeInjectRunner _baseTypeInjectRunner; void IEcsInject.Inject(T obj) { + if (obj == null) ThrowArgumentNullException(); _baseTypeInjectRunner.Inject(obj); foreach (var item in targets) item.Inject(obj); } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + private void ThrowArgumentNullException() => throw new ArgumentNullException(); protected override void OnSetup() { Type baseType = typeof(T).BaseType;