Skip to content

Conversation

@rudyhuyn
Copy link
Collaborator

@rudyhuyn rudyhuyn commented Mar 9, 2025

This PR refactors the C# code generator to use Roslyn’s SyntaxFactory API instead of manually concatenating strings to build C# source files.

@rudyhuyn rudyhuyn changed the title Improve C# Code Generator to Use Roslyn SyntaxFactory Instead of String Concatenation Improve C# Code Generator to use Roslyn SyntaxFactory instead of basic string concatenation Mar 9, 2025
@rudyhuyn rudyhuyn merged commit e6dafb6 into main Mar 9, 2025
3 checks passed
@rudyhuyn rudyhuyn deleted the user/rudy/useSyntaxFactory branch March 9, 2025 10:10
@Sergio0694
Copy link
Contributor

This PR just made the generator much, much slower and less efficient. It is highly discouraged to use syntax factory APIs to create source generator text, as they're orders of magnitude slower than just building a string. See: dotnet/roslyn#52914 (comment).

You should copy the IndentedTextWriter type (eg. here) and use that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants