-
Notifications
You must be signed in to change notification settings - Fork 668
DYN-9604: Fix blank quantity dropdown in unit nodes #16621
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See the ticket for this pull request: https://jira.autodesk.com/browse/DYN-9604
There was a problem hiding this comment.
Choose a reason for hiding this comment
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 |
| src/Libraries/UnitsNodeModels/Properties/AssemblyInfo.cs | Exposed internal methods to test assembly for testing reconciliation logic |
reddyashish
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
/cherrypick |
(cherry picked from commit 534a240)
|
Successfully created backport PR for |
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)