Skip to content
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

Config binding gen omits a needed comma in an emitted Configure overload replacement #91258

Closed
martincostello opened this issue Aug 29, 2023 · 9 comments
Assignees
Labels
area-Extensions-Configuration bug source-generator Indicates an issue with a source generator feature
Milestone

Comments

@martincostello
Copy link
Member

Description

Updating to .NET SDK 8.0.100-rc.2.23428.11 from 8.0.100-rc.2.23427.4 introduces compilation errors in the configuration binding source generator:

Error: /home/runner/work/costellobot/costellobot/src/Costellobot/Microsoft.Extensions.Configuration.Binder.SourceGeneration/Microsoft.Extensions.Configuration.Binder.SourceGeneration.ConfigurationBindingGenerator/BindingExtensions.g.cs(59,227): error CS1003: Syntax error, ',' expected [/home/runner/work/costellobot/costellobot/src/Costellobot/Costellobot.csproj]
Error: /home/runner/work/costellobot/costellobot/src/Costellobot/Microsoft.Extensions.Configuration.Binder.SourceGeneration/Microsoft.Extensions.Configuration.Binder.SourceGeneration.ConfigurationBindingGenerator/BindingExtensions.g.cs(58,35): error CS0246: The type or namespace name 'IOptionsChangeTokenSource<>' could not be found (are you missing a using directive or an assembly reference?) [/home/runner/work/costellobot/costellobot/src/Costellobot/Costellobot.csproj]
Error: /home/runner/work/costellobot/costellobot/src/Costellobot/Microsoft.Extensions.Configuration.Binder.SourceGeneration/Microsoft.Extensions.Configuration.Binder.SourceGeneration.ConfigurationBindingGenerator/BindingExtensions.g.cs(58,76): error CS0246: The type or namespace name 'ConfigurationChangeTokenSource<>' could not be found (are you missing a using directive or an assembly reference?) [/home/runner/work/costellobot/costellobot/src/Costellobot/Costellobot.csproj]

/cc @layomia

Reproduction Steps

  1. Clone martincostello/costellobot@09ae9ea.
  2. Run build.ps1 in the root of the repository.

Expected behavior

The application compiles.

Actual behavior

The application fails to compile with CS1003 and CS0246 errors.

Regression?

Yes compared to recent preview builds.

Known Workarounds

None.

Configuration

.NET SDK 8.0.100-rc.2.23428.11

Other information

No response

@ghost ghost added the untriaged New issue has not been triaged by the area owner label Aug 29, 2023
@ghost
Copy link

ghost commented Aug 29, 2023

Tagging subscribers to this area: @dotnet/area-extensions-configuration
See info in area-owners.md if you want to be subscribed.

Issue Details

Description

Updating to .NET SDK 8.0.100-rc.2.23428.11 from 8.0.100-rc.2.23427.4 introduces compilation errors in the configuration binding source generator:

Error: /home/runner/work/costellobot/costellobot/src/Costellobot/Microsoft.Extensions.Configuration.Binder.SourceGeneration/Microsoft.Extensions.Configuration.Binder.SourceGeneration.ConfigurationBindingGenerator/BindingExtensions.g.cs(59,227): error CS1003: Syntax error, ',' expected [/home/runner/work/costellobot/costellobot/src/Costellobot/Costellobot.csproj]
Error: /home/runner/work/costellobot/costellobot/src/Costellobot/Microsoft.Extensions.Configuration.Binder.SourceGeneration/Microsoft.Extensions.Configuration.Binder.SourceGeneration.ConfigurationBindingGenerator/BindingExtensions.g.cs(58,35): error CS0246: The type or namespace name 'IOptionsChangeTokenSource<>' could not be found (are you missing a using directive or an assembly reference?) [/home/runner/work/costellobot/costellobot/src/Costellobot/Costellobot.csproj]
Error: /home/runner/work/costellobot/costellobot/src/Costellobot/Microsoft.Extensions.Configuration.Binder.SourceGeneration/Microsoft.Extensions.Configuration.Binder.SourceGeneration.ConfigurationBindingGenerator/BindingExtensions.g.cs(58,76): error CS0246: The type or namespace name 'ConfigurationChangeTokenSource<>' could not be found (are you missing a using directive or an assembly reference?) [/home/runner/work/costellobot/costellobot/src/Costellobot/Costellobot.csproj]

