Skip to content

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

Merged
merged 3 commits into from
Jul 17, 2025

Conversation

MichalStrehovsky
Copy link
Member

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

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.
@Copilot Copilot AI review requested due to automatic review settings July 16, 2025 10:19
@MichalStrehovsky MichalStrehovsky added breaking-change Issue or PR that represents a breaking API or functional change over a prerelease. area-Extensions-Configuration labels Jul 16, 2025
Copy link
Contributor

@Copilot Copilot AI left a 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 of All 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

@dotnet-policy-service dotnet-policy-service bot added the needs-breaking-change-doc-created Breaking changes need an issue opened with https://github.com/dotnet/docs/issues/new?template=dotnet label Jul 16, 2025
@MichalStrehovsky MichalStrehovsky added the linkable-framework Issues associated with delivering a linker friendly framework label Jul 16, 2025
Copy link
Contributor

Tagging subscribers to this area: @dotnet/area-meta
See info in area-owners.md if you want to be subscribed.

@tarekgh
Copy link
Member

tarekgh commented Jul 16, 2025

@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

@MichalStrehovsky
Copy link
Member Author

@MichalStrehovsky can you look at the failures? https://github.com/dotnet/runtime/pull/117707/checks?check_run_id=46091806985.

Fixed.

Is there any app compat concerning this change? What kind of breaking would be? Also, could you please file a breaking change issue too?

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.

@tarekgh
Copy link
Member

tarekgh commented Jul 16, 2025

CC @stephentoub @ericst @jeffhandley @halter73 just FYI.

@MichalStrehovsky MichalStrehovsky merged commit 64bc826 into dotnet:main Jul 17, 2025
84 of 87 checks passed
@MichalStrehovsky MichalStrehovsky deleted the binderall branch July 17, 2025 22:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Meta breaking-change Issue or PR that represents a breaking API or functional change over a prerelease. linkable-framework Issues associated with delivering a linker friendly framework needs-breaking-change-doc-created Breaking changes need an issue opened with https://github.com/dotnet/docs/issues/new?template=dotnet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants