Rename RegistrationOrder to SortOrder and remove redundant OrderBy#17935
Rename RegistrationOrder to SortOrder and remove redundant OrderBy#17935Copilot wants to merge 2 commits into
Conversation
…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>
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 17935Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 17935" |
There was a problem hiding this comment.
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
RegistrationOrder→SortOrderacross C# serialization, CLI mapping, and the VS Code extension types/usages. - Remove
.OrderBy(c => c.command.Name)fromResourceSnapshotMapperso 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; |
| 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) |
There was a problem hiding this comment.
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.
Description
Addresses two post-merge review comments from @JamesNK on #17881:
RegistrationOrder→SortOrder— aligns with established convention (UrlDisplayPropertiesSnapshot.SortOrder)..OrderBy(c => c.command.Name)inResourceSnapshotMapper— consumers sort bySortOrder, so pre-sorting dictionary keys alphabetically is unnecessary.Changes:
ResourceJson.cs— property renameResourceSnapshotMapper.cs— drop.OrderBy(), use new field nameResourceSnapshotMapperTests.cs— updated assertions verify registration-order key sequenceAppHostDataRepository.ts,resourceDisplay.ts,appHostTreeView.test.ts— TypeScript field renameChecklist
<remarks />and<code />elements on your triple slash comments?