Skip to content

[Breaking change]: HostBuilder now enables ValidateOnBuild and ValidateScopes in Development environment #41887

Closed

Description

Description

Previously no validation was enabled by default.

Now, when in Development environment ValidateOnBuild and ValidateScopes will be enabled.

Version

.NET 9 Preview 7

Previous behavior

ValidateOnBuild and ValidateScopes default to false and are only enabled when users set them with UseDefaultServiceProvider.

New behavior

ValidateOnBuild and ValidateScopes will be set to true, when in the development environment and options have not be set with UseDefaultServiceProvider.

Type of breaking change

  • Binary incompatible: Existing binaries might encounter a breaking change in behavior, such as failure to load or execute, and if so, require recompilation.
  • Source incompatible: When recompiled using the new SDK or component or to target the new runtime, existing source code might require source changes to compile successfully.
  • Behavioral change: Existing binaries might behave differently at run time.

Reason for change

Enabling validation will help catch problems early in application startup rather than later (or not at all) when the application interacts with it's service provider.

Recommended action

No action necessary for applications which validate successfully. If you do see a validation error when testing in development then first try to fix it. If you cannot fix it you can disable validation by calling UseDefaultServiceProvider.

Feature area

ASP.NET Core, Extensions

Affected APIs

Microsoft.Extensions.Hosting.HostBuilder
Microsoft.Extensions.Hosting.HostBuilder.Build()


Associated WorkItem - 288934

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

📌 seQUESTeredIdentifies that an issue has been imported into Quest.Pri1High priority, do before Pri2 and Pri3breaking-changeIndicates a .NET Core breaking changedoc-ideaIndicates issues that are suggestions for new topics [org][type][category]in-prThis issue will be closed (fixed) by an active pull request.

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions