-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Source generated configuration binder error #92343
Comments
Tagging subscribers to this area: @dotnet/area-extensions-configuration Issue DetailsDescriptionI followed the guide in the doc, but build fails. Reproduction Steps
<PropertyGroup>
<EnableConfigurationBindingGenerator>true</EnableConfigurationBindingGenerator>
</PropertyGroup>
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
WebApplicationBuilder builder = WebApplication.CreateBuilder(args);
IConfigurationSection section = builder.Configuration.GetSection("MyOptions");
// !! Configure call - to be replaced with source-gen'd implementation
builder.Services.Configure<MyOptions>(section);
// !! Get call - to be replaced with source-gen'd implementation
MyOptions options0 = section.Get<MyOptions>();
// !! Bind call - to be replaced with source-gen'd implementation
MyOptions options1 = new MyOptions();
section.Bind(options1);
WebApplication app = builder.Build();
app.MapGet("/", () => "Hello World!");
app.Run();
public class MyOptions
{
public int A { get; set; }
public string S { get; set; }
public byte[] Data { get; set; }
public Dictionary<string, string> Values { get; set; }
public List<MyClass> Values2 { get; set; }
}
public class MyClass
{
public int SomethingElse { get; set; }
}
dotnet publish -r win-x64 -c Release Expected behaviorProgram compiles without error and warnings. Actual behaviorBuild fails with the following source generation errors: MSBuild version 17.8.0-preview-23418-03+0125fc9fb for .NET
Determining projects to restore...
All projects are up-to-date for restore.
C:\Program Files\dotnet\sdk\8.0.100-rc.1.23463.5\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.RuntimeIdentifierInferenc
e.targets(311,5): message NETSDK1057: You are using a preview version of .NET. See: https://aka.ms/dotnet-support-polic
y [C:\Users\source\repos\NativeAOT.Demo\NativeAOT.Demo\NativeAOT.Demo.csproj]
C:\Users\source\repos\NativeAOT.Demo\NativeAOT.Demo\Microsoft.Extensions.Configuration.Binder.SourceGeneration\Mi
crosoft.Extensions.Configuration.Binder.SourceGeneration.ConfigurationBindingGenerator\BindingExtensions.g.cs(80,227):
error CS1003: Syntax error, ',' expected [C:\Users\source\repos\NativeAOT.Demo\NativeAOT.Demo\NativeAOT.Demo.cspr
oj]
C:\Users\source\repos\NativeAOT.Demo\NativeAOT.Demo\Microsoft.Extensions.Configuration.Binder.SourceGeneration\Mi
crosoft.Extensions.Configuration.Binder.SourceGeneration.ConfigurationBindingGenerator\BindingExtensions.g.cs(79,35): e
rror CS0246: The type or namespace name 'IOptionsChangeTokenSource<>' could not be found (are you missing a using direc
tive or an assembly reference?) [C:\Users\source\repos\NativeAOT.Demo\NativeAOT.Demo\NativeAOT.Demo.csproj]
C:\Users\source\repos\NativeAOT.Demo\NativeAOT.Demo\Microsoft.Extensions.Configuration.Binder.SourceGeneration\Mi
crosoft.Extensions.Configuration.Binder.SourceGeneration.ConfigurationBindingGenerator\BindingExtensions.g.cs(79,76): e
rror CS0246: The type or namespace name 'ConfigurationChangeTokenSource<>' could not be found (are you missing a using
directive or an assembly reference?) [C:\Users\source\repos\NativeAOT.Demo\NativeAOT.Demo\NativeAOT.Demo.csproj] Regression?Unfortunately I'm not sure. Known WorkaroundsConfigurationVersion: .NET 8 RC1 Other informationNo response
|
Apparently due to be fixed in RC2: #92021 (comment) |
Thanks @jamiewinder. Since it's the same issue, I'm closing this one. |
Description
I followed the guide in the doc, but build fails.
Reproduction Steps
dotnet new webapiaot
Expected behavior
Program compiles without error and warnings.
Actual behavior
Build fails with the following source generation errors:
Regression?
Unfortunately I'm not sure.
Known Workarounds
N/A
Configuration
Version: .NET 8 RC1
SDK: 8.0.100-rc.1.23463.5
Runtime: Microsoft.AspNetCore.App 8.0.0-rc.1.23421.29
OS: Windows 11 x64, Version 21H2 (Build 22000.2416)
Other information
No response
The text was updated successfully, but these errors were encountered: