public static class MetaScannerReads a .meta file's envelope and stops.
No guide page documents this yet — the page shows what the code says about itself.
Remarks
This is why the schema puts the envelope first. [08](../../../docs/plan/08-asset-pipeline-and-addressables.md) budgets a GUID index rebuild of a hundred thousand assets at under ten seconds. Parsing a hundred thousand complete documents does not fit in that; reading the first few lines of each does, and the importer's settings block — which is most of the file and all of the work — is never touched.
So this is a line scanner rather than the YAML parser, and it can be because it is looking at a fixed, known prefix of a file this repository also writes: three top-level keys, in order, no anchors, no flow at the root. Anything it cannot make sense of it declines, and the caller falls back to a full parse — a wrong answer here would be a corrupt index, so it says "no" rather than guessing.
⚠ Taking the first match is only safe because a document may not state a key twice. Scanning stops at the first metaVersion: and YamlReader used to take the last, so a merge artefact carrying two of them made the two readers of one format disagree about the version an asset compiles under — 11 against 1, on 142 bytes, found by Vixen.Fuzz's meta target. The refusal lives in the reader because it is the one that parses; what this scanner owes in exchange is to keep reading top-down, so that "the first" and "the only" are the same answer.
⚠ The keys are matched case-insensitively, and matching them ordinally was the same class of disagreement in a different place. YamlSerializer binds members case-insensitively, so a document saying MetaVersion: 5 gave 0 from this scanner and 5 from the parser — the index would file the asset at version zero and the compiler would build it at five. The fix belongs here rather than at the reader: refusing keys that differ only in case would false-refuse a legitimate extensions map carrying both Foo and foo, which is a document nobody wrote by mistake.
Methods (2)
public static bool TryScan(ReadOnlySpan<char> text, out MetaEnvelope envelope)Reads the envelope out of a document.
public static bool TryScanFile(string path, out MetaEnvelope envelope)Reads the envelope out of a file.
Used by (3)
- AssetMetaTargetVixen.Fuzz
- MetaTestsVixen.Core.Yaml.Tests
- AssetDatabaseVixen.Editor.Core