Vixen
caa30e12
csharp
public static class DefinitionSerialization

A definition's bytes, self-describing, because the reader does not know its type.

Read the guide page for this →

Remarks

Every other artefact in the engine is read back through a known type. Serializer.Read<BehaviorTreeContent> works because the caller knows what it asked for. A definition catalog does not: it reads a directory of .vxdef files whose only statement of type is the !ItemDefinition a designer wrote, and the whole point of the seam is that a game can add a definition type without the loader learning about it.

So the payload leads with the [DataContract] alias, and the reader resolves that through SerializerRegistry — the same alias table Vixen.Core.Serialization's own dynamic paths use for a member of a base type. What this adds is that a whole artefact can be one, which Serializer.ToBytes<T> cannot do for an abstract T.

⚠ The alias is content, so renaming one is a content break. Same rule as renaming an address, and [DataContract]'s former-alias list is the migration path — which is also what ADR-005 specifies for a .meta.

Methods (3)

  • public static byte[] ToBytes(Definition definition)

    Writes a definition, whatever kind it is.

  • public static Definition FromBytes(ReadOnlySpan<byte> bytes)

    Reads a definition back.

  • public static DefinitionCatalogBuilder Add(this DefinitionCatalogBuilder builder, string address, ReadOnlySpan<byte> bytes)

    Adds a definition to a catalog straight from its bytes.

Used by (8)

  • AuthoredContentMmo.Content.Tests
  • MmoLibrariesMmo.Shared
  • RealmTestsMmo.Realm.Tests
  • DefinitionImporterVixen.Editor.Assets
  • DefinitionImporterTestsVixen.Editor.Assets.Tests
  • DefinitionContentVixen.Gameplay.Content
  • DefinitionSerializationTestsVixen.Gameplay.Tests
  • ShippedVixen.Gameplay.Content.Tests