Skip to content

Commit f3a4b80

Browse files
authored
Generate Files in Parallel (#8882)
1 parent 7e117b9 commit f3a4b80

14 files changed

+168
-123
lines changed

src/HotChocolate/Core/src/Types.Analyzers/FileBuilders/DataLoaderFileBuilder.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
using HotChocolate.Types.Analyzers.Inspectors;
55
using HotChocolate.Types.Analyzers.Models;
66
using Microsoft.CodeAnalysis;
7-
using Microsoft.CodeAnalysis.Text;
87
using static HotChocolate.Types.Analyzers.Helpers.GeneratorUtils;
98

109
namespace HotChocolate.Types.Analyzers.FileBuilders;
@@ -678,9 +677,6 @@ private static ITypeSymbol ExtractMapType(ITypeSymbol returnType)
678677
public override string ToString()
679678
=> _sb.ToString();
680679

681-
public SourceText ToSourceText()
682-
=> SourceText.From(ToString(), Encoding.UTF8);
683-
684680
public void Dispose()
685681
{
686682
if (_disposed)

src/HotChocolate/Core/src/Types.Analyzers/FileBuilders/DataLoaderModuleFileBuilder.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using System.Text;
22
using HotChocolate.Types.Analyzers.Helpers;
3-
using Microsoft.CodeAnalysis.Text;
43

54
namespace HotChocolate.Types.Analyzers.FileBuilders;
65

@@ -118,9 +117,6 @@ public void WriteAddDataLoaderGroup(string groupType, string groupInterfaceType)
118117
public override string ToString()
119118
=> _sb.ToString();
120119

121-
public SourceText ToSourceText()
122-
=> SourceText.From(ToString(), Encoding.UTF8);
123-
124120
public void Dispose()
125121
{
126122
if (_disposed)

src/HotChocolate/Core/src/Types.Analyzers/FileBuilders/ModuleFileBuilder.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using System.Text;
22
using HotChocolate.Types.Analyzers.Helpers;
33
using HotChocolate.Types.Analyzers.Models;
4-
using Microsoft.CodeAnalysis.Text;
54

65
namespace HotChocolate.Types.Analyzers.FileBuilders;
76

@@ -166,9 +165,6 @@ public void WriteTryAddOperationType(OperationType type)
166165
public override string ToString()
167166
=> _sb.ToString();
168167

169-
public SourceText ToSourceText()
170-
=> SourceText.From(ToString(), Encoding.UTF8);
171-
172168
public void Dispose()
173169
{
174170
if (_disposed)

src/HotChocolate/Core/src/Types.Analyzers/FileBuilders/OperationFieldFileBuilder.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using System.Text;
22
using HotChocolate.Types.Analyzers.Helpers;
33
using HotChocolate.Types.Analyzers.Models;
4-
using Microsoft.CodeAnalysis.Text;
54

65
namespace HotChocolate.Types.Analyzers.FileBuilders;
76

@@ -115,9 +114,6 @@ private static string GetOperationConstant(OperationType type)
115114
public override string ToString()
116115
=> _sb.ToString();
117116

118-
public SourceText ToSourceText()
119-
=> SourceText.From(ToString(), Encoding.UTF8);
120-
121117
public void Dispose()
122118
{
123119
if (_disposed)

src/HotChocolate/Core/src/Types.Analyzers/FileBuilders/RequestMiddlewareFileBuilder.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using System.Text;
22
using HotChocolate.Types.Analyzers.Helpers;
33
using HotChocolate.Types.Analyzers.Models;
4-
using Microsoft.CodeAnalysis.Text;
54
using static HotChocolate.Types.Analyzers.WellKnownTypes;
65

76
namespace HotChocolate.Types.Analyzers.FileBuilders;
@@ -282,9 +281,6 @@ public void WriteInterceptMethod(
282281
public override string ToString()
283282
=> _sb.ToString();
284283

285-
public SourceText ToSourceText()
286-
=> SourceText.From(ToString(), Encoding.UTF8);
287-
288284
public void Dispose()
289285
{
290286
if (_disposed)

src/HotChocolate/Core/src/Types.Analyzers/Generators/DataLoaderGenerator.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
using HotChocolate.Types.Analyzers.Inspectors;
55
using HotChocolate.Types.Analyzers.Models;
66
using Microsoft.CodeAnalysis;
7-
using Microsoft.CodeAnalysis.Text;
87

98
namespace HotChocolate.Types.Analyzers.Generators;
109

@@ -14,7 +13,7 @@ public void Generate(
1413
SourceProductionContext context,
1514
string assemblyName,
1615
ImmutableArray<SyntaxInfo> syntaxInfos,
17-
Action<string, SourceText> addSource)
16+
Action<string, string> addSource)
1817
{
1918
var dataLoaderDefaults = syntaxInfos.GetDataLoaderDefaults();
2019
WriteDataLoader(syntaxInfos, dataLoaderDefaults, addSource);
@@ -23,7 +22,7 @@ public void Generate(
2322
private static void WriteDataLoader(
2423
ImmutableArray<SyntaxInfo> syntaxInfos,
2524
DataLoaderDefaultsInfo defaults,
26-
Action<string, SourceText> addSource)
25+
Action<string, string> addSource)
2726
{
2827
var dataLoaders = new List<DataLoaderInfo>();
2928

@@ -124,7 +123,7 @@ private static void WriteDataLoader(
124123

125124
if (hasDataLoaders)
126125
{
127-
addSource(WellKnownFileNames.DataLoaderFile, generator.ToSourceText());
126+
addSource(WellKnownFileNames.DataLoaderFile, generator.ToString());
128127
}
129128
}
130129

src/HotChocolate/Core/src/Types.Analyzers/Generators/DataLoaderModuleGenerator.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
using HotChocolate.Types.Analyzers.Helpers;
44
using HotChocolate.Types.Analyzers.Models;
55
using Microsoft.CodeAnalysis;
6-
using Microsoft.CodeAnalysis.Text;
76

87
namespace HotChocolate.Types.Analyzers.Generators;
98

@@ -13,7 +12,7 @@ public void Generate(
1312
SourceProductionContext context,
1413
string assemblyName,
1514
ImmutableArray<SyntaxInfo> syntaxInfos,
16-
Action<string, SourceText> addSource)
15+
Action<string, string> addSource)
1716
{
1817
var module = GetDataLoaderModuleInfo(syntaxInfos);
1918
var dataLoaderDefaults = syntaxInfos.GetDataLoaderDefaults();
@@ -73,7 +72,7 @@ public void Generate(
7372
generator.WriteEndClass();
7473
generator.WriteEndNamespace();
7574

76-
addSource(WellKnownFileNames.DataLoaderModuleFile, generator.ToSourceText());
75+
addSource(WellKnownFileNames.DataLoaderModuleFile, generator.ToString());
7776
}
7877

7978
private static DataLoaderModuleInfo? GetDataLoaderModuleInfo(
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using System.Collections.Immutable;
22
using HotChocolate.Types.Analyzers.Models;
33
using Microsoft.CodeAnalysis;
4-
using Microsoft.CodeAnalysis.Text;
54

65
namespace HotChocolate.Types.Analyzers.Generators;
76

@@ -11,5 +10,5 @@ void Generate(
1110
SourceProductionContext context,
1211
string assemblyName,
1312
ImmutableArray<SyntaxInfo> syntaxInfos,
14-
Action<string, SourceText> addSource);
13+
Action<string, string> addSource);
1514
}

src/HotChocolate/Core/src/Types.Analyzers/Generators/MiddlewareGenerator.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
using HotChocolate.Types.Analyzers.Helpers;
44
using HotChocolate.Types.Analyzers.Models;
55
using Microsoft.CodeAnalysis;
6-
using Microsoft.CodeAnalysis.Text;
76

87
namespace HotChocolate.Types.Analyzers.Generators;
98

@@ -15,7 +14,7 @@ public void Generate(
1514
SourceProductionContext context,
1615
string assemblyName,
1716
ImmutableArray<SyntaxInfo> syntaxInfos,
18-
Action<string, SourceText> addSource)
17+
Action<string, string> addSource)
1918
{
2019
if (syntaxInfos.IsEmpty)
2120
{
@@ -65,6 +64,6 @@ public void Generate(
6564

6665
generator.WriteEndNamespace();
6766

68-
addSource(WellKnownFileNames.MiddlewareFile, generator.ToSourceText());
67+
addSource(WellKnownFileNames.MiddlewareFile, generator.ToString());
6968
}
7069
}

src/HotChocolate/Core/src/Types.Analyzers/Generators/TypeModuleSyntaxGenerator.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
using HotChocolate.Types.Analyzers.Helpers;
44
using HotChocolate.Types.Analyzers.Models;
55
using Microsoft.CodeAnalysis;
6-
using Microsoft.CodeAnalysis.Text;
76
using TypeInfo = HotChocolate.Types.Analyzers.Models.TypeInfo;
87

98
namespace HotChocolate.Types.Analyzers.Generators;
@@ -14,7 +13,7 @@ public void Generate(
1413
SourceProductionContext context,
1514
string assemblyName,
1615
ImmutableArray<SyntaxInfo> syntaxInfos,
17-
Action<string, SourceText> addSource)
16+
Action<string, string> addSource)
1817
{
1918
if (syntaxInfos.IsEmpty)
2019
{
@@ -43,7 +42,7 @@ public void Generate(
4342
private static void WriteConfiguration(
4443
List<SyntaxInfo> syntaxInfos,
4544
ModuleInfo module,
46-
Action<string, SourceText> addSource)
45+
Action<string, string> addSource)
4746
{
4847
var dataLoaderDefaults = syntaxInfos.GetDataLoaderDefaults();
4948
HashSet<(string InterfaceName, string ClassName)>? groups = null;
@@ -267,14 +266,14 @@ private static void WriteConfiguration(
267266

268267
if (hasConfigurations)
269268
{
270-
addSource(WellKnownFileNames.TypeModuleFile, generator.ToSourceText());
269+
addSource(WellKnownFileNames.TypeModuleFile, generator.ToString());
271270
}
272271
}
273272

274273
private static void WriteOperationTypes(
275274
List<SyntaxInfo> syntaxInfos,
276275
ModuleInfo module,
277-
Action<string, SourceText> addSource)
276+
Action<string, string> addSource)
278277
{
279278
var operations = new List<OperationInfo>();
280279

@@ -310,7 +309,7 @@ private static void WriteOperationTypes(
310309

311310
generator.WriteEndNamespace();
312311

313-
addSource(WellKnownFileNames.RootTypesFile, generator.ToSourceText());
312+
addSource(WellKnownFileNames.RootTypesFile, generator.ToString());
314313
}
315314

316315
public static string GetAssemblyQualifiedName(ITypeSymbol typeSymbol)

0 commit comments

Comments
 (0)