-
-
Notifications
You must be signed in to change notification settings - Fork 30
Update role and user comparison logic, add tests #252
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
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.
|
The documentation preview is available at https://preview.netcord.dev/252. |
There was a problem hiding this 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
Rolecomparison (CompareToand relational operators) to incorporate bothPositionandId. - 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.
There was a problem hiding this 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.