-
-
Notifications
You must be signed in to change notification settings - Fork 21k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make C# source generators incremental #64899
base: master
Are you sure you want to change the base?
Make C# source generators incremental #64899
Conversation
04bfc9a
to
9f1b712
Compare
9f1b712
to
6788065
Compare
6788065
to
d94f562
Compare
I didn't realize there was a draft for this already, I had made a discussion proposal here as If you're looking for structure from other generators the MVVM Toolkit ones are some of the best around, they have tests setup as well. For generator performance, you can look to use For tests, you can also use things like Seems like setting up tests for the current generator could be a good first step? I know having tests makes running source generators and debugging them as part of debugging a test a whole lot easier of a workflow. Also, not sure how decisions in godotengine/godot-proposals#7895 effect this code; I'm not familiar enough with the engine and extension internals to know. |
Some suggestions:
|
@Lidsel what do you mean by the following:
What user friction is increased? User use of attributes should be unchanged between the two implementations. This is just generator implementation detail using Agree that dedicated analyzers can certainly be useful to provide hints/help to users on using correct patterns. |
@hawkerm The user would have to add an attribute to every Godot type-derived class for |
I was thinking the same thing. Usually I prefer smaller PRs that make small improvements over big PRs that are hard to review, so I just wanted to make an initial move to incremental generators before doing more changes.
Sure, like I said I wanted to keep the PR small to start, but it sounds like a good idea.
This would require C# classes to have some attribute and, as you say, would increase user friction. I don't think we'll want to do that with the scripting API. It would also break compatibility.
I think that depends on the diagnostic, if the generator is already going to be performing the check anyway might as well report the diagnostic, that's what the API is there for, I imagine. Of course if there's some checks that we can move outside of the generators into analyzers that would be great. As for IDEs not supporting diagnostics from generators, that sounds like an IDE bug to me. I think I've heard from users that Visual Studio does display them, but I can't confirm since I don't use it. I've seen them reported in VSCode at some point with the new Roslyn-based C# extension but I think source generators are currently broken, so I'm currently using the Omnisharp backend. As you can see this PR is somewhat abandoned at the moment, I haven't had the time to work in it. I'm mostly worried about breaking changes, so I think a good first step would be to implement proper tests (I was looking at Microsoft.CodeAnalysis.Testing). Then we can make refactors without worrying so much about breaking stuff. |
I was recommending this API for the existing attributes like For the classes themselves, that's of course a different discussion. Not sure if there's a better approach from a performance perspective. At least with Godot most things inherit from some sort of Node, so that should be a starting point to limiting scope of the generator. |
@raulsntos The recommendation to report diagnostics in analyzers is based on general recommendations from the Roslyn team. A source generator will trigger whenever the source changes i.e. on every keystroke in editing any code file in the project, you want to minimize the amount of work it does for the value providers. Reporting diagnostics is extra work and it will do it for every class it examines which is all of them every time. An analyzer, from what I can tell, will run just on the files you open, rerun while you're editing them and on the entire project when you're building it - i.e. when it's actually actionable.
@hawkerm By the time we're examining for |
Hard agree.
That may indeed be an issue with Omnisharp that'll get phased out when (if?) the issues with the Roslyn extension are fixed. In my own tests (granted, more than a year old now), diagnostics reported from an |
Switch to incremental source generators to increase their performance as they are executed in steps and avoid re-doing work.
TODO
Production edit: closes godotengine/godot-roadmap#50