feat(AutoComplete): update UseElasticSearch method signature#749
Merged
feat(AutoComplete): update UseElasticSearch method signature#749
Conversation
Changed the parameter type of the `UseElasticSearch` method in `AutoCompleteOptionsExtensions.cs` from `Action<ElasticSearchAutoCompleteOptions>` to `Action<IServiceProvider, ElasticSearchAutoCompleteOptions>`. Updated internal method calls accordingly to pass the `IServiceProvider` instance. Modified all calls to `UseElasticSearch` in `AutoCompleteTest.cs` to accommodate the new method signature, ensuring proper passing of `IServiceProvider` and `ElasticSearchAutoCompleteOptions` instances. These changes enhance the flexibility of the `UseElasticSearch` method, allowing access to the service provider for configuring `ElasticSearchAutoCompleteOptions` with additional services and dependencies.
There was a problem hiding this comment.
Pull Request Overview
This PR updates the UseElasticSearch method signature to include an IServiceProvider parameter, enhancing flexibility by enabling dependency injection during the configuration of ElasticSearchAutoCompleteOptions.
- Updated the UseElasticSearch method in AutoCompleteOptionsExtensions.cs to pass IServiceProvider into the action callback.
- Modified all test call sites in AutoCompleteTest.cs to use a two-parameter lambda, accommodating the new method signature.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/Contrib/SearchEngine/AutoComplete/Tests/Masa.Contrib.SearchEngine.AutoComplete.ElasticSearch.Tests/AutoCompleteTest.cs | Updated test lambdas to include and pass along the unused serviceProvider parameter with the new method signature. |
| src/Contrib/SearchEngine/AutoComplete/Masa.Contrib.SearchEngine.AutoComplete.ElasticSearch/Extensions/AutoCompleteOptionsExtensions.cs | Updated the UseElasticSearch extension to invoke the action with both serviceProvider and elasticSearchAutoCompleteOptions. |
Comments suppressed due to low confidence (1)
src/Contrib/SearchEngine/AutoComplete/Tests/Masa.Contrib.SearchEngine.AutoComplete.ElasticSearch.Tests/AutoCompleteTest.cs:25
- The 'serviceProvider' parameter is currently unused in the lambda. To improve code clarity and indicate its intentional omission, consider renaming it to '_serviceProvider' or using a discard if supported.
autoCompleteOptions.UseElasticSearch((serviceProvider, options) =>
wzh425
approved these changes
Jun 4, 2025
|
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.



Changed the parameter type of the
UseElasticSearchmethod inAutoCompleteOptionsExtensions.csfromAction<ElasticSearchAutoCompleteOptions>toAction<IServiceProvider, ElasticSearchAutoCompleteOptions>. Updated internal method calls accordingly to pass theIServiceProviderinstance.Modified all calls to
UseElasticSearchinAutoCompleteTest.csto accommodate the new method signature, ensuring proper passing ofIServiceProviderandElasticSearchAutoCompleteOptionsinstances.These changes enhance the flexibility of the
UseElasticSearchmethod, allowing access to the service provider for configuringElasticSearchAutoCompleteOptionswith additional services and dependencies.