Repository navigation
Prevent CS0121 (ambiguous method calls) resulting from config binding source gen #86363
Description
Activity
- addedsource-generatorIndicates an issue with a source generator featureIndicates an issue with a source generator feature
on May 17, 2023 FYI @davidfowl @eerhardt @ericstj re: #44493 (comment).
@andrewlock do you also have
Configure<T>calls in that assembly?Reacted by Layomi Akinrinade and Andrew Lock@tarekgh @eerhardt @ericstj, does it seem reasonable to generate random names to avoid the clashes? Thinking we can make this change when we adopt the Roslyn interceptors feature.
Right now this name clash issue doesn't seem crucial for 8.0, pending feedback from @andrewlock.
I have done similar things in the options source gen if you want to take a look at #89148
Reacted by Layomi Akinrinade- addedin-prThere is an active PR which will close this issue when it is mergedThere is an active PR which will close this issue when it is mergedand removedin-prThere is an active PR which will close this issue when it is mergedThere is an active PR which will close this issue when it is merged
on Jul 25, 2023 - changed the title
[-]Prevent CS0121 (ambiguous method calls) resulting from config binding source gen[/-][+]Prevent CS0121 (ambiguous method calls) resulting from config binding & options source gen[/+]on Aug 18, 2023 I have done similar things in the options source gen if you want to take a look at #89148
There was discussion in #90340 (comment) about the right approach to avoid name clashes. This needs to be addressed for the options generator, and I'd have to validate interception behavior in the config generator.
We're sticking with the interceptors approach for RC-1, where this problem does not arise. Options generator changes are being tracked in #90990.
- changed the title
[-]Prevent CS0121 (ambiguous method calls) resulting from config binding & options source gen[/-][+]Prevent CS0121 (ambiguous method calls) resulting from config binding source gen[/+]on Aug 24, 2023 - ghost locked as resolved and limited conversation to collaborators
on Sep 23, 2023
From @andrewlock in #44493 (comment):
One potential issue I can foresee with the design of the generated code (because I've run into a similar issue with my own generators) is around
internalclasses andInternalsVisibleTo.The fact that the generated code is always a fixed type (
GeneratedConfigurationBinder) in the global namespace, means that something like this will no longer compile:Project 1:
Project 2: (has a
<ProjectReference>to Project1)Gives
You might consider it an edge case, but it was one of the first issues I ran into when building my first source generator.
Note: I've just seen that preview 4 bits are going onto NuGet, so apologies if this is no longer relevant! :D (Edit: looks like the preview 3 package is broken for me)