Disable conventional registration of InMemoryDynamicBackgroundWorker#25355
Merged
salihozkara merged 2 commits intorel-10.3from May 4, 2026
Merged
Conversation
InMemoryDynamicBackgroundWorker indirectly implements ISingletonDependency via IBackgroundWorker, so conventional registration tries to register it as a service. Its constructor takes a string workerName parameter that the DI container cannot resolve, which crashes any host that runs ServiceCollection validation (e.g. ASP.NET Core in Development, where WebApplicationBuilder.Build() enables ValidateOnBuild). The dynamic worker is created on demand by DefaultDynamicBackgroundWorkerManager and must not be auto-registered, so mark it with [DisableConventionalRegistration].
Contributor
There was a problem hiding this comment.
Pull request overview
This PR prevents InMemoryDynamicBackgroundWorker from being registered by ABP’s conventional DI scanning, avoiding ValidateOnBuild failures in Microsoft.Extensions.DependencyInjection when running without Autofac (notably ASP.NET Core Development defaults).
Changes:
- Marked
InMemoryDynamicBackgroundWorkerwith[DisableConventionalRegistration]so it’s not auto-registered as a singleton service. - Added a regression test ensuring the worker is absent from the service collection and that building a provider with
ValidateOnBuild = truesucceeds.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
framework/src/Volo.Abp.BackgroundWorkers/Volo/Abp/BackgroundWorkers/InMemoryDynamicBackgroundWorker.cs |
Disables conventional registration to prevent DI validation from trying to construct the worker (unresolvable string workerName). |
framework/test/Volo.Abp.BackgroundJobs.Tests/Volo/Abp/BackgroundWorkers/InMemoryDynamicBackgroundWorker_Registration_Tests.cs |
Regression test verifying the type is not registered and DI validation passes with ValidateOnBuild. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## rel-10.3 #25355 +/- ##
============================================
+ Coverage 49.30% 49.80% +0.49%
============================================
Files 3667 3609 -58
Lines 123121 120658 -2463
Branches 9404 9215 -189
============================================
- Hits 60707 60094 -613
+ Misses 60590 58760 -1830
+ Partials 1824 1804 -20 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
salihozkara
approved these changes
May 4, 2026
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.
InMemoryDynamicBackgroundWorkeris auto-registered as a Singleton becauseIBackgroundWorkerderives fromISingletonDependency. Its constructor takes astring workerNameparameter that DI cannot resolve, so any host that runsServiceCollectionvalidation (ASP.NET Core in Development withWebApplicationBuilder.Build()enablingValidateOnBuild) crashes at startup.Mark it
[DisableConventionalRegistration]since the manager creates instances on demand vianew.