Skip to content

Add OnlyRead anotation #56

@skyjoe999

Description

@skyjoe999

It would be nice to be able to mark a key/property/field such that it will be set if it exists in a file but will not be written when saving that type to a file.

Take this struct for example:

public struct Angle
{
    [SaveThis]
    public float degrees;
    // [OnlyRead]
    public float radians
    {
        set => degrees = value / 6.283184f * 360f;
        get => degrees * 6.283184f / 360f;
    }
}

If you are loading a file and the entry has radians: 3.141592 it should set the radians property (and by extension the degrees field) properly. But when saving a file there is no need to have both written. So by tagging radians with [OnlyRead] it would be set when reading but not written when saving.

It would also be useful for updating an existing type and want to mark an old field as obsolete. You wouldn't want to save that data when saving but you may still want to read it for backwards compatibility reasons.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions