Vixen
dd8b0a81
csharp
public sealed class ImportCache

What the last import of each asset produced.

No guide page documents this yet — the page shows what the code says about itself.

Remarks

This is what resolves the cache key's chicken and egg. The key includes the artefact ids of everything the import depended on — and what it depends on is only known once it has run. So the key is computed from the dependencies the previous import declared: if they have not changed, neither has the answer, and the import is skipped; if any of them has, the key differs and the import runs, declaring a fresh set as it goes.

A newly-declared dependency is therefore respected from the second import onwards, not the first — which is exactly right, because the first import is the one that ran and produced a correct artefact. Every incremental build system reaches this answer; it is worth writing down because it looks like a bug until it is stated.

Tab-separated text, like the GUID index it sits next to. It lives in Library/, so it is never committed and never has to be compatible with anything — and a hundred thousand entries of it are read line by line rather than parsed as one document.

⚠ Every operation is safe to call from more than one thread at once, because ImportAllAsync runs N imports concurrently and each of them both reads the cache — to price its dependencies — and writes its own record into it. A Dictionary`2 read while another thread is resizing it does not throw reliably; it returns wrong answers, which here means a cache key computed from a dependency record that never existed. The lock is uncontended in the common case and the work under it is a hash lookup.

Fields and properties (2)

  • public int Count

    How many assets have a record.

  • public IReadOnlyCollection<ImportRecord> Records

    Every record.

Methods (5)

  • public bool TryGet(AssetId asset, out ImportRecord? record)

    Looks up what an asset's last import produced.

  • public void Set(ImportRecord record)

    Records an import.

  • public bool Forget(AssetId asset)

    Forgets an asset, so its next import runs.

  • public void Save(string path)

    Writes the cache.

  • public bool TryLoad(string path)

    Reads the cache back, if it is there.

Used by (16)

  • BuildPlannerVixen.Editor.Assets
  • ContentTasksVixen.Editor.App
  • DoctorRunnerVixen.Cli
  • EditorContentVixen.Editor.App
  • EditorContentTestsVixen.Editor.App.Tests
  • ImportPipelineVixen.Editor.Assets
  • ImportPipelineTestsVixen.Editor.Assets.Tests
  • LooseContentTestsVixen.Editor.Assets.Tests
  • PlannedProjectVixen.Editor.Assets.Tests
  • ProjectVixen.Cli
  • ProjectMeshSourceVixen.Editor.Assets
  • ProjectSurfaceSourceVixen.Editor.Assets
  • ProjectWorkspaceVixen.Editor.Assets
  • SequentialViewVixen.Editor.Assets
  • SharedImportCacheTestsVixen.Editor.Assets.Tests
  • ViewVixen.Editor.Assets