Skip to content

Enable TfsNodeStructureTool upgrade command to convert old dictionary format to new array format#2754

Merged
MrHinsh merged 3 commits intomainfrom
copilot/fix-2752
Jun 16, 2025
Merged

Enable TfsNodeStructureTool upgrade command to convert old dictionary format to new array format#2754
MrHinsh merged 3 commits intomainfrom
copilot/fix-2752

Conversation

Copy link
Contributor

Copilot AI commented Jun 16, 2025

The TfsNodeStructureTool has been updated to use a new mapping format, but the upgrade command was not able to handle the conversion from the old dictionary format to the new array format.

Problem

The old configuration format used dictionaries for mappings:

"TfsNodeStructureTool": {
  "Enabled": true,
  "Areas": {
    "Filters": [],
    "Mappings": {
      "Foo\\\\AAA\\\\123\\\\(.+)": "FooDest\\AAA\\$1",
      "Foo\\\\(.+)": "FooDest\\$1"    
    }
  }
}

The new format uses arrays of mapping objects:

"TfsNodeStructureTool": {
  "Enabled": true,
  "Areas": {
    "Filters": [],
    "Mappings": [
      {
        "Match": "Foo\\\\AAA\\\\123\\\\(.+)",
        "Replacement": "FooDest\\AAA\\$1"
      },
      {
        "Match": "Foo\\\\(.+)",
        "Replacement": "FooDest\\$1"
      }
    ]
  }
}

Solution

Enhanced the OptionsConfigurationUpgrader to:

  1. Smart Format Detection: Automatically detects whether mappings are in old dictionary format or new array format
  2. Dictionary-to-Array Conversion: Converts each key-value pair to a NodeMapping object with Match and Replacement properties
  3. Cross-Assembly Compatibility: Uses reflection to create NodeMapping objects without requiring direct assembly dependencies
  4. Backward Compatibility: Leaves existing array format configurations unchanged
  5. Error Handling: Gracefully handles missing types and null configurations

Key Changes

  • Enhanced MapTfsNodeStructureOptions: Added intelligent format detection and conversion logic for both Areas and Iterations mappings
  • Added CommonTools Support: Fixed missing CommonTools processing in v15.0 schema upgrade path
  • Improved Error Handling: Prevents crashes when optional tool types aren't found in current assembly context
  • Dynamic Type Resolution: Uses reflection to create NodeMapping objects at runtime

Testing

  • Added comprehensive unit tests covering both old and new mapping formats
  • Validated dictionary-to-array conversion logic with multiple mapping scenarios
  • Confirmed all existing tests continue to pass (34 passed, 2 skipped)
  • Functional testing demonstrates successful conversion of complex mapping configurations

The upgrade command now successfully converts TfsNodeStructureTool configurations, enabling users to seamlessly migrate from the old dictionary-based format to the new array-based format.

Fixes #2752.

Warning

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • api.elmah.io
    • Triggering command: /home/REDACTED/work/azure-devops-migration-tools/azure-devops-migration-tools/src/MigrationTools.ConsoleCore/bin/Debug/net8.0/devopsmigration upgrade --config /tmp/test-old-format.json (dns block)
    • Triggering command: /home/REDACTED/work/azure-devops-migration-tools/azure-devops-migration-tools/src/MigrationTools.ConsoleCore/bin/Debug/net8.0/devopsmigration upgrade --config /tmp/test-old-format-v150.json (dns block)
    • Triggering command: /home/REDACTED/work/azure-devops-migration-tools/azure-devops-migration-tools/src/MigrationTools.ConsoleCore/bin/Debug/net8.0/devopsmigration upgrade --config /tmp/test-old-format-correct.json (dns block)
  • westeurope-5.in.applicationinsights.azure.com
    • Triggering command: /home/REDACTED/work/azure-devops-migration-tools/azure-devops-migration-tools/src/MigrationTools.ConsoleCore/bin/Debug/net8.0/devopsmigration upgrade --config /tmp/test-old-format.json (dns block)
    • Triggering command: /home/REDACTED/work/azure-devops-migration-tools/azure-devops-migration-tools/src/MigrationTools.ConsoleCore/bin/Debug/net8.0/devopsmigration upgrade --config /tmp/test-old-format-v150.json (dns block)
    • Triggering command: /home/REDACTED/work/azure-devops-migration-tools/azure-devops-migration-tools/src/MigrationTools.ConsoleCore/bin/Debug/net8.0/devopsmigration upgrade --config /tmp/test-old-format-correct.json (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copilot AI and others added 2 commits June 16, 2025 13:50
…array format

Co-authored-by: MrHinsh <5205575+MrHinsh@users.noreply.github.com>
Co-authored-by: MrHinsh <5205575+MrHinsh@users.noreply.github.com>
Copilot AI changed the title [WIP] Enable the Upgrade command to upgrade the old TfsNodeStructureTool format to the new one. Enable TfsNodeStructureTool upgrade command to convert old dictionary format to new array format Jun 16, 2025
Copilot AI requested a review from MrHinsh June 16, 2025 13:55
@MrHinsh MrHinsh marked this pull request as ready for review June 16, 2025 16:11
@MrHinsh MrHinsh enabled auto-merge June 16, 2025 16:11
@MrHinsh MrHinsh merged commit 6617433 into main Jun 16, 2025
14 checks passed
@MrHinsh MrHinsh deleted the copilot/fix-2752 branch June 16, 2025 16:12
@nkdagility-actions-bot
Copy link

Azure Static Web Apps: Your stage site is ready! Visit it here: https://blue-river-093197403-2754.westeurope.5.azurestaticapps.net

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.

Enable the Upgrade command to upgrade the old TfsNodeStructureTool format to the new one.

2 participants