Skip to content

Conversation

ToddGrun
Copy link
Contributor

@ToddGrun ToddGrun commented May 1, 2025

SourceGenerator.DoGenerate was previously writing the text into a StringBuilder, wrapping that in a TextReader, and creating a SourceText from that. Creation of that source text would end up allocating in SourceText.From (likely from calling ReadToEnd in the give text reader)

Instead, we can use a copy of the (unused) StringBuilderText class and just use that as the source text.

SourceGenerator.DoGenerate was previously writing the text into a StringBuilder, wrapping that in a TextReader, and creating a SourceText from that. Creation of that source text would end up allocating in SourceText.From (likely from calling ReadToEnd in the give text reader)

Instead, we can use a copy of the (unused) StringBuilderText and just use that as the source text.
@ToddGrun ToddGrun requested a review from a team as a code owner May 1, 2025 21:24
@ghost ghost added Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead labels May 1, 2025
@ToddGrun ToddGrun requested a review from a team as a code owner May 4, 2025 18:14
@ToddGrun
Copy link
Contributor Author

ToddGrun commented May 5, 2025

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@ToddGrun
Copy link
Contributor Author

ToddGrun commented May 5, 2025

@dotnet/roslyn-compiler -- PTAL as it looks like this one needs compiler reviews.

@jaredpar
Copy link
Member

jaredpar commented May 7, 2025

@chsienki PTAL

@jaredpar jaredpar requested a review from chsienki May 7, 2025 06:46
@ToddGrun ToddGrun merged commit 516ad84 into dotnet:main May 7, 2025
28 checks passed
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone May 7, 2025
333fred added a commit to 333fred/roslyn that referenced this pull request May 8, 2025
* upstream/main: (415 commits)
  Use lazy initialization for members in CodeFixService (dotnet#78484)
  Targeted perf changes to CommandLineParser (dotnet#78446)
  Exclude VS.ExternalAPIs.Roslyn.Package from source-build
  Add syntax highlighting of ignored directives (dotnet#78458)
  Fix unexpected conditional state in nullable analysis of conditional access (dotnet#78439)
  Update RoslynAnalyzers to use Roslyns version
  Fix source-build by renaming Assets folder to assets
  Unlist M.CA.AnalyzerUtilities as an expected DevDivInsertion dependency
  Use a project reference for M.CA.AnalyzerUtilities
  Rectify status of dictionary expressions (dotnet#78497)
  Remove unused field
  Remove unused field
  Remove using
  Fix check
  Update eng/config/PublishData.json
  Make internal
  Remove now unused methods from IWorkspaceProjectContext (dotnet#78479)
  Reduce allocations during SourceGeneration (dotnet#78403)
  Update Roslyn.sln
  Merge EditorFeatures.Wpf entirely into EditorFeatures
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants