Skip to content

Group channels in darc get-channels output and deduplicate categorization logic#5197

Merged
premun merged 10 commits intomainfrom
copilot/fix-5196
Aug 26, 2025
Merged

Group channels in darc get-channels output and deduplicate categorization logic#5197
premun merged 10 commits intomainfrom
copilot/fix-5196

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Aug 26, 2025

The darc get-channels command now groups channels by category in the text output, matching the organization used in the BarViz navigation menu. This provides better structure and readability when viewing channels in the CLI.

Additionally, the duplicate categorization logic between Darc and BarViz has been consolidated into a shared ChannelCategorizer class in the Microsoft.DotNet.ProductConstructionService.Client.Helpers namespace, eliminating code duplication and ensuring both tools use identical categorization logic.

Changes Made

  • Added ChannelCategorizer utility class in the shared Client project that implements the categorization logic
  • Modified WriteYamlChannelList() to group channels by category instead of simple alphabetical listing
  • Updated NavMenu.razor to use the shared ChannelCategorizer instead of its own duplicate logic (~50 lines of code removed)
  • Preserved JSON output format - only text output is affected by the grouping
  • Added comprehensive test suite with 6 test cases covering various scenarios
  • Fixed static state bug that was causing channel accumulation across multiple categorization calls

Example Output

Before:

(1)    .NET 8
(3)    Test Channel
(2)    VS Main

After:

.NET 8:
  (1)    .NET 8

VS:
  (2)    VS Main

Test:
  (3)    Test Channel

Categorization Logic

Channels are organized into predefined categories in priority order:

  • .NET 20, .NET 19, ... .NET 6, .NET (for .NET releases)
  • VS (for Visual Studio channels)
  • Windows (for Windows-related channels)
  • Test (for channels with classification="test")
  • Other (for channels that don't match other categories)

Categories with no channels are automatically excluded from the output. The categorization uses case-insensitive prefix matching, ensuring channels like ".NET 8 Preview" are correctly grouped under ".NET 8".

Fixes #5196.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits August 26, 2025 09:43
Co-authored-by: premun <7013027+premun@users.noreply.github.com>
Co-authored-by: premun <7013027+premun@users.noreply.github.com>
Copilot AI changed the title [WIP] Group channels in darc get-channels output Group channels in darc get-channels output Aug 26, 2025
Copilot AI requested a review from premun August 26, 2025 09:48
Copy link
Copy Markdown
Member

@premun premun left a comment

Choose a reason for hiding this comment

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

@copilot please add the .NET 11 group

Co-authored-by: premun <7013027+premun@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Aug 26, 2025

@copilot please add the .NET 11 group

Added the .NET 11 group to the channel categorizer. The group is positioned at the top of the priority list (before .NET 10) and will correctly categorize channels like ".NET 11 Preview" or ".NET 11". Commit: bad5e6d

Copilot AI requested a review from premun August 26, 2025 09:59
Copy link
Copy Markdown
Member

@premun premun left a comment

Choose a reason for hiding this comment

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

@copilot can the NavMenu.razor also use the ChannelCategorizer to deduplicate the code?

Co-authored-by: premun <7013027+premun@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Aug 26, 2025

@copilot can the NavMenu.razor also use the ChannelCategorizer to deduplicate the code?

Yes! I've now moved the ChannelCategorizer to the shared Microsoft.DotNet.ProductConstructionService.Client.Helpers namespace and updated NavMenu.razor to use it instead of its own duplicate categorization logic. This eliminates about 50 lines of duplicate code from NavMenu.razor and ensures both the Darc CLI and BarViz UI use the same categorization logic. Commit: df8d719

Copilot AI changed the title Group channels in darc get-channels output Group channels in darc get-channels output and deduplicate categorization logic Aug 26, 2025
Copilot AI requested a review from premun August 26, 2025 11:18
@premun premun marked this pull request as ready for review August 26, 2025 11:27
Copilot AI review requested due to automatic review settings August 26, 2025 11:27
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 improves the organization and maintainability of channel display logic by grouping channels by category in the darc get-channels command output and consolidating duplicate categorization logic into a shared utility class.

Key changes:

  • Shared categorization logic: Created ChannelCategorizer utility class to eliminate code duplication between Darc and BarViz
  • Enhanced CLI output: Modified text output to group channels by category (.NET versions, VS, Windows, Test, Other) while preserving JSON format
  • Comprehensive testing: Added test suite covering various scenarios including edge cases and output format verification

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Helpers/ChannelCategorizer.cs New shared utility class implementing channel categorization logic with predefined category hierarchy
src/Microsoft.DotNet.Darc/Darc/Operations/GetChannelsOperation.cs Updated to use shared categorizer and group channels by category in text output
src/ProductConstructionService/ProductConstructionService.BarViz/Layout/NavMenu.razor Refactored to use shared ChannelCategorizer instead of duplicate local implementation
test/Microsoft.DotNet.Darc.Tests/Operations/GetChannelsOperationTests.cs Comprehensive test suite covering operation behavior, output formats, and categorization edge cases
Test verification files Expected output snapshots for JSON, text, and grouped text formats

Comment thread test/Microsoft.DotNet.Darc.Tests/Operations/GetChannelsOperationTests.cs Outdated
Comment thread test/Microsoft.DotNet.Darc.Tests/Operations/GetChannelsOperationTests.cs Outdated
Comment thread test/Microsoft.DotNet.Darc.Tests/Operations/GetChannelsOperationTests.cs Outdated
Comment thread test/Microsoft.DotNet.Darc.Tests/Operations/GetChannelsOperationTests.cs Outdated
Comment thread test/Microsoft.DotNet.Darc.Tests/Operations/GetChannelsOperationTests.cs Outdated
adamzip
adamzip previously approved these changes Aug 26, 2025
Copy link
Copy Markdown
Contributor

@adamzip adamzip left a comment

Choose a reason for hiding this comment

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

Do we need to update the categorizer each time a new .NET major version comes out? If that's the case, could we anticipate future version, maybe by regex matching on .NET X where X is some whole integer?

@dkurepa
Copy link
Copy Markdown
Member

dkurepa commented Aug 26, 2025

we might want to hide this feature behind some flag, could be that there's some automation using the command?

@premun
Copy link
Copy Markdown
Member

premun commented Aug 26, 2025

Do we need to update the categorizer each time a new .NET major version comes out? If that's the case, could we anticipate future version, maybe by regex matching on .NET X where X is some whole integer?

Good point. We can just put a bunch of .NET versions there as empty groups are discarded.

we might want to hide this feature behind some flag, could be that there's some automation using the command?

I searched through the dnceng and devdiv orgs and didn't find any. I hope if people use this, they use --output-format json at the least.

adamzip
adamzip previously approved these changes Aug 26, 2025
@premun
Copy link
Copy Markdown
Member

premun commented Aug 26, 2025

@copilot fix the unit tests to match the last changes

Co-authored-by: premun <7013027+premun@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Aug 26, 2025

@copilot fix the unit tests to match the last changes

Fixed the unit test failures caused by a static state bug in ChannelCategorizer. The issue was that the static categories were being reused across multiple test runs, causing channels to accumulate. Now creates fresh category instances for each categorization call. All tests now pass. Commit: 3f68429

@premun premun requested a review from adamzip August 26, 2025 13:13
@premun premun enabled auto-merge (squash) August 26, 2025 13:13
@premun premun merged commit 0824900 into main Aug 26, 2025
8 of 9 checks passed
@premun premun deleted the copilot/fix-5196 branch August 26, 2025 13:56
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.

Group channels in darc get-channels output

5 participants