-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Create source generator for configuration binding #82179
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
|
Tagging subscribers to this area: @dotnet/area-extensions-configuration Issue Details
|
d27439a to
6c9f2ed
Compare
6c9f2ed to
2020a35
Compare
|
We have the green light from API review to proceed with this implementation. Still need to resolve CI failures but it's ready for a first look. |
...ft.Extensions.Configuration.Binder/gen/ConfigurationBinderSourceGenerator.Emitter.Helpers.cs
Outdated
Show resolved
Hide resolved
...ft.Extensions.Configuration.Binder/gen/ConfigurationBinderSourceGenerator.Emitter.Helpers.cs
Outdated
Show resolved
Hide resolved
...ft.Extensions.Configuration.Binder/gen/ConfigurationBinderSourceGenerator.Emitter.Helpers.cs
Outdated
Show resolved
Hide resolved
.../Microsoft.Extensions.Configuration.Binder/gen/ConfigurationBinderSourceGenerator.Emitter.cs
Outdated
Show resolved
Hide resolved
...ibraries/Microsoft.Extensions.Configuration.Binder/gen/ConfigurationBinderSourceGenerator.cs
Outdated
Show resolved
Hide resolved
.../Microsoft.Extensions.Configuration.Binder/gen/ConfigurationBinderSourceGenerator.Emitter.cs
Outdated
Show resolved
Hide resolved
...ft.Extensions.Configuration.Binder/gen/ConfigurationBinderSourceGenerator.Emitter.Helpers.cs
Outdated
Show resolved
Hide resolved
...s/Microsoft.Extensions.Configuration.Binder/tests/Common/ConfigurationBinderTests.Helpers.cs
Outdated
Show resolved
Hide resolved
| (node, _) => node is InvocationExpressionSyntax invocation, | ||
| (context, cancellationToken) => new BinderInvocationOperation(context, cancellationToken)); | ||
|
|
||
| IncrementalValueProvider<(KnownTypeData, ImmutableArray<BinderInvocationOperation>)> inputData = compilationData.Combine(inputCalls.Collect()); |
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.
Why do we need to call Combine here? Assuming you have an application with 500 BinderInvocationOperation locations, then changing just one would result in all 500 of them being aggregated and recalculated.
Assuming there is no strong performance reason behind consolidating one parser for all operations, I would recommend keeping these independent as an IncrementalValueSProvider<(KnownTypeData, BinderInvocationOperation)>. IncrementalValuesProvider also has a RegisterSourceOutput which can be triggered independently for each of its components without forcing recalculation of the others.
...ons.Configuration.Binder/tests/SourceGenerationTests/Baselines/TestBindCallGen.generated.txt
Show resolved
Hide resolved
...ions.Configuration.Binder/tests/SourceGenerationTests/Baselines/TestGetCallGen.generated.txt
Show resolved
Hide resolved
...Microsoft.Extensions.Configuration.Binder/gen/ConfigurationBindingSourceGenerator.Emitter.cs
Show resolved
Hide resolved
...braries/Microsoft.Extensions.Configuration.Binder/gen/ConfigurationBindingSourceGenerator.cs
Show resolved
Hide resolved
...crosoft.Extensions.Configuration.Binder/tests/Common/ConfigurationBinderTests.Collections.cs
Show resolved
Hide resolved
...crosoft.Extensions.Configuration.Binder/tests/Common/ConfigurationBinderTests.Collections.cs
Show resolved
Hide resolved
...aries/Microsoft.Extensions.Configuration.Binder/tests/ConfigurationCollectionBindingTests.cs
Show resolved
Hide resolved
...s/Microsoft.Extensions.Configuration.Binder/tests/Common/ConfigurationBinderTests.Helpers.cs
Show resolved
Hide resolved
...ons.Configuration.Binder/tests/SourceGenerationTests/Baselines/TestBindCallGen.generated.txt
Show resolved
Hide resolved
...ons.Configuration.Binder/tests/SourceGenerationTests/Baselines/TestBindCallGen.generated.txt
Show resolved
Hide resolved
...Microsoft.Extensions.Configuration.Binder/gen/ConfigurationBindingSourceGenerator.Helpers.cs
Show resolved
Hide resolved
...Microsoft.Extensions.Configuration.Binder/gen/ConfigurationBindingSourceGenerator.Helpers.cs
Show resolved
Hide resolved
src/libraries/Microsoft.Extensions.Configuration.Binder/gen/Resources/Strings.resx
Show resolved
Hide resolved
| namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration | ||
| { | ||
| internal sealed record SourceGenerationSpec( | ||
| HashSet<TypeSpec> TypesForBindMethodGen, |
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.
💡 This was my solution:
DotNetAnalyzers/StyleCopAnalyzers@253d408
If there is a better solution I'm interested to know.
|
Thanks for reviewing this PR folks. I've opened issues to address feedback not resolved in this PR. They are linked above and also tracked by #79527. I'll merge this PR now to make preview 3 & because additional changes will require more review & churn. I believe the current implementation is viable for users to try as-is. W.r.t risk to the product caused by issues/bugs in the feature:
Here are the follow up items I'll try to address in preview 3 (snaps on Monday 3/20, cc @carlossanlop): |
...onfiguration.Binder/tests/SourceGenerationTests/ConfingurationBindingSourceGeneratorTests.cs
Show resolved
Hide resolved
|
How do I enable the source generator? |
@davidfowl see layomi's comment above:
Make sure that the latest available |
Uh oh!
There was an error while loading. Please reload this page.