Skip to content

Commit 9864512

Browse files
committed
refactor: cleanup symbol condition
1 parent e6a55d1 commit 9864512

18 files changed

+30
-31
lines changed

src/WeihanLi.Common/Event/EventBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ protected EventBase(string eventId)
4242

4343
// https://www.newtonsoft.com/json/help/html/JsonConstructorAttribute.htm
4444
[JsonConstructor]
45-
#if NET6_0_OR_GREATER
45+
#if NET
4646
[System.Text.Json.Serialization.JsonConstructor]
4747
#endif
4848
protected EventBase(string eventId, DateTimeOffset eventAt)

src/WeihanLi.Common/Extensions/CollectionExtension.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ public static IEnumerable<T> GetRandomList<T>(this IList<T> list)
234234
;
235235
}
236236

237-
#if NET6_0_OR_GREATER
237+
#if NET
238238
// https://github.com/more-itertools/more-itertools/blob/master/more_itertools/more.py#L3149
239239
//def set_partitions_helper(L, k):
240240
//n = len(L)

src/WeihanLi.Common/Extensions/CoreExtension.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ public static string ToBase64String(this byte[] inArray, int offset, int length,
136136
return Convert.ToBase64String(inArray, offset, length, options);
137137
}
138138

139-
#if NET5_0_OR_GREATER
139+
#if NET
140140
public static string ToHexString(this ReadOnlySpan<byte> bytes, bool isLowerCase = false)
141141
{
142142
#if NET9_0_OR_GREATER
@@ -1616,7 +1616,7 @@ public static byte[] HexStringToBytes(this string hexString)
16161616
if (string.IsNullOrEmpty(hexString))
16171617
return [];
16181618

1619-
#if NET6_0_OR_GREATER
1619+
#if NET
16201620
return Convert.FromHexString(hexString);
16211621
#else
16221622
var charArray = hexString.ToCharArray();

src/WeihanLi.Common/Extensions/DataExtension.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,7 @@ private static string GetParameterName(string originName)
611611
[typeof(TimeSpan)] = DbType.Time,
612612
[typeof(byte[])] = DbType.Binary,
613613
[typeof(object)] = DbType.Object,
614-
#if NET6_0_OR_GREATER
614+
#if NET
615615
[typeof(DateOnly)] = DbType.Date,
616616
[typeof(TimeOnly)] = DbType.Time,
617617
#endif

src/WeihanLi.Common/Extensions/HttpClientExtension.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public static async Task<TResponse?> ReadJsonResponseAsync<TResponse>
8989
{
9090
Guard.NotNull(response);
9191
responseAction?.Invoke(response);
92-
#if NET6_0_OR_GREATER
92+
#if NET
9393
var responseText = await response.Content.ReadAsStringAsync(cancellationToken);
9494
#else
9595
var responseText = await response.Content.ReadAsStringAsync();
@@ -109,15 +109,15 @@ public static async Task<TResponse?> ReadJsonResponseAsync<TResponse>
109109
requestAction?.Invoke(requestMessage);
110110
using var response = await httpClient.SendAsync(requestMessage, cancellationToken);
111111
responseAction?.Invoke(response);
112-
#if NET6_0_OR_GREATER
112+
#if NET
113113
var responseText = await response.Content.ReadAsStringAsync(cancellationToken);
114114
#else
115115
var responseText = await response.Content.ReadAsStringAsync();
116116
#endif
117117
return JsonConvert.DeserializeObject<TResponse>(responseText);
118118
}
119119

120-
#if NET6_0_OR_GREATER
120+
#if NET
121121
/// <summary>
122122
/// PatchAsJsonAsync
123123
/// </summary>

src/WeihanLi.Common/Extensions/ProcessExtension.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ public static ProcessStartInfo WithEnv(this ProcessStartInfo processStartInfo, s
1919
return processStartInfo;
2020
}
2121

22-
#if NET6_0_OR_GREATER
23-
#else
22+
#if NETSTANDARD
2423
public static Task WaitForExitAsync(this Process process, CancellationToken cancellationToken = default)
2524
{
2625
Guard.NotNull(process);
@@ -285,7 +284,7 @@ public static async Task<Process> ExecuteProcessAsync(this ProcessStartInfo psi,
285284
public static bool TryKill(this Process process, bool entireProcessTree = true)
286285
{
287286
return
288-
#if NET6_0_OR_GREATER
287+
#if NET
289288
process.Try(x => x.Kill(entireProcessTree))
290289
#else
291290
process.Try(x => x.Kill())

src/WeihanLi.Common/Extensions/TaskExtension.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public static Task AsTask(this CancellationToken cancellationToken)
2828

2929
public static Task WhenAllSafely(this IEnumerable<Task> tasks, Action<Exception>? onException = null) => Task.WhenAll(tasks.Select(async t =>
3030
{
31-
#if NET8_0_OR_GREATER
31+
#if NET
3232
await t.ConfigureAwait(ConfigureAwaitOptions.SuppressThrowing);
3333
#else
3434
try

src/WeihanLi.Common/Extensions/TypeExtension.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public static class TypeExtension
3434
typeof(char),
3535
typeof(string),// IsPrimitive:False
3636

37-
#if NET6_0_OR_GREATER
37+
#if NET
3838
typeof(DateOnly),
3939
typeof(TimeOnly),
4040
#endif

src/WeihanLi.Common/Guard.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public static T NotNull<T>([NotNull] T? t,
1010
[CallerArgumentExpression(nameof(t))]
1111
string? paramName = default)
1212
{
13-
#if NET6_0_OR_GREATER
13+
#if NET
1414
ArgumentNullException.ThrowIfNull(t, paramName);
1515
#else
1616
if (t is null)
@@ -26,7 +26,7 @@ public static string NotNullOrEmpty([NotNull] string? str,
2626
[CallerArgumentExpression(nameof(str))]
2727
string? paramName = null)
2828
{
29-
#if NET7_0_OR_GREATER
29+
#if NET
3030
ArgumentException.ThrowIfNullOrEmpty(str, paramName);
3131
#else
3232
NotNull(str, paramName);
@@ -42,7 +42,7 @@ public static string NotNullOrEmpty([NotNull] string? str,
4242
public static string NotNullOrWhiteSpace([NotNull] string? str,
4343
[CallerArgumentExpression(nameof(str))] string? paramName = null)
4444
{
45-
#if NET8_0_OR_GREATER
45+
#if NET
4646
ArgumentException.ThrowIfNullOrWhiteSpace(str, paramName);
4747
#else
4848
NotNull(str, paramName);

src/WeihanLi.Common/Helpers/ApplicationHelper.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public static LibraryInfo GetLibraryInfo(Assembly assembly)
7575
if (!string.IsNullOrEmpty(environmentOverride) && Directory.Exists(environmentOverride))
7676
{
7777
var execFileName =
78-
#if NET6_0_OR_GREATER
78+
#if NET
7979
OperatingSystem.IsWindows()
8080
#else
8181
RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
@@ -105,7 +105,7 @@ public static string GetDotnetDirectory()
105105

106106
if (string.IsNullOrWhiteSpace(dotnetExe))
107107
{
108-
#if NET6_0_OR_GREATER
108+
#if NET
109109
dotnetExe = Environment.ProcessPath;
110110
#else
111111
dotnetExe = System.Diagnostics.Process.GetCurrentProcess().MainModule?.FileName;
@@ -141,15 +141,15 @@ public static string GetDotnetDirectory()
141141
private static RuntimeInfo GetRuntimeInfo()
142142
{
143143
var libInfo = GetLibraryInfo(typeof(object).Assembly);
144-
#if NET6_0_OR_GREATER
144+
#if NET
145145
#else
146146
var currentProcess = System.Diagnostics.Process.GetCurrentProcess();
147147
#endif
148148
var runtimeInfo = new RuntimeInfo()
149149
{
150150
Version = Environment.Version.ToString(),
151151

152-
#if NET6_0_OR_GREATER
152+
#if NET
153153
ProcessId = Environment.ProcessId,
154154
ProcessPath = Environment.ProcessPath ?? string.Empty,
155155
RuntimeIdentifier = RuntimeInformation.RuntimeIdentifier,
@@ -257,7 +257,7 @@ public class RuntimeInfo
257257
public required string MachineName { get; init; }
258258
public required string UserName { get; init; }
259259

260-
#if NET6_0_OR_GREATER
260+
#if NET
261261
public required string RuntimeIdentifier { get; init; }
262262
#endif
263263

0 commit comments

Comments
 (0)