Split method cloning from the async to sync rules - #168
Merged
Merged
Conversation
Separates the parts of the generator which have nothing to do with async from the async to sync rules, so that the next transformation does not have to start by untangling them: - CloneTarget finds the methods an attribute marks, directly or through their containing type - MethodLocation collects the namespaces, using directives and containing types a copy of a method needs to compile - MethodSignature and ClonedMethodOutput detect colliding signatures, name the generated files and register the output - ClonedMethodSource writes the file around the rewritten method SyncMethodSourceGenerator keeps the attributes, the filtering and the rewriter. Namespaces and using directives are now collected for every method rather than only for those without errors, so a method with errors is no longer compared for collisions without its namespace. Generated with Claude Code
The half of the rewriter which fully qualifies the types and static members a method names, so that its copy compiles in a file of its own, moves into Cloning/CloningRewriter. AsyncToSyncRewriter derives from it and keeps the async to sync rules. Visitors which did both now call the base for the qualification and apply the async rules to its result. Where the async rules change how a type is named, they go through two hooks of the base: MapSymbol for Task to void or T and the async enumerator to IEnumerator, and MapTypeName for AsyncEnumerable to Enumerable. A parameter whose type has no named type symbol, such as a type parameter, now goes through the base's qualification as well, which writes the same text for it. AGENTS.md describes the Cloning layer and where the boundary is. Generated with Claude Code
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #168 +/- ##
==========================================
+ Coverage 92.19% 92.26% +0.07%
==========================================
Files 11 15 +4
Lines 1652 1706 +54
Branches 381 391 +10
==========================================
+ Hits 1523 1574 +51
- Misses 45 48 +3
Partials 84 84 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Separates copying a method into its own file from the async to sync rules, so a second transformation would not have to untangle them. No change to generated output; every snapshot is unchanged.
Cloning/now holds target discovery (CloneTarget), namespaces/usings/containing types (MethodLocation), collision detection and file naming (MethodSignature,ClonedMethodOutput), and file emission (ClonedMethodSource).CloningRewriteris a new base class that fully qualifies types and static members.AsyncToSyncRewriterderives from it and keeps only the async rules; its type substitutions go through theMapSymbolandMapTypeNamehooks.Namespaces are now collected for methods with errors too, so such methods in different namespaces are no longer compared for collisions without them.
Generated with Claude Code