alttester / alttester/AltTester-Unity-SDK

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

Offen
#834 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
gitlab no version triaged
Vorherrschende Sprache
C#
Sterne
121
Forks
24
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

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).

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.