An editor-side JSON upgrader for ShaderGraphPlus that migrates saved graph data to version 11. It validates presence of parameter and node arrays and renames the top-level JSON property "Domain" to "ShaderType".
using System.Text.Json.Nodes;
namespace ShaderGraphPlus;
public partial class ShaderGraphPlus
{
/// <summary>
/// Changes : <br/>
/// - Replace Domain with ShaderType.
/// </summary>
[SGPJsonUpgrader( typeof( ShaderGraphPlus ), 11 )]
internal static void Upgrader_v11( JsonObject obj )
{
if ( obj[JsonKeys.ParameterArray] is not JsonArray oldParameterArray )
throw new Exception( $"Cannot find jsonArray \"{JsonKeys.ParameterArray}\"" );
if ( obj[JsonKeys.NodeArray] is not JsonArray oldNodeArray )
throw new Exception( $"Cannot find jsonArray \"{JsonKeys.NodeArray}\"" );
JsonUtils.RenamePropertyKey( obj, "Domain", "ShaderType" );
}
}