Skip to content
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

ConfigurationBinder source generator shouldn't generate empty methods #92151

Open
ericstj opened this issue Sep 15, 2023 · 1 comment
Open

ConfigurationBinder source generator shouldn't generate empty methods #92151

ericstj opened this issue Sep 15, 2023 · 1 comment
Labels
area-Extensions-Configuration enhancement Product code improvement that does NOT require public API changes/additions
Milestone

Comments

@ericstj
Copy link
Member

ericstj commented Sep 15, 2023

Description

I noticed the following empty method when reviewing the codegen for the repro in #91324

        public static void BindCore(IConfiguration configuration, ref EndPointCollection instance, bool defaultValueIfNotFound, BinderOptions? binderOptions)
        {
            foreach (IConfigurationSection section in configuration.GetChildren())
            {
            }
        }

I tried this with an empty class, and it seems we'll skip that, so this might be more specific to collection initialization.

Reproduction Steps

Compile the repro in #91324 when setting <EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>.

Observe the generated code.

Expected behavior

Only meaninful methods are generated, methods that do nothing should be avoided.

Actual behavior

Method generated that merely enumerates the configuration children of section.

Regression?

No

Known Workarounds

No response

Configuration

No response

Other information

No response

@ericstj
Copy link
Member Author

ericstj commented Sep 19, 2023

This is not necessary for 8.0.

@ericstj ericstj added the enhancement Product code improvement that does NOT require public API changes/additions label Sep 19, 2023
@ericstj ericstj modified the milestones: 9.0.0, 10.0.0 Aug 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Extensions-Configuration enhancement Product code improvement that does NOT require public API changes/additions
Projects
None yet
Development

No branches or pull requests

1 participant