You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Consider merging Microsoft.Extensions.Options.DataAnnotations into Microsoft.Extensions.Options #82844
The Microsoft.Extensions.Options.DataAnnotations library only exists because it has a dependency on System.ComponentModel.Annotations. Since System.ComponentModel.Annotations wasn't in netstandard2.0 by default, the code in this library was split into its own package instead of being added to Microsoft.Extensions.Options.
However, recently we've added a dependency from Microsoft.Extensions.Options netstandard2.0 to System.ComponentModel.Annotations in the 6.0.0-preview5.21301.5 NuGet package. It looks like this was added by a combination of #52084 + #35606.
Also, as of 6.0, System.ComponentModel.Annotations is now part of the netX.0+ TFM by default. It is no longer a separate NuGet package.
With #82749, we are doubling down on this dependency, and fully adding System.ComponentModel.Annotations code to Microsoft.Extensions.Options.
Given all these changes, it doesn't make sense to keep Microsoft.Extensions.Options.DataAnnotations as a separate library/NuGet package. It is just an extra package, assembly, etc and can be merged into Microsoft.Extensions.Options.
I'm not exactly sure how to do this with NuGet packages. I know we will need TypeForwardedTo attributes in order to keep back compat working. Does that mean we will need to keep shipping a NuGet package for Microsoft.Extensions.Options.DataAnnotations with just the TypeForwardedTo attribute? Maybe we only need to ship 1 more - 8.0.0 with TypeForwardedTo and then it can be dead-ended after that?
This sounds reasonable. Is there any urgency here or is this just about cleaning things up? (trying to understand if merging them will enable any scenarios)
If the service name is not set, an exception is raised DataAnnotation validation failed for 'ConfigurationRoot' members: 'ServiceName' . That doesn't say anything about the configuration name to be set.
Activity
ericstj commentedon Mar 1, 2023
This sounds reasonable. Is there any urgency here or is this just about cleaning things up? (trying to understand if merging them will enable any scenarios)
tarekgh commentedon Mar 1, 2023
My understanding there is no urgency. This mostly optimizes loading one assembly instead of two in the apps.
eerhardt commentedon Mar 2, 2023
Agreed. This is more of a "clean up" thing, and isn't blocking any scenarios.
tarekgh commentedon Jul 25, 2023
I talked offline with @ericstj and we believe this better be done in the early cycle of the next release and there will be some risk doing it now.
alrz commentedon Oct 30, 2024
As part of this I'd like to bring up an issue when validation fails, which probably needs this two packages be tightly coupled,
DataAnnotation validation failed for '<type>' members: '<property-name>'When using
[ConfigurationKeyName], that name/path should appear in the exception, as the<property-name>isn't quite helpful.tarekgh commentedon Oct 30, 2024
@alrz could you please provide a small reproduce project for the issue?
alrz commentedon Oct 30, 2024
When
[ConfigurationKeyName]is used in conjunction with annotations, only the property name is mentioned in the exception, not the path:If the service name is not set, an exception is raised
DataAnnotation validation failed for 'ConfigurationRoot' members: 'ServiceName'. That doesn't say anything about the configuration name to be set.rosebyte commentedon Mar 17, 2026
Triage: we may consider it when we will have capacity.