DotAwait 1.0.0-preview.4

This is a prerelease version of DotAwait.
There is a newer prerelease version of this package available.
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
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="DotAwait" Version="1.0.0-preview.4" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DotAwait" Version="1.0.0-preview.4" />
                    
Directory.Packages.props
<PackageReference Include="DotAwait" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add DotAwait --version 1.0.0-preview.4
                    
#r "nuget: DotAwait, 1.0.0-preview.4"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package DotAwait@1.0.0-preview.4
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=DotAwait&version=1.0.0-preview.4&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=DotAwait&version=1.0.0-preview.4&prerelease
                    
Install as a Cake Tool

NuGet License

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 CoreCompile target
  • Calls like task.Await() become await task
  • The rewritten sources are emitted under obj/.../.dotawait/src and 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 as await keyword

License

This project is licensed under the MIT License

There are no supported framework assets in this package.

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