-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Fix: Config binder generator doesn't generate code when named arguments are out of order #91961
Conversation
Tagging subscribers to this area: @dotnet/area-system-configuration Issue DetailsConfig binder generator doesn't generate code when named arguments are out of order like in: internal void Configure(IConfiguration configuration) =>
ConfigurationBinder.Bind(instance: this, configuration: configuration); The issue also happens for ConfigurationBinder.Get(...) overloads. Fixes #90908
|
src/libraries/Microsoft.Extensions.Configuration.Binder/gen/Parser/ConfigurationBinder.cs
Show resolved
Hide resolved
I believe it applies to all the extensions methods -- so in addition to |
...tests/SourceGenerationTests/Baselines/ConfigurationBinder/Bind_NamedParameters.generated.txt
Outdated
Show resolved
Hide resolved
Did not found any indexed access of arguments in those files, only |
Per offline discussion, we do need a fix/tests for these as well, e.g. using System;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
public class Program
{
public static void Main()
{
ServiceCollection services = new();
IConfiguration configuration = new ConfigurationBuilder().Build();
services.Configure<string>(name: "string", configureBinder: null, config: configuration);
}
} |
...soft.Extensions.Configuration.Binder/tests/SourceGenerationTests/GeneratorTests.Baselines.cs
Outdated
Show resolved
Hide resolved
@layomia I have been testing similar code to see if I can repro it, but encountering errors similar to #91258 even though I am using latest
|
Tagging subscribers to this area: @dotnet/area-extensions-configuration Issue DetailsConfig binder generator doesn't generate code when named arguments are out of order like in: internal void Configure(IConfiguration configuration) =>
ConfigurationBinder.Bind(instance: this, configuration: configuration); The issue also happens for ConfigurationBinder.Get(...) overloads. Fixes #90908
|
That's odd. Checking that out. In the meantime, you can verify your fix by adding unit tests like the ones you add for |
Yes, of course that is the plan, just wanted to let you know about these errors as it might be important. |
…, add test for OptionsBuilder... and ServiceCollection extensins
Added unit tests for those, there were no need a code fix for those extension methods |
...ensions.Configuration.Binder/tests/SourceGenerationTests/GeneratorTests.Baselines.Options.cs
Outdated
Show resolved
Hide resolved
...ensions.Configuration.Binder/tests/SourceGenerationTests/GeneratorTests.Baselines.Options.cs
Outdated
Show resolved
Hide resolved
...soft.Extensions.Configuration.Binder/tests/SourceGenerationTests/GeneratorTests.Baselines.cs
Outdated
Show resolved
Hide resolved
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.
Thanks!
One CI build not finishes even running for more than 3.5hrs, going to merge |
/backport to release/8.0 |
Started backporting to release/8.0: https://github.com/dotnet/runtime/actions/runs/6229413419 |
Config binder generator doesn't generate code when named arguments are out of order like in:
The issue also happens for ConfigurationBinder.Get(...) overloads.
Fixes #90908