Skip to content

Commit be504a7

Browse files
committed
Remove directives
1 parent 7b1d77b commit be504a7

File tree

16 files changed

+2
-186
lines changed

16 files changed

+2
-186
lines changed

src/Directory.Build.props

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,4 @@
3636
<None Include="../../.neo/README.md" Pack="true" Visible="false" PackagePath=""/>
3737
</ItemGroup>
3838

39-
<ItemGroup>
40-
<Compile Include="$(MSBuildThisFileDirectory)IsExternalInit.cs" Visible="false" />
41-
</ItemGroup>
42-
4339
</Project>

src/IsExternalInit.cs

Lines changed: 0 additions & 28 deletions
This file was deleted.

src/Neo.Extensions/BigIntegerExtensions.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,7 @@ public static int GetLowestSetBit(this BigInteger value)
4040
{
4141
if (value.Sign == 0) return -1; // special case for zero. TrailingZeroCount returns 32 in standard library.
4242

43-
#if NET7_0_OR_GREATER
4443
return (int)BigInteger.TrailingZeroCount(value);
45-
#else
46-
return TrailingZeroCount(value.ToByteArray());
47-
#endif
4844
}
4945

5046
/// <summary>
@@ -179,11 +175,7 @@ internal static BigInteger GetLowPart(this BigInteger value, int bitCount)
179175
[MethodImpl(MethodImplOptions.AggressiveInlining)]
180176
public static long GetBitLength(this BigInteger value)
181177
{
182-
#if NET5_0_OR_GREATER
183178
return value.GetBitLength();
184-
#else
185-
return BitLength(value);
186-
#endif
187179
}
188180

189181
/// <summary>

src/Neo.Extensions/ByteExtensions.cs

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -57,19 +57,7 @@ public static string ToHexString(this byte[]? value)
5757
if (value is null)
5858
throw new ArgumentNullException(nameof(value));
5959

60-
#if NET9_0_OR_GREATER
6160
return Convert.ToHexStringLower(value);
62-
#else
63-
return string.Create(value.Length * 2, value, (span, bytes) =>
64-
{
65-
for (var i = 0; i < bytes.Length; i++)
66-
{
67-
var b = bytes[i];
68-
span[i * 2] = s_hexChars[b >> 4];
69-
span[i * 2 + 1] = s_hexChars[b & 0xF];
70-
}
71-
});
72-
#endif
7361
}
7462

7563
/// <summary>
@@ -107,19 +95,7 @@ public static string ToHexString(this byte[]? value, bool reverse = false)
10795
[MethodImpl(MethodImplOptions.AggressiveInlining)]
10896
public static string ToHexString(this ReadOnlySpan<byte> value)
10997
{
110-
#if NET9_0_OR_GREATER
11198
return Convert.ToHexStringLower(value);
112-
#else
113-
// string.Create with ReadOnlySpan<char> not supported in NET5 or lower
114-
var sb = new StringBuilder(value.Length * 2);
115-
for (var i = 0; i < value.Length; i++)
116-
{
117-
var b = value[i];
118-
sb.Append(s_hexChars[b >> 4]);
119-
sb.Append(s_hexChars[b & 0xF]);
120-
}
121-
return sb.ToString();
122-
#endif
12399
}
124100

125101
/// <summary>
@@ -138,15 +114,7 @@ public static string ToHexString(this ReadOnlySpan<byte> value)
138114
[MethodImpl(MethodImplOptions.AggressiveInlining)]
139115
public static bool NotZero(this ReadOnlySpan<byte> x)
140116
{
141-
#if NET7_0_OR_GREATER
142117
return x.IndexOfAnyExcept((byte)0) >= 0;
143-
#else
144-
for (var i = 0; i < x.Length; i++)
145-
{
146-
if (x[i] != 0) return true;
147-
}
148-
return false;
149-
#endif
150118
}
151119
}
152120
}

src/Neo.Extensions/StringExtensions.cs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@
1414
using System.Runtime.CompilerServices;
1515
using System.Text;
1616

17-
#if !NET9_0_OR_GREATER
18-
using System.Globalization;
19-
#endif
20-
2117
namespace Neo.Extensions
2218
{
2319
public static class StringExtensions
@@ -145,18 +141,7 @@ public static byte[] HexToBytesReversed(this ReadOnlySpan<char> value)
145141
/// <returns>The converted byte array.</returns>
146142
public static byte[] HexToBytes(this ReadOnlySpan<char> value)
147143
{
148-
#if !NET9_0_OR_GREATER
149-
if (value.IsEmpty)
150-
return [];
151-
if (value.Length % 2 == 1)
152-
throw new FormatException($"value.Length({value.Length}) not multiple of 2");
153-
var result = new byte[value.Length / 2];
154-
for (var i = 0; i < result.Length; i++)
155-
result[i] = byte.Parse(value.Slice(i * 2, 2), NumberStyles.AllowHexSpecifier);
156-
return result;
157-
#else
158144
return Convert.FromHexString(value);
159-
#endif
160145
}
161146

162147
/// <summary>

src/Neo.IO/Caching/Cache.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,7 @@ public void Unlink()
7474
}
7575

7676
protected CacheItem Head { get; } = new(default!, default!);
77-
78-
#if NET9_0_OR_GREATER
7977
private readonly Lock _lock = new();
80-
#else
81-
private readonly object _lock = new();
82-
#endif
8378

8479
private readonly Dictionary<TKey, CacheItem> _innerDictionary = new(comparer);
8580

src/Neo.VM/ReferenceEqualityComparer.cs

Lines changed: 0 additions & 30 deletions
This file was deleted.

src/Neo.VM/Types/Buffer.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,7 @@ public override StackItem ConvertTo(StackItemType type)
8282
throw new InvalidCastException();
8383
return new BigInteger(InnerBuffer.Span);
8484
case StackItemType.ByteString:
85-
#if NET5_0_OR_GREATER
8685
var clone = GC.AllocateUninitializedArray<byte>(InnerBuffer.Length);
87-
#else
88-
var clone = new byte[InnerBuffer.Length];
89-
#endif
9086
InnerBuffer.CopyTo(clone);
9187
return clone;
9288
default:

src/Neo/BigDecimal.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,8 @@ public BigDecimal(BigInteger value, byte decimals)
5757
/// <param name="value">The value of the number.</param>
5858
public BigDecimal(decimal value)
5959
{
60-
#if NET5_0_OR_GREATER
6160
Span<int> span = stackalloc int[4];
6261
decimal.GetBits(value, span);
63-
#else
64-
var span = decimal.GetBits(value);
65-
#endif
6662
var buffer = MemoryMarshal.AsBytes((ReadOnlySpan<int>)span);
6763
_value = new BigInteger(buffer[..12], isUnsigned: true);
6864

@@ -77,12 +73,8 @@ public BigDecimal(decimal value)
7773
/// <param name="decimals">The number of decimal places for this number.</param>
7874
public BigDecimal(decimal value, byte decimals)
7975
{
80-
#if NET5_0_OR_GREATER
8176
Span<int> span = stackalloc int[4];
8277
decimal.GetBits(value, span);
83-
#else
84-
var span = decimal.GetBits(value);
85-
#endif
8678
var buffer = MemoryMarshal.AsBytes((ReadOnlySpan<int>)span);
8779
_value = new BigInteger(buffer[..12], isUnsigned: true);
8880
if (buffer[14] > decimals)

src/Neo/Cryptography/Helper.cs

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,7 @@ public static byte[] Murmur128(this ReadOnlySpan<byte> value, uint seed)
107107
[MethodImpl(MethodImplOptions.AggressiveInlining)]
108108
public static byte[] Sha256(this byte[] value)
109109
{
110-
#if !NET5_0_OR_GREATER
111-
using var sha256 = SHA256.Create();
112-
return sha256.ComputeHash(value);
113-
#else
114110
return SHA256.HashData(value);
115-
#endif
116111
}
117112

118113
/// <summary>
@@ -123,12 +118,7 @@ public static byte[] Sha256(this byte[] value)
123118
[MethodImpl(MethodImplOptions.AggressiveInlining)]
124119
public static byte[] Sha512(this byte[] value)
125120
{
126-
#if !NET5_0_OR_GREATER
127-
using var sha512 = SHA512.Create();
128-
return sha512.ComputeHash(value);
129-
#else
130121
return SHA512.HashData(value);
131-
#endif
132122
}
133123

134124
/// <summary>
@@ -141,12 +131,7 @@ public static byte[] Sha512(this byte[] value)
141131
[MethodImpl(MethodImplOptions.AggressiveInlining)]
142132
public static byte[] Sha256(this byte[] value, int offset, int count)
143133
{
144-
#if !NET5_0_OR_GREATER
145-
using var sha256 = SHA256.Create();
146-
return sha256.ComputeHash(value, offset, count);
147-
#else
148134
return SHA256.HashData(value.AsSpan(offset, count));
149-
#endif
150135
}
151136

152137
/// <summary>
@@ -159,12 +144,7 @@ public static byte[] Sha256(this byte[] value, int offset, int count)
159144
[MethodImpl(MethodImplOptions.AggressiveInlining)]
160145
public static byte[] Sha512(this byte[] value, int offset, int count)
161146
{
162-
#if !NET5_0_OR_GREATER
163-
using var sha512 = SHA512.Create();
164-
return sha512.ComputeHash(value, offset, count);
165-
#else
166147
return SHA512.HashData(value.AsSpan(offset, count));
167-
#endif
168148
}
169149

170150
/// <summary>
@@ -176,12 +156,7 @@ public static byte[] Sha512(this byte[] value, int offset, int count)
176156
public static byte[] Sha256(this ReadOnlySpan<byte> value)
177157
{
178158
var buffer = new byte[32];
179-
#if !NET5_0_OR_GREATER
180-
using var sha256 = SHA256.Create();
181-
sha256.TryComputeHash(value, buffer, out _);
182-
#else
183159
SHA256.HashData(value, buffer);
184-
#endif
185160
return buffer;
186161
}
187162

@@ -194,12 +169,7 @@ public static byte[] Sha256(this ReadOnlySpan<byte> value)
194169
public static byte[] Sha512(this ReadOnlySpan<byte> value)
195170
{
196171
var buffer = new byte[64];
197-
#if !NET5_0_OR_GREATER
198-
using var sha512 = SHA512.Create();
199-
sha512.TryComputeHash(value, buffer, out _);
200-
#else
201172
SHA512.HashData(value, buffer);
202-
#endif
203173
return buffer;
204174
}
205175

0 commit comments

Comments
 (0)