Skip to content

Commit 7d944ea

Browse files
authored
Abandon ValueTask (#611)
1 parent 87cd222 commit 7d944ea

35 files changed

+91
-89
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## vNext
44

5+
* Abandon ValueTask #611
56
* Fix Cache deleted on HttpTransport exception. (#610) @lucas-zimerman
67
* Add SentryScopeStateProcessor #603
78
* Add net5.0 TFM to libraries #606

benchmarks/Sentry.Benchmarks/BackgroundWorkerFlushBenchmarks.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public class BackgroundWorkerFlushBenchmarks
1212
{
1313
private class FakeTransport : ITransport
1414
{
15-
public ValueTask SendEnvelopeAsync(Envelope envelope, CancellationToken cancellationToken = default)
15+
public Task SendEnvelopeAsync(Envelope envelope, CancellationToken cancellationToken = default)
1616
=> default;
1717
}
1818

@@ -40,6 +40,6 @@ public void IterationSetup()
4040
public int Items;
4141

4242
[Benchmark(Description = "Enqueue event and FlushAsync")]
43-
public ValueTask FlushAsync_QueueDepthAsync() => _backgroundWorker.FlushAsync(TimeSpan.FromSeconds(10));
43+
public Task FlushAsync_QueueDepthAsync() => _backgroundWorker.FlushAsync(TimeSpan.FromSeconds(10));
4444
}
4545
}

src/Sentry.NLog/SentryTarget.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,6 @@ protected override void FlushAsync(AsyncContinuation asyncContinuation)
283283
{
284284
_ = HubAccessor()
285285
.FlushAsync(Options.FlushTimeout)
286-
.AsTask()
287286
.ContinueWith(t => asyncContinuation(t.Exception));
288287
}
289288

src/Sentry/Extensibility/DisabledHub.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public void ConfigureScope(Action<Scope> configureScope)
3333
/// <summary>
3434
/// No-Op.
3535
/// </summary>
36-
public ValueTask ConfigureScopeAsync(Func<Scope, ValueTask> configureScope) => default;
36+
public Task ConfigureScopeAsync(Func<Scope, Task> configureScope) => Task.CompletedTask;
3737

3838
/// <summary>
3939
/// No-Op.
@@ -67,7 +67,7 @@ public void BindClient(ISentryClient client)
6767
/// <summary>
6868
/// No-Op.
6969
/// </summary>
70-
public ValueTask FlushAsync(TimeSpan timeout) => default;
70+
public Task FlushAsync(TimeSpan timeout) => Task.CompletedTask;
7171

7272
/// <summary>
7373
/// No-Op.

src/Sentry/Extensibility/HubAdapter.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public void ConfigureScope(Action<Scope> configureScope)
4747
/// Forwards the call to <see cref="SentrySdk"/>.
4848
/// </summary>
4949
[DebuggerStepThrough]
50-
public ValueTask ConfigureScopeAsync(Func<Scope, ValueTask> configureScope)
50+
public Task ConfigureScopeAsync(Func<Scope, Task> configureScope)
5151
=> SentrySdk.ConfigureScopeAsync(configureScope);
5252

5353
/// <summary>
@@ -137,7 +137,7 @@ public SentryId CaptureEvent(SentryEvent evt, Scope? scope)
137137
/// </summary>
138138
[DebuggerStepThrough]
139139
[EditorBrowsable(EditorBrowsableState.Never)]
140-
public ValueTask FlushAsync(TimeSpan timeout)
140+
public Task FlushAsync(TimeSpan timeout)
141141
=> SentrySdk.FlushAsync(timeout);
142142

143143
/// <summary>

src/Sentry/Extensibility/IBackgroundWorker.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ internal interface IBackgroundWorker
2020
/// </summary>
2121
/// <param name="timeout">How long to wait for flush to finish.</param>
2222
/// <returns>A task to await for the flush operation.</returns>
23-
ValueTask FlushAsync(TimeSpan timeout);
23+
Task FlushAsync(TimeSpan timeout);
2424

2525
/// <summary>
2626
/// Current count of items queued up.

src/Sentry/Extensibility/ITransport.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ internal interface ITransport
1414
/// </summary>
1515
/// <param name="envelope">The envelope to send to Sentry.</param>
1616
/// <param name="cancellationToken">The cancellation token.</param>
17-
ValueTask SendEnvelopeAsync(Envelope envelope, CancellationToken cancellationToken = default);
17+
Task SendEnvelopeAsync(Envelope envelope, CancellationToken cancellationToken = default);
1818
}
1919
}

src/Sentry/ISentryClient.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,6 @@ public interface ISentryClient
3333
/// </summary>
3434
/// <param name="timeout">How long to wait for flush to finish.</param>
3535
/// <returns>A task to await for the flush operation.</returns>
36-
ValueTask FlushAsync(TimeSpan timeout);
36+
Task FlushAsync(TimeSpan timeout);
3737
}
3838
}

src/Sentry/ISentryScopeManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public interface ISentryScopeManager
2323
/// </summary>
2424
/// <param name="configureScope">The configure scope.</param>
2525
/// <returns>A task that completes when the callback is done or a completed task if the SDK is disabled.</returns>
26-
ValueTask ConfigureScopeAsync(Func<Scope, ValueTask> configureScope);
26+
Task ConfigureScopeAsync(Func<Scope, Task> configureScope);
2727

2828
/// <summary>
2929
/// Binds the client to the current scope.

src/Sentry/Internal/BackgroundWorker.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public bool EnqueueEnvelope(Envelope envelope)
6868
return true;
6969
}
7070

71-
private async ValueTask WorkerAsync()
71+
private async Task WorkerAsync()
7272
{
7373
var cancellation = _shutdownSource.Token;
7474

@@ -179,7 +179,7 @@ private async ValueTask WorkerAsync()
179179
}
180180
}
181181

182-
public async ValueTask FlushAsync(TimeSpan timeout)
182+
public async Task FlushAsync(TimeSpan timeout)
183183
{
184184
if (_disposed)
185185
{

0 commit comments

Comments
 (0)