Repository navigation
Remove no sync context scope and add ConfigureAwait(false) - #5225
Conversation
371c320 to
3cc96a3
Compare
# Conflicts: # src/Npgsql/NpgsqlCommand.cs # src/Npgsql/NpgsqlDataReader.cs
3cc96a3 to
2c4c00a
Compare
roji
left a comment
There was a problem hiding this comment.
Looks good! There's some cases of ThrowIfCancelled() in a non-async method, which would produce an exception instead of a cancelled task (see below), as well as some more simplifying inline opportunities.
Important: the project seems to build just fine if a ConfigureAwait(false) is omitted; I think we need to make CA2007 it a warning via .editorconfig (which warnings-as-errors then turns to an error)
| Task Write<T>(bool async, T value, string dataTypeName, CancellationToken cancellationToken = default) | ||
| { | ||
| CheckColumnIndex(); | ||
| cancellationToken.ThrowIfCancellationRequested(); |
There was a problem hiding this comment.
Careful, if you do this from a non-async method, invoking with a cancelled token causes an OperationCancelledException to be thrown, rather than a cancelled task to be returned (it's subtle but it's there). That's why we currently have a check followed by returning a cancelled task (seems like another analyzer rule that should be there...)
There was a problem hiding this comment.
Yes good catch, I clearly went too fast with the refactor here. (I'm aware of the semantic difference, I authored https://www.nuget.org/packages/Ply after all)
There was a problem hiding this comment.
Doesn't look like it's fixed
There was a problem hiding this comment.
I thought I saw it fixed, maybe some sort of botched commit?
There was a problem hiding this comment.
10eaa3e to
fdc94fb
Compare
| Task Write<T>(bool async, T value, NpgsqlDbType npgsqlDbType, CancellationToken cancellationToken = default) | ||
| { | ||
| CheckColumnIndex(); | ||
| cancellationToken.ThrowIfCancellationRequested(); |
There was a problem hiding this comment.
Shouldn't it return Task.FromCanceled just like above?
| Task Write<T>(bool async, T value, string dataTypeName, CancellationToken cancellationToken = default) | ||
| { | ||
| CheckColumnIndex(); | ||
| cancellationToken.ThrowIfCancellationRequested(); |
There was a problem hiding this comment.
Doesn't look like it's fixed
Closes #1130