-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Fix Config Source Gen to avoid compilation error missing System.Collections.Generic namespace #121364
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 Source Gen to avoid compilation error missing System.Collections.Generic namespace #121364
Conversation
…ctions.Generic namespace
|
Tagging subscribers to this area: @dotnet/area-extensions-configuration |
|
CC @ezhevita |
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 moves the System.Collections.Generic namespace import to the initial namespace set in the binding helper code generator, removing conditional logic that previously added it only when processing object types.
- Adds
System.Collections.Genericto the default namespace set initialized inBindingHelperInfo.Builder - Removes the conditional namespace addition that occurred when registering object types
- Updates all baseline test files to reflect the new namespace being consistently included
- Adds a new test case for binding to collection-only scenarios
Reviewed Changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/libraries/Microsoft.Extensions.Configuration.Binder/gen/Specs/BindingHelperInfo.cs |
Moves System.Collections.Generic to the initial namespace set and removes conditional addition logic |
src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/GeneratorTests.cs |
Adds new test for binding to collection types only |
src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/ConfigurationBinder/Version1/*.generated.txt |
Updates baseline files to include the new namespace |
src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/ConfigurationBinder/Version1/*.generated.txt |
Updates baseline files to include the new namespace |
|
/ba-g Timeouts in Android and known test failures |
|
@tarekgh Since customers are reporting this against .NET 10 RC bits and the scenario is becoming more common, I would support submitting for servicing consideration, illustrating the webapiaot scenario, the code that triggers the error, and the workaround that you prescribed in the issue. The risk for the fix looks low. |
...rceGenerationTests/Baselines/net462/ConfigurationBinder/Version1/Bind_Instance.generated.txt
Show resolved
Hide resolved
src/libraries/Microsoft.Extensions.Configuration.Binder/gen/Emitter/Helpers.cs
Show resolved
Hide resolved
|
/ba-g the failures are known timeout issues. |
Fixes #118630
The configuration source generator can produce code that references collection types such as HashSet without including the System.Collections.Generic namespace. This results in a compilation error. More users have started encountering this issue when using project templates like webapiaot and disabling ImplicitUsings.