Skip to content

Modernise codebase to C# 12 and fix formatting bugs - #417

Draft
jedrek0429 wants to merge 4 commits into
NetCordDev:mainfrom
jedrek0429:primary-constructors
Draft

jedrek0429 wants to merge 4 commits into
NetCordDev:mainfrom
jedrek0429:primary-constructors

Conversation

@jedrek0429

@jedrek0429 jedrek0429 commented Sep 15, 2026

Copy link
Copy Markdown
Contributor
  • 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; or using NetCord.Rest.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.

- 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.
@jedrek0429
jedrek0429 marked this pull request as draft September 15, 2026 17:15
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.

1 participant