logo SERENITY
Game Systems Foundation
Search Results for

    Show / Hide Table of Contents

    Class AssetFileSnapshot

    One asset file's bytes and timestamp, taken before a test drives code that must not write it, so the test can tell whether it was written — marked dirty, or changed on disk — and put it back exactly as it was when it was. Putting the timestamp back too keeps every assembly's shipped-content residue guard seeing the file as this test found it, so a red run never leaves the package modified.

    Inheritance
    object
    AssetFileSnapshot
    Inherited Members
    object.ToString()
    object.Equals(object)
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    object.GetHashCode()
    object.GetType()
    Namespace: Serenity.Tests.Shared.Editor
    Assembly: Serenity.Tests.Shared.Editor.dll
    Syntax
    public sealed class AssetFileSnapshot

    Properties

    AssetPath

    The project-relative path the snapshot was taken of.

    Declaration
    public string AssetPath { get; }
    Property Value
    Type Description
    string

    BytesChanged

    True when the file on disk no longer holds the bytes this snapshot read.

    Declaration
    public bool BytesChanged { get; }
    Property Value
    Type Description
    bool

    TimestampChanged

    True when the file was rewritten since this snapshot, even with the same bytes.

    Declaration
    public bool TimestampChanged { get; }
    Property Value
    Type Description
    bool

    Methods

    RestoreIfWritten(Object)

    Clears the dirty mark, puts the bytes back, reimports so the loaded object reads them again, and restores the timestamp — only when WasWritten(Object) says there is something to undo.

    Declaration
    public void RestoreIfWritten(Object asset)
    Parameters
    Type Name Description
    Object asset

    Take(string)

    Reads the bytes and the timestamp of the file at assetPath.

    Declaration
    public static AssetFileSnapshot Take(string assetPath)
    Parameters
    Type Name Description
    string assetPath
    Returns
    Type Description
    AssetFileSnapshot

    WasWritten(Object)

    True when asset was marked dirty or its file was rewritten — a change that is only marked is still a write, because the next save of anything persists it, and a save that reproduced the same bytes still touched a file the author never asked to have touched.

    Declaration
    public bool WasWritten(Object asset)
    Parameters
    Type Name Description
    Object asset
    Returns
    Type Description
    bool
    In this article
    © 2026 Serenity. All Rights Reserved