JetBrains / JetBrains/resharper-unity
Support SerializedObject and SerializedProperty
- Dominant language
- C#
- Stars
- 1.2k
- Forks
- 142
- PR merge metrics
- No merged PRs in 30d
Description
E.g. Given something like
``` csharp
using UnityEngine;
using UnityEditor;
public class MyObject : ScriptableObject
{
public int myInt = 42;
}
public class SerializedProperty : MonoBehaviour
{
void Start ()
{
MyObject obj = ScriptableObject.CreateInstance();
SerializedObject serializedObject = new SerializedObject(obj);
SerializedProperty serializedPropertyMyInt = serializedObject.FindProperty("myInt");
Debug.Log("myInt " + serializedPropertyMyInt.intValue);
}
}
```
- [ ] Create a reference provider for the `"myInt"` string literal to reference the `MyObject.myInt` field, providing find usages + rename support
- [ ] The reference provider would provide a candidate list of available public fields to power code completion in the string literal
- [ ] Flow type information from the property name to the usage of the property, so that the correct accessor is used - if `myInt` is actually a string, then `serializedPropertyMyInt.intValue` will fail. It should suggest `serialisedPropertyMyInt.stringValue`
This is difficult, and would require control flow analysis. The `FindProperty` call would need to know the type of the object passed to `new SerializedObject(obj)`. And the returned `SerializedProperty` would need some "type" information attached.
Contributor guide
Assessment
This issue has not been assessed yet.