Skip to content

Commit

Permalink
Upgrade to .NET 8 (#191)
Browse files Browse the repository at this point in the history
- Upgrade to .NET 8
- Drop support for .NET 3.1
- MediatR and ProblemDetails projects will have second round, because they depend on Kros.AspNetCore.
- MassTransit project has some obsolete warnings. It will need deeper refactoring to use new MassTransit library.
  • Loading branch information
satano authored Dec 20, 2023
1 parent 8240c93 commit f50a3a7
Show file tree
Hide file tree
Showing 33 changed files with 126 additions and 204 deletions.
64 changes: 27 additions & 37 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -1,39 +1,29 @@
<Project>
<ItemGroup>
<PackageVersion Include="Azure.Extensions.AspNetCore.Configuration.Secrets" Version="1.2.2" />
<PackageVersion Include="AspNetCore.HealthChecks.Uris" Version="6.0.3" />
<PackageVersion Include="Azure.Identity" Version="1.8.0" />
<PackageVersion Include="coverlet.collector" Version="3.2.0" />
<PackageVersion Include="FluentAssertions" Version="6.8.0" />
<PackageVersion Include="FluentValidation" Version="11.4.0" />
<PackageVersion Include="Hellang.Middleware.ProblemDetails" Version="6.5.1" />
<PackageVersion Include="IdentityServer4.AccessTokenValidation" Version="3.0.1" />
<PackageVersion Include="Kros.AspNetCore" Version="3.7.0" />
<PackageVersion Include="Kros.Utils" Version="2.0.0" />
<PackageVersion Include="MassTransit.AspNetCore" Version="7.1.8" />
<PackageVersion Include="MassTransit.Azure.ServiceBus.Core" Version="7.1.8" />
<PackageVersion Include="MediatR.Extensions.Microsoft.DependencyInjection" Version="11.0.0" />
<PackageVersion Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.21.0" />
<PackageVersion Include="Microsoft.AspNetCore.JsonPatch" Version="6.0.11" />
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.3" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.4.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.4.0" />
<PackageVersion Include="Microsoft.Extensions.Caching.Abstractions" Version="6.0.0" />
<PackageVersion Include="Microsoft.Extensions.Caching.Memory" Version="6.0.1" />
<PackageVersion Include="Microsoft.Extensions.Configuration.Abstractions" Version="6.0.0" />
<PackageVersion Include="Microsoft.Extensions.Configuration.AzureAppConfiguration" Version="5.2.0" />
<PackageVersion Include="Microsoft.Extensions.Configuration.Binder" Version="6.0.0" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="6.0.1" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="6.0.0" />
<PackageVersion Include="Microsoft.Extensions.Diagnostics.HealthChecks.Abstractions" Version="6.0.11" />
<PackageVersion Include="Microsoft.Extensions.Http" Version="6.0.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.4.0" />
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="1.1.1" />
<PackageVersion Include="NSubstitute" Version="4.4.0" />
<PackageVersion Include="Scrutor" Version="4.2.0" />
<PackageVersion Include="System.Collections.Immutable" Version="6.0.0" />
<PackageVersion Include="Swashbuckle.AspNetCore" Version="6.4.0" />
<PackageVersion Include="xunit" Version="2.4.2" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.4.5" />
</ItemGroup>
<ItemGroup>
<PackageVersion Include="AspNetCore.HealthChecks.Uris" Version="8.0.0" />
<PackageVersion Include="Azure.Extensions.AspNetCore.Configuration.Secrets" Version="1.3.0" />
<PackageVersion Include="Azure.Messaging.ServiceBus" Version="7.17.1" />
<PackageVersion Include="coverlet.collector" Version="6.0.0" />
<PackageVersion Include="FluentAssertions" Version="6.12.0" />
<PackageVersion Include="FluentValidation" Version="11.8.1" />
<PackageVersion Include="Hellang.Middleware.ProblemDetails" Version="6.5.1" />
<PackageVersion Include="IdentityServer4.AccessTokenValidation" Version="3.0.1" />
<PackageVersion Include="Kros.AspNetCore" Version="3.7.0" />
<PackageVersion Include="Kros.Utils" Version="3.0.0" />
<PackageVersion Include="MassTransit.AspNetCore" Version="7.3.1" />
<PackageVersion Include="MassTransit.Azure.ServiceBus.Core" Version="8.1.2" />
<PackageVersion Include="MediatR" Version="12.2.0" />
<PackageVersion Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.22.0" />
<PackageVersion Include="Microsoft.AspNetCore.JsonPatch" Version="8.0.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.8.0" />
<PackageVersion Include="Microsoft.Extensions.Configuration.AzureAppConfiguration" Version="7.0.0" />
<PackageVersion Include="Microsoft.Extensions.Configuration.Binder" Version="8.0.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="8.0.0" />
<PackageVersion Include="NSubstitute" Version="5.1.0" />
<PackageVersion Include="Scrutor" Version="4.2.2" />
<PackageVersion Include="Swashbuckle.AspNetCore" Version="6.5.0" />
<PackageVersion Include="xunit" Version="2.6.3" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.5.5" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0;netcoreapp3.1</TargetFrameworks>
<Version>2.3.0</Version>
<TargetFramework>net8.0</TargetFramework>
<Version>3.0.0</Version>
<Description>Extensions to facilitate work with Application Insights.</Description>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
</PropertyGroup>
Expand All @@ -21,8 +21,6 @@
<ItemGroup>
<PackageReference Include="Kros.Utils" />
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ public class ApiKeyBasicAuthenticationHandler : AuthenticationHandler<ApiKeyBasi
public ApiKeyBasicAuthenticationHandler(
IOptionsMonitor<ApiKeyBasicAuthenticationOptions> options,
ILoggerFactory logger,
UrlEncoder encoder,
ISystemClock clock) : base(options, logger, encoder, clock)
UrlEncoder encoder) : base(options, logger, encoder)
{
}

Expand Down
32 changes: 0 additions & 32 deletions src/Kros.AspNetCore/Extensions/HttpClientExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,7 @@ public static async Task<string> GetStringAndCheckResponseAsync(
Exception defaultException = null,
CancellationToken cancellationToken = default)
=> await (await client.GetAndCheckResponseAsync(uri, defaultException, cancellationToken))
#if NETCOREAPP3_1
.Content.ReadAsStringAsync();
#else
.Content.ReadAsStringAsync(cancellationToken);
#endif

/// <summary>
/// Get string response from http request and throws exception if request is unsuccessful.
Expand All @@ -127,11 +123,7 @@ public static async Task<string> GetStringAndCheckResponseAsync(
Exception defaultException = null,
CancellationToken cancellationToken = default)
=> await (await client.GetAndCheckResponseAsync(url, defaultException, cancellationToken))
#if NETCOREAPP3_1
.Content.ReadAsStringAsync();
#else
.Content.ReadAsStringAsync(cancellationToken);
#endif

/// <summary>
/// Get stream response from http request and throws exception if request is unsuccessful.
Expand All @@ -146,11 +138,7 @@ public static async Task<Stream> GetStreamAndCheckResponseAsync(
Exception defaultException = null,
CancellationToken cancellationToken = default)
=> await (await client.GetAndCheckResponseAsync(uri, defaultException, cancellationToken))
#if NETCOREAPP3_1
.Content.ReadAsStreamAsync();
#else
.Content.ReadAsStreamAsync(cancellationToken);
#endif

/// <summary>
/// Get stream response from http request and throws exception if request is unsuccessful.
Expand All @@ -165,11 +153,7 @@ public static async Task<Stream> GetStreamAndCheckResponseAsync(
Exception defaultException = null,
CancellationToken cancellationToken = default)
=> await (await client.GetAndCheckResponseAsync(url, defaultException, cancellationToken))
#if NETCOREAPP3_1
.Content.ReadAsStreamAsync();
#else
.Content.ReadAsStreamAsync(cancellationToken);
#endif

