Using code generation to replace reflection, and Roslyn+Visual Studio performance.
Hey everyone,
To better support trimming and AOT I'm shifting over some reflection code to code generation, which involves going over namespaces and types and generating functions to replace my usages of reflection.
The generated code works and everything is fine, however it seems to me like Visual Studio's performance is way down and stuff like Ctrl+Click/F12 randomly stop working.
Additionally hot reload randomly stops working and sometimes even watching values. I am observing this behavior across multiple computers and VS installations.
According to the task manager Roslyn Code Analysis is taking a lot of CPU. My understanding is that it runs everytime I make a change (hence hot reloading breaking, maybe?) but I'm not sure how to deal with this, how to profile it and so forth. Are there any obvious gotchas I'm missing here?
7 Replies
try #roslyn
youre using incremental generators right?
hm no I am using ISourceGenerator
I guess I should be using incremental generators
thats the old one dont use it
got it, thanks
$ig
If you want to make an incremental source generator, please make sure to read through both the design document and the cookbook before starting.
Using incremental generators, and especially using ForAttributeWithMetadataName, should significantly improve your experience