DotAwait 1.0.0-preview.4
See the version list below for details.
dotnet add package DotAwait --version 1.0.0-preview.4
NuGet\Install-Package DotAwait -Version 1.0.0-preview.4
<PackageReference Include="DotAwait" Version="1.0.0-preview.4" />
<PackageVersion Include="DotAwait" Version="1.0.0-preview.4" />
<PackageReference Include="DotAwait" />
paket add DotAwait --version 1.0.0-preview.4
#r "nuget: DotAwait, 1.0.0-preview.4"
#:package DotAwait@1.0.0-preview.4
#addin nuget:?package=DotAwait&version=1.0.0-preview.4&prerelease
#tool nuget:?package=DotAwait&version=1.0.0-preview.4&prerelease
DotAwait is still in early development. Use with caution!
DotAwait
Write await in a fluent/LINQ-friendly style with a single .Await() extension call.
Why
In C#, await forces you to 'drop out' of the fluent chain:
var names = (await service.GetUsersAsync())
.Where(u => u.IsActive)
.Select(u => u.Name)
.ToArray();
With DotAwait, you can keep the chain intact:
var names = service
.GetUsersAsync()
.Await()
.Where(u => u.IsActive)
.Select(u => u.Name)
.ToArray();
How it works
DotAwait hooks into compilation via MSBuild:
- Source rewriting task runs before
CoreCompiletarget - Calls like
task.Await()becomeawait task - The rewritten sources are emitted under
obj/.../.dotawait/srcand passed to the compiler
The .Await() methods are just stubs and should never execute.
Implicit usings
DotAwait provides a set of implicit usings to simplify your code. They are enabled by default which can cause problems for C# 9 or lower. You can disable them by adding the following to your project file:
<PropertyGroup>
<DotAwaitImplicitUsings>disable</DotAwaitImplicitUsings>
</PropertyGroup>
Custom awaitable types support
DotAwait supports user-defined task-like types.
To make your type compatible you should add the following definition to your project:
namespace DotAwait
{
internal static partial class DotAwaitTaskExtensions
{
public static T Await<T>(this MyTaskType<T> task) => Throw<T>();
public static void Await(this MyTaskType task) => Throw();
}
}
It's not required to add both void and generic overloads, only those that you need.
To be done
This is an early version, so there are some things to be done:
- Automated tests
- Rewriter optimizations
- Edge cases validation
- Verify .props and .targets doesn't affect transitive dependencies
- Fix debugger line matching issues
- Visual Studio extension for highlighting
.Await()the same way asawaitkeyword
License
This project is licensed under the MIT License
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0-preview.7 | 81 | 1/14/2026 |
| 1.0.0-preview.6 | 74 | 1/9/2026 |
| 1.0.0-preview.5 | 75 | 1/8/2026 |
| 1.0.0-preview.4 | 79 | 1/5/2026 |
| 1.0.0-preview.3 | 85 | 1/4/2026 |
| 1.0.0-preview.2 | 81 | 1/3/2026 |
| 1.0.0-preview.1 | 86 | 1/3/2026 |