Skip to content

Conversation

@KubaZ2
Copy link
Member

@KubaZ2 KubaZ2 commented Jan 28, 2026

  • Refactor Role and RestGuild comparison logic to match Discord's hierarchy rules, considering both position and ID.
  • Redefine Role comparison operators (>, <, >=, <=) for correct ordering.
  • Update CanManageAttribute, NormalCommands, and CustomCommandModule to use new comparison logic.
  • Add RoleTest project with comprehensive MSTest unit tests for role and user comparison.
  • Enable parallel test execution in test project.
  • Improves correctness and test coverage for role/user hierarchy.

- Refactor Role and RestGuild comparison logic to match Discord's hierarchy rules, considering both position and ID.
- Redefine Role comparison operators (>, <, >=, <=) for correct ordering.
- Update CanManageAttribute, NormalCommands, and CustomCommandModule to use new comparison logic.
- Add RoleTest project with comprehensive MSTest unit tests for role and user comparison.
- Enable parallel test execution in test project.
- Improves correctness and test coverage for role/user hierarchy.
@github-actions
Copy link

The documentation preview is available at https://preview.netcord.dev/252.

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

Refines role/user hierarchy comparisons to align with Discord-style ordering (role position with ID tie-break), updates call sites to use the new comparison behavior, and adds a dedicated test project validating the new ordering semantics.

Changes:

  • Redefines Role comparison (CompareTo and relational operators) to incorporate both Position and Id.
  • Refactors RestGuild.Compare(PartialGuildUser, PartialGuildUser) to use role comparisons and handle role-less users.
  • Adds a new MSTest project (RoleTest) with unit tests for role and guild-user comparison, enabling parallel test execution.

Reviewed changes

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

Show a summary per file
File Description
Tests/RoleTest/RoleTest.csproj Adds new MSTest test project referencing NetCord.
Tests/RoleTest/RoleComparison.cs Unit tests validating Role comparison and operators.
Tests/RoleTest/GuildUserComparison.cs Unit tests validating RestGuild.Compare user hierarchy logic.
Tests/RoleTest/AssemblyInfo.cs Enables method-level parallel test execution.
Tests/NetCord.Test/Commands/NormalCommands.cs Updates role sorting to rely on default role ordering.
Tests/NetCord.Test/Commands/Administrative/CanManageAttribute.cs Switches manage-check logic to use guild.Compare(...).
NetCord/Role.cs Implements position + ID tie-break ordering for role comparisons/operators.
NetCord/Rest/RestGuild.cs Updates user comparison logic to use role ordering rules.
NetCord.slnx Adds the new RoleTest project to the solution.
Documentation/guides/services/CustomModuleBasesAndContexts/CustomModuleBases/CustomCommandModule.cs Updates sample role ordering to use the new default ordering.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Replaced strict 1/-1 checks with greater/less than zero in role
comparison tests, making them more robust to different CompareTo
implementations that may return any positive or negative value.
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

Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@KubaZ2 KubaZ2 merged commit a9ce2ac into alpha Jan 28, 2026
1 check passed
@KubaZ2 KubaZ2 deleted the feature/better-role-comparison branch January 28, 2026 23:41
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.

2 participants