-
Notifications
You must be signed in to change notification settings - Fork 34
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
[BUG] Source generator error - The call is ambiguous between the following methods or properties - CommunityToolkit.Maui.Markup.TextAlignmentExtensions #158
Comments
Sample project has been pushed into this repo for simulation. |
Thanks @egvijayanand! We had just been discussing making the class generated by Source Generators Here's the link to the NuGet Package generated by the PR if you'd like to use it until we get the PR merged + released: |
Glad to hear that it's getting fixed at the earliest. Not required immediately. Today, upgraded one of my packages, and while testing got this issue, as it's specific to one method and simulated for all platforms when debugged further. Hence wanted to report and get it fixed. Will make note of it and test it when released officially. |
Is there an existing issue for this?
Current Behavior
This is a peculiar issue as it is getting simulated only when
CommunityToolkit.Maui.Markup
is referenced in a class library or dependency for a NuGet package and that is in turn gets referenced in a .NET MAUI App.Such a scenario results in the below error:
The call is ambiguous between the following methods or properties: 'CommunityToolkit.Maui.Markup.TextAlignmentExtensions_XYZ.TextCenterHorizontal(Microsoft.Maui.Controls.XYZ)' and 'CommunityToolkit.Maui.Markup.TextAlignmentExtensions_XYZ.TextCenterHorizontal(Microsoft.Maui.Controls.XYZ)'
Where XYZ is the type for which the TextCenterHorizontal() extension method is defined.
Detailed error:
Build started...
1>------ Build started: Project: MauiApp6, Configuration: Debug Any CPU ------
1>E:\MauiApp6\MauiApp6\CommunityToolkit.Maui.Markup.SourceGenerators\CommunityToolkit.Maui.Markup.SourceGenerators.TextAlignmentExtensionsGenerator\SearchBarTextAlignmentExtensions.g.cs(122,153,122,173): error CS0121: The call is ambiguous between the following methods or properties: 'CommunityToolkit.Maui.Markup.TextAlignmentExtensions_SearchBar.TextCenterHorizontal(Microsoft.Maui.Controls.SearchBar)' and 'CommunityToolkit.Maui.Markup.TextAlignmentExtensions_SearchBar.TextCenterHorizontal(Microsoft.Maui.Controls.SearchBar)'
1>E:\MauiApp6\MauiApp6\CommunityToolkit.Maui.Markup.SourceGenerators\CommunityToolkit.Maui.Markup.SourceGenerators.TextAlignmentExtensionsGenerator\EntryCellTextAlignmentExtensions.g.cs(122,153,122,173): error CS0121: The call is ambiguous between the following methods or properties: 'CommunityToolkit.Maui.Markup.TextAlignmentExtensions_EntryCell.TextCenterHorizontal(Microsoft.Maui.Controls.EntryCell)' and 'CommunityToolkit.Maui.Markup.TextAlignmentExtensions_EntryCell.TextCenterHorizontal(Microsoft.Maui.Controls.EntryCell)'
1>E:\MauiApp6\MauiApp6\CommunityToolkit.Maui.Markup.SourceGenerators\CommunityToolkit.Maui.Markup.SourceGenerators.TextAlignmentExtensionsGenerator\EditorTextAlignmentExtensions.g.cs(122,147,122,167): error CS0121: The call is ambiguous between the following methods or properties: 'CommunityToolkit.Maui.Markup.TextAlignmentExtensions_Editor.TextCenterHorizontal(Microsoft.Maui.Controls.Editor)' and 'CommunityToolkit.Maui.Markup.TextAlignmentExtensions_Editor.TextCenterHorizontal(Microsoft.Maui.Controls.Editor)'
1>E:\MauiApp6\MauiApp6\CommunityToolkit.Maui.Markup.SourceGenerators\CommunityToolkit.Maui.Markup.SourceGenerators.TextAlignmentExtensionsGenerator\PickerTextAlignmentExtensions.g.cs(122,147,122,167): error CS0121: The call is ambiguous between the following methods or properties: 'CommunityToolkit.Maui.Markup.TextAlignmentExtensions_Picker.TextCenterHorizontal(Microsoft.Maui.Controls.Picker)' and 'CommunityToolkit.Maui.Markup.TextAlignmentExtensions_Picker.TextCenterHorizontal(Microsoft.Maui.Controls.Picker)'
1>E:\MauiApp6\MauiApp6\CommunityToolkit.Maui.Markup.SourceGenerators\CommunityToolkit.Maui.Markup.SourceGenerators.TextAlignmentExtensionsGenerator\EntryTextAlignmentExtensions.g.cs(122,145,122,165): error CS0121: The call is ambiguous between the following methods or properties: 'CommunityToolkit.Maui.Markup.TextAlignmentExtensions_Entry.TextCenterHorizontal(Microsoft.Maui.Controls.Entry)' and 'CommunityToolkit.Maui.Markup.TextAlignmentExtensions_Entry.TextCenterHorizontal(Microsoft.Maui.Controls.Entry)'
1>E:\MauiApp6\MauiApp6\CommunityToolkit.Maui.Markup.SourceGenerators\CommunityToolkit.Maui.Markup.SourceGenerators.TextAlignmentExtensionsGenerator\LabelTextAlignmentExtensions.g.cs(122,145,122,165): error CS0121: The call is ambiguous between the following methods or properties: 'CommunityToolkit.Maui.Markup.TextAlignmentExtensions_Label.TextCenterHorizontal(Microsoft.Maui.Controls.Label)' and 'CommunityToolkit.Maui.Markup.TextAlignmentExtensions_Label.TextCenterHorizontal(Microsoft.Maui.Controls.Label)'
1>Done building project "MauiApp6.csproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 1 up-to-date, 0 skipped ==========
========== Elapsed 00:00.874 ==========
Expected Behavior
Should compile without any errors.
Steps To Reproduce
In simple terms, whenever this Markup library is an external dependency, it results in this source generator error.
Link to public reproduction project repository
https://github.com/egvijayanand/markup-issue-158
Environment
Anything else?
This issue is encountered only when
CommunityToolkit.Maui.Markup
is an external dependency and not getting simulated when directly referenced in the App project.The text was updated successfully, but these errors were encountered: