Consider the following code
private SemaphoreSlim semaphore = new(1);
[Zomp.SyncMethodGenerator.CreateSyncVersion()]
public async Task FooAsync(CancellationToken cancellationToken = default)
{
await semaphore.WaitAsync(cancellationToken);
try
{
await Task.Delay(100, cancellationToken);
}
finally
{
semaphore.Release();
}
}
I was expecting it to become
public void Foo()
{
semaphore.Wait(cancellationToken);
try
{
global::System.Threading.Thread.Sleep(100);
}
finally
{
semaphore.Release();
}
}
However what I actually got was
public void Foo()
{
try
{
global::System.Threading.Thread.Sleep(100);
}
finally
{
semaphore.Release();
}
}
Notice that the semaphore.Wait(cancellationToken); is missing from the code generation, and the semaphore will become out of sync
Consider the following code
I was expecting it to become
However what I actually got was
Notice that the
semaphore.Wait(cancellationToken);is missing from the code generation, and the semaphore will become out of sync