DotAwait 1.0.0-preview.7

This is a prerelease version of DotAwait.
dotnet add package DotAwait --version 1.0.0-preview.7
                    
NuGet\Install-Package DotAwait -Version 1.0.0-preview.7
                    
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.7">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
                    
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.7" />
                    
Directory.Packages.props
<PackageReference Include="DotAwait">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
                    
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.7
                    
#r "nuget: DotAwait, 1.0.0-preview.7"
                    
#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.7
                    
#: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.7&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=DotAwait&version=1.0.0-preview.7&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.

Usage

While 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();

Installation

Install the DotAwait NuGet package into your project via NuGet Package Manager or the .NET CLI:

dotnet add package DotAwait

How it works

DotAwait integrates via MSBuild:

  • Content files contains .Await() extension methods marked with [DotAwait] attribute
  • A source-rewriting task runs before the CoreCompile target
  • Calls like task.Await() become await task
  • All the methods marked with [DotAwait] attribute are removed from the rewritten sources
  • Rewritten sources are emitted under obj/.../.dotawait/src
  • Compilation uses rewritten sources instead of original ones

Compile time safety

DotAwait is designed to be safe and not cause unexpected runtime errors. 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 partial methods with no body
  • For design-time builds DotAwait adds DOTAWAIT_DESIGN_TIME symbol that enables auto-generated stub implementations of these methods

So:

  • In the IDE, .Await() is available and type-checks correctly
  • In a normal build, .Await() is rewritten into await and the partial method definitions are removed
  • If rewriting fails, the build fails because partial methods have no body

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 custom awaitable types.

To make your type compatible, you should create an extension method marked with [DotAwait] attribute with single parameter of your awaitable type.

The recommended implementation looks like this (you only need the overloads you actually use):

namespace DotAwait
{
    internal static partial class DotAwaitTaskExtensions
    {
        [DotAwait]
        public static partial T Await<T>(this MyTaskType<T> task);

        [DotAwait]
        public static partial void Await(this MyTaskType task);
}

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 57 1/14/2026
1.0.0-preview.6 55 1/9/2026
1.0.0-preview.5 56 1/8/2026
1.0.0-preview.4 55 1/5/2026
1.0.0-preview.3 61 1/4/2026
1.0.0-preview.2 61 1/3/2026
1.0.0-preview.1 65 1/3/2026