You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+13-1Lines changed: 13 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -62,7 +62,7 @@ A list of changes applied to the new synchronized method:
62
62
\*\*`Memory` and `ReadOnlyMemory` is preserved in sync methods if it is a type argument of a collection. This is due to a compiler limitation which states that a `ref struct` can't be the element type of an array.
-[CancellationToken](https://learn.microsoft.com/en-us/dotnet/api/system.threading.cancellationtoken), unless the `PreserveCancellationToken` property is set to `true`.
66
66
-[IProgress\<T>](https://learn.microsoft.com/en-us/dotnet/api/system.iprogress-1), unless the `PreserveProgress` property is set to `true`.
67
67
- Invocation changes
68
68
- Remove `ConfigureAwait` from [Tasks](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task.configureawait) and [Asynchronous Enumerations](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.taskasyncenumerableextensions.configureawait)
@@ -106,6 +106,18 @@ public async Task MethodAsync(IProgress<double> progress)
106
106
}
107
107
```
108
108
109
+
#### PreserveCancellationToken
110
+
111
+
By default, this source generator removes `CancellationToken` parameters from async methods. To preserve them, use the `PreserveCancellationToken` option.
Copy file name to clipboardExpand all lines: src/Zomp.SyncMethodGenerator/SourceGenerationHelper.cs
+5Lines changed: 5 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -36,6 +36,11 @@ internal class {{SyncMethodSourceGenerator.CreateSyncVersionAttribute}} : System
36
36
/// Gets or sets a value indicating whether <see cref="System.IProgress{T}"/> parameters will be preserved in the generated code. False by default.
37
37
/// </summary>
38
38
public bool {{SyncMethodSourceGenerator.PreserveProgress}} { get; set; }
39
+
40
+
/// <summary>
41
+
/// Gets or sets a value indicating whether <see cref="System.Threading.CancellationToken"/> parameters will be preserved in the generated code. False by default.
42
+
/// </summary>
43
+
public bool {{SyncMethodSourceGenerator.PreserveCancellationToken}} { get; set; }
0 commit comments