Skip to content

Add support for keyed services#105

Merged
KubaZ2 merged 1 commit into
alphafrom
feature/keyed-di-support
May 14, 2025
Merged

Add support for keyed services#105
KubaZ2 merged 1 commit into
alphafrom
feature/keyed-di-support

Conversation

@KubaZ2

@KubaZ2 KubaZ2 commented May 14, 2025

Copy link
Copy Markdown
Member

No description provided.

@KubaZ2 KubaZ2 requested a review from Copilot May 14, 2025 12:41

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 adds support for keyed services by introducing a new service resolver provider parameter across various command and interaction components. The key changes include:

  • Updating InvocationHelper delegate creation methods to accept an additional service resolver provider.
  • Modifying interface methods and configuration classes to incorporate the new ServiceResolverProvider.
  • Adding a new KeyedServiceResolverProvider implementation and updating related project files.

Reviewed Changes

Copilot reviewed 40 out of 40 changed files in this pull request and generated no comments.

Show a summary per file
File Description
NetCord.Services/ApplicationCommands/SlashCommandInfo.cs Updated delegate creation to include ServiceResolverProvider in module commands.
NetCord.Services/ApplicationCommands/SlashCommandGroupInfo.cs Updated InitializeAutocomplete to pass ServiceResolverProvider.
NetCord.Services/ApplicationCommands/MessageCommandInfo.cs Updated delegate creation for message commands with ServiceResolverProvider.
NetCord.Services/ApplicationCommands/ISlashCommandParameterNameProcessor.cs Added Instance properties to parameter name processors.
NetCord.Services/ApplicationCommands/IAutocompleteInfo.cs Updated autocomplete initialization to require ServiceResolverProvider.
NetCord.Services/ApplicationCommands/ApplicationCommandServiceConfiguration.cs Updated configuration to use singleton instances and include ServiceResolverProvider.
NetCord.Services/ApplicationCommands/ApplicationCommandService.cs Modified autocomplete execution to pass ServiceResolverProvider.
NetCord.Services/ApplicationCommands/ApplicationCommandResultResolverProvider.cs Updated to use a singleton instance pattern.
Hosting/NetCord.Hosting/NetCord.Hosting.csproj Added new files for the keyed service resolver support.
Hosting/NetCord.Hosting/DelegateHandlerHelper.cs Updated service expression calls to include KeyedServiceResolverProvider.
Hosting/NetCord.Hosting.Services/KeyedServiceResolverProvider.cs New implementation for keyed service resolution.
Hosting/NetCord.Hosting.Services/ContextHelper.cs Updated context delegate creation to accept ServiceResolverProvider.
Hosting/NetCord.Hosting.Services/ComponentInteractions/* Added ServiceResolverProvider properties and updated context creation logic.
Hosting/NetCord.Hosting.Services/Commands/* Added ServiceResolverProvider properties and updated context creation logic for commands and interactions.
Comments suppressed due to low confidence (3)

NetCord.Services/ApplicationCommands/SlashCommandInfo.cs:24

  • Ensure that InvocationHelper.CreateModuleDelegate has been updated to correctly accept and handle the additional ServiceResolverProvider parameter, and verify that all related call sites are consistent with the new method signature.
_invokeAsync = InvocationHelper.CreateModuleDelegate(method, declaringType, parameters.Select(p => p.Type), configuration.ResultResolverProvider, configuration.ServiceResolverProvider);

NetCord.Services/ApplicationCommands/MessageCommandInfo.cs:17

  • Confirm that CreateModuleDelegate is correctly updated to support the additional ServiceResolverProvider parameter, and that the conditional array for messageParameter is handled as intended.
_invokeAsync = InvocationHelper.CreateModuleDelegate(method, declaringType, messageParameter ? [typeof(RestMessage)] : [], configuration.ResultResolverProvider, configuration.ServiceResolverProvider);

Hosting/NetCord.Hosting.Services/ComponentInteractions/ComponentInteractionHandler.cs:50

  • Ensure that the updated call to ContextHelper.CreateContextDelegate, which now requires a ServiceResolverProvider, correctly reflects the intended configuration source and that the renaming from _interactionService to _componentInteractionService is consistently applied.
_createContext = optionsValue.CreateContext ?? ContextHelper.CreateContextDelegate<TInteraction, GatewayClient?, TContext>(_componentInteractionService.Configuration.ServiceResolverProvider);

@github-actions

Copy link
Copy Markdown

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

@KubaZ2 KubaZ2 merged commit 945b737 into alpha May 14, 2025
1 check passed
@KubaZ2 KubaZ2 deleted the feature/keyed-di-support branch May 14, 2025 12:45
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