CsWinRT
CsWinRT copied to clipboard
WinRT.SourceGenerator should implement IIncrementalGenerator instead of ISourceGenerator
Describe the bug
The RegisterForSyntaxNotifications API provided to ISourceGenerator produces an unavoidable, catastrophic performance penalty. Source generators operating on syntax need to be carefully rewritten implementing IIncrementalGenerator to avoid this overhead.
https://github.com/microsoft/CsWinRT/blob/98122be4624e0b36b8bc2c48bcde6d9f39cd4e42/src/Authoring/WinRT.SourceGenerator/Generator.cs#L430
To Reproduce
Discovered during ETL and heap dump analysis of this issue: https://developercommunity.visualstudio.com/t/Poor-performance-on-intellicode-operatio/10717804
Expected behavior
Version Info
Additional context
Absolutely needed, current situation in my solution.
@FrayxRulez I am curious, are you authoring a CsWinRT Component (WinRT component in C#) or just using the projection support and AOT support?
@manodasanW I have a large WinUI app that consumes a few C++/WinRT projects, one of them definitely large too.
I just implemented a WinRT.SourceGenerator implments IIncrementalGenerator for my own purpose. Since it's not fully tested so I decide not making a PR for it. If you are interested in this you can try it out.
Unfortunately it looks like your generator is caching syntaxes and providers, which means it is not actually incremental.
Unfortunately it looks like your generator is caching syntaxes and providers, which means it is not actually incremental.
Yes, technically not incremental, just reduced some generation attempts, it's enough for me though.
Great! With version 2.1.3 released, it now takes me forever to rename a variable.🤓