-
Notifications
You must be signed in to change notification settings - Fork 745
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Async overloads source generator #1575
Merged
bartdesmet
merged 36 commits into
dotnet:main
from
bash:async-overloads-source-generator
Aug 24, 2021
Merged
Async overloads source generator #1575
bartdesmet
merged 36 commits into
dotnet:main
from
bash:async-overloads-source-generator
Aug 24, 2021
Conversation
This file contains 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
Thanks for your contribution. This simplifies and modernizes the code significantly and sets a good example for future source generators in this space (e.g. the generation of expression tree based "queryable" variants of operators, which is a bit more involved). |
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.
I took a crack at writing a source generator to replace the
AsyncOverloads.t4
template. This is a follow up to my PR #1545.Details
The source generator looks for methods annotated with the
[GenerateAsyncOverload]
attribute.It generates a public method with the same signature, return type, generic parameter constraints, etc. that calls the annotated method.
The generator even copies the XML documentation to the public method. 🤓
API Diff
I used Microsoft.DotNet.GenAPI (the tool generates a C# file representing the API of an assembly) to ensure that I didn't accidentally break the API surface.
A pre-generated diff is available in this gist. The only thing that changed is that the
comparer
parameter in the generated methods is now marked as nullable too which is a good change I think?Instructions for verifying the API diff
Here's a .patch file that installs Microsoft.DotNet.GenAPI (can be applied using
git apply <patch-file>
).main
branchdotnet build /p:GenerateReferenceAssemblySource=true /p:GenAPITargetPath=System.Linq.Async-before --framework netcoreapp3.1 --no-incremental Ix.NET/Source/System.Linq.Async
dotnet build /p:GenerateReferenceAssemblySource=true /p:GenAPITargetPath=System.Linq.Async-after --framework netcoreapp3.1 --no-incremental Ix.NET/Source/System.Linq.Async
git diff --no-index -- Ix.NET/Source/System.Linq.Async/System.Linq.Async-before Ix.NET/Source/System.Linq.Async/System.Linq.Async-after
Unrelated changes
I found that having a solution filter that only opens projects needed for System.Linq.Async to be really helpful while working on System.Linq.Async. I can revert the commit ba8ba26 if you don't want the solution filter checked into the repo.