Skip to content

38 Optimize Endpoint Generator#41

Merged
ewilliams0305 merged 10 commits into
mainfrom
38-Optimize-Generator
Sep 18, 2025
Merged

38 Optimize Endpoint Generator#41
ewilliams0305 merged 10 commits into
mainfrom
38-Optimize-Generator

Conversation

@ewilliams0305
Copy link
Copy Markdown
Contributor

@ewilliams0305 ewilliams0305 commented Sep 18, 2025

Scribbly Pull Request

Description

This PR takes advantage of Roslyn APIs used to located specific Attribute Annotations and reduces the query mechanics required to located endpoint method handlers.

context.SyntaxProvider.ForAttributeWithMetadataName

After initial testing the generator seems much faster and will only improve more when Groups are updated as well.

Type of change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

Checklist

  • I have executed all the unit tests
  • I have compiled and executed the application
  • I have updated the documentation to reflect my changes

Github Issues

closes #39

@ewilliams0305 ewilliams0305 linked an issue Sep 18, 2025 that may be closed by this pull request
.Select(static (type, _) => TransformHandlerType(type!.Value))
.WithComparer(TargetMethodCaptureContextComparer.Instance);
IncrementalValueProvider<ImmutableArray<CapturedHandler>> getHandlers = context.SyntaxProvider.ForAttributeWithMetadataName(
GetEndpointAttribute.TypeFullName,
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally I would capture every endpoint handler using the EndpointAttribute base then later determine its derrived type and use that information for the Verb. There would be no need to combine these arrays and reconstruct the Tuples below

IncrementalValuesProvider<TargetMethodCaptureContext> endpointProvider =
combinedEndpointArrays.SelectMany(static (tuple, _) =>
{
var (((gets, posts), puts), deletes) = tuple;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a bit too gnarly for my taste

@ewilliams0305 ewilliams0305 merged commit 072ba61 into main Sep 18, 2025
3 checks passed
@ewilliams0305 ewilliams0305 deleted the 38-Optimize-Generator branch September 18, 2025 15:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SyntaxProvider.ForAllWithMetadataName - Endpoint Generator Optimize Generator Using ForAllWithMetadataName

1 participant