Unable to weave async/await
arontsang opened this issue · comments
Fody 4.2.1
Ionad.Fody 1.0.2
MsBuild 15
VS2017
Trying to weave
public static TaskRx
{
public Task Delay(int delay)
{
return Observerable.Timer(delay, RxApp.BackgroundThreadScheduler).ToTask();
}
}
Possibly because I was trying to weave this inside a lambda, will try to create a SSCCE tomorrow at work.
can u try with the latest version
As promised, here is a SSCCE. Unfortunately I do not have access to VS2019, so 4.2.1 is the best I can get access to.
class Program
{
static async Task<int> Main(string[] args)
{
var ret = Observable.Create<string>(async (observer, cancellation) =>
{
await Task.Delay(100, cancellation);
observer.OnNext("Hello World!");
});
using(ret.Subscribe(Console.WriteLine))
{
await Task.Delay(100000);
}
return 0;
}
}
[StaticReplacement(typeof(Task))]
public static class TaskRx
{
public static Task Delay(int delay, CancellationToken cancellationToken)
{
return Observable.Timer(TimeSpan.FromMilliseconds(delay)).ToTask(cancellationToken);
}
public static Task Delay(int delay)
{
return Observable.Timer(TimeSpan.FromMilliseconds(delay)).ToTask();
}
}
This program throws a System.InvalidProgramException in System.Private.CoreLib.dll
Exist persists with
VS2019
MSBuild 16
Fody 5
Ionad 2
Closing because issue has nothing to do with async/await, and is completely to do with method overloading.