DotAwait 1.0.0-preview.5

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.5
                    
NuGet\Install-Package DotAwait -Version 1.0.0-preview.5
                    
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.5" />
                    
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.5" />
                    
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.5
                    
#r "nuget: DotAwait, 1.0.0-preview.5"
                    
#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.5
                    
#: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.5&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=DotAwait&version=1.0.0-preview.5&prerelease
                    
Install as a Cake Tool

NuGet License

DotAwait is still in early development. Use with caution!

DotAwait

DotAwait lets you use await in a fluent / LINQ-friendly style via an .Await() extension call that gets rewritten at build time.

Why

In C#, await often breaks fluent chains:

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 integrates via MSBuild targets:

  • A source-rewriting step runs before the CoreCompile target
  • Calls like task.Await() are rewritten into await task
  • All DotAwaitTaskExtensions declarations in the DotAwait namespace are removed from the rewritten sources (they are only needed for design-time type checking)
  • Rewritten sources are emitted under obj/.../.dotawait/src and then compiled

Compile time safety

DotAwait is designed to be safe to use in production. The rewrite step is all-or-nothing - if anything goes wrong, the build fails at compile time, not at runtime.

How:

  • All .Await() extension methods are implemented as calls to DesignTimeStub().
  • DesignTimeStub() exists only under #if DOTAWAIT_DESIGN_TIME.
  • DOTAWAIT_DESIGN_TIME is defined only for design-time builds (IDE/type-checking).

So:

  • In the IDE, .Await() is available and type-checks correctly
  • In a normal build, .Await() is rewritten into await. If rewriting fails, the build fails

Implicit usings

DotAwait provides implicit usings enabled by default to simplify usage.

Implicit usings are a C# 10+ feature, so they may cause issues in projects using older language versions.

To disable DotAwait implicit usings, add the following to your project file:

<PropertyGroup>
  <DotAwaitImplicitUsings>disable</DotAwaitImplicitUsings>
</PropertyGroup>

Custom awaitable (task-like) types

DotAwait supports user-defined task-like types.

To make your type compatible, add the following to your project:

namespace DotAwait
{
    internal static partial class DotAwaitTaskExtensions
    {
        public static T Await<T>(this MyTaskType<T> task) => DesignTimeStub<T>();
        
        public static void Await(this MyTaskType task) => DesignTimeStub();
    }
}

You only need the overloads you actually use.

Roadmap

  • Automated tests
  • Code cleanup
  • Rewriter optimizations
  • Edge-case validation
  • Ensure .props / .targets do not affect transitive dependencies
  • Fix debugger line mapping issues
  • Visual Studio extension to highlight .Await() similarly to the 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