EndpointBuilder.ApplicationServices should use init
instead of set
#43544
Labels
api-approved
API was approved in API review, it can be implemented
area-web-frameworks
*DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels
Milestone
Background and Motivation
When doing more work with
EndpointBuilder
as part of #43543, I noticed that it was odd and unnecessary thatApplicationServices
could be modified after construction. Usinginit
doesn't completely prevent this, but it makes it clear it's unintended.I also think that IEndpointMetadataProvider and IEndpointMetadataProvider belong in Http.Abstractions instead of Http.Extensions. It doesn't have any big dependency, and we already have all our other endpoint metadata related stuff there like
EndpointBuilder
itself.Proposed API
Usage Examples
Alternative Designs
Leave it as
set
. Leave the providers inHttp.Extensions.dll
.Risks
I think it's riskier to leave it as
set
. It's new API, and we could always remove the init-onlyness in a later release. I don't think it's a huge problem either way though.If someone wanted to enlighten an existing EndpointBuilder they didn't construct, the C# language will now try to stop them from modifying it. This might be annoying, but changing this value after construction could lead to some weird hard-to-diagnose bugs.
I cannot think of any justification for not moving the providers to
Http.Abstractions.dll
.The text was updated successfully, but these errors were encountered: