Skip to content
SheetForge

Types and grammar

This page lists the Core types that read and write cell text: custom cell types, the sheet grammar constants, asset references, and the visual value types. Every type on this page is in the SheetForge.Core.Model namespace.

Custom cell types

These types let a plugin add a cell type, a wrapper type or a marker row.

TypeRole
ICellValueParserParses one scalar cell
ICustomCellTypeOptional helper for codegen and the round trip
IReferencingCellTypeOpt-in capability for a parser whose notation holds a key
IRefBearingValueThe value-side half of IReferencingCellType
ICellWrapperTypeA generic wrapper value shape, MyWrapper<T>
WrapperValueThe parsed intermediate representation (IR) of a wrapper cell
IStructuralMarkerDefinitionA custom @marker row
MarkerCellContextOne marker-cell validation call
CellParseContextThe context of one parse call

To write a cell type step by step, see Enums and cell types.

ICellValueParser

Parses one scalar cell.

  • string TypeName
  • bool TryParse(CellParseContext, string, out object)

On failure, collect the error into context.Errors and return false. Never throw.

ICustomCellType

An optional helper for codegen and the round trip.

  • Type ValueType
  • bool TryRender(object, out string text, out string reason)

IReferencingCellType

An opt-in capability that a registered ICellValueParser may also implement. With it, a key buried in the parser's own notation gets the full RecordId@Tab treatment:

  • Integrity checks and suggestions
  • Key-rename propagation, with the payload preserved
  • Graph edges and ports
  • The ▾ picker
  • Orphan detection (records that nothing references)
  • Exported dropdown rules

The Core finds the capability by casting the registered parser. There is no separate registration.

Members:

  • bool TryGetTokenKey(elementText, out key)
  • string MakeToken(key)
  • bool TryRetargetToken(elementText, newKey, out newText)
  • bool TryRemoveToken(elementText, key, out newText). An empty result means the element disappears.
  • bool TryRewriteKeys(elementText, IReadOnlyDictionary<string,string> renames, out newText)

Rules:

  • One call handles one element. An element is the whole cell, or one ;-separated element.
  • A payload may not contain ;.
  • @target must name a real sheet tab. Otherwise the error is UnknownTargetTab.
  • The members never throw. false or null means "cannot interpret".
  • Rewrites preserve the rest of the element's text.

Reference parity shows how to implement the capability.

IRefBearingValue

The value-side half of IReferencingCellType. The parsed value implements it.

  • IEnumerable<string> ReferencedKeys

Declaration order is the order of diagnostics, and the order in which the suggestion budget is spent. Null and empty entries are skipped.

Both halves are needed. The scanner reads IRefBearingValue, and the text hooks of IReferencingCellType rewrite the cell. A parsed value cannot restore the author's notation, and text cannot be validated without being read.

ICellWrapperType

A generic wrapper value shape, MyWrapper<T>. For example, Pair<int> is written 1~2. The wrapper owns the outer syntax, and the Core parses the inner type recursively.

  • string Name
  • bool TrySplit(string, out IReadOnlyList<string> pieces, out string reason)
  • string JoinCanonical(IReadOnlyList<string>)
  • Type OpenClrType
  • object Assemble(IReadOnlyList<object>, Type closed)
  • bool TryDisassemble(object, out IReadOnlyList<object>, out string reason)

WrapperValue

The parsed IR of a wrapper cell. It carries the wrapper strategy and exposes the inner CellValues. References inside a wrapper therefore pass through validation, key and tab rename, and Export.

  • ICellWrapperType Wrapper
  • IReadOnlyList<CellValue> Inner

IStructuralMarkerDefinition

A custom @marker row. The row holds per-column values and is validated column by column. It generalizes @overlap.

  • string MarkerName, without the @
  • string Description
  • void ValidateCell(MarkerCellContext)

MarkerCellContext

One marker-cell validation call.

  • string MarkerName
  • string RawText
  • string FieldName
  • CellCoordinate Coordinate
  • void Reject(string reason, string suggestion = null). A rejection produces MarkerCellInvalid.

CellParseContext

The context of one parse call.

  • TypeToken Type
  • CellCoordinate Coordinate
  • ErrorCollector Errors
  • EnumRegistry Enums

Sheet grammar constants

A plugin that reads or writes cell text works in the same grammar the importer does. It splits a list cell, composes an @type string, or checks whether a name is already taken.

TypeKindRole
SheetSyntaxstatic classThe sheet grammar as constants

These constants are the grammar's single source of truth. Use them instead of copying a separator into your plugin, because a copied character goes out of date when the grammar changes.

The lists are handed out read-only, so nothing a plugin does can change the grammar itself.

Sheet syntax documents the notation in full. SheetSyntax is the programmatic handle on it.

Markers

ConstantHolds
CommentPrefix#
MarkerPrefix@
RequiredMarkersThe three markers every sheet must carry
ReservedMarkersEvery built-in marker name

Each built-in marker row has its own constant: NameMarker, TypeMarker, DescMarker, OverlapMarker, StyleMarker, EnumMarker and LocMarker.

Read ReservedMarkers before you name a custom marker. A collision is refused at registration.

Separators

ListSeparator (;) separates list elements.

These constants separate the layers inside one value:

  • EntrySeparator (,)
  • FieldSeparator (:)
  • SectionSeparator (|)
  • KeyTimeSeparator (@)

Because those layers have separators of their own, ; never appears in a value's own text.

StyleKeyValueSeparator (=) is used inside a @style cell.

Type notation

These constants spell the @type notation:

  • OptionalSuffix (?)
  • DefaultSeparator (=)
  • TargetSeparator (@, as in RecordId@Tab)
  • ListTypeName
  • ListOpen (List<)
  • ListClose (>)

Type names

Each built-in type name has its own constant: IntTypeName, FloatTypeName, BoolTypeName, StringTypeName, RecordIdTypeName, IntIdTypeName, AssetRefTypeName, ResourceRefTypeName, DirectRefTypeName, LocRefTypeName, ColorTypeName, AnimationCurveTypeName, GradientTypeName and EnumTypeName.

BuiltinScalarTypes and IsBuiltinScalarTypeName(name) tell whether a name is already a built-in. Check a name with them before you register a parser under it.

DeliveryGatedTypeNames lists the built-in cell types whose use depends on the delivery mode: AssetRef and ResourceRef.

Name lists

ConstantHolds
StyleKeyNamestitle, color
LocReservedColumnssmart, comment

Values

TrueCanonical and FalseCanonical hold the canonical bool text.

NumberCellStyles is the NumberStyles SheetForge reads every numeric cell with. Thousands separators are excluded, and the culture is always InvariantCulture. A decimal comma from a locale therefore fails to parse instead of silently changing a number.

Typed asset references

The <Type> in AssetRef@Group<Type>, ResourceRef<Type> and DirectRef<Type> is resolved by the host.

The Core knows neither the engine nor the project's assemblies. It only judges the result. Everything here is pure data.

TypeKindRole
IAssetTypeResolverinterfaceResolves one type name to one verdict
AssetTypeResolutionsealed classThe verdict for one name
AssetTypeResolutionStatusenumThe status of a verdict

IAssetTypeResolver

  • AssetTypeResolution Resolve(string rawName)

One name goes in and one verdict comes out. The same name always gets the same answer, so implementations may cache.

The resolver is injected into ImportPipeline separately from AssetKeyIndex. Type names are therefore resolved even in a project that has no Addressables settings yet.

When no resolver is injected, as in a headless or browser host, the type-name diagnostics are not produced.

The Editor's implementation resolves against the project's loaded asset types that derive from UnityEngine.Object. It has no allow-list. It excludes components and editor-only types.

AssetTypeResolution

The verdict for one name.

  • RawName
  • AssetTypeResolutionStatus Status
  • FullName. The CLR full name, with + for nested types. Set for Resolved and NotReferenceable only.
  • AssemblyName. The assembly that the generated companion assembly must reference. Set for assembly-definition types, and null for engine modules and unresolved names.
  • Candidates. Never null. Holds the ambiguous candidates, or the nearest-match suggestions for an unknown name.

Factories:

  • Resolved(raw, fullName, assemblyName)
  • Unknown(raw, suggestions)
  • Ambiguous(raw, candidates)
  • NotReferenceable(raw, fullName, assemblyName)

AssetTypeResolutionStatus

ValueMeaning
ResolvedThe name resolved
UnknownNo such type
AmbiguousThe short name matches several types and no single concrete one. Write the full name
NotReferenceableThe type lives in a predefined assembly such as Assembly-CSharp, which generated code cannot reference

Generated field types

Codegen reads the resolved dictionary that the pipeline produces. For a resolved name it emits AssetReferenceT<global::FullName>.

A name that codegen cannot find in that dictionary is never emitted verbatim. The field falls back to AssetReference, and an AssetTypeUnresolvedFallback warning is collected.

The resolved full name is also mixed into the schema fingerprint.

Asset delivery

These types hold the cell values of the two asset cell types that need no Addressables catalog, and the inputs that the delivery-mode verdict on them is made from. They also hold the check on which gated cell types a mode accepts.

All of it is pure data. The editor fills the indexes and hands the mode's verdict in.

TypeKindRole
ResourceRefValuereadonly structThe parse result of a ResourceRef cell
DirectRefValuereadonly structThe parse result of a DirectRef cell
DirectRefKindenumWhich spelling a DirectRef cell used
ResourceAssetIndexsealed classWhat exists under the project's Resources folders, by lookup path
ProjectAssetIndexsealed classThe project assets the sheets mention
DeliveryContextsealed classThe active mode as validation sees it

ResourceRefValue

The parse result of a ResourceRef cell.

  • Path. Relative to the Resources folder, in canonical form: / separators, no extension, case kept.
  • SubName
  • IsEmpty
  • ToString(). The cell spelling, path[sub].

DirectRefValue

The parse result of a DirectRef cell.

  • Kind. A DirectRefKind.
  • Identity. The Assets/… path, or the lower-case GUID.
  • SubName
  • IsEmpty
  • ToString()

DirectRefKind

Which spelling the cell used. A cell keeps the one it has.

  • Path
  • Guid

ResourceAssetIndex

What exists under the project's Resources folders, by lookup path.

  • Register(path)
  • RegisterTyped(path, satisfiedTypeFullNames)
  • RegisterDuplicate(path)
  • HasPath
  • IsDuplicate
  • HasTypeInfo
  • SatisfiesType(path, typeFullName)
  • Paths
  • DuplicatePaths

When the index is injected as null, as in the browser or a headless host, ResourceRef validation is skipped.

ProjectAssetIndex

The project assets the sheets mention. The index maps each path to its GUID and type closure, and each GUID to its path.

  • Register(path, guid, satisfiedTypeFullNames)
  • HasPath
  • GuidOf(path)
  • PathOf(guid)
  • HasTypeInfo
  • SatisfiesType
  • Paths

The index is filled with what the sheets refer to, not with the whole project.

When the index is injected as null, DirectRef validation is skipped.

DeliveryContext

The active mode as validation sees it.

  • Id
  • GatedTypeNames. The set of types the gate can refuse, which is SheetSyntax.DeliveryGatedTypeNames.
  • AllowedGatedTypes. What this mode honors.
  • IsGated(typeName)
  • Allows(typeName). True for every type outside that set, and for a gated type this mode accepts.

A null context means "do not judge the gate".

Visual value types

These are engine-free value models for the three built-in visual types. Each model is immutable and IEquatable. Each owns its own text form through TryParse and Render.

The text form is the notation that Visual types documents. A plugin type that stores a color, a curve or a gradient can reuse these models instead of inventing a second notation.

The Editor bakes the models into UnityEngine.Color, AnimationCurve and Gradient, and reads them back. The browser samples them through the evaluators below rather than re-implementing the math.

TypeKindRole
ColorValuereadonly structA color as four bytes
CurveValuesealed classA curve: its keys and wrap modes
CurveKeyreadonly structOne key of a curve
CurveWrapenumUnity's wrap vocabulary by name
CurveTangentModeenumTangent modes, identical to AnimationUtility.TangentMode
CurveWeightedMode[Flags] enumWhich side of a key uses weighted (Bezier) tangents
CurveTangentSolverstatic classDerives the tangent numbers a mode dictates
CurveEvaluatorstatic classEvaluates and samples a curve
GradientValuesealed classA gradient: its keys, blend mode and color space
GradientColorKeyreadonly structOne color key of a gradient
GradientAlphaKeyreadonly structOne alpha key of a gradient
GradientBlendenumHow a gradient blends
GradientColorSpaceenumThe color space of a gradient
GradientEvaluatorstatic classEvaluates and samples a gradient

