Home > OS >  File Layout: Matching field targeted attributes on auto-properties
File Layout: Matching field targeted attributes on auto-properties

Time:04-07

In newer versions of Unity you can serialize the backing fields of properties via this pattern:

[field: SerializeField]
public Sprite Sprite { get; private set; }

Is there any way to specifically match on properties that have field targeted attributes in the File Layout settings of Rider? I've tried a few different things but none of them seem to result in a match:

<Entry DisplayName="Serialized Properties" Priority="150">
    <Entry.Match>
        <And>
            <unity:SerializedField/>
            <Kind Is="Autoproperty" />
        </And>
    </Entry.Match>
</Entry>

<Entry DisplayName="Serialized Properties" Priority="150">
    <Entry.Match>
        <And>
            <HasAttribute Name="SerializeField"/>
            <Kind Is="Autoproperty" />
        </And>
    </Entry.Match>
</Entry>

<Entry DisplayName="Serialized Properties" Priority="150">
    <Entry.Match>
        <And>
            <HasAttribute Name="field: SerializeField"/>
            <Kind Is="Autoproperty" />
        </And>
    </Entry.Match>
</Entry>

CodePudding user response:

As of Rider 2022.1, the File Layout settings don't have a way of matching an auto property with a field: targeted attribute - the HasAttribute element will only match attributes that target the property itself. Here's an issue you can vote for and track: RSRP-488346.

  • Related