Skip to content

Disable UNT0039 in Reset methods #453

@sailro

Description

@sailro

Copied from microsoft/vscode-dotnettools#2827 cc @BarionLP

Describe the feature you'd like
i have this pattern where i expose a field in the editor and use the Reset method to populate it with a default reference, e.g. like this:

[SerializeField] private MyComponent component;

void Reset()
{
    component = GetComponent<MyComponent>();
}

this way i have the option to use a different one without having to assign the field every time

unfortunately this will trigger UNT0039 telling me to use RequireComponentAttribute.
It would be nice to disable that rule in this case

Alternatives considered
people probably do other things with GetComponent in Reset so the rule could only be disabled when no members of the result are used

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions