diff --git a/CleanArchitecture.WorkerService.sln b/CleanArchitecture.WorkerService.sln
index 1c939b3..a2e6758 100644
--- a/CleanArchitecture.WorkerService.sln
+++ b/CleanArchitecture.WorkerService.sln
@@ -18,6 +18,7 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "sln", "sln", "{2DD960C4-7461-4547-9983-3E3034D2B0C6}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
+ Directory.Build.props = Directory.Build.props
Directory.Packages.props = Directory.Packages.props
ef-migrations.txt = ef-migrations.txt
global.json = global.json
diff --git a/Directory.Build.props b/Directory.Build.props
new file mode 100644
index 0000000..4afb2c0
--- /dev/null
+++ b/Directory.Build.props
@@ -0,0 +1,7 @@
+
+
+
+ net8.0
+
+
+
\ No newline at end of file
diff --git a/Directory.Packages.props b/Directory.Packages.props
index 478a78b..a5afb35 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -5,7 +5,7 @@
-
+
@@ -21,18 +21,18 @@
-
+
-
+
-
-
-
-
-
+
+
+
+
+
@@ -43,7 +43,7 @@
-
-
+
+
\ No newline at end of file
diff --git a/src/CleanArchitecture.Core/CleanArchitecture.Core.csproj b/src/CleanArchitecture.Core/CleanArchitecture.Core.csproj
index 55d6dde..a0645b9 100644
--- a/src/CleanArchitecture.Core/CleanArchitecture.Core.csproj
+++ b/src/CleanArchitecture.Core/CleanArchitecture.Core.csproj
@@ -1,9 +1,5 @@
-
- net7.0
-
-
diff --git a/src/CleanArchitecture.Core/Services/EntryPointService.cs b/src/CleanArchitecture.Core/Services/EntryPointService.cs
index 3fc2674..a13c15a 100644
--- a/src/CleanArchitecture.Core/Services/EntryPointService.cs
+++ b/src/CleanArchitecture.Core/Services/EntryPointService.cs
@@ -9,30 +9,12 @@ namespace CleanArchitecture.Core.Services;
///
/// An example service that performs business logic
///
-public class EntryPointService : IEntryPointService
+public class EntryPointService(ILoggerAdapter _logger,
+ EntryPointSettings _settings,
+ IQueueReceiver _queueReceiver,
+ IServiceLocator _serviceScopeFactoryLocator,
+ IUrlStatusChecker _urlStatusChecker) : IEntryPointService
{
- private readonly ILoggerAdapter _logger;
- private readonly EntryPointSettings _settings;
- private readonly IQueueReceiver _queueReceiver;
- private readonly IQueueSender _queueSender;
- private readonly IServiceLocator _serviceScopeFactoryLocator;
- private readonly IUrlStatusChecker _urlStatusChecker;
-
- public EntryPointService(ILoggerAdapter logger,
- EntryPointSettings settings,
- IQueueReceiver queueReceiver,
- IQueueSender queueSender,
- IServiceLocator serviceScopeFactoryLocator,
- IUrlStatusChecker urlStatusChecker)
- {
- _logger = logger;
- _settings = settings;
- _queueReceiver = queueReceiver;
- _queueSender = queueSender;
- _serviceScopeFactoryLocator = serviceScopeFactoryLocator;
- _urlStatusChecker = urlStatusChecker;
- }
-
public async Task ExecuteAsync()
{
_logger.LogInformation("{service} running at: {time}", nameof(EntryPointService), DateTimeOffset.Now);
diff --git a/src/CleanArchitecture.Core/Services/ServiceScopeFactoryLocator.cs b/src/CleanArchitecture.Core/Services/ServiceScopeFactoryLocator.cs
index 4f20fbd..73f3712 100644
--- a/src/CleanArchitecture.Core/Services/ServiceScopeFactoryLocator.cs
+++ b/src/CleanArchitecture.Core/Services/ServiceScopeFactoryLocator.cs
@@ -6,16 +6,10 @@ namespace CleanArchitecture.Core.Services;
/// A wrapper around ServiceScopeFactory to make it easier to fake out with MOQ.
///
///
-public sealed class ServiceScopeFactoryLocator : IServiceLocator
+public sealed class ServiceScopeFactoryLocator(IServiceScopeFactory _factory) : IServiceLocator
{
- private readonly IServiceScopeFactory _factory;
private IServiceScope _scope;
- public ServiceScopeFactoryLocator(IServiceScopeFactory factory)
- {
- _factory = factory;
- }
-
public T Get()
{
CreateScope();
diff --git a/src/CleanArchitecture.Core/Services/UrlStatusChecker.cs b/src/CleanArchitecture.Core/Services/UrlStatusChecker.cs
index 032e37a..02b805b 100644
--- a/src/CleanArchitecture.Core/Services/UrlStatusChecker.cs
+++ b/src/CleanArchitecture.Core/Services/UrlStatusChecker.cs
@@ -8,15 +8,8 @@ namespace CleanArchitecture.Core.Services;
///
/// A simple service that fetches a URL and returns a UrlStatusHistory instance with the result
///
-public class UrlStatusChecker : IUrlStatusChecker
+public class UrlStatusChecker(IHttpService _httpService) : IUrlStatusChecker
{
- private readonly IHttpService _httpService;
-
- public UrlStatusChecker(IHttpService httpService)
- {
- _httpService = httpService;
- }
-
public async Task CheckUrlAsync(string url, string requestId)
{
Guard.Against.NullOrWhiteSpace(url, nameof(url));
diff --git a/src/CleanArchitecture.Infrastructure/CleanArchitecture.Infrastructure.csproj b/src/CleanArchitecture.Infrastructure/CleanArchitecture.Infrastructure.csproj
index 86caa6c..9be8f61 100644
--- a/src/CleanArchitecture.Infrastructure/CleanArchitecture.Infrastructure.csproj
+++ b/src/CleanArchitecture.Infrastructure/CleanArchitecture.Infrastructure.csproj
@@ -1,9 +1,5 @@
-
- net7.0
-
-
diff --git a/src/CleanArchitecture.Infrastructure/Http/HttpService.cs b/src/CleanArchitecture.Infrastructure/Http/HttpService.cs
index 3080747..e613be2 100644
--- a/src/CleanArchitecture.Infrastructure/Http/HttpService.cs
+++ b/src/CleanArchitecture.Infrastructure/Http/HttpService.cs
@@ -11,11 +11,9 @@ public class HttpService : IHttpService
{
public async Task GetUrlResponseStatusCodeAsync(string url)
{
- using (var client = new HttpClient())
- {
- var result = await client.GetAsync(url);
+ using var client = new HttpClient();
+ var result = await client.GetAsync(url);
- return (int)result.StatusCode;
- }
+ return (int)result.StatusCode;
}
}
diff --git a/src/CleanArchitecture.Infrastructure/LoggerAdapter.cs b/src/CleanArchitecture.Infrastructure/LoggerAdapter.cs
index d49b94b..3fd5821 100644
--- a/src/CleanArchitecture.Infrastructure/LoggerAdapter.cs
+++ b/src/CleanArchitecture.Infrastructure/LoggerAdapter.cs
@@ -8,15 +8,8 @@ namespace CleanArchitecture.Infrastructure;
/// An ILoggerAdapter implementation that uses Microsoft.Extensions.Logging
///
///
-public class LoggerAdapter : ILoggerAdapter
+public class LoggerAdapter(ILogger _logger) : ILoggerAdapter
{
- private readonly ILogger _logger;
-
- public LoggerAdapter(ILogger logger)
- {
- _logger = logger;
- }
-
public void LogError(Exception ex, string message, params object[] args)
{
_logger.LogError(ex, message, args);
diff --git a/src/CleanArchitecture.Worker/CleanArchitecture.Worker.csproj b/src/CleanArchitecture.Worker/CleanArchitecture.Worker.csproj
index 0651754..9ba3562 100644
--- a/src/CleanArchitecture.Worker/CleanArchitecture.Worker.csproj
+++ b/src/CleanArchitecture.Worker/CleanArchitecture.Worker.csproj
@@ -1,7 +1,6 @@
- net7.0
dotnet-CleanArchitecture.Worker-AF0DD401-BB78-4FCC-8186-3E275E001A54
Linux
..\..
diff --git a/src/CleanArchitecture.Worker/Dockerfile b/src/CleanArchitecture.Worker/Dockerfile
index ca7b3e5..50f1861 100644
--- a/src/CleanArchitecture.Worker/Dockerfile
+++ b/src/CleanArchitecture.Worker/Dockerfile
@@ -1,7 +1,7 @@
-FROM mcr.microsoft.com/dotnet/runtime:6.0 AS base
+FROM mcr.microsoft.com/dotnet/runtime:8.0 AS base
WORKDIR /app
-FROM mcr.microsoft.com/dotnet/runtime:6.0 AS build
+FROM mcr.microsoft.com/dotnet/runtime:8.0 AS build
WORKDIR /src
COPY ["src/CleanArchitecture.Worker/CleanArchitecture.Worker.csproj", "src/CleanArchitecture.Worker/"]
RUN dotnet restore "src/CleanArchitecture.Worker/CleanArchitecture.Worker.csproj"
diff --git a/src/CleanArchitecture.Worker/Worker.cs b/src/CleanArchitecture.Worker/Worker.cs
index fdbc421..0752fe8 100644
--- a/src/CleanArchitecture.Worker/Worker.cs
+++ b/src/CleanArchitecture.Worker/Worker.cs
@@ -11,21 +11,10 @@ namespace CleanArchitecture.Worker;
/// It should not contain any business logic but should call an entrypoint service that
/// execute once per time period.
///
-public class Worker : BackgroundService
+public class Worker(ILoggerAdapter _logger,
+ IEntryPointService _entryPointService,
+ WorkerSettings _settings) : BackgroundService
{
- private readonly ILoggerAdapter _logger;
- private readonly IEntryPointService _entryPointService;
- private readonly WorkerSettings _settings;
-
- public Worker(ILoggerAdapter logger,
- IEntryPointService entryPointService,
- WorkerSettings settings)
- {
- _logger = logger;
- _entryPointService = entryPointService;
- _settings = settings;
- }
-
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
_logger.LogInformation("CleanArchitecture.Worker service starting at: {time}", DateTimeOffset.Now);
diff --git a/tests/CleanArchitecture.UnitTests/CleanArchitecture.UnitTests.csproj b/tests/CleanArchitecture.UnitTests/CleanArchitecture.UnitTests.csproj
index 973a1e9..9e341a8 100644
--- a/tests/CleanArchitecture.UnitTests/CleanArchitecture.UnitTests.csproj
+++ b/tests/CleanArchitecture.UnitTests/CleanArchitecture.UnitTests.csproj
@@ -1,8 +1,6 @@
- net7.0
-
false