Currently there is no default implementation of IASTVisitorContext. I suggest providing one with a CancellationToken and one without a CancellationToken (where => default;).
In a similar vein, perhaps we should add an extension method to run a visitor synchronously. Many visitors will not run asynchronously and will not need a cancellation token. .GetAwaiter().GetResult() produces a warning as it will not work correctly if run on a truly asynchronous task, but .ToTask() returns Task.CompletedTask for a completed ValueTask and so perhaps .ToTask().GetAwaiter().GetResult() is an allocation-free and safe method to expose externally.
Currently there is no default implementation of
IASTVisitorContext
. I suggest providing one with aCancellationToken
and one without aCancellationToken
(where=> default;
).In a similar vein, perhaps we should add an extension method to run a visitor synchronously. Many visitors will not run asynchronously and will not need a cancellation token.
.GetAwaiter().GetResult()
produces a warning as it will not work correctly if run on a truly asynchronous task, but.ToTask()
returnsTask.CompletedTask
for a completedValueTask
and so perhaps.ToTask().GetAwaiter().GetResult()
is an allocation-free and safe method to expose externally.