-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Description
Description
var dict = conf.GetSection(sectionPrefix).Get<IDictionary<string, string>>();generates code w/o the correct System.Collections.Generic namespace for public static void ValidateConfigurationKeys(Type type, Lazy<HashSet<string>> keys, IConfiguration configuration, BinderOptions? binderOptions) where it declares a Lazy<HashSet<string>> argument.
Reproduction Steps
See above.
Expected behavior
The generator produces compliable code.
Actual behavior
But it doesn't.
Regression?
No response
Known Workarounds
Global/implicit using directives can be used as a workaround.
Configuration
Which version of .NET is the code running on? .NET 9.0.
What OS and version, and what distro if applicable? Windows 10.
What is the architecture (x64, x86, ARM, ARM64)? x64.
Do you know whether it is specific to that configuration? No idea.
If you're using Blazor, which web browser(s) do you see this issue in? N/A.
Other information
The line
runtime/src/libraries/Microsoft.Extensions.Configuration.Binder/gen/Specs/BindingHelperInfo.cs
Line 170 in 811da24
| _namespaces.Add("System.Collections.Generic"); |
ObjectSpec root type, but it generates the validation method assuming the namespace is added unconditionally. I think just making it do so should fix this, worst case scenario it adds a redundant used namespace declaration, which I think is negligible.