You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Fixes DYN-9604: Unit conversion node quantity dropdown appears blank when opening v1 schema graphs in environments with ASC 2026+ installed.
Background:
When Dynamo graphs are saved without ASC available (using ForgeUnits.Schemas v1.0.4), unit conversion nodes serialize with v1 schema identifiers like autodesk.unit.quantity:length-1.0.5. When these graphs are opened in environments where ASC 2026+ is installed, Dynamo automatically loads v2 schemas from ASC instead of the bundled v1 schemas.
During deserialization, the JSON constructor first populates QuantityConversionSource by calling GetAllQuantities(), which returns only the latest v2 schemas from ASC. Then, when SelectedQuantityConversion is deserialized, Quantity.ByTypeID() is called with the v1 TypeId from the DYN file (e.g., "autodesk.unit.quantity:length-1.0.5"), creating a newQuantity object instance. Since WPF ComboBox SelectedItem binding uses reference equality by default, the deserialized Quantity cannot find a matching instance in the ItemsSource, causing the dropdown to appear blank.
For example, after loading a v1 DYN file:
QuantityConversionSource (the ComboBox ItemsSource): [Quantity@0x1234 {TypeId="length-2.0.0"}, ...] - v2 schemas from GetAllQuantities() in the constructor
SelectedQuantityConversion (the ComboBox SelectedItem): Quantity@0x5678 {TypeId="length-1.0.5"} - a different instance created by ByTypeID() during JSON deserialization
The ComboBox cannot find a match because the deserialized Quantity has TypeId "length-1.0.5" (v1), but the collection only contains v2 schemas like "length-2.0.0". Even though they represent the same quantity type (Length), the TypeIds don't match.
The same issue affects the from/to unit dropdowns, though they were less visible because the unit sources are populated from the deserialized Quantity's .Units property, which may return units from multiple schema versions.
Solution:
Introduced a reconciliation mechanism that matches deserialized items to their corresponding collection entries by comparing typeName (TypeId without version suffix). This ensures reference equality for WPF binding while maintaining backward compatibility with v1 schemas.
Declarations
Is documented according to the standards
The level of testing this PR includes is appropriate
Changes to the API follow Semantic Versioning and are documented in the API Changes document (N/A - internal changes only)
Release Notes
Fixed an issue where the quantity dropdown in "Convert By Units" nodes would appear blank when opening graphs saved with v1 schemas in environments with ASC 2026+ installed. The node now correctly displays and functions with schema version upgrades.
Reviewers
(Assign appropriate reviewer)
Testing Notes:
Tested with graphs saved in non-ASC environments (v1 schemas) opened in ASC 2026+ environments (v2 schemas)
Added comprehensive unit tests for the reconciliation logic covering edge cases and null handling
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes a critical bug where unit conversion node quantity dropdowns appear blank when opening graphs saved with v1 schemas in environments with ASC 2026+ installed. The issue stems from a mismatch between schema versions during deserialization, where v1 TypeIds from saved graphs cannot match v2 TypeIds in the dropdown's ItemsSource due to WPF ComboBox using reference equality.
Key changes:
Implemented a reconciliation mechanism to match deserialized items to collection entries by comparing type names (without version suffixes)
Applied reconciliation to quantity, from-unit, and to-unit property setters to ensure WPF binding works correctly
Added comprehensive unit tests covering edge cases including null handling, version matching, and non-matching scenarios
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
File
Description
src/Libraries/UnitsNodeModels/UnitNodeModels.cs
Added ReconcileFromCollection and GetTypeName helper methods; updated property setters to reconcile deserialized values with their collections
test/DynamoCoreWpf3Tests/UnitsUITests.cs
Added comprehensive unit tests for the reconciliation logic covering valid TypeIds, edge cases, and null handling
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose
Fixes DYN-9604: Unit conversion node quantity dropdown appears blank when opening v1 schema graphs in environments with ASC 2026+ installed.
Background:
When Dynamo graphs are saved without ASC available (using
ForgeUnits.Schemas v1.0.4), unit conversion nodes serialize with v1 schema identifiers likeautodesk.unit.quantity:length-1.0.5. When these graphs are opened in environments where ASC 2026+ is installed, Dynamo automatically loads v2 schemas from ASC instead of the bundled v1 schemas.During deserialization, the JSON constructor first populates
QuantityConversionSourceby callingGetAllQuantities(), which returns only the latest v2 schemas from ASC. Then, whenSelectedQuantityConversionis deserialized,Quantity.ByTypeID()is called with the v1 TypeId from the DYN file (e.g.,"autodesk.unit.quantity:length-1.0.5"), creating a newQuantityobject instance. Since WPF ComboBoxSelectedItembinding uses reference equality by default, the deserializedQuantitycannot find a matching instance in theItemsSource, causing the dropdown to appear blank.For example, after loading a v1 DYN file:
QuantityConversionSource(the ComboBox ItemsSource):[Quantity@0x1234 {TypeId="length-2.0.0"}, ...]- v2 schemas fromGetAllQuantities()in the constructorSelectedQuantityConversion(the ComboBox SelectedItem):Quantity@0x5678 {TypeId="length-1.0.5"}- a different instance created byByTypeID()during JSON deserializationThe ComboBox cannot find a match because the deserialized
Quantityhas TypeId"length-1.0.5"(v1), but the collection only contains v2 schemas like"length-2.0.0". Even though they represent the same quantity type (Length), the TypeIds don't match.The same issue affects the from/to unit dropdowns, though they were less visible because the unit sources are populated from the deserialized Quantity's
.Unitsproperty, which may return units from multiple schema versions.Solution:
Introduced a reconciliation mechanism that matches deserialized items to their corresponding collection entries by comparing
typeName(TypeId without version suffix). This ensures reference equality for WPF binding while maintaining backward compatibility with v1 schemas.Declarations
Release Notes
Fixed an issue where the quantity dropdown in "Convert By Units" nodes would appear blank when opening graphs saved with v1 schemas in environments with ASC 2026+ installed. The node now correctly displays and functions with schema version upgrades.
Reviewers
(Assign appropriate reviewer)
Testing Notes:
FYIs
(Optional)