question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] CS0436 "conflicts with the imported type" when using community toolkit with a shared maui project

See original GitHub issue

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

When using .net communityToolkit maui for two projects in a solution, one main executable and one shared library, the following error occurs

MainTest-master\MainTest-master\MainTest\CommunityToolkit.Maui.SourceGenerators\CommunityToolkit.Maui.SourceGenerators.Generators.TextColorToGenerator\TimePickerTextColorTo.g.shared.cs(41,89,41,124): warning CS0436: The type ‘ColorAnimationExtensions_TimePicker’ in ‘CommunityToolkit.Maui.SourceGenerators\CommunityToolkit.Maui.SourceGenerators.Generators.TextColorToGenerator\TimePickerTextColorTo.g.shared.cs’ conflicts with the imported type ‘ColorAnimationExtensions_TimePicker’ in ‘MainTest.Shared, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null’. Using the type defined in ‘CommunityToolkit.Maui.SourceGenerators\CommunityToolkit.Maui.SourceGenerators.Generators.TextColorToGenerator\TimePickerTextColorTo.g.shared.cs’.

Expected Behavior

No build errors should occur

Steps To Reproduce

  1. I create two maui project, one main that can run, and one with shared code
  2. Reference the shared project from the main project
  3. Then i add the community toolkit to the shared code projet
  4. Then build the main project, build warnings/errors occur

See below:

C:\Users\xxx\source\repos\MainTest\MainTest\CommunityToolkit.Maui.SourceGenerators\CommunityToolkit.Maui.SourceGenerators.Generators.TextColorToGenerator\TimePickerTextColorTo.g.shared.cs(41,89,41,124): warning CS0436: The type ‘ColorAnimationExtensions_TimePicker’ in ‘CommunityToolkit.Maui.SourceGenerators\CommunityToolkit.Maui.SourceGenerators.Generators.TextColorToGenerator\TimePickerTextColorTo.g.shared.cs’ conflicts with the imported type ‘ColorAnimationExtensions_TimePicker’ in ‘MainTest.Shared, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null’. Using the type defined in ‘CommunityToolkit.Maui.SourceGenerators\CommunityToolkit.Maui.SourceGenerators.Generators.TextColorToGenerator\TimePickerTextColorTo.g.shared.cs’. 2>C:\Users\xxx\source\repos\MainTest\MainTest\CommunityToolkit.Maui.SourceGenerators\CommunityToolkit.Maui.SourceGenerators.Generators.TextColorToGenerator\EditorTextColorTo.g.shared.cs(41,89,41,120): warning CS0436: The type ‘ColorAnimationExtensions_Editor’ in ‘CommunityToolkit.Maui.SourceGenerators\CommunityToolkit.Maui.SourceGenerators.Generators.TextColorToGenerator\EditorTextColorTo.g.shared.cs’ conflicts with the imported type ‘ColorAnimationExtensions_Editor’ in ‘MainTest.Shared, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null’. Using the type defined in ‘CommunityToolkit.Maui.SourceGenerators\CommunityToolkit.Maui.SourceGenerators.Generators.TextColorToGenerator\EditorTextColorTo.g.shared.cs’. 2>C:\Users\xxx\source\repos\MainTest\MainTest\CommunityToolkit.Maui.SourceGenerators\CommunityToolkit.Maui.SourceGenerators.Generators.TextColorToGenerator\PickerTextColorTo.g.shared.cs(41,89,41,120): warning CS0436: The type ‘ColorAnimationExtensions_Picker’ in ‘CommunityToolkit.Maui.SourceGenerators\CommunityToolkit.Maui.SourceGenerators.Generators.TextColorToGenerator\PickerTextColorTo.g.shared.cs’ conflicts with the imported type ‘ColorAnimationExtensions_Picker’ in ‘MainTest.Shared, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null’. Using the type defined in ‘CommunityToolkit.Maui.SourceGenerators\CommunityToolkit.Maui.SourceGenerators.Generators.TextColorToGenerator\PickerTextColorTo.g.shared.cs’. 2>C:\Users\xxx\source\repos\MainTest\MainTest\CommunityToolkit.Maui.SourceGenerators\CommunityToolkit.Maui.SourceGenerators.Generators.TextColorToGenerator\SearchBarTextColorTo.g.shared.cs(41,89,41,123): warning CS0436: The type ‘ColorAnimationExtensions_SearchBar’ in ‘CommunityToolkit.Maui.SourceGenerators\CommunityToolkit.Maui.SourceGenerators.Generators.TextColorToGenerator\SearchBarTextColorTo.g.shared.cs’ conflicts with the imported type ‘ColorAnimationExtensions_SearchBar’ in ‘MainTest.Shared, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null’. Using the type defined in ‘CommunityToolkit.Maui.SourceGenerators\CommunityToolkit.Maui.SourceGenerators.Generators.TextColorToGenerator\SearchBarTextColorTo.g.shared.cs’. 2>C:\Users\xxx\source\repos\MainTest\MainTest\CommunityToolkit.Maui.SourceGenerators\CommunityToolkit.Maui.SourceGenerators.Generators.TextColorToGenerator\DatePickerTextColorTo.g.shared.cs(41,89,41,124): warning CS0436: The type ‘ColorAnimationExtensions_DatePicker’ in ‘CommunityToolkit.Maui.SourceGenerators\CommunityToolkit.Maui.SourceGenerators.Generators.TextColorToGenerator\DatePickerTextColorTo.g.shared.cs’ conflicts with the imported type ‘ColorAnimationExtensions_DatePicker’ in ‘MainTest.Shared, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null’. Using the type defined in ‘CommunityToolkit.Maui.SourceGenerators\CommunityToolkit.Maui.SourceGenerators.Generators.TextColorToGenerator\DatePickerTextColorTo.g.shared.cs’. 2>C:\Users\xxx\source\repos\MainTest\MainTest\CommunityToolkit.Maui.SourceGenerators\CommunityToolkit.Maui.SourceGenerators.Generators.TextColorToGenerator\ButtonTextColorTo.g.shared.cs(41,89,41,120): warning CS0436: The type ‘ColorAnimationExtensions_Button’ in ‘CommunityToolkit.Maui.SourceGenerators\CommunityToolkit.Maui.SourceGenerators.Generators.TextColorToGenerator\ButtonTextColorTo.g.shared.cs’ conflicts with the imported type ‘ColorAnimationExtensions_Button’ in ‘MainTest.Shared, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null’. Using the type defined in ‘CommunityToolkit.Maui.SourceGenerators\CommunityToolkit.Maui.SourceGenerators.Generators.TextColorToGenerator\ButtonTextColorTo.g.shared.cs’. 2>C:\Users\xxx\source\repos\MainTest\MainTest\CommunityToolkit.Maui.SourceGenerators\CommunityToolkit.Maui.SourceGenerators.Generators.TextColorToGenerator\RadioButtonTextColorTo.g.shared.cs(41,89,41,125): warning CS0436: The type ‘ColorAnimationExtensions_RadioButton’ in ‘CommunityToolkit.Maui.SourceGenerators\CommunityToolkit.Maui.SourceGenerators.Generators.TextColorToGenerator\RadioButtonTextColorTo.g.shared.cs’ conflicts with the imported type ‘ColorAnimationExtensions_RadioButton’ in ‘MainTest.Shared, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null’. Using the type defined in ‘CommunityToolkit.Maui.SourceGenerators\CommunityToolkit.Maui.SourceGenerators.Generators.TextColorToGenerator\RadioButtonTextColorTo.g.shared.cs’. 2>C:\Users\xxx\source\repos\MainTest\MainTest\CommunityToolkit.Maui.SourceGenerators\CommunityToolkit.Maui.SourceGenerators.Generators.TextColorToGenerator\EntryTextColorTo.g.shared.cs(41,89,41,119): warning CS0436: The type ‘ColorAnimationExtensions_Entry’ in ‘CommunityToolkit.Maui.SourceGenerators\CommunityToolkit.Maui.SourceGenerators.Generators.TextColorToGenerator\EntryTextColorTo.g.shared.cs’ conflicts with the imported type ‘ColorAnimationExtensions_Entry’ in ‘MainTest.Shared, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null’. Using the type defined in ‘CommunityToolkit.Maui.SourceGenerators\CommunityToolkit.Maui.SourceGenerators.Generators.TextColorToGenerator\EntryTextColorTo.g.shared.cs’. 2>C:\Users\xxx\source\repos\MainTest\MainTest\CommunityToolkit.Maui.SourceGenerators\CommunityToolkit.Maui.SourceGenerators.Generators.TextColorToGenerator\LabelTextColorTo.g.shared.cs(41,89,41,119): warning CS0436: The type ‘ColorAnimationExtensions_Label’ in ‘CommunityToolkit.Maui.SourceGenerators\CommunityToolkit.Maui.SourceGenerators.Generators.TextColorToGenerator\LabelTextColorTo.g.shared.cs’ conflicts with the imported type ‘ColorAnimationExtensions_Label’ in ‘MainTest.Shared, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null’. Using the type defined in ‘CommunityToolkit.Maui.SourceGenerators\CommunityToolkit.Maui.SourceGenerators.Generators.TextColorToGenerator\LabelTextColorTo.g.shared.cs’.

Link to public reproduction project repository

https://github.com/norfus/MainTest

Environment

- .NET MAUI CommunityToolkit: 2.0 or 3.0
- OS:Windows 10
- .NET MAUI: 6 or 7

Anything else?

No response

Issue Analytics

  • State:closed
  • Created 9 months ago
  • Reactions:1
  • Comments:5

github_iconTop GitHub Comments

1reaction
brminnickcommented, Dec 7, 2022

Fixed in #791

0reactions
VladislavAntonyukcommented, Dec 12, 2022

We do not plan downgrading to net 6.

so we nightly recommend upgrading to net 7

Read more comments on GitHub >

github_iconTop Results From Across the Web

CS0436: Type conflicts with the imported type
"The type [type] in [licence.cs full path] conflicts with the imported type [LicenceClass] in [dependency project also including licence.cs].
Read more >
[BUG] CS0436 compiler warning because of source ...
TextColorToGenerator\TimePickerTextColorTo.g.shared.cs' conflicts with the imported ... Using the type defined in 'CommunityToolkit.Maui.
Read more >
Compiler Warning (level 2) CS0436
This warning is issued when a type in a source file (file_2) conflicts with an imported type in file_1. The compiler uses the...
Read more >
MAUI Sounds Amazing. Is It?
shared.cs' conflicts with the imported type 'ColorAnimationExtensions_Button' in 'Lee.MyMauiApp, Version=1.0.0.0, Culture=neutral, ...
Read more >
Warning: Type conflicts with the imported type
From what I understand, the error is usually caused when referencing the containing class when declaring a variable, but this class doesn't ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found