Skip to content

Commit

Permalink
(re)store previous m_removeAsyncAnywhere state
Browse files Browse the repository at this point in the history
  • Loading branch information
AnaCoda committed Aug 9, 2023
1 parent a5ca8cd commit 9501d2f
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,8 @@ private StatementSyntax Transform( ExpressionStatementSyntax exprStmt ) {

private ExpressionSyntax Transform( InvocationExpressionSyntax invocationExpr) {
ITypeSymbol? returnTypeInfo = Model.GetTypeInfo( invocationExpr ).Type;

bool prevRemoveAsyncAnywhereState = m_removeAsyncAnywhere;
if( returnTypeInfo?.MetadataName == "IAsyncEnumerable`1" && returnTypeInfo.ContainingNamespace.ToString() == "System.Collections.Generic" ) {
m_removeAsyncAnywhere = true;
}
Expand All @@ -369,9 +371,13 @@ private ExpressionSyntax Transform( InvocationExpressionSyntax invocationExpr) {
return SyntaxFactory.ParseExpression( $"Task.Run(() => {invocationExpr}).Result" );
}

return invocationExpr
invocationExpr = invocationExpr
.WithExpression( Transform( invocationExpr.Expression ) )
.WithArgumentList( TransformAll( invocationExpr.ArgumentList, Transform ) );

m_removeAsyncAnywhere = prevRemoveAsyncAnywhereState;

return invocationExpr;
}

bool ShouldRemoveReturnedMemberAccess( MemberAccessExpressionSyntax memberAccessExpr ) {
Expand Down

0 comments on commit 9501d2f

Please sign in to comment.