Table of Contents

Class SyntaxNodeJson

Namespace
RDCore.SDK.Model.AST.Abstract
Assembly
RDCore.SDK.dll

Shared System.Text.Json configuration for (de)serializing a SyntaxNode tree.

public static class SyntaxNodeJson
Inheritance
SyntaxNodeJson
Inherited Members

Remarks

The AST crosses the ParseServer-to-LanguageServer process boundary as JSON on every parse (PlatformJson). Most node types store the same children under two or three differently-named properties: the generic inherited spine (Children, and ExpressionNode/StatementNode's own Inputs) and specific typed properties (e.g. InlineIfStatementNode.ConditionExpression). Left alone, System.Text.Json serializes all of them, so each nesting level multiplies the payload rather than adding to it — an ordinary depth-16 nested expression (1 + 1 + ... + 1) serializes to hundreds of megabytes.

Options installs a DefaultJsonTypeInfoResolver modifier that detects, per concrete node type, whether the generic spine (Children/Inputs) is exactly reconstructable from that type's other, non-[JsonIgnore]d node-bearing properties — and if so, omits the spine from the JSON instead of the reverse. Never the reverse: a typed property (read directly by consumers like SymbolBuilder, post-deserialize, in a different process) silently losing data on the wire would be a far worse failure than a bloated payload. The check runs per instance, not just per type, and falls back to keeping the spine on any shape it can't prove — false negatives (a payload that could have shrunk further but didn't) are an acceptable missed optimization; false positives (dropping data that wasn't actually reconstructable) are not.

Properties

Options

The options every AST (de)serialization call site should share — PlatformJson (the live wire path) and tests alike, so what a test exercises matches what actually ships.

public static JsonSerializerOptions Options { get; }

Property Value

JsonSerializerOptions