/cc @layomia

Reproduction Steps

  1. Clone martincostello/costellobot@09ae9ea.
  2. Run build.ps1 in the root of the repository.

Expected behavior

The application compiles.

Actual behavior

The application fails to compile with CS1003 and CS0246 errors.

Regression?

Yes compared to recent preview builds.

Known Workarounds

None.

Configuration

.NET SDK 8.0.100-rc.2.23428.11

Other information

No response

Author: martincostello
Assignees: -
Labels:

untriaged, area-Extensions-Configuration

Milestone: -

@ShreyasJejurkar
Copy link
Contributor

cc @layomia

@stephentoub
Copy link
Member

Simple repro:

using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;

IServiceCollection services = null!;
IConfiguration configuration = null!;
services.Configure<MyOptions>(configuration.GetSection("repro"));

class MyOptions { }

@stephentoub stephentoub added this to the 8.0.0 milestone Aug 29, 2023
@ghost ghost removed the untriaged New issue has not been triaged by the area owner label Aug 29, 2023
@layomia
Copy link
Contributor

layomia commented Aug 29, 2023

Thanks folks. I fixed this in #91180, which introduced build coverage for all the options-binding-extension methods to prevent regressions. We're planning to port it to RC-2.

@martincostello, please try the fix when you get a chance.

@martincostello
Copy link
Member Author

Sure, will report back when the SDK version flowing into my automation includes the fix.

@layomia
Copy link
Contributor

layomia commented Aug 29, 2023

I ran into a different issue unrelated to this one when testing the fix on the costellobot project martincostello/costellobot@09ae9ea.

I'll share details shortly & will likely create a separate issue.

@layomia layomia changed the title CS0246 error from configuration binding source generator with .NET 8.0.100-rc.2.23428.11 SDK from daily builds Config binding gen omits a needed comma in an emitted Configure overload replacement Aug 29, 2023
@layomia
Copy link
Contributor

layomia commented Aug 29, 2023

I ran into a different issue unrelated to this one when testing the fix on the costellobot project martincostello/costellobot@09ae9ea.

I'll share details shortly & will likely create a separate issue.

Scratch this, all's well. I verified that the fix works in your project. Pls let us know if you still face issues here & I'll reopen the issue.

@layomia layomia closed this as completed Aug 29, 2023
@layomia layomia added the source-generator Indicates an issue with a source generator feature label Aug 29, 2023
@martincostello
Copy link
Member Author

@layomia As well as spreading to an additional repository with the 8.0.100-rc.2.23429.6 SDK today, I've got a new problem in a third repository:

Error: D:\a\apple-fitness-workout-mapper\apple-fitness-workout-mapper\src\AppleFitnessWorkoutMapper\Microsoft.Extensions.Configuration.Binder.SourceGeneration\Microsoft.Extensions.Configuration.Binder.SourceGeneration.ConfigurationBindingGenerator\BindingExtensions.g.cs(36,90): error CS9143: The given line is '20' characters long, which is fewer than the provided character number '22'. [D:\a\apple-fitness-workout-mapper\apple-fitness-workout-mapper\src\AppleFitnessWorkoutMapper\AppleFitnessWorkoutMapper.csproj]

Is this something that should already have been fixed and I just need to wait to flow into the installer/SDK, or is this a new problem?

@layomia
Copy link
Contributor

layomia commented Aug 30, 2023

@martincostello thanks. That issue is fixed with #91107.

#90851 describes it more, and this LOC is a sample test case. Workaround would be to move the .Configure call to the same LOC as builder.Services, but that won't be needed when the fix flows through.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-Extensions-Configuration bug source-generator Indicates an issue with a source generator feature
Projects
None yet
Development

No branches or pull requests

4 participants