-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Drop usage of .All
in Microsoft.Extensions
#117707
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The existing usage is a leftover from when we didn't have the binding source generation and the guidance was to suppress warning and preserve everything manually. We had a similar thing for S.T.Json in the past that we also deleted/dropped in favor of the source generation. All the updated places are already marked RUC.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR removes DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)
annotations from generic type parameters across Microsoft.Extensions libraries. This cleanup is possible because these libraries now use binding source generation instead of manual reflection-based binding, making the broad "All" member preservation unnecessary since the required members are preserved automatically by the source generator.
- Removes
DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)
from configuration binding and options extension methods - Updates class declarations to remove the broad member access requirements
- Refines one internal method to use
AllProperties
instead ofAll
for more precise member preservation
Reviewed Changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
OptionsConfigurationServiceCollectionExtensions.cs | Removes DynamicallyAccessedMembers.All from Configure method type parameters |
OptionsBuilderConfigurationExtensions.cs | Removes DynamicallyAccessedMembers.All from Bind and BindConfiguration method type parameters |
NamedConfigureFromConfigurationOptions.cs | Removes DynamicallyAccessedMembers.All from class type parameter |
ConfigureFromConfigurationOptions.cs | Removes DynamicallyAccessedMembers.All from class type parameter |
ConsoleLoggerExtensions.cs | Removes DynamicallyAccessedMembers.All from TOptions type parameter in formatter methods |
LoggerProviderConfigureOptions.cs | Removes DynamicallyAccessedMembers.All from TOptions type parameter |
LoggerProviderConfigurationExtensions.cs | Removes DynamicallyAccessedMembers.All from RegisterProviderOptions method |
ConfigurationBinder.cs | Removes most DynamicallyAccessedMembers.All annotations, refines one to use AllProperties |
Reference assemblies | Updates public API signatures to match implementation changes |
src/libraries/Microsoft.Extensions.Configuration.Binder/src/ConfigurationBinder.cs
Outdated
Show resolved
Hide resolved
src/libraries/Microsoft.Extensions.Configuration.Binder/src/ConfigurationBinder.cs
Outdated
Show resolved
Hide resolved
…nfigurationBinder.cs
Tagging subscribers to this area: @dotnet/area-meta |
@MichalStrehovsky can you look at the failures? https://github.com/dotnet/runtime/pull/117707/checks?check_run_id=46091806985. Is there any app compat concerning this change? What kind of breaking would be? Also, could you please file a breaking change issue too? CC @ericstj |
Fixed.
Yup, that's why I added the breaking-change label. The break is that if someone is using this with trimming and without the source generator (and suppresses the trimming warnings that are generated for all of the methods this is updating), we'd previously keep members on the T (and presumably some of this still worked with trimming). Now switching to the source generator becomes a harder requirement. It can still be worked around by manual preservation and warning suppression. We don't recommend/support such use cases. |
CC @stephentoub @ericst @jeffhandley @halter73 just FYI. |
The existing usage is a leftover from when we didn't have the binding source generation and the guidance was to suppress warning and preserve everything manually. We had a similar thing for S.T.Json in the past that we also deleted/dropped in favor of the source generation.
All the updated places are already marked RUC.
Cc @eerhardt - as you suggested on Teams