Skip to content

Conversation

@benglin
Copy link
Contributor

@benglin benglin commented Oct 22, 2025

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 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 new Quantity 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.

unit-conversion-v1-to-v2

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
  • Existing unit conversion tests continue to pass

FYIs

(Optional)

Copilot AI review requested due to automatic review settings October 22, 2025 09:56
Copy link

@github-actions github-actions bot left a 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

Copy link
Contributor

Copilot AI left a 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

@zeusongit zeusongit requested a review from a team October 22, 2025 14:10
Copy link
Contributor

@reddyashish reddyashish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@zeusongit zeusongit merged commit 534a240 into master Oct 22, 2025
26 of 27 checks passed
@zeusongit zeusongit deleted the DYN-9604 branch October 22, 2025 16:13
@zeusongit zeusongit added this to the 4.0 milestone Oct 22, 2025
@zeusongit
Copy link
Contributor

/cherrypick

@github-actions
Copy link

Successfully created backport PR for RC4.0.0_master:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants