From 090dbc9c5af608ecf77ecf0387f5986163575368 Mon Sep 17 00:00:00 2001
From: labbbirder <502100554@qq.com>
Date: Mon, 1 Apr 2024 18:45:47 +0800
Subject: [PATCH] chore: update dependency dra
---
Runtime/ClassicalUsages/DecoratorAttribute.cs | 4 +--
Runtime/ClassicalUsages/SimpleDIAttribute.cs | 28 +++++++++----------
Runtime/FixHelper.cs | 2 +-
package.json | 2 +-
4 files changed, 18 insertions(+), 18 deletions(-)
diff --git a/Runtime/ClassicalUsages/DecoratorAttribute.cs b/Runtime/ClassicalUsages/DecoratorAttribute.cs
index c0a1ac0..8a78b06 100644
--- a/Runtime/ClassicalUsages/DecoratorAttribute.cs
+++ b/Runtime/ClassicalUsages/DecoratorAttribute.cs
@@ -21,11 +21,11 @@ public abstract partial class DecoratorAttribute : InjectionAttribute
///
///
public bool IsAsyncMethod
- => m_IsAsyncMethod ??= targetMember.GetCustomAttribute() != null;
+ => m_IsAsyncMethod ??= targetInfo.GetCustomAttribute() != null;
public override IEnumerable ProvideInjections()
{
- var InjectedMethod = this.targetMember as MethodInfo;
+ var InjectedMethod = this.targetInfo as MethodInfo;
var OriginSavingField = ThisType.GetField(nameof(originFunc), BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static);
var OriginSavingTarget = this;
diff --git a/Runtime/ClassicalUsages/SimpleDIAttribute.cs b/Runtime/ClassicalUsages/SimpleDIAttribute.cs
index c0a8e5d..b2d92a1 100644
--- a/Runtime/ClassicalUsages/SimpleDIAttribute.cs
+++ b/Runtime/ClassicalUsages/SimpleDIAttribute.cs
@@ -95,11 +95,11 @@ public override IEnumerable ProvideInjections()
s_MetaMethodInfo ??= typeof(SimpleDIAttribute).GetMethod(nameof(MetaGet), Static | NonPublic);
s_StaticMetaMethodInfo ??= typeof(SimpleDIAttribute).GetMethod(nameof(StaticMetaGet), Static | NonPublic);
s_miMetaConstructor ??= typeof(SimpleDIAttribute).GetMethod(nameof(MetaConstructor), Static | NonPublic);
- if (targetMember is not PropertyInfo and not FieldInfo)
- throw new Exception($"cannot inject {targetMember} on type {targetType}, only fields and properties allowed");
- var memberType = GetMemberType(targetMember);
- var isStatic = IsStatic(targetMember);
- var canWrite = CanWrite(targetMember);
+ if (targetInfo is not PropertyInfo and not FieldInfo)
+ throw new Exception($"cannot inject {targetInfo} on type {targetInfo.DeclaringType}, only fields and properties allowed");
+ var memberType = GetMemberType(targetInfo);
+ var isStatic = IsStatic(targetInfo);
+ var canWrite = CanWrite(targetInfo);
// var declaringType = targetMember.DeclaringType;
if (isStatic)
{
@@ -108,14 +108,14 @@ public override IEnumerable ProvideInjections()
// set on fix instantly
yield return InjectionInfo.Create(() =>
{
- SetMemberValue(targetMember, null, GetContainerInst(memberType, targetType));
+ SetMemberValue(targetInfo, null, GetContainerInst(memberType, targetInfo.DeclaringType));
});
}
else
{
// inject get method
- var propertyInfo = targetMember as PropertyInfo;
- var fixingMethod = s_StaticMetaMethodInfo.MakeGenericMethod(propertyInfo.PropertyType, targetType);
+ var propertyInfo = targetInfo as PropertyInfo;
+ var fixingMethod = s_StaticMetaMethodInfo.MakeGenericMethod(propertyInfo.PropertyType, targetInfo.DeclaringType);
yield return InjectionInfo.Create(
propertyInfo.GetGetMethod(nonPublic: true),
fixingMethod
@@ -127,13 +127,13 @@ public override IEnumerable ProvideInjections()
if (canWrite)
{
// inject constructor
- var constructors = Get_Ctors(targetType);
+ var constructors = Get_Ctors(targetInfo.DeclaringType);
var argtypes = new List();
foreach (var constructor in constructors)
{
Delegate rawAction = default;
argtypes.Clear();
- argtypes.Add(targetType);
+ argtypes.Add(targetInfo.DeclaringType);
foreach (var p in constructor.GetParameters())
{
argtypes.Add(p.ParameterType);
@@ -150,7 +150,7 @@ public override IEnumerable ProvideInjections()
}
var miCtorInst = s_miMetaConstructor.MakeGenericMethod(miInstAction);
var fixingFunc = miCtorInst.Invoke(null, new object[]{
- (Action