Closed RichardMarsh closed 2 years ago
@RichardMarsh I tried your sample attached and everything runs like a charm as you can see in the screenshot below
Also, I noticed some wrong configs on your csproj
.
@pictos Thanks for taking the time to look into this.
Not sure why you aren't getting warnings, but here's a screenshot
Also, you said there's some config issues? I just created the default projects and added CommunityToolkit. What was wrong with the configs?
I was able to reproduce it: this happens because SourceGenerator files were generated for both the app and library. To fix the issue replace the PackageReference with:
<PackageReference Include="CommunityToolkit.Maui" Version="1.0.0-rc3">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="CommunityToolkit.Maui" Version="1.0.0-rc3">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Thanks for this suggestion. However the build warnings will reappear if I then add the CommunityToolkit.Maui package to my App ,if for some reason my app needs to use the CommunityToolkit directly.
Unless I'm doing it incorrectly, which is also possible.
Hello,
I have exactly the same warning message when I add a xUnit project to my solution and my MAUI project as a reference of my xUnit project.
@pictos is it fixed with 1.1.0 release?
@pictos is it fixed with 1.1.0 release?
No. Warnings still there.
We didn't change anything on that... And not sure if we can... SG will generate code for all assemblies that reference the MCT. TBH not sure if we can do something on that, maybe the lib that uses MCT needs to do some work, maybe exposing the MCT to the consumers, that way the App doesn't need to install the MCT by itself? Or suppressing the generated files that way it doesn't leak to consumers?
If anyone knows something about SG that can prevent that, let us know then we can see if makes sense to implement it here.
Description
The TextColorTo extention methods are being created via SourceGenerators. These source generators however create CS0436 warnings when the CommunityToolkit is used in a library.
C:\Users\R\source\repos\CommunityToolkitSample\CommunityToolkitSample.App\CommunityToolkit.Maui.SourceGenerators\CommunityToolkit.Maui.SourceGenerators.Generators.TextColorToGenerator\LabelTextColorTo_71aacac4-5ef7-473e-aae1-1fe5429261f1.g.shared.cs(41,89,41,119): warning CS0436: The type 'ColorAnimationExtensions_Label' in 'CommunityToolkit.Maui.SourceGenerators\CommunityToolkit.Maui.SourceGenerators.Generators.TextColorToGenerator\LabelTextColorTo_71aacac4-5ef7-473e-aae1-1fe5429261f1.g.shared.cs' conflicts with the imported type 'ColorAnimationExtensions_Label' in 'CommunityToolkitSample.Library, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. Using the type defined in 'CommunityToolkit.Maui.SourceGenerators\CommunityToolkit.Maui.SourceGenerators.Generators.TextColorToGenerator\LabelTextColorTo_71aacac4-5ef7-473e-aae1-1fe5429261f1.g.shared.cs'.
Link to Reproduction Sample
https://github.com/RichardMarsh/CommunityToolkitSample
Steps to Reproduce
Basic Information
Workaround
Remove the analyzer from the custom library project. However that means the custom library does not have access to those features.
`
`