Zomp.SyncMethodGenerator
0.1.4-alpha
See the version list below for details.
dotnet add package Zomp.SyncMethodGenerator --version 0.1.4-alpha
NuGet\Install-Package Zomp.SyncMethodGenerator -Version 0.1.4-alpha
<PackageReference Include="Zomp.SyncMethodGenerator" Version="0.1.4-alpha" />
<PackageVersion Include="Zomp.SyncMethodGenerator" Version="0.1.4-alpha" />
<PackageReference Include="Zomp.SyncMethodGenerator" />
paket add Zomp.SyncMethodGenerator --version 0.1.4-alpha
#r "nuget: Zomp.SyncMethodGenerator, 0.1.4-alpha"
#:package Zomp.SyncMethodGenerator@0.1.4-alpha
#addin nuget:?package=Zomp.SyncMethodGenerator&version=0.1.4-alpha&prerelease
#tool nuget:?package=Zomp.SyncMethodGenerator&version=0.1.4-alpha&prerelease
Sync Method Generator
This .NET source generator produces a sync method from an async one.
Use cases
- A library which exposes both sync and async version of a method
- An application has to process two kinds of data in the same way:
- Large data from I/O which cannot be stored in memory before processing: Original async method
- Small sample of data in memory, usually a sample of the larger data: Generated sync method
How it works
Add CreateSyncVersionAttribute to your async method in your partial class
[Zomp.SyncMethodGenerator.CreateSyncVersion]
static async Task WriteAsync(ReadOnlyMemory<byte> buffer, Stream stream,
CancellationToken ct)
=> await stream.WriteAsync(buffer, ct).ConfigureAwait(true);
And it will generate a sync version of the method:
static void Write(ReadOnlySpan<byte> buffer, Stream stream)
=> stream.Write(buffer);
A list of changes applied to the new synchronized method:
Remove async modifier
Remove await from methods as well as
foreachstatementChange types
From To Task or ValueTask void Task<T> or ValueTask<T> T IAsyncEnumerable<T> IEnumerable<T> IAsyncEnumerator<T> IEnumerator<T> Memory<T> Span<T> ReadOnlyMemory<T> ReadOnlySpan<T> Remove parameters
Invocation changes
- Remove ConfigureAwait
- Remove WithCancellation
- Remove
Asyncsuffix from method calls (e.g. MoveNextAsync becomes MoveNext) - Remove CancellationToken parameter
- Remove IProgress<T>.Report(T) call
- Remove Memory<T>.Span property
Remove
CreateSyncVersionAttributeUpdate XML documentation
Installation
To add the library use:
dotnet add package Zomp.SyncMethodGenerator
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 (4)
Showing the top 4 popular GitHub repositories that depend on Zomp.SyncMethodGenerator:
| Repository | Stars |
|---|---|
|
FluentValidation/FluentValidation
A popular .NET validation library for building strongly-typed validation rules.
|
|
|
mini-software/MiniExcel
Fast, Low-Memory, Easy Excel .NET helper to import/export/template spreadsheet (support Linux, Mac)
|
|
|
Zeugma440/atldotnet
Fully managed, portable and easy-to-use C# library to read and edit audio data and metadata (tags) from various audio formats, playlists and CUE sheets
|
|
|
BigBang1112/gbx-net
General purpose library for Gbx files - data from Nadeo games like Trackmania or Shootmania, written in C#/.NET. It supports high performance serialization and deserialization of 400+ Gbx classes.
|
| Version | Downloads | Last Updated | |
|---|---|---|---|
| 2.0.7 | 373 | 12/24/2025 | |
| 2.0.5 | 423 | 12/15/2025 | |
| 2.0.4 | 288 | 11/27/2025 | |
| 2.0.3 | 202 | 11/27/2025 | |
| 2.0.2 | 188 | 11/24/2025 | |
| 2.0.1 | 185 | 11/24/2025 | |
| 1.6.17 | 1,267 | 7/28/2025 | |
| 1.6.16 | 156 | 7/28/2025 | |
| 1.6.15 | 257 | 7/28/2025 | |
| 1.6.14 | 182 | 7/27/2025 | |
| 1.6.13 | 382 | 7/27/2025 | |
| 1.6.12 | 270 | 7/26/2025 | |
| 1.6.11 | 543 | 7/24/2025 | |
| 1.6.10 | 939 | 7/24/2025 | |
| 1.6.9 | 610 | 7/23/2025 | |
| 1.6.8 | 389 | 7/20/2025 | |
| 1.6.3 | 217 | 7/17/2025 | |
| 1.6.2 | 1,301 | 7/8/2025 | |
| 1.6.1 | 197 | 7/8/2025 | |
| 1.5.3 | 229 | 7/4/2025 | |
| 1.5.1 | 288 | 6/29/2025 | |
| 1.4.38 | 220 | 6/23/2025 | |
| 1.4.37 | 283 | 6/23/2025 | |
| 1.4.35 | 217 | 6/17/2025 | |
| 1.4.32 | 347 | 6/17/2025 | |
| 1.4.30 | 699 | 6/14/2025 | |
| 1.4.29 | 581 | 6/12/2025 | |
| 1.4.28 | 366 | 6/11/2025 | |
| 1.4.27 | 349 | 6/11/2025 | |
| 1.4.26 | 575 | 6/11/2025 | |
| 1.4.25 | 576 | 6/10/2025 | |
| 1.4.20 | 593 | 3/9/2025 | |
| 1.4.18 | 250 | 2/24/2025 | |
| 1.4.15 | 663 | 11/17/2024 | |
| 1.4.14 | 2,002 | 8/7/2024 | |
| 1.4.13 | 1,113 | 7/21/2024 | |
| 1.4.11 | 793 | 7/15/2024 | |
| 1.4.10 | 714 | 7/13/2024 | |
| 1.4.8 | 392 | 7/8/2024 | |
| 1.4.3 | 326 | 6/27/2024 | |
| 1.4.1 | 374 | 5/21/2024 | |
| 1.3.44 | 288 | 5/14/2024 | |
| 1.3.43 | 367 | 4/26/2024 | |
| 1.3.40 | 596 | 4/11/2024 | |
| 1.3.39 | 326 | 4/9/2024 | |
| 1.3.38 | 458 | 3/23/2024 | |
| 1.3.36 | 295 | 3/20/2024 | |
| 1.3.35 | 188 | 3/19/2024 | |
| 1.3.33 | 239 | 3/18/2024 | |
| 1.3.28 | 272 | 3/18/2024 | |
| 1.3.27 | 271 | 3/17/2024 | |
| 1.3.24 | 537 | 3/12/2024 | |
| 1.3.23 | 311 | 3/12/2024 | |
| 1.3.21 | 305 | 3/11/2024 | |
| 1.3.20 | 332 | 3/11/2024 | |
| 1.3.18 | 296 | 3/10/2024 | |
| 1.3.17 | 347 | 2/26/2024 | |
| 1.3.16 | 408 | 2/26/2024 | |
| 1.3.13 | 319 | 2/25/2024 | |
| 1.3.8-beta | 1,508 | 2/12/2024 | |
| 1.3.6 | 366 | 1/26/2024 | |
| 1.3.5 | 303 | 1/21/2024 | |
| 1.3.1 | 402 | 1/17/2024 | |
| 1.2.24 | 295 | 1/14/2024 | |
| 1.2.18 | 288 | 1/5/2024 | |
| 1.2.16 | 293 | 1/5/2024 | |
| 1.2.13 | 268 | 1/4/2024 | |
| 1.2.12 | 264 | 1/4/2024 | |
| 1.2.8 | 267 | 1/3/2024 | |
| 1.2.3 | 492 | 11/20/2023 | |
| 1.2.1 | 286 | 11/13/2023 | |
| 1.1.2 | 7,213 | 8/8/2023 | |
| 1.0.14 | 357 | 8/4/2023 | |
| 1.0.12 | 33,764 | 8/3/2023 | |
| 1.0.11 | 330 | 8/2/2023 | |
| 1.0.5 | 254 | 7/31/2023 | |
| 1.0.3 | 241 | 7/29/2023 | |
| 1.0.2 | 255 | 7/29/2023 | |
| 1.0.1 | 1,503 | 7/27/2023 | |
| 0.1.39-alpha | 660 | 1/25/2023 | |
| 0.1.38-alpha | 353 | 1/19/2023 | |
| 0.1.37-alpha | 353 | 1/19/2023 | |
| 0.1.34-alpha | 361 | 1/18/2023 | |
| 0.1.33-alpha | 325 | 1/15/2023 | |
| 0.1.30-alpha | 410 | 11/21/2022 | |
| 0.1.22-alpha | 341 | 11/19/2022 | |
| 0.1.21-alpha | 342 | 11/19/2022 | |
| 0.1.19-alpha | 313 | 11/19/2022 | |
| 0.1.18-alpha | 344 | 11/18/2022 | |
| 0.1.17-alpha | 427 | 11/14/2022 | |
| 0.1.13-alpha | 330 | 11/13/2022 | |
| 0.1.12-alpha | 368 | 10/31/2022 | |
| 0.1.10-alpha | 344 | 10/28/2022 | |
| 0.1.9-alpha | 367 | 10/27/2022 | |
| 0.1.8-alpha | 392 | 10/27/2022 | |
| 0.1.5-alpha | 375 | 10/27/2022 | |
| 0.1.4-alpha | 371 | 10/27/2022 | |
| 0.1.3-alpha | 408 | 10/26/2022 | |
| 0.1.2-alpha | 425 | 10/25/2022 | |
| 0.1.1-alpha | 429 | 10/25/2022 |