-
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 binder generator creates namespace ambiguity error #94836
Comments
Tagging subscribers to this area: @dotnet/area-extensions-configuration Issue DetailsDescriptionAfter upgrading our ASP.Net 7 application (that started life as 1.1 and upgraded through several .Net Core versions) to .Net 8, when building in a DevOps pipeline, the following error happens:
According to the docs, the Configuration Binding Source Generator is disabled by default, yet we have needed to add false to the csproj to work around the error. Reproduction Steps
Expected behaviorProject should build successfully. Configuration-binding source generator should not be enabled. Actual behaviorProject fails to build with the following error:
Configuration-binding source generator appears to be enabled despite it supposedly being disabled by default. Regression?No response Known Workaroundsfalse in the csproj Configuration.Net 8 Other informationNo response
|
Is See dotnet/aspnetcore#48416 and dotnet/sdk#34022. However, if your app is a Blazor WASM app, it shouldn't be enabled by default. |
@paulguz-datapa could you please provide a sample project reproduce the issue? or compile your app with |
This issue has been marked |
Also, #94267 maybe fixing the namespace ambiguity too. You may try the 8.0.2 builds from https://github.com/dotnet/installer or when you share a sample project, I can try it too. |
Thanks @paulguz-datapa for providing the sample and answering the questions. Enabling For the ambiguity build errors, I have confirmed through your sample it is fixed by #94267. This fix is scheduled to be released next month as the first 8.0 servicing release 8.0.1. With the fix, you'll find the generated code changed from something like: if (type == typeof(Options))
{
var temp = (Options)instance;
return;
} To if (type == typeof(global::CBGError.Options))
{
var temp = (global::CBGError.Options)instance;
return;
} I am closing the issue but feel free to send any more question if you have any. |
thanks @tarekgh @eerhardt PublishTrimmed enabling source generators doesn't seem to be documented (the What's New doc only mentions AOT and there's no sign at the Trimming Options doc either) |
@captainsafia - do you know of a good place to document this behavior? Also cc @gewarren We made this change with dotnet/sdk#34022 |
The trimming options doc page referenced by @paulguz-datapa seems as good a place as any. I opened a docs issue to track this over at dotnet/docs#38555 |
Description
After upgrading our ASP.Net 7 application (that started life as Core 1.1 and upgraded through several .Net Core versions) to .Net 8, when building in a DevOps pipeline, the following error happens:
BindingExtensions.g.cs(131,71): error CS0104: 'Options' is an ambiguous reference between 'myProject.Options' and 'Microsoft.Extensions.Options.Options'
According to the docs, the Configuration Binding Source Generator is disabled by default, yet we have needed to add
<EnableConfigurationBindingGenerator>false</EnableConfigurationBindingGenerator>
to the csproj to work around the error. We are not using AOT, and never have.Note, the project references a Microsoft.NET.Sdk.BlazorWebAssembly project. I'm not sure if that's relevant.
Reproduction Steps
Expected behavior
Project should build successfully. Configuration-binding source generator should not be enabled.
Actual behavior
Project fails to build with the following error:
BindingExtensions.g.cs(131,71): error CS0104: 'Options' is an ambiguous reference between 'myProject.Options' and 'Microsoft.Extensions.Options.Options'
Configuration-binding source generator appears to be enabled despite it supposedly being disabled by default.
Regression?
No response
Known Workarounds
<EnableConfigurationBindingGenerator>false</EnableConfigurationBindingGenerator>
in the csprojConfiguration
.Net 8
Other information
No response
The text was updated successfully, but these errors were encountered: