Skip to content

Commit 0ee60ea

Browse files
committed
Revert "Add where T : allows ref struct anti-constraints."
This reverts commit 2d46b79.
1 parent 2d46b79 commit 0ee60ea

2 files changed

Lines changed: 11 additions & 29 deletions

File tree

src/BenchmarkDotNet/Engines/DeadCodeEliminationHelper.cs

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,15 @@ public static class DeadCodeEliminationHelper
1111
/// </summary>
1212
[MethodImpl(MethodImplOptions.NoInlining)]
1313
[UsedImplicitly] // Used in generated benchmarks
14-
public static void KeepAliveWithoutBoxing<T>(T value)
15-
#if NET9_0_OR_GREATER
16-
where T : allows ref struct
17-
#endif
18-
{ }
14+
public static void KeepAliveWithoutBoxing<T>(T value) { }
1915

2016
/// <summary>
2117
/// This method can't get inlined, so any value send to it
2218
/// will not get eliminated by the dead code elimination
2319
/// </summary>
2420
[MethodImpl(MethodImplOptions.NoInlining)]
2521
[UsedImplicitly] // Used in generated benchmarks
26-
public static void KeepAliveWithoutBoxing<T>(ref T value)
27-
#if NET9_0_OR_GREATER
28-
where T : allows ref struct
29-
#endif
30-
{ }
22+
public static void KeepAliveWithoutBoxing<T>(ref T value) { }
3123

3224
/// <summary>
3325
/// This method can't get inlined, so any value send to it
@@ -36,10 +28,6 @@ public static void KeepAliveWithoutBoxing<T>(ref T value)
3628
/// </summary>
3729
[MethodImpl(MethodImplOptions.NoInlining)]
3830
[UsedImplicitly] // Used in generated benchmarks
39-
public static void KeepAliveWithoutBoxingReadonly<T>(in T value)
40-
#if NET9_0_OR_GREATER
41-
where T : allows ref struct
42-
#endif
43-
{ }
31+
public static void KeepAliveWithoutBoxingReadonly<T>(in T value) { }
4432
}
4533
}

src/BenchmarkDotNet/Toolchains/InProcess/NoEmit/BenchmarkActionImpl.cs

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -544,21 +544,18 @@ public override void Cleanup()
544544
}
545545

546546
[AggressivelyOptimizeMethods]
547-
public class BenchmarkActionAsyncEnumerable<T> : BenchmarkActionBase
548-
#if NET9_0_OR_GREATER
549-
where T : allows ref struct
550-
#endif
547+
public class BenchmarkActionConfiguredCancelableAsyncEnumerable<T> : BenchmarkActionBase
551548
{
552-
private readonly Func<IAsyncEnumerable<T>> callback;
549+
private readonly Func<ConfiguredCancelableAsyncEnumerable<T>> callback;
553550
private readonly int unrollFactor;
554551
private WorkloadValueTaskSource workloadValueTaskSource = null!;
555552
private IClock? clock;
556553
private long invokeCount;
557554

558555
[SetsRequiredMembers]
559-
public BenchmarkActionAsyncEnumerable(object? instance, MethodInfo method, int unrollFactor)
556+
public BenchmarkActionConfiguredCancelableAsyncEnumerable(object? instance, MethodInfo method, int unrollFactor)
560557
{
561-
callback = CreateWorkload<Func<IAsyncEnumerable<T>>>(instance, method);
558+
callback = CreateWorkload<Func<ConfiguredCancelableAsyncEnumerable<T>>>(instance, method);
562559
this.unrollFactor = unrollFactor;
563560
InvokeSingle = InvokeOnce;
564561
InvokeUnroll = WorkloadActionUnroll;
@@ -626,21 +623,18 @@ public override void Cleanup()
626623
}
627624

628625
[AggressivelyOptimizeMethods]
629-
public class BenchmarkActionConfiguredCancelableAsyncEnumerable<T> : BenchmarkActionBase
630-
#if NET10_0_OR_GREATER
631-
where T : allows ref struct
632-
#endif
626+
public class BenchmarkActionAsyncEnumerable<T> : BenchmarkActionBase
633627
{
634-
private readonly Func<ConfiguredCancelableAsyncEnumerable<T>> callback;
628+
private readonly Func<IAsyncEnumerable<T>> callback;
635629
private readonly int unrollFactor;
636630
private WorkloadValueTaskSource workloadValueTaskSource = null!;
637631
private IClock? clock;
638632
private long invokeCount;
639633

640634
[SetsRequiredMembers]
641-
public BenchmarkActionConfiguredCancelableAsyncEnumerable(object? instance, MethodInfo method, int unrollFactor)
635+
public BenchmarkActionAsyncEnumerable(object? instance, MethodInfo method, int unrollFactor)
642636
{
643-
callback = CreateWorkload<Func<ConfiguredCancelableAsyncEnumerable<T>>>(instance, method);
637+
callback = CreateWorkload<Func<IAsyncEnumerable<T>>>(instance, method);
644638
this.unrollFactor = unrollFactor;
645639
InvokeSingle = InvokeOnce;
646640
InvokeUnroll = WorkloadActionUnroll;

0 commit comments

Comments
 (0)