alttester / alttester/AltTester-Unity-SDK

Setting a nested property results in error: Unable to cast object of type 'RuntimePropertyInfo' to type 'FieldInfo'

未关闭
#834 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
gitlab no version triaged
主要语言
C#
星标
121
派生
24
PR 合并指标
30 天内没有已合并 PR

描述

Setting a nested property results in error.

Scenario: Call set_component_property(component_name, 'field.Property.Property', value)

Recursively assigning values from the innermost property, AltUnity ignores the possibility of the intermediate property being of type RuntimePropertyInfo, and therefore ends up casting it to FieldInfo which results in the following error:

```
altunityrunner.altUnityExceptions.UnknownErrorException: error:unknownError
Unable to cast object of type 'RuntimePropertyInfo' to type 'FieldInfo'.
```

Code block that causes the issue:
```
AltUnityReflectionMethodsCommand.cs:setValueRecursive()

if (memberInfo.GetType().Equals(typeof(PropertyInfo)))
{
((PropertyInfo)memberInfo).SetValue(instance, valueObtained);
}
else
{
((FieldInfo)memberInfo).SetValue(instance, valueObtained);
}
```

---
You can find the original issue from GitLab [here](https://gitlab.com/altom/altunity/altunitytester/-/issues/857).

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。