In some places, Insight codebase has been using ConfigureAwait(false), but this has not been the case everywhere. This caused deadlocks when used in environments with a SynchronizationContext.
This PR adds ConfigureAwait(false) to all awaits in the library.
Checklist
Please note that there are no functional changes here, so tests and documentation do not need updating.
[] Tests for any changes have been added (for bug fixes / features).
[] Docs have been added / updated (for bug fixes / features).
Type
This pull request includes what type of changes?
[X] Bug.
[ ] Feature.
[ ] Code style update (formatting, local variables).
[X] Refactoring (no functional changes, no api changes).
[ ] Documentation content changes.
[X] Other (please describe below).
Breaking Changes
Does this pull request introduce any breaking changes?
[ ] Yes
[X] No
Any other comment
In addition to adding ConfigureAwait calls, there are a couple of changes related to T4 templates. The templates did not build for me, some due to invalid include paths, and all due to the ending newline in the included file. This has also been fixed, and .editorconfig updated to ensure that final newline is not automatically added to .tt files.
A small bug has also been fixed, where ReliableConnection.OpenAsync did not pass the cancellation token to the connection.
Description
When running in environments with a
SynchronizationContext
, such as WPF or ASP.NET MVC, it is strongly recommended for libraries to useConfigureAwait(false)
when awaiting asynchronous operations, to avoid deadlocks if their code is used in sync-over-async scenarios.In some places, Insight codebase has been using
ConfigureAwait(false)
, but this has not been the case everywhere. This caused deadlocks when used in environments with aSynchronizationContext
.This PR adds
ConfigureAwait(false)
to all awaits in the library.Checklist
Please note that there are no functional changes here, so tests and documentation do not need updating.
Type
This pull request includes what type of changes?
Breaking Changes
Does this pull request introduce any breaking changes?
Any other comment
In addition to adding
ConfigureAwait
calls, there are a couple of changes related to T4 templates. The templates did not build for me, some due to invalid include paths, and all due to the ending newline in the included file. This has also been fixed, and.editorconfig
updated to ensure that final newline is not automatically added to.tt
files.A small bug has also been fixed, where
ReliableConnection.OpenAsync
did not pass the cancellation token to the connection.