DYN-10119: Add IValueSchemaProvider and typeIds to DefineData#17040
DYN-10119: Add IValueSchemaProvider and typeIds to DefineData#17040kalunkuo wants to merge 2 commits intoDynamoDS:masterfrom
Conversation
There was a problem hiding this comment.
See the ticket for this pull request: https://jira.autodesk.com/browse/DYN-10119
There was a problem hiding this comment.
Pull request overview
This PR adds a new public API surface to expose a stable, wire-format type identifier ($typeid) for DefineData nodes so external consumers (e.g., DynamoPlayer, DynamoMCP) can resolve canonical type identifiers without relying on display names.
Changes:
- Introduces
Dynamo.Graph.Nodes.IValueSchemaProviderwithValueTypeIdandIsListValue. - Extends
DSCore.Data.DataNodeDynamoTypewith aTypeIdfield populated for supported types and wires those IDs into the supported type list. - Implements
IValueSchemaProvideronCoreNodeModels.DefineDataand updatesDynamoCore/PublicAPI.Unshipped.txt.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| src/Libraries/CoreNodes/Data.cs | Adds TypeId to supported data types and populates wire-format $typeid strings. |
| src/Libraries/CoreNodeModels/DefineData.cs | Implements IValueSchemaProvider to expose typeId/list context from the dropdown selection. |
| src/DynamoCore/Graph/Nodes/IValueSchemaProvider.cs | Adds the new public interface for external consumers to query schema/type info. |
| src/DynamoCore/PublicAPI.Unshipped.txt | Registers the new public interface members for API analyzer compliance. |
| public string ValueTypeId => | ||
| (Items[SelectedIndex].Item as Data.DataNodeDynamoType)?.TypeId ?? SelectedString; | ||
|
|
There was a problem hiding this comment.
ValueTypeId indexes Items[SelectedIndex] directly. DSDropDownBase.SelectedIndex can be -1 (e.g., when the saved selection can’t be restored or if an invalid index is set), which will throw an IndexOutOfRangeException here. Consider guarding for SelectedIndex < 0 || SelectedIndex >= Items.Count and returning null/SelectedString accordingly (and avoid indexing when the selection is invalid).
| public string ValueTypeId => | |
| (Items[SelectedIndex].Item as Data.DataNodeDynamoType)?.TypeId ?? SelectedString; | |
| public string ValueTypeId | |
| { | |
| get | |
| { | |
| if (SelectedIndex < 0 || SelectedIndex >= Items.Count) | |
| { | |
| return SelectedString; | |
| } | |
| return (Items[SelectedIndex].Item as Data.DataNodeDynamoType)?.TypeId ?? SelectedString; | |
| } | |
| } |
| public class DefineData : DSDropDownBase, IValueSchemaProvider | ||
| { | ||
| /// <inheritdoc/> | ||
| [JsonIgnore] | ||
| public string ValueTypeId => | ||
| (Items[SelectedIndex].Item as Data.DataNodeDynamoType)?.TypeId ?? SelectedString; | ||
|
|
||
| /// <inheritdoc/> | ||
| [JsonIgnore] | ||
| public bool IsListValue => IsList; |
There was a problem hiding this comment.
The new public contract (IValueSchemaProvider implemented by DefineData) isn’t covered by tests. There are existing DefineData tests; please add coverage that verifies ValueTypeId returns the expected wire $typeid for at least one geometry type (e.g., Point) and that it behaves safely when nothing is selected (SelectedIndex == -1), plus a basic assertion for IsListValue mirroring IsList.
| /// Null for primitive types (bool, string, Number, etc.) that don't use $typeid serialization. | ||
| /// Must match the identifiers recognised by <see cref="DynamoJObjectToNative"/> | ||
| /// and the actual $typeid values produced by ProtoGeometry serialization. | ||
| /// Exposed to external consumers via <see cref="IValueSchemaProvider.ValueTypeId"/> |
There was a problem hiding this comment.
The XML doc uses <see cref="IValueSchemaProvider.ValueTypeId"/>, but this file doesn’t import Dynamo.Graph.Nodes and the type isn’t in the DSCore namespace. That will produce an unresolved-cref XML documentation warning (e.g., CS1574). Prefer fully-qualifying the cref (Dynamo.Graph.Nodes.IValueSchemaProvider.ValueTypeId) or adding the appropriate using so docs build cleanly.
| /// Exposed to external consumers via <see cref="IValueSchemaProvider.ValueTypeId"/> | |
| /// Exposed to external consumers via <see cref="Dynamo.Graph.Nodes.IValueSchemaProvider.ValueTypeId"/> |
| var polygon = new DataNodeDynamoType(typeof(Polygon), 2, false, null, polyCurve, "autodesk.geometry.curve:polyline-1.0.0"); | ||
| var rectangle = new DataNodeDynamoType(typeof(Autodesk.DesignScript.Geometry.Rectangle), 3, true, null, polyCurve, "dynamo.geometry:rectangle-1.0.0"); | ||
| var solid = new DataNodeDynamoType(typeof(Solid), 0, false, null, null, "dynamo.geometry:sab-1.0.0"); | ||
| var cone = new DataNodeDynamoType(typeof(Cone), 1, false, null, solid, "dynamo.geometry:cone-1.0.0"); |
There was a problem hiding this comment.
DataNodeDynamoType assigns Cone the typeId "dynamo.geometry:cone-1.0.0", but DynamoJObjectToNative doesn’t recognize that $typeid (it only special-cases sab, tsm, rectangle, cuboid, solid, etc., plus autodesk.geometry*). If this is truly the wire-format $typeid, ParseJSON/ToNative won’t round-trip cone values. Either update DynamoJObjectToNative to handle this $typeid, or adjust the Cone TypeId to one that is actually emitted/recognized.
| var cone = new DataNodeDynamoType(typeof(Cone), 1, false, null, solid, "dynamo.geometry:cone-1.0.0"); | |
| var cone = new DataNodeDynamoType(typeof(Cone), 1, false, null, solid, "dynamo.geometry:sab-1.0.0"); |
Purpose
Expose wire-format
$typeidvalues fromDataNodeDynamoTypethrough a new publicIValueSchemaProviderinterface, so DynamoPlayer and DynamoMCP can programmatically resolve the canonical type identifier for DefineData nodes.Previously, external consumers (DynamoPlayer, MCP) had no programmatic way to get the
$typeidthat ProtoGeometry'sToJson()emits for a given DefineData type. They relied on display names (e.g. "Point") and maintained separate hardcoded lookup dictionaries, which drifted from actual wire values.Related PRs: DynamoPlayer (reads
ValueTypeIdvia reflection) and DynamoMCP (resolves typeIds to JSON Schemas for LLM consumers).Key changes:
IValueSchemaProviderinterface inDynamoCore/Graph/Nodes/withValueTypeId(string) andIsListValue(bool)DefineDataimplementsIValueSchemaProvider, returningDataNodeDynamoType.TypeIdviaValueTypeIdDataNodeDynamoTypegains aTypeIdproperty populated with the actual wire-format$typeidfor each supported type (e.g."autodesk.math:point3d-1.0.0"for Point,"autodesk.geometry.curve:circle-1.0.0"for Arc/Circle)StringifyJSONoutput — see Sample.json attached to the Jira ticketPublicAPI.Unshipped.txtupdated with the 3 new public API membersDeclarations
Check these if you believe they are true
Release Notes
Expose wire-format
$typeidvalues fromDataNodeDynamoTypethrough a new publicIValueSchemaProviderinterfaceReviewers
(FILL ME IN) Reviewer 1 (If possible, assign the Reviewer for the PR)
(FILL ME IN, optional) Any additional notes to reviewers or testers.
FYIs
(FILL ME IN, Optional) Names of anyone else you wish to be notified of