jonwagner / Insight.Database

Fast, lightweight .NET micro-ORM
Other
861 stars 145 forks source link

Add ConfigureAwait(false) to all awaits #447

Closed resnikb closed 4 years ago

resnikb commented 4 years ago

Description

When running in environments with a SynchronizationContext, such as WPF or ASP.NET MVC, it is strongly recommended for libraries to use ConfigureAwait(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 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.

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.

jonwagner commented 4 years ago

Good stuff - I'll schedule some time to do a build :+1:

resnikb commented 4 years ago

@jonwagner Thanks! This will help with some of our older projects that can't use Insight yet.

jonwagner commented 4 years ago

Build 6.3.2 has been posted.

resnikb commented 4 years ago

Thanks, @jonwagner