Skip to content
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

Rm "async" anywhere from IAsyncEnumerable & methods returning it #905

Merged
merged 15 commits into from
Aug 9, 2023

Conversation

AnaCoda
Copy link
Contributor

@AnaCoda AnaCoda commented Aug 2, 2023

TA177961

Motivation is that the sync generator currently can't convert IAsyncEnumerable and most related functions because the Async keyword isn't at the end, for example here:
https://github.com/Brightspace/lms/blob/c4f2338b4d7f6b582b8c56ac959fd953f0846ec3/lp/framework/core/D2L.LP/LP/Security/OAuth2/AccessTokens/Keys/MsSqlKeyDataProvider.cs#L63

In general, there is no clear naming convention for methods that return IAsyncEnumerable except for adding the keyword async somewhere: https://stackoverflow.com/questions/59439281/is-there-a-definitive-naming-convention-for-methods-returning-iasyncenumerable/59452285#59452285

So for converting these we will change all variables/return types defined IAsyncEnumerable to IEnumerable, as well as removing "async" from any method that returns an IAsyncEnumerable.

I also had to make new test methods for this because we needed another method in the class that returns an IAsyncEnumerable

@AnaCoda AnaCoda requested a review from JeffAshton August 3, 2023 19:26
@AnaCoda AnaCoda requested a review from JeffAshton August 4, 2023 19:18
@AnaCoda AnaCoda requested a review from j3parker August 9, 2023 15:57
@AnaCoda AnaCoda mentioned this pull request Aug 9, 2023
@@ -73,6 +75,13 @@ AttributeSyntax attribute
);

private SyntaxToken RemoveAsyncSuffix( SyntaxToken ident, bool optional = false ) {
if( m_removeAsyncAnywhere && ident.ValueText.Contains( "Async" ) ) {
Copy link
Member

Choose a reason for hiding this comment

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

Should this check optional?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think so, because there are cases where a function may return IAsyncEnumerable and not end in Async and we want the sync generator to transform it without a diagnostic

@AnaCoda AnaCoda requested a review from j3parker August 9, 2023 17:32
@AnaCoda AnaCoda requested a review from j3parker August 9, 2023 18:17
@AnaCoda AnaCoda changed the title Remove "async" anywhere from IAsyncEnumerable and methods that return it Rm "async" anywhere from IAsyncEnumerable & methods returning it Aug 9, 2023
@AnaCoda AnaCoda merged commit ea9a2c3 into main Aug 9, 2023
1 check passed
@AnaCoda AnaCoda deleted the anacoda/handle-iasyncenumerable branch August 9, 2023 18: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.

3 participants