ColorValue

Four bytes: R, G, B and A.

  • static Default. The value #00000000.
  • static TryParse(text, out value, out error). Accepts #RGB, #RGBA, #RRGGBB and #RRGGBBAA.
  • Render(). Upper-case, six digits when opaque.

CurveValue

  • Keys. Time-ascending.
  • PreWrap and PostWrap
  • static Empty. No keys. It is the only state with no text form, and Render() gives "".
  • static Create(keys, preWrap, postWrap). The one construction path.
  • static TryParse. Accepts keys of 2, 4, 7 or 8 fields, Once as an alias of ClampForever, and Infinity or -Infinity tangents.
  • Render(). Writes 8-field keys, and the wrap suffix only when needed.

Create sorts by time, rejects duplicate times, and applies CurveTangentSolver, so the tangent modes take precedence over the stored tangent numbers from the moment a curve exists.

CurveKey

  • Time
  • Value
  • InTangent
  • OutTangent
  • InWeight
  • OutWeight
  • CurveWeightedMode WeightedMode
  • CurveTangentMode LeftMode and RightMode
  • bool Broken

The constructor takes ten arguments and does no normalization of its own.

CurveWrap

Unity's wrap vocabulary by name. The value mapping to WrapMode belongs to the baker.

  • ClampForever
  • Loop
  • PingPong
  • Default

CurveTangentMode

  • Free = 0
  • Auto = 1
  • Linear = 2
  • Constant = 3
  • ClampedAuto = 4

The names and values are identical to AnimationUtility.TangentMode. The baker therefore maps by name and never touches Unity's packed tangent bits.

CurveWeightedMode

A [Flags] enum. It says which side of a key uses weighted (Bezier) tangents.

  • None = 0
  • In = 1
  • Out = 2
  • Both = 3

CurveTangentSolver

  • CurveKey[] Apply(IReadOnlyList<CurveKey> sortedKeys)

Apply derives the tangent numbers a mode dictates. It applies the stages in the engine's order:

  1. Linear on its own side
  2. ClampedAuto on both sides
  3. Auto on both sides
  4. Constant on its own side

Free sides and weights stay untouched.

CurveValue.Create calls the solver, so callers rarely do.

CurveEvaluator

  • float Evaluate(CurveValue, float time)
  • float[] Sample(CurveValue, int count). Needs count ≥ 2. The samples are evenly spaced from the first key to the last.

The evaluator uses:

  • Hermite interpolation between keys
  • Weighted Bezier on the sides whose weight flag is set
  • A hold when a tangent is infinite
  • The four wrap behaviors outside the key range

It is verified against AnimationCurve.Evaluate on random curves.

GradientValue

  • ColorKeys and AlphaKeys. 1 to 8 each, time-ascending.
  • GradientBlend Mode
  • GradientColorSpace ColorSpace
  • static Default. White, fully opaque, Blend.
  • static Create(colorKeys, alphaKeys, mode, colorSpace). Validates counts and 0…1 ranges, quantizes times to 16 bits as Unity does, and sorts stably.
  • static TryParse. Reads three or four |-separated sections.
  • Render()

GradientColorKey

  • ColorValue Color. Alpha is ignored, because alpha has its own keys.
  • float Time

GradientAlphaKey

  • float Alpha
  • float Time

GradientBlend

  • Blend
  • Fixed
  • PerceptualBlend

GradientColorSpace

  • Uninitialized. Not written. Reads as Gamma.
  • Gamma
  • Linear

The color space affects only PerceptualBlend.

GradientEvaluator

  • ColorValue Evaluate(GradientValue, float time)
  • ColorValue[] Sample(GradientValue, int count)

Blending is linear, stepped or perceptual (Oklab). The alpha keys are blended separately, and the result is rounded to bytes.

It is verified against Gradient.Evaluate on random gradients.

Next steps