Skip to content

Commit a635f6d

Browse files
committed
cleanup a great many #if
1 parent b6dd818 commit a635f6d

39 files changed

Lines changed: 91 additions & 115 deletions

src/RESPite/Buffers/CycleBuffer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -727,7 +727,7 @@ public void Write(in ReadOnlySequence<byte> value)
727727
{
728728
if (value.IsSingleSegment)
729729
{
730-
#if NETCOREAPP3_0_OR_GREATER || NETSTANDARD2_1
730+
#if NET
731731
Write(value.FirstSpan);
732732
#else
733733
Write(value.First.Span);
@@ -742,7 +742,7 @@ static void WriteMultiSegment(ref CycleBuffer @this, in ReadOnlySequence<byte> v
742742
{
743743
foreach (var segment in value)
744744
{
745-
#if NETCOREAPP3_0_OR_GREATER || NETSTANDARD2_1
745+
#if NET
746746
@this.Write(value.FirstSpan);
747747
#else
748748
@this.Write(value.First.Span);

src/RESPite/Internal/Raw.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
using System.Runtime.InteropServices;
44
using System.Text;
55

6-
#if NETCOREAPP3_0_OR_GREATER
6+
#if NET
77
using System.Runtime.Intrinsics;
88
using System.Runtime.Intrinsics.X86;
99
#endif
@@ -95,7 +95,7 @@ public static uint Create32(ReadOnlySpan<byte> bytes, int length)
9595
public static uint ArrayPrefix_9_4 = Create32("*9\r\n"u8, 4);
9696
public static ulong ArrayPrefix_10_5 = Create64("*10\r\n"u8, 5);
9797

98-
#if NETCOREAPP3_0_OR_GREATER
98+
#if NET
9999
private static uint FirstAndLast(char first, char last)
100100
{
101101
Debug.Assert(first < 128 && last < 128, "ASCII please");

src/RESPite/Messages/RespFrameScanner.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ public OperationStatus TryRead(ref RespScanState state, in ReadOnlySequence<byte
125125
{
126126
if (!_pubsub & state.TotalBytes == 0 & data.IsSingleSegment)
127127
{
128-
#if NETCOREAPP3_1_OR_GREATER
128+
#if NET
129129
var status = TryFastRead(data.FirstSpan, ref state);
130130
#else
131131
var status = TryFastRead(data.First.Span, ref state);
@@ -154,7 +154,7 @@ public OperationStatus TryRead(ref RespScanState state, ReadOnlySpan<byte> data)
154154
{
155155
if (!_pubsub & state.TotalBytes == 0)
156156
{
157-
#if NETCOREAPP3_1_OR_GREATER
157+
#if NET
158158
var status = TryFastRead(data, ref state);
159159
#else
160160
var status = TryFastRead(data, ref state);

src/RESPite/Messages/RespReader.AggregateEnumerator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public AggregateEnumerator(scoped in RespReader reader)
4747
/// <inheritdoc cref="IEnumerator{T}.Current"/>
4848
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
4949
#if DEBUG
50-
#if NET6_0 || NET8_0
50+
#if NET8_0 // strictly net8; net10 and our polyfill have .Message
5151
[Experimental("SERDBG")]
5252
#else
5353
[Experimental("SERDBG", Message = $"Prefer {nameof(Value)}")]

src/RESPite/Messages/RespReader.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
using System.Text;
99
using RESPite.Internal;
1010

11-
#if NETCOREAPP3_0_OR_GREATER
11+
#if NET
1212
using System.Runtime.Intrinsics;
1313
using System.Runtime.Intrinsics.X86;
1414
#endif
@@ -797,7 +797,7 @@ internal readonly ReadOnlySpan<byte> Buffer(Span<byte> target)
797797
return simple;
798798
}
799799

800-
#if NET6_0_OR_GREATER
800+
#if NET
801801
return BufferSlow(ref Unsafe.NullRef<byte[]>(), target, usePool: false);
802802
#else
803803
byte[] pooled = [];
@@ -1019,7 +1019,7 @@ private void MovePastCurrent()
10191019

10201020
/// <inheritdoc cref="RespReader"/>
10211021
public RespReader(scoped in ReadOnlySequence<byte> value)
1022-
#if NETCOREAPP3_0_OR_GREATER
1022+
#if NET
10231023
: this(value.FirstSpan)
10241024
#else
10251025
: this(value.First.Span)
@@ -1046,7 +1046,7 @@ public unsafe bool TryReadNext()
10461046
{
10471047
MovePastCurrent();
10481048

1049-
#if NETCOREAPP3_0_OR_GREATER
1049+
#if NET
10501050
// check what we have available; don't worry about zero/fetching the next segment; this is only
10511051
// for SIMD lookup, and zero would only apply when data ends exactly on segment boundaries, which
10521052
// is incredible niche
@@ -1883,7 +1883,7 @@ public readonly bool ReadBoolean()
18831883
/// <typeparam name="T">The type of enum being parsed.</typeparam>
18841884
public readonly T ReadEnum<T>(T unknownValue = default) where T : struct, Enum
18851885
{
1886-
#if NET6_0_OR_GREATER
1886+
#if NET
18871887
return ParseChars(static (chars, state) => Enum.TryParse(chars, true, out T value) ? value : state, unknownValue);
18881888
#else
18891889
return Enum.TryParse(ReadString(), true, out T value) ? value : unknownValue;

src/RESPite/Shared/AsciiHash.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ internal static long ToUC(long hashCS)
199199

200200
// Something looks possibly lower-case; we can't just mask it off,
201201
// because there are other non-alpha characters in that range.
202-
#if NET || NETSTANDARD2_1_OR_GREATER
202+
#if NET
203203
ToUpper(MemoryMarshal.CreateSpan(ref Unsafe.As<long, byte>(ref hashCS), sizeof(long)));
204204
return hashCS;
205205
#else

src/RESPite/Shared/FrameworkShims.Encoding.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#if !(NETCOREAPP || NETSTANDARD2_1_OR_GREATER)
1+
#if !NET
22
// ReSharper disable once CheckNamespace
33
namespace System.Text
44
{

src/RESPite/Shared/FrameworkShims.Stream.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using System.Buffers;
22
using System.Runtime.InteropServices;
33

4-
#if !(NETCOREAPP || NETSTANDARD2_1_OR_GREATER)
4+
#if !NET
55
// ReSharper disable once CheckNamespace
66
namespace System.IO
77
{

src/RESPite/Shared/NullableHacks.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
namespace System.Diagnostics.CodeAnalysis
1010
{
11-
#if NETSTANDARD2_0 || NETCOREAPP2_0 || NETCOREAPP2_1 || NETCOREAPP2_2 || NET45 || NET451 || NET452 || NET46 || NET461 || NET462 || NET47 || NET471 || NET472 || NET48
11+
#if !NET
1212
/// <summary>Specifies that null is allowed as an input even if the corresponding type disallows it.</summary>
1313
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.Property, Inherited = false)]
1414
internal sealed class AllowNullAttribute : Attribute { }
@@ -85,9 +85,7 @@ internal sealed class DoesNotReturnIfAttribute : Attribute
8585
/// <summary>Gets the condition parameter value.</summary>
8686
public bool ParameterValue { get; }
8787
}
88-
#endif
8988

90-
#if NETSTANDARD2_0 || NETCOREAPP2_0 || NETCOREAPP2_1 || NETCOREAPP2_2 || NETCOREAPP3_0 || NETCOREAPP3_1 || NET45 || NET451 || NET452 || NET46 || NET461 || NET462 || NET47 || NET471 || NET472 || NET48
9189
/// <summary>Specifies that the method or property will ensure that the listed field and property members have not-null values.</summary>
9290
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)]
9391
internal sealed class MemberNotNullAttribute : Attribute

src/StackExchange.Redis/ChannelMessageQueue.cs

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@
44
using System.Threading;
55
using System.Threading.Channels;
66
using System.Threading.Tasks;
7-
#if NETCOREAPP3_1
8-
using System.Diagnostics;
9-
using System.Reflection;
10-
#endif
117

128
namespace StackExchange.Redis;
139

@@ -76,31 +72,12 @@ public ValueTask<ChannelMessage> ReadAsync(CancellationToken cancellationToken =
7672
/// <param name="count">The (approximate) count of items in the Channel.</param>
7773
public bool TryGetCount(out int count)
7874
{
79-
// This is specific to netcoreapp3.1, because full framework was out of band and the new prop is present
80-
#if NETCOREAPP3_1
81-
// get this using the reflection
82-
try
83-
{
84-
var prop =
85-
_queue.GetType().GetProperty("ItemsCountForDebugger", BindingFlags.Instance | BindingFlags.NonPublic);
86-
if (prop is not null)
87-
{
88-
count = (int)prop.GetValue(_queue)!;
89-
return true;
90-
}
91-
}
92-
catch (Exception ex)
93-
{
94-
Debug.WriteLine(ex.Message); // but ignore
95-
}
96-
#else
9775
var reader = _queue.Reader;
9876
if (reader.CanCount)
9977
{
10078
count = reader.Count;
10179
return true;
10280
}
103-
#endif
10481

10582
count = 0;
10683
return false;
@@ -334,7 +311,7 @@ internal async Task UnsubscribeAsyncImpl(Exception? error = null, CommandFlags f
334311
public Task UnsubscribeAsync(CommandFlags flags = CommandFlags.None) => UnsubscribeAsyncImpl(null, flags);
335312

336313
/// <inheritdoc cref="IAsyncEnumerable{ChannelMessage}.GetAsyncEnumerator(CancellationToken)"/>
337-
#if NETCOREAPP3_0_OR_GREATER
314+
#if NET
338315
public IAsyncEnumerator<ChannelMessage> GetAsyncEnumerator(CancellationToken cancellationToken = default)
339316
// ReSharper disable once MethodSupportsCancellation - provided in GetAsyncEnumerator
340317
=> _queue.Reader.ReadAllAsync().GetAsyncEnumerator(cancellationToken);

0 commit comments

Comments
 (0)