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 件 担当者 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 を短くまとめたダイジェスト。