Skip to content

Commit 20488ed

Browse files
committed
feat!: remove support for NETSTANDARD2.1 in prep for SqlClient v6
1 parent 4edc548 commit 20488ed

File tree

17 files changed

+5
-123
lines changed

17 files changed

+5
-123
lines changed

Diff for: Ark.Tools.ApplicationInsights.HostedService/Ex.cs

-8
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,6 @@ public static IHostBuilder AddApplicationInsightsForHostedService(this IHostBuil
6565
if (!string.IsNullOrWhiteSpace(cs))
6666
services.AddSingleton<ITelemetryProcessorFactory>(new SkipSqlDatabaseDependencyFilterFactory(cs!));
6767

68-
#if NET5_0
69-
services.Configure<SnapshotCollectorConfiguration>(o =>
70-
{
71-
});
72-
services.Configure<SnapshotCollectorConfiguration>(ctx.Configuration.GetSection(nameof(SnapshotCollectorConfiguration)));
73-
services.AddSnapshotCollector();
74-
#endif
75-
7668
});
7769
}
7870
}

Diff for: Ark.Tools.Core/Ark.Tools.Core.csproj

-4
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,5 @@
2828
<PackageReference Include="System.Reactive" Version="6.0.1" />
2929
</ItemGroup>
3030

31-
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.1'">
32-
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="[8.0.0,9)" />
33-
</ItemGroup>
34-
3531

3632
</Project>

Diff for: Ark.Tools.Core/EmailValidator.cs

-19
Original file line numberDiff line numberDiff line change
@@ -13,32 +13,13 @@ public static partial class EmailValidator
1313

1414
public static bool IsValid(string emailAddress)
1515
{
16-
#if NET6_0_OR_GREATER
1716
return MailAddress.TryCreate(emailAddress, out var _);
18-
#else
19-
try
20-
{
21-
var _ = new MailAddress(emailAddress);
22-
return true;
23-
}
24-
catch (FormatException)
25-
{
26-
return false;
27-
}
28-
#endif
2917
}
3018

3119
private const string _regexRFC5322 = @"^(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|""(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*"")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])$";
3220

33-
#if NET8_0_OR_GREATER
3421
[GeneratedRegex(_regexRFC5322, RegexOptions.CultureInvariant | RegexOptions.ExplicitCapture, 1000)]
3522
private static partial Regex _validEmailAddressRegEx();
36-
#else
37-
private static Regex _validEmailAddressRegEx()
38-
{
39-
return new Regex(_regexRFC5322, RegexOptions.Compiled | RegexOptions.CultureInvariant | RegexOptions.ExplicitCapture, TimeSpan.FromMilliseconds(1000));
40-
}
41-
#endif
4223

4324
}
4425
}

Diff for: Ark.Tools.Core/EnumerableExtensions.cs

-8
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@
99
using System.Linq;
1010
using System.Linq.Expressions;
1111
using System.Reflection;
12-
#if NET6_0_OR_GREATER
1312
using System.Runtime.CompilerServices;
14-
#endif
1513

1614
namespace Ark.Tools.Core
1715
{
@@ -33,16 +31,10 @@ static class QueryCompiler<T>
3331
private static readonly ConcurrentDictionary<string, Func<IQueryable<T>, IQueryable<T>>> _cache = new(StringComparer.Ordinal);
3432

3533
public static IQueryable<T> ApplyOrderBy(IQueryable<T> collection, string orderBy
36-
#if NET6_0_OR_GREATER
3734
, [CallerArgumentExpression(nameof(orderBy))] string? orderByParam = null
38-
#endif
3935
)
4036
{
41-
#if NET6_0_OR_GREATER
4237
var paramName = orderByParam;
43-
#else
44-
var paramName = nameof(orderBy);
45-
#endif
4638

4739
var apply = _cache.GetOrAdd(orderBy, k =>
4840
{

Diff for: Ark.Tools.FtpClient.SftpClient/SftpClientConnection.cs

-10
Original file line numberDiff line numberDiff line change
@@ -162,18 +162,8 @@ private Renci.SshNet.SftpClient _getSFtpClientWithCertificate()
162162
if (isKeyNull)
163163
throw new InvalidOperationException($"ClientCertificate has a null Key");
164164

165-
#if NET5_0_OR_GREATER
166165
var privateKeyPem = PemEncoding.Write($"{keyExchangeAlgorithm} PRIVATE KEY", privateKeyBytes);
167166
privateKeyPemString = new string(privateKeyPem);
168-
#else
169-
var builder = new StringBuilder();
170-
builder.Append("-----BEGIN ").Append(keyExchangeAlgorithm).AppendLine(" PRIVATE KEY-----");
171-
builder.AppendLine(
172-
Convert.ToBase64String(privateKeyBytes, Base64FormattingOptions.InsertLineBreaks));
173-
builder.Append("-----END ").Append(keyExchangeAlgorithm).AppendLine(" PRIVATE KEY-----");
174-
175-
privateKeyPemString = builder.ToString();
176-
#endif
177167

178168
var byteArray = Encoding.UTF8.GetBytes(privateKeyPemString);
179169

Diff for: Ark.Tools.Hosting/SingletonBackgroundService.cs

-6
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,7 @@ protected SingletonBackgroundService(IDistributedLockProvider distributedLockPro
5555
{
5656
ServiceName = serviceName ?? this.GetType().FullName!;
5757
#pragma warning disable CA5351 // Do Not Use Broken Cryptographic Algorithms | used only for identifier hash
58-
#if NET6_0_OR_GREATER
5958
var hash = MD5.HashData(Encoding.UTF8.GetBytes(ServiceName));
60-
#else
61-
using var md5 = MD5.Create();
62-
var hash = md5.ComputeHash(Encoding.UTF8.GetBytes(ServiceName));
63-
#endif
64-
6559
#pragma warning restore CA5351 // Do Not Use Broken Cryptographic Algorithms
6660
LockId = new Guid(hash);
6761

Diff for: Ark.Tools.Http/Ex.cs

-16
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,7 @@
77

88
using System;
99

10-
/* Unmerged change from project 'Ark.Tools.Http (netstandard2.1)'
11-
Before:
12-
using Ark.Tools.NewtonsoftJson;
13-
using System.Text.Json;
14-
After:
15-
using Ark.Tools.NewtonsoftJson;
16-
17-
using System.Text.Json;
18-
*/
1910
using System.Text.Json;
20-
#if !NET5_0_OR_GREATER
21-
using System.Net;
22-
#endif
2311

2412
namespace Ark.Tools.Http
2513
{
@@ -34,11 +22,7 @@ public static IFlurlClientBuilder ConfigureArkDefaults(this IFlurlClientBuilder
3422
.ConfigureInnerHandler(h =>
3523
{
3624
if (h is null) return; // can be null when using TestServer.CreateHandler() as inner handler
37-
#if NET5_0_OR_GREATER
3825
h.AutomaticDecompression = System.Net.DecompressionMethods.All;
39-
#else
40-
h.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
41-
#endif
4226
})
4327
.BeforeCall(c => c.Request.WithCookies(j))
4428
.WithAutoRedirect(true)

Diff for: Ark.Tools.NLog/Ark.Tools.NLog.csproj

-4
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,6 @@
3535
<PackageReference Include="System.Text.RegularExpressions" Version="4.3.1" />
3636
</ItemGroup>
3737

38-
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.1'">
39-
<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="8.0.1" />
40-
</ItemGroup>
41-
4238
<ItemGroup>
4339
<ProjectReference Include="..\Ark.Tools.ApplicationInsights\Ark.Tools.ApplicationInsights.csproj" />
4440
<ProjectReference Include="..\Ark.Tools.Core\Ark.Tools.Core.csproj" />

Diff for: Ark.Tools.Outbox/IOutboxProducer.cs

-2
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ namespace Ark.Tools.Outbox
1111
public interface IOutboxService
1212
{
1313
Task PublishAsync<T>(IOutboxContext ctx, T message, CancellationToken ctk = default) where T : class
14-
#if NETSTANDARD2_1
1514
=> PublishAsync(ctx, message, null, ctk)
16-
#endif
1715
;
1816

1917
Task PublishAsync<T>(IOutboxContext ctx, T message, IDictionary<string, string>? optionalHeaders = null, CancellationToken ctk = default) where T : class;

Diff for: Ark.Tools.ResourceWatcher.WorkerHost.Ftp/FtpWorkerHost.cs

-6
Original file line numberDiff line numberDiff line change
@@ -126,13 +126,7 @@ public async Task<IEnumerable<FtpMetadata>> GetMetadata(FtpFilter filter, Cancel
126126
[System.Diagnostics.CodeAnalysis.SuppressMessage("Security", "CA5351:Do Not Use Broken Cryptographic Algorithms", Justification = "Used only for checksum")]
127127
private string _computeChecksum(byte[] contents)
128128
{
129-
#if NET6_0_OR_GREATER
130129
return MD5.HashData(contents).ToHexString();
131-
#else
132-
using var hash = MD5.Create();
133-
var h = hash.ComputeHash(contents);
134-
return h.ToHexString();
135-
#endif
136130
}
137131

138132
}

Diff for: Ark.Tools.ResourceWatcher/Ark.Tools.ResourceWatcher.csproj

-4
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,6 @@
2222
<PackageReference Include="Microsoft.Extensions.DiagnosticAdapter" Version="3.1.32" />
2323
</ItemGroup>
2424

25-
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.1'">
26-
<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="8.0.1" />
27-
</ItemGroup>
28-
2925
<ItemGroup>
3026
<ProjectReference Include="..\Ark.Tools.Core\Ark.Tools.Core.csproj" />
3127
<ProjectReference Include="..\Ark.Tools.NLog\Ark.Tools.NLog.csproj" />

Diff for: Ark.Tools.Sql.SqlServer/SqlServerExtensions.cs

+1-4
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,9 @@ OFFSET @Skip ROWS FETCH NEXT @Limit ROWS ONLY
3838

3939
public static async Task<(IEnumerable<TReturn> data, int count)> ReadPagedAsync<TReturn>(this IDbConnection connection, CommandDefinition cmd)
4040
{
41-
#if NET6_0_OR_GREATER
4241
var r = await connection.QueryMultipleAsync(cmd).ConfigureAwait(false);
4342
await using var _ = r.ConfigureAwait(false);
44-
#else
45-
using var r = await connection.QueryMultipleAsync(cmd).ConfigureAwait(false);
46-
#endif
43+
4744
var retVal = await r.ReadAsync<TReturn>().ConfigureAwait(false);
4845
var count = await r.ReadFirstAsync<int>().ConfigureAwait(false);
4946

Diff for: Ark.Tools.SystemTextJson/Ark.Tools.SystemTextJson.csproj

-4
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,6 @@
2121
<PackageReference Include="Macross.Json.Extensions" Version="3.0.0" />
2222
</ItemGroup>
2323

24-
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.1'">
25-
<PackageReference Include="System.Text.Json" Version="8.0.5" />
26-
</ItemGroup>
27-
2824
<ItemGroup>
2925
<ProjectReference Include="..\Ark.Tools.Core\Ark.Tools.Core.csproj" />
3026
<ProjectReference Include="..\Ark.Tools.Nodatime.SystemTextJson\Ark.Tools.Nodatime.SystemTextJson.csproj" />

Diff for: Directory.Build.props

+1-14
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project>
22

33
<PropertyGroup>
4-
<TargetFrameworks>net8.0;netstandard2.1</TargetFrameworks>
4+
<TargetFrameworks>net8.0</TargetFrameworks>
55
<LangVersion>12.0</LangVersion>
66
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
77
<NoWarn>1591</NoWarn>
@@ -89,19 +89,6 @@
8989

9090
</ItemGroup>
9191

92-
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.1'">
93-
94-
<PackageReference Include="Nullable" Version="1.3.1">
95-
<PrivateAssets>all</PrivateAssets>
96-
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
97-
</PackageReference>
98-
99-
<PackageReference Include="IsExternalInit" Version="1.0.3">
100-
<PrivateAssets>all</PrivateAssets>
101-
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
102-
</PackageReference>
103-
</ItemGroup>
104-
10592
<Target Name="_ExactProjectReferencesVersion" AfterTargets="_GetProjectReferenceVersions">
10693
<ItemGroup>
10794
<_ProjectReferencesWithExactVersions Include="@(_ProjectReferencesWithVersions)">

Diff for: Directory.Packages.props.disable

-7
Original file line numberDiff line numberDiff line change
@@ -137,13 +137,6 @@
137137

138138
</ItemGroup>
139139

140-
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.1'">
141-
<PackageVersion Include="System.Diagnostics.DiagnosticSource" Version="[8.0.1,9)" />
142-
<PackageVersion Include="System.Text.Json" Version="[8.0.4,9)" />
143-
<GlobalPackageReference Include="IsExternalInit" Version="1.0.3" />
144-
<GlobalPackageReference Include="Nullable" Version="1.3.1" />
145-
</ItemGroup>
146-
147140
<ItemGroup>
148141
<GlobalPackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" />
149142
<GlobalPackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="8.0.0" />

Diff for: README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ To migrate:
4444

4545
.NET SDK has been updated to .NET 8. AspNetCore packages only target .NET8 (latest LTS).
4646

47-
### Deprecated .NET Framework, NetStandard 2.0
47+
### Deprecated .NET Framework, NetStandard
4848

49-
NetStandard 2.1 is the minimum version going forward.
49+
.NET8 is the minimum version going forward.
5050

5151
### Flurl v4 Migration Guide
5252

Diff for: Samples/TesterWorker/Worker.cs

+1-5
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,7 @@ protected override async Task ExecuteAsync(CancellationToken stoppingToken)
5252
d1.Telemetry.Success = false;
5353
}
5454

55-
var _ = await client.GetStringAsync("https://www.google.it"
56-
#if NET5_0_OR_GREATER
57-
, stoppingToken
58-
#endif
59-
);
55+
var _ = await client.GetStringAsync("https://www.google.it", stoppingToken);
6056

6157
using (var d1 = _telemetryClient.StartOperation<DependencyTelemetry>("DepException"))
6258
{

0 commit comments

Comments
 (0)