Data does not survive a round trip

Bevel saves each dataset to JSON and reads it back. Yours changed on the way.

  • Error
  • BEVEL050

What it means

Bevel freezes your data into a snapshot at build time. It checks that the snapshot reads back to the same values. Private setters, interface-typed members and values missing from a constructor are the usual causes.

Example message

text
Data/Posts/BlogPost.cs(6,15): error BEVEL050: Dataset 'Posts' (CLR type 'IReadOnlyList<BlogPost>') does not survive a JSON round-trip: at $[0].Tags the snapshot holds ["a","b"] but after deserialization it becomes []. Make the member a public property with get and set/init, add a matching constructor parameter, avoid interface-typed or polymorphic members (or add [JsonDerivedType]), use concrete collection types, and break reference cycles. Help: https://khalidabuhakmeh.github.io/bevel/reference/diagnostics/bevel050/

How to fix

Make the type easy for JSON to rebuild:

  1. Give every member a public get and init (or set).
  2. Put every value in a constructor parameter of the same name.
  3. Use concrete types, or add [JsonDerivedType] for interfaces.
csharp
public IReadOnlyList<string> Tags { get; private set; }
public List<string> Tags { get; init; } = [];