Repository: dotnet/yarp (2025-07-19T16:53:08Z)

Issue:
Use exception throw helper
Since we're on .NET 8, maybe we could use the exception throw helper from the framework to simplify the exception throw

For example:

Use `ArgumentNullException.ThrowIfNull(context);` to simplify the null checking

before:
```c#
if (context is null)
{
    throw new ArgumentNullException(nameof(context));
}
```

after:

```c#
ArgumentNullException.ThrowIfNull(context);
```

Use `ArgumentException.ThrowIfNullOrEmpty` to simplify the `string.IsNullOrEmpty` checking

before:

```c#
if (string.IsNullOrEmpty(headerName))
{
    throw new ArgumentException($"'{nameof(headerName)}' cannot be null or empty.", nameof(headerName));
}
```

after:

```c#
ArgumentException.ThrowIfNullOrEmpty(headerName);
```

> maybe copilot could help on this


Discussion:

Patch:
diff --git a/samples/ReverseProxy.Metrics.Sample/WebSocketsTelemetryConsumer.cs b/samples/ReverseProxy.Metrics.Sample/WebSocketsTelemetryConsumer.cs
index 161c55ea1..ad9d276dd 100644
--- a/samples/ReverseProxy.Metrics.Sample/WebSocketsTelemetryConsumer.cs
+++ b/samples/ReverseProxy.Metrics.Sample/WebSocketsTelemetryConsumer.cs
@@ -13,7 +13,8 @@ public sealed class WebSocketsTelemetryConsumer : IWebSocketsTelemetryConsumer
 
         public WebSocketsTelemetryConsumer(ILogger<WebSocketsTelemetryConsumer> logger)
         {
-            _logger = logger ?? throw new ArgumentNullException(nameof(logger));
+            ArgumentNullException.ThrowIfNull(logger);
+            _logger = logger;
         }
 
         public void OnWebSocketClosed(DateTime timestamp, DateTime establishedTime, WebSocketCloseReason closeReason, long messagesRead, long messagesWritten)
diff --git a/src/Kubernetes.Controller/Caching/Endpoints.cs b/src/Kubernetes.Controller/Caching/Endpoints.cs
index 7d63c75c2..db677440c 100644
--- a/src/Kubernetes.Controller/Caching/Endpoints.cs
+++ b/src/Kubernetes.Controller/Caching/Endpoints.cs
@@ -14,10 +14,7 @@ public struct Endpoints
 {
     public Endpoints(V1Endpoints endpoints)
     {
-        if (endpoints is null)
-        {
-            throw new ArgumentNullException(nameof(endpoints));
-        }
+        ArgumentNullException.ThrowIfNull(endpoints);
 
         Name = endpoints.Name();
         Subsets = endpoints.Subsets;
diff --git a/src/Kubernetes.Controller/Caching/IngressCache.cs b/src/Kubernetes.Controller/Caching/IngressCache.cs
index 835610569..584b4bfd3 100644
--- a/src/Kubernetes.Controller/Caching/IngressCache.cs
+++ b/src/Kubernetes.Controller/Caching/IngressCache.cs
@@ -32,18 +32,20 @@ public class IngressCache : ICache
 
     public IngressCache(IOptions<YarpOptions> options, IServerCertificateSelector certificateSelector, ICertificateHelper certificateHelper, ILogger<IngressCache> logger)
     {
-        _options = options?.Value ?? throw new ArgumentNullException(nameof(options));
-        _certificateSelector = certificateSelector ?? throw new ArgumentNullException(nameof(certificateSelector));
-        _certificateHelper = certificateHelper ?? throw new ArgumentNullException(nameof(certificateHelper));
-        _logger = logger ?? throw new ArgumentNullException(nameof(logger));
+        ArgumentNullException.ThrowIfNull(options?.Value);
+        ArgumentNullException.ThrowIfNull(certificateSelector);
+        ArgumentNullException.ThrowIfNull(certificateHelper);
+        ArgumentNullException.ThrowIfNull(logger);
+
+        _options = options.Value;
+        _certificateSelector = certificateSelector;
+        _certificateHelper = certificateHelper;
+        _logger = logger;
     }
 
     public void Update(WatchEventType eventType, V1IngressClass ingressClass)
     {
-        if (ingressClass is null)
-        {
-            throw new ArgumentNullException(nameof(ingressClass));
-        }
+        ArgumentNullException.ThrowIfNull(ingressClass);
 
         if (!string.Equals(_options.ControllerClass, ingressClass.Spec.Controller, StringComparison.OrdinalIgnoreCase))
         {
@@ -72,10 +74,7 @@ public void Update(WatchEventType eventType, V1IngressClass ingressClass)
 
     public bool Update(WatchEventType eventType, V1Ingress ingress)
     {
-        if (ingress is null)
-        {
-            throw new ArgumentNullException(nameof(ingress));
-        }
+        ArgumentNullException.ThrowIfNull(ingress);
 
         Namespace(ingress.Namespace()).Update(eventType, ingress);
         return true;
@@ -84,10 +83,7 @@ public bool Update(WatchEventType eventType, V1Ingress ingress)
 
     public ImmutableList<string> Update(WatchEventType eventType, V1Service service)
     {
-        if (service is null)
-        {
-            throw new ArgumentNullException(nameof(service));
-        }
+        ArgumentNullException.ThrowIfNull(service);
 
         return Namespace(service.Namespace()).Update(eventType, service);
     }
diff --git a/src/Kubernetes.Controller/Caching/IngressClassData.cs b/src/Kubernetes.Controller/Caching/IngressClassData.cs
index 6389561b7..a29690ac7 100644
--- a/src/Kubernetes.Controller/Caching/IngressClassData.cs
+++ b/src/Kubernetes.Controller/Caching/IngressClassData.cs
@@ -13,10 +13,7 @@ public struct IngressClassData
 {
     public IngressClassData(V1IngressClass ingressClass)
     {
-        if (ingressClass is null)
-        {
-            throw new ArgumentNullException(nameof(ingressClass));
-        }
+        ArgumentNullException.ThrowIfNull(ingressClass);
 
         IngressClass = ingressClass;
         IsDefault = GetDefaultAnnotation(ingressClass);
diff --git a/src/Kubernetes.Controller/Caching/IngressData.cs b/src/Kubernetes.Controller/Caching/IngressData.cs
index 73552b1d2..60869a435 100644
--- a/src/Kubernetes.Controller/Caching/IngressData.cs
+++ b/src/Kubernetes.Controller/Caching/IngressData.cs
@@ -13,10 +13,7 @@ public struct IngressData
 {
     public IngressData(V1Ingress ingress)
     {
-        if (ingress is null)
-        {
-            throw new ArgumentNullException(nameof(ingress));
-        }
+        ArgumentNullException.ThrowIfNull(ingress);
 
         Spec = ingress.Spec;
         Metadata = ingress.Metadata;
diff --git a/src/Kubernetes.Controller/Caching/NamespaceCache.cs b/src/Kubernetes.Controller/Caching/NamespaceCache.cs
index 35d69ab4e..b3af5a339 100644
--- a/src/Kubernetes.Controller/Caching/NamespaceCache.cs
+++ b/src/Kubernetes.Controller/Caching/NamespaceCache.cs
@@ -26,10 +26,7 @@ public class NamespaceCache
 
     public void Update(WatchEventType eventType, V1Ingress ingress)
     {
-        if (ingress is null)
-        {
-            throw new ArgumentNullException(nameof(ingress));
-        }
+        ArgumentNullException.ThrowIfNull(ingress);
 
         var serviceNames = ImmutableList<string>.Empty;
 
@@ -121,10 +118,7 @@ public void Update(WatchEventType eventType, V1Ingress ingress)
 
     public ImmutableList<string> Update(WatchEventType eventType, V1Service service)
     {
-        if (service is null)
-        {
-            throw new ArgumentNullException(nameof(service));
-        }
+        ArgumentNullException.ThrowIfNull(service);
 
         var serviceName = service.Name();
         lock (_sync)
@@ -151,10 +145,7 @@ public ImmutableList<string> Update(WatchEventType eventType, V1Service service)
 
     public void GetKeys(string ns, List<NamespacedName> keys)
     {
-        if (keys is null)
-        {
-            throw new ArgumentNullException(nameof(keys));
-        }
+        ArgumentNullException.ThrowIfNull(keys);
 
         lock (_sync)
         {
@@ -167,10 +158,7 @@ public void GetKeys(string ns, List<NamespacedName> keys)
 
     public ImmutableList<string> Update(WatchEventType eventType, V1Endpoints endpoints)
     {
-        if (endpoints is null)
-        {
-            throw new ArgumentNullException(nameof(endpoints));
-        }
+        ArgumentNullException.ThrowIfNull(endpoints);
 
         var serviceName = endpoints.Name();
         lock (_sync)
diff --git a/src/Kubernetes.Controller/Caching/ServiceData.cs b/src/Kubernetes.Controller/Caching/ServiceData.cs
index df087158c..fdb282ddf 100644
--- a/src/Kubernetes.Controller/Caching/ServiceData.cs
+++ b/src/Kubernetes.Controller/Caching/ServiceData.cs
@@ -13,10 +13,7 @@ public struct ServiceData
 {
     public ServiceData(V1Service service)
     {
-        if (service is null)
-        {
-            throw new ArgumentNullException(nameof(service));
-        }
+        ArgumentNullException.ThrowIfNull(service);
 
         Spec = service.Spec;
         Metadata = service.Metadata;
diff --git a/src/Kubernetes.Controller/Certificates/CertificateHelper.cs b/src/Kubernetes.Controller/Certificates/CertificateHelper.cs
index 8ea2bd4d2..1efdbb93b 100644
--- a/src/Kubernetes.Controller/Certificates/CertificateHelper.cs
+++ b/src/Kubernetes.Controller/Certificates/CertificateHelper.cs
@@ -19,7 +19,8 @@ public class CertificateHelper : ICertificateHelper
 
     public CertificateHelper(ILogger<CertificateHelper> logger)
     {
-        _logger = logger ?? throw new ArgumentNullException(nameof(logger));
+        ArgumentNullException.ThrowIfNull(logger);
+        _logger = logger;
     }
 
     public X509Certificate2 ConvertCertificate(NamespacedName namespacedName, V1Secret secret)
diff --git a/src/Kubernetes.Controller/Client/ResourceInformer.cs b/src/Kubernetes.Controller/Client/ResourceInformer.cs
index c39be15c5..d8b8c6124 100644
--- a/src/Kubernetes.Controller/Client/ResourceInformer.cs
+++ b/src/Kubernetes.Controller/Client/ResourceInformer.cs
@@ -54,8 +54,11 @@ public ResourceInformer(
         ILogger logger)
         : base(hostApplicationLifetime, logger)
     {
+        ArgumentNullException.ThrowIfNull(client);
+        ArgumentNullException.ThrowIfNull(selector);
+
         Client = client;
-        _selector = selector ?? throw new ArgumentNullException(nameof(selector));
+        _selector = selector;
         _names = GroupApiVersionKind.From<TResource>();
     }
 
diff --git a/src/Kubernetes.Controller/Client/V1IngressResourceStatusUpdater.cs b/src/Kubernetes.Controller/Client/V1IngressResourceStatusUpdater.cs
index eb3b92055..3a09c4b64 100644
--- a/src/Kubernetes.Controller/Client/V1IngressResourceStatusUpdater.cs
+++ b/src/Kubernetes.Controller/Client/V1IngressResourceStatusUpdater.cs
@@ -25,7 +25,8 @@ public V1IngressResourceStatusUpdater(
         ICache cache,
         ILogger<V1ServiceResourceInformer> logger)
     {
-        _options = options?.Value ?? throw new ArgumentNullException(nameof(options));
+        ArgumentNullException.ThrowIfNull(options?.Value);
+        _options = options.Value;
         _client = client;
         _cache = cache;
         _logger = logger;
diff --git a/src/Kubernetes.Controller/ConfigProvider/KubernetesConfigProvider.cs b/src/Kubernetes.Controller/ConfigProvider/KubernetesConfigProvider.cs
index 64b92bba8..d7b2ead1d 100644
--- a/src/Kubernetes.Controller/ConfigProvider/KubernetesConfigProvider.cs
+++ b/src/Kubernetes.Controller/ConfigProvider/KubernetesConfigProvider.cs
@@ -40,7 +40,8 @@ public MessageConfig(IReadOnlyList<RouteConfig> routes, IReadOnlyList<ClusterCon
 
         public MessageConfig(IReadOnlyList<RouteConfig> routes, IReadOnlyList<ClusterConfig> clusters, string revisionId)
         {
-            RevisionId = revisionId ?? throw new ArgumentNullException(nameof(revisionId));
+            ArgumentNullException.ThrowIfNull(revisionId);
+            RevisionId = revisionId;
             Routes = routes;
             Clusters = clusters;
             ChangeToken = new CancellationChangeToken(_cts.Token);
diff --git a/src/Kubernetes.Controller/Hosting/BackgroundHostedService.cs b/src/Kubernetes.Controller/Hosting/BackgroundHostedService.cs
index 8a5336593..385248ad8 100644
--- a/src/Kubernetes.Controller/Hosting/BackgroundHostedService.cs
+++ b/src/Kubernetes.Controller/Hosting/BackgroundHostedService.cs
@@ -35,8 +35,10 @@ protected BackgroundHostedService(
         IHostApplicationLifetime hostApplicationLifetime,
         ILogger logger)
     {
-        _hostApplicationLifetime = hostApplicationLifetime ?? throw new ArgumentNullException(nameof(hostApplicationLifetime));
-        Logger = logger ?? throw new ArgumentNullException(nameof(logger));
+        ArgumentNullException.ThrowIfNull(hostApplicationLifetime);
+        ArgumentNullException.ThrowIfNull(logger);
+        _hostApplicationLifetime = hostApplicationLifetime;
+        Logger = logger;
 
         // register the stoppingToken to become cancelled as soon as the
         // shutdown sequence is initiated.
diff --git a/src/Kubernetes.Controller/NamespacedName.cs b/src/Kubernetes.Controller/NamespacedName.cs
index e046e9f8b..f410aaca5 100644
--- a/src/Kubernetes.Controller/NamespacedName.cs
+++ b/src/Kubernetes.Controller/NamespacedName.cs
@@ -80,10 +80,7 @@ public NamespacedName(string name)
     /// <returns>NamespacedName.</returns>
     public static NamespacedName From(IKubernetesObject<V1ObjectMeta> resource)
     {
-        if (resource is null)
-        {
-            throw new ArgumentNullException(nameof(resource));
-        }
+        ArgumentNullException.ThrowIfNull(resource);
 
         return new NamespacedName(resource.Namespace(), resource.Name());
     }
@@ -97,8 +94,8 @@ public static NamespacedName From(IKubernetesObject<V1ObjectMeta> resource)
     /// <returns>NamespacedName.</returns>
     public static NamespacedName From(V1ObjectMeta metadata, [NotNull] V1OwnerReference ownerReference, bool? clusterScoped = null)
     {
-        _ = metadata ?? throw new ArgumentNullException(nameof(metadata));
-        _ = ownerReference ?? throw new ArgumentNullException(nameof(ownerReference));
+        ArgumentNullException.ThrowIfNull(metadata);
+        ArgumentNullException.ThrowIfNull(ownerReference);
 
         return new NamespacedName(
             clusterScoped ?? false ? null : metadata.NamespaceProperty,
diff --git a/src/Kubernetes.Controller/Protocol/DispatchActionResult.cs b/src/Kubernetes.Controller/Protocol/DispatchActionResult.cs
index 76a5893ef..771b182a1 100644
--- a/src/Kubernetes.Controller/Protocol/DispatchActionResult.cs
+++ b/src/Kubernetes.Controller/Protocol/DispatchActionResult.cs
@@ -38,10 +38,7 @@ public override string ToString()
 
     public async Task ExecuteResultAsync(ActionContext context)
     {
-        if (context is null)
-        {
-            throw new ArgumentNullException(nameof(context));
-        }
+        ArgumentNullException.ThrowIfNull(context);
 
         var cancellationToken = context.HttpContext.RequestAborted;
 
diff --git a/src/Kubernetes.Controller/Protocol/DispatchConfigProvider.cs b/src/Kubernetes.Controller/Protocol/DispatchConfigProvider.cs
index d70f55eda..000c8e403 100644
--- a/src/Kubernetes.Controller/Protocol/DispatchConfigProvider.cs
+++ b/src/Kubernetes.Controller/Protocol/DispatchConfigProvider.cs
@@ -20,7 +20,8 @@ public class DispatchConfigProvider : IUpdateConfig
 
     public DispatchConfigProvider(IDispatcher dispatcher)
     {
-        _dispatcher = dispatcher ?? throw new ArgumentNullException(nameof(dispatcher));
+        ArgumentNullException.ThrowIfNull(dispatcher);
+        _dispatcher = dispatcher;
     }
 
     public async Task UpdateAsync(IReadOnlyList<RouteConfig> routes, IReadOnlyList<ClusterConfig> clusters, CancellationToken cancellationToken)
diff --git a/src/Kubernetes.Controller/Protocol/MessageConfigProviderExtensions.cs b/src/Kubernetes.Controller/Protocol/MessageConfigProviderExtensions.cs
index afed0444d..15be70670 100644
--- a/src/Kubernetes.Controller/Protocol/MessageConfigProviderExtensions.cs
+++ b/src/Kubernetes.Controller/Protocol/MessageConfigProviderExtensions.cs
@@ -12,10 +12,7 @@ public static class MessageConfigProviderExtensions
 {
     public static IReverseProxyBuilder LoadFromMessages(this IReverseProxyBuilder builder)
     {
-        if (builder is null)
-        {
-            throw new ArgumentNullException(nameof(builder));
-        }
+        ArgumentNullException.ThrowIfNull(builder);
 
         var provider = new KubernetesConfigProvider();
         builder.Services.AddSingleton<IProxyConfigProvider>(provider);
diff --git a/src/Kubernetes.Controller/Protocol/Receiver.cs b/src/Kubernetes.Controller/Protocol/Receiver.cs
index 1b1af04e7..46830002a 100644
--- a/src/Kubernetes.Controller/Protocol/Receiver.cs
+++ b/src/Kubernetes.Controller/Protocol/Receiver.cs
@@ -28,10 +28,7 @@ public Receiver(
         ILogger<Receiver> logger,
         IUpdateConfig proxyConfigProvider) : base(hostApplicationLifetime, logger)
     {
-        if (options is null)
-        {
-            throw new ArgumentNullException(nameof(options));
-        }
+        ArgumentNullException.ThrowIfNull(options);
 
         _options = options.Value;
 
diff --git a/src/Kubernetes.Controller/Services/IngressController.cs b/src/Kubernetes.Controller/Services/IngressController.cs
index b3e11ac9e..4f76cbccc 100644
--- a/src/Kubernetes.Controller/Services/IngressController.cs
+++ b/src/Kubernetes.Controller/Services/IngressController.cs
@@ -83,8 +83,11 @@ public IngressController(
 
         _queue = new ProcessingRateLimitedQueue<QueueItem>(perSecond: 0.5, burst: 1);
 
-        _cache = cache ?? throw new ArgumentNullException(nameof(cache));
-        _reconciler = reconciler ?? throw new ArgumentNullException(nameof(reconciler));
+        ArgumentNullException.ThrowIfNull(cache);
+        ArgumentNullException.ThrowIfNull(reconciler);
+
+        _cache = cache;
+        _reconciler = reconciler;
 
         _ingressChangeQueueItem = new QueueItem("Ingress Change");
     }
diff --git a/src/Kubernetes.Controller/Services/Reconciler.cs b/src/Kubernetes.Controller/Services/Reconciler.cs
index f0537071c..a5302537f 100644
--- a/src/Kubernetes.Controller/Services/Reconciler.cs
+++ b/src/Kubernetes.Controller/Services/Reconciler.cs
@@ -27,9 +27,13 @@ public partial class Reconciler : IReconciler
 
     public Reconciler(ICache cache, IUpdateConfig updateConfig, IIngressResourceStatusUpdater ingressResourceStatusUpdater, ILogger<Reconciler> logger)
     {
-        _cache = cache ?? throw new ArgumentNullException(nameof(cache));
-        _updateConfig = updateConfig ?? throw new ArgumentNullException(nameof(updateConfig));
-        _ingressResourceStatusUpdater = ingressResourceStatusUpdater ?? throw new ArgumentNullException(nameof(ingressResourceStatusUpdater));
+        ArgumentNullException.ThrowIfNull(cache);
+        ArgumentNullException.ThrowIfNull(updateConfig);
+        ArgumentNullException.ThrowIfNull(ingressResourceStatusUpdater);
+
+        _cache = cache;
+        _updateConfig = updateConfig;
+        _ingressResourceStatusUpdater = ingressResourceStatusUpdater;
         _logger = logger;
     }
 
diff --git a/src/ReverseProxy/Configuration/ClusterValidators/HealthCheckValidator.cs b/src/ReverseProxy/Configuration/ClusterValidators/HealthCheckValidator.cs
index 375286b4b..b80a704f1 100644
--- a/src/ReverseProxy/Configuration/ClusterValidators/HealthCheckValidator.cs
+++ b/src/ReverseProxy/Configuration/ClusterValidators/HealthCheckValidator.cs
@@ -20,9 +20,13 @@ public HealthCheckValidator(IEnumerable<IAvailableDestinationsPolicy> availableD
         IEnumerable<IActiveHealthCheckPolicy> activeHealthCheckPolicies,
         IEnumerable<IPassiveHealthCheckPolicy> passiveHealthCheckPolicies)
     {
-        _availableDestinationsPolicies = availableDestinationsPolicies?.ToDictionaryByUniqueId(p => p.Name) ?? throw new ArgumentNullException(nameof(availableDestinationsPolicies));
-        _activeHealthCheckPolicies = activeHealthCheckPolicies?.ToDictionaryByUniqueId(p => p.Name) ?? throw new ArgumentNullException(nameof(availableDestinationsPolicies));
-        _passiveHealthCheckPolicies = passiveHealthCheckPolicies?.ToDictionaryByUniqueId(p => p.Name) ?? throw new ArgumentNullException(nameof(availableDestinationsPolicies));
+        ArgumentNullException.ThrowIfNull(availableDestinationsPolicies);
+        ArgumentNullException.ThrowIfNull(activeHealthCheckPolicies);
+        ArgumentNullException.ThrowIfNull(passiveHealthCheckPolicies);
+
+        _availableDestinationsPolicies = availableDestinationsPolicies.ToDictionaryByUniqueId(p => p.Name);
+        _activeHealthCheckPolicies = activeHealthCheckPolicies.ToDictionaryByUniqueId(p => p.Name);
+        _passiveHealthCheckPolicies = passiveHealthCheckPolicies.ToDictionaryByUniqueId(p => p.Name);
     }
 
     public ValueTask ValidateAsync(ClusterConfig cluster, IList<Exception> errors)
diff --git a/src/ReverseProxy/Configuration/ClusterValidators/LoadBalancingValidator.cs b/src/ReverseProxy/Configuration/ClusterValidators/LoadBalancingValidator.cs
index 0a575b435..296452eee 100644
--- a/src/ReverseProxy/Configuration/ClusterValidators/LoadBalancingValidator.cs
+++ b/src/ReverseProxy/Configuration/ClusterValidators/LoadBalancingValidator.cs
@@ -15,7 +15,8 @@ internal sealed class LoadBalancingValidator : IClusterValidator
     private readonly FrozenDictionary<string, ILoadBalancingPolicy> _loadBalancingPolicies;
     public LoadBalancingValidator(IEnumerable<ILoadBalancingPolicy> loadBalancingPolicies)
     {
-        _loadBalancingPolicies = loadBalancingPolicies?.ToDictionaryByUniqueId(p => p.Name) ?? throw new ArgumentNullException(nameof(loadBalancingPolicies));
+        ArgumentNullException.ThrowIfNull(loadBalancingPolicies);
+        _loadBalancingPolicies = loadBalancingPolicies.ToDictionaryByUniqueId(p => p.Name);
     }
 
     public ValueTask ValidateAsync(ClusterConfig cluster, IList<Exception> errors)
diff --git a/src/ReverseProxy/Configuration/ClusterValidators/SessionAffinityValidator.cs b/src/ReverseProxy/Configuration/ClusterValidators/SessionAffinityValidator.cs
index 4402dcd7e..f814efb56 100644
--- a/src/ReverseProxy/Configuration/ClusterValidators/SessionAffinityValidator.cs
+++ b/src/ReverseProxy/Configuration/ClusterValidators/SessionAffinityValidator.cs
@@ -16,7 +16,8 @@ internal sealed class SessionAffinityValidator : IClusterValidator
 
     public SessionAffinityValidator(IEnumerable<IAffinityFailurePolicy> affinityFailurePolicies)
     {
-        _affinityFailurePolicies = affinityFailurePolicies?.ToDictionaryByUniqueId(p => p.Name) ?? throw new ArgumentNullException(nameof(affinityFailurePolicies));
+        ArgumentNullException.ThrowIfNull(affinityFailurePolicies);
+        _affinityFailurePolicies = affinityFailurePolicies.ToDictionaryByUniqueId(p => p.Name);
     }
 
     public ValueTask ValidateAsync(ClusterConfig cluster, IList<Exception> errors)
diff --git a/src/ReverseProxy/Configuration/ConfigProvider/ConfigurationConfigProvider.cs b/src/ReverseProxy/Configuration/ConfigProvider/ConfigurationConfigProvider.cs
index a3c6c7dee..85e52c2bf 100644
--- a/src/ReverseProxy/Configuration/ConfigProvider/ConfigurationConfigProvider.cs
+++ b/src/ReverseProxy/Configuration/ConfigProvider/ConfigurationConfigProvider.cs
@@ -35,8 +35,10 @@ public ConfigurationConfigProvider(
         ILogger<ConfigurationConfigProvider> logger,
         IConfiguration configuration)
     {
-        _logger = logger ?? throw new ArgumentNullException(nameof(logger));
-        _configuration = configuration ?? throw new ArgumentNullException(nameof(configuration));
+        ArgumentNullException.ThrowIfNull(logger);
+        ArgumentNullException.ThrowIfNull(configuration);
+        _logger = logger;
+        _configuration = configuration;
     }
 
     public void Dispose()
diff --git a/src/ReverseProxy/Configuration/ConfigValidator.cs b/src/ReverseProxy/Configuration/ConfigValidator.cs
index 8df4334d2..16bc895e5 100644
--- a/src/ReverseProxy/Configuration/ConfigValidator.cs
+++ b/src/ReverseProxy/Configuration/ConfigValidator.cs
@@ -21,15 +21,19 @@ public ConfigValidator(ITransformBuilder transformBuilder,
         IEnumerable<IRouteValidator> routeValidators,
         IEnumerable<IClusterValidator> clusterValidators)
     {
-        _transformBuilder = transformBuilder ?? throw new ArgumentNullException(nameof(transformBuilder));
-        _routeValidators = routeValidators?.ToArray() ?? throw new ArgumentNullException(nameof(routeValidators));
-        _clusterValidators = clusterValidators?.ToArray() ?? throw new ArgumentNullException(nameof(clusterValidators));
+        ArgumentNullException.ThrowIfNull(transformBuilder);
+        ArgumentNullException.ThrowIfNull(routeValidators);
+        ArgumentNullException.ThrowIfNull(clusterValidators);
+
+        _transformBuilder = transformBuilder;
+        _routeValidators = routeValidators.ToArray();
+        _clusterValidators = clusterValidators.ToArray();
     }
 
     // Note this performs all validation steps without short-circuiting in order to report all possible errors.
     public async ValueTask<IList<Exception>> ValidateRouteAsync(RouteConfig route)
     {
-        _ = route ?? throw new ArgumentNullException(nameof(route));
+        ArgumentNullException.ThrowIfNull(route);
         var errors = new List<Exception>();
 
         if (string.IsNullOrEmpty(route.RouteId))
@@ -61,7 +65,8 @@ public async ValueTask<IList<Exception>> ValidateRouteAsync(RouteConfig route)
     // Note this performs all validation steps without short-circuiting in order to report all possible errors.
     public async ValueTask<IList<Exception>> ValidateClusterAsync(ClusterConfig cluster)
     {
-        _ = cluster ?? throw new ArgumentNullException(nameof(cluster));
+        ArgumentNullException.ThrowIfNull(cluster);
+
         var errors = new List<Exception>();
 
         if (string.IsNullOrEmpty(cluster.ClusterId))
diff --git a/src/ReverseProxy/Configuration/IYarpOutputCachePolicyProvider.cs b/src/ReverseProxy/Configuration/IYarpOutputCachePolicyProvider.cs
index def89df61..783a1aa32 100644
--- a/src/ReverseProxy/Configuration/IYarpOutputCachePolicyProvider.cs
+++ b/src/ReverseProxy/Configuration/IYarpOutputCachePolicyProvider.cs
@@ -31,7 +31,8 @@ internal sealed class YarpOutputCachePolicyProvider : IYarpOutputCachePolicyProv
 
     public YarpOutputCachePolicyProvider(IOptions<OutputCacheOptions> outputCacheOptions)
     {
-        _outputCacheOptions = outputCacheOptions?.Value ?? throw new ArgumentNullException(nameof(outputCacheOptions));
+        ArgumentNullException.ThrowIfNull(outputCacheOptions?.Value);
+        _outputCacheOptions = outputCacheOptions.Value;
 
         var property = s_OutputCacheOptionsType.GetProperty("NamedPolicies", BindingFlags.Instance | BindingFlags.NonPublic);
         if (property == null || !typeof(IDictionary).IsAssignableFrom(property.PropertyType))
diff --git a/src/ReverseProxy/Configuration/IYarpRateLimiterPolicyProvider.cs b/src/ReverseProxy/Configuration/IYarpRateLimiterPolicyProvider.cs
index d45ac0297..f71e88c04 100644
--- a/src/ReverseProxy/Configuration/IYarpRateLimiterPolicyProvider.cs
+++ b/src/ReverseProxy/Configuration/IYarpRateLimiterPolicyProvider.cs
@@ -26,7 +26,8 @@ internal sealed class YarpRateLimiterPolicyProvider : IYarpRateLimiterPolicyProv
 
     public YarpRateLimiterPolicyProvider(IOptions<RateLimiterOptions> rateLimiterOptions)
     {
-        _rateLimiterOptions = rateLimiterOptions?.Value ?? throw new ArgumentNullException(nameof(rateLimiterOptions));
+        ArgumentNullException.ThrowIfNull(rateLimiterOptions?.Value);
+        _rateLimiterOptions = rateLimiterOptions.Value;
 
         var type = typeof(RateLimiterOptions);
         var flags = BindingFlags.Instance | BindingFlags.NonPublic;
diff --git a/src/ReverseProxy/Configuration/InMemoryConfigProvider.cs b/src/ReverseProxy/Configuration/InMemoryConfigProvider.cs
index 163d5cdab..71e924b5b 100644
--- a/src/ReverseProxy/Configuration/InMemoryConfigProvider.cs
+++ b/src/ReverseProxy/Configuration/InMemoryConfigProvider.cs
@@ -75,7 +75,8 @@ public InMemoryConfig(IReadOnlyList<RouteConfig> routes, IReadOnlyList<ClusterCo
 
         public InMemoryConfig(IReadOnlyList<RouteConfig> routes, IReadOnlyList<ClusterConfig> clusters, string revisionId)
         {
-            RevisionId = revisionId ?? throw new ArgumentNullException(nameof(revisionId));
+            ArgumentNullException.ThrowIfNull(revisionId);
+            RevisionId = revisionId;
             Routes = routes;
             Clusters = clusters;
             ChangeToken = new CancellationChangeToken(_cts.Token);
diff --git a/src/ReverseProxy/Delegation/HttpSysDelegator.cs b/src/ReverseProxy/Delegation/HttpSysDelegator.cs
index 908a74bb5..f5157086a 100644
--- a/src/ReverseProxy/Delegation/HttpSysDelegator.cs
+++ b/src/ReverseProxy/Delegation/HttpSysDelegator.cs
@@ -30,7 +30,8 @@ public HttpSysDelegator(
             IServer server,
             ILogger<HttpSysDelegator> logger)
     {
-        _logger = logger ?? throw new ArgumentNullException(nameof(logger));
+        ArgumentNullException.ThrowIfNull(logger);
+        _logger = logger;
 
         // IServerDelegationFeature isn't added to DI https://github.com/dotnet/aspnetcore/issues/40043
         // IServerDelegationFeature may not be set if not http.sys server or the OS doesn't support delegation
@@ -55,8 +56,8 @@ public void ResetQueue(string queueName, string urlPrefix)
 
     public void DelegateRequest(HttpContext context, DestinationState destination)
     {
-        _ = context ?? throw new ArgumentNullException(nameof(context));
-        _ = destination ?? throw new ArgumentNullException(nameof(destination));
+        ArgumentNullException.ThrowIfNull(context);
+        ArgumentNullException.ThrowIfNull(destination);
 
         var requestDelegationFeature = context.Features.Get<IHttpSysRequestDelegationFeature>()
                     ?? throw new InvalidOperationException($"{typeof(IHttpSysRequestDelegationFeature).FullName} is missing.");
diff --git a/src/ReverseProxy/Delegation/HttpSysDelegatorMiddleware.cs b/src/ReverseProxy/Delegation/HttpSysDelegatorMiddleware.cs
index c82e0c62a..1a080b419 100644
--- a/src/ReverseProxy/Delegation/HttpSysDelegatorMiddleware.cs
+++ b/src/ReverseProxy/Delegation/HttpSysDelegatorMiddleware.cs
@@ -24,15 +24,20 @@ public HttpSysDelegatorMiddleware(
         HttpSysDelegator delegator,
         IRandomFactory randomFactory)
     {
-        _next = next ?? throw new ArgumentNullException(nameof(next));
-        _logger = logger ?? throw new ArgumentNullException(nameof(logger));
-        _delegator = delegator ?? throw new ArgumentNullException(nameof(delegator));
-        _randomFactory = randomFactory ?? throw new ArgumentNullException(nameof(randomFactory));
+        ArgumentNullException.ThrowIfNull(next);
+        ArgumentNullException.ThrowIfNull(logger);
+        ArgumentNullException.ThrowIfNull(delegator);
+        ArgumentNullException.ThrowIfNull(randomFactory);
+        _next = next;
+        _logger = logger;
+        _delegator = delegator;
+        _randomFactory = randomFactory;
     }
 
     public Task Invoke(HttpContext context)
     {
-        _ = context ?? throw new ArgumentNullException(nameof(context));
+        ArgumentNullException.ThrowIfNull(context);
+        
         var reverseProxyFeature = context.GetReverseProxyFeature();
         var destinations = reverseProxyFeature.AvailableDestinations
             ?? throw new InvalidOperationException($"The {nameof(IReverseProxyFeature)} Destinations collection was not set.");
diff --git a/src/ReverseProxy/Forwarder/CallbackHttpClientFactory.cs b/src/ReverseProxy/Forwarder/CallbackHttpClientFactory.cs
index 574d859e4..fdb33809f 100644
--- a/src/ReverseProxy/Forwarder/CallbackHttpClientFactory.cs
+++ b/src/ReverseProxy/Forwarder/CallbackHttpClientFactory.cs
@@ -14,7 +14,8 @@ internal sealed class CallbackHttpClientFactory : ForwarderHttpClientFactory
     internal CallbackHttpClientFactory(ILogger<ForwarderHttpClientFactory> logger,
         Action<ForwarderHttpClientContext, SocketsHttpHandler> configureClient) : base(logger)
     {
-        _configureClient = configureClient ?? throw new ArgumentNullException(nameof(configureClient));
+        ArgumentNullException.ThrowIfNull(configureClient);
+        _configureClient = configureClient;
     }
 
     protected override void ConfigureHandler(ForwarderHttpClientContext context, SocketsHttpHandler handler)
diff --git a/src/ReverseProxy/Forwarder/ForwarderHttpClientFactory.cs b/src/ReverseProxy/Forwarder/ForwarderHttpClientFactory.cs
index ef330c10f..77f0ea253 100644
--- a/src/ReverseProxy/Forwarder/ForwarderHttpClientFactory.cs
+++ b/src/ReverseProxy/Forwarder/ForwarderHttpClientFactory.cs
@@ -29,7 +29,8 @@ public ForwarderHttpClientFactory() : this(NullLogger<ForwarderHttpClientFactory
     /// </summary>
     public ForwarderHttpClientFactory(ILogger<ForwarderHttpClientFactory> logger)
     {
-        _logger = logger ?? throw new ArgumentNullException(nameof(logger));
+        ArgumentNullException.ThrowIfNull(logger);
+        _logger = logger;
     }
 
     /// <inheritdoc/>
diff --git a/src/ReverseProxy/Forwarder/ForwarderMiddleware.cs b/src/ReverseProxy/Forwarder/ForwarderMiddleware.cs
index af90eb65c..74949ddd6 100644
--- a/src/ReverseProxy/Forwarder/ForwarderMiddleware.cs
+++ b/src/ReverseProxy/Forwarder/ForwarderMiddleware.cs
@@ -23,16 +23,21 @@ internal sealed class ForwarderMiddleware
 
     public ForwarderMiddleware(RequestDelegate next, ILogger<ForwarderMiddleware> logger, IHttpForwarder forwarder, IRandomFactory randomFactory)
     {
-        _next = next ?? throw new ArgumentNullException(nameof(next));
-        _logger = logger ?? throw new ArgumentNullException(nameof(logger));
-        _forwarder = forwarder ?? throw new ArgumentNullException(nameof(forwarder));
-        _randomFactory = randomFactory ?? throw new ArgumentNullException(nameof(randomFactory));
+        ArgumentNullException.ThrowIfNull(next);
+        ArgumentNullException.ThrowIfNull(logger);
+        ArgumentNullException.ThrowIfNull(forwarder);
+        ArgumentNullException.ThrowIfNull(randomFactory);
+        _next = next;
+        _logger = logger;
+        _forwarder = forwarder;
+        _randomFactory = randomFactory;
     }
 
     /// <inheritdoc/>
     public async Task Invoke(HttpContext context)
     {
-        _ = context ?? throw new ArgumentNullException(nameof(context));
+        ArgumentNullException.ThrowIfNull(context);
+        
 
         var reverseProxyFeature = context.GetReverseProxyFeature();
         var destinations = reverseProxyFeature.AvailableDestinations
diff --git a/src/ReverseProxy/Forwarder/HttpForwarder.cs b/src/ReverseProxy/Forwarder/HttpForwarder.cs
index 93e2f55fa..923ce6575 100644
--- a/src/ReverseProxy/Forwarder/HttpForwarder.cs
+++ b/src/ReverseProxy/Forwarder/HttpForwarder.cs
@@ -33,8 +33,11 @@ internal sealed class HttpForwarder : IHttpForwarder
 
     public HttpForwarder(ILogger<HttpForwarder> logger, TimeProvider timeProvider)
     {
-        _logger = logger ?? throw new ArgumentNullException(nameof(logger));
-        _timeProvider = timeProvider ?? throw new ArgumentNullException(nameof(timeProvider));
+        ArgumentNullException.ThrowIfNull(logger);
+        ArgumentNullException.ThrowIfNull(timeProvider);
+
+        _logger = logger;
+        _timeProvider = timeProvider;
     }
 
     /// <summary>
@@ -98,11 +101,11 @@ public async ValueTask<ForwarderError> SendAsync(
         HttpTransformer transformer,
         CancellationToken cancellationToken)
     {
-        _ = context ?? throw new ArgumentNullException(nameof(context));
-        _ = destinationPrefix ?? throw new ArgumentNullException(nameof(destinationPrefix));
-        _ = httpClient ?? throw new ArgumentNullException(nameof(httpClient));
-        _ = requestConfig ?? throw new ArgumentNullException(nameof(requestConfig));
-        _ = transformer ?? throw new ArgumentNullException(nameof(transformer));
+        ArgumentNullException.ThrowIfNull(context);
+        ArgumentNullException.ThrowIfNull(destinationPrefix);
+        ArgumentNullException.ThrowIfNull(httpClient);
+        ArgumentNullException.ThrowIfNull(requestConfig);
+        ArgumentNullException.ThrowIfNull(transformer);
 
         if (RequestUtilities.IsResponseSet(context.Response))
         {
diff --git a/src/ReverseProxy/Forwarder/IHttpForwarderExtensions.cs b/src/ReverseProxy/Forwarder/IHttpForwarderExtensions.cs
index de43ca21e..259291285 100644
--- a/src/ReverseProxy/Forwarder/IHttpForwarderExtensions.cs
+++ b/src/ReverseProxy/Forwarder/IHttpForwarderExtensions.cs
@@ -24,10 +24,7 @@ public static class IHttpForwarderExtensions
     public static ValueTask<ForwarderError> SendAsync(this IHttpForwarder forwarder, HttpContext context, string destinationPrefix,
         HttpMessageInvoker httpClient)
     {
-        if (forwarder is null)
-        {
-            throw new ArgumentNullException(nameof(forwarder));
-        }
+        ArgumentNullException.ThrowIfNull(forwarder);
 
         return forwarder.SendAsync(context, destinationPrefix, httpClient, ForwarderRequestConfig.Empty, HttpTransformer.Default);
     }
@@ -44,10 +41,7 @@ public static ValueTask<ForwarderError> SendAsync(this IHttpForwarder forwarder,
     public static ValueTask<ForwarderError> SendAsync(this IHttpForwarder forwarder, HttpContext context, string destinationPrefix,
         HttpMessageInvoker httpClient, ForwarderRequestConfig requestConfig)
     {
-        if (forwarder is null)
-        {
-            throw new ArgumentNullException(nameof(forwarder));
-        }
+        ArgumentNullException.ThrowIfNull(forwarder);
 
         return forwarder.SendAsync(context, destinationPrefix, httpClient, requestConfig, HttpTransformer.Default);
     }
diff --git a/src/ReverseProxy/Forwarder/ReverseProxyPropagator.cs b/src/ReverseProxy/Forwarder/ReverseProxyPropagator.cs
index b6b665512..0a1e0429e 100644
--- a/src/ReverseProxy/Forwarder/ReverseProxyPropagator.cs
+++ b/src/ReverseProxy/Forwarder/ReverseProxyPropagator.cs
@@ -22,7 +22,8 @@ public sealed class ReverseProxyPropagator : DistributedContextPropagator
     /// </summary>
     public ReverseProxyPropagator(DistributedContextPropagator innerPropagator)
     {
-        _innerPropagator = innerPropagator ?? throw new ArgumentNullException(nameof(innerPropagator));
+        ArgumentNullException.ThrowIfNull(innerPropagator);
+        _innerPropagator = innerPropagator;
         _headersToRemove = _innerPropagator.Fields.ToArray();
     }
 
diff --git a/src/ReverseProxy/Forwarder/StreamCopier.cs b/src/ReverseProxy/Forwarder/StreamCopier.cs
index a685f4114..82134018d 100644
--- a/src/ReverseProxy/Forwarder/StreamCopier.cs
+++ b/src/ReverseProxy/Forwarder/StreamCopier.cs
@@ -158,8 +158,10 @@ private sealed class StreamCopierTelemetry
 
         public StreamCopierTelemetry(bool isRequest, TimeProvider timeProvider)
         {
+            ArgumentNullException.ThrowIfNull(timeProvider);
+
             _isRequest = isRequest;
-            _timeProvider = timeProvider ?? throw new ArgumentNullException(nameof(timeProvider));
+            _timeProvider = timeProvider;
             _firstReadTime = -1;
 
             ForwarderTelemetry.Log.ForwarderStage(isRequest ? ForwarderStage.RequestContentTransferStart : ForwarderStage.ResponseContentTransferStart);
diff --git a/src/ReverseProxy/Forwarder/StreamCopyHttpContent.cs b/src/ReverseProxy/Forwarder/StreamCopyHttpContent.cs
index 334ac570b..220bda380 100644
--- a/src/ReverseProxy/Forwarder/StreamCopyHttpContent.cs
+++ b/src/ReverseProxy/Forwarder/StreamCopyHttpContent.cs
@@ -54,9 +54,12 @@ internal sealed class StreamCopyHttpContent : HttpContent
 
     public StreamCopyHttpContent(HttpContext context, bool isStreamingRequest, TimeProvider timeProvider, ILogger logger, ActivityCancellationTokenSource activityToken)
     {
-        _context = context ?? throw new ArgumentNullException(nameof(context));
+        ArgumentNullException.ThrowIfNull(context);
+        ArgumentNullException.ThrowIfNull(timeProvider);
+
+        _context = context;
         _isStreamingRequest = isStreamingRequest;
-        _timeProvider = timeProvider ?? throw new ArgumentNullException(nameof(timeProvider));
+        _timeProvider = timeProvider;
         _logger = logger;
         _activityToken = activityToken;
     }
diff --git a/src/ReverseProxy/Health/ActiveHealthCheckMonitor.cs b/src/ReverseProxy/Health/ActiveHealthCheckMonitor.cs
index 40382d7f9..6e34e8c36 100644
--- a/src/ReverseProxy/Health/ActiveHealthCheckMonitor.cs
+++ b/src/ReverseProxy/Health/ActiveHealthCheckMonitor.cs
@@ -29,10 +29,15 @@ public ActiveHealthCheckMonitor(
         TimeProvider timeProvider,
         ILogger<ActiveHealthCheckMonitor> logger)
     {
-        _monitorOptions = monitorOptions?.Value ?? throw new ArgumentNullException(nameof(monitorOptions));
-        _policies = policies?.ToDictionaryByUniqueId(p => p.Name) ?? throw new ArgumentNullException(nameof(policies));
-        _probingRequestFactory = probingRequestFactory ?? throw new ArgumentNullException(nameof(probingRequestFactory));
-        _logger = logger ?? throw new ArgumentNullException(nameof(logger));
+        ArgumentNullException.ThrowIfNull(monitorOptions?.Value);
+        ArgumentNullException.ThrowIfNull(policies);
+        ArgumentNullException.ThrowIfNull(probingRequestFactory);
+        ArgumentNullException.ThrowIfNull(logger);
+
+        _monitorOptions = monitorOptions.Value;
+        _policies = policies.ToDictionaryByUniqueId(p => p.Name);
+        _probingRequestFactory = probingRequestFactory;
+        _logger = logger;
         Scheduler = new EntityActionScheduler<ClusterState>(cluster => ProbeCluster(cluster), autoStart: false, runOnce: false, timeProvider);
     }
 
diff --git a/src/ReverseProxy/Health/ClusterDestinationsUpdater.cs b/src/ReverseProxy/Health/ClusterDestinationsUpdater.cs
index 237c2eccb..288792e68 100644
--- a/src/ReverseProxy/Health/ClusterDestinationsUpdater.cs
+++ b/src/ReverseProxy/Health/ClusterDestinationsUpdater.cs
@@ -18,7 +18,8 @@ internal sealed class ClusterDestinationsUpdater : IClusterDestinationsUpdater
 
     public ClusterDestinationsUpdater(IEnumerable<IAvailableDestinationsPolicy> destinationPolicies)
     {
-        _destinationPolicies = destinationPolicies?.ToDictionaryByUniqueId(p => p.Name) ?? throw new ArgumentNullException(nameof(destinationPolicies));
+        ArgumentNullException.ThrowIfNull(destinationPolicies);
+        _destinationPolicies = destinationPolicies.ToDictionaryByUniqueId(p => p.Name);
     }
 
     public void UpdateAvailableDestinations(ClusterState cluster)
diff --git a/src/ReverseProxy/Health/ConsecutiveFailuresHealthPolicy.cs b/src/ReverseProxy/Health/ConsecutiveFailuresHealthPolicy.cs
index da8258e63..7ab059b6d 100644
--- a/src/ReverseProxy/Health/ConsecutiveFailuresHealthPolicy.cs
+++ b/src/ReverseProxy/Health/ConsecutiveFailuresHealthPolicy.cs
@@ -23,8 +23,10 @@ internal sealed class ConsecutiveFailuresHealthPolicy : IActiveHealthCheckPolicy
 
     public ConsecutiveFailuresHealthPolicy(IOptions<ConsecutiveFailuresHealthPolicyOptions> options, IDestinationHealthUpdater healthUpdater)
     {
-        _options = options?.Value ?? throw new ArgumentNullException(nameof(options));
-        _healthUpdater = healthUpdater ?? throw new ArgumentNullException(nameof(healthUpdater));
+        ArgumentNullException.ThrowIfNull(options?.Value);
+        ArgumentNullException.ThrowIfNull(healthUpdater);
+        _options = options.Value;
+        _healthUpdater = healthUpdater;
     }
 
     public void ProbingCompleted(ClusterState cluster, IReadOnlyList<DestinationProbingResult> probingResults)
diff --git a/src/ReverseProxy/Health/DestinationHealthUpdater.cs b/src/ReverseProxy/Health/DestinationHealthUpdater.cs
index 497a21aca..39080015c 100644
--- a/src/ReverseProxy/Health/DestinationHealthUpdater.cs
+++ b/src/ReverseProxy/Health/DestinationHealthUpdater.cs
@@ -21,9 +21,12 @@ public DestinationHealthUpdater(
         IClusterDestinationsUpdater clusterDestinationsUpdater,
         ILogger<DestinationHealthUpdater> logger)
     {
+        ArgumentNullException.ThrowIfNull(clusterDestinationsUpdater);
+        ArgumentNullException.ThrowIfNull(logger);
+
         _scheduler = new EntityActionScheduler<(ClusterState Cluster, DestinationState Destination)>(d => Reactivate(d.Cluster, d.Destination), autoStart: true, runOnce: true, timeProvider);
-        _clusterUpdater = clusterDestinationsUpdater ?? throw new ArgumentNullException(nameof(clusterDestinationsUpdater));
-        _logger = logger ?? throw new ArgumentNullException(nameof(logger));
+        _clusterUpdater = clusterDestinationsUpdater;
+        _logger = logger;
     }
 
     public void SetActive(ClusterState cluster, IEnumerable<NewActiveDestinationHealth> newHealthPairs)
diff --git a/src/ReverseProxy/Health/DestinationProbingResult.cs b/src/ReverseProxy/Health/DestinationProbingResult.cs
index 47abbe8c9..7fe55c38c 100644
--- a/src/ReverseProxy/Health/DestinationProbingResult.cs
+++ b/src/ReverseProxy/Health/DestinationProbingResult.cs
@@ -14,7 +14,8 @@ public readonly struct DestinationProbingResult
 {
     public DestinationProbingResult(DestinationState destination, HttpResponseMessage? response, Exception? exception)
     {
-        Destination = destination ?? throw new ArgumentNullException(nameof(destination));
+        ArgumentNullException.ThrowIfNull(destination);
+        Destination = destination;
         Response = response;
         Exception = exception;
     }
diff --git a/src/ReverseProxy/Health/EntityActionScheduler.cs b/src/ReverseProxy/Health/EntityActionScheduler.cs
index 992ff3297..e7fb3567a 100644
--- a/src/ReverseProxy/Health/EntityActionScheduler.cs
+++ b/src/ReverseProxy/Health/EntityActionScheduler.cs
@@ -37,9 +37,12 @@ internal sealed class EntityActionScheduler<T> : IDisposable where T : notnull
 
     public EntityActionScheduler(Func<T, Task> action, bool autoStart, bool runOnce, TimeProvider timeProvider)
     {
-        _action = action ?? throw new ArgumentNullException(nameof(action));
+        ArgumentNullException.ThrowIfNull(action);
+        ArgumentNullException.ThrowIfNull(timeProvider);
+
+        _action = action;
         _runOnce = runOnce;
-        _timeProvider = timeProvider ?? throw new ArgumentNullException(nameof(timeProvider));
+        _timeProvider = timeProvider;
         _status = autoStart ? Started : NotStarted;
         _weakThisRef = new WeakReference<EntityActionScheduler<T>>(this);
     }
diff --git a/src/ReverseProxy/Health/PassiveHealthCheckMiddleware.cs b/src/ReverseProxy/Health/PassiveHealthCheckMiddleware.cs
index 57f3b25c9..7cbcc8314 100644
--- a/src/ReverseProxy/Health/PassiveHealthCheckMiddleware.cs
+++ b/src/ReverseProxy/Health/PassiveHealthCheckMiddleware.cs
@@ -17,8 +17,10 @@ public class PassiveHealthCheckMiddleware
 
     public PassiveHealthCheckMiddleware(RequestDelegate next, IEnumerable<IPassiveHealthCheckPolicy> policies)
     {
-        _next = next ?? throw new ArgumentNullException(nameof(next));
-        _policies = policies?.ToDictionaryByUniqueId(p => p.Name) ?? throw new ArgumentNullException(nameof(policies));
+        ArgumentNullException.ThrowIfNull(next);
+        ArgumentNullException.ThrowIfNull(policies);
+        _next = next;
+        _policies = policies.ToDictionaryByUniqueId(p => p.Name);
     }
 
     public async Task Invoke(HttpContext context)
diff --git a/src/ReverseProxy/Health/TransportFailureRateHealthPolicy.cs b/src/ReverseProxy/Health/TransportFailureRateHealthPolicy.cs
index 27041297a..2b8e55d42 100644
--- a/src/ReverseProxy/Health/TransportFailureRateHealthPolicy.cs
+++ b/src/ReverseProxy/Health/TransportFailureRateHealthPolicy.cs
@@ -39,9 +39,13 @@ public TransportFailureRateHealthPolicy(
         TimeProvider timeProvider,
         IDestinationHealthUpdater healthUpdater)
     {
-        _timeProvider = timeProvider ?? throw new ArgumentNullException(nameof(timeProvider));
-        _policyOptions = policyOptions?.Value ?? throw new ArgumentNullException(nameof(policyOptions));
-        _healthUpdater = healthUpdater ?? throw new ArgumentNullException(nameof(healthUpdater));
+        ArgumentNullException.ThrowIfNull(timeProvider);
+        ArgumentNullException.ThrowIfNull(policyOptions?.Value);
+        ArgumentNullException.ThrowIfNull(healthUpdater);
+
+        _timeProvider = timeProvider;
+        _policyOptions = policyOptions.Value;
+        _healthUpdater = healthUpdater;
     }
 
     public void RequestProxied(HttpContext context, ClusterState cluster, DestinationState destination)
diff --git a/src/ReverseProxy/Limits/LimitsMiddleware.cs b/src/ReverseProxy/Limits/LimitsMiddleware.cs
index acddb20b7..9ef83c547 100644
--- a/src/ReverseProxy/Limits/LimitsMiddleware.cs
+++ b/src/ReverseProxy/Limits/LimitsMiddleware.cs
@@ -22,14 +22,17 @@ internal sealed class LimitsMiddleware
 
     public LimitsMiddleware(RequestDelegate next, ILogger<LimitsMiddleware> logger)
     {
-        _next = next ?? throw new ArgumentNullException(nameof(next));
-        _logger = logger ?? throw new ArgumentNullException(nameof(logger));
+        ArgumentNullException.ThrowIfNull(next);
+        ArgumentNullException.ThrowIfNull(logger);
+
+        _next = next;
+        _logger = logger;
     }
 
     /// <inheritdoc/>
     public Task Invoke(HttpContext context)
     {
-        _ = context ?? throw new ArgumentNullException(nameof(context));
+        ArgumentNullException.ThrowIfNull(context);
 
         var config = context.GetRouteModel().Config;
 
diff --git a/src/ReverseProxy/LoadBalancing/LoadBalancingMiddleware.cs b/src/ReverseProxy/LoadBalancing/LoadBalancingMiddleware.cs
index 02d165afd..450af11d1 100644
--- a/src/ReverseProxy/LoadBalancing/LoadBalancingMiddleware.cs
+++ b/src/ReverseProxy/LoadBalancing/LoadBalancingMiddleware.cs
@@ -26,9 +26,12 @@ public LoadBalancingMiddleware(
         ILogger<LoadBalancingMiddleware> logger,
         IEnumerable<ILoadBalancingPolicy> loadBalancingPolicies)
     {
-        _next = next ?? throw new ArgumentNullException(nameof(next));
-        _logger = logger ?? throw new ArgumentNullException(nameof(logger));
-        _loadBalancingPolicies = loadBalancingPolicies?.ToDictionaryByUniqueId(p => p.Name) ?? throw new ArgumentNullException(nameof(loadBalancingPolicies));
+        ArgumentNullException.ThrowIfNull(next);
+        ArgumentNullException.ThrowIfNull(logger);
+        ArgumentNullException.ThrowIfNull(loadBalancingPolicies);
+        _next = next;
+        _logger = logger;
+        _loadBalancingPolicies = loadBalancingPolicies.ToDictionaryByUniqueId(p => p.Name);
     }
 
     public Task Invoke(HttpContext context)
diff --git a/src/ReverseProxy/Management/ProxyConfigManager.cs b/src/ReverseProxy/Management/ProxyConfigManager.cs
index 06d4b7e85..96c674b30 100644
--- a/src/ReverseProxy/Management/ProxyConfigManager.cs
+++ b/src/ReverseProxy/Management/ProxyConfigManager.cs
@@ -72,19 +72,31 @@ public ProxyConfigManager(
         IEnumerable<IConfigChangeListener> configChangeListeners,
         IDestinationResolver destinationResolver)
     {
-        _logger = logger ?? throw new ArgumentNullException(nameof(logger));
-        _providers = providers?.ToArray() ?? throw new ArgumentNullException(nameof(providers));
-        _clusterChangeListeners = (clusterChangeListeners as IClusterChangeListener[])
-            ?? clusterChangeListeners?.ToArray() ?? throw new ArgumentNullException(nameof(clusterChangeListeners));
-        _filters = (filters as IProxyConfigFilter[]) ?? filters?.ToArray() ?? throw new ArgumentNullException(nameof(filters));
-        _configValidator = configValidator ?? throw new ArgumentNullException(nameof(configValidator));
-        _proxyEndpointFactory = proxyEndpointFactory ?? throw new ArgumentNullException(nameof(proxyEndpointFactory));
-        _transformBuilder = transformBuilder ?? throw new ArgumentNullException(nameof(transformBuilder));
-        _httpClientFactory = httpClientFactory ?? throw new ArgumentNullException(nameof(httpClientFactory));
-        _activeHealthCheckMonitor = activeHealthCheckMonitor ?? throw new ArgumentNullException(nameof(activeHealthCheckMonitor));
-        _clusterDestinationsUpdater = clusterDestinationsUpdater ?? throw new ArgumentNullException(nameof(clusterDestinationsUpdater));
-        _destinationResolver = destinationResolver ?? throw new ArgumentNullException(nameof(destinationResolver));
-        _configChangeListeners = configChangeListeners?.ToArray() ?? Array.Empty<IConfigChangeListener>();
+        ArgumentNullException.ThrowIfNull(logger);
+        ArgumentNullException.ThrowIfNull(providers);
+        ArgumentNullException.ThrowIfNull(clusterChangeListeners);
+        ArgumentNullException.ThrowIfNull(filters);
+        ArgumentNullException.ThrowIfNull(configValidator);
+        ArgumentNullException.ThrowIfNull(proxyEndpointFactory);
+        ArgumentNullException.ThrowIfNull(transformBuilder);
+        ArgumentNullException.ThrowIfNull(httpClientFactory);
+        ArgumentNullException.ThrowIfNull(activeHealthCheckMonitor);
+        ArgumentNullException.ThrowIfNull(clusterDestinationsUpdater);
+        ArgumentNullException.ThrowIfNull(configChangeListeners);
+        ArgumentNullException.ThrowIfNull(destinationResolver);
+
+        _logger = logger;
+        _providers = providers.ToArray();
+        _clusterChangeListeners = clusterChangeListeners.ToArray();
+        _filters = filters.ToArray();
+        _configValidator = configValidator;
+        _proxyEndpointFactory = proxyEndpointFactory;
+        _transformBuilder = transformBuilder;
+        _httpClientFactory = httpClientFactory;
+        _activeHealthCheckMonitor = activeHealthCheckMonitor;
+        _clusterDestinationsUpdater = clusterDestinationsUpdater;
+        _destinationResolver = destinationResolver;
+        _configChangeListeners = configChangeListeners.ToArray();
 
         if (_providers.Length == 0)
         {
@@ -822,10 +834,7 @@ private bool UpdateRuntimeRoutes(IList<RouteConfig> incomingRoutes)
     [MemberNotNull(nameof(_endpoints))]
     private void UpdateEndpoints(List<Endpoint> endpoints)
     {
-        if (endpoints is null)
-        {
-            throw new ArgumentNullException(nameof(endpoints));
-        }
+        ArgumentNullException.ThrowIfNull(endpoints);
 
         lock (_syncRoot)
         {
diff --git a/src/ReverseProxy/Management/ReverseProxyBuilder.cs b/src/ReverseProxy/Management/ReverseProxyBuilder.cs
index 986697ac0..6a76dc945 100644
--- a/src/ReverseProxy/Management/ReverseProxyBuilder.cs
+++ b/src/ReverseProxy/Management/ReverseProxyBuilder.cs
@@ -17,7 +17,8 @@ internal sealed class ReverseProxyBuilder : IReverseProxyBuilder
     /// <param name="services">Services collection.</param>
     public ReverseProxyBuilder(IServiceCollection services)
     {
-        Services = services ?? throw new ArgumentNullException(nameof(services));
+        ArgumentNullException.ThrowIfNull(services);
+        Services = services;
     }
 
     /// <summary>
diff --git a/src/ReverseProxy/Management/ReverseProxyServiceCollectionExtensions.cs b/src/ReverseProxy/Management/ReverseProxyServiceCollectionExtensions.cs
index 955d370d3..5b50dcf0f 100644
--- a/src/ReverseProxy/Management/ReverseProxyServiceCollectionExtensions.cs
+++ b/src/ReverseProxy/Management/ReverseProxyServiceCollectionExtensions.cs
@@ -84,10 +84,7 @@ public static IReverseProxyBuilder AddReverseProxy(this IServiceCollection servi
     /// </summary>
     public static IReverseProxyBuilder LoadFromConfig(this IReverseProxyBuilder builder, IConfiguration config)
     {
-        if (config is null)
-        {
-            throw new ArgumentNullException(nameof(config));
-        }
+        ArgumentNullException.ThrowIfNull(config);
 
         builder.Services.AddSingleton<IProxyConfigProvider>(sp =>
         {
@@ -104,10 +101,7 @@ public static IReverseProxyBuilder LoadFromConfig(this IReverseProxyBuilder buil
     /// <typeparam name="TService">A class that implements IProxyConfigFilter.</typeparam>
     public static IReverseProxyBuilder AddConfigFilter<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] TService>(this IReverseProxyBuilder builder) where TService : class, IProxyConfigFilter
     {
-        if (builder is null)
-        {
-            throw new ArgumentNullException(nameof(builder));
-        }
+        ArgumentNullException.ThrowIfNull(builder);
 
         builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<IProxyConfigFilter, TService>());
         return builder;
@@ -120,10 +114,7 @@ public static IReverseProxyBuilder LoadFromConfig(this IReverseProxyBuilder buil
     /// </summary>
     public static IReverseProxyBuilder AddTransforms(this IReverseProxyBuilder builder, Action<TransformBuilderContext> action)
     {
-        if (action is null)
-        {
-            throw new ArgumentNullException(nameof(action));
-        }
+        ArgumentNullException.ThrowIfNull(action);
 
         builder.Services.AddSingleton<ITransformProvider>(new ActionTransformProvider(action));
         return builder;
@@ -157,10 +148,7 @@ public static IReverseProxyBuilder AddTransforms(this IReverseProxyBuilder build
     /// </summary>
     public static IReverseProxyBuilder ConfigureHttpClient(this IReverseProxyBuilder builder, Action<ForwarderHttpClientContext, SocketsHttpHandler> configure)
     {
-        if (configure is null)
-        {
-            throw new ArgumentNullException(nameof(configure));
-        }
+        ArgumentNullException.ThrowIfNull(configure);
 
         // Avoid overriding any other custom factories. This does not handle the case where a IForwarderHttpClientFactory
         // is registered after this call.
diff --git a/src/ReverseProxy/Model/ClusterDestinationsState.cs b/src/ReverseProxy/Model/ClusterDestinationsState.cs
index cbb1e21e0..8ed49f465 100644
--- a/src/ReverseProxy/Model/ClusterDestinationsState.cs
+++ b/src/ReverseProxy/Model/ClusterDestinationsState.cs
@@ -12,8 +12,11 @@ public ClusterDestinationsState(
         IReadOnlyList<DestinationState> allDestinations,
         IReadOnlyList<DestinationState> availableDestinations)
     {
-        AllDestinations = allDestinations ?? throw new ArgumentNullException(nameof(allDestinations));
-        AvailableDestinations = availableDestinations ?? throw new ArgumentNullException(nameof(availableDestinations));
+        ArgumentNullException.ThrowIfNull(allDestinations);
+        ArgumentNullException.ThrowIfNull(availableDestinations);
+
+        AllDestinations = allDestinations;
+        AvailableDestinations = availableDestinations;
     }
 
     public IReadOnlyList<DestinationState> AllDestinations { get; }
diff --git a/src/ReverseProxy/Model/ClusterModel.cs b/src/ReverseProxy/Model/ClusterModel.cs
index 3fe331ed4..1a1d95628 100644
--- a/src/ReverseProxy/Model/ClusterModel.cs
+++ b/src/ReverseProxy/Model/ClusterModel.cs
@@ -26,8 +26,11 @@ public ClusterModel(
         ClusterConfig config,
         HttpMessageInvoker httpClient)
     {
-        Config = config ?? throw new ArgumentNullException(nameof(config));
-        HttpClient = httpClient ?? throw new ArgumentNullException(nameof(httpClient));
+        ArgumentNullException.ThrowIfNull(config);
+        ArgumentNullException.ThrowIfNull(httpClient);
+
+        Config = config;
+        HttpClient = httpClient;
     }
 
     /// <summary>
diff --git a/src/ReverseProxy/Model/ClusterState.cs b/src/ReverseProxy/Model/ClusterState.cs
index eaf92a6c6..37e10bcba 100644
--- a/src/ReverseProxy/Model/ClusterState.cs
+++ b/src/ReverseProxy/Model/ClusterState.cs
@@ -22,7 +22,8 @@ public sealed class ClusterState
     /// </summary>
     public ClusterState(string clusterId)
     {
-        ClusterId = clusterId ?? throw new ArgumentNullException(nameof(clusterId));
+        ArgumentNullException.ThrowIfNull(clusterId);
+        ClusterId = clusterId;
     }
 
     /// <summary>
@@ -32,7 +33,8 @@ public ClusterState(string clusterId)
     /// <exception cref="ArgumentNullException"><paramref name="model"/> is <see langword="null"/>.</exception>
     public ClusterState(string clusterId, ClusterModel model) : this(clusterId)
     {
-        Model = model ?? throw new ArgumentNullException(nameof(model));
+        ArgumentNullException.ThrowIfNull(model);
+        Model = model;
     }
 
     /// <summary>
diff --git a/src/ReverseProxy/Model/DestinationModel.cs b/src/ReverseProxy/Model/DestinationModel.cs
index a428a1ee8..3fdbaa80d 100644
--- a/src/ReverseProxy/Model/DestinationModel.cs
+++ b/src/ReverseProxy/Model/DestinationModel.cs
@@ -24,7 +24,8 @@ public sealed class DestinationModel
     /// </summary>
     public DestinationModel(DestinationConfig destination)
     {
-        Config = destination ?? throw new ArgumentNullException(nameof(destination));
+        ArgumentNullException.ThrowIfNull(destination);
+        Config = destination;
     }
 
     /// <summary>
diff --git a/src/ReverseProxy/Model/DestinationState.cs b/src/ReverseProxy/Model/DestinationState.cs
index a68b8b707..b1f34a943 100644
--- a/src/ReverseProxy/Model/DestinationState.cs
+++ b/src/ReverseProxy/Model/DestinationState.cs
@@ -22,10 +22,7 @@ public sealed class DestinationState : IReadOnlyList<DestinationState>
     /// </summary>
     public DestinationState(string destinationId)
     {
-        if (string.IsNullOrEmpty(destinationId))
-        {
-            throw new ArgumentNullException(nameof(destinationId));
-        }
+        ArgumentException.ThrowIfNullOrEmpty(destinationId);
         DestinationId = destinationId;
     }
 
@@ -36,7 +33,8 @@ public DestinationState(string destinationId)
     /// <exception cref="ArgumentNullException"><paramref name="model"/> is <see langword="null"/>.</exception>
     public DestinationState(string destinationId, DestinationModel model) : this(destinationId)
     {
-        Model = model ?? throw new ArgumentNullException(nameof(model));
+        ArgumentNullException.ThrowIfNull(model);
+        Model = model;
     }
 
     /// <summary>
diff --git a/src/ReverseProxy/Model/ProxyPipelineInitializerMiddleware.cs b/src/ReverseProxy/Model/ProxyPipelineInitializerMiddleware.cs
index a5f4c05f9..b914de4f2 100644
--- a/src/ReverseProxy/Model/ProxyPipelineInitializerMiddleware.cs
+++ b/src/ReverseProxy/Model/ProxyPipelineInitializerMiddleware.cs
@@ -24,10 +24,13 @@ internal sealed class ProxyPipelineInitializerMiddleware
 
     public ProxyPipelineInitializerMiddleware(RequestDelegate next, ILogger<ProxyPipelineInitializerMiddleware> logger, IOptionsMonitor<RequestTimeoutOptions> timeoutOptions)
     {
-        _logger = logger ?? throw new ArgumentNullException(nameof(logger));
-        _next = next ?? throw new ArgumentNullException(nameof(next));
+        ArgumentNullException.ThrowIfNull(logger);
+        ArgumentNullException.ThrowIfNull(next);
+        ArgumentNullException.ThrowIfNull(timeoutOptions);
 
-        _timeoutOptions = timeoutOptions ?? throw new ArgumentNullException(nameof(timeoutOptions));
+        _logger = logger;
+        _next = next;
+        _timeoutOptions = timeoutOptions;
     }
 
     public Task Invoke(HttpContext context)
diff --git a/src/ReverseProxy/Model/ReverseProxyApplicationBuilder.cs b/src/ReverseProxy/Model/ReverseProxyApplicationBuilder.cs
index 98d4e7191..6eab8c17e 100644
--- a/src/ReverseProxy/Model/ReverseProxyApplicationBuilder.cs
+++ b/src/ReverseProxy/Model/ReverseProxyApplicationBuilder.cs
@@ -15,7 +15,8 @@ public class ReverseProxyApplicationBuilder : IReverseProxyApplicationBuilder
 
     public ReverseProxyApplicationBuilder(IApplicationBuilder applicationBuilder)
     {
-        _applicationBuilder = applicationBuilder ?? throw new ArgumentNullException(nameof(applicationBuilder));
+        ArgumentNullException.ThrowIfNull(applicationBuilder);
+        _applicationBuilder = applicationBuilder;
     }
 
     public IServiceProvider ApplicationServices
diff --git a/src/ReverseProxy/Model/RouteModel.cs b/src/ReverseProxy/Model/RouteModel.cs
index b387f0a92..24091a662 100644
--- a/src/ReverseProxy/Model/RouteModel.cs
+++ b/src/ReverseProxy/Model/RouteModel.cs
@@ -26,9 +26,12 @@ public RouteModel(
         ClusterState? cluster,
         HttpTransformer transformer)
     {
-        Config = config ?? throw new ArgumentNullException(nameof(config));
+        ArgumentNullException.ThrowIfNull(config);
+        ArgumentNullException.ThrowIfNull(transformer);
+
+        Config = config;
         Cluster = cluster;
-        Transformer = transformer ?? throw new ArgumentNullException(nameof(transformer));
+        Transformer = transformer;
     }
 
     // May not be populated if the cluster config is missing. https://github.com/dotnet/yarp/issues/797
diff --git a/src/ReverseProxy/Model/RouteState.cs b/src/ReverseProxy/Model/RouteState.cs
index b7568709c..ca21b75d5 100644
--- a/src/ReverseProxy/Model/RouteState.cs
+++ b/src/ReverseProxy/Model/RouteState.cs
@@ -15,10 +15,7 @@ internal sealed class RouteState
 
     public RouteState(string routeId)
     {
-        if (string.IsNullOrEmpty(routeId))
-        {
-            throw new ArgumentNullException(nameof(routeId));
-        }
+        ArgumentException.ThrowIfNullOrEmpty(routeId);
         RouteId = routeId;
     }
 
@@ -31,7 +28,7 @@ public RouteState(string routeId)
     internal RouteModel Model
     {
         get => _model;
-        set => _model = value ?? throw new ArgumentNullException(nameof(value));
+        set { ArgumentNullException.ThrowIfNull(value); _model = value; }
     }
 
     /// <summary>
diff --git a/src/ReverseProxy/Routing/HeaderMatcherPolicy.cs b/src/ReverseProxy/Routing/HeaderMatcherPolicy.cs
index 56ccec724..8cb277198 100644
--- a/src/ReverseProxy/Routing/HeaderMatcherPolicy.cs
+++ b/src/ReverseProxy/Routing/HeaderMatcherPolicy.cs
@@ -26,7 +26,7 @@ internal sealed class HeaderMatcherPolicy : MatcherPolicy, IEndpointComparerPoli
     /// <inheritdoc/>
     bool IEndpointSelectorPolicy.AppliesToEndpoints(IReadOnlyList<Endpoint> endpoints)
     {
-        _ = endpoints ?? throw new ArgumentNullException(nameof(endpoints));
+        ArgumentNullException.ThrowIfNull(endpoints);
 
         // When the node contains dynamic endpoints we can't make any assumptions.
         if (ContainsDynamicEndpoints(endpoints))
@@ -49,8 +49,8 @@ private static bool AppliesToEndpointsCore(IReadOnlyList<Endpoint> endpoints)
     /// <inheritdoc/>
     public Task ApplyAsync(HttpContext httpContext, CandidateSet candidates)
     {
-        _ = httpContext ?? throw new ArgumentNullException(nameof(httpContext));
-        _ = candidates ?? throw new ArgumentNullException(nameof(candidates));
+        ArgumentNullException.ThrowIfNull(httpContext);
+        ArgumentNullException.ThrowIfNull(candidates);
 
         var headers = httpContext.Request.Headers;
 
diff --git a/src/ReverseProxy/Routing/HeaderMetadata.cs b/src/ReverseProxy/Routing/HeaderMetadata.cs
index d51b22e00..cfb058db6 100644
--- a/src/ReverseProxy/Routing/HeaderMetadata.cs
+++ b/src/ReverseProxy/Routing/HeaderMetadata.cs
@@ -14,7 +14,8 @@ internal sealed class HeaderMetadata : IHeaderMetadata
 {
     public HeaderMetadata(IReadOnlyList<HeaderMatcher> matchers)
     {
-        Matchers = matchers?.ToArray() ?? throw new ArgumentNullException(nameof(matchers));
+        ArgumentNullException.ThrowIfNull(matchers);
+        Matchers = matchers.ToArray();
     }
 
     /// <inheritdoc/>
diff --git a/src/ReverseProxy/Routing/ProxyEndpointFactory.cs b/src/ReverseProxy/Routing/ProxyEndpointFactory.cs
index efeea87c9..fa1f6ef1a 100644
--- a/src/ReverseProxy/Routing/ProxyEndpointFactory.cs
+++ b/src/ReverseProxy/Routing/ProxyEndpointFactory.cs
@@ -159,6 +159,7 @@ public Endpoint CreateEndpoint(RouteModel route, IReadOnlyList<Action<EndpointBu
 
     public void SetProxyPipeline(RequestDelegate pipeline)
     {
-        _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline));
+        ArgumentNullException.ThrowIfNull(pipeline);
+        _pipeline = pipeline;
     }
 }
diff --git a/src/ReverseProxy/Routing/QueryParameterMatcher.cs b/src/ReverseProxy/Routing/QueryParameterMatcher.cs
index 994553d9f..db2e3d150 100644
--- a/src/ReverseProxy/Routing/QueryParameterMatcher.cs
+++ b/src/ReverseProxy/Routing/QueryParameterMatcher.cs
@@ -18,10 +18,7 @@ internal sealed class QueryParameterMatcher
     /// </summary>
     public QueryParameterMatcher(string name, IReadOnlyList<string>? values, QueryParameterMatchMode mode, bool isCaseSensitive)
     {
-        if (string.IsNullOrEmpty(name))
-        {
-            throw new ArgumentException("A query parameter name is required.", nameof(name));
-        }
+        ArgumentException.ThrowIfNullOrEmpty(name);
         if (mode != QueryParameterMatchMode.Exists
             && (values is null || values.Count == 0))
         {
diff --git a/src/ReverseProxy/Routing/QueryParameterMatcherPolicy.cs b/src/ReverseProxy/Routing/QueryParameterMatcherPolicy.cs
index 782b30472..01054cc59 100644
--- a/src/ReverseProxy/Routing/QueryParameterMatcherPolicy.cs
+++ b/src/ReverseProxy/Routing/QueryParameterMatcherPolicy.cs
@@ -25,7 +25,7 @@ internal sealed class QueryParameterMatcherPolicy : MatcherPolicy, IEndpointComp
     /// <inheritdoc/>
     bool IEndpointSelectorPolicy.AppliesToEndpoints(IReadOnlyList<Endpoint> endpoints)
     {
-        _ = endpoints ?? throw new ArgumentNullException(nameof(endpoints));
+        ArgumentNullException.ThrowIfNull(endpoints);
 
         // When the node contains dynamic endpoints we can't make any assumptions.
         if (ContainsDynamicEndpoints(endpoints))
@@ -48,8 +48,8 @@ private static bool AppliesToEndpointsCore(IReadOnlyList<Endpoint> endpoints)
     /// <inheritdoc/>
     public Task ApplyAsync(HttpContext httpContext, CandidateSet candidates)
     {
-        _ = httpContext ?? throw new ArgumentNullException(nameof(httpContext));
-        _ = candidates ?? throw new ArgumentNullException(nameof(candidates));
+        ArgumentNullException.ThrowIfNull(httpContext);
+        ArgumentNullException.ThrowIfNull(candidates);
 
         var query = httpContext.Request.Query;
 
diff --git a/src/ReverseProxy/Routing/QueryParameterMetadata.cs b/src/ReverseProxy/Routing/QueryParameterMetadata.cs
index 35a231888..9fac941a2 100644
--- a/src/ReverseProxy/Routing/QueryParameterMetadata.cs
+++ b/src/ReverseProxy/Routing/QueryParameterMetadata.cs
@@ -14,7 +14,8 @@ internal sealed class QueryParameterMetadata : IQueryParameterMetadata
 {
     public QueryParameterMetadata(IReadOnlyList<QueryParameterMatcher> matchers)
     {
-        Matchers = matchers?.ToArray() ?? throw new ArgumentNullException(nameof(matchers));
+        ArgumentNullException.ThrowIfNull(matchers);
+        Matchers = matchers.ToArray();
     }
 
     /// <inheritdoc/>
diff --git a/src/ReverseProxy/Routing/ReverseProxyConventionBuilder.cs b/src/ReverseProxy/Routing/ReverseProxyConventionBuilder.cs
index 532d43337..7df49ad36 100644
--- a/src/ReverseProxy/Routing/ReverseProxyConventionBuilder.cs
+++ b/src/ReverseProxy/Routing/ReverseProxyConventionBuilder.cs
@@ -15,7 +15,8 @@ public class ReverseProxyConventionBuilder : IEndpointConventionBuilder
 
     internal ReverseProxyConventionBuilder(List<Action<EndpointBuilder>> conventions)
     {
-        _conventions = conventions ?? throw new ArgumentNullException(nameof(conventions));
+        ArgumentNullException.ThrowIfNull(conventions);
+        _conventions = conventions;
     }
 
     /// <summary>
@@ -24,7 +25,7 @@ internal ReverseProxyConventionBuilder(List<Action<EndpointBuilder>> conventions
     /// <param name="convention">The convention to add to the builder.</param>
     public void Add(Action<EndpointBuilder> convention)
     {
-        _ = convention ?? throw new ArgumentNullException(nameof(convention));
+        ArgumentNullException.ThrowIfNull(convention);
 
         _conventions.Add(convention);
     }
@@ -36,7 +37,7 @@ public void Add(Action<EndpointBuilder> convention)
     /// <returns></returns>
     public ReverseProxyConventionBuilder ConfigureEndpoints(Action<IEndpointConventionBuilder> convention)
     {
-        _ = convention ?? throw new ArgumentNullException(nameof(convention));
+        ArgumentNullException.ThrowIfNull(convention);
 
         void Action(EndpointBuilder endpointBuilder)
         {
@@ -56,7 +57,7 @@ void Action(EndpointBuilder endpointBuilder)
     /// <returns></returns>
     public ReverseProxyConventionBuilder ConfigureEndpoints(Action<IEndpointConventionBuilder, RouteConfig> convention)
     {
-        _ = convention ?? throw new ArgumentNullException(nameof(convention));
+        ArgumentNullException.ThrowIfNull(convention);
 
         void Action(EndpointBuilder endpointBuilder)
         {
@@ -77,7 +78,7 @@ void Action(EndpointBuilder endpointBuilder)
     /// <returns></returns>
     public ReverseProxyConventionBuilder ConfigureEndpoints(Action<IEndpointConventionBuilder, RouteConfig, ClusterConfig?> convention)
     {
-        _ = convention ?? throw new ArgumentNullException(nameof(convention));
+        ArgumentNullException.ThrowIfNull(convention);
 
         void Action(EndpointBuilder endpointBuilder)
         {
diff --git a/src/ReverseProxy/Routing/ReverseProxyIEndpointRouteBuilderExtensions.cs b/src/ReverseProxy/Routing/ReverseProxyIEndpointRouteBuilderExtensions.cs
index 6d7baf45e..b35cc06aa 100644
--- a/src/ReverseProxy/Routing/ReverseProxyIEndpointRouteBuilderExtensions.cs
+++ b/src/ReverseProxy/Routing/ReverseProxyIEndpointRouteBuilderExtensions.cs
@@ -38,14 +38,8 @@ public static ReverseProxyConventionBuilder MapReverseProxy(this IEndpointRouteB
     /// </summary>
     public static ReverseProxyConventionBuilder MapReverseProxy(this IEndpointRouteBuilder endpoints, Action<IReverseProxyApplicationBuilder> configureApp)
     {
-        if (endpoints is null)
-        {
-            throw new ArgumentNullException(nameof(endpoints));
-        }
-        if (configureApp is null)
-        {
-            throw new ArgumentNullException(nameof(configureApp));
-        }
+        ArgumentNullException.ThrowIfNull(endpoints);
+        ArgumentNullException.ThrowIfNull(configureApp);
 
         var proxyAppBuilder = new ReverseProxyApplicationBuilder(endpoints.CreateApplicationBuilder());
         proxyAppBuilder.UseMiddleware<ProxyPipelineInitializerMiddleware>();
diff --git a/src/ReverseProxy/SessionAffinity/AffinitizeTransform.cs b/src/ReverseProxy/SessionAffinity/AffinitizeTransform.cs
index d04193ea9..f96e894cd 100644
--- a/src/ReverseProxy/SessionAffinity/AffinitizeTransform.cs
+++ b/src/ReverseProxy/SessionAffinity/AffinitizeTransform.cs
@@ -19,7 +19,8 @@ internal sealed class AffinitizeTransform : ResponseTransform
 
     public AffinitizeTransform(ISessionAffinityPolicy sessionAffinityPolicy)
     {
-        _sessionAffinityPolicy = sessionAffinityPolicy ?? throw new ArgumentNullException(nameof(sessionAffinityPolicy));
+        ArgumentNullException.ThrowIfNull(sessionAffinityPolicy);
+        _sessionAffinityPolicy = sessionAffinityPolicy;
     }
 
     public override ValueTask ApplyAsync(ResponseTransformContext context)
diff --git a/src/ReverseProxy/SessionAffinity/AffinitizeTransformProvider.cs b/src/ReverseProxy/SessionAffinity/AffinitizeTransformProvider.cs
index aabb58083..b15ebab74 100644
--- a/src/ReverseProxy/SessionAffinity/AffinitizeTransformProvider.cs
+++ b/src/ReverseProxy/SessionAffinity/AffinitizeTransformProvider.cs
@@ -15,8 +15,8 @@ internal sealed class AffinitizeTransformProvider : ITransformProvider
 
     public AffinitizeTransformProvider(IEnumerable<ISessionAffinityPolicy> sessionAffinityPolicies)
     {
-        _sessionAffinityPolicies = sessionAffinityPolicies?.ToDictionaryByUniqueId(p => p.Name)
-            ?? throw new ArgumentNullException(nameof(sessionAffinityPolicies));
+        ArgumentNullException.ThrowIfNull(sessionAffinityPolicies);
+        _sessionAffinityPolicies = sessionAffinityPolicies.ToDictionaryByUniqueId(p => p.Name);
     }
 
     public void ValidateRoute(TransformRouteValidationContext context)
diff --git a/src/ReverseProxy/SessionAffinity/BaseEncryptedSessionAffinityPolicy.cs b/src/ReverseProxy/SessionAffinity/BaseEncryptedSessionAffinityPolicy.cs
index f96d6e55a..d942ad679 100644
--- a/src/ReverseProxy/SessionAffinity/BaseEncryptedSessionAffinityPolicy.cs
+++ b/src/ReverseProxy/SessionAffinity/BaseEncryptedSessionAffinityPolicy.cs
@@ -20,8 +20,9 @@ internal abstract class BaseEncryptedSessionAffinityPolicy<T> : ISessionAffinity
 
     protected BaseEncryptedSessionAffinityPolicy(IDataProtectionProvider dataProtectionProvider, ILogger logger)
     {
+        ArgumentNullException.ThrowIfNull(logger);
         _dataProtector = dataProtectionProvider?.CreateProtector(GetType().FullName!) ?? throw new ArgumentNullException(nameof(dataProtectionProvider));
-        Logger = logger ?? throw new ArgumentNullException(nameof(logger));
+        Logger = logger;
     }
 
     public abstract string Name { get; }
diff --git a/src/ReverseProxy/SessionAffinity/BaseHashCookieSessionAffinityPolicy.cs b/src/ReverseProxy/SessionAffinity/BaseHashCookieSessionAffinityPolicy.cs
index d54ee612a..c456810cd 100644
--- a/src/ReverseProxy/SessionAffinity/BaseHashCookieSessionAffinityPolicy.cs
+++ b/src/ReverseProxy/SessionAffinity/BaseHashCookieSessionAffinityPolicy.cs
@@ -18,8 +18,11 @@ internal abstract class BaseHashCookieSessionAffinityPolicy : ISessionAffinityPo
 
     public BaseHashCookieSessionAffinityPolicy(TimeProvider timeProvider, ILogger logger)
     {
-        _timeProvider = timeProvider ?? throw new ArgumentNullException(nameof(timeProvider));
-        _logger = logger ?? throw new ArgumentNullException(nameof(logger));
+        ArgumentNullException.ThrowIfNull(timeProvider);
+        ArgumentNullException.ThrowIfNull(logger);
+
+        _timeProvider = timeProvider;
+        _logger = logger;
     }
 
     public abstract string Name { get; }
diff --git a/src/ReverseProxy/SessionAffinity/CookieSessionAffinityPolicy.cs b/src/ReverseProxy/SessionAffinity/CookieSessionAffinityPolicy.cs
index 14b308799..50d0df46f 100644
--- a/src/ReverseProxy/SessionAffinity/CookieSessionAffinityPolicy.cs
+++ b/src/ReverseProxy/SessionAffinity/CookieSessionAffinityPolicy.cs
@@ -20,7 +20,8 @@ public CookieSessionAffinityPolicy(
         ILogger<CookieSessionAffinityPolicy> logger)
         : base(dataProtectionProvider, logger)
     {
-        _timeProvider = timeProvider ?? throw new ArgumentNullException(nameof(timeProvider));
+        ArgumentNullException.ThrowIfNull(timeProvider);
+        _timeProvider = timeProvider;
     }
 
     public override string Name => SessionAffinityConstants.Policies.Cookie;
diff --git a/src/ReverseProxy/SessionAffinity/SessionAffinityMiddleware.cs b/src/ReverseProxy/SessionAffinity/SessionAffinityMiddleware.cs
index 1950e3836..5038928fe 100644
--- a/src/ReverseProxy/SessionAffinity/SessionAffinityMiddleware.cs
+++ b/src/ReverseProxy/SessionAffinity/SessionAffinityMiddleware.cs
@@ -29,10 +29,15 @@ public SessionAffinityMiddleware(
         IEnumerable<IAffinityFailurePolicy> affinityFailurePolicies,
         ILogger<SessionAffinityMiddleware> logger)
     {
-        _next = next ?? throw new ArgumentNullException(nameof(next));
-        _logger = logger ?? throw new ArgumentNullException(nameof(logger));
-        _sessionAffinityPolicies = sessionAffinityPolicies?.ToDictionaryByUniqueId(p => p.Name) ?? throw new ArgumentNullException(nameof(sessionAffinityPolicies));
-        _affinityFailurePolicies = affinityFailurePolicies?.ToDictionaryByUniqueId(p => p.Name) ?? throw new ArgumentNullException(nameof(affinityFailurePolicies));
+        ArgumentNullException.ThrowIfNull(next);
+        ArgumentNullException.ThrowIfNull(logger);
+        ArgumentNullException.ThrowIfNull(sessionAffinityPolicies);
+        ArgumentNullException.ThrowIfNull(affinityFailurePolicies);
+
+        _next = next;
+        _logger = logger;
+        _sessionAffinityPolicies = sessionAffinityPolicies.ToDictionaryByUniqueId(p => p.Name);
+        _affinityFailurePolicies = affinityFailurePolicies.ToDictionaryByUniqueId(p => p.Name);
     }
 
     public Task Invoke(HttpContext context)
diff --git a/src/ReverseProxy/Transforms/Builder/ActionTransformProvider.cs b/src/ReverseProxy/Transforms/Builder/ActionTransformProvider.cs
index d4cd6dc72..e84ed2b2e 100644
--- a/src/ReverseProxy/Transforms/Builder/ActionTransformProvider.cs
+++ b/src/ReverseProxy/Transforms/Builder/ActionTransformProvider.cs
@@ -11,7 +11,8 @@ internal sealed class ActionTransformProvider : ITransformProvider
 
     public ActionTransformProvider(Action<TransformBuilderContext> action)
     {
-        _action = action ?? throw new ArgumentNullException(nameof(action));
+        ArgumentNullException.ThrowIfNull(action);
+        _action = action;
     }
 
     public void Apply(TransformBuilderContext transformBuildContext)
diff --git a/src/ReverseProxy/Transforms/Builder/StructuredTransformer.cs b/src/ReverseProxy/Transforms/Builder/StructuredTransformer.cs
index 8b0c80bf7..12e2270c2 100644
--- a/src/ReverseProxy/Transforms/Builder/StructuredTransformer.cs
+++ b/src/ReverseProxy/Transforms/Builder/StructuredTransformer.cs
@@ -26,12 +26,16 @@ internal StructuredTransformer(bool? copyRequestHeaders, bool? copyResponseHeade
         IList<ResponseTransform> responseTransforms,
         IList<ResponseTrailersTransform> responseTrailerTransforms)
     {
+        ArgumentNullException.ThrowIfNull(requestTransforms);
+        ArgumentNullException.ThrowIfNull(responseTransforms);
+        ArgumentNullException.ThrowIfNull(responseTrailerTransforms);
+
         ShouldCopyRequestHeaders = copyRequestHeaders;
         ShouldCopyResponseHeaders = copyResponseHeaders;
         ShouldCopyResponseTrailers = copyResponseTrailers;
-        RequestTransforms = requestTransforms?.ToArray() ?? throw new ArgumentNullException(nameof(requestTransforms));
-        ResponseTransforms = responseTransforms?.ToArray() ?? throw new ArgumentNullException(nameof(responseTransforms));
-        ResponseTrailerTransforms = responseTrailerTransforms?.ToArray() ?? throw new ArgumentNullException(nameof(responseTrailerTransforms));
+        RequestTransforms = requestTransforms.ToArray();
+        ResponseTransforms = responseTransforms.ToArray();
+        ResponseTrailerTransforms = responseTrailerTransforms.ToArray();
     }
 
     /// <summary>
diff --git a/src/ReverseProxy/Transforms/Builder/TransformBuilder.cs b/src/ReverseProxy/Transforms/Builder/TransformBuilder.cs
index 4c1f65810..04f8d3b89 100644
--- a/src/ReverseProxy/Transforms/Builder/TransformBuilder.cs
+++ b/src/ReverseProxy/Transforms/Builder/TransformBuilder.cs
@@ -23,9 +23,13 @@ internal sealed class TransformBuilder : ITransformBuilder
     /// </summary>
     public TransformBuilder(IServiceProvider services, IEnumerable<ITransformFactory> factories, IEnumerable<ITransformProvider> providers)
     {
-        _services = services ?? throw new ArgumentNullException(nameof(services));
-        _factories = factories?.ToList() ?? throw new ArgumentNullException(nameof(factories));
-        _providers = providers?.ToList() ?? throw new ArgumentNullException(nameof(providers));
+        ArgumentNullException.ThrowIfNull(services);
+        ArgumentNullException.ThrowIfNull(factories);
+        ArgumentNullException.ThrowIfNull(providers);
+
+        _services = services;
+        _factories = factories.ToList();
+        _providers = providers.ToList();
     }
 
     /// <inheritdoc/>
diff --git a/src/ReverseProxy/Transforms/ForwardedTransformFactory.cs b/src/ReverseProxy/Transforms/ForwardedTransformFactory.cs
index 9af6f6f48..477def198 100644
--- a/src/ReverseProxy/Transforms/ForwardedTransformFactory.cs
+++ b/src/ReverseProxy/Transforms/ForwardedTransformFactory.cs
@@ -28,7 +28,8 @@ internal sealed class ForwardedTransformFactory : ITransformFactory
 
     public ForwardedTransformFactory(IRandomFactory randomFactory)
     {
-        _randomFactory = randomFactory ?? throw new ArgumentNullException(nameof(randomFactory));
+        ArgumentNullException.ThrowIfNull(randomFactory);
+        _randomFactory = randomFactory;
     }
 
     public bool Validate(TransformRouteValidationContext context, IReadOnlyDictionary<string, string> transformValues)
diff --git a/src/ReverseProxy/Transforms/PathRouteValuesTransform.cs b/src/ReverseProxy/Transforms/PathRouteValuesTransform.cs
index 0a5ccf0dd..f95e5b9f9 100644
--- a/src/ReverseProxy/Transforms/PathRouteValuesTransform.cs
+++ b/src/ReverseProxy/Transforms/PathRouteValuesTransform.cs
@@ -25,8 +25,9 @@ public class PathRouteValuesTransform : RequestTransform
     public PathRouteValuesTransform(
         [StringSyntax("Route")] string pattern, TemplateBinderFactory binderFactory)
     {
-        _ = pattern ?? throw new ArgumentNullException(nameof(pattern));
-        _binderFactory = binderFactory ?? throw new ArgumentNullException(nameof(binderFactory));
+        ArgumentNullException.ThrowIfNull(pattern);
+        ArgumentNullException.ThrowIfNull(binderFactory);
+        _binderFactory = binderFactory;
         Pattern = RoutePatternFactory.Parse(pattern);
     }
 
@@ -35,10 +36,7 @@ public PathRouteValuesTransform(
     /// <inheritdoc/>
     public override ValueTask ApplyAsync(RequestTransformContext context)
     {
-        if (context is null)
-        {
-            throw new ArgumentNullException(nameof(context));
-        }
+        ArgumentNullException.ThrowIfNull(context);
 
         // TemplateBinder.BindValues will modify the RouteValueDictionary
         // We make a copy so that the original request is not modified by the transform
diff --git a/src/ReverseProxy/Transforms/PathStringTransform.cs b/src/ReverseProxy/Transforms/PathStringTransform.cs
index 6fd602c7a..ed98fa303 100644
--- a/src/ReverseProxy/Transforms/PathStringTransform.cs
+++ b/src/ReverseProxy/Transforms/PathStringTransform.cs
@@ -19,10 +19,7 @@ public class PathStringTransform : RequestTransform
     /// <param name="value">The path value used to update the existing value.</param>
     public PathStringTransform(PathTransformMode mode, PathString value)
     {
-        if (value.Value is null)
-        {
-            throw new ArgumentNullException(nameof(value));
-        }
+        ArgumentNullException.ThrowIfNull(value.Value);
 
         Mode = mode;
         Value = value;
@@ -35,10 +32,7 @@ public PathStringTransform(PathTransformMode mode, PathString value)
     /// <inheritdoc/>
     public override ValueTask ApplyAsync(RequestTransformContext context)
     {
-        if (context is null)
-        {
-            throw new ArgumentNullException(nameof(context));
-        }
+        ArgumentNullException.ThrowIfNull(context);
 
         switch (Mode)
         {
diff --git a/src/ReverseProxy/Transforms/PathTransformExtensions.cs b/src/ReverseProxy/Transforms/PathTransformExtensions.cs
index bb9861ed4..7d9567658 100644
--- a/src/ReverseProxy/Transforms/PathTransformExtensions.cs
+++ b/src/ReverseProxy/Transforms/PathTransformExtensions.cs
@@ -21,10 +21,7 @@ public static class PathTransformExtensions
     /// </summary>
     public static RouteConfig WithTransformPathSet(this RouteConfig route, PathString path)
     {
-        if (path.Value is null)
-        {
-            throw new ArgumentNullException(nameof(path));
-        }
+        ArgumentNullException.ThrowIfNull(path.Value);
 
         return route.WithTransform(transform =>
         {
@@ -46,10 +43,7 @@ public static TransformBuilderContext AddPathSet(this TransformBuilderContext co
     /// </summary>
     public static RouteConfig WithTransformPathPrefix(this RouteConfig route, PathString prefix)
     {
-        if (prefix.Value is null)
-        {
-            throw new ArgumentNullException(nameof(prefix));
-        }
+        ArgumentNullException.ThrowIfNull(prefix.Value);
 
         return route.WithTransform(transform =>
         {
@@ -71,10 +65,7 @@ public static TransformBuilderContext AddPathPrefix(this TransformBuilderContext
     /// </summary>
     public static RouteConfig WithTransformPathRemovePrefix(this RouteConfig route, PathString prefix)
     {
-        if (prefix.Value is null)
-        {
-            throw new ArgumentNullException(nameof(prefix));
-        }
+        ArgumentNullException.ThrowIfNull(prefix.Value);
 
         return route.WithTransform(transform =>
         {
@@ -96,10 +87,7 @@ public static TransformBuilderContext AddPathRemovePrefix(this TransformBuilderC
     /// </summary>
     public static RouteConfig WithTransformPathRouteValues(this RouteConfig route, [StringSyntax("Route")] PathString pattern)
     {
-        if (pattern.Value is null)
-        {
-            throw new ArgumentNullException(nameof(pattern));
-        }
+        ArgumentNullException.ThrowIfNull(pattern.Value);
 
         return route.WithTransform(transform =>
         {
@@ -112,10 +100,7 @@ public static RouteConfig WithTransformPathRouteValues(this RouteConfig route, [
     /// </summary>
     public static TransformBuilderContext AddPathRouteValues(this TransformBuilderContext context, [StringSyntax("Route")] PathString pattern)
     {
-        if (pattern.Value is null)
-        {
-            throw new ArgumentNullException(nameof(pattern));
-        }
+        ArgumentNullException.ThrowIfNull(pattern.Value);
 
         var binder = context.Services.GetRequiredService<TemplateBinderFactory>();
         context.RequestTransforms.Add(new PathRouteValuesTransform(pattern.Value, binder));
diff --git a/src/ReverseProxy/Transforms/PathTransformFactory.cs b/src/ReverseProxy/Transforms/PathTransformFactory.cs
index 04f2b2cdd..2e2a76b55 100644
--- a/src/ReverseProxy/Transforms/PathTransformFactory.cs
+++ b/src/ReverseProxy/Transforms/PathTransformFactory.cs
@@ -20,7 +20,8 @@ internal sealed class PathTransformFactory : ITransformFactory
 
     public PathTransformFactory(TemplateBinderFactory binderFactory)
     {
-        _binderFactory = binderFactory ?? throw new ArgumentNullException(nameof(binderFactory));
+        ArgumentNullException.ThrowIfNull(binderFactory);
+        _binderFactory = binderFactory;
     }
 
     public bool Validate(TransformRouteValidationContext context, IReadOnlyDictionary<string, string> transformValues)
@@ -99,10 +100,7 @@ public bool Build(TransformBuilderContext context, IReadOnlyDictionary<string, s
 
     private static PathString MakePathString(string path)
     {
-        if (path is null)
-        {
-            throw new ArgumentNullException(nameof(path));
-        }
+        ArgumentNullException.ThrowIfNull(path);
         if (!path.StartsWith('/'))
         {
             path = "/" + path;
diff --git a/src/ReverseProxy/Transforms/QueryParameterFromStaticTransform.cs b/src/ReverseProxy/Transforms/QueryParameterFromStaticTransform.cs
index e60e133db..014567954 100644
--- a/src/ReverseProxy/Transforms/QueryParameterFromStaticTransform.cs
+++ b/src/ReverseProxy/Transforms/QueryParameterFromStaticTransform.cs
@@ -15,7 +15,9 @@ public QueryParameterFromStaticTransform(QueryStringTransformMode mode, string k
             throw new ArgumentException($"'{nameof(key)}' cannot be null or empty.", nameof(key));
         }
 
-        Value = value ?? throw new ArgumentNullException(nameof(value));
+        ArgumentNullException.ThrowIfNull(value);
+
+        Value = value;
     }
 
     internal string Value { get; }
diff --git a/src/ReverseProxy/Transforms/QueryParameterRemoveTransform.cs b/src/ReverseProxy/Transforms/QueryParameterRemoveTransform.cs
index 5b088d836..706c22f49 100644
--- a/src/ReverseProxy/Transforms/QueryParameterRemoveTransform.cs
+++ b/src/ReverseProxy/Transforms/QueryParameterRemoveTransform.cs
@@ -26,10 +26,7 @@ public QueryParameterRemoveTransform(string key)
     /// <inheritdoc/>
     public override ValueTask ApplyAsync(RequestTransformContext context)
     {
-        if (context is null)
-        {
-            throw new ArgumentNullException(nameof(context));
-        }
+        ArgumentNullException.ThrowIfNull(context);
 
         context.Query.Collection.Remove(Key);
 
diff --git a/src/ReverseProxy/Transforms/QueryParameterTransform.cs b/src/ReverseProxy/Transforms/QueryParameterTransform.cs
index ea4c59e82..839e2cb56 100644
--- a/src/ReverseProxy/Transforms/QueryParameterTransform.cs
+++ b/src/ReverseProxy/Transforms/QueryParameterTransform.cs
@@ -27,10 +27,7 @@ public QueryParameterTransform(QueryStringTransformMode mode, string key)
     /// <inheritdoc/>
     public override ValueTask ApplyAsync(RequestTransformContext context)
     {
-        if (context is null)
-        {
-            throw new ArgumentNullException(nameof(context));
-        }
+        ArgumentNullException.ThrowIfNull(context);
 
         var value = GetValue(context);
         if (value is not null)
diff --git a/src/ReverseProxy/Transforms/QueryTransformContext.cs b/src/ReverseProxy/Transforms/QueryTransformContext.cs
index 7e0e5ff4d..8c3deae62 100644
--- a/src/ReverseProxy/Transforms/QueryTransformContext.cs
+++ b/src/ReverseProxy/Transforms/QueryTransformContext.cs
@@ -20,7 +20,8 @@ public class QueryTransformContext
 
     public QueryTransformContext(HttpRequest request)
     {
-        _request = request ?? throw new ArgumentNullException(nameof(request));
+        ArgumentNullException.ThrowIfNull(request);
+        _request = request;
         _originalQueryString = request.QueryString;
         _modifiedQueryParameters = null;
     }
diff --git a/src/ReverseProxy/Transforms/RequestFuncTransform.cs b/src/ReverseProxy/Transforms/RequestFuncTransform.cs
index f53cb62e9..d6c7cb819 100644
--- a/src/ReverseProxy/Transforms/RequestFuncTransform.cs
+++ b/src/ReverseProxy/Transforms/RequestFuncTransform.cs
@@ -15,7 +15,8 @@ public class RequestFuncTransform : RequestTransform
 
     public RequestFuncTransform(Func<RequestTransformContext, ValueTask> func)
     {
-        _func = func ?? throw new ArgumentNullException(nameof(func));
+        ArgumentNullException.ThrowIfNull(func);
+        _func = func;
     }
 
     /// <inheritdoc/>
diff --git a/src/ReverseProxy/Transforms/RequestHeaderClientCertTransform.cs b/src/ReverseProxy/Transforms/RequestHeaderClientCertTransform.cs
index 61fb0b818..ab809edb1 100644
--- a/src/ReverseProxy/Transforms/RequestHeaderClientCertTransform.cs
+++ b/src/ReverseProxy/Transforms/RequestHeaderClientCertTransform.cs
@@ -26,10 +26,7 @@ public RequestHeaderClientCertTransform(string headerName)
     /// <inheritdoc/>
     public override ValueTask ApplyAsync(RequestTransformContext context)
     {
-        if (context is null)
-        {
-            throw new ArgumentNullException(nameof(context));
-        }
+        ArgumentNullException.ThrowIfNull(context);
 
         RemoveHeader(context, HeaderName);
 
diff --git a/src/ReverseProxy/Transforms/RequestHeaderForwardedTransform.cs b/src/ReverseProxy/Transforms/RequestHeaderForwardedTransform.cs
index 9e0a25a12..6a87e6f5b 100644
--- a/src/ReverseProxy/Transforms/RequestHeaderForwardedTransform.cs
+++ b/src/ReverseProxy/Transforms/RequestHeaderForwardedTransform.cs
@@ -27,7 +27,8 @@ public class RequestHeaderForwardedTransform : RequestTransform
 
     public RequestHeaderForwardedTransform(IRandomFactory randomFactory, NodeFormat forFormat, NodeFormat byFormat, bool host, bool proto, ForwardedTransformActions action)
     {
-        _randomFactory = randomFactory ?? throw new ArgumentNullException(nameof(randomFactory));
+        ArgumentNullException.ThrowIfNull(randomFactory);
+        _randomFactory = randomFactory;
         ForFormat = forFormat;
         ByFormat = byFormat;
         HostEnabled = host;
@@ -49,10 +50,7 @@ public RequestHeaderForwardedTransform(IRandomFactory randomFactory, NodeFormat
     /// <inheritdoc/>
     public override ValueTask ApplyAsync(RequestTransformContext context)
     {
-        if (context is null)
-        {
-            throw new ArgumentNullException(nameof(context));
-        }
+        ArgumentNullException.ThrowIfNull(context);
 
         var httpContext = context.HttpContext;
 
diff --git a/src/ReverseProxy/Transforms/RequestHeaderRemoveTransform.cs b/src/ReverseProxy/Transforms/RequestHeaderRemoveTransform.cs
index f08908cda..444e2dfca 100644
--- a/src/ReverseProxy/Transforms/RequestHeaderRemoveTransform.cs
+++ b/src/ReverseProxy/Transforms/RequestHeaderRemoveTransform.cs
@@ -26,10 +26,7 @@ public RequestHeaderRemoveTransform(string headerName)
     /// <inheritdoc/>
     public override ValueTask ApplyAsync(RequestTransformContext context)
     {
-        if (context is null)
-        {
-            throw new ArgumentNullException(nameof(context));
-        }
+        ArgumentNullException.ThrowIfNull(context);
 
         RemoveHeader(context, HeaderName);
 
diff --git a/src/ReverseProxy/Transforms/RequestHeaderTransform.cs b/src/ReverseProxy/Transforms/RequestHeaderTransform.cs
index b46d0d1e2..09fc188ec 100644
--- a/src/ReverseProxy/Transforms/RequestHeaderTransform.cs
+++ b/src/ReverseProxy/Transforms/RequestHeaderTransform.cs
@@ -25,10 +25,7 @@ protected RequestHeaderTransform(string headerName, bool append)
 
     public override ValueTask ApplyAsync(RequestTransformContext context)
     {
-        if (context is null)
-        {
-            throw new ArgumentNullException(nameof(context));
-        }
+        ArgumentNullException.ThrowIfNull(context);
 
         var value = GetValue(context);
         if (value is null)
diff --git a/src/ReverseProxy/Transforms/RequestHeaderValueTransform.cs b/src/ReverseProxy/Transforms/RequestHeaderValueTransform.cs
index 47e91c55e..42a40aefe 100644
--- a/src/ReverseProxy/Transforms/RequestHeaderValueTransform.cs
+++ b/src/ReverseProxy/Transforms/RequestHeaderValueTransform.cs
@@ -13,12 +13,9 @@ public class RequestHeaderValueTransform : RequestHeaderTransform
 {
     public RequestHeaderValueTransform(string headerName, string value, bool append) : base(headerName, append)
     {
-        if (string.IsNullOrEmpty(headerName))
-        {
-            throw new ArgumentException($"'{nameof(headerName)}' cannot be null or empty.", nameof(headerName));
-        }
-
-        Value = value ?? throw new ArgumentNullException(nameof(value));
+        ArgumentException.ThrowIfNullOrEmpty(headerName);
+        ArgumentNullException.ThrowIfNull(value);
+        Value = value;
     }
 
     internal string Value { get; }
diff --git a/src/ReverseProxy/Transforms/RequestHeaderXForwardedForTransform.cs b/src/ReverseProxy/Transforms/RequestHeaderXForwardedForTransform.cs
index aa630260f..50b702043 100644
--- a/src/ReverseProxy/Transforms/RequestHeaderXForwardedForTransform.cs
+++ b/src/ReverseProxy/Transforms/RequestHeaderXForwardedForTransform.cs
@@ -37,10 +37,7 @@ public RequestHeaderXForwardedForTransform(string headerName, ForwardedTransform
     /// <inheritdoc/>
     public override ValueTask ApplyAsync(RequestTransformContext context)
     {
-        if (context is null)
-        {
-            throw new ArgumentNullException(nameof(context));
-        }
+        ArgumentNullException.ThrowIfNull(context);
 
         string? remoteIp = null;
         var remoteIpAddress = context.HttpContext.Connection.RemoteIpAddress;
diff --git a/src/ReverseProxy/Transforms/RequestHeaderXForwardedHostTransform.cs b/src/ReverseProxy/Transforms/RequestHeaderXForwardedHostTransform.cs
index 4fbd3decf..3309b2a3e 100644
--- a/src/ReverseProxy/Transforms/RequestHeaderXForwardedHostTransform.cs
+++ b/src/ReverseProxy/Transforms/RequestHeaderXForwardedHostTransform.cs
@@ -20,10 +20,7 @@ public class RequestHeaderXForwardedHostTransform : RequestTransform
     /// <param name="action">Action to applied to the header.</param>
     public RequestHeaderXForwardedHostTransform(string headerName, ForwardedTransformActions action)
     {
-        if (string.IsNullOrEmpty(headerName))
-        {
-            throw new ArgumentException($"'{nameof(headerName)}' cannot be null or empty.", nameof(headerName));
-        }
+        ArgumentException.ThrowIfNullOrEmpty(headerName);
 
         HeaderName = headerName;
         Debug.Assert(action != ForwardedTransformActions.Off);
@@ -36,10 +33,7 @@ public RequestHeaderXForwardedHostTransform(string headerName, ForwardedTransfor
     /// <inheritdoc/>
     public override ValueTask ApplyAsync(RequestTransformContext context)
     {
-        if (context is null)
-        {
-            throw new ArgumentNullException(nameof(context));
-        }
+        ArgumentNullException.ThrowIfNull(context);
 
         var host = context.HttpContext.Request.Host;
 
diff --git a/src/ReverseProxy/Transforms/RequestHeaderXForwardedPrefixTransform.cs b/src/ReverseProxy/Transforms/RequestHeaderXForwardedPrefixTransform.cs
index 1fa465674..c493e7d7e 100644
--- a/src/ReverseProxy/Transforms/RequestHeaderXForwardedPrefixTransform.cs
+++ b/src/ReverseProxy/Transforms/RequestHeaderXForwardedPrefixTransform.cs
@@ -31,10 +31,7 @@ public RequestHeaderXForwardedPrefixTransform(string headerName, ForwardedTransf
     /// <inheritdoc/>
     public override ValueTask ApplyAsync(RequestTransformContext context)
     {
-        if (context is null)
-        {
-            throw new ArgumentNullException(nameof(context));
-        }
+        ArgumentNullException.ThrowIfNull(context);
 
         var pathBase = context.HttpContext.Request.PathBase;
 
diff --git a/src/ReverseProxy/Transforms/RequestHeaderXForwardedProtoTransform.cs b/src/ReverseProxy/Transforms/RequestHeaderXForwardedProtoTransform.cs
index f4e4c7a93..2acbbc2f2 100644
--- a/src/ReverseProxy/Transforms/RequestHeaderXForwardedProtoTransform.cs
+++ b/src/ReverseProxy/Transforms/RequestHeaderXForwardedProtoTransform.cs
@@ -36,10 +36,7 @@ public RequestHeaderXForwardedProtoTransform(string headerName, ForwardedTransfo
     /// <inheritdoc/>
     public override ValueTask ApplyAsync(RequestTransformContext context)
     {
-        if (context is null)
-        {
-            throw new ArgumentNullException(nameof(context));
-        }
+        ArgumentNullException.ThrowIfNull(context);
 
         var scheme = context.HttpContext.Request.Scheme;
 
diff --git a/src/ReverseProxy/Transforms/RequestHeadersAllowedTransform.cs b/src/ReverseProxy/Transforms/RequestHeadersAllowedTransform.cs
index d71ca2ce3..93757f6b3 100644
--- a/src/ReverseProxy/Transforms/RequestHeadersAllowedTransform.cs
+++ b/src/ReverseProxy/Transforms/RequestHeadersAllowedTransform.cs
@@ -17,10 +17,7 @@ public class RequestHeadersAllowedTransform : RequestTransform
 {
     public RequestHeadersAllowedTransform(string[] allowedHeaders)
     {
-        if (allowedHeaders is null)
-        {
-            throw new ArgumentNullException(nameof(allowedHeaders));
-        }
+        ArgumentNullException.ThrowIfNull(allowedHeaders);
 
         AllowedHeaders = allowedHeaders;
         AllowedHeadersSet = new HashSet<string>(allowedHeaders, StringComparer.OrdinalIgnoreCase).ToFrozenSet(StringComparer.OrdinalIgnoreCase);
@@ -33,10 +30,7 @@ public RequestHeadersAllowedTransform(string[] allowedHeaders)
     /// <inheritdoc/>
     public override ValueTask ApplyAsync(RequestTransformContext context)
     {
-        if (context is null)
-        {
-            throw new ArgumentNullException(nameof(context));
-        }
+        ArgumentNullException.ThrowIfNull(context);
 
         Debug.Assert(!context.HeadersCopied);
 
diff --git a/src/ReverseProxy/Transforms/RequestTransform.cs b/src/ReverseProxy/Transforms/RequestTransform.cs
index 8872efee5..3d199e61a 100644
--- a/src/ReverseProxy/Transforms/RequestTransform.cs
+++ b/src/ReverseProxy/Transforms/RequestTransform.cs
@@ -57,15 +57,8 @@ public static StringValues TakeHeader(RequestTransformContext context, string he
     /// </summary>
     public static void AddHeader(RequestTransformContext context, string headerName, StringValues values)
     {
-        if (context is null)
-        {
-            throw new ArgumentNullException(nameof(context));
-        }
-
-        if (string.IsNullOrEmpty(headerName))
-        {
-            throw new ArgumentException($"'{nameof(headerName)}' cannot be null or empty.", nameof(headerName));
-        }
+        ArgumentNullException.ThrowIfNull(context);
+        ArgumentException.ThrowIfNullOrEmpty(headerName);
 
         RequestUtilities.AddHeader(context.ProxyRequest, headerName, values);
     }
@@ -75,15 +68,8 @@ public static void AddHeader(RequestTransformContext context, string headerName,
     /// </summary>
     public static void RemoveHeader(RequestTransformContext context, string headerName)
     {
-        if (context is null)
-        {
-            throw new ArgumentNullException(nameof(context));
-        }
-
-        if (string.IsNullOrEmpty(headerName))
-        {
-            throw new ArgumentException($"'{nameof(headerName)}' cannot be null or empty.", nameof(headerName));
-        }
+        ArgumentNullException.ThrowIfNull(context);
+        ArgumentException.ThrowIfNullOrEmpty(headerName);
 
         RequestUtilities.RemoveHeader(context.ProxyRequest, headerName);
     }
diff --git a/src/ReverseProxy/Transforms/ResponseFuncTransform.cs b/src/ReverseProxy/Transforms/ResponseFuncTransform.cs
index f4ea7f160..19653a52b 100644
--- a/src/ReverseProxy/Transforms/ResponseFuncTransform.cs
+++ b/src/ReverseProxy/Transforms/ResponseFuncTransform.cs
@@ -15,7 +15,8 @@ public class ResponseFuncTransform : ResponseTransform
 
     public ResponseFuncTransform(Func<ResponseTransformContext, ValueTask> func)
     {
-        _func = func ?? throw new ArgumentNullException(nameof(func));
+        ArgumentNullException.ThrowIfNull(func);
+        _func = func;
     }
 
     /// <inheritdoc/>
diff --git a/src/ReverseProxy/Transforms/ResponseHeaderRemoveTransform.cs b/src/ReverseProxy/Transforms/ResponseHeaderRemoveTransform.cs
index dd82a47b5..60a274ee0 100644
--- a/src/ReverseProxy/Transforms/ResponseHeaderRemoveTransform.cs
+++ b/src/ReverseProxy/Transforms/ResponseHeaderRemoveTransform.cs
@@ -30,10 +30,7 @@ public ResponseHeaderRemoveTransform(string headerName, ResponseCondition condit
     /// <inheritdoc/>
     public override ValueTask ApplyAsync(ResponseTransformContext context)
     {
-        if (context is null)
-        {
-            throw new ArgumentNullException(nameof(context));
-        }
+        ArgumentNullException.ThrowIfNull(context);
 
         if (Condition == ResponseCondition.Always
             || Success(context) == (Condition == ResponseCondition.Success))
diff --git a/src/ReverseProxy/Transforms/ResponseHeaderValueTransform.cs b/src/ReverseProxy/Transforms/ResponseHeaderValueTransform.cs
index 41168819d..412c4402a 100644
--- a/src/ReverseProxy/Transforms/ResponseHeaderValueTransform.cs
+++ b/src/ReverseProxy/Transforms/ResponseHeaderValueTransform.cs
@@ -20,7 +20,8 @@ public ResponseHeaderValueTransform(string headerName, string value, bool append
         }
 
         HeaderName = headerName;
-        Value = value ?? throw new ArgumentNullException(nameof(value));
+        ArgumentNullException.ThrowIfNull(value);
+        Value = value;
         Append = append;
         Condition = condition;
     }
@@ -37,10 +38,7 @@ public ResponseHeaderValueTransform(string headerName, string value, bool append
     /// <inheritdoc/>
     public override ValueTask ApplyAsync(ResponseTransformContext context)
     {
-        if (context is null)
-        {
-            throw new ArgumentNullException(nameof(context));
-        }
+        ArgumentNullException.ThrowIfNull(context);
 
         if (Condition == ResponseCondition.Always
             || Success(context) == (Condition == ResponseCondition.Success))
diff --git a/src/ReverseProxy/Transforms/ResponseHeadersAllowedTransform.cs b/src/ReverseProxy/Transforms/ResponseHeadersAllowedTransform.cs
index ab8b89868..d532994b2 100644
--- a/src/ReverseProxy/Transforms/ResponseHeadersAllowedTransform.cs
+++ b/src/ReverseProxy/Transforms/ResponseHeadersAllowedTransform.cs
@@ -19,10 +19,7 @@ public class ResponseHeadersAllowedTransform : ResponseTransform
 {
     public ResponseHeadersAllowedTransform(string[] allowedHeaders)
     {
-        if (allowedHeaders is null)
-        {
-            throw new ArgumentNullException(nameof(allowedHeaders));
-        }
+        ArgumentNullException.ThrowIfNull(allowedHeaders);
 
         AllowedHeaders = allowedHeaders;
         AllowedHeadersSet = new HashSet<string>(allowedHeaders, StringComparer.OrdinalIgnoreCase).ToFrozenSet(StringComparer.OrdinalIgnoreCase);
@@ -35,10 +32,7 @@ public ResponseHeadersAllowedTransform(string[] allowedHeaders)
     /// <inheritdoc/>
     public override ValueTask ApplyAsync(ResponseTransformContext context)
     {
-        if (context is null)
-        {
-            throw new ArgumentNullException(nameof(context));
-        }
+        ArgumentNullException.ThrowIfNull(context);
 
         if (context.ProxyResponse is null)
         {
diff --git a/src/ReverseProxy/Transforms/ResponseTrailerRemoveTransform.cs b/src/ReverseProxy/Transforms/ResponseTrailerRemoveTransform.cs
index cdec51a16..fd5ae7ffc 100644
--- a/src/ReverseProxy/Transforms/ResponseTrailerRemoveTransform.cs
+++ b/src/ReverseProxy/Transforms/ResponseTrailerRemoveTransform.cs
@@ -32,10 +32,7 @@ public ResponseTrailerRemoveTransform(string headerName, ResponseCondition condi
     /// <inheritdoc/>
     public override ValueTask ApplyAsync(ResponseTrailersTransformContext context)
     {
-        if (context is null)
-        {
-            throw new ArgumentNullException(nameof(context));
-        }
+        ArgumentNullException.ThrowIfNull(context);
 
         Debug.Assert(context.ProxyResponse is not null);
 
diff --git a/src/ReverseProxy/Transforms/ResponseTrailerValueTransform.cs b/src/ReverseProxy/Transforms/ResponseTrailerValueTransform.cs
index 676d4c48c..4fbd29858 100644
--- a/src/ReverseProxy/Transforms/ResponseTrailerValueTransform.cs
+++ b/src/ReverseProxy/Transforms/ResponseTrailerValueTransform.cs
@@ -20,7 +20,8 @@ public ResponseTrailerValueTransform(string headerName, string value, bool appen
         }
 
         HeaderName = headerName;
-        Value = value ?? throw new ArgumentNullException(nameof(value));
+        ArgumentNullException.ThrowIfNull(value);
+        Value = value;
         Append = append;
         Condition = condition;
     }
@@ -37,10 +38,7 @@ public ResponseTrailerValueTransform(string headerName, string value, bool appen
     /// <inheritdoc/>
     public override ValueTask ApplyAsync(ResponseTrailersTransformContext context)
     {
-        if (context is null)
-        {
-            throw new ArgumentNullException(nameof(context));
-        }
+        ArgumentNullException.ThrowIfNull(context);
 
         if (Condition == ResponseCondition.Always
             || Success(context) == (Condition == ResponseCondition.Success))
diff --git a/src/ReverseProxy/Transforms/ResponseTrailersAllowedTransform.cs b/src/ReverseProxy/Transforms/ResponseTrailersAllowedTransform.cs
index 49b7241e2..74e411157 100644
--- a/src/ReverseProxy/Transforms/ResponseTrailersAllowedTransform.cs
+++ b/src/ReverseProxy/Transforms/ResponseTrailersAllowedTransform.cs
@@ -20,10 +20,7 @@ public class ResponseTrailersAllowedTransform : ResponseTrailersTransform
 {
     public ResponseTrailersAllowedTransform(string[] allowedHeaders)
     {
-        if (allowedHeaders is null)
-        {
-            throw new ArgumentNullException(nameof(allowedHeaders));
-        }
+        ArgumentNullException.ThrowIfNull(allowedHeaders);
 
         AllowedHeaders = allowedHeaders;
         AllowedHeadersSet = new HashSet<string>(allowedHeaders, StringComparer.OrdinalIgnoreCase).ToFrozenSet(StringComparer.OrdinalIgnoreCase);
@@ -36,10 +33,7 @@ public ResponseTrailersAllowedTransform(string[] allowedHeaders)
     /// <inheritdoc/>
     public override ValueTask ApplyAsync(ResponseTrailersTransformContext context)
     {
-        if (context is null)
-        {
-            throw new ArgumentNullException(nameof(context));
-        }
+        ArgumentNullException.ThrowIfNull(context);
 
         Debug.Assert(context.ProxyResponse is not null);
         Debug.Assert(!context.HeadersCopied);
diff --git a/src/ReverseProxy/Transforms/ResponseTrailersFuncTransform.cs b/src/ReverseProxy/Transforms/ResponseTrailersFuncTransform.cs
index 4d9ec85d2..41bf2634b 100644
--- a/src/ReverseProxy/Transforms/ResponseTrailersFuncTransform.cs
+++ b/src/ReverseProxy/Transforms/ResponseTrailersFuncTransform.cs
@@ -15,7 +15,8 @@ public class ResponseTrailersFuncTransform : ResponseTrailersTransform
 
     public ResponseTrailersFuncTransform(Func<ResponseTrailersTransformContext, ValueTask> func)
     {
-        _func = func ?? throw new ArgumentNullException(nameof(func));
+        ArgumentNullException.ThrowIfNull(func);
+        _func = func;
     }
 
     /// <inheritdoc/>
diff --git a/src/ReverseProxy/Transforms/ResponseTrailersTransform.cs b/src/ReverseProxy/Transforms/ResponseTrailersTransform.cs
index 5b7805023..e7c913670 100644
--- a/src/ReverseProxy/Transforms/ResponseTrailersTransform.cs
+++ b/src/ReverseProxy/Transforms/ResponseTrailersTransform.cs
@@ -33,15 +33,8 @@ public abstract class ResponseTrailersTransform
     /// <returns>The response header value, or StringValues.Empty if none.</returns>
     public static StringValues TakeHeader(ResponseTrailersTransformContext context, string headerName)
     {
-        if (context is null)
-        {
-            throw new ArgumentNullException(nameof(context));
-        }
-
-        if (string.IsNullOrEmpty(headerName))
-        {
-            throw new ArgumentException($"'{nameof(headerName)}' cannot be null or empty.", nameof(headerName));
-        }
+        ArgumentNullException.ThrowIfNull(context);
+        ArgumentException.ThrowIfNullOrEmpty(headerName);
 
         Debug.Assert(context.ProxyResponse is not null);
 
diff --git a/src/ReverseProxy/Transforms/ResponseTransform.cs b/src/ReverseProxy/Transforms/ResponseTransform.cs
index 77053166d..16a0bbb57 100644
--- a/src/ReverseProxy/Transforms/ResponseTransform.cs
+++ b/src/ReverseProxy/Transforms/ResponseTransform.cs
@@ -31,10 +31,7 @@ public abstract class ResponseTransform
     /// <returns>The response header value, or StringValues.Empty if none.</returns>
     public static StringValues TakeHeader(ResponseTransformContext context, string headerName)
     {
-        if (context is null)
-        {
-            throw new ArgumentNullException(nameof(context));
-        }
+        ArgumentNullException.ThrowIfNull(context);
 
         if (string.IsNullOrEmpty(headerName))
         {
diff --git a/src/ReverseProxy/Transforms/RouteConfigTransformExtensions.cs b/src/ReverseProxy/Transforms/RouteConfigTransformExtensions.cs
index 8ae074840..b593b7286 100644
--- a/src/ReverseProxy/Transforms/RouteConfigTransformExtensions.cs
+++ b/src/ReverseProxy/Transforms/RouteConfigTransformExtensions.cs
@@ -18,10 +18,7 @@ public static class RouteConfigTransformExtensions
     /// <returns>The cloned route with the new transform.</returns>
     public static RouteConfig WithTransform(this RouteConfig route, Action<IDictionary<string, string>> createTransform)
     {
-        if (createTransform is null)
-        {
-            throw new ArgumentNullException(nameof(createTransform));
-        }
+        ArgumentNullException.ThrowIfNull(createTransform);
 
         List<IReadOnlyDictionary<string, string>> transforms;
         if (route.Transforms is null)
diff --git a/src/ReverseProxy/Transforms/TransformBuilderContextFuncExtensions.cs b/src/ReverseProxy/Transforms/TransformBuilderContextFuncExtensions.cs
index 84bb1737e..0b87cce10 100644
--- a/src/ReverseProxy/Transforms/TransformBuilderContextFuncExtensions.cs
+++ b/src/ReverseProxy/Transforms/TransformBuilderContextFuncExtensions.cs
@@ -18,15 +18,8 @@ public static class TransformBuilderContextFuncExtensions
     /// </summary>
     public static TransformBuilderContext AddRequestTransform(this TransformBuilderContext context, Func<RequestTransformContext, ValueTask> func)
     {
-        if (context is null)
-        {
-            throw new ArgumentNullException(nameof(context));
-        }
-
-        if (func is null)
-        {
-            throw new ArgumentNullException(nameof(func));
-        }
+        ArgumentNullException.ThrowIfNull(context);
+        ArgumentNullException.ThrowIfNull(func);
 
         context.RequestTransforms.Add(new RequestFuncTransform(func));
         return context;
@@ -37,15 +30,8 @@ public static TransformBuilderContext AddRequestTransform(this TransformBuilderC
     /// </summary>
     public static TransformBuilderContext AddResponseTransform(this TransformBuilderContext context, Func<ResponseTransformContext, ValueTask> func)
     {
-        if (context is null)
-        {
-            throw new ArgumentNullException(nameof(context));
-        }
-
-        if (func is null)
-        {
-            throw new ArgumentNullException(nameof(func));
-        }
+        ArgumentNullException.ThrowIfNull(context);
+        ArgumentNullException.ThrowIfNull(func);
 
         context.ResponseTransforms.Add(new ResponseFuncTransform(func));
         return context;
@@ -56,15 +42,8 @@ public static TransformBuilderContext AddResponseTransform(this TransformBuilder
     /// </summary>
     public static TransformBuilderContext AddResponseTrailersTransform(this TransformBuilderContext context, Func<ResponseTrailersTransformContext, ValueTask> func)
     {
-        if (context is null)
-        {
-            throw new ArgumentNullException(nameof(context));
-        }
-
-        if (func is null)
-        {
-            throw new ArgumentNullException(nameof(func));
-        }
+        ArgumentNullException.ThrowIfNull(context);
+        ArgumentNullException.ThrowIfNull(func);
 
         context.ResponseTrailersTransforms.Add(new ResponseTrailersFuncTransform(func));
         return context;
diff --git a/src/ReverseProxy/Utilities/ParsedMetadataEntry.cs b/src/ReverseProxy/Utilities/ParsedMetadataEntry.cs
index b279d56b5..f634ce368 100644
--- a/src/ReverseProxy/Utilities/ParsedMetadataEntry.cs
+++ b/src/ReverseProxy/Utilities/ParsedMetadataEntry.cs
@@ -18,9 +18,13 @@ internal sealed class ParsedMetadataEntry<T>
 
     public ParsedMetadataEntry(Parser parser, ClusterState cluster, string metadataName)
     {
-        _parser = parser ?? throw new ArgumentNullException(nameof(parser));
-        _cluster = cluster ?? throw new ArgumentNullException(nameof(cluster));
-        _metadataName = metadataName ?? throw new ArgumentNullException(nameof(metadataName));
+        ArgumentNullException.ThrowIfNull(parser);
+        ArgumentNullException.ThrowIfNull(cluster);
+        ArgumentNullException.ThrowIfNull(metadataName);
+
+        _parser = parser;
+        _cluster = cluster;
+        _metadataName = metadataName;
     }
 
     public T GetParsedOrDefault(T defaultValue)
diff --git a/src/ReverseProxy/Utilities/ServiceLookupHelper.cs b/src/ReverseProxy/Utilities/ServiceLookupHelper.cs
index 102282a1b..8dca977ef 100644
--- a/src/ReverseProxy/Utilities/ServiceLookupHelper.cs
+++ b/src/ReverseProxy/Utilities/ServiceLookupHelper.cs
@@ -11,10 +11,7 @@ internal static class ServiceLookupHelper
 {
     public static FrozenDictionary<string, T> ToDictionaryByUniqueId<T>(this IEnumerable<T> services, Func<T, string> idSelector)
     {
-        if (services is null)
-        {
-            throw new ArgumentNullException(nameof(services));
-        }
+        ArgumentNullException.ThrowIfNull(services);
 
         var result = new Dictionary<string, T>(StringComparer.OrdinalIgnoreCase);
 
diff --git a/src/ReverseProxy/WebSocketsTelemetry/HttpConnectFeatureWrapper.cs b/src/ReverseProxy/WebSocketsTelemetry/HttpConnectFeatureWrapper.cs
index 02fafa61d..cc0285f1d 100644
--- a/src/ReverseProxy/WebSocketsTelemetry/HttpConnectFeatureWrapper.cs
+++ b/src/ReverseProxy/WebSocketsTelemetry/HttpConnectFeatureWrapper.cs
@@ -26,9 +26,13 @@ internal sealed class HttpConnectFeatureWrapper : IHttpExtendedConnectFeature
 
     public HttpConnectFeatureWrapper(TimeProvider timeProvider, HttpContext httpContext, IHttpExtendedConnectFeature connectFeature)
     {
-        _timeProvider = timeProvider ?? throw new ArgumentNullException(nameof(timeProvider));
-        HttpContext = httpContext ?? throw new ArgumentNullException(nameof(httpContext));
-        InnerConnectFeature = connectFeature ?? throw new ArgumentNullException(nameof(connectFeature));
+        ArgumentNullException.ThrowIfNull(timeProvider);
+        ArgumentNullException.ThrowIfNull(httpContext);
+        ArgumentNullException.ThrowIfNull(connectFeature);
+
+        _timeProvider = timeProvider;
+        HttpContext = httpContext;
+        InnerConnectFeature = connectFeature;
     }
 
     public async ValueTask<Stream> AcceptAsync()
diff --git a/src/ReverseProxy/WebSocketsTelemetry/HttpUpgradeFeatureWrapper.cs b/src/ReverseProxy/WebSocketsTelemetry/HttpUpgradeFeatureWrapper.cs
index 19c115ed0..7e4142e99 100644
--- a/src/ReverseProxy/WebSocketsTelemetry/HttpUpgradeFeatureWrapper.cs
+++ b/src/ReverseProxy/WebSocketsTelemetry/HttpUpgradeFeatureWrapper.cs
@@ -25,9 +25,13 @@ internal sealed class HttpUpgradeFeatureWrapper : IHttpUpgradeFeature
 
     public HttpUpgradeFeatureWrapper(TimeProvider timeProvider, HttpContext httpContext, IHttpUpgradeFeature upgradeFeature)
     {
-        _timeProvider = timeProvider ?? throw new ArgumentNullException(nameof(timeProvider));
-        HttpContext = httpContext ?? throw new ArgumentNullException(nameof(httpContext));
-        InnerUpgradeFeature = upgradeFeature ?? throw new ArgumentNullException(nameof(upgradeFeature));
+        ArgumentNullException.ThrowIfNull(timeProvider);
+        ArgumentNullException.ThrowIfNull(httpContext);
+        ArgumentNullException.ThrowIfNull(upgradeFeature);
+
+        _timeProvider = timeProvider;
+        HttpContext = httpContext;
+        InnerUpgradeFeature = upgradeFeature;
     }
 
     public async Task<Stream> UpgradeAsync()
diff --git a/src/ReverseProxy/WebSocketsTelemetry/WebSocketsTelemetryMiddleware.cs b/src/ReverseProxy/WebSocketsTelemetry/WebSocketsTelemetryMiddleware.cs
index b34ed3da6..90b18c02a 100644
--- a/src/ReverseProxy/WebSocketsTelemetry/WebSocketsTelemetryMiddleware.cs
+++ b/src/ReverseProxy/WebSocketsTelemetry/WebSocketsTelemetryMiddleware.cs
@@ -15,8 +15,11 @@ internal sealed class WebSocketsTelemetryMiddleware
 
     public WebSocketsTelemetryMiddleware(RequestDelegate next, TimeProvider timeProvider)
     {
-        _next = next ?? throw new ArgumentNullException(nameof(next));
-        _timeProvider = timeProvider ?? throw new ArgumentNullException(nameof(timeProvider));
+        ArgumentNullException.ThrowIfNull(next);
+        ArgumentNullException.ThrowIfNull(timeProvider);
+
+        _next = next;
+        _timeProvider = timeProvider;
     }
 
     public Task InvokeAsync(HttpContext context)
diff --git a/src/TelemetryConsumption/EventListenerService.cs b/src/TelemetryConsumption/EventListenerService.cs
index ffbd6fbd6..ac30292fd 100644
--- a/src/TelemetryConsumption/EventListenerService.cs
+++ b/src/TelemetryConsumption/EventListenerService.cs
@@ -37,10 +37,11 @@ public EventListenerService(
         IEnumerable<TTelemetryConsumer> telemetryConsumers,
         IEnumerable<IMetricsConsumer<TMetrics>> metricsConsumers)
     {
-        _logger = logger ?? throw new ArgumentNullException(nameof(logger));
-        _ = telemetryConsumers ?? throw new ArgumentNullException(nameof(telemetryConsumers));
-        _ = metricsConsumers ?? throw new ArgumentNullException(nameof(metricsConsumers));
-
+        ArgumentNullException.ThrowIfNull(logger);
+        ArgumentNullException.ThrowIfNull(telemetryConsumers);
+        ArgumentNullException.ThrowIfNull(metricsConsumers);
+        
+        _logger = logger;
         _telemetryConsumers = telemetryConsumers.ToArray();
         _metricsConsumers = metricsConsumers.ToArray();
 


Test patch:
diff --git a/test/Kubernetes.Tests/TestCluster/TestCluster.cs b/test/Kubernetes.Tests/TestCluster/TestCluster.cs
index 304e922de..ca02d1fe3 100644
--- a/test/Kubernetes.Tests/TestCluster/TestCluster.cs
+++ b/test/Kubernetes.Tests/TestCluster/TestCluster.cs
@@ -18,10 +18,7 @@ public class TestCluster : ITestCluster
 
     public TestCluster(IOptions<TestClusterOptions> options)
     {
-        if (options is null)
-        {
-            throw new ArgumentNullException(nameof(options));
-        }
+        ArgumentNullException.ThrowIfNull(options);
 
         foreach (var resource in options.Value.InitialResources)
         {
@@ -36,20 +33,9 @@ public virtual Task UnhandledRequest(HttpContext context)
 
     public virtual Task<ListResult> ListResourcesAsync(string group, string version, string plural, ListParameters parameters)
     {
-        if (string.IsNullOrEmpty(version))
-        {
-            throw new ArgumentException($"'{nameof(version)}' cannot be null or empty", nameof(version));
-        }
-
-        if (string.IsNullOrEmpty(plural))
-        {
-            throw new ArgumentException($"'{nameof(plural)}' cannot be null or empty", nameof(plural));
-        }
-
-        if (parameters is null)
-        {
-            throw new ArgumentNullException(nameof(parameters));
-        }
+        ArgumentException.ThrowIfNullOrEmpty(version);
+        ArgumentException.ThrowIfNullOrEmpty(plural);
+        ArgumentNullException.ThrowIfNull(parameters);
 
         return Task.FromResult(new ListResult
         {
diff --git a/test/ReverseProxy.Tests/Common/MockHttpHandler.cs b/test/ReverseProxy.Tests/Common/MockHttpHandler.cs
index cbbd31df9..7b85a43b0 100644
--- a/test/ReverseProxy.Tests/Common/MockHttpHandler.cs
+++ b/test/ReverseProxy.Tests/Common/MockHttpHandler.cs
@@ -14,7 +14,8 @@ internal class MockHttpHandler : HttpMessageHandler
 
     public MockHttpHandler(Func<HttpRequestMessage, CancellationToken, Task<HttpResponseMessage>> func)
     {
-        _func = func ?? throw new ArgumentNullException(nameof(func));
+        ArgumentNullException.ThrowIfNull(func);
+        _func = func;
     }
 
     public static HttpMessageInvoker CreateClient(Func<HttpRequestMessage, CancellationToken, Task<HttpResponseMessage>> func)
diff --git a/test/ReverseProxy.Tests/Forwarder/HttpForwarderTests.cs b/test/ReverseProxy.Tests/Forwarder/HttpForwarderTests.cs
index 82bb01a1b..c9e47e941 100644
--- a/test/ReverseProxy.Tests/Forwarder/HttpForwarderTests.cs
+++ b/test/ReverseProxy.Tests/Forwarder/HttpForwarderTests.cs
@@ -1064,7 +1064,6 @@ public async Task RequestWithCookieHeaders(params string[] cookies)
     {
         var events = TestEventListener.Collect();
 
-        
         var httpContext = new DefaultHttpContext();
         httpContext.Request.Method = "GET";
         httpContext.Request.Headers[HeaderNames.Cookie] = cookies;
@@ -1260,7 +1259,7 @@ public static IEnumerable<object[]> ResponseMultiHeadersData()
     {
         foreach (var header in ResponseMultiHeaderNames())
         {
-            foreach (var version in new[] { "1.1", "2.0" })                
+            foreach (var version in new[] { "1.1", "2.0" })
             {
                 foreach (var value in MultiValues())
                 {
@@ -2935,8 +2934,10 @@ private class DuplexStream : Stream
     {
         public DuplexStream(Stream readStream, Stream writeStream)
         {
-            ReadStream = readStream ?? throw new ArgumentNullException(nameof(readStream));
-            WriteStream = writeStream ?? throw new ArgumentNullException(nameof(writeStream));
+            ArgumentNullException.ThrowIfNull(readStream);
+            ArgumentNullException.ThrowIfNull(writeStream);
+            ReadStream = readStream;
+            WriteStream = writeStream;
         }
 
         public Stream ReadStream { get; }
@@ -3009,7 +3010,8 @@ private class RawStreamContent : HttpContent
 
         public RawStreamContent(Stream stream)
         {
-            _stream = stream ?? throw new ArgumentNullException(nameof(stream));
+            ArgumentNullException.ThrowIfNull(stream);
+            _stream = stream;
         }
 
         protected override Task<Stream> CreateContentReadStreamAsync()
diff --git a/test/Tests.Common/TestAutoMockBase.cs b/test/Tests.Common/TestAutoMockBase.cs
index 897666536..49a478a19 100644
--- a/test/Tests.Common/TestAutoMockBase.cs
+++ b/test/Tests.Common/TestAutoMockBase.cs
@@ -70,8 +70,7 @@ public Mock<TDependencyToMock> Mock<TDependencyToMock>()
     public void Provide<TService>(TService instance)
         where TService : class
     {
-        _ = instance ?? throw new ArgumentNullException(nameof(instance));
-
+        ArgumentNullException.ThrowIfNull(instance);
         AutoMock.Provide(instance);
     }