Vixen
dd8b0a81
csharp
public sealed class SerializedHandleAnalyzer

Reports a component that would write an entity handle into a file.

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

Remarks

docs/plan/04-ecs-and-scripting.md § Determinism and persistence, in three words: never serialise a raw Entity. Ids are dense and reused, so a handle is a slot in a running process; written down and read back into another world it either names a different entity or fails a version check, and nothing says which.

The engine already keeps this rule by hand, in comments. CameraTargets, Possessing, PossessedBy, ViewTarget and PredictionSmoothing each carry [Component] without [DataContract] and each says why in its own remarks — "not [DataContract], because it names an entity". This is that convention with a compiler behind it. ⚠ It found one component that had drifted out of it.

Both attributes are the trigger, because both together are what makes a component reach a file. SceneComponentRegistry declares a type carrying the pair, and WorldSerializer writes a column for exactly those; a component with only [Component] lives entirely in a running world and may hold whatever it likes.

⚠ What this is not is a fix. A component that genuinely needs to point at another entity across a save has nothing to hold instead — there is no persistent identity, no GuidComponent and no Guid → Entity map — which is #296. This makes the gap loud instead of silent, which is the half of that issue that does not need the design decided.

Fields and properties (2)

  • public const string DiagnosticId

    The id reported for a serialised component that holds an entity handle.

  • public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics

    Returns a set of descriptors for the diagnostics that this analyzer is capable of producing.

Methods (1)

  • public override void Initialize(AnalysisContext context)

    Called once at session start to register actions in the analysis context.

Used by (2)

  • SerializedHandleTestsVixen.Engine.Generators.Tests
  • RealExampleRuleTestsVixen.DocGen.Tests