Hi,
I'm developing a macro that takes an async function as a parameter and wraps it in a Task
. My problem is that the execution does not halt at breakpoints that I set in the block:
Breakpoints that I set in the expanded macro, work though:
Is there a way to make this work?
My macro looks like this:
public struct RunMacro: ExpressionMacro {
public static func expansion(
of node: some FreestandingMacroExpansionSyntax,
in context: some MacroExpansionContext
) -> ExprSyntax {
guard let closure = node.arguments.first?.expression.as(ClosureExprSyntax.self) ?? node.trailingClosure else {
// Expected closure
return ""
}
return
"""
Task { () async throws in
return try await { () async throws in
\(closure)()
}()
}
"""
}
}
Thanks!