Skip to content
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

Update generator to really be incremental #83

Merged
merged 12 commits into from
Oct 15, 2023

Conversation

k94ll13nn3
Copy link
Owner

@k94ll13nn3 k94ll13nn3 commented Oct 5, 2023

Fixes #82

@k94ll13nn3 k94ll13nn3 force-pushed the fix/real-incremental-generator branch from bca9320 to 89f0bc2 Compare October 7, 2023 12:11
@k94ll13nn3 k94ll13nn3 marked this pull request as ready for review October 7, 2023 19:33
Copy link
Contributor

@Sergio0694 Sergio0694 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks much better! Just left a few notes 🙂

As a follow up in another PR, you might want to also switch the generator to use a pooled indented text writer rather than syntax trees, which is orders of magnitude faster and more efficient in terms of memory use (I've shared some screenshots here). It is the recommended approach to generate code from source generators. I'd recommend reusing my implementation here, which also includes an interpolated string handler to improve performance even more when interpolating output text 🚀

src/AutoConstructor.Generator/Core/IsExternalInit.cs Outdated Show resolved Hide resolved
src/AutoConstructor.Generator/Models/FieldInfo.cs Outdated Show resolved Hide resolved
src/AutoConstructor.Generator/CodeGenerator.cs Outdated Show resolved Hide resolved
@k94ll13nn3
Copy link
Owner Author

Looks much better! Just left a few notes 🙂

As a follow up in another PR, you might want to also switch the generator to use a pooled indented text writer rather than syntax trees, which is orders of magnitude faster and more efficient in terms of memory use (I've shared some screenshots here). It is the recommended approach to generate code from source generators. I'd recommend reusing my implementation here, which also includes an interpolated string handler to improve performance even more when interpolating output text 🚀

Thanks a lot (and @Youssef1313) for taking some of your time to review this.
I had initially used a basic string builder, but I changed it to use the syntax factory because I thought it would be better to generate code using this than manually, but yeah, I will look at using your writer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The source generator is completely non incremental
3 participants