Description
ConfigurationBinder source generator generates code that doesn't compile when using recodrs with requried properties as option Property
Reproduction Steps
build this code
namespaceBindGeneratorRepro;usingSystem.Reflection;internalclassProgram{privatestaticvoidMain(string[]args){varbuilder=WebApplication.CreateSlimBuilder(args);builder.Services.AddOptions();builder.Services.AddOptions<MyOptionA>().BindConfiguration("myPath", options =>options.BindNonPublicProperties=true);varapp=builder.Build();app.MapGet("/version",()=>{varfileVersionAttribute=Assembly.GetExecutingAssembly().GetCustomAttribute<AssemblyFileVersionAttribute>();returnResults.Text(fileVersionAttribute!.Version);});app.Run();}}internalsealedrecordMyOptionA{publicrequiredstringMyParamA{get;init;}publicrequiredMyOptionBMyParamAB{get;init;}}internalsealedrecordMyOptionB{publicrequiredstringMyParamB{get;init;}}Expected behavior
Code should compiles
Actual behavior
build files with error CS9035
BinGeneratorRepro\Microsoft.Extensions.Configuration.Binder.SourceGeneration\Microsoft.Extensions.Configuration.Binder.SourceGeneration.ConfigurationBindingGenerator\BindingExtensions.g.cs(106,31,106,40): error CS9035: Required member 'MyOptionB.MyParamB' must be set in the object initializer or attribute constructor.
Regression?
No response
Known Workarounds
No response
Configuration
No response
Other information
<ProjectSdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<AccelerateBuildsInVisualStudio>true</AccelerateBuildsInVisualStudio>
<EnableRequestDelegateGenerator>true</EnableRequestDelegateGenerator>
<EnableConfigurationBindingGenerator>true</EnableConfigurationBindingGenerator>
</PropertyGroup>
</Project>
Description
ConfigurationBinder source generator generates code that doesn't compile when using recodrs with requried properties as option Property
Reproduction Steps
build this code
Expected behavior
Code should compiles
Actual behavior
build files with error CS9035
BinGeneratorRepro\Microsoft.Extensions.Configuration.Binder.SourceGeneration\Microsoft.Extensions.Configuration.Binder.SourceGeneration.ConfigurationBindingGenerator\BindingExtensions.g.cs(106,31,106,40): error CS9035: Required member 'MyOptionB.MyParamB' must be set in the object initializer or attribute constructor.
Regression?
No response
Known Workarounds
No response
Configuration
No response
Other information