Skip to content

Commit a61306a

Browse files
committed
feat: Add Dependency Injection Validation
1 parent 9a742b3 commit a61306a

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
55

66
Prefix your items with `(Template)` if the change is about the template and not the resulting application.
77

8+
## 3.10.X
9+
- Added Dependency Injection validation in the development environment.
10+
811
## 3.9.X
912
- Removed unnecessary `IsExternalInit.cs` files.
1013
- Renamed multiple components from the data access layer to not all be named `Repository`.

src/ApplicationTemplate.sln

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "root", "root", "{8711E408-6
1212
..\.editorconfig = ..\.editorconfig
1313
..\.gitignore = ..\.gitignore
1414
..\APP_README.md = ..\APP_README.md
15+
..\CHANGELOG.md = ..\CHANGELOG.md
1516
..\CODE_OF_CONDUCT.md = ..\CODE_OF_CONDUCT.md
1617
..\CONTRIBUTING.md = ..\CONTRIBUTING.md
1718
..\Directory.Build.props = ..\Directory.Build.props
@@ -24,7 +25,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "doc", "doc", "{4A31B4ED-94E
2425
ProjectSection(SolutionItems) = preProject
2526
..\doc\Architecture.md = ..\doc\Architecture.md
2627
..\doc\AzurePipelines.md = ..\doc\AzurePipelines.md
27-
..\CHANGELOG.md = ..\CHANGELOG.md
2828
..\doc\Configuration.md = ..\doc\Configuration.md
2929
..\doc\DataLoading.md = ..\doc\DataLoading.md
3030
..\doc\DefaultAnalytics.md = ..\doc\DefaultAnalytics.md

src/app/ApplicationTemplate.Presentation/Framework/Startup/CoreStartupBase.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,13 @@ private IServiceProvider CreateHostServices(string contentRootPath, string setti
183183
{
184184
loggingConfiguration(hostBuilderContext, loggingBuilder, isAppLogging: false);
185185
})
186+
// Configures the default service provider for the host.
187+
.UseDefaultServiceProvider((context, options) =>
188+
{
189+
// Enable validation check in development mode.
190+
// Validates the service provider's configuration when it is built, ensuring all services can be created and there are no missing or circular dependencies.
191+
options.ValidateOnBuild = context.HostingEnvironment.IsDevelopment();
192+
})
186193
.Build();
187194

188195
return coreHost.Services;

0 commit comments

Comments
 (0)