-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Configuration binding source generator fails with CS8598 error #89010
Comments
Tagging subscribers to this area: @dotnet/area-extensions-configuration Issue DetailsDescriptionAttempting to enable the Configuration binding source generator with a struct used as a custom configuration type causes the source generator to emit code that fails to compile with a CS8598 error.
The method generated is below. The failing line is public static void BindCore(IConfiguration configuration, ref IDictionary<string, Geolocation> obj, BinderOptions? binderOptions)
{
if (obj is null)
{
throw new ArgumentNullException(nameof(obj));
}
foreach (IConfigurationSection section in configuration.GetChildren())
{
if (!(obj.TryGetValue(section.Key!, out Geolocation element)))
{
element = InitializeGeolocation(section, binderOptions);;
}
var temp4 = InitializeGeolocation(configuration, binderOptions);;
BindCore(section, ref temp4, binderOptions);
element! = temp4; // CS8598 occurs here
obj[section.Key!] = element;
}
} Reproduction Steps
Expected behaviorThe application compiles and configuration binding works equivalently to runtime binding. Actual behaviorThe application fails to compile with a CS8598 error. Regression?No. Known WorkaroundsNone. Configuration.NET SDK 8.0.100-preview.6.23330.14 Other informationNo response
|
Thanks for providing a repro. Taking a look at this & #89019. |
Side note: I notice that you're using a After this (#89010) bug is fixed, could you try the generator again to see if the binding behavior matches your expectations? |
Sure. The repro is adapted from a private repo that has a suite of tests. Once it uses a version of the SDK that should compile, it should be trivial to see if the binding behaviour works correctly. |
Looking at the core parsing logic, it looks like the generator would not handle your inputs as expected - https://github.com/martincostello/config-binding-source-generator-cs8598-repro/blob/57998e5dcd44f6ec59429240bcc63839f6d1a70e/Repro/Geolocation.cs#L69. So IIUC the input -- I say this just to point out the extensibility feature if you want to chime in there. |
Reopen as looks the changes are reverted. |
Description
Attempting to enable the Configuration binding source generator with a struct used as a custom configuration type causes the source generator to emit code that fails to compile with a CS8598 error.
The method generated is below. The failing line is
element! = temp4;
.Reproduction Steps
dotnet build
Expected behavior
The application compiles and configuration binding works equivalently to runtime binding.
Actual behavior
The application fails to compile with a CS8598 error.
Regression?
No.
Known Workarounds
None.
Configuration
.NET SDK 8.0.100-preview.6.23330.14
Other information
No response
The text was updated successfully, but these errors were encountered: