Defines a small polymorphic data model for representing a callee reference in the editor wiring system. CalleeRef is an abstract record with two derived records: MethodCallee holds a SymbolId GUID, InlineCallee holds raw C# code as a string. Uses System.Text.Json source polymorphism attributes for (de)serialization.
using System;
using System.Text.Json.Serialization;
namespace Grains.RazorDesigner.Wiring;
[JsonPolymorphic( TypeDiscriminatorPropertyName = "$type" )]
[JsonDerivedType( typeof( MethodCallee ), "Method" )]
[JsonDerivedType( typeof( InlineCallee ), "Inline" )]
public abstract record CalleeRef;
public sealed record MethodCallee : CalleeRef
{
public Guid SymbolId { get; init; }
}
public sealed record InlineCallee : CalleeRef
{
// Raw C# (a name, dotted member path, etc.). Treated as opaque by the projector.
public string Code { get; init; } = "";
}