Zomp.SyncMethodGenerator 0.1.38-alpha
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
Showing the top 20 packages that depend on Zomp.SyncMethodGenerator.
| Packages | Downloads |
|---|---|
|
z440.atl.core
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
|
3 |
|
z440.atl.core
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
|
2 |
.NET Standard 2.0
- No dependencies.
| Version | Downloads | Last updated |
|---|---|---|
| 2.0.8 | 2 | 04/07/2026 |
| 2.0.7 | 1 | 04/07/2026 |
| 2.0.5 | 2 | 04/07/2026 |
| 2.0.4 | 1 | 04/07/2026 |
| 2.0.3 | 2 | 04/07/2026 |
| 2.0.2 | 1 | 04/07/2026 |
| 2.0.1 | 2 | 04/07/2026 |
| 1.6.17 | 1 | 04/07/2026 |
| 1.6.16 | 1 | 04/07/2026 |
| 1.6.15 | 2 | 04/07/2026 |
| 1.6.14 | 1 | 04/07/2026 |
| 1.6.13 | 1 | 04/07/2026 |
| 1.6.12 | 1 | 04/07/2026 |
| 1.6.11 | 1 | 04/07/2026 |
| 1.6.10 | 1 | 04/07/2026 |
| 1.6.9 | 1 | 04/07/2026 |
| 1.6.8 | 2 | 04/07/2026 |
| 1.6.3 | 1 | 04/07/2026 |
| 1.6.2 | 1 | 04/07/2026 |
| 1.6.1 | 1 | 04/07/2026 |
| 1.5.3 | 2 | 04/07/2026 |
| 1.5.1 | 2 | 04/07/2026 |
| 1.4.38 | 3 | 04/07/2026 |
| 1.4.37 | 1 | 04/07/2026 |
| 1.4.35 | 3 | 04/07/2026 |
| 1.4.32 | 2 | 04/07/2026 |
| 1.4.30 | 1 | 04/07/2026 |
| 1.4.29 | 2 | 04/07/2026 |
| 1.4.28 | 1 | 04/07/2026 |
| 1.4.27 | 1 | 04/07/2026 |
| 1.4.26 | 2 | 04/07/2026 |
| 1.4.25 | 1 | 04/07/2026 |
| 1.4.20 | 1 | 04/07/2026 |
| 1.4.18 | 2 | 04/07/2026 |
| 1.4.15 | 2 | 04/07/2026 |
| 1.4.14 | 1 | 04/07/2026 |
| 1.4.13 | 1 | 04/07/2026 |
| 1.4.11 | 3 | 04/07/2026 |
| 1.4.10 | 2 | 04/07/2026 |
| 1.4.8 | 1 | 04/07/2026 |
| 1.4.3 | 1 | 04/07/2026 |
| 1.4.1 | 2 | 04/07/2026 |
| 1.3.44 | 1 | 04/07/2026 |
| 1.3.43 | 1 | 04/07/2026 |
| 1.3.40 | 2 | 04/07/2026 |
| 1.3.39 | 1 | 04/07/2026 |
| 1.3.38 | 3 | 04/07/2026 |
| 1.3.36 | 3 | 04/07/2026 |
| 1.3.35 | 2 | 04/07/2026 |
| 1.3.33 | 2 | 04/07/2026 |
| 1.3.28 | 1 | 04/07/2026 |
| 1.3.27 | 2 | 04/07/2026 |
| 1.3.24 | 1 | 04/07/2026 |
| 1.3.23 | 1 | 04/07/2026 |
| 1.3.21 | 1 | 04/07/2026 |
| 1.3.20 | 1 | 04/07/2026 |
| 1.3.18 | 2 | 04/07/2026 |
| 1.3.17 | 1 | 04/07/2026 |
| 1.3.16 | 2 | 04/07/2026 |
| 1.3.13 | 1 | 04/07/2026 |
| 1.3.8-beta | 1 | 04/07/2026 |
| 1.3.6 | 1 | 04/07/2026 |
| 1.3.5 | 1 | 04/07/2026 |
| 1.3.1 | 2 | 04/07/2026 |
| 1.2.24 | 1 | 04/07/2026 |
| 1.2.18 | 1 | 04/07/2026 |
| 1.2.16 | 1 | 04/07/2026 |
| 1.2.13 | 2 | 04/07/2026 |
| 1.2.12 | 3 | 04/07/2026 |
| 1.2.8 | 2 | 04/07/2026 |
| 1.2.3 | 1 | 04/07/2026 |
| 1.2.1 | 2 | 04/07/2026 |
| 1.1.2 | 1 | 04/07/2026 |
| 1.0.14 | 2 | 04/07/2026 |
| 1.0.12 | 2 | 04/07/2026 |
| 1.0.11 | 1 | 04/07/2026 |
| 1.0.5 | 1 | 04/07/2026 |
| 1.0.3 | 2 | 04/07/2026 |
| 1.0.2 | 1 | 04/07/2026 |
| 1.0.1 | 1 | 04/07/2026 |
| 0.1.39-alpha | 1 | 04/07/2026 |
| 0.1.38-alpha | 1 | 04/07/2026 |
| 0.1.37-alpha | 2 | 04/07/2026 |
| 0.1.34-alpha | 2 | 04/07/2026 |
| 0.1.33-alpha | 3 | 04/07/2026 |
| 0.1.30-alpha | 1 | 04/07/2026 |
| 0.1.22-alpha | 1 | 04/07/2026 |
| 0.1.21-alpha | 2 | 04/07/2026 |
| 0.1.19-alpha | 2 | 04/07/2026 |
| 0.1.18-alpha | 1 | 04/07/2026 |
| 0.1.17-alpha | 1 | 04/07/2026 |
| 0.1.13-alpha | 2 | 04/07/2026 |
| 0.1.12-alpha | 2 | 04/07/2026 |
| 0.1.10-alpha | 1 | 04/07/2026 |
| 0.1.9-alpha | 1 | 04/07/2026 |
| 0.1.8-alpha | 2 | 04/07/2026 |
| 0.1.5-alpha | 2 | 04/07/2026 |
| 0.1.4-alpha | 1 | 04/07/2026 |
| 0.1.3-alpha | 3 | 04/07/2026 |
| 0.1.2-alpha | 1 | 04/07/2026 |
| 0.1.1-alpha | 1 | 04/07/2026 |