-
-
Notifications
You must be signed in to change notification settings - Fork 273
Closed
Description
This code triggers a false positive because async/await is not possible in an unsafe context:
internal sealed unsafe class UnsafeStream(void* unmanagedMemory) : Stream
{
private readonly void* _unmanagedMemory = unmanagedMemory;
// ↓↓↓ RCS1229: Use async/await when necessary
public override ValueTask<int> ReadAsync(Memory<byte> buffer, CancellationToken cancellationToken = default)
{
// try is required to trigger it
try
{
var tcs = new TaskCompletionSource<int>();
// Do stuff with _unmanagedMemory that will run async and use the TCS to complete the returned task
return new ValueTask<int>(tcs.Task);
}
catch
{
throw;
}
}
}
Metadata
Metadata
Assignees
Labels
No labels