Modernise codebase to C# 12 and fix formatting bugs - #417
Draft
jedrek0429 wants to merge 4 commits into
Draft
jedrek0429 wants to merge 4 commits into
jedrek0429 wants to merge 4 commits into
Conversation
- Reduced traditional constructors to primary constructors across models.
- Utilised secondary constructors (`: this(...)`) for classes with constructor overloads.
- Removed unnecessary private fields and traditional `if` checks in constructors in favour of pattern matching.
- Added `using NetCord.JsonModels;` and simplified type references from `JsonModels.X` to `X`.
- Added missing XML documentation to all refactored classes and properties.
- Added `IJsonModel` implementation to `InteractionResolvedData` and `Interaction`.
- Removed deprecated `Summary` property from `IntegrationApplication`.
- Fixed an issue in `InteractionResolvedData` where `Users` mapping relied on dictionary iteration order matching `GuildUsers`, replacing manual enumerator iteration with safe `TryGetValue` lookups.
- Fixed field initialization order bugs in `RestGuild` where `Id` evaluated to `0` during `Roles` and `Emojis` dictionary initialization.
- Retained explicit constructors for `Guild` and `RestGuild` to support complex update/copy constructor logic.
- Retained explicit constructor for `RestMessage` and `RestGuild` to support complex constructor logic.
- Modernised `Interaction` class and optimised object factory.
- Retained explicit constructor for `Interaction` to support complex constructor logic.
- Modernised `WebhookEventArgs` by utilising constructor parameters, enforcing `readonly` encapsulation on event data fields, and aligning `ApplicationDeauthorizedWebhookEventArgs` with the authorization class structure.
- Retained explicit constructor for `WebhookEventArgs` to support complex constructor logic.
- Removed `private protected readonly` field `_jsonModels` from `User`, `Webhook` and `ApplicationCommand`.
- Removed `private protected` field `_client` from `CustomEmoji`.
- Removed `private readonly` field `_client` from `GuildSticker`.
- Refactored `ApplicationCommandOption`, `CustomEmoji` and `ApplicationCommand` string formatting to fix bugs and improve performance.
- Retained explicit constructor for `GuildScheduledEventUser`, `MessageComponentInteraction` and `GuildScheduledEventUser` to handle inline mutations.
- Initialization requires an in-flight side effect mutation of the underlying jsonModel properties before child entities can be correctly instantiated. This could be refactored in a separate PR.
… of NetCord.JsonModels
jedrek0429
marked this pull request as draft
September 15, 2026 17:15
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
: this(...)) for classes with constructor overloads.ifchecks in constructors in favour of pattern matching.using NetCord.JsonModels;orusing NetCord.Rest.JsonModels;and simplified type references fromJsonModels.XtoX.IJsonModelimplementation toInteractionResolvedDataandInteraction.Summaryproperty fromIntegrationApplication.InteractionResolvedDatawhereUsersmapping relied on dictionary iteration order matchingGuildUsers, replacing manual enumerator iteration with safeTryGetValuelookups.RestGuildwhereIdevaluated to0duringRolesandEmojisdictionary initialization.GuildandRestGuildto support complex update/copy constructor logic.RestMessageandRestGuildto support complex constructor logic.Interactionclass and optimised object factory.Interactionto support complex constructor logic.WebhookEventArgsby utilising constructor parameters, enforcingreadonlyencapsulation on event data fields, and aligningApplicationDeauthorizedWebhookEventArgswith the authorization class structure.WebhookEventArgsto support complex constructor logic.private protected readonlyfield_jsonModelsfromUser,WebhookandApplicationCommand.private protectedfield_clientfromCustomEmoji.private readonlyfield_clientfromGuildSticker.ApplicationCommandOption,CustomEmojiandApplicationCommandstring formatting to fix bugs and improve performance.GuildScheduledEventUser,MessageComponentInteractionandGuildScheduledEventUserto handle inline mutations.