Use is null instead of == null (#1565)

* Use is null instead of == null

* Use is null in new code

Co-authored-by: Miha Zupan <mihazupan.zupan1@gmail.com>
This commit is contained in:
Kahbazi 2022-03-29 04:21:06 +04:30 коммит произвёл GitHub
Родитель f2d943cf45
Коммит 9bbdf5eec8
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
101 изменённых файлов: 290 добавлений и 290 удалений

Просмотреть файл

@ -139,7 +139,7 @@ public class FirstUnsuccessfulResponseHealthPolicy : IActiveHealthCheckPolicy
for (var i = 0; i < probingResults.Count; i++)
{
var response = probingResults[i].Response;
var newHealth = response != null && response.IsSuccessStatusCode ? DestinationHealth.Healthy : DestinationHealth.Unhealthy;
var newHealth = response is not null && response.IsSuccessStatusCode ? DestinationHealth.Healthy : DestinationHealth.Unhealthy;
newHealthStates[i] = new NewActiveDestinationHealth(probingResults[i].Destination, newHealth);
}
@ -317,7 +317,7 @@ public class FirstUnsuccessfulResponseHealthPolicy : IPassiveHealthCheckPolicy
public void RequestProxied(ClusterState cluster, DestinationState destination, HttpContext context)
{
var error = context.Features.Get<IProxyErrorFeature>();
if (error != null)
if (error is not null)
{
var reactivationPeriod = cluster.Model.Config.HealthCheck.Passive.ReactivationPeriod ?? _defaultReactivationPeriod;
_ = _healthUpdater.SetPassiveAsync(cluster, destination, DestinationHealth.Unhealthy, reactivationPeriod);

Просмотреть файл

@ -137,7 +137,7 @@ proxyPipeline.Use(async (context, next) =>
await next();
var errorFeature = context.GetForwarderErrorFeature();
if (errorFeature != null)
if (errorFeature is not null)
{
Report(errorFeature.Error, errorFeature.Exception);
}

Просмотреть файл

@ -145,7 +145,7 @@ public class IngressCache : ICache
private bool IsYarpIngress(V1IngressSpec spec)
{
if (spec.IngressClassName != null)
if (spec.IngressClassName is not null)
{
lock (_sync)
{

Просмотреть файл

@ -90,7 +90,7 @@ internal static class YarpParser
{
Match = new RouteMatch()
{
Hosts = host != null ? new[] { host } : Array.Empty<string>(),
Hosts = host is not null ? new[] { host } : Array.Empty<string>(),
Path = pathMatch
},
ClusterId = cluster.ClusterId,
@ -117,7 +117,7 @@ internal static class YarpParser
private static string UpstreamName(string namespaceName, V1IngressServiceBackend ingressServiceBackend)
{
if (ingressServiceBackend != null)
if (ingressServiceBackend is not null)
{
if (ingressServiceBackend.Port.Number.HasValue && ingressServiceBackend.Port.Number.Value > 0)
{
@ -156,7 +156,7 @@ internal static class YarpParser
{
var options = context.Options;
var annotations = metadata.Annotations;
if (annotations == null)
if (annotations is null)
{
return options;
}
@ -216,7 +216,7 @@ internal static class YarpParser
private static bool MatchesPort(Corev1EndpointPort port1, IntstrIntOrString port2)
{
if (port1 == null || port2 == null)
if (port1 is null || port2 is null)
{
return false;
}
@ -233,15 +233,15 @@ internal static class YarpParser
private static bool MatchesPort(V1ServicePort port1, V1ServiceBackendPort port2)
{
if (port1 == null || port2 == null)
if (port1 is null || port2 is null)
{
return false;
}
if (port2.Number != null && port2.Number == port1.Port)
if (port2.Number is not null && port2.Number == port1.Port)
{
return true;
}
if (port2.Name != null && string.Equals(port2.Name, port1.Name, StringComparison.Ordinal))
if (port2.Name is not null && string.Equals(port2.Name, port1.Name, StringComparison.Ordinal))
{
return true;
}

Просмотреть файл

@ -11,7 +11,7 @@ public static class MessageConfigProviderExtensions
{
public static IReverseProxyBuilder LoadFromMessages(this IReverseProxyBuilder builder)
{
if (builder == null)
if (builder is null)
{
throw new ArgumentNullException(nameof(builder));
}

Просмотреть файл

@ -405,7 +405,7 @@ namespace Microsoft.Kubernetes.Controller.Informers
catch (Exception innerException)
#pragma warning restore CA1031 // Do not catch general exception types
{
if (innerExceptions == null)
if (innerExceptions is null)
{
innerExceptions = new List<Exception>();
}
@ -414,7 +414,7 @@ namespace Microsoft.Kubernetes.Controller.Informers
}
}
if (innerExceptions != null)
if (innerExceptions is not null)
{
throw new AggregateException("One or more exceptions thrown by ResourceInformerCallback.", innerExceptions);
}

Просмотреть файл

@ -59,15 +59,15 @@ public class AnyResourceKind : IServiceOperations<k8s.Kubernetes>, IAnyResourceK
public async Task<HttpOperationResponse<KubernetesList<TResource>>> ListClusterAnyResourceKindWithHttpMessagesAsync<TResource>(string group, string version, string plural, string continueParameter = null, string fieldSelector = null, string labelSelector = null, int? limit = null, string resourceVersion = null, int? timeoutSeconds = null, bool? watch = null, string pretty = null, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default) where TResource : IKubernetesObject
{
if (group == null)
if (group is null)
{
throw new ValidationException(ValidationRules.CannotBeNull, "group");
}
if (version == null)
if (version is null)
{
throw new ValidationException(ValidationRules.CannotBeNull, "version");
}
if (plural == null)
if (plural is null)
{
throw new ValidationException(ValidationRules.CannotBeNull, "plural");
}
@ -109,35 +109,35 @@ public class AnyResourceKind : IServiceOperations<k8s.Kubernetes>, IAnyResourceK
_url = _url.Replace("{version}", System.Uri.EscapeDataString(version));
_url = _url.Replace("{plural}", System.Uri.EscapeDataString(plural));
List<string> _queryParameters = new List<string>();
if (continueParameter != null)
if (continueParameter is not null)
{
_queryParameters.Add(string.Format("continue={0}", System.Uri.EscapeDataString(continueParameter)));
}
if (fieldSelector != null)
if (fieldSelector is not null)
{
_queryParameters.Add(string.Format("fieldSelector={0}", System.Uri.EscapeDataString(fieldSelector)));
}
if (labelSelector != null)
if (labelSelector is not null)
{
_queryParameters.Add(string.Format("labelSelector={0}", System.Uri.EscapeDataString(labelSelector)));
}
if (limit != null)
if (limit is not null)
{
_queryParameters.Add(string.Format("limit={0}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeObject(limit, Client.SerializationSettings).Trim('"'))));
}
if (resourceVersion != null)
if (resourceVersion is not null)
{
_queryParameters.Add(string.Format("resourceVersion={0}", System.Uri.EscapeDataString(resourceVersion)));
}
if (timeoutSeconds != null)
if (timeoutSeconds is not null)
{
_queryParameters.Add(string.Format("timeoutSeconds={0}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeObject(timeoutSeconds, Client.SerializationSettings).Trim('"'))));
}
if (watch != null)
if (watch is not null)
{
_queryParameters.Add(string.Format("watch={0}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeObject(watch, Client.SerializationSettings).Trim('"'))));
}
if (pretty != null)
if (pretty is not null)
{
_queryParameters.Add(string.Format("pretty={0}", System.Uri.EscapeDataString(pretty)));
}
@ -153,7 +153,7 @@ public class AnyResourceKind : IServiceOperations<k8s.Kubernetes>, IAnyResourceK
// Set Headers
if (customHeaders != null)
if (customHeaders is not null)
{
foreach (var _header in customHeaders)
{
@ -168,7 +168,7 @@ public class AnyResourceKind : IServiceOperations<k8s.Kubernetes>, IAnyResourceK
// Serialize Request
string _requestContent = null;
// Set Credentials
if (Client.Credentials != null)
if (Client.Credentials is not null)
{
cancellationToken.ThrowIfCancellationRequested();
await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
@ -190,7 +190,7 @@ public class AnyResourceKind : IServiceOperations<k8s.Kubernetes>, IAnyResourceK
if ((int)_statusCode != 200)
{
var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
if (_httpResponse.Content != null)
if (_httpResponse.Content is not null)
{
_responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
}
@ -205,7 +205,7 @@ public class AnyResourceKind : IServiceOperations<k8s.Kubernetes>, IAnyResourceK
ServiceClientTracing.Error(_invocationId, ex);
}
_httpRequest.Dispose();
if (_httpResponse != null)
if (_httpResponse is not null)
{
_httpResponse.Dispose();
}
@ -226,7 +226,7 @@ public class AnyResourceKind : IServiceOperations<k8s.Kubernetes>, IAnyResourceK
catch (Newtonsoft.Json.JsonException ex)
{
_httpRequest.Dispose();
if (_httpResponse != null)
if (_httpResponse is not null)
{
_httpResponse.Dispose();
}
@ -243,23 +243,23 @@ public class AnyResourceKind : IServiceOperations<k8s.Kubernetes>, IAnyResourceK
public async Task<HttpOperationResponse<object>> CreateAnyResourceKindWithHttpMessagesAsync<TResource>(TResource body, string group, string version, string namespaceParameter, string plural, string dryRun = default(string), string fieldManager = default(string), string pretty = default(string), Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) where TResource : IKubernetesObject
{
if (body == null)
if (body is null)
{
throw new ValidationException(ValidationRules.CannotBeNull, "body");
}
if (group == null)
if (group is null)
{
throw new ValidationException(ValidationRules.CannotBeNull, "group");
}
if (version == null)
if (version is null)
{
throw new ValidationException(ValidationRules.CannotBeNull, "version");
}
if (namespaceParameter == null)
if (namespaceParameter is null)
{
throw new ValidationException(ValidationRules.CannotBeNull, "namespaceParameter");
}
if (plural == null)
if (plural is null)
{
throw new ValidationException(ValidationRules.CannotBeNull, "plural");
}
@ -289,15 +289,15 @@ public class AnyResourceKind : IServiceOperations<k8s.Kubernetes>, IAnyResourceK
_url = _url.Replace("{namespace}", System.Uri.EscapeDataString(namespaceParameter));
_url = _url.Replace("{plural}", System.Uri.EscapeDataString(plural));
List<string> _queryParameters = new List<string>();
if (dryRun != null)
if (dryRun is not null)
{
_queryParameters.Add(string.Format("dryRun={0}", System.Uri.EscapeDataString(dryRun)));
}
if (fieldManager != null)
if (fieldManager is not null)
{
_queryParameters.Add(string.Format("fieldManager={0}", System.Uri.EscapeDataString(fieldManager)));
}
if (pretty != null)
if (pretty is not null)
{
_queryParameters.Add(string.Format("pretty={0}", System.Uri.EscapeDataString(pretty)));
}
@ -313,7 +313,7 @@ public class AnyResourceKind : IServiceOperations<k8s.Kubernetes>, IAnyResourceK
// Set Headers
if (customHeaders != null)
if (customHeaders is not null)
{
foreach (var _header in customHeaders)
{
@ -327,14 +327,14 @@ public class AnyResourceKind : IServiceOperations<k8s.Kubernetes>, IAnyResourceK
// Serialize Request
string _requestContent = null;
if (body != null)
if (body is not null)
{
_requestContent = SafeJsonConvert.SerializeObject(body, Client.SerializationSettings);
_httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
_httpRequest.Content.Headers.ContentType = Client.GetHeader(body);
}
// Set Credentials
if (Client.Credentials != null)
if (Client.Credentials is not null)
{
cancellationToken.ThrowIfCancellationRequested();
await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
@ -356,7 +356,7 @@ public class AnyResourceKind : IServiceOperations<k8s.Kubernetes>, IAnyResourceK
if ((int)_statusCode != 201)
{
var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
if (_httpResponse.Content != null)
if (_httpResponse.Content is not null)
{
_responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
}
@ -371,7 +371,7 @@ public class AnyResourceKind : IServiceOperations<k8s.Kubernetes>, IAnyResourceK
ServiceClientTracing.Error(_invocationId, ex);
}
_httpRequest.Dispose();
if (_httpResponse != null)
if (_httpResponse is not null)
{
_httpResponse.Dispose();
}
@ -392,7 +392,7 @@ public class AnyResourceKind : IServiceOperations<k8s.Kubernetes>, IAnyResourceK
catch (JsonException ex)
{
_httpRequest.Dispose();
if (_httpResponse != null)
if (_httpResponse is not null)
{
_httpResponse.Dispose();
}
@ -409,27 +409,27 @@ public class AnyResourceKind : IServiceOperations<k8s.Kubernetes>, IAnyResourceK
public async Task<HttpOperationResponse<object>> PatchAnyResourceKindWithHttpMessagesAsync(V1Patch body, string group, string version, string namespaceParameter, string plural, string name, string dryRun = default(string), string fieldManager = default(string), bool? force = default(bool?), Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
{
if (body == null)
if (body is null)
{
throw new ValidationException(ValidationRules.CannotBeNull, "body");
}
if (group == null)
if (group is null)
{
throw new ValidationException(ValidationRules.CannotBeNull, "group");
}
if (version == null)
if (version is null)
{
throw new ValidationException(ValidationRules.CannotBeNull, "version");
}
if (namespaceParameter == null)
if (namespaceParameter is null)
{
throw new ValidationException(ValidationRules.CannotBeNull, "namespaceParameter");
}
if (plural == null)
if (plural is null)
{
throw new ValidationException(ValidationRules.CannotBeNull, "plural");
}
if (name == null)
if (name is null)
{
throw new ValidationException(ValidationRules.CannotBeNull, "name");
}
@ -461,15 +461,15 @@ public class AnyResourceKind : IServiceOperations<k8s.Kubernetes>, IAnyResourceK
_url = _url.Replace("{plural}", System.Uri.EscapeDataString(plural));
_url = _url.Replace("{name}", System.Uri.EscapeDataString(name));
List<string> _queryParameters = new List<string>();
if (dryRun != null)
if (dryRun is not null)
{
_queryParameters.Add(string.Format("dryRun={0}", System.Uri.EscapeDataString(dryRun)));
}
if (fieldManager != null)
if (fieldManager is not null)
{
_queryParameters.Add(string.Format("fieldManager={0}", System.Uri.EscapeDataString(fieldManager)));
}
if (force != null)
if (force is not null)
{
_queryParameters.Add(string.Format("force={0}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeObject(force, Client.SerializationSettings).Trim('"'))));
}
@ -485,7 +485,7 @@ public class AnyResourceKind : IServiceOperations<k8s.Kubernetes>, IAnyResourceK
// Set Headers
if (customHeaders != null)
if (customHeaders is not null)
{
foreach (var _header in customHeaders)
{
@ -499,14 +499,14 @@ public class AnyResourceKind : IServiceOperations<k8s.Kubernetes>, IAnyResourceK
// Serialize Request
string _requestContent = null;
if (body != null)
if (body is not null)
{
_requestContent = SafeJsonConvert.SerializeObject(body, Client.SerializationSettings);
_httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
_httpRequest.Content.Headers.ContentType = Client.GetHeader(body);
}
// Set Credentials
if (Client.Credentials != null)
if (Client.Credentials is not null)
{
cancellationToken.ThrowIfCancellationRequested();
await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
@ -528,7 +528,7 @@ public class AnyResourceKind : IServiceOperations<k8s.Kubernetes>, IAnyResourceK
if ((int)_statusCode != 200)
{
var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
if (_httpResponse.Content != null)
if (_httpResponse.Content is not null)
{
_responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
}
@ -543,7 +543,7 @@ public class AnyResourceKind : IServiceOperations<k8s.Kubernetes>, IAnyResourceK
ServiceClientTracing.Error(_invocationId, ex);
}
_httpRequest.Dispose();
if (_httpResponse != null)
if (_httpResponse is not null)
{
_httpResponse.Dispose();
}
@ -564,7 +564,7 @@ public class AnyResourceKind : IServiceOperations<k8s.Kubernetes>, IAnyResourceK
catch (JsonException ex)
{
_httpRequest.Dispose();
if (_httpResponse != null)
if (_httpResponse is not null)
{
_httpResponse.Dispose();
}
@ -581,23 +581,23 @@ public class AnyResourceKind : IServiceOperations<k8s.Kubernetes>, IAnyResourceK
public async Task<HttpOperationResponse<object>> DeleteAnyResourceKindWithHttpMessagesAsync(string group, string version, string namespaceParameter, string plural, string name, V1DeleteOptions body = default(V1DeleteOptions), int? gracePeriodSeconds = default(int?), bool? orphanDependents = default(bool?), string propagationPolicy = default(string), string dryRun = default(string), Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
{
if (group == null)
if (group is null)
{
throw new ValidationException(ValidationRules.CannotBeNull, "group");
}
if (version == null)
if (version is null)
{
throw new ValidationException(ValidationRules.CannotBeNull, "version");
}
if (namespaceParameter == null)
if (namespaceParameter is null)
{
throw new ValidationException(ValidationRules.CannotBeNull, "namespaceParameter");
}
if (plural == null)
if (plural is null)
{
throw new ValidationException(ValidationRules.CannotBeNull, "plural");
}
if (name == null)
if (name is null)
{
throw new ValidationException(ValidationRules.CannotBeNull, "name");
}
@ -630,19 +630,19 @@ public class AnyResourceKind : IServiceOperations<k8s.Kubernetes>, IAnyResourceK
_url = _url.Replace("{plural}", System.Uri.EscapeDataString(plural));
_url = _url.Replace("{name}", System.Uri.EscapeDataString(name));
List<string> _queryParameters = new List<string>();
if (gracePeriodSeconds != null)
if (gracePeriodSeconds is not null)
{
_queryParameters.Add(string.Format("gracePeriodSeconds={0}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeObject(gracePeriodSeconds, Client.SerializationSettings).Trim('"'))));
}
if (orphanDependents != null)
if (orphanDependents is not null)
{
_queryParameters.Add(string.Format("orphanDependents={0}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeObject(orphanDependents, Client.SerializationSettings).Trim('"'))));
}
if (propagationPolicy != null)
if (propagationPolicy is not null)
{
_queryParameters.Add(string.Format("propagationPolicy={0}", System.Uri.EscapeDataString(propagationPolicy)));
}
if (dryRun != null)
if (dryRun is not null)
{
_queryParameters.Add(string.Format("dryRun={0}", System.Uri.EscapeDataString(dryRun)));
}
@ -658,7 +658,7 @@ public class AnyResourceKind : IServiceOperations<k8s.Kubernetes>, IAnyResourceK
// Set Headers
if (customHeaders != null)
if (customHeaders is not null)
{
foreach (var _header in customHeaders)
{
@ -672,14 +672,14 @@ public class AnyResourceKind : IServiceOperations<k8s.Kubernetes>, IAnyResourceK
// Serialize Request
string _requestContent = null;
if (body != null)
if (body is not null)
{
_requestContent = SafeJsonConvert.SerializeObject(body, Client.SerializationSettings);
_httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
_httpRequest.Content.Headers.ContentType = Client.GetHeader(body);
}
// Set Credentials
if (Client.Credentials != null)
if (Client.Credentials is not null)
{
cancellationToken.ThrowIfCancellationRequested();
await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
@ -701,7 +701,7 @@ public class AnyResourceKind : IServiceOperations<k8s.Kubernetes>, IAnyResourceK
if ((int)_statusCode != 200)
{
var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
if (_httpResponse.Content != null)
if (_httpResponse.Content is not null)
{
_responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
}
@ -716,7 +716,7 @@ public class AnyResourceKind : IServiceOperations<k8s.Kubernetes>, IAnyResourceK
ServiceClientTracing.Error(_invocationId, ex);
}
_httpRequest.Dispose();
if (_httpResponse != null)
if (_httpResponse is not null)
{
_httpResponse.Dispose();
}
@ -737,7 +737,7 @@ public class AnyResourceKind : IServiceOperations<k8s.Kubernetes>, IAnyResourceK
catch (JsonException ex)
{
_httpRequest.Dispose();
if (_httpResponse != null)
if (_httpResponse is not null)
{
_httpResponse.Dispose();
}

Просмотреть файл

@ -27,7 +27,7 @@ namespace Microsoft.Extensions.DependencyInjection
{
services = services.Configure<KubernetesClientOptions>(options =>
{
if (options.Configuration == null)
if (options.Configuration is null)
{
options.Configuration = KubernetesClientConfiguration.BuildDefaultConfig();
}

Просмотреть файл

@ -21,7 +21,7 @@ public class ResourceKindManager : IResourceKindManager
foreach (var provider in _providers)
{
var resourceKind = await provider.GetResourceKindAsync(apiVersion, kind);
if (resourceKind != null)
if (resourceKind is not null)
{
return resourceKind;
}

Просмотреть файл

@ -61,7 +61,7 @@ public class ResourcePatcher : IResourcePatcher
{
return ReplacePrimative(patch, context);
}
else if (context.ApplyToken == null && context.LastAppliedToken != null)
else if (context.ApplyToken is null && context.LastAppliedToken is not null)
{
return patch.Remove(context.Path);
}
@ -105,7 +105,7 @@ public class ResourcePatcher : IResourcePatcher
var lastApplied = context.LastAppliedToken as JObject;
var live = context.LiveToken as JObject;
if (live == null)
if (live is null)
{
return patch.Replace(context.Path, apply);
}
@ -117,7 +117,7 @@ public class ResourcePatcher : IResourcePatcher
var liveProperty = live.Property(name, StringComparison.Ordinal);
if (liveProperty == null)
if (liveProperty is null)
{
patch = patch.Add(path, applyProperty.Value);
}
@ -141,10 +141,10 @@ public class ResourcePatcher : IResourcePatcher
var name = liveProperty.Name;
var applyProperty = apply.Property(name, StringComparison.Ordinal);
if (applyProperty == null)
if (applyProperty is null)
{
var lastAppliedProperty = lastApplied?.Property(name, StringComparison.Ordinal);
if (lastAppliedProperty != null)
if (lastAppliedProperty is not null)
{
var path = $"{context.Path}/{EscapePath(name)}";
patch = patch.Remove(path);
@ -161,7 +161,7 @@ public class ResourcePatcher : IResourcePatcher
var lastApplied = context.LastAppliedToken as JObject;
var live = context.LiveToken as JObject;
if (live == null)
if (live is null)
{
return patch.Replace(context.Path, apply);
}
@ -175,7 +175,7 @@ public class ResourcePatcher : IResourcePatcher
var liveProperty = live.Property(key, StringComparison.Ordinal);
if (liveProperty == null)
if (liveProperty is null)
{
patch = patch.Add(path, applyProperty.Value);
}
@ -199,10 +199,10 @@ public class ResourcePatcher : IResourcePatcher
var name = liveProperty.Name;
var applyProperty = apply.Property(name, StringComparison.Ordinal);
if (applyProperty == null)
if (applyProperty is null)
{
var lastAppliedProperty = lastApplied?.Property(name, StringComparison.Ordinal);
if (lastAppliedProperty != null)
if (lastAppliedProperty is not null)
{
var path = $"{context.Path}/{EscapePath(name)}";
patch = patch.Remove(path);
@ -321,7 +321,7 @@ public class ResourcePatcher : IResourcePatcher
var (_, index, liveToken) = liveItems.SingleOrDefault(item => item.name == name);
var (_, _, lastAppliedToken) = lastAppliedItems.SingleOrDefault(item => item.name == name);
if (liveToken != null)
if (liveToken is not null)
{
var itemContext = context.Push(
path: $"{context.Path}/{index}",
@ -343,7 +343,7 @@ public class ResourcePatcher : IResourcePatcher
var (_, index, liveToken) = liveItems.SingleOrDefault(item => item.name == name);
var (_, _, applyToken) = applyItems.SingleOrDefault(item => item.name == name);
if (applyToken == null && liveToken != null)
if (applyToken is null && liveToken is not null)
{
patch = patch.Remove($"{context.Path}/{index}");
}

Просмотреть файл

@ -64,7 +64,7 @@ public class CustomResourceDefinitionUpdater<TResource> : IHostedService
var existingCustomResourceDefinition = existingList?.Items?.SingleOrDefault();
if (existingCustomResourceDefinition != null)
if (existingCustomResourceDefinition is not null)
{
customResourceDefinition.Metadata.ResourceVersion = existingCustomResourceDefinition.ResourceVersion();

Просмотреть файл

@ -40,7 +40,7 @@ public struct OperatorCacheWorkItem<TResource> : IEquatable<OperatorCacheWorkIte
/// <value>The related resources.</value>
public ImmutableDictionary<GroupKindNamespacedName, IKubernetesObject<V1ObjectMeta>> Related { get; }
public bool IsEmpty => Resource == null && Related.IsEmpty;
public bool IsEmpty => Resource is null && Related.IsEmpty;
/// <summary>
/// Returns a WorkItem with Resource assigned to new value.

Просмотреть файл

@ -220,7 +220,7 @@ public class OperatorHandler<TResource> : IOperatorHandler<TResource>
};
}
if (result.Error != null)
if (result.Error is not null)
{
// TODO: LOG Reconciler error

Просмотреть файл

@ -91,7 +91,7 @@ public class OperatorReconciler<TResource> : IOperatorReconciler<TResource>
throw new ArgumentNullException(nameof(parameters));
}
if (parameters.Resource == null)
if (parameters.Resource is null)
{
// Custom resource has been deleted - k8s garbage collection will do the rest of the work
return default;

Просмотреть файл

@ -106,14 +106,14 @@ public class OpenApiResourceKind : IResourceKind
private static bool HasPatchStrategy(JsonSchema schema, string value)
{
return
schema.ExtensionData != null &&
schema.ExtensionData is not null &&
schema.ExtensionData.TryGetValue("x-kubernetes-patch-strategy", out var patchStrategy) &&
(patchStrategy as string ?? string.Empty).Split(',').Any(part => part == value);
}
private static bool HasPatchMergeKey(JsonSchema schema, out string mergeKey)
{
if (schema.ExtensionData != null &&
if (schema.ExtensionData is not null &&
schema.ExtensionData.TryGetValue("x-kubernetes-patch-merge-key", out var value) &&
value is string stringValue)
{

Просмотреть файл

@ -60,7 +60,7 @@ public class OpenApiResourceKindProvider : IResourceKindProvider
public async Task<IDictionary<string, JsonSchema>> LoadDefinitions()
{
using var stream = typeof(OpenApiResourceKindProvider).Assembly.GetManifestResourceStream(typeof(OpenApiResourceKindProvider), "swagger.json");
if (stream == null)
if (stream is null)
{
_logger.LogError(
new EventId(1, "MissingEmbeddedStream"),

Просмотреть файл

@ -40,7 +40,7 @@ public abstract partial class ResourcePatcherTestsBase
LiveResource = testYaml.Live,
};
if (testYaml.ResourceKind != null)
if (testYaml.ResourceKind is not null)
{
parameters.ResourceKind = await Manager.GetResourceKindAsync(
testYaml.ResourceKind.ApiVersion,
@ -66,7 +66,7 @@ public abstract partial class ResourcePatcherTestsBase
LiveResource = testYaml.Live,
};
if (testYaml.ResourceKind != null)
if (testYaml.ResourceKind is not null)
{
parameters.ResourceKind = await Manager.GetResourceKindAsync(
testYaml.ResourceKind.ApiVersion,

Просмотреть файл

@ -42,7 +42,7 @@ public static class TestYaml
}
var manifestStream = reflectedType.Assembly.GetManifestResourceStream(reflectedType, $"{reflectedType.Name}.{methodName}.yaml");
if (manifestStream == null)
if (manifestStream is null)
{
throw new FileNotFoundException($"Could not find embedded stream {reflectedType.FullName}.{methodName}.yaml");
}

Просмотреть файл

@ -37,7 +37,7 @@ public sealed record ActiveHealthCheckConfig
public bool Equals(ActiveHealthCheckConfig? other)
{
if (other == null)
if (other is null)
{
return false;
}

Просмотреть файл

@ -56,7 +56,7 @@ public sealed record ClusterConfig
public bool Equals(ClusterConfig? other)
{
if (other == null)
if (other is null)
{
return false;
}
@ -67,7 +67,7 @@ public sealed record ClusterConfig
internal bool EqualsExcludingDestinations(ClusterConfig other)
{
if (other == null)
if (other is null)
{
return false;
}

Просмотреть файл

@ -52,7 +52,7 @@ internal sealed class ConfigurationConfigProvider : IProxyConfigProvider, IDispo
public IProxyConfig GetConfig()
{
// First time load
if (_snapshot == null)
if (_snapshot is null)
{
_subscription = ChangeToken.OnChange(_configuration.GetReloadToken, UpdateSnapshot);
UpdateSnapshot();
@ -88,7 +88,7 @@ internal sealed class ConfigurationConfigProvider : IProxyConfigProvider, IDispo
Log.ConfigurationDataConversionFailed(_logger, ex);
// Re-throw on the first time load to prevent app from starting.
if (_snapshot == null)
if (_snapshot is null)
{
throw;
}
@ -319,7 +319,7 @@ internal sealed class ConfigurationConfigProvider : IProxyConfigProvider, IDispo
{
foreach (var protocolConfig in sslProtocolsSection.GetChildren().Select(s => Enum.Parse<SslProtocols>(s.Value, ignoreCase: true)))
{
sslProtocols = sslProtocols == null ? protocolConfig : sslProtocols | protocolConfig;
sslProtocols = sslProtocols is null ? protocolConfig : sslProtocols | protocolConfig;
}
}

Просмотреть файл

@ -70,13 +70,13 @@ internal sealed class ConfigValidator : IConfigValidator
await ValidateAuthorizationPolicyAsync(errors, route.AuthorizationPolicy, route.RouteId);
await ValidateCorsPolicyAsync(errors, route.CorsPolicy, route.RouteId);
if (route.Match == null)
if (route.Match is null)
{
errors.Add(new ArgumentException($"Route '{route.RouteId}' did not set any match criteria, it requires Hosts or Path specified. Set the Path to '/{{**catchall}}' to match all requests."));
return errors;
}
if ((route.Match.Hosts == null || !route.Match.Hosts.Any(host => !string.IsNullOrEmpty(host))) && string.IsNullOrEmpty(route.Match.Path))
if ((route.Match.Hosts is null || !route.Match.Hosts.Any(host => !string.IsNullOrEmpty(host))) && string.IsNullOrEmpty(route.Match.Path))
{
errors.Add(new ArgumentException($"Route '{route.RouteId}' requires Hosts or Path specified. Set the Path to '/{{**catchall}}' to match all requests."));
}
@ -114,7 +114,7 @@ internal sealed class ConfigValidator : IConfigValidator
private static void ValidateHost(IList<Exception> errors, IReadOnlyList<string>? hosts, string routeId)
{
// Host is optional when Path is specified
if (hosts == null || hosts.Count == 0)
if (hosts is null || hosts.Count == 0)
{
return;
}
@ -153,7 +153,7 @@ internal sealed class ConfigValidator : IConfigValidator
private static void ValidateMethods(IList<Exception> errors, IReadOnlyList<string>? methods, string routeId)
{
// Methods are optional
if (methods == null)
if (methods is null)
{
return;
}
@ -177,14 +177,14 @@ internal sealed class ConfigValidator : IConfigValidator
private static void ValidateHeaders(List<Exception> errors, IReadOnlyList<RouteHeader>? headers, string routeId)
{
// Headers are optional
if (headers == null)
if (headers is null)
{
return;
}
foreach (var header in headers)
{
if (header == null)
if (header is null)
{
errors.Add(new ArgumentException($"A null route header has been set for route '{routeId}'."));
continue;
@ -196,7 +196,7 @@ internal sealed class ConfigValidator : IConfigValidator
}
if (header.Mode != HeaderMatchMode.Exists
&& (header.Values == null || header.Values.Count == 0))
&& (header.Values is null || header.Values.Count == 0))
{
errors.Add(new ArgumentException($"No header values were set on route header '{header.Name}' for route '{routeId}'."));
}
@ -211,14 +211,14 @@ internal sealed class ConfigValidator : IConfigValidator
private static void ValidateQueryParameters(List<Exception> errors, IReadOnlyList<RouteQueryParameter>? queryparams, string routeId)
{
// Query Parameters are optional
if (queryparams == null)
if (queryparams is null)
{
return;
}
foreach (var queryparam in queryparams)
{
if (queryparam == null)
if (queryparam is null)
{
errors.Add(new ArgumentException($"A null route query parameter has been set for route '{routeId}'."));
continue;
@ -230,7 +230,7 @@ internal sealed class ConfigValidator : IConfigValidator
}
if (queryparam.Mode != QueryParameterMatchMode.Exists
&& (queryparam.Values == null || queryparam.Values.Count == 0))
&& (queryparam.Values is null || queryparam.Values.Count == 0))
{
errors.Add(new ArgumentException($"No query parameter values were set on route query parameter '{queryparam.Name}' for route '{routeId}'."));
}
@ -252,7 +252,7 @@ internal sealed class ConfigValidator : IConfigValidator
if (string.Equals(AuthorizationConstants.Default, authorizationPolicyName, StringComparison.OrdinalIgnoreCase))
{
var policy = await _authorizationPolicyProvider.GetPolicyAsync(authorizationPolicyName);
if (policy != null)
if (policy is not null)
{
errors.Add(new ArgumentException($"The application has registered an authorization policy named '{authorizationPolicyName}' that conflicts with the reserved authorization policy name used on this route. The registered policy name needs to be changed for this route to function."));
}
@ -262,7 +262,7 @@ internal sealed class ConfigValidator : IConfigValidator
if (string.Equals(AuthorizationConstants.Anonymous, authorizationPolicyName, StringComparison.OrdinalIgnoreCase))
{
var policy = await _authorizationPolicyProvider.GetPolicyAsync(authorizationPolicyName);
if (policy != null)
if (policy is not null)
{
errors.Add(new ArgumentException($"The application has registered an authorization policy named '{authorizationPolicyName}' that conflicts with the reserved authorization policy name used on this route. The registered policy name needs to be changed for this route to function."));
}
@ -272,7 +272,7 @@ internal sealed class ConfigValidator : IConfigValidator
try
{
var policy = await _authorizationPolicyProvider.GetPolicyAsync(authorizationPolicyName);
if (policy == null)
if (policy is null)
{
errors.Add(new ArgumentException($"Authorization policy '{authorizationPolicyName}' not found for route '{routeId}'."));
}
@ -294,7 +294,7 @@ internal sealed class ConfigValidator : IConfigValidator
{
var dummyHttpContext = new DefaultHttpContext();
var policy = await _corsPolicyProvider.GetPolicyAsync(dummyHttpContext, corsPolicyName);
if (policy != null)
if (policy is not null)
{
errors.Add(new ArgumentException($"The application has registered a CORS policy named '{corsPolicyName}' that conflicts with the reserved CORS policy name used on this route. The registered policy name needs to be changed for this route to function."));
}
@ -305,7 +305,7 @@ internal sealed class ConfigValidator : IConfigValidator
{
var dummyHttpContext = new DefaultHttpContext();
var policy = await _corsPolicyProvider.GetPolicyAsync(dummyHttpContext, corsPolicyName);
if (policy != null)
if (policy is not null)
{
errors.Add(new ArgumentException($"The application has registered a CORS policy named '{corsPolicyName}' that conflicts with the reserved CORS policy name used on this route. The registered policy name needs to be changed for this route to function."));
}
@ -316,7 +316,7 @@ internal sealed class ConfigValidator : IConfigValidator
{
var dummyHttpContext = new DefaultHttpContext();
var policy = await _corsPolicyProvider.GetPolicyAsync(dummyHttpContext, corsPolicyName);
if (policy == null)
if (policy is null)
{
errors.Add(new ArgumentException($"CORS policy '{corsPolicyName}' not found for route '{routeId}'."));
}
@ -371,17 +371,17 @@ internal sealed class ConfigValidator : IConfigValidator
var cookieConfig = cluster.SessionAffinity.Cookie;
if (cookieConfig == null)
if (cookieConfig is null)
{
return;
}
if (cookieConfig.Expiration != null && cookieConfig.Expiration <= TimeSpan.Zero)
if (cookieConfig.Expiration is not null && cookieConfig.Expiration <= TimeSpan.Zero)
{
errors.Add(new ArgumentException($"Session affinity cookie expiration must be positive or null."));
}
if (cookieConfig.MaxAge != null && cookieConfig.MaxAge <= TimeSpan.Zero)
if (cookieConfig.MaxAge is not null && cookieConfig.MaxAge <= TimeSpan.Zero)
{
errors.Add(new ArgumentException($"Session affinity cookie max-age must be positive or null."));
}
@ -389,19 +389,19 @@ internal sealed class ConfigValidator : IConfigValidator
private static void ValidateProxyHttpClient(IList<Exception> errors, ClusterConfig cluster)
{
if (cluster.HttpClient == null)
if (cluster.HttpClient is null)
{
// Proxy http client options are not set.
return;
}
if (cluster.HttpClient.MaxConnectionsPerServer != null && cluster.HttpClient.MaxConnectionsPerServer <= 0)
if (cluster.HttpClient.MaxConnectionsPerServer is not null && cluster.HttpClient.MaxConnectionsPerServer <= 0)
{
errors.Add(new ArgumentException($"Max connections per server limit set on the cluster '{cluster.ClusterId}' must be positive."));
}
#if NET
var encoding = cluster.HttpClient.RequestHeaderEncoding;
if (encoding != null)
if (encoding is not null)
{
try
{
@ -417,13 +417,13 @@ internal sealed class ConfigValidator : IConfigValidator
private static void ValidateProxyHttpRequest(IList<Exception> errors, ClusterConfig cluster)
{
if (cluster.HttpRequest == null)
if (cluster.HttpRequest is null)
{
// Proxy http request options are not set.
return;
}
if (cluster.HttpRequest.Version != null &&
if (cluster.HttpRequest.Version is not null &&
cluster.HttpRequest.Version != HttpVersion.Version10 &&
cluster.HttpRequest.Version != HttpVersion.Version11 &&
cluster.HttpRequest.Version != HttpVersion.Version20)
@ -470,12 +470,12 @@ internal sealed class ConfigValidator : IConfigValidator
errors.Add(new ArgumentException($"No matching {nameof(IActiveHealthCheckPolicy)} found for the active health check policy name '{policy}' set on the cluster '{cluster.ClusterId}'."));
}
if (activeOptions.Interval != null && activeOptions.Interval <= TimeSpan.Zero)
if (activeOptions.Interval is not null && activeOptions.Interval <= TimeSpan.Zero)
{
errors.Add(new ArgumentException($"Destination probing interval set on the cluster '{cluster.ClusterId}' must be positive."));
}
if (activeOptions.Timeout != null && activeOptions.Timeout <= TimeSpan.Zero)
if (activeOptions.Timeout is not null && activeOptions.Timeout <= TimeSpan.Zero)
{
errors.Add(new ArgumentException($"Destination probing timeout set on the cluster '{cluster.ClusterId}' must be positive."));
}
@ -501,7 +501,7 @@ internal sealed class ConfigValidator : IConfigValidator
errors.Add(new ArgumentException($"No matching {nameof(IPassiveHealthCheckPolicy)} found for the passive health check policy name '{policy}' set on the cluster '{cluster.ClusterId}'."));
}
if (passiveOptions.ReactivationPeriod != null && passiveOptions.ReactivationPeriod <= TimeSpan.Zero)
if (passiveOptions.ReactivationPeriod is not null && passiveOptions.ReactivationPeriod <= TimeSpan.Zero)
{
errors.Add(new ArgumentException($"Unhealthy destination reactivation period set on the cluster '{cluster.ClusterId}' must be positive."));
}

Просмотреть файл

@ -30,7 +30,7 @@ public sealed record DestinationConfig
public bool Equals(DestinationConfig? other)
{
if (other == null)
if (other is null)
{
return false;
}

Просмотреть файл

@ -27,7 +27,7 @@ public sealed record HealthCheckConfig
public bool Equals(HealthCheckConfig? other)
{
if (other == null)
if (other is null)
{
return false;
}

Просмотреть файл

@ -53,7 +53,7 @@ public sealed record HttpClientConfig
public bool Equals(HttpClientConfig? other)
{
if (other == null)
if (other is null)
{
return false;
}

Просмотреть файл

@ -27,7 +27,7 @@ public sealed record PassiveHealthCheckConfig
public bool Equals(PassiveHealthCheckConfig? other)
{
if (other == null)
if (other is null)
{
return false;
}

Просмотреть файл

@ -64,7 +64,7 @@ public sealed record RouteConfig
public bool Equals(RouteConfig? other)
{
if (other == null)
if (other is null)
{
return false;
}

Просмотреть файл

@ -40,7 +40,7 @@ public sealed record RouteHeader
public bool Equals(RouteHeader? other)
{
if (other == null)
if (other is null)
{
return false;
}

Просмотреть файл

@ -40,7 +40,7 @@ public sealed record RouteMatch
public bool Equals(RouteMatch? other)
{
if (other == null)
if (other is null)
{
return false;
}

Просмотреть файл

@ -39,7 +39,7 @@ public sealed record RouteQueryParameter
public bool Equals(RouteQueryParameter? other)
{
if (other == null)
if (other is null)
{
return false;
}

Просмотреть файл

@ -45,7 +45,7 @@ public sealed record SessionAffinityConfig
public bool Equals(SessionAffinityConfig? other)
{
if (other == null)
if (other is null)
{
return false;
}

Просмотреть файл

@ -60,7 +60,7 @@ public sealed record SessionAffinityCookieConfig
public bool Equals(SessionAffinityCookieConfig? other)
{
if (other == null)
if (other is null)
{
return false;
}

Просмотреть файл

@ -29,7 +29,7 @@ public sealed record WebProxyConfig : IEquatable<WebProxyConfig>
public bool Equals(WebProxyConfig? other)
{
if (other == null)
if (other is null)
{
return false;
}

Просмотреть файл

@ -19,7 +19,7 @@ internal static class DelegationExtensions
public static bool ShouldUseHttpSysDelegation(this DestinationState destination)
{
return destination.GetHttpSysDelegationQueue() != null;
return destination.GetHttpSysDelegationQueue() is not null;
}
}
#endif

Просмотреть файл

@ -52,7 +52,7 @@ internal sealed class HttpSysDelegator : IClusterChangeListener
"Current request can't be delegated. Either the request body has started to be read or the response has started to be sent.");
}
if (_delegationFeature == null || !_queuesPerDestination.TryGetValue(destination, out var queue))
if (_delegationFeature is null || !_queuesPerDestination.TryGetValue(destination, out var queue))
{
Log.QueueNotFound(_logger, destination);
context.Response.StatusCode = StatusCodes.Status503ServiceUnavailable;
@ -102,7 +102,7 @@ internal sealed class HttpSysDelegator : IClusterChangeListener
private void AddOrUpdateRules(ClusterState cluster)
{
if (_delegationFeature == null)
if (_delegationFeature is null)
{
return;
}
@ -121,7 +121,7 @@ internal sealed class HttpSysDelegator : IClusterChangeListener
{
var queueName = destination.GetHttpSysDelegationQueue();
var urlPrefix = destination.Model?.Config?.Address;
if (queueName != null && urlPrefix != null)
if (queueName is not null && urlPrefix is not null)
{
var queueKey = new QueueKey(queueName, urlPrefix);
if (!_queuesPerDestination.TryGetValue(destination, out var queue) || !queue.Equals(queueKey))
@ -140,7 +140,7 @@ internal sealed class HttpSysDelegator : IClusterChangeListener
queueWeakRef.TryGetTarget(out queue);
}
if (queue != null)
if (queue is not null)
{
// We call this outside of the above if bock so that if previous
// initialization failed, we will retry it for every new destination added.

Просмотреть файл

@ -69,7 +69,7 @@ public class ForwarderHttpClientFactory : IForwarderHttpClientFactory
/// </summary>
protected virtual bool CanReuseOldClient(ForwarderHttpClientContext context)
{
return context.OldClient != null && context.NewConfig == context.OldConfig;
return context.OldClient is not null && context.NewConfig == context.OldConfig;
}
/// <summary>
@ -86,7 +86,7 @@ public class ForwarderHttpClientFactory : IForwarderHttpClientFactory
{
handler.SslOptions.EnabledSslProtocols = newConfig.SslProtocols.Value;
}
if (newConfig.MaxConnectionsPerServer != null)
if (newConfig.MaxConnectionsPerServer is not null)
{
handler.MaxConnectionsPerServer = newConfig.MaxConnectionsPerServer.Value;
}
@ -97,14 +97,14 @@ public class ForwarderHttpClientFactory : IForwarderHttpClientFactory
#if NET
handler.EnableMultipleHttp2Connections = newConfig.EnableMultipleHttp2Connections.GetValueOrDefault(true);
if (newConfig.RequestHeaderEncoding != null)
if (newConfig.RequestHeaderEncoding is not null)
{
var encoding = Encoding.GetEncoding(newConfig.RequestHeaderEncoding);
handler.RequestHeaderEncodingSelector = (_, _) => encoding;
}
#endif
var webProxy = TryCreateWebProxy(newConfig.WebProxy);
if (webProxy != null)
if (webProxy is not null)
{
handler.Proxy = webProxy;
handler.UseProxy = true;
@ -113,7 +113,7 @@ public class ForwarderHttpClientFactory : IForwarderHttpClientFactory
private static IWebProxy? TryCreateWebProxy(WebProxyConfig? webProxyConfig)
{
if (webProxyConfig == null || webProxyConfig.Address == null)
if (webProxyConfig is null || webProxyConfig.Address is null)
{
return null;
}

Просмотреть файл

@ -59,7 +59,7 @@ internal sealed class ForwarderMiddleware
reverseProxyFeature.ProxiedDestination = destination;
var destinationModel = destination.Model;
if (destinationModel == null)
if (destinationModel is null)
{
throw new InvalidOperationException($"Chosen destination has no model set: '{destination.DestinationId}'");
}

Просмотреть файл

@ -47,7 +47,7 @@ public sealed record ForwarderRequestConfig
public bool Equals(ForwarderRequestConfig? other)
{
if (other == null)
if (other is null)
{
return false;
}

Просмотреть файл

@ -257,7 +257,7 @@ internal sealed class HttpForwarder : IHttpForwarder
HttpTransformer transformer, ForwarderRequestConfig? requestConfig, bool isStreamingRequest, ActivityCancellationTokenSource activityToken)
{
// "http://a".Length = 8
if (destinationPrefix == null || destinationPrefix.Length < 8)
if (destinationPrefix is null || destinationPrefix.Length < 8)
{
throw new ArgumentException("Invalid destination prefix.", nameof(destinationPrefix));
}
@ -325,7 +325,7 @@ internal sealed class HttpForwarder : IHttpForwarder
}
}
if (connectionUpgradeValue != null && context.Request.Headers.TryGetValue(HeaderNames.Upgrade, out var upgradeValue))
if (connectionUpgradeValue is not null && context.Request.Headers.TryGetValue(HeaderNames.Upgrade, out var upgradeValue))
{
request.Headers.TryAddWithoutValidation(HeaderNames.Connection, connectionUpgradeValue);
request.Headers.TryAddWithoutValidation(HeaderNames.Upgrade, (IEnumerable<string>)upgradeValue);
@ -344,7 +344,7 @@ internal sealed class HttpForwarder : IHttpForwarder
#if NET
var canHaveBodyFeature = request.HttpContext.Features.Get<IHttpRequestBodyDetectionFeature>();
if (canHaveBodyFeature != null)
if (canHaveBodyFeature is not null)
{
// 5.0 servers provide a definitive answer for us.
hasBody = canHaveBodyFeature.CanHaveBody;
@ -548,14 +548,14 @@ internal sealed class HttpForwarder : IHttpForwarder
// SocketHttpHandler and similar transports always provide an HttpContent object, even if it's empty.
// Note as of 5.0 HttpResponse.Content never returns null.
// https://github.com/dotnet/runtime/blame/8fc68f626a11d646109a758cb0fc70a0aa7826f1/src/libraries/System.Net.Http/src/System/Net/Http/HttpResponseMessage.cs#L46
if (destinationResponse.Content == null)
if (destinationResponse.Content is null)
{
throw new InvalidOperationException("A response content is required for upgrades.");
}
// :: Step 7-A-1: Upgrade the client channel. This will also send response headers.
var upgradeFeature = context.Features.Get<IHttpUpgradeFeature>();
if (upgradeFeature == null)
if (upgradeFeature is null)
{
var ex = new InvalidOperationException("Invalid 101 response when upgrades aren't supported.");
destinationResponse.Dispose();
@ -637,7 +637,7 @@ internal sealed class HttpForwarder : IHttpForwarder
// In 3.1 this is only likely to return null in tests.
// As of 5.0 HttpResponse.Content never returns null.
// https://github.com/dotnet/runtime/blame/8fc68f626a11d646109a758cb0fc70a0aa7826f1/src/libraries/System.Net.Http/src/System/Net/Http/HttpResponseMessage.cs#L46
if (destinationResponseContent != null)
if (destinationResponseContent is not null)
{
using var destinationResponseStream = await destinationResponseContent.ReadAsStreamAsync();
// The response content-length is enforced by the server.
@ -711,13 +711,13 @@ internal sealed class HttpForwarder : IHttpForwarder
private void DisableMinRequestBodyDataRateAndMaxRequestBodySize(HttpContext httpContext)
{
var minRequestBodyDataRateFeature = httpContext.Features.Get<IHttpMinRequestBodyDataRateFeature>();
if (minRequestBodyDataRateFeature != null)
if (minRequestBodyDataRateFeature is not null)
{
minRequestBodyDataRateFeature.MinDataRate = null;
}
var maxRequestBodySizeFeature = httpContext.Features.Get<IHttpMaxRequestBodySizeFeature>();
if (maxRequestBodySizeFeature != null)
if (maxRequestBodySizeFeature is not null)
{
if (!maxRequestBodySizeFeature.IsReadOnly)
{
@ -742,7 +742,7 @@ internal sealed class HttpForwarder : IHttpForwarder
private static void ResetOrAbort(HttpContext context, bool isCancelled)
{
var resetFeature = context.Features.Get<IHttpResetFeature>();
if (resetFeature != null)
if (resetFeature is not null)
{
// https://tools.ietf.org/html/rfc7540#section-7
const int Cancelled = 2;

Просмотреть файл

@ -79,7 +79,7 @@ public class HttpTransformer
if (ProtocolHelper.IsHttp2OrGreater(httpContext.Request.Protocol))
{
var te = httpContext.Request.Headers.GetCommaSeparatedValues(HeaderNames.TE);
if (te != null)
if (te is not null)
{
for (var i = 0; i < te.Length; i++)
{
@ -109,14 +109,14 @@ public class HttpTransformer
/// etc.</returns>
public virtual ValueTask<bool> TransformResponseAsync(HttpContext httpContext, HttpResponseMessage? proxyResponse)
{
if (proxyResponse == null)
if (proxyResponse is null)
{
return new ValueTask<bool>(false);
}
var responseHeaders = httpContext.Response.Headers;
CopyResponseHeaders(proxyResponse.Headers, responseHeaders);
if (proxyResponse.Content != null)
if (proxyResponse.Content is not null)
{
CopyResponseHeaders(proxyResponse.Content.Headers, responseHeaders);
}
@ -129,7 +129,7 @@ public class HttpTransformer
// (Section 9.4) and ought to be handled as an error. A sender MUST
// remove the received Content-Length field prior to forwarding such
// a message downstream.
if (proxyResponse.Content != null
if (proxyResponse.Content is not null
&& RequestUtilities.ContainsHeader(proxyResponse.Headers, HeaderNames.TransferEncoding)
&& RequestUtilities.ContainsHeader(proxyResponse.Content.Headers, HeaderNames.ContentLength))
{
@ -151,7 +151,7 @@ public class HttpTransformer
// because they lookup `IHttpResponseTrailersFeature` for every call. Here we do it just once instead.
var responseTrailersFeature = httpContext.Features.Get<IHttpResponseTrailersFeature>();
var outgoingTrailers = responseTrailersFeature?.Trailers;
if (outgoingTrailers != null && !outgoingTrailers.IsReadOnly)
if (outgoingTrailers is not null && !outgoingTrailers.IsReadOnly)
{
// Note that trailers, if any, should already have been declared in Proxy's response
// by virtue of us having proxied all response headers in step 6.

Просмотреть файл

@ -49,7 +49,7 @@ internal static class ProtocolHelper
#if NET
return HttpProtocol.GetHttpProtocol(version);
#else
if (version == null)
if (version is null)
{
throw new ArgumentNullException(nameof(version));
}
@ -86,7 +86,7 @@ internal static class ProtocolHelper
/// </summary>
public static bool IsGrpcContentType(string? contentType)
{
if (contentType == null)
if (contentType is null)
{
return false;
}

Просмотреть файл

@ -71,7 +71,7 @@ internal partial class ActiveHealthCheckMonitor : IActiveHealthCheckMonitor, ICl
public void OnClusterAdded(ClusterState cluster)
{
var config = cluster.Model.Config.HealthCheck?.Active;
if (config != null && config.Enabled.GetValueOrDefault())
if (config is not null && config.Enabled.GetValueOrDefault())
{
Scheduler.ScheduleEntity(cluster, config.Interval ?? _monitorOptions.DefaultInterval);
}
@ -80,7 +80,7 @@ internal partial class ActiveHealthCheckMonitor : IActiveHealthCheckMonitor, ICl
public void OnClusterChanged(ClusterState cluster)
{
var config = cluster.Model.Config.HealthCheck?.Active;
if (config != null && config.Enabled.GetValueOrDefault())
if (config is not null && config.Enabled.GetValueOrDefault())
{
Scheduler.ChangePeriod(cluster, config.Interval ?? _monitorOptions.DefaultInterval);
}
@ -103,7 +103,7 @@ internal partial class ActiveHealthCheckMonitor : IActiveHealthCheckMonitor, ICl
private async Task ProbeCluster(ClusterState cluster)
{
var config = cluster.Model.Config.HealthCheck?.Active;
if (config == null || !config.Enabled.GetValueOrDefault())
if (config is null || !config.Enabled.GetValueOrDefault())
{
return;
}

Просмотреть файл

@ -23,7 +23,7 @@ internal sealed class ClusterDestinationsUpdater : IClusterDestinationsUpdater
public void UpdateAvailableDestinations(ClusterState cluster)
{
var allDestinations = cluster.DestinationsState?.AllDestinations;
if (allDestinations == null)
if (allDestinations is null)
{
throw new InvalidOperationException($"{nameof(UpdateAllDestinations)} must be called first.");
}

Просмотреть файл

@ -58,7 +58,7 @@ internal sealed class ConsecutiveFailuresHealthPolicy : IActiveHealthCheckPolicy
private static DestinationHealth EvaluateHealthState(double threshold, HttpResponseMessage? response, AtomicCounter count)
{
DestinationHealth newHealth;
if (response != null && response.IsSuccessStatusCode)
if (response is not null && response.IsSuccessStatusCode)
{
// Success
count.Reset();

Просмотреть файл

@ -28,7 +28,7 @@ public class PassiveHealthCheckMiddleware
var options = proxyFeature.Cluster.Config.HealthCheck?.Passive;
// Do nothing if no target destination has been chosen for the request.
if (options == null || !options.Enabled.GetValueOrDefault() || proxyFeature.ProxiedDestination == null)
if (options is null || !options.Enabled.GetValueOrDefault() || proxyFeature.ProxiedDestination is null)
{
return;
}

Просмотреть файл

@ -47,7 +47,7 @@ internal sealed class TransportFailureRateHealthPolicy : IPassiveHealthCheckPoli
public void RequestProxied(HttpContext context, ClusterState cluster, DestinationState destination)
{
var error = context.Features.Get<IForwarderErrorFeature>();
var newHealth = EvaluateProxiedRequest(cluster, destination, error != null);
var newHealth = EvaluateProxiedRequest(cluster, destination, error is not null);
var clusterReactivationPeriod = cluster.Model.Config.HealthCheck?.Passive?.ReactivationPeriod ?? _defaultReactivationPeriod;
// Avoid reactivating until the history has expired so that it does not affect future health assessments.
var reactivationPeriod = clusterReactivationPeriod >= _policyOptions.DetectionWindowSize ? clusterReactivationPeriod : _policyOptions.DetectionWindowSize;

Просмотреть файл

@ -53,7 +53,7 @@ internal sealed class LoadBalancingMiddleware
destination = currentPolicy.PickDestination(context, proxyFeature.Route.Cluster!, destinations);
}
if (destination == null)
if (destination is null)
{
// We intentionally do not short circuit here, we allow for later middleware to decide how to handle this case.
Log.NoAvailableDestinations(_logger, proxyFeature.Cluster.Config.ClusterId);

Просмотреть файл

@ -104,11 +104,11 @@ internal sealed class ProxyConfigManager : EndpointDataSource, IProxyStateLookup
{
// The Endpoints needs to be lazy the first time to give a chance to ReverseProxyConventionBuilder to add its conventions.
// Endpoints are accessed by routing on the first request.
if (_endpoints == null)
if (_endpoints is null)
{
lock (_syncRoot)
{
if (_endpoints == null)
if (_endpoints is null)
{
CreateEndpoints();
}
@ -127,7 +127,7 @@ internal sealed class ProxyConfigManager : EndpointDataSource, IProxyStateLookup
{
// Only rebuild the endpoint for modified routes or clusters.
var endpoint = existingRoute.Value.CachedEndpoint;
if (endpoint == null)
if (endpoint is null)
{
endpoint = _proxyEndpointFactory.CreateEndpoint(existingRoute.Value.Model, _conventions);
existingRoute.Value.CachedEndpoint = endpoint;
@ -216,7 +216,7 @@ internal sealed class ProxyConfigManager : EndpointDataSource, IProxyStateLookup
{
// Skip if changes are signaled before the endpoints are initialized for the first time.
// The endpoint conventions might not be ready yet.
if (hasChanged && _endpoints != null)
if (hasChanged && _endpoints is not null)
{
CreateEndpoints();
}
@ -233,11 +233,11 @@ internal sealed class ProxyConfigManager : EndpointDataSource, IProxyStateLookup
private static void ValidateConfigProperties(IProxyConfig config)
{
if (config == null)
if (config is null)
{
throw new InvalidOperationException($"{nameof(IProxyConfigProvider.GetConfig)} returned a null value.");
}
if (config.ChangeToken == null)
if (config.ChangeToken is null)
{
throw new InvalidOperationException($"{nameof(IProxyConfig.ChangeToken)} has a null value.");
}
@ -316,7 +316,7 @@ internal sealed class ProxyConfigManager : EndpointDataSource, IProxyStateLookup
private async Task<(IList<RouteConfig>, IList<Exception>)> VerifyRoutesAsync(IReadOnlyList<RouteConfig> routes, IReadOnlyDictionary<string, ClusterConfig> clusters, CancellationToken cancellation)
{
if (routes == null)
if (routes is null)
{
return (Array.Empty<RouteConfig>(), Array.Empty<Exception>());
}
@ -340,7 +340,7 @@ internal sealed class ProxyConfigManager : EndpointDataSource, IProxyStateLookup
if (_filters.Length != 0)
{
ClusterConfig? cluster = null;
if (route.ClusterId != null)
if (route.ClusterId is not null)
{
clusters.TryGetValue(route.ClusterId, out cluster);
}
@ -377,7 +377,7 @@ internal sealed class ProxyConfigManager : EndpointDataSource, IProxyStateLookup
private async Task<(IReadOnlyDictionary<string, ClusterConfig>, IList<Exception>)> VerifyClustersAsync(IReadOnlyList<ClusterConfig> clusters, CancellationToken cancellation)
{
if (clusters == null)
if (clusters is null)
{
return (_emptyClusterDictionary, Array.Empty<Exception>());
}
@ -530,7 +530,7 @@ internal sealed class ProxyConfigManager : EndpointDataSource, IProxyStateLookup
var desiredDestinations = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
var changed = false;
if (incomingDestinations != null)
if (incomingDestinations is not null)
{
foreach (var incomingDestination in incomingDestinations)
{
@ -649,7 +649,7 @@ internal sealed class ProxyConfigManager : EndpointDataSource, IProxyStateLookup
[MemberNotNull(nameof(_endpoints))]
private void UpdateEndpoints(List<Endpoint> endpoints)
{
if (endpoints == null)
if (endpoints is null)
{
throw new ArgumentNullException(nameof(endpoints));
}

Просмотреть файл

@ -33,7 +33,7 @@ internal sealed class ProxyPipelineInitializerMiddleware
var cluster = route.Cluster;
// TODO: Validate on load https://github.com/microsoft/reverse-proxy/issues/797
if (cluster == null)
if (cluster is null)
{
Log.NoClusterFound(_logger, route.Config.RouteId);
context.Response.StatusCode = StatusCodes.Status503ServiceUnavailable;

Просмотреть файл

@ -22,7 +22,7 @@ internal sealed class HeaderMatcher
throw new ArgumentException("A header name is required.", nameof(name));
}
if (mode != HeaderMatchMode.Exists
&& (values == null || values.Count == 0))
&& (values is null || values.Count == 0))
{
throw new ArgumentException("Header values must have at least one value.", nameof(values));
}

Просмотреть файл

@ -60,7 +60,7 @@ internal sealed class HeaderMatcherPolicy : MatcherPolicy, IEndpointComparerPoli
var matchers = candidates[i].Endpoint.Metadata.GetMetadata<IHeaderMetadata>()?.Matchers;
if (matchers == null)
if (matchers is null)
{
continue;
}
@ -132,11 +132,11 @@ internal sealed class HeaderMatcherPolicy : MatcherPolicy, IEndpointComparerPoli
return matchMode switch
{
HeaderMatchMode.ExactHeader => MemoryExtensions.Equals(requestHeaderValue, metadataHeaderValue, comparison),
HeaderMatchMode.HeaderPrefix => requestHeaderValue != null && metadataHeaderValue != null
HeaderMatchMode.HeaderPrefix => requestHeaderValue is not null && metadataHeaderValue is not null
&& MemoryExtensions.StartsWith(requestHeaderValue, metadataHeaderValue, comparison),
HeaderMatchMode.Contains => requestHeaderValue != null && metadataHeaderValue != null
HeaderMatchMode.Contains => requestHeaderValue is not null && metadataHeaderValue is not null
&& MemoryExtensions.Contains(requestHeaderValue, metadataHeaderValue, comparison),
HeaderMatchMode.NotContains => requestHeaderValue != null && metadataHeaderValue != null
HeaderMatchMode.NotContains => requestHeaderValue is not null && metadataHeaderValue is not null
&& !MemoryExtensions.Contains(requestHeaderValue, metadataHeaderValue, comparison),
_ => throw new NotImplementedException(matchMode.ToString()),
};

Просмотреть файл

@ -44,12 +44,12 @@ internal sealed class ProxyEndpointFactory
endpointBuilder.Metadata.Add(route);
if (match.Hosts != null && match.Hosts.Count != 0)
if (match.Hosts is not null && match.Hosts.Count != 0)
{
endpointBuilder.Metadata.Add(new HostAttribute(match.Hosts.ToArray()));
}
if (match.Headers != null && match.Headers.Count > 0)
if (match.Headers is not null && match.Headers.Count > 0)
{
var matchers = new List<HeaderMatcher>(match.Headers.Count);
foreach (var header in match.Headers)
@ -60,7 +60,7 @@ internal sealed class ProxyEndpointFactory
endpointBuilder.Metadata.Add(new HeaderMetadata(matchers));
}
if (match.QueryParameters != null && match.QueryParameters.Count > 0)
if (match.QueryParameters is not null && match.QueryParameters.Count > 0)
{
var matchers = new List<QueryParameterMatcher>(match.QueryParameters.Count);
foreach (var queryparam in match.QueryParameters)
@ -92,7 +92,7 @@ internal sealed class ProxyEndpointFactory
acceptCorsPreflight = false;
}
if (match.Methods != null && match.Methods.Count > 0)
if (match.Methods is not null && match.Methods.Count > 0)
{
endpointBuilder.Metadata.Add(new HttpMethodMetadata(match.Methods, acceptCorsPreflight));
}

Просмотреть файл

@ -22,7 +22,7 @@ internal sealed class QueryParameterMatcher
throw new ArgumentException("A query parameter name is required.", nameof(name));
}
if (mode != QueryParameterMatchMode.Exists
&& (values == null || values.Count == 0))
&& (values is null || values.Count == 0))
{
throw new ArgumentException("Query parameter values must have at least one value.", nameof(values));
}

Просмотреть файл

@ -60,7 +60,7 @@ internal sealed class QueryParameterMatcherPolicy : MatcherPolicy, IEndpointComp
var matchers = candidates[i].Endpoint.Metadata.GetMetadata<IQueryParameterMetadata>()?.Matchers;
if (matchers == null)
if (matchers is null)
{
continue;
}
@ -132,11 +132,11 @@ internal sealed class QueryParameterMatcherPolicy : MatcherPolicy, IEndpointComp
return matchMode switch
{
QueryParameterMatchMode.Exact => MemoryExtensions.Equals(requestQueryParameterValue, metadataQueryParameterValue, comparison),
QueryParameterMatchMode.Prefix => requestQueryParameterValue != null && metadataQueryParameterValue != null
QueryParameterMatchMode.Prefix => requestQueryParameterValue is not null && metadataQueryParameterValue is not null
&& MemoryExtensions.StartsWith(requestQueryParameterValue, metadataQueryParameterValue, comparison),
QueryParameterMatchMode.Contains => requestQueryParameterValue != null && metadataQueryParameterValue != null
QueryParameterMatchMode.Contains => requestQueryParameterValue is not null && metadataQueryParameterValue is not null
&& MemoryExtensions.Contains(requestQueryParameterValue, metadataQueryParameterValue, comparison),
QueryParameterMatchMode.NotContains => requestQueryParameterValue != null && metadataQueryParameterValue != null
QueryParameterMatchMode.NotContains => requestQueryParameterValue is not null && metadataQueryParameterValue is not null
&& !MemoryExtensions.Contains(requestQueryParameterValue, metadataQueryParameterValue, comparison),
_ => throw new NotImplementedException(matchMode.ToString()),
};

Просмотреть файл

@ -61,7 +61,7 @@ public static class ReverseProxyIEndpointRouteBuilderExtensions
private static ProxyConfigManager GetOrCreateDataSource(IEndpointRouteBuilder endpoints)
{
var dataSource = endpoints.DataSources.OfType<ProxyConfigManager>().FirstOrDefault();
if (dataSource == null)
if (dataSource is null)
{
dataSource = endpoints.ServiceProvider.GetRequiredService<ProxyConfigManager>();
endpoints.DataSources.Add(dataSource);

Просмотреть файл

@ -28,7 +28,7 @@ internal sealed class AffinitizeTransform : ResponseTransform
var options = proxyFeature.Cluster.Config.SessionAffinity;
// The transform should only be added to routes that have affinity enabled.
// However, the cluster can be re-assigned dynamically.
if (options == null || !options.Enabled.GetValueOrDefault())
if (options is null || !options.Enabled.GetValueOrDefault())
{
return default;
}

Просмотреть файл

@ -47,7 +47,7 @@ internal sealed class AffinitizeTransformProvider : ITransformProvider
{
var options = context.Cluster?.SessionAffinity;
if (options != null && options.Enabled.GetValueOrDefault())
if (options is not null && options.Enabled.GetValueOrDefault())
{
var policy = _sessionAffinityPolicies.GetRequiredServiceById(options.Policy, SessionAffinityConstants.Policies.Cookie);
context.ResponseTransforms.Add(new AffinitizeTransform(policy));

Просмотреть файл

@ -50,7 +50,7 @@ internal abstract class BaseSessionAffinityPolicy<T> : ISessionAffinityPolicy
var requestAffinityKey = GetRequestAffinityKey(context, cluster, config);
if (requestAffinityKey.Key == null)
if (requestAffinityKey.Key is null)
{
return new AffinityResult(null, requestAffinityKey.ExtractedSuccessfully ? AffinityStatus.AffinityKeyNotSet : AffinityStatus.AffinityKeyExtractionFailed);
}
@ -70,7 +70,7 @@ internal abstract class BaseSessionAffinityPolicy<T> : ISessionAffinityPolicy
}
}
if (matchingDestinations == null)
if (matchingDestinations is null)
{
Log.DestinationMatchingToAffinityKeyNotFound(Logger, cluster.ClusterId);
}
@ -81,7 +81,7 @@ internal abstract class BaseSessionAffinityPolicy<T> : ISessionAffinityPolicy
}
// Empty destination list passed to this method is handled the same way as if no matching destinations are found.
if (matchingDestinations == null)
if (matchingDestinations is null)
{
return new AffinityResult(null, AffinityStatus.DestinationNotFound);
}
@ -121,7 +121,7 @@ internal abstract class BaseSessionAffinityPolicy<T> : ISessionAffinityPolicy
var keyBytes = Convert.FromBase64String(Pad(encryptedRequestKey));
var decryptedKeyBytes = _dataProtector.Unprotect(keyBytes);
if (decryptedKeyBytes == null)
if (decryptedKeyBytes is null)
{
Log.RequestAffinityKeyDecryptionFailed(Logger, null);
return (Key: null, ExtractedSuccessfully: false);

Просмотреть файл

@ -48,7 +48,7 @@ internal sealed class CookieSessionAffinityPolicy : BaseSessionAffinityPolicy<st
Domain = config.Cookie?.Domain,
IsEssential = config.Cookie?.IsEssential ?? false,
Secure = config.Cookie?.SecurePolicy == CookieSecurePolicy.Always || (config.Cookie?.SecurePolicy == CookieSecurePolicy.SameAsRequest && context.Request.IsHttps),
Expires = config.Cookie?.Expiration != null ? _clock.GetUtcNow().Add(config.Cookie.Expiration.Value) : default(DateTimeOffset?),
Expires = config.Cookie?.Expiration is not null ? _clock.GetUtcNow().Add(config.Cookie.Expiration.Value) : default(DateTimeOffset?),
};
context.Response.Cookies.Append(config.AffinityKeyName, Protect(unencryptedKey), affinityCookieOptions);
}

Просмотреть файл

@ -40,7 +40,7 @@ internal sealed class SessionAffinityMiddleware
var config = proxyFeature.Cluster.Config.SessionAffinity;
if (config == null || !config.Enabled.GetValueOrDefault())
if (config is null || !config.Enabled.GetValueOrDefault())
{
return _next(context);
}

Просмотреть файл

@ -137,7 +137,7 @@ internal sealed class StructuredTransformer : HttpTransformer
// Only run the transforms if trailers are actually supported by the client response.
var responseTrailersFeature = httpContext.Features.Get<IHttpResponseTrailersFeature>();
var outgoingTrailers = responseTrailersFeature?.Trailers;
if (outgoingTrailers != null && !outgoingTrailers.IsReadOnly)
if (outgoingTrailers is not null && !outgoingTrailers.IsReadOnly)
{
var transformContext = new ResponseTrailersTransformContext()
{

Просмотреть файл

@ -30,22 +30,22 @@ public static class ForwardedTransformExtensions
{
transform[ForwardedTransformFactory.XForwardedKey] = xDefault.ToString();
if (xFor != null)
if (xFor is not null)
{
transform[ForwardedTransformFactory.ForKey] = xFor.Value.ToString();
}
if (xPrefix != null)
if (xPrefix is not null)
{
transform[ForwardedTransformFactory.PrefixKey] = xPrefix.Value.ToString();
}
if (xHost != null)
if (xHost is not null)
{
transform[ForwardedTransformFactory.HostKey] = xHost.Value.ToString();
}
if (xProto != null)
if (xProto is not null)
{
transform[ForwardedTransformFactory.ProtoKey] = xProto.Value.ToString();
}

Просмотреть файл

@ -19,7 +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 == null)
if (value.Value is null)
{
throw new ArgumentNullException(nameof(value));
}

Просмотреть файл

@ -20,7 +20,7 @@ public static class PathTransformExtensions
/// </summary>
public static RouteConfig WithTransformPathSet(this RouteConfig route, PathString path)
{
if (path.Value == null)
if (path.Value is null)
{
throw new ArgumentNullException(nameof(path));
}
@ -45,7 +45,7 @@ public static class PathTransformExtensions
/// </summary>
public static RouteConfig WithTransformPathPrefix(this RouteConfig route, PathString prefix)
{
if (prefix.Value == null)
if (prefix.Value is null)
{
throw new ArgumentNullException(nameof(prefix));
}
@ -70,7 +70,7 @@ public static class PathTransformExtensions
/// </summary>
public static RouteConfig WithTransformPathRemovePrefix(this RouteConfig route, PathString prefix)
{
if (prefix.Value == null)
if (prefix.Value is null)
{
throw new ArgumentNullException(nameof(prefix));
}
@ -95,7 +95,7 @@ public static class PathTransformExtensions
/// </summary>
public static RouteConfig WithTransformPathRouteValues(this RouteConfig route, PathString pattern)
{
if (pattern.Value == null)
if (pattern.Value is null)
{
throw new ArgumentNullException(nameof(pattern));
}
@ -111,7 +111,7 @@ public static class PathTransformExtensions
/// </summary>
public static TransformBuilderContext AddPathRouteValues(this TransformBuilderContext context, PathString pattern)
{
if (pattern.Value == null)
if (pattern.Value is null)
{
throw new ArgumentNullException(nameof(pattern));
}

Просмотреть файл

@ -56,7 +56,7 @@ internal sealed class PathTransformFactory : ITransformFactory
private void CheckPathNotNull(TransformRouteValidationContext context, string fieldName, string? path)
{
if (path == null)
if (path is null)
{
context.Errors.Add(new ArgumentNullException(fieldName));
}
@ -99,7 +99,7 @@ internal sealed class PathTransformFactory : ITransformFactory
private static PathString MakePathString(string path)
{
if (path == null)
if (path is null)
{
throw new ArgumentNullException(nameof(path));
}

Просмотреть файл

@ -26,7 +26,7 @@ public class QueryParameterRemoveTransform : RequestTransform
/// <inheritdoc/>
public override ValueTask ApplyAsync(RequestTransformContext context)
{
if (context == null)
if (context is null)
{
throw new ArgumentNullException(nameof(context));
}

Просмотреть файл

@ -27,13 +27,13 @@ public abstract class QueryParameterTransform : RequestTransform
/// <inheritdoc/>
public override ValueTask ApplyAsync(RequestTransformContext context)
{
if (context == null)
if (context is null)
{
throw new ArgumentNullException(nameof(context));
}
var value = GetValue(context);
if (value != null)
if (value is not null)
{
switch (Mode)
{

Просмотреть файл

@ -30,7 +30,7 @@ public class QueryTransformContext
{
get
{
if (_modifiedQueryParameters == null)
if (_modifiedQueryParameters is null)
{
return _originalQueryString;
}
@ -50,7 +50,7 @@ public class QueryTransformContext
{
get
{
if (_modifiedQueryParameters == null)
if (_modifiedQueryParameters is null)
{
_modifiedQueryParameters = new Dictionary<string, StringValues>(_request.Query, StringComparer.OrdinalIgnoreCase);
}

Просмотреть файл

@ -34,7 +34,7 @@ public class RequestHeaderClientCertTransform : RequestTransform
RemoveHeader(context, HeaderName);
var clientCert = context.HttpContext.Connection.ClientCertificate;
if (clientCert != null)
if (clientCert is not null)
{
var encoded = Convert.ToBase64String(clientCert.RawData);
AddHeader(context, HeaderName, encoded);

Просмотреть файл

@ -148,7 +148,7 @@ public class RequestHeaderForwardedTransform : RequestTransform
var addPort = port != 0 && (format == NodeFormat.IpAndPort || format == NodeFormat.UnknownAndPort || format == NodeFormat.RandomAndPort);
var addRandomPort = (format == NodeFormat.IpAndRandomPort || format == NodeFormat.UnknownAndRandomPort || format == NodeFormat.RandomAndRandomPort);
var ipv6 = (format == NodeFormat.Ip || format == NodeFormat.IpAndPort || format == NodeFormat.IpAndRandomPort)
&& ipAddress != null && ipAddress.AddressFamily == System.Net.Sockets.AddressFamily.InterNetworkV6;
&& ipAddress is not null && ipAddress.AddressFamily == System.Net.Sockets.AddressFamily.InterNetworkV6;
var quote = addPort || addRandomPort || ipv6;
if (quote)
@ -161,7 +161,7 @@ public class RequestHeaderForwardedTransform : RequestTransform
case NodeFormat.Ip:
case NodeFormat.IpAndPort:
case NodeFormat.IpAndRandomPort:
if (ipAddress != null)
if (ipAddress is not null)
{
if (ipv6)
{

Просмотреть файл

@ -48,7 +48,7 @@ public class RequestHeaderXForwardedForTransform : RequestTransform
{
case ForwardedTransformActions.Set:
RemoveHeader(context, HeaderName);
if (remoteIp != null)
if (remoteIp is not null)
{
AddHeader(context, HeaderName, remoteIp);
}
@ -69,7 +69,7 @@ public class RequestHeaderXForwardedForTransform : RequestTransform
private void Append(RequestTransformContext context, string? remoteIp)
{
var existingValues = TakeHeader(context, HeaderName);
if (remoteIp == null)
if (remoteIp is null)
{
if (!string.IsNullOrEmpty(existingValues))
{

Просмотреть файл

@ -41,7 +41,7 @@ public class ResponseHeadersAllowedTransform : ResponseTransform
throw new ArgumentNullException(nameof(context));
}
if (context.ProxyResponse == null)
if (context.ProxyResponse is null)
{
return default;
}
@ -51,7 +51,7 @@ public class ResponseHeadersAllowedTransform : ResponseTransform
// See https://github.com/microsoft/reverse-proxy/blob/51d797986b1fea03500a1ad173d13a1176fb5552/src/ReverseProxy/Forwarder/HttpTransformer.cs#L67-L77
var responseHeaders = context.HttpContext.Response.Headers;
CopyResponseHeaders(context.ProxyResponse.Headers, responseHeaders);
if (context.ProxyResponse.Content != null)
if (context.ProxyResponse.Content is not null)
{
CopyResponseHeaders(context.ProxyResponse.Content.Headers, responseHeaders);
}

Просмотреть файл

@ -37,7 +37,7 @@ public class ResponseTrailerRemoveTransform : ResponseTrailersTransform
throw new ArgumentNullException(nameof(context));
}
Debug.Assert(context.ProxyResponse != null);
Debug.Assert(context.ProxyResponse is not null);
if (Condition == ResponseCondition.Always
|| Success(context) == (Condition == ResponseCondition.Success))
@ -45,7 +45,7 @@ public class ResponseTrailerRemoveTransform : ResponseTrailersTransform
var responseTrailersFeature = context.HttpContext.Features.Get<IHttpResponseTrailersFeature>();
var responseTrailers = responseTrailersFeature?.Trailers;
// Support should have already been checked by the caller.
Debug.Assert(responseTrailers != null);
Debug.Assert(responseTrailers is not null);
Debug.Assert(!responseTrailers.IsReadOnly);
responseTrailers.Remove(HeaderName);

Просмотреть файл

@ -42,7 +42,7 @@ public class ResponseTrailersAllowedTransform : ResponseTrailersTransform
throw new ArgumentNullException(nameof(context));
}
Debug.Assert(context.ProxyResponse != null);
Debug.Assert(context.ProxyResponse is not null);
Debug.Assert(!context.HeadersCopied);
// See https://github.com/microsoft/reverse-proxy/blob/51d797986b1fea03500a1ad173d13a1176fb5552/src/ReverseProxy/Forwarder/HttpTransformer.cs#L85-L99
@ -50,7 +50,7 @@ public class ResponseTrailersAllowedTransform : ResponseTrailersTransform
// because they lookup `IHttpResponseTrailersFeature` for every call. Here we do it just once instead.
var responseTrailersFeature = context.HttpContext.Features.Get<IHttpResponseTrailersFeature>();
var outgoingTrailers = responseTrailersFeature?.Trailers;
if (outgoingTrailers != null && !outgoingTrailers.IsReadOnly)
if (outgoingTrailers is not null && !outgoingTrailers.IsReadOnly)
{
// Note that trailers, if any, should already have been declared in Proxy's response
CopyResponseHeaders(context.ProxyResponse.TrailingHeaders, outgoingTrailers);

Просмотреть файл

@ -43,12 +43,12 @@ public abstract class ResponseTrailersTransform
throw new ArgumentException($"'{nameof(headerName)}' cannot be null or empty.", nameof(headerName));
}
Debug.Assert(context.ProxyResponse != null);
Debug.Assert(context.ProxyResponse is not null);
var responseTrailersFeature = context.HttpContext.Features.Get<IHttpResponseTrailersFeature>();
var responseTrailers = responseTrailersFeature?.Trailers;
// Support should have already been checked by the caller.
Debug.Assert(responseTrailers != null);
Debug.Assert(responseTrailers is not null);
Debug.Assert(!responseTrailers.IsReadOnly);
if (responseTrailers.TryGetValue(headerName, out var existingValues))
@ -71,7 +71,7 @@ public abstract class ResponseTrailersTransform
var responseTrailersFeature = context.HttpContext.Features.Get<IHttpResponseTrailersFeature>();
var responseTrailers = responseTrailersFeature?.Trailers;
// Support should have already been checked by the caller.
Debug.Assert(responseTrailers != null);
Debug.Assert(responseTrailers is not null);
Debug.Assert(!responseTrailers.IsReadOnly);
responseTrailers[headerName] = values;

Просмотреть файл

@ -24,7 +24,7 @@ public static class RouteConfigTransformExtensions
}
List<IReadOnlyDictionary<string, string>> transforms;
if (route.Transforms == null)
if (route.Transforms is null)
{
transforms = new List<IReadOnlyDictionary<string, string>>();
}

Просмотреть файл

@ -64,7 +64,7 @@ internal abstract class DelegatingStream : Stream
protected DelegatingStream(Stream innerStream)
{
Debug.Assert(innerStream != null);
Debug.Assert(innerStream is not null);
_innerStream = innerStream;
}

Просмотреть файл

@ -26,14 +26,14 @@ internal sealed class ParsedMetadataEntry<T>
public T GetParsedOrDefault(T defaultValue)
{
var currentValue = _value;
if (_cluster.Model.Config.Metadata != null && _cluster.Model.Config.Metadata.TryGetValue(_metadataName, out var stringValue))
if (_cluster.Model.Config.Metadata is not null && _cluster.Model.Config.Metadata.TryGetValue(_metadataName, out var stringValue))
{
if (currentValue == null || currentValue.Item1 != stringValue)
if (currentValue is null || currentValue.Item1 != stringValue)
{
_value = Tuple.Create<string?, T>(stringValue, _parser(stringValue, out var parsedValue) ? parsedValue : defaultValue);
}
}
else if (currentValue == null || currentValue.Item1 != null)
else if (currentValue is null || currentValue.Item1 is not null)
{
_value = Tuple.Create<string?, T>(null, defaultValue);
}

Просмотреть файл

@ -10,7 +10,7 @@ internal static class ServiceLookupHelper
{
public static IDictionary<string, T> ToDictionaryByUniqueId<T>(this IEnumerable<T> services, Func<T, string> idSelector)
{
if (services == null)
if (services is null)
{
throw new ArgumentNullException(nameof(services));
}

Просмотреть файл

@ -131,7 +131,7 @@ public static class TlsFrameHelper
{
get
{
return _ciphers == null ? ReadOnlyMemory<TlsCipherSuite>.Empty : new ReadOnlyMemory<TlsCipherSuite>(_ciphers);
return _ciphers is null ? ReadOnlyMemory<TlsCipherSuite>.Empty : new ReadOnlyMemory<TlsCipherSuite>(_ciphers);
}
}

Просмотреть файл

@ -54,7 +54,7 @@ internal ref partial struct ValueStringBuilder
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Append(string s)
{
if (s == null)
if (s is null)
{
return;
}
@ -111,7 +111,7 @@ internal ref partial struct ValueStringBuilder
var toReturn = _arrayToReturnToPool;
RawChars = _arrayToReturnToPool = poolArray;
if (toReturn != null)
if (toReturn is not null)
{
ArrayPool<char>.Shared.Return(toReturn);
}
@ -122,7 +122,7 @@ internal ref partial struct ValueStringBuilder
{
var toReturn = _arrayToReturnToPool;
this = default; // for safety, to avoid using pooled array if this instance is erroneously appended to again
if (toReturn != null)
if (toReturn is not null)
{
ArrayPool<char>.Shared.Return(toReturn);
}

Просмотреть файл

@ -36,7 +36,7 @@ public class IngressCacheTests
public void IngressWithClassAnnotationTests(string ingressClassName, string controllerName, bool? isDefault, int expectedIngressCount)
{
// Arrange
if (controllerName != null)
if (controllerName is not null)
{
var ingressClass = KubeResourceGenerator.CreateIngressClass(ingressClassName, controllerName, isDefault);
_cacheUnderTest.Update(WatchEventType.Added, ingressClass);
@ -64,7 +64,7 @@ public class IngressCacheTests
public void IngressWithoutClassAnnotationTests(string ingressClassName, string controllerName, bool? isDefault, int expectedIngressCount)
{
// Arrange
if (controllerName != null)
if (controllerName is not null)
{
var ingressClass = KubeResourceGenerator.CreateIngressClass(ingressClassName, controllerName, isDefault);
_cacheUnderTest.Update(WatchEventType.Added, ingressClass);

Просмотреть файл

@ -129,7 +129,7 @@ public class IngressControllerTests
typeMap.Add("v1/Service", typeof(V1Service));
typeMap.Add("v1/Endpoints", typeof(V1Endpoints));
if (ingressClass != null)
if (ingressClass is not null)
{
cache.Update(WatchEventType.Added, ingressClass);
}

Просмотреть файл

@ -163,7 +163,7 @@ public class TestEnvironment
.UseKestrel(kestrel =>
{
#if NET
if (requestHeaderEncoding != null)
if (requestHeaderEncoding is not null)
{
kestrel.RequestHeaderEncodingSelector = _ => requestHeaderEncoding;
}

Просмотреть файл

@ -307,7 +307,7 @@ public class Expect100ContinueTests
Assert.Equal(0, contentStream.Position);
}
if (responseAction != null)
if (responseAction is not null)
{
await responseAction(response);
}

Просмотреть файл

@ -209,7 +209,7 @@ public class WebSocketTests
static async Task RawUpgrade(HttpContext httpContext)
{
var upgradeFeature = httpContext.Features.Get<IHttpUpgradeFeature>();
if (upgradeFeature == null || !upgradeFeature.IsUpgradableRequest)
if (upgradeFeature is null || !upgradeFeature.IsUpgradableRequest)
{
httpContext.Response.StatusCode = StatusCodes.Status426UpgradeRequired;
return;

Просмотреть файл

@ -23,7 +23,7 @@ public static class TestResources
{
// On Windows, applications should not import PFX files in parallel to avoid a known system-level
// race condition bug in native code which can cause crashes/corruption of the certificate state.
if (importPfxMutex != null)
if (importPfxMutex is not null)
{
Assert.True(importPfxMutex.WaitOne(MutexTimeout), "Cannot acquire the global certificate mutex.");
}
@ -42,12 +42,12 @@ public static class TestResources
{
var webProxy = new WebProxy(new System.Uri(address));
if (bypassOnLocal != null)
if (bypassOnLocal is not null)
{
webProxy.BypassProxyOnLocal = bypassOnLocal.Value;
}
if (useDefaultCredentials != null)
if (useDefaultCredentials is not null)
{
webProxy.UseDefaultCredentials = useDefaultCredentials.Value;
}
@ -57,7 +57,7 @@ public static class TestResources
public static string GetCertPath(string fileName)
{
if (fileName == null)
if (fileName is null)
{
return null;
}

Просмотреть файл

@ -411,7 +411,7 @@ public class ConfigValidatorTests
{
Name = name,
Mode = mode,
Values = value == null ? null : new[] { value },
Values = value is null ? null : new[] { value },
};
var route = new RouteConfig
@ -444,7 +444,7 @@ public class ConfigValidatorTests
{
Name = name,
Mode = mode,
Values = value == null ? null : new[] { value },
Values = value is null ? null : new[] { value },
};
var route = new RouteConfig
@ -888,10 +888,10 @@ public class ConfigValidatorTests
Active = new ActiveHealthCheckConfig
{
Enabled = true,
Interval = interval != null ? TimeSpan.FromSeconds(interval.Value) : (TimeSpan?)null,
Interval = interval is not null ? TimeSpan.FromSeconds(interval.Value) : (TimeSpan?)null,
Path = path,
Policy = policy,
Timeout = timeout != null ? TimeSpan.FromSeconds(timeout.Value) : (TimeSpan?)null
Timeout = timeout is not null ? TimeSpan.FromSeconds(timeout.Value) : (TimeSpan?)null
}
}
};
@ -918,9 +918,9 @@ public class ConfigValidatorTests
Active = new ActiveHealthCheckConfig
{
Enabled = true,
Interval = interval != null ? TimeSpan.FromSeconds(interval.Value) : (TimeSpan?)null,
Interval = interval is not null ? TimeSpan.FromSeconds(interval.Value) : (TimeSpan?)null,
Policy = policy,
Timeout = timeout != null ? TimeSpan.FromSeconds(timeout.Value) : (TimeSpan?)null
Timeout = timeout is not null ? TimeSpan.FromSeconds(timeout.Value) : (TimeSpan?)null
}
}
};
@ -951,7 +951,7 @@ public class ConfigValidatorTests
{
Enabled = true,
Policy = policy,
ReactivationPeriod = reactivationPeriod != null ? TimeSpan.FromSeconds(reactivationPeriod.Value) : (TimeSpan?)null
ReactivationPeriod = reactivationPeriod is not null ? TimeSpan.FromSeconds(reactivationPeriod.Value) : (TimeSpan?)null
}
}
};
@ -978,7 +978,7 @@ public class ConfigValidatorTests
{
Enabled = true,
Policy = policy,
ReactivationPeriod = reactivationPeriod != null ? TimeSpan.FromSeconds(reactivationPeriod.Value) : (TimeSpan?)null
ReactivationPeriod = reactivationPeriod is not null ? TimeSpan.FromSeconds(reactivationPeriod.Value) : (TimeSpan?)null
}
}
};

Просмотреть файл

@ -672,7 +672,7 @@ public class ActiveHealthCheckMonitorTests
httpClient.Setup(c => c.SendAsync(It.IsAny<HttpRequestMessage>(), It.IsAny<CancellationToken>()))
.Returns((HttpRequestMessage m, CancellationToken c) =>
{
if (cancellation != null)
if (cancellation is not null)
{
c.Register(_ => cancellation(), null);
}

Просмотреть файл

@ -119,7 +119,7 @@ public class ConsecutiveFailuresHealthPolicyTests
private ClusterState GetClusterInfo(string id, int destinationCount, int? failureThreshold = null)
{
var metadata = failureThreshold != null
var metadata = failureThreshold is not null
? new Dictionary<string, string> { { ConsecutiveFailuresHealthPolicyOptions.ThresholdMetadataName, failureThreshold.ToString() } }
: null;
var clusterModel = new ClusterModel(

Просмотреть файл

@ -42,7 +42,7 @@ public class DefaultProbingRequestFactoryTests
[InlineData(null)]
public void CreateRequest_RequestVersionProperties(string versionString)
{
var version = versionString != null ? Version.Parse(versionString) : null;
var version = versionString is not null ? Version.Parse(versionString) : null;
var clusterModel = GetClusterConfig("cluster0",
new ActiveHealthCheckConfig()
{

Просмотреть файл

@ -247,7 +247,7 @@ public class TransportFailureRateHealthPolicyTests
private ClusterState GetClusterInfo(string id, int destinationCount, double? failureRateLimit = null, TimeSpan? reactivationPeriod = null)
{
var metadata = failureRateLimit != null
var metadata = failureRateLimit is not null
? new Dictionary<string, string> { { TransportFailureRateHealthPolicyOptions.FailureRateLimitMetadataName, failureRateLimit?.ToString(CultureInfo.InvariantCulture) } }
: null;
var clusterModel = new ClusterModel(

Просмотреть файл

@ -732,7 +732,7 @@ public class ProxyConfigManagerTests
public ValueTask<RouteConfig> ConfigureRouteAsync(RouteConfig route, ClusterConfig cluster, CancellationToken cancel)
{
string order;
if (cluster != null)
if (cluster is not null)
{
order = cluster.Metadata["Order"];
}

Просмотреть файл

@ -156,7 +156,7 @@ public class HeaderMatcherPolicyTests
public async Task ApplyAsync_MatchingScenarios_AnyHeaderValue(string incomingHeaderValue, bool shouldMatch)
{
var context = new DefaultHttpContext();
if (incomingHeaderValue != null)
if (incomingHeaderValue is not null)
{
context.Request.Headers.Add("org-id", incomingHeaderValue);
}
@ -238,7 +238,7 @@ public class HeaderMatcherPolicyTests
bool shouldMatch)
{
var context = new DefaultHttpContext();
if (incomingHeaderValue != null)
if (incomingHeaderValue is not null)
{
context.Request.Headers.Add("org-id", incomingHeaderValue);
}

Просмотреть файл

@ -161,7 +161,7 @@ public class QueryParameterMatcherPolicyTests
public async Task ApplyAsync_MatchingScenarios_AnyQueryParamValue(string incomingQueryParamValue, bool shouldMatch)
{
var context = new DefaultHttpContext();
if (incomingQueryParamValue != null)
if (incomingQueryParamValue is not null)
{
var queryStr = "?org-id=" + incomingQueryParamValue;
context.Request.QueryString = new QueryString(queryStr);
@ -246,7 +246,7 @@ public class QueryParameterMatcherPolicyTests
bool shouldMatch)
{
var context = new DefaultHttpContext();
if (incomingQueryParamValue != null)
if (incomingQueryParamValue is not null)
{
var queryStr = "?org-id=" + incomingQueryParamValue;
context.Request.QueryString = new QueryString(queryStr);

Просмотреть файл

@ -54,14 +54,14 @@ public class BaseSesstionAffinityPolicyTests
Assert.Equal(expectedStatus, affinityResult.Status);
Assert.Same(expectedDestination, affinityResult.Destinations?.FirstOrDefault());
if (expectedLogLevel != null)
if (expectedLogLevel is not null)
{
logger.Verify(
l => l.Log(expectedLogLevel.Value, expectedEventId, It.IsAny<It.IsAnyType>(), It.IsAny<Exception>(), (Func<It.IsAnyType, Exception, string>)It.IsAny<object>()),
Times.Once);
}
if (expectedDestination != null)
if (expectedDestination is not null)
{
Assert.Equal(1, affinityResult.Destinations.Count);
}

Просмотреть файл

@ -40,7 +40,7 @@ public class SessionAffinityMiddlewareTests
var cluster = GetCluster();
var endpoint = GetEndpoint(cluster);
DestinationState foundDestination = null;
if (foundDestinationId != null)
if (foundDestinationId is not null)
{
cluster.Destinations.TryGetValue(foundDestinationId, out foundDestination);
}
@ -72,7 +72,7 @@ public class SessionAffinityMiddlewareTests
policies[0].VerifyNoOtherCalls();
policies[1].VerifyAll();
if (foundDestinationId != null)
if (foundDestinationId is not null)
{
Assert.Equal(1, destinationFeature.AvailableDestinations.Count);
Assert.Equal(foundDestinationId, destinationFeature.AvailableDestinations[0].DestinationId);

Просмотреть файл

@ -60,7 +60,7 @@ public class Startup
{
await httpProxy.SendAsync(httpContext, "https://example.com", httpClient, requestConfig, transformer);
var errorFeature = httpContext.GetForwarderErrorFeature();
if (errorFeature != null)
if (errorFeature is not null)
{
var error = errorFeature.Error;
var exception = errorFeature.Exception;

Просмотреть файл

@ -24,7 +24,7 @@ internal class Program
// Do nothing, we will show help right after.
}
if (parsedArgs == null || parsedArgs.Help)
if (parsedArgs is null || parsedArgs.Help)
{
CommandLineArgs.ShowHelp();
return 1;

Просмотреть файл

@ -96,7 +96,7 @@ public class HttpController : ControllerBase
public async Task Stress([FromQuery] int delay, [FromQuery] int responseSize)
{
var bodyReader = Request.BodyReader;
if (bodyReader != null)
if (bodyReader is not null)
{
while (true)
{
@ -114,7 +114,7 @@ public class HttpController : ControllerBase
}
var bodyWriter = Response.BodyWriter;
if (bodyWriter != null && responseSize > 0)
if (bodyWriter is not null && responseSize > 0)
{
const int WriteBufferSize = 4096;

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше