Skip to content

Commit 33b5a19

Browse files
committed
Use StringBuilderPool
1 parent fcfe5f5 commit 33b5a19

File tree

4 files changed

+10
-1
lines changed

4 files changed

+10
-1
lines changed

src/Compiler/Directory.Packages.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
<PackageVersion Include="Microsoft.Css.Parser" Version="$(MicrosoftCssParserVersion)" />
1616
<PackageVersion Include="Microsoft.Extensions.DependencyModel" Version="$(MicrosoftExtensionsDependencyModelVersion)" />
1717
<PackageVersion Include="Microsoft.Extensions.FileSystemGlobbing" Version="$(MicrosoftExtensionsFileSystemGlobbingVersion)" />
18+
<PackageVersion Include="Microsoft.Extensions.ObjectPool" Version="$(MicrosoftExtensionsPackageVersion)" />
1819
<PackageVersion Include="Microsoft.NET.Sdk.Razor.SourceGenerators.Transport" Version="$(Benchmarks_BaselineSourceGeneratorsVersion)" />
1920
<PackageVersion Include="Moq" Version="$(MoqVersion)" />
2021
<PackageVersion Include="Newtonsoft.Json" Version="$(NewtonsoftJsonVersion)" />

src/Compiler/Microsoft.AspNetCore.Razor.Language/src/Microsoft.AspNetCore.Razor.Language.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
</PropertyGroup>
1010

1111
<ItemGroup>
12+
<ProjectReference Include="..\..\..\Razor\src\Microsoft.AspNetCore.Razor.Common\Microsoft.AspNetCore.Razor.Common.csproj" />
1213
<ProjectReference Include="$(SharedSourceRoot)\Microsoft.AspNetCore.Razor.LanguageSupport\Microsoft.AspNetCore.Razor.LanguageSupport.csproj" />
1314
</ItemGroup>
1415

src/Compiler/Microsoft.AspNetCore.Razor.Language/src/Syntax/SyntaxNodeExtensions.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using System.Collections.Generic;
88
using System.Diagnostics;
99
using Microsoft.AspNetCore.Razor.Language.Legacy;
10+
using Microsoft.AspNetCore.Razor.PooledObjects;
1011

1112
namespace Microsoft.AspNetCore.Razor.Language.Syntax;
1213

@@ -204,7 +205,8 @@ public static TRoot InsertNodesAfter<TRoot>(this TRoot root, SyntaxNode nodeInLi
204205

205206
public static string GetContent<TNode>(this TNode node) where TNode : SyntaxNode
206207
{
207-
using var writer = new System.IO.StringWriter();
208+
using var _ = StringBuilderPool.GetPooledObject(out var sb);
209+
using var writer = new System.IO.StringWriter(sb);
208210
node.Green.WriteTo(writer);
209211
return writer.ToString();
210212
}

src/Compiler/tools/Microsoft.AspNetCore.Razor.SourceGenerator.Tooling.Internal/Microsoft.AspNetCore.Razor.SourceGenerator.Tooling.Internal.csproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,15 @@
2626
ClassName="Microsoft.AspNetCore.Mvc.Razor.Extensions.RazorExtensionsResources" />
2727

2828
<Compile Include="$(SharedSourceRoot)\Microsoft.AspNetCore.Razor.LanguageSupport\NullableAttributes.cs" LinkBase="LanguageSupport" />
29+
30+
<Compile Include="..\..\..\Razor\src\Microsoft.AspNetCore.Razor.Common\PooledObjects\**\*.cs" LinkBase="PooledObjects" />
31+
32+
<Compile Include="..\..\..\Razor\src\Microsoft.AspNetCore.Razor.Common\Utilities\**\*.cs" LinkBase="Utilities" />
2933
</ItemGroup>
3034

3135
<ItemGroup>
3236
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" PrivateAssets="All" />
37+
<PackageReference Include="Microsoft.Extensions.ObjectPool" PrivateAssets="All" />
3338
</ItemGroup>
3439

3540
</Project>

0 commit comments

Comments
 (0)