diff --git a/Directory.Build.targets b/Directory.Build.targets
index 1885ca7..78bf621 100644
--- a/Directory.Build.targets
+++ b/Directory.Build.targets
@@ -67,15 +67,15 @@
-
+
-
-
+
+
@@ -87,13 +87,13 @@
-
-
-
+
+
+
runtime; build; native; contentfiles; analyzers; buildtransitive
all
-
+
runtime; build; native; contentfiles; analyzers; buildtransitive
all
diff --git a/src/Domain.SourceGenerators/EntityIdCodeGenerators.cs b/src/Domain.SourceGenerators/EntityIdCodeGenerators.cs
index acfc7a9..ea29aac 100644
--- a/src/Domain.SourceGenerators/EntityIdCodeGenerators.cs
+++ b/src/Domain.SourceGenerators/EntityIdCodeGenerators.cs
@@ -65,13 +65,13 @@ namespace {ns}
[TypeConverter(typeof(EntityIdTypeConverter<{className}, {sourceType}>))]
public partial record {className}({sourceType} Id) : I{sourceType}StronglyTypedId
{{
- ///
- /// implicit operator
- ///
+ /////
+ ///// implicit operator
+ /////
//public static implicit operator {sourceType}({className} id) => id.Id;
- ///
- /// implicit operator
- ///
+ /////
+ ///// implicit operator
+ /////
//public static implicit operator {className}({sourceType} id) => new {className}(id);
///
diff --git a/src/Repository.EntityFrameworkCore/AppDbContextBase.cs b/src/Repository.EntityFrameworkCore/AppDbContextBase.cs
index a8aa569..6333d36 100644
--- a/src/Repository.EntityFrameworkCore/AppDbContextBase.cs
+++ b/src/Repository.EntityFrameworkCore/AppDbContextBase.cs
@@ -35,9 +35,8 @@ protected virtual void ConfigureStronglyTypedIdValueConverter(ModelConfiguration
protected virtual void ConfigureRowVersion(ModelBuilder modelBuilder)
{
ArgumentNullException.ThrowIfNull(modelBuilder);
- foreach (var entityType in modelBuilder.Model.GetEntityTypes())
+ foreach (var clrType in modelBuilder.Model.GetEntityTypes().Select(p => p.ClrType))
{
- var clrType = entityType.ClrType;
var properties = clrType.GetProperties(BindingFlags.Public | BindingFlags.Instance)
.Where(p => p.PropertyType == typeof(RowVersion));
diff --git a/src/Snowflake.Consul/ConsulWorkerIdGenerator.cs b/src/Snowflake.Consul/ConsulWorkerIdGenerator.cs
index baf131d..bd00a91 100644
--- a/src/Snowflake.Consul/ConsulWorkerIdGenerator.cs
+++ b/src/Snowflake.Consul/ConsulWorkerIdGenerator.cs
@@ -137,7 +137,6 @@ public async Task Refresh(CancellationToken stoppingToken = default)
public string GetWorkerIdKey()
{
- ArgumentNullException.ThrowIfNull(_workId);
return GetWorkerIdKey(_workId);
}
diff --git a/src/Snowflake.Redis/RedisWorkerIdGenerator.cs b/src/Snowflake.Redis/RedisWorkerIdGenerator.cs
index 312620b..ad98de5 100644
--- a/src/Snowflake.Redis/RedisWorkerIdGenerator.cs
+++ b/src/Snowflake.Redis/RedisWorkerIdGenerator.cs
@@ -24,8 +24,6 @@ public sealed class RedisWorkerIdGenerator : BackgroundService, IWorkIdGenerator
///
private readonly string _workerName;
- private readonly IConnectionMultiplexer _connectionMultiplexer;
-
private readonly IDatabase _database;
public RedisWorkerIdGenerator(ILogger logger,
@@ -35,7 +33,6 @@ public RedisWorkerIdGenerator(ILogger logger,
_workerName = $"{Environment.MachineName}-{Guid.NewGuid()}";
_logger = logger;
_options = options.Value;
- _connectionMultiplexer = connectionMultiplexer;
_database = connectionMultiplexer.GetDatabase();
_workId = GenWorkId().Result;
_logger.LogInformation("workerid got, workerId: {workerId} , identity name: {workerName}",
@@ -127,7 +124,6 @@ public async Task Refresh(CancellationToken stoppingToken = default)
public string GetWorkerIdKey()
{
- ArgumentNullException.ThrowIfNull(_workId);
return GetWorkerIdKey(_workId);
}
diff --git a/test/NetCorePal.Extensions.Snowflake.Consul.UnitTests/ConsulWorkerIdGeneratorTests.cs b/test/NetCorePal.Extensions.Snowflake.Consul.UnitTests/ConsulWorkerIdGeneratorTests.cs
index c9438e5..5816846 100644
--- a/test/NetCorePal.Extensions.Snowflake.Consul.UnitTests/ConsulWorkerIdGeneratorTests.cs
+++ b/test/NetCorePal.Extensions.Snowflake.Consul.UnitTests/ConsulWorkerIdGeneratorTests.cs
@@ -45,7 +45,7 @@ public async Task Refresh_Throw_Exception_When_Session_Locked_By_Others_Test()
var id = consulWorkerIdGenerator.GetId();
Assert.Equal(0, id);
Assert.True(consulWorkerIdGenerator.IsHealth);
- Assert.Equal(HealthStatus.Healthy, consulWorkerIdGenerator.CheckHealthAsync(healthCheckContext).Result.Status);
+ Assert.Equal(HealthStatus.Healthy, (await consulWorkerIdGenerator.CheckHealthAsync(healthCheckContext)).Status);
var releaseResult = await _consulClient.KV.Release(new KVPair(consulWorkerIdGenerator.GetWorkerIdKey())
{
@@ -71,7 +71,7 @@ public async Task Refresh_Throw_Exception_When_Session_Locked_By_Others_Test()
await Assert.ThrowsAsync(async () => await consulWorkerIdGenerator.Refresh());
Assert.False(consulWorkerIdGenerator.IsHealth);
Assert.Equal(HealthStatus.Unhealthy,
- consulWorkerIdGenerator.CheckHealthAsync(healthCheckContext).Result.Status);
+ (await consulWorkerIdGenerator.CheckHealthAsync(healthCheckContext)).Status);
}
@@ -90,7 +90,7 @@ public async Task Refresh_Throw_Exception_When_Session_Locked_By_Others_And_Unhe
var id = consulWorkerIdGenerator.GetId();
Assert.Equal(0, id);
Assert.True(consulWorkerIdGenerator.IsHealth);
- Assert.Equal(HealthStatus.Healthy, consulWorkerIdGenerator.CheckHealthAsync(healthCheckContext).Result.Status);
+ Assert.Equal(HealthStatus.Healthy, (await consulWorkerIdGenerator.CheckHealthAsync(healthCheckContext)).Status);
var releaseResult = await _consulClient.KV.Release(new KVPair(consulWorkerIdGenerator.GetWorkerIdKey())
{
@@ -116,7 +116,7 @@ public async Task Refresh_Throw_Exception_When_Session_Locked_By_Others_And_Unhe
await Assert.ThrowsAsync(async () => await consulWorkerIdGenerator.Refresh());
Assert.False(consulWorkerIdGenerator.IsHealth);
Assert.Equal(HealthStatus.Degraded,
- consulWorkerIdGenerator.CheckHealthAsync(healthCheckContext).Result.Status);
+ (await consulWorkerIdGenerator.CheckHealthAsync(healthCheckContext)).Status);
}
@@ -134,7 +134,7 @@ public async Task Refresh_OK_When_Session_Released_And_Not_Lock_By_Others_Test()
var id = consulWorkerIdGenerator.GetId();
Assert.Equal(0, id);
Assert.True(consulWorkerIdGenerator.IsHealth);
- Assert.Equal(HealthStatus.Healthy, consulWorkerIdGenerator.CheckHealthAsync(healthCheckContext).Result.Status);
+ Assert.Equal(HealthStatus.Healthy, (await consulWorkerIdGenerator.CheckHealthAsync(healthCheckContext)).Status);
var releaseResult = await _consulClient.KV.Release(new KVPair(consulWorkerIdGenerator.GetWorkerIdKey())
{
@@ -159,7 +159,8 @@ public async Task Refresh_OK_When_Session_Released_And_Not_Lock_By_Others_Test()
});
Assert.Equal(1, consulWorkerIdGenerator2.GetId());
Assert.True(consulWorkerIdGenerator2.IsHealth);
- Assert.Equal(HealthStatus.Healthy, consulWorkerIdGenerator2.CheckHealthAsync(healthCheckContext).Result.Status);
+ Assert.Equal(HealthStatus.Healthy,
+ (await consulWorkerIdGenerator2.CheckHealthAsync(healthCheckContext)).Status);
}
[Fact]
diff --git a/test/NetCorePal.Extensions.Snowflake.Redis.UnitTests/RedisWorkerIdGeneratorTests.cs b/test/NetCorePal.Extensions.Snowflake.Redis.UnitTests/RedisWorkerIdGeneratorTests.cs
index 103b0e7..7f074eb 100644
--- a/test/NetCorePal.Extensions.Snowflake.Redis.UnitTests/RedisWorkerIdGeneratorTests.cs
+++ b/test/NetCorePal.Extensions.Snowflake.Redis.UnitTests/RedisWorkerIdGeneratorTests.cs
@@ -47,7 +47,7 @@ public async Task Refresh_Throw_Exception_When_Session_Locked_By_Others_Test()
var id = workerIdGenerator.GetId();
Assert.Equal(0, id);
Assert.True(workerIdGenerator.IsHealth);
- Assert.Equal(HealthStatus.Healthy, workerIdGenerator.CheckHealthAsync(healthCheckContext).Result.Status);
+ Assert.Equal(HealthStatus.Healthy, (await workerIdGenerator.CheckHealthAsync(healthCheckContext)).Status);
var value = await _database.StringGetAsync(workerIdGenerator.GetWorkerIdKey());
Assert.True(value.HasValue);
@@ -65,7 +65,7 @@ public async Task Refresh_Throw_Exception_When_Session_Locked_By_Others_Test()
await Assert.ThrowsAsync(async () => await workerIdGenerator.Refresh());
Assert.False(workerIdGenerator.IsHealth);
Assert.Equal(HealthStatus.Unhealthy,
- workerIdGenerator.CheckHealthAsync(healthCheckContext).Result.Status);
+ (await workerIdGenerator.CheckHealthAsync(healthCheckContext)).Status);
}
@@ -84,7 +84,7 @@ public async Task Refresh_Throw_Exception_When_Session_Locked_By_Others_And_Unhe
var id = workerIdGenerator.GetId();
Assert.Equal(0, id);
Assert.True(workerIdGenerator.IsHealth);
- Assert.Equal(HealthStatus.Healthy, workerIdGenerator.CheckHealthAsync(healthCheckContext).Result.Status);
+ Assert.Equal(HealthStatus.Healthy, (await workerIdGenerator.CheckHealthAsync(healthCheckContext)).Status);
var value = await _database.StringGetAsync(workerIdGenerator.GetWorkerIdKey());
Assert.True(value.HasValue);
@@ -102,7 +102,7 @@ public async Task Refresh_Throw_Exception_When_Session_Locked_By_Others_And_Unhe
await Assert.ThrowsAsync(async () => await workerIdGenerator.Refresh());
Assert.False(workerIdGenerator.IsHealth);
Assert.Equal(HealthStatus.Degraded,
- workerIdGenerator.CheckHealthAsync(healthCheckContext).Result.Status);
+ (await workerIdGenerator.CheckHealthAsync(healthCheckContext)).Status);
}
@@ -120,11 +120,11 @@ public async Task Refresh_OK_When_Session_Released_And_Not_Lock_By_Others_Test()
var id = consulWorkerIdGenerator.GetId();
Assert.Equal(0, id);
Assert.True(consulWorkerIdGenerator.IsHealth);
- Assert.Equal(HealthStatus.Healthy, consulWorkerIdGenerator.CheckHealthAsync(healthCheckContext).Result.Status);
+ Assert.Equal(HealthStatus.Healthy, (await consulWorkerIdGenerator.CheckHealthAsync(healthCheckContext)).Status);
var value = await _database.StringGetAsync(consulWorkerIdGenerator.GetWorkerIdKey());
Assert.True(value.HasValue);
-
+
await _database.KeyDeleteAsync(consulWorkerIdGenerator.GetWorkerIdKey());
await consulWorkerIdGenerator.Refresh();
@@ -137,7 +137,8 @@ public async Task Refresh_OK_When_Session_Released_And_Not_Lock_By_Others_Test()
});
Assert.Equal(1, consulWorkerIdGenerator2.GetId());
Assert.True(consulWorkerIdGenerator2.IsHealth);
- Assert.Equal(HealthStatus.Healthy, consulWorkerIdGenerator2.CheckHealthAsync(healthCheckContext).Result.Status);
+ Assert.Equal(HealthStatus.Healthy,
+ (await consulWorkerIdGenerator2.CheckHealthAsync(healthCheckContext)).Status);
}
[Fact]
diff --git a/test/NetCorePal.Web.UnitTests/ProgramTests.cs b/test/NetCorePal.Web.UnitTests/ProgramTests.cs
index f408e4a..73d5cca 100644
--- a/test/NetCorePal.Web.UnitTests/ProgramTests.cs
+++ b/test/NetCorePal.Web.UnitTests/ProgramTests.cs
@@ -29,10 +29,10 @@ public ProgramTests(MyWebApplicationFactory factory)
JsonSerializerOptions JsonOption;
[Fact]
- public void HealthCheckTest()
+ public async Task HealthCheckTest()
{
var client = factory.CreateClient();
- var response = client.GetAsync("/health").Result;
+ var response = await client.GetAsync("/health");
Assert.True(response.IsSuccessStatusCode);
}
@@ -200,7 +200,7 @@ public async Task SetOrderItemNameTest()
Assert.Equal(14, queryResult.Count);
Assert.False(queryResult.Paid);
Assert.Equal(1, queryResult.RowVersion.VersionNumber);
- Assert.Equal(1,queryResult.OrderItems.Count());
+ Assert.Single(queryResult.OrderItems);
Assert.Equal(1,queryResult.OrderItems.First().RowVersion.VersionNumber);
}
diff --git a/test/NetCorePal.Web/Application/Commands/SetOrderItemNameCommand.cs b/test/NetCorePal.Web/Application/Commands/SetOrderItemNameCommand.cs
index 4f0a090..2e46ab5 100644
--- a/test/NetCorePal.Web/Application/Commands/SetOrderItemNameCommand.cs
+++ b/test/NetCorePal.Web/Application/Commands/SetOrderItemNameCommand.cs
@@ -2,10 +2,25 @@
namespace NetCorePal.Web.Application.Commands;
+///
+///
+///
+///
+///
public record SetOrderItemNameCommand(OrderId OrderId,string NewName) : ICommand;
+///
+///
+///
+///
public class SetOrderItemNameCommandHandler(IOrderRepository orderRepository) : ICommandHandler
{
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
public async Task Handle(SetOrderItemNameCommand command, CancellationToken cancellationToken)
{
var order = await orderRepository.GetAsync(command.OrderId, cancellationToken);
diff --git a/test/NetCorePal.Web/Application/IntegrationEventHandlers/OrderCreatedntegrationEventHandler.cs b/test/NetCorePal.Web/Application/IntegrationEventHandlers/OrderCreatedntegrationEventHandler.cs
index 1c8b859..291b6fc 100644
--- a/test/NetCorePal.Web/Application/IntegrationEventHandlers/OrderCreatedntegrationEventHandler.cs
+++ b/test/NetCorePal.Web/Application/IntegrationEventHandlers/OrderCreatedntegrationEventHandler.cs
@@ -7,6 +7,7 @@ namespace NetCorePal.Web.Application.IntegrationEventHandlers
///
///
///
+ ///
public class OrderCreatedIntegrationEventHandler(
IMediator mediator,
ILogger logger) : IIntegrationEventHandler
@@ -16,10 +17,11 @@ public class OrderCreatedIntegrationEventHandler(
///
///
///
- public async Task HandleAsync(OrderCreatedIntegrationEvent eventData,
+ public Task HandleAsync(OrderCreatedIntegrationEvent eventData,
CancellationToken cancellationToken = default)
{
logger.LogInformation("OrderCreatedIntegrationEventHandler.HandleAsync");
+ return Task.CompletedTask;
}
}
}
\ No newline at end of file
diff --git a/test/NetCorePal.Web/Application/Queries/OrderQuery.cs b/test/NetCorePal.Web/Application/Queries/OrderQuery.cs
index 60c575d..5faf2b6 100644
--- a/test/NetCorePal.Web/Application/Queries/OrderQuery.cs
+++ b/test/NetCorePal.Web/Application/Queries/OrderQuery.cs
@@ -24,6 +24,16 @@ public class OrderQuery(ApplicationDbContext applicationDbContext)
}
}
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
public record OrderQueryResult(
OrderId OrderId,
string Name,
@@ -33,7 +43,13 @@ public record OrderQueryResult(
RowVersion RowVersion,
IEnumerable OrderItems);
-
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
public record OrderItemQueryResult(
OrderItemId OrderItemId,
string Name,
diff --git a/test/NetCorePal.Web/Controllers/OrderController.cs b/test/NetCorePal.Web/Controllers/OrderController.cs
index 35bed01..e23b483 100644
--- a/test/NetCorePal.Web/Controllers/OrderController.cs
+++ b/test/NetCorePal.Web/Controllers/OrderController.cs
@@ -76,6 +76,12 @@ public async Task SetPaid(OrderId id)
return true.AsResponseData();
}
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
[HttpPost]
[Route("/setorderItemName")]
public async Task SetOrderItemName([FromQuery]long id, [FromQuery]string name)
@@ -175,6 +181,11 @@ public Task> BadRequest(long id)
}
+ ///
+ ///
+ ///
+ ///
+ ///
[HttpGet]
[Route("/path/{id}")]
public Task> Path([FromRoute] OrderId id)
diff --git a/test/NetCorePal.Web/Domain/Order.cs b/test/NetCorePal.Web/Domain/Order.cs
index 6bb0635..6bbcb3d 100644
--- a/test/NetCorePal.Web/Domain/Order.cs
+++ b/test/NetCorePal.Web/Domain/Order.cs
@@ -75,6 +75,11 @@ public void OrderPaid()
}
+ ///
+ ///
+ ///
+ ///
+ ///
public void ChangeItemName(string name)
{
this.Name = name;
diff --git a/test/NetCorePal.Web/Domain/OrderItem.cs b/test/NetCorePal.Web/Domain/OrderItem.cs
index 43b309c..288a5b5 100644
--- a/test/NetCorePal.Web/Domain/OrderItem.cs
+++ b/test/NetCorePal.Web/Domain/OrderItem.cs
@@ -4,25 +4,51 @@ namespace NetCorePal.Web.Domain;
public partial record OrderItemId : IInt64StronglyTypedId;
+///
+///
+///
public class OrderItem : Entity
{
+ ///
+ ///
+ ///
protected OrderItem()
{
}
+ ///
+ ///
+ ///
+ ///
+ ///
public OrderItem(string name, int count)
{
this.Name = name;
this.Count = count;
}
+ ///
+ ///
+ ///
public OrderId OrderId { get; private set; } = default!;
+ ///
+ ///
+ ///
public string Name { get; private set; } = string.Empty;
+ ///
+ ///
+ ///
public int Count { get; private set; }
-
+ ///
+ ///
+ ///
public RowVersion RowVersion { get; private set; } = new RowVersion();
+ ///
+ ///
+ ///
+ ///
public void ChangeName(string newName)
{
this.Name = newName;
diff --git a/test/NetCorePal.Web/HostedServices/CreateOrderCommandBackgroundService.cs b/test/NetCorePal.Web/HostedServices/CreateOrderCommandBackgroundService.cs
index 2137082..eba6775 100644
--- a/test/NetCorePal.Web/HostedServices/CreateOrderCommandBackgroundService.cs
+++ b/test/NetCorePal.Web/HostedServices/CreateOrderCommandBackgroundService.cs
@@ -2,8 +2,16 @@
namespace NetCorePal.Web.HostedServices;
+///
+///
+///
+///
public class CreateOrderCommandBackgroundService(IServiceProvider serviceProvider) : BackgroundService
{
+ ///
+ ///
+ ///
+ ///
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
while (!stoppingToken.IsCancellationRequested)
diff --git a/test/NetCorePal.Web/Infra/EntityConfigurations/OrderItemEntityTypeConfiguration.cs b/test/NetCorePal.Web/Infra/EntityConfigurations/OrderItemEntityTypeConfiguration.cs
index fde4ef2..41d64bd 100644
--- a/test/NetCorePal.Web/Infra/EntityConfigurations/OrderItemEntityTypeConfiguration.cs
+++ b/test/NetCorePal.Web/Infra/EntityConfigurations/OrderItemEntityTypeConfiguration.cs
@@ -3,8 +3,15 @@
namespace NetCorePal.Web.Infra.EntityConfigurations;
+///
+///
+///
public class OrderItemEntityTypeConfiguration : IEntityTypeConfiguration
{
+ ///
+ ///
+ ///
+ ///
public void Configure(EntityTypeBuilder builder)
{
builder.ToTable("orderitem");
diff --git a/test/NetCorePal.Web/NetCorePal.Web.csproj b/test/NetCorePal.Web/NetCorePal.Web.csproj
index 72a8ffd..3b699e7 100644
--- a/test/NetCorePal.Web/NetCorePal.Web.csproj
+++ b/test/NetCorePal.Web/NetCorePal.Web.csproj
@@ -19,7 +19,7 @@
-
+
diff --git a/test/NetCorePal.Web/Program.cs b/test/NetCorePal.Web/Program.cs
index 60412a7..af0eb4b 100644
--- a/test/NetCorePal.Web/Program.cs
+++ b/test/NetCorePal.Web/Program.cs
@@ -45,7 +45,6 @@
options.JsonSerializerOptions.Converters.Add(new EntityIdJsonConverterFactory());
}));
- var a = typeof(CapTracingDiagnosticProcessor);
builder.Services.AddHealthChecks();
builder.Services.AddMvc().AddControllersAsServices().AddJsonOptions(options =>