-
Notifications
You must be signed in to change notification settings - Fork 470
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool! I know very little about Source Generators, so I have two questions:
- How come it's in its own
csproj
,Xamarin.CommunityToolkit.SourceGenerator.csproj
? - Do we need to commit
Xamarin.CommunityToolkit.SourceGenerator.dll
to the repo? Or is that auto-generated at build time?
Not sure if I follow this question. But for Source Generators (SG) we need to have a separate project that targets
We can do both since we will not touch in SG too much (I believe that we will never change anything in there) I added the |
Sounds good to me! Is there anyway to make a Unit Test for the error fixed by this? |
I'll investigate that. |
Agreed. The only thing I can think of is to make a second sample app that doesn't reference any toolkit stuff in C# (only using XAML). Then we build that sample in our CI/CD pipeline to confirm there's no build errors. It's not exactly a "Unit Test", but it'd accomplish the sample thing. |
src/SourceGenerator/Xamarin.CommunityToolkit.SourceGenerator/XCTGenerator.cs
Show resolved
Hide resolved
You don't need to do that. You can pack the dll inside the NuGet (same way it works with static analyzers). Actually, Source Generators and static analyzers are almost the same thing. You can think about Source Generators as static analyzers that can produce files. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we try not include dll as Max suggested?
@VladislavAntonyuk IMHO is better to use the dll instead of binding this project every time. This SG is just generating that code all the time, so we don't need to include it on our build process. Referencing the dll in release mode will be the best approach |
I'm having a small issue with this change. The type Xamarin.CommunityToolkit.Initializer.XCTInitCaller is now present in each assembly of my app. This results in a 'duplicate type' warning when I merge these assemblies (obfuscation step during the release process of my app). |
@tranb3r please open an issue and mark me. IF possible provide a small sample that I can use as reference |
Description of Bug
This PR adds a Source Generator in our project and nuget, with this we can call an
Init
method and hopefully avoid that fake XAML error.I didn't test on Mac, so please try it on Mac before merging.
Issues Fixed
Behavioral Changes
This shouldn't change anything in the lib.
PR Checklist
approved