Simplifying boilerplate dependency injection with C# 12 Primary Constructors:
// C# 12 Primary Constructor syntax
public class PaymentProcessor(ILogger<PaymentProcessor> logger, IPaymentGateway gateway, IOrderRepository repo)
{
public async Task ProcessAsync(OrderId id)
{
logger.LogInformation("Processing order {Id}", id);
await gateway.ChargeAsync(id);
await repo.MarkAsPaidAsync(id);
}
}Eliminates private field declarations (private readonly ILogger _logger;) and constructor assignment boilerplate, making service classes concise and readable!