/// <summary>
/// Get stream response from http request and throws exception if request is unsuccessful.
Expand All @@ -186,11 +170,7 @@ public static async Task<Stream> GetStreamAndCheckResponseAsync(
Exception defaultException = null,
CancellationToken cancellationToken = default)
=> await (await client.GetAndCheckResponseAsync(uri, body, defaultException, cancellationToken))
#if NETCOREAPP3_1
.Content.ReadAsStreamAsync();
#else
.Content.ReadAsStreamAsync(cancellationToken);
#endif

/// <summary>
/// Get stream response from http request and throws exception if request is unsuccessful.
Expand All @@ -207,11 +187,7 @@ public static async Task<Stream> GetStreamAndCheckResponseAsync(
Exception defaultException = null,
CancellationToken cancellationToken = default)
=> await (await client.GetAndCheckResponseAsync(url, body, defaultException, cancellationToken))
#if NETCOREAPP3_1
.Content.ReadAsStreamAsync();
#else
.Content.ReadAsStreamAsync(cancellationToken);
#endif

/// <summary>
/// Get byte array response from http request and throws exception if request is unsuccessful.
Expand All @@ -226,11 +202,7 @@ public static async Task<byte[]> GetByteArrayAndCheckResponseAsync(
Exception defaultException = null,
CancellationToken cancellationToken = default)
=> await (await client.GetAndCheckResponseAsync(uri, defaultException, cancellationToken))
#if NETCOREAPP3_1
.Content.ReadAsByteArrayAsync();
#else
.Content.ReadAsByteArrayAsync(cancellationToken);
#endif

/// <summary>
/// Get byte array response from http request and throws exception if request is unsuccessful.
Expand All @@ -245,10 +217,6 @@ public static async Task<byte[]> GetByteArrayAndCheckResponseAsync(
Exception defaultException = null,
CancellationToken cancellationToken = default)
=> await (await client.GetAndCheckResponseAsync(url, defaultException, cancellationToken))
#if NETCOREAPP3_1
.Content.ReadAsByteArrayAsync();
#else
.Content.ReadAsByteArrayAsync(cancellationToken);
#endif
}
}
10 changes: 2 additions & 8 deletions src/Kros.AspNetCore/Kros.AspNetCore.csproj
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0;netcoreapp3.1</TargetFrameworks>
<Version>3.7.0</Version>
<TargetFramework>net8.0</TargetFramework>
<Version>4.0.0</Version>
<Description>General utilities and helpers for building ASP.NET Core WEB API</Description>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
</PropertyGroup>
Expand All @@ -21,16 +21,10 @@
<ItemGroup>
<PackageReference Include="AspNetCore.HealthChecks.Uris" />
<PackageReference Include="Azure.Extensions.AspNetCore.Configuration.Secrets" />
<PackageReference Include="Azure.Identity" />
<PackageReference Include="IdentityServer4.AccessTokenValidation" />
<PackageReference Include="Kros.Utils" />
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" />
<PackageReference Include="Microsoft.AspNetCore.JsonPatch" />
<PackageReference Include="Microsoft.Extensions.Caching.Abstractions" />
<PackageReference Include="Microsoft.Extensions.Configuration.AzureAppConfiguration" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" />
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks.Abstractions" />
<PackageReference Include="Microsoft.Extensions.Http" />
</ItemGroup>

<ItemGroup>
Expand Down
10 changes: 3 additions & 7 deletions src/Kros.MassTransit.Analyzers/Kros.MassTransit.Analyzers.csproj
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<Version>2.0.0</Version>
<TargetFramework>net8.0</TargetFramework>
<Version>3.0.0</Version>
<IncludeBuildOutput>false</IncludeBuildOutput>
<GeneratePackageOnBuild>False</GeneratePackageOnBuild>
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" />
</ItemGroup>

Expand Down
11 changes: 7 additions & 4 deletions src/Kros.MassTransit.AzureServiceBus/AzureServiceBusOptions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Microsoft.Azure.ServiceBus;
using Azure.Messaging.ServiceBus;
using System;
using System.Collections.Generic;

namespace Kros.MassTransit.AzureServiceBus
Expand All @@ -20,8 +21,9 @@ public string Endpoint
{
get
{
string endpoint = new ServiceBusConnectionStringBuilder(ConnectionString).Endpoint;
if (!string.IsNullOrEmpty(endpoint) && endpoint.EndsWith("/"))
Uri endpointUri = ServiceBusConnectionStringProperties.Parse(ConnectionString).Endpoint;
string endpoint = endpointUri is null ? string.Empty : endpointUri.ToString();
if (!string.IsNullOrEmpty(endpoint) && endpoint.EndsWith('/'))
{
return endpoint;
}
Expand All @@ -33,8 +35,9 @@ public string Endpoint
}

/// <summary>
/// Token time to live in seconds. If 0, default value <see cref=" ConfigDefaults.TokenTimeToLive"/> is used.
/// Token time to live in seconds.
/// </summary>
[Obsolete("This property is not used anymore.")]
public int TokenTimeToLive { get; set; }

/// <summary>
Expand Down
5 changes: 0 additions & 5 deletions src/Kros.MassTransit.AzureServiceBus/ConfigDefaults.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@ namespace Kros.MassTransit.AzureServiceBus
/// </summary>
public static class ConfigDefaults
{
/// <summary>
/// Default time to live for Azure service bus token.
/// </summary>
public static TimeSpan TokenTimeToLive { get; } = TimeSpan.FromMinutes(1);

/// <summary>
/// Default message time to live in the queue.
/// </summary>
Expand Down
2 changes: 0 additions & 2 deletions src/Kros.MassTransit.AzureServiceBus/Endpoints/Endpoint.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using Kros.Utils;
using MassTransit;
using MassTransit.Azure.ServiceBus.Core;
using MassTransit.ConsumeConfigurators;
using System;

namespace Kros.MassTransit.AzureServiceBus.Endpoints
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using MassTransit;
using MassTransit.Azure.ServiceBus.Core;
using MassTransit.ConsumeConfigurators;
using System;
using System.Collections.Generic;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using MassTransit;
using MassTransit.Azure.ServiceBus.Core;
using MassTransit.ConsumeConfigurators;
using System;
using System.Collections.Generic;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public static IServiceCollection AddMassTransitForAzure(
cfg.AddBus(provider =>
{
MassTransitForAzureBuilder builder = new(provider);
MassTransitForAzureBuilder builder = new((IServiceProvider)provider);
busCfg?.Invoke(builder);
return builder.Build();
Expand Down
5 changes: 1 addition & 4 deletions src/Kros.MassTransit.AzureServiceBus/Interfaces.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using GreenPipes.Configurators;
using MassTransit;
using MassTransit.Azure.ServiceBus.Core;
using MassTransit.ConsumeConfigurators;
using MassTransit;
using System;

namespace Kros.MassTransit.AzureServiceBus
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<Version>2.3.0</Version>
<TargetFramework>net8.0</TargetFramework>
<Version>3.0.0</Version>
<Description>Simpler configuration of MassTransit library.</Description>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
</PropertyGroup>
Expand All @@ -22,11 +22,9 @@

<ItemGroup>
<PackageReference Include="Kros.Utils" />
<PackageReference Include="MassTransit.AspNetCore" />
<PackageReference Include="MassTransit.Azure.ServiceBus.Core" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" />
<PackageReference Include="Scrutor" />
<PackageReference Include="System.Collections.Immutable" />
</ItemGroup>

<ItemGroup>
Expand Down
Loading

0 comments on commit f50a3a7

Please sign in to comment.