Skip to content

Commit cbf5452

Browse files
Move verbs to incremental pipeline
Use another incremental pipeline to produce the HTTP verbs.
1 parent a136e78 commit cbf5452

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

src/Http/Http.Extensions/gen/RequestDelegateGenerator.cs

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -167,12 +167,17 @@ public void Initialize(IncrementalGeneratorInitializationContext context)
167167
codeWriter.EndBlock();
168168
}
169169

170-
var verbs = endpoints
170+
return stringWriter.ToString();
171+
});
172+
173+
var httpVerbs = endpoints
174+
.Collect()
175+
.Select((endpoints, _) =>
176+
{
177+
return endpoints
171178
.Select(endpoint => endpoint.EmitterContext.HttpMethod!)
172179
.Where(verb => verb is not null)
173180
.ToImmutableHashSet();
174-
175-
return (stringWriter.ToString(), verbs);
176181
});
177182

178183
var endpointHelpers = endpoints
@@ -266,11 +271,16 @@ public void Initialize(IncrementalGeneratorInitializationContext context)
266271
return stringWriter.ToString();
267272
});
268273

269-
var thunksAndEndpoints = thunks.Collect().Combine(stronglyTypedEndpointDefinitions).Combine(endpointHelpers).Combine(helperTypes);
274+
var thunksAndEndpoints = thunks
275+
.Collect()
276+
.Combine(stronglyTypedEndpointDefinitions)
277+
.Combine(httpVerbs)
278+
.Combine(endpointHelpers)
279+
.Combine(helperTypes);
270280

271281
context.RegisterSourceOutput(thunksAndEndpoints, (context, sources) =>
272282
{
273-
var (((thunks, (endpointsCode, verbs)), helperMethods), helperTypes) = sources;
283+
var ((((thunks, endpointsCode), httpVerbs), helperMethods), helperTypes) = sources;
274284

275285
if (thunks.IsDefaultOrEmpty || string.IsNullOrEmpty(endpointsCode))
276286
{
@@ -289,7 +299,7 @@ public void Initialize(IncrementalGeneratorInitializationContext context)
289299
endpoints: endpointsCode,
290300
helperMethods: helperMethods ?? string.Empty,
291301
helperTypes: helperTypes ?? string.Empty,
292-
verbs: verbs);
302+
verbs: httpVerbs);
293303

294304
context.AddSource("GeneratedRouteBuilderExtensions.g.cs", code);
295305
});

0 commit comments

Comments
 (0)