Skip to content

Rename RegistrationOrder to SortOrder and remove redundant OrderBy#17935

Open
Copilot wants to merge 2 commits into
mainfrom
copilot/fix-outstanding-comments
Open

Rename RegistrationOrder to SortOrder and remove redundant OrderBy#17935
Copilot wants to merge 2 commits into
mainfrom
copilot/fix-outstanding-comments

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jun 5, 2026

Description

Addresses two post-merge review comments from @JamesNK on #17881:

  • Rename RegistrationOrderSortOrder — aligns with established convention (UrlDisplayPropertiesSnapshot.SortOrder).
  • Remove redundant .OrderBy(c => c.command.Name) in ResourceSnapshotMapper — consumers sort by SortOrder, so pre-sorting dictionary keys alphabetically is unnecessary.

Changes:

  • ResourceJson.cs — property rename
  • ResourceSnapshotMapper.cs — drop .OrderBy(), use new field name
  • ResourceSnapshotMapperTests.cs — updated assertions verify registration-order key sequence
  • AppHostDataRepository.ts, resourceDisplay.ts, appHostTreeView.test.ts — TypeScript field rename

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
      • If yes, did you have an API Review for it?
        • Yes
        • No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • Yes
        • No
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • Yes
        • No
    • No

Copilot AI and others added 2 commits June 5, 2026 03:13
…der and remove redundant OrderBy

Co-authored-by: JamesNK <303201+JamesNK@users.noreply.github.com>
Co-authored-by: JamesNK <303201+JamesNK@users.noreply.github.com>
Copilot AI changed the title Address PR #17881 review comments: rename RegistrationOrder to SortOrder and remove redundant OrderBy Rename RegistrationOrder to SortOrder and remove redundant OrderBy Jun 5, 2026
Copilot AI requested a review from JamesNK June 5, 2026 03:15
@JamesNK JamesNK marked this pull request as ready for review June 5, 2026 05:51
Copilot AI review requested due to automatic review settings June 5, 2026 05:51
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 5, 2026

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 17935

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 17935"

Copy link
Copy Markdown
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 updates the resource command JSON contract to use SortOrder (renaming RegistrationOrder) and removes the pre-sorting of commands by name so command ordering better reflects registration order as used by UI consumers (e.g., VS Code extension / dashboard).

Changes:

  • Rename RegistrationOrderSortOrder across C# serialization, CLI mapping, and the VS Code extension types/usages.
  • Remove .OrderBy(c => c.command.Name) from ResourceSnapshotMapper so command dictionaries are produced in registration order.
  • Update CLI and extension tests to assert the new ordering/field name.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/Aspire.Cli.Tests/Backchannel/ResourceSnapshotMapperTests.cs Updates command ordering and field name assertions to match the new contract.
src/Shared/Model/Serialization/ResourceJson.cs Renames the serialized field to SortOrder and updates the XML doc summary.
src/Aspire.Cli/Backchannel/ResourceSnapshotMapper.cs Removes redundant alphabetical ordering and stamps SortOrder.
extension/src/views/AppHostDataRepository.ts Renames the TypeScript contract field to sortOrder.
extension/src/utils/resourceDisplay.ts Sorts commands using sortOrder instead of registrationOrder.
extension/src/test/appHostTreeView.test.ts Updates test fixtures to use sortOrder.


/// <summary>
/// The zero-based index at which the command was registered.
/// The sort order of the command for display purposes.
visibility?: string | null;
state?: string | null;
registrationOrder?: number | null;
sortOrder?: number | null;
Comment on lines +9 to +10
const orderA = a.sortOrder ?? 0;
const orderB = b.sortOrder ?? 0;
var commands = snapshot.Commands
.Select((command, index) => (command, index))
.Where(c => IsCommandVisibleForConsumer(c.command.Visibility, includeDisabledCommands) && IsCommandVisibleToConsumer(c.command.State, includeDisabledCommands))
.OrderBy(c => c.command.Name)
Copy link
Copy Markdown
Contributor

@ellahathaway ellahathaway Jun 5, 2026

Choose a reason for hiding this comment

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

I ran aspire describe --format json and looked at a parameter's commands:

"commands": {
  "set-parameter":    { ..., "sortOrder": 0 },
  "delete-parameter": { ..., "sortOrder": 1 }
}

The OrderBy kept the raw JSON keys in a stable order, so without it, anything reading describe --format json directly (MCP, export, scripts, etc) now gets whatever order things registered in.

Not sure if that impact matters, but that's why I had originally kept the OrderBy in the previous PR.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants