diff --git a/src/HealthChecks/Abstractions/ref/Microsoft.Extensions.Diagnostics.HealthChecks.Abstractions.csproj b/src/HealthChecks/Abstractions/ref/Microsoft.Extensions.Diagnostics.HealthChecks.Abstractions.csproj index 8be8d278db..9a93a6f80b 100644 --- a/src/HealthChecks/Abstractions/ref/Microsoft.Extensions.Diagnostics.HealthChecks.Abstractions.csproj +++ b/src/HealthChecks/Abstractions/ref/Microsoft.Extensions.Diagnostics.HealthChecks.Abstractions.csproj @@ -3,6 +3,7 @@ netstandard2.0;$(DefaultNetCoreTargetFramework) $(DefaultNetCoreTargetFramework) + annotations diff --git a/src/HealthChecks/Abstractions/ref/Microsoft.Extensions.Diagnostics.HealthChecks.Abstractions.netcoreapp.cs b/src/HealthChecks/Abstractions/ref/Microsoft.Extensions.Diagnostics.HealthChecks.Abstractions.netcoreapp.cs index 6166362745..3a8e37aca1 100644 --- a/src/HealthChecks/Abstractions/ref/Microsoft.Extensions.Diagnostics.HealthChecks.Abstractions.netcoreapp.cs +++ b/src/HealthChecks/Abstractions/ref/Microsoft.Extensions.Diagnostics.HealthChecks.Abstractions.netcoreapp.cs @@ -10,10 +10,10 @@ namespace Microsoft.Extensions.Diagnostics.HealthChecks } public sealed partial class HealthCheckRegistration { - public HealthCheckRegistration(string name, Microsoft.Extensions.Diagnostics.HealthChecks.IHealthCheck instance, Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus? failureStatus, System.Collections.Generic.IEnumerable tags) { } - public HealthCheckRegistration(string name, Microsoft.Extensions.Diagnostics.HealthChecks.IHealthCheck instance, Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus? failureStatus, System.Collections.Generic.IEnumerable tags, System.TimeSpan? timeout) { } - public HealthCheckRegistration(string name, System.Func factory, Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus? failureStatus, System.Collections.Generic.IEnumerable tags) { } - public HealthCheckRegistration(string name, System.Func factory, Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus? failureStatus, System.Collections.Generic.IEnumerable tags, System.TimeSpan? timeout) { } + public HealthCheckRegistration(string name, Microsoft.Extensions.Diagnostics.HealthChecks.IHealthCheck instance, Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus? failureStatus, System.Collections.Generic.IEnumerable? tags) { } + public HealthCheckRegistration(string name, Microsoft.Extensions.Diagnostics.HealthChecks.IHealthCheck instance, Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus? failureStatus, System.Collections.Generic.IEnumerable? tags, System.TimeSpan? timeout) { } + public HealthCheckRegistration(string name, System.Func factory, Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus? failureStatus, System.Collections.Generic.IEnumerable? tags) { } + public HealthCheckRegistration(string name, System.Func factory, Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus? failureStatus, System.Collections.Generic.IEnumerable? tags, System.TimeSpan? timeout) { } public System.Func Factory { get { throw null; } set { } } public Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus FailureStatus { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute] set { } } public string Name { get { throw null; } set { } } @@ -25,14 +25,14 @@ namespace Microsoft.Extensions.Diagnostics.HealthChecks { private object _dummy; private int _dummyPrimitive; - public HealthCheckResult(Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus status, string description = null, System.Exception exception = null, System.Collections.Generic.IReadOnlyDictionary data = null) { throw null; } + public HealthCheckResult(Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus status, string? description = null, System.Exception? exception = null, System.Collections.Generic.IReadOnlyDictionary? data = null) { throw null; } public System.Collections.Generic.IReadOnlyDictionary Data { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } } - public string Description { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } } - public System.Exception Exception { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } } + public string? Description { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } } + public System.Exception? Exception { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } } public Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus Status { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } } - public static Microsoft.Extensions.Diagnostics.HealthChecks.HealthCheckResult Degraded(string description = null, System.Exception exception = null, System.Collections.Generic.IReadOnlyDictionary data = null) { throw null; } - public static Microsoft.Extensions.Diagnostics.HealthChecks.HealthCheckResult Healthy(string description = null, System.Collections.Generic.IReadOnlyDictionary data = null) { throw null; } - public static Microsoft.Extensions.Diagnostics.HealthChecks.HealthCheckResult Unhealthy(string description = null, System.Exception exception = null, System.Collections.Generic.IReadOnlyDictionary data = null) { throw null; } + public static Microsoft.Extensions.Diagnostics.HealthChecks.HealthCheckResult Degraded(string? description = null, System.Exception? exception = null, System.Collections.Generic.IReadOnlyDictionary? data = null) { throw null; } + public static Microsoft.Extensions.Diagnostics.HealthChecks.HealthCheckResult Healthy(string? description = null, System.Collections.Generic.IReadOnlyDictionary? data = null) { throw null; } + public static Microsoft.Extensions.Diagnostics.HealthChecks.HealthCheckResult Unhealthy(string? description = null, System.Exception? exception = null, System.Collections.Generic.IReadOnlyDictionary? data = null) { throw null; } } public sealed partial class HealthReport { @@ -46,12 +46,12 @@ namespace Microsoft.Extensions.Diagnostics.HealthChecks { private object _dummy; private int _dummyPrimitive; - public HealthReportEntry(Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus status, string description, System.TimeSpan duration, System.Exception exception, System.Collections.Generic.IReadOnlyDictionary data) { throw null; } - public HealthReportEntry(Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus status, string description, System.TimeSpan duration, System.Exception exception, System.Collections.Generic.IReadOnlyDictionary data, System.Collections.Generic.IEnumerable tags = null) { throw null; } + public HealthReportEntry(Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus status, string? description, System.TimeSpan duration, System.Exception? exception, System.Collections.Generic.IReadOnlyDictionary? data) { throw null; } + public HealthReportEntry(Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus status, string? description, System.TimeSpan duration, System.Exception? exception, System.Collections.Generic.IReadOnlyDictionary? data, System.Collections.Generic.IEnumerable? tags = null) { throw null; } public System.Collections.Generic.IReadOnlyDictionary Data { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } } - public string Description { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } } + public string? Description { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } } public System.TimeSpan Duration { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } } - public System.Exception Exception { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } } + public System.Exception? Exception { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } } public Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus Status { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } } public System.Collections.Generic.IEnumerable Tags { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } } } diff --git a/src/HealthChecks/Abstractions/ref/Microsoft.Extensions.Diagnostics.HealthChecks.Abstractions.netstandard2.0.cs b/src/HealthChecks/Abstractions/ref/Microsoft.Extensions.Diagnostics.HealthChecks.Abstractions.netstandard2.0.cs index 6166362745..3a8e37aca1 100644 --- a/src/HealthChecks/Abstractions/ref/Microsoft.Extensions.Diagnostics.HealthChecks.Abstractions.netstandard2.0.cs +++ b/src/HealthChecks/Abstractions/ref/Microsoft.Extensions.Diagnostics.HealthChecks.Abstractions.netstandard2.0.cs @@ -10,10 +10,10 @@ namespace Microsoft.Extensions.Diagnostics.HealthChecks } public sealed partial class HealthCheckRegistration { - public HealthCheckRegistration(string name, Microsoft.Extensions.Diagnostics.HealthChecks.IHealthCheck instance, Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus? failureStatus, System.Collections.Generic.IEnumerable tags) { } - public HealthCheckRegistration(string name, Microsoft.Extensions.Diagnostics.HealthChecks.IHealthCheck instance, Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus? failureStatus, System.Collections.Generic.IEnumerable tags, System.TimeSpan? timeout) { } - public HealthCheckRegistration(string name, System.Func factory, Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus? failureStatus, System.Collections.Generic.IEnumerable tags) { } - public HealthCheckRegistration(string name, System.Func factory, Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus? failureStatus, System.Collections.Generic.IEnumerable tags, System.TimeSpan? timeout) { } + public HealthCheckRegistration(string name, Microsoft.Extensions.Diagnostics.HealthChecks.IHealthCheck instance, Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus? failureStatus, System.Collections.Generic.IEnumerable? tags) { } + public HealthCheckRegistration(string name, Microsoft.Extensions.Diagnostics.HealthChecks.IHealthCheck instance, Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus? failureStatus, System.Collections.Generic.IEnumerable? tags, System.TimeSpan? timeout) { } + public HealthCheckRegistration(string name, System.Func factory, Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus? failureStatus, System.Collections.Generic.IEnumerable? tags) { } + public HealthCheckRegistration(string name, System.Func factory, Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus? failureStatus, System.Collections.Generic.IEnumerable? tags, System.TimeSpan? timeout) { } public System.Func Factory { get { throw null; } set { } } public Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus FailureStatus { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute] set { } } public string Name { get { throw null; } set { } } @@ -25,14 +25,14 @@ namespace Microsoft.Extensions.Diagnostics.HealthChecks { private object _dummy; private int _dummyPrimitive; - public HealthCheckResult(Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus status, string description = null, System.Exception exception = null, System.Collections.Generic.IReadOnlyDictionary data = null) { throw null; } + public HealthCheckResult(Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus status, string? description = null, System.Exception? exception = null, System.Collections.Generic.IReadOnlyDictionary? data = null) { throw null; } public System.Collections.Generic.IReadOnlyDictionary Data { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } } - public string Description { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } } - public System.Exception Exception { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } } + public string? Description { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } } + public System.Exception? Exception { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } } public Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus Status { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } } - public static Microsoft.Extensions.Diagnostics.HealthChecks.HealthCheckResult Degraded(string description = null, System.Exception exception = null, System.Collections.Generic.IReadOnlyDictionary data = null) { throw null; } - public static Microsoft.Extensions.Diagnostics.HealthChecks.HealthCheckResult Healthy(string description = null, System.Collections.Generic.IReadOnlyDictionary data = null) { throw null; } - public static Microsoft.Extensions.Diagnostics.HealthChecks.HealthCheckResult Unhealthy(string description = null, System.Exception exception = null, System.Collections.Generic.IReadOnlyDictionary data = null) { throw null; } + public static Microsoft.Extensions.Diagnostics.HealthChecks.HealthCheckResult Degraded(string? description = null, System.Exception? exception = null, System.Collections.Generic.IReadOnlyDictionary? data = null) { throw null; } + public static Microsoft.Extensions.Diagnostics.HealthChecks.HealthCheckResult Healthy(string? description = null, System.Collections.Generic.IReadOnlyDictionary? data = null) { throw null; } + public static Microsoft.Extensions.Diagnostics.HealthChecks.HealthCheckResult Unhealthy(string? description = null, System.Exception? exception = null, System.Collections.Generic.IReadOnlyDictionary? data = null) { throw null; } } public sealed partial class HealthReport { @@ -46,12 +46,12 @@ namespace Microsoft.Extensions.Diagnostics.HealthChecks { private object _dummy; private int _dummyPrimitive; - public HealthReportEntry(Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus status, string description, System.TimeSpan duration, System.Exception exception, System.Collections.Generic.IReadOnlyDictionary data) { throw null; } - public HealthReportEntry(Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus status, string description, System.TimeSpan duration, System.Exception exception, System.Collections.Generic.IReadOnlyDictionary data, System.Collections.Generic.IEnumerable tags = null) { throw null; } + public HealthReportEntry(Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus status, string? description, System.TimeSpan duration, System.Exception? exception, System.Collections.Generic.IReadOnlyDictionary? data) { throw null; } + public HealthReportEntry(Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus status, string? description, System.TimeSpan duration, System.Exception? exception, System.Collections.Generic.IReadOnlyDictionary? data, System.Collections.Generic.IEnumerable? tags = null) { throw null; } public System.Collections.Generic.IReadOnlyDictionary Data { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } } - public string Description { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } } + public string? Description { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } } public System.TimeSpan Duration { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } } - public System.Exception Exception { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } } + public System.Exception? Exception { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } } public Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus Status { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } } public System.Collections.Generic.IEnumerable Tags { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } } } diff --git a/src/HealthChecks/Abstractions/src/HealthCheckContext.cs b/src/HealthChecks/Abstractions/src/HealthCheckContext.cs index 027451c0d2..afb0e282a0 100644 --- a/src/HealthChecks/Abstractions/src/HealthCheckContext.cs +++ b/src/HealthChecks/Abstractions/src/HealthCheckContext.cs @@ -1,4 +1,4 @@ -// Copyright (c) .NET Foundation. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. namespace Microsoft.Extensions.Diagnostics.HealthChecks @@ -8,6 +8,7 @@ namespace Microsoft.Extensions.Diagnostics.HealthChecks /// /// Gets or sets the of the currently executing . /// - public HealthCheckRegistration Registration { get; set; } + // This allows null values for convenience during unit testing. This is expected to be non-null when within application code. + public HealthCheckRegistration Registration { get; set; } = default!; } } diff --git a/src/HealthChecks/Abstractions/src/HealthCheckRegistration.cs b/src/HealthChecks/Abstractions/src/HealthCheckRegistration.cs index 8ee11e3195..b7f662645d 100644 --- a/src/HealthChecks/Abstractions/src/HealthCheckRegistration.cs +++ b/src/HealthChecks/Abstractions/src/HealthCheckRegistration.cs @@ -36,7 +36,7 @@ namespace Microsoft.Extensions.Diagnostics.HealthChecks /// is null, then will be reported. /// /// A list of tags that can be used for filtering health checks. - public HealthCheckRegistration(string name, IHealthCheck instance, HealthStatus? failureStatus, IEnumerable tags) + public HealthCheckRegistration(string name, IHealthCheck instance, HealthStatus? failureStatus, IEnumerable? tags) : this(name, instance, failureStatus, tags, default) { } @@ -52,7 +52,7 @@ namespace Microsoft.Extensions.Diagnostics.HealthChecks /// /// A list of tags that can be used for filtering health checks. /// An optional representing the timeout of the check. - public HealthCheckRegistration(string name, IHealthCheck instance, HealthStatus? failureStatus, IEnumerable tags, TimeSpan? timeout) + public HealthCheckRegistration(string name, IHealthCheck instance, HealthStatus? failureStatus, IEnumerable? tags, TimeSpan? timeout) { if (name == null) { @@ -69,10 +69,10 @@ namespace Microsoft.Extensions.Diagnostics.HealthChecks throw new ArgumentOutOfRangeException(nameof(timeout)); } - Name = name; + _name = name; FailureStatus = failureStatus ?? HealthStatus.Unhealthy; Tags = new HashSet(tags ?? Array.Empty(), StringComparer.OrdinalIgnoreCase); - Factory = (_) => instance; + _factory = (_) => instance; Timeout = timeout ?? System.Threading.Timeout.InfiniteTimeSpan; } @@ -90,7 +90,7 @@ namespace Microsoft.Extensions.Diagnostics.HealthChecks string name, Func factory, HealthStatus? failureStatus, - IEnumerable tags) + IEnumerable? tags) : this(name, factory, failureStatus, tags, default) { } @@ -110,7 +110,7 @@ namespace Microsoft.Extensions.Diagnostics.HealthChecks string name, Func factory, HealthStatus? failureStatus, - IEnumerable tags, + IEnumerable? tags, TimeSpan? timeout) { if (name == null) @@ -128,10 +128,10 @@ namespace Microsoft.Extensions.Diagnostics.HealthChecks throw new ArgumentOutOfRangeException(nameof(timeout)); } - Name = name; + _name = name; FailureStatus = failureStatus ?? HealthStatus.Unhealthy; Tags = new HashSet(tags ?? Array.Empty(), StringComparer.OrdinalIgnoreCase); - Factory = factory; + _factory = factory; Timeout = timeout ?? System.Threading.Timeout.InfiniteTimeSpan; } diff --git a/src/HealthChecks/Abstractions/src/HealthCheckResult.cs b/src/HealthChecks/Abstractions/src/HealthCheckResult.cs index 7f4522da19..16aca75586 100644 --- a/src/HealthChecks/Abstractions/src/HealthCheckResult.cs +++ b/src/HealthChecks/Abstractions/src/HealthCheckResult.cs @@ -14,14 +14,14 @@ namespace Microsoft.Extensions.Diagnostics.HealthChecks private static readonly IReadOnlyDictionary _emptyReadOnlyDictionary = new Dictionary(); /// - /// Creates a new with the specified values for , + /// Creates a new with the specified values for , /// , , and . /// /// A value indicating the status of the component that was checked. /// A human-readable description of the status of the component that was checked. /// An representing the exception that was thrown when checking for status (if any). /// Additional key-value pairs describing the health of the component. - public HealthCheckResult(HealthStatus status, string description = null, Exception exception = null, IReadOnlyDictionary data = null) + public HealthCheckResult(HealthStatus status, string? description = null, Exception? exception = null, IReadOnlyDictionary? data = null) { Status = status; Description = description; @@ -37,12 +37,12 @@ namespace Microsoft.Extensions.Diagnostics.HealthChecks /// /// Gets a human-readable description of the status of the component that was checked. /// - public string Description { get; } + public string? Description { get; } /// /// Gets an representing the exception that was thrown when checking for status (if any). /// - public Exception Exception { get; } + public Exception? Exception { get; } /// /// Gets a value indicating the status of the component that was checked. @@ -55,7 +55,7 @@ namespace Microsoft.Extensions.Diagnostics.HealthChecks /// A human-readable description of the status of the component that was checked. Optional. /// Additional key-value pairs describing the health of the component. Optional. /// A representing a healthy component. - public static HealthCheckResult Healthy(string description = null, IReadOnlyDictionary data = null) + public static HealthCheckResult Healthy(string? description = null, IReadOnlyDictionary? data = null) { return new HealthCheckResult(status: HealthStatus.Healthy, description, exception: null, data); } @@ -68,7 +68,7 @@ namespace Microsoft.Extensions.Diagnostics.HealthChecks /// An representing the exception that was thrown when checking for status. Optional. /// Additional key-value pairs describing the health of the component. Optional. /// A representing a degraged component. - public static HealthCheckResult Degraded(string description = null, Exception exception = null, IReadOnlyDictionary data = null) + public static HealthCheckResult Degraded(string? description = null, Exception? exception = null, IReadOnlyDictionary? data = null) { return new HealthCheckResult(status: HealthStatus.Degraded, description, exception: exception, data); } @@ -80,7 +80,7 @@ namespace Microsoft.Extensions.Diagnostics.HealthChecks /// An representing the exception that was thrown when checking for status. Optional. /// Additional key-value pairs describing the health of the component. Optional. /// A representing an unhealthy component. - public static HealthCheckResult Unhealthy(string description = null, Exception exception = null, IReadOnlyDictionary data = null) + public static HealthCheckResult Unhealthy(string? description = null, Exception? exception = null, IReadOnlyDictionary? data = null) { return new HealthCheckResult(status: HealthStatus.Unhealthy, description, exception, data); } diff --git a/src/HealthChecks/Abstractions/src/HealthReportEntry.cs b/src/HealthChecks/Abstractions/src/HealthReportEntry.cs index 043c1414a4..0622fd1b47 100644 --- a/src/HealthChecks/Abstractions/src/HealthReportEntry.cs +++ b/src/HealthChecks/Abstractions/src/HealthReportEntry.cs @@ -23,7 +23,7 @@ namespace Microsoft.Extensions.Diagnostics.HealthChecks /// A value indicating the health execution duration. /// An representing the exception that was thrown when checking for status (if any). /// Additional key-value pairs describing the health of the component. - public HealthReportEntry(HealthStatus status, string description, TimeSpan duration, Exception exception, IReadOnlyDictionary data) + public HealthReportEntry(HealthStatus status, string? description, TimeSpan duration, Exception? exception, IReadOnlyDictionary? data) : this(status, description, duration, exception, data, null) { } @@ -38,7 +38,7 @@ namespace Microsoft.Extensions.Diagnostics.HealthChecks /// An representing the exception that was thrown when checking for status (if any). /// Additional key-value pairs describing the health of the component. /// Tags associated with the health check that generated the report entry. - public HealthReportEntry(HealthStatus status, string description, TimeSpan duration, Exception exception, IReadOnlyDictionary data, IEnumerable tags = null) + public HealthReportEntry(HealthStatus status, string? description, TimeSpan duration, Exception? exception, IReadOnlyDictionary? data, IEnumerable? tags = null) { Status = status; Description = description; @@ -57,7 +57,7 @@ namespace Microsoft.Extensions.Diagnostics.HealthChecks /// /// Gets a human-readable description of the status of the component that was checked. /// - public string Description { get; } + public string? Description { get; } /// /// Gets the health check execution duration. @@ -67,7 +67,7 @@ namespace Microsoft.Extensions.Diagnostics.HealthChecks /// /// Gets an representing the exception that was thrown when checking for status (if any). /// - public Exception Exception { get; } + public Exception? Exception { get; } /// /// Gets the health status of the component that was checked. diff --git a/src/HealthChecks/Abstractions/src/Microsoft.Extensions.Diagnostics.HealthChecks.Abstractions.csproj b/src/HealthChecks/Abstractions/src/Microsoft.Extensions.Diagnostics.HealthChecks.Abstractions.csproj index 659c39adc1..9575431a56 100644 --- a/src/HealthChecks/Abstractions/src/Microsoft.Extensions.Diagnostics.HealthChecks.Abstractions.csproj +++ b/src/HealthChecks/Abstractions/src/Microsoft.Extensions.Diagnostics.HealthChecks.Abstractions.csproj @@ -1,4 +1,4 @@ - + Abstractions for defining health checks in .NET applications @@ -14,6 +14,7 @@ Microsoft.Extensions.Diagnostics.HealthChecks.IHealthCheck diagnostics;healthchecks true true + enable diff --git a/src/HealthChecks/HealthChecks/ref/Microsoft.Extensions.Diagnostics.HealthChecks.csproj b/src/HealthChecks/HealthChecks/ref/Microsoft.Extensions.Diagnostics.HealthChecks.csproj index 4f83bbda83..076213fc3b 100644 --- a/src/HealthChecks/HealthChecks/ref/Microsoft.Extensions.Diagnostics.HealthChecks.csproj +++ b/src/HealthChecks/HealthChecks/ref/Microsoft.Extensions.Diagnostics.HealthChecks.csproj @@ -3,6 +3,7 @@ netstandard2.0;$(DefaultNetCoreTargetFramework) $(DefaultNetCoreTargetFramework) + annotations diff --git a/src/HealthChecks/HealthChecks/ref/Microsoft.Extensions.Diagnostics.HealthChecks.netcoreapp.cs b/src/HealthChecks/HealthChecks/ref/Microsoft.Extensions.Diagnostics.HealthChecks.netcoreapp.cs index cee2d1420e..4a2f8dc0c8 100644 --- a/src/HealthChecks/HealthChecks/ref/Microsoft.Extensions.Diagnostics.HealthChecks.netcoreapp.cs +++ b/src/HealthChecks/HealthChecks/ref/Microsoft.Extensions.Diagnostics.HealthChecks.netcoreapp.cs @@ -6,10 +6,10 @@ namespace Microsoft.Extensions.DependencyInjection public static partial class HealthChecksBuilderAddCheckExtensions { public static Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder AddCheck(this Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder builder, string name, Microsoft.Extensions.Diagnostics.HealthChecks.IHealthCheck instance, Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus? failureStatus, System.Collections.Generic.IEnumerable tags) { throw null; } - public static Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder AddCheck(this Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder builder, string name, Microsoft.Extensions.Diagnostics.HealthChecks.IHealthCheck instance, Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus? failureStatus = default(Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus?), System.Collections.Generic.IEnumerable tags = null, System.TimeSpan? timeout = default(System.TimeSpan?)) { throw null; } + public static Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder AddCheck(this Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder builder, string name, Microsoft.Extensions.Diagnostics.HealthChecks.IHealthCheck instance, Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus? failureStatus = default(Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus?), System.Collections.Generic.IEnumerable? tags = null, System.TimeSpan? timeout = default(System.TimeSpan?)) { throw null; } public static Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder AddCheck(this Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder builder, string name, Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus? failureStatus, System.Collections.Generic.IEnumerable tags) where T : class, Microsoft.Extensions.Diagnostics.HealthChecks.IHealthCheck { throw null; } - public static Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder AddCheck(this Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder builder, string name, Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus? failureStatus = default(Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus?), System.Collections.Generic.IEnumerable tags = null, System.TimeSpan? timeout = default(System.TimeSpan?)) where T : class, Microsoft.Extensions.Diagnostics.HealthChecks.IHealthCheck { throw null; } - public static Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder AddTypeActivatedCheck(this Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder builder, string name, Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus? failureStatus, System.Collections.Generic.IEnumerable tags, params object[] args) where T : class, Microsoft.Extensions.Diagnostics.HealthChecks.IHealthCheck { throw null; } + public static Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder AddCheck(this Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder builder, string name, Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus? failureStatus = default(Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus?), System.Collections.Generic.IEnumerable? tags = null, System.TimeSpan? timeout = default(System.TimeSpan?)) where T : class, Microsoft.Extensions.Diagnostics.HealthChecks.IHealthCheck { throw null; } + public static Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder AddTypeActivatedCheck(this Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder builder, string name, Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus? failureStatus, System.Collections.Generic.IEnumerable? tags, params object[] args) where T : class, Microsoft.Extensions.Diagnostics.HealthChecks.IHealthCheck { throw null; } public static Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder AddTypeActivatedCheck(this Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder builder, string name, Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus? failureStatus, System.Collections.Generic.IEnumerable tags, System.TimeSpan timeout, params object[] args) where T : class, Microsoft.Extensions.Diagnostics.HealthChecks.IHealthCheck { throw null; } public static Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder AddTypeActivatedCheck(this Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder builder, string name, Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus? failureStatus, params object[] args) where T : class, Microsoft.Extensions.Diagnostics.HealthChecks.IHealthCheck { throw null; } public static Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder AddTypeActivatedCheck(this Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder builder, string name, params object[] args) where T : class, Microsoft.Extensions.Diagnostics.HealthChecks.IHealthCheck { throw null; } @@ -17,13 +17,13 @@ namespace Microsoft.Extensions.DependencyInjection public static partial class HealthChecksBuilderDelegateExtensions { public static Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder AddAsyncCheck(this Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder builder, string name, System.Func> check, System.Collections.Generic.IEnumerable tags) { throw null; } - public static Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder AddAsyncCheck(this Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder builder, string name, System.Func> check, System.Collections.Generic.IEnumerable tags = null, System.TimeSpan? timeout = default(System.TimeSpan?)) { throw null; } + public static Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder AddAsyncCheck(this Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder builder, string name, System.Func> check, System.Collections.Generic.IEnumerable? tags = null, System.TimeSpan? timeout = default(System.TimeSpan?)) { throw null; } public static Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder AddAsyncCheck(this Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder builder, string name, System.Func> check, System.Collections.Generic.IEnumerable tags) { throw null; } - public static Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder AddAsyncCheck(this Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder builder, string name, System.Func> check, System.Collections.Generic.IEnumerable tags = null, System.TimeSpan? timeout = default(System.TimeSpan?)) { throw null; } + public static Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder AddAsyncCheck(this Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder builder, string name, System.Func> check, System.Collections.Generic.IEnumerable? tags = null, System.TimeSpan? timeout = default(System.TimeSpan?)) { throw null; } public static Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder AddCheck(this Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder builder, string name, System.Func check, System.Collections.Generic.IEnumerable tags) { throw null; } - public static Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder AddCheck(this Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder builder, string name, System.Func check, System.Collections.Generic.IEnumerable tags = null, System.TimeSpan? timeout = default(System.TimeSpan?)) { throw null; } - public static Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder AddCheck(this Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder builder, string name, System.Func check, System.Collections.Generic.IEnumerable tags) { throw null; } - public static Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder AddCheck(this Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder builder, string name, System.Func check, System.Collections.Generic.IEnumerable tags = null, System.TimeSpan? timeout = default(System.TimeSpan?)) { throw null; } + public static Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder AddCheck(this Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder builder, string name, System.Func check, System.Collections.Generic.IEnumerable? tags = null, System.TimeSpan? timeout = default(System.TimeSpan?)) { throw null; } + public static Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder AddCheck(this Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder builder, string name, System.Func check, System.Collections.Generic.IEnumerable? tags) { throw null; } + public static Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder AddCheck(this Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder builder, string name, System.Func check, System.Collections.Generic.IEnumerable? tags = null, System.TimeSpan? timeout = default(System.TimeSpan?)) { throw null; } } public static partial class HealthCheckServiceCollectionExtensions { @@ -42,13 +42,13 @@ namespace Microsoft.Extensions.Diagnostics.HealthChecks public HealthCheckPublisherOptions() { } public System.TimeSpan Delay { get { throw null; } set { } } public System.TimeSpan Period { get { throw null; } set { } } - public System.Func Predicate { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute] set { } } + public System.Func? Predicate { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute] set { } } public System.TimeSpan Timeout { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute] set { } } } public abstract partial class HealthCheckService { protected HealthCheckService() { } - public abstract System.Threading.Tasks.Task CheckHealthAsync(System.Func predicate, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + public abstract System.Threading.Tasks.Task CheckHealthAsync(System.Func? predicate, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); public System.Threading.Tasks.Task CheckHealthAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } } public sealed partial class HealthCheckServiceOptions diff --git a/src/HealthChecks/HealthChecks/ref/Microsoft.Extensions.Diagnostics.HealthChecks.netstandard2.0.cs b/src/HealthChecks/HealthChecks/ref/Microsoft.Extensions.Diagnostics.HealthChecks.netstandard2.0.cs index cee2d1420e..4a2f8dc0c8 100644 --- a/src/HealthChecks/HealthChecks/ref/Microsoft.Extensions.Diagnostics.HealthChecks.netstandard2.0.cs +++ b/src/HealthChecks/HealthChecks/ref/Microsoft.Extensions.Diagnostics.HealthChecks.netstandard2.0.cs @@ -6,10 +6,10 @@ namespace Microsoft.Extensions.DependencyInjection public static partial class HealthChecksBuilderAddCheckExtensions { public static Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder AddCheck(this Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder builder, string name, Microsoft.Extensions.Diagnostics.HealthChecks.IHealthCheck instance, Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus? failureStatus, System.Collections.Generic.IEnumerable tags) { throw null; } - public static Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder AddCheck(this Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder builder, string name, Microsoft.Extensions.Diagnostics.HealthChecks.IHealthCheck instance, Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus? failureStatus = default(Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus?), System.Collections.Generic.IEnumerable tags = null, System.TimeSpan? timeout = default(System.TimeSpan?)) { throw null; } + public static Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder AddCheck(this Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder builder, string name, Microsoft.Extensions.Diagnostics.HealthChecks.IHealthCheck instance, Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus? failureStatus = default(Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus?), System.Collections.Generic.IEnumerable? tags = null, System.TimeSpan? timeout = default(System.TimeSpan?)) { throw null; } public static Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder AddCheck(this Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder builder, string name, Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus? failureStatus, System.Collections.Generic.IEnumerable tags) where T : class, Microsoft.Extensions.Diagnostics.HealthChecks.IHealthCheck { throw null; } - public static Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder AddCheck(this Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder builder, string name, Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus? failureStatus = default(Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus?), System.Collections.Generic.IEnumerable tags = null, System.TimeSpan? timeout = default(System.TimeSpan?)) where T : class, Microsoft.Extensions.Diagnostics.HealthChecks.IHealthCheck { throw null; } - public static Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder AddTypeActivatedCheck(this Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder builder, string name, Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus? failureStatus, System.Collections.Generic.IEnumerable tags, params object[] args) where T : class, Microsoft.Extensions.Diagnostics.HealthChecks.IHealthCheck { throw null; } + public static Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder AddCheck(this Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder builder, string name, Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus? failureStatus = default(Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus?), System.Collections.Generic.IEnumerable? tags = null, System.TimeSpan? timeout = default(System.TimeSpan?)) where T : class, Microsoft.Extensions.Diagnostics.HealthChecks.IHealthCheck { throw null; } + public static Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder AddTypeActivatedCheck(this Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder builder, string name, Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus? failureStatus, System.Collections.Generic.IEnumerable? tags, params object[] args) where T : class, Microsoft.Extensions.Diagnostics.HealthChecks.IHealthCheck { throw null; } public static Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder AddTypeActivatedCheck(this Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder builder, string name, Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus? failureStatus, System.Collections.Generic.IEnumerable tags, System.TimeSpan timeout, params object[] args) where T : class, Microsoft.Extensions.Diagnostics.HealthChecks.IHealthCheck { throw null; } public static Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder AddTypeActivatedCheck(this Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder builder, string name, Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus? failureStatus, params object[] args) where T : class, Microsoft.Extensions.Diagnostics.HealthChecks.IHealthCheck { throw null; } public static Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder AddTypeActivatedCheck(this Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder builder, string name, params object[] args) where T : class, Microsoft.Extensions.Diagnostics.HealthChecks.IHealthCheck { throw null; } @@ -17,13 +17,13 @@ namespace Microsoft.Extensions.DependencyInjection public static partial class HealthChecksBuilderDelegateExtensions { public static Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder AddAsyncCheck(this Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder builder, string name, System.Func> check, System.Collections.Generic.IEnumerable tags) { throw null; } - public static Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder AddAsyncCheck(this Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder builder, string name, System.Func> check, System.Collections.Generic.IEnumerable tags = null, System.TimeSpan? timeout = default(System.TimeSpan?)) { throw null; } + public static Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder AddAsyncCheck(this Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder builder, string name, System.Func> check, System.Collections.Generic.IEnumerable? tags = null, System.TimeSpan? timeout = default(System.TimeSpan?)) { throw null; } public static Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder AddAsyncCheck(this Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder builder, string name, System.Func> check, System.Collections.Generic.IEnumerable tags) { throw null; } - public static Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder AddAsyncCheck(this Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder builder, string name, System.Func> check, System.Collections.Generic.IEnumerable tags = null, System.TimeSpan? timeout = default(System.TimeSpan?)) { throw null; } + public static Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder AddAsyncCheck(this Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder builder, string name, System.Func> check, System.Collections.Generic.IEnumerable? tags = null, System.TimeSpan? timeout = default(System.TimeSpan?)) { throw null; } public static Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder AddCheck(this Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder builder, string name, System.Func check, System.Collections.Generic.IEnumerable tags) { throw null; } - public static Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder AddCheck(this Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder builder, string name, System.Func check, System.Collections.Generic.IEnumerable tags = null, System.TimeSpan? timeout = default(System.TimeSpan?)) { throw null; } - public static Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder AddCheck(this Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder builder, string name, System.Func check, System.Collections.Generic.IEnumerable tags) { throw null; } - public static Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder AddCheck(this Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder builder, string name, System.Func check, System.Collections.Generic.IEnumerable tags = null, System.TimeSpan? timeout = default(System.TimeSpan?)) { throw null; } + public static Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder AddCheck(this Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder builder, string name, System.Func check, System.Collections.Generic.IEnumerable? tags = null, System.TimeSpan? timeout = default(System.TimeSpan?)) { throw null; } + public static Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder AddCheck(this Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder builder, string name, System.Func check, System.Collections.Generic.IEnumerable? tags) { throw null; } + public static Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder AddCheck(this Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder builder, string name, System.Func check, System.Collections.Generic.IEnumerable? tags = null, System.TimeSpan? timeout = default(System.TimeSpan?)) { throw null; } } public static partial class HealthCheckServiceCollectionExtensions { @@ -42,13 +42,13 @@ namespace Microsoft.Extensions.Diagnostics.HealthChecks public HealthCheckPublisherOptions() { } public System.TimeSpan Delay { get { throw null; } set { } } public System.TimeSpan Period { get { throw null; } set { } } - public System.Func Predicate { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute] set { } } + public System.Func? Predicate { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute] set { } } public System.TimeSpan Timeout { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute] set { } } } public abstract partial class HealthCheckService { protected HealthCheckService() { } - public abstract System.Threading.Tasks.Task CheckHealthAsync(System.Func predicate, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + public abstract System.Threading.Tasks.Task CheckHealthAsync(System.Func? predicate, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); public System.Threading.Tasks.Task CheckHealthAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } } public sealed partial class HealthCheckServiceOptions diff --git a/src/HealthChecks/HealthChecks/src/DefaultHealthCheckService.cs b/src/HealthChecks/HealthChecks/src/DefaultHealthCheckService.cs index f2dcc4f5b7..87461ce3c0 100644 --- a/src/HealthChecks/HealthChecks/src/DefaultHealthCheckService.cs +++ b/src/HealthChecks/HealthChecks/src/DefaultHealthCheckService.cs @@ -36,7 +36,7 @@ namespace Microsoft.Extensions.Diagnostics.HealthChecks ValidateRegistrations(_options.Value.Registrations); } public override async Task CheckHealthAsync( - Func predicate, + Func? predicate, CancellationToken cancellationToken = default) { var registrations = _options.Value.Registrations; @@ -89,7 +89,7 @@ namespace Microsoft.Extensions.Diagnostics.HealthChecks Log.HealthCheckBegin(_logger, registration); HealthReportEntry entry; - CancellationTokenSource timeoutCancellationTokenSource = null; + CancellationTokenSource? timeoutCancellationTokenSource = null; try { HealthCheckResult result; @@ -183,17 +183,17 @@ namespace Microsoft.Extensions.Diagnostics.HealthChecks private static class Log { - private static readonly Action _healthCheckProcessingBegin = LoggerMessage.Define( + private static readonly Action _healthCheckProcessingBegin = LoggerMessage.Define( LogLevel.Debug, EventIds.HealthCheckProcessingBegin, "Running health checks"); - private static readonly Action _healthCheckProcessingEnd = LoggerMessage.Define( + private static readonly Action _healthCheckProcessingEnd = LoggerMessage.Define( LogLevel.Debug, EventIds.HealthCheckProcessingEnd, "Health check processing completed after {ElapsedMilliseconds}ms with combined status {HealthStatus}"); - private static readonly Action _healthCheckBegin = LoggerMessage.Define( + private static readonly Action _healthCheckBegin = LoggerMessage.Define( LogLevel.Debug, EventIds.HealthCheckBegin, "Running health check {HealthCheckName}"); @@ -201,27 +201,27 @@ namespace Microsoft.Extensions.Diagnostics.HealthChecks // These are separate so they can have different log levels private static readonly string HealthCheckEndText = "Health check {HealthCheckName} completed after {ElapsedMilliseconds}ms with status {HealthStatus} and description '{HealthCheckDescription}'"; - private static readonly Action _healthCheckEndHealthy = LoggerMessage.Define( + private static readonly Action _healthCheckEndHealthy = LoggerMessage.Define( LogLevel.Debug, EventIds.HealthCheckEnd, HealthCheckEndText); - private static readonly Action _healthCheckEndDegraded = LoggerMessage.Define( + private static readonly Action _healthCheckEndDegraded = LoggerMessage.Define( LogLevel.Warning, EventIds.HealthCheckEnd, HealthCheckEndText); - private static readonly Action _healthCheckEndUnhealthy = LoggerMessage.Define( + private static readonly Action _healthCheckEndUnhealthy = LoggerMessage.Define( LogLevel.Error, EventIds.HealthCheckEnd, HealthCheckEndText); - private static readonly Action _healthCheckEndFailed = LoggerMessage.Define( + private static readonly Action _healthCheckEndFailed = LoggerMessage.Define( LogLevel.Error, EventIds.HealthCheckEnd, HealthCheckEndText); - private static readonly Action _healthCheckError = LoggerMessage.Define( + private static readonly Action _healthCheckError = LoggerMessage.Define( LogLevel.Error, EventIds.HealthCheckError, "Health check {HealthCheckName} threw an unhandled exception after {ElapsedMilliseconds}ms"); @@ -283,7 +283,7 @@ namespace Microsoft.Extensions.Diagnostics.HealthChecks private readonly string _name; private readonly List> _values; - private string _formatted; + private string? _formatted; public HealthCheckDataLogValue(string name, IReadOnlyDictionary values) { diff --git a/src/HealthChecks/HealthChecks/src/DependencyInjection/HealthChecksBuilderAddCheckExtensions.cs b/src/HealthChecks/HealthChecks/src/DependencyInjection/HealthChecksBuilderAddCheckExtensions.cs index 51b7815438..0f280d9b68 100644 --- a/src/HealthChecks/HealthChecks/src/DependencyInjection/HealthChecksBuilderAddCheckExtensions.cs +++ b/src/HealthChecks/HealthChecks/src/DependencyInjection/HealthChecksBuilderAddCheckExtensions.cs @@ -53,7 +53,7 @@ namespace Microsoft.Extensions.DependencyInjection string name, IHealthCheck instance, HealthStatus? failureStatus = null, - IEnumerable tags = null, + IEnumerable? tags = null, TimeSpan? timeout = null) { if (builder == null) @@ -125,7 +125,7 @@ namespace Microsoft.Extensions.DependencyInjection this IHealthChecksBuilder builder, string name, HealthStatus? failureStatus = null, - IEnumerable tags = null, + IEnumerable? tags = null, TimeSpan? timeout = null) where T : class, IHealthCheck { if (builder == null) @@ -227,7 +227,7 @@ namespace Microsoft.Extensions.DependencyInjection this IHealthChecksBuilder builder, string name, HealthStatus? failureStatus, - IEnumerable tags, + IEnumerable? tags, params object[] args) where T : class, IHealthCheck { if (builder == null) diff --git a/src/HealthChecks/HealthChecks/src/DependencyInjection/HealthChecksBuilderDelegateExtensions.cs b/src/HealthChecks/HealthChecks/src/DependencyInjection/HealthChecksBuilderDelegateExtensions.cs index ba27ab5554..0419d0c3b2 100644 --- a/src/HealthChecks/HealthChecks/src/DependencyInjection/HealthChecksBuilderDelegateExtensions.cs +++ b/src/HealthChecks/HealthChecks/src/DependencyInjection/HealthChecksBuilderDelegateExtensions.cs @@ -45,7 +45,7 @@ namespace Microsoft.Extensions.DependencyInjection this IHealthChecksBuilder builder, string name, Func check, - IEnumerable tags = null, + IEnumerable? tags = null, TimeSpan? timeout = default) { if (builder == null) @@ -80,7 +80,7 @@ namespace Microsoft.Extensions.DependencyInjection this IHealthChecksBuilder builder, string name, Func check, - IEnumerable tags) + IEnumerable? tags) { return AddCheck(builder, name, check, tags, default); } @@ -98,7 +98,7 @@ namespace Microsoft.Extensions.DependencyInjection this IHealthChecksBuilder builder, string name, Func check, - IEnumerable tags = null, + IEnumerable? tags = null, TimeSpan? timeout = default) { if (builder == null) @@ -151,7 +151,7 @@ namespace Microsoft.Extensions.DependencyInjection this IHealthChecksBuilder builder, string name, Func> check, - IEnumerable tags = null, + IEnumerable? tags = null, TimeSpan? timeout = default) { if (builder == null) @@ -204,7 +204,7 @@ namespace Microsoft.Extensions.DependencyInjection this IHealthChecksBuilder builder, string name, Func> check, - IEnumerable tags = null, + IEnumerable? tags = null, TimeSpan? timeout = default) { if (builder == null) diff --git a/src/HealthChecks/HealthChecks/src/HealthCheckPublisherHostedService.cs b/src/HealthChecks/HealthChecks/src/HealthCheckPublisherHostedService.cs index 6a24d4c4a3..4da7a52bee 100644 --- a/src/HealthChecks/HealthChecks/src/HealthCheckPublisherHostedService.cs +++ b/src/HealthChecks/HealthChecks/src/HealthCheckPublisherHostedService.cs @@ -21,8 +21,8 @@ namespace Microsoft.Extensions.Diagnostics.HealthChecks private readonly IHealthCheckPublisher[] _publishers; private CancellationTokenSource _stopping; - private Timer _timer; - private CancellationTokenSource _runTokenSource; + private Timer? _timer; + private CancellationTokenSource? _runTokenSource; public HealthCheckPublisherHostedService( HealthCheckService healthCheckService, @@ -100,7 +100,7 @@ namespace Microsoft.Extensions.Diagnostics.HealthChecks } // Yes, async void. We need to be async. We need to be void. We handle the exceptions in RunAsync - private async void Timer_Tick(object state) + private async void Timer_Tick(object? state) { await RunAsync(); } @@ -108,7 +108,7 @@ namespace Microsoft.Extensions.Diagnostics.HealthChecks // Internal for testing internal void CancelToken() { - _runTokenSource.Cancel(); + _runTokenSource!.Cancel(); } // Internal for testing @@ -117,7 +117,7 @@ namespace Microsoft.Extensions.Diagnostics.HealthChecks var duration = ValueStopwatch.StartNew(); Logger.HealthCheckPublisherProcessingBegin(_logger); - CancellationTokenSource cancellation = null; + CancellationTokenSource? cancellation = null; try { var timeout = _options.Value.Timeout; @@ -142,7 +142,7 @@ namespace Microsoft.Extensions.Diagnostics.HealthChecks } finally { - cancellation.Dispose(); + cancellation?.Dispose(); } } @@ -206,32 +206,32 @@ namespace Microsoft.Extensions.Diagnostics.HealthChecks private static class Logger { - private static readonly Action _healthCheckPublisherProcessingBegin = LoggerMessage.Define( + private static readonly Action _healthCheckPublisherProcessingBegin = LoggerMessage.Define( LogLevel.Debug, EventIds.HealthCheckPublisherProcessingBegin, "Running health check publishers"); - private static readonly Action _healthCheckPublisherProcessingEnd = LoggerMessage.Define( + private static readonly Action _healthCheckPublisherProcessingEnd = LoggerMessage.Define( LogLevel.Debug, EventIds.HealthCheckPublisherProcessingEnd, "Health check publisher processing completed after {ElapsedMilliseconds}ms"); - private static readonly Action _healthCheckPublisherBegin = LoggerMessage.Define( + private static readonly Action _healthCheckPublisherBegin = LoggerMessage.Define( LogLevel.Debug, EventIds.HealthCheckPublisherBegin, "Running health check publisher '{HealthCheckPublisher}'"); - private static readonly Action _healthCheckPublisherEnd = LoggerMessage.Define( + private static readonly Action _healthCheckPublisherEnd = LoggerMessage.Define( LogLevel.Debug, EventIds.HealthCheckPublisherEnd, "Health check '{HealthCheckPublisher}' completed after {ElapsedMilliseconds}ms"); - private static readonly Action _healthCheckPublisherError = LoggerMessage.Define( + private static readonly Action _healthCheckPublisherError = LoggerMessage.Define( LogLevel.Error, EventIds.HealthCheckPublisherError, "Health check {HealthCheckPublisher} threw an unhandled exception after {ElapsedMilliseconds}ms"); - private static readonly Action _healthCheckPublisherTimeout = LoggerMessage.Define( + private static readonly Action _healthCheckPublisherTimeout = LoggerMessage.Define( LogLevel.Error, EventIds.HealthCheckPublisherTimeout, "Health check {HealthCheckPublisher} was canceled after {ElapsedMilliseconds}ms"); @@ -241,7 +241,7 @@ namespace Microsoft.Extensions.Diagnostics.HealthChecks _healthCheckPublisherProcessingBegin(logger, null); } - public static void HealthCheckPublisherProcessingEnd(ILogger logger, TimeSpan duration, Exception exception = null) + public static void HealthCheckPublisherProcessingEnd(ILogger logger, TimeSpan duration, Exception? exception = null) { _healthCheckPublisherProcessingEnd(logger, duration.TotalMilliseconds, exception); } diff --git a/src/HealthChecks/HealthChecks/src/HealthCheckPublisherOptions.cs b/src/HealthChecks/HealthChecks/src/HealthCheckPublisherOptions.cs index 6b7c8c3365..312ff14ca9 100644 --- a/src/HealthChecks/HealthChecks/src/HealthCheckPublisherOptions.cs +++ b/src/HealthChecks/HealthChecks/src/HealthCheckPublisherOptions.cs @@ -1,4 +1,4 @@ -// Copyright (c) .NET Foundation. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; @@ -72,7 +72,7 @@ namespace Microsoft.Extensions.Diagnostics.HealthChecks /// registered health checks - this is the default behavior. To run a subset of health checks, /// provide a function that filters the set of checks. The predicate will be evaluated each period. /// - public Func Predicate { get; set; } + public Func? Predicate { get; set; } /// /// Gets or sets the timeout for executing the health checks an all diff --git a/src/HealthChecks/HealthChecks/src/HealthCheckService.cs b/src/HealthChecks/HealthChecks/src/HealthCheckService.cs index e4a128148d..7ef29cc961 100644 --- a/src/HealthChecks/HealthChecks/src/HealthCheckService.cs +++ b/src/HealthChecks/HealthChecks/src/HealthCheckService.cs @@ -55,7 +55,7 @@ namespace Microsoft.Extensions.Diagnostics.HealthChecks /// yielding a containing the results. /// public abstract Task CheckHealthAsync( - Func predicate, + Func? predicate, CancellationToken cancellationToken = default); } } diff --git a/src/HealthChecks/HealthChecks/src/Microsoft.Extensions.Diagnostics.HealthChecks.csproj b/src/HealthChecks/HealthChecks/src/Microsoft.Extensions.Diagnostics.HealthChecks.csproj index 44e1d8d95f..505a90fc3d 100644 --- a/src/HealthChecks/HealthChecks/src/Microsoft.Extensions.Diagnostics.HealthChecks.csproj +++ b/src/HealthChecks/HealthChecks/src/Microsoft.Extensions.Diagnostics.HealthChecks.csproj @@ -1,4 +1,4 @@ - + Components for performing health checks in .NET applications @@ -13,6 +13,7 @@ Microsoft.Extensions.Diagnostics.HealthChecks.IHealthChecksBuilder diagnostics;healthchecks true true + enable diff --git a/src/HealthChecks/HealthChecks/test/DefaultHealthCheckServiceTest.cs b/src/HealthChecks/HealthChecks/test/DefaultHealthCheckServiceTest.cs index 1cb5b7420b..ad566909c7 100644 --- a/src/HealthChecks/HealthChecks/test/DefaultHealthCheckServiceTest.cs +++ b/src/HealthChecks/HealthChecks/test/DefaultHealthCheckServiceTest.cs @@ -139,7 +139,7 @@ namespace Microsoft.Extensions.Diagnostics.HealthChecks Assert.Equal("ExceptionCheck", actual.Key); Assert.Equal(ExceptionMessage, actual.Value.Description); Assert.Equal(HealthStatus.Unhealthy, actual.Value.Status); - Assert.Equal(ExceptionMessage, actual.Value.Exception.Message); + Assert.Equal(ExceptionMessage, actual.Value.Exception!.Message); Assert.Empty(actual.Value.Data); Assert.Equal(actual.Value.Tags, exceptionTags); }, @@ -148,7 +148,7 @@ namespace Microsoft.Extensions.Diagnostics.HealthChecks Assert.Equal("OperationExceptionCheck", actual.Key); Assert.Equal("A timeout occurred while running check.", actual.Value.Description); Assert.Equal(HealthStatus.Unhealthy, actual.Value.Status); - Assert.Equal(OperationCancelledMessage, actual.Value.Exception.Message); + Assert.Equal(OperationCancelledMessage, actual.Value.Exception!.Message); Assert.Empty(actual.Value.Data); Assert.Equal(actual.Value.Tags, operationExceptionTags); }); @@ -243,7 +243,7 @@ namespace Microsoft.Extensions.Diagnostics.HealthChecks public async Task CheckHealthAsync_Cancellation_CanPropagate() { // Arrange - var insideCheck = new TaskCompletionSource(); + var insideCheck = new TaskCompletionSource(); var service = CreateHealthChecksService(b => { @@ -428,10 +428,10 @@ namespace Microsoft.Extensions.Diagnostics.HealthChecks public async Task CheckHealthAsync_ChecksAreRunInParallel() { // Arrange - var input1 = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); - var input2 = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); - var output1 = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); - var output2 = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); + var input1 = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); + var input2 = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); + var output1 = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); + var output2 = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); var service = CreateHealthChecksService(b => { diff --git a/src/HealthChecks/HealthChecks/test/HealthCheckPublisherHostedServiceTest.cs b/src/HealthChecks/HealthChecks/test/HealthCheckPublisherHostedServiceTest.cs index 2413b57054..b2cdef6b5e 100644 --- a/src/HealthChecks/HealthChecks/test/HealthCheckPublisherHostedServiceTest.cs +++ b/src/HealthChecks/HealthChecks/test/HealthCheckPublisherHostedServiceTest.cs @@ -76,9 +76,9 @@ namespace Microsoft.Extensions.Diagnostics.HealthChecks public async Task StartAsync_WithPublishers_StartsTimer_RunsPublishers() { // Arrange - var unblock0 = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); - var unblock1 = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); - var unblock2 = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); + var unblock0 = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); + var unblock1 = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); + var unblock2 = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); var publishers = new TestPublisher[] { @@ -121,7 +121,7 @@ namespace Microsoft.Extensions.Diagnostics.HealthChecks public async Task StopAsync_CancelsExecution() { // Arrange - var unblock = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); + var unblock = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); var publishers = new TestPublisher[] { @@ -167,7 +167,7 @@ namespace Microsoft.Extensions.Diagnostics.HealthChecks // Arrange var sink = new TestSink(); - var unblock = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); + var unblock = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); var publishers = new TestPublisher[] { @@ -225,9 +225,9 @@ namespace Microsoft.Extensions.Diagnostics.HealthChecks public async Task RunAsync_WaitsForCompletion_Multiple() { // Arrange - var unblock0 = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); - var unblock1 = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); - var unblock2 = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); + var unblock0 = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); + var unblock1 = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); + var unblock2 = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); var publishers = new TestPublisher[] { @@ -278,7 +278,7 @@ namespace Microsoft.Extensions.Diagnostics.HealthChecks { // Arrange var sink = new TestSink(); - var unblock = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); + var unblock = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); var publishers = new TestPublisher[] { @@ -440,8 +440,8 @@ namespace Microsoft.Extensions.Diagnostics.HealthChecks private HealthCheckPublisherHostedService CreateService( IHealthCheckPublisher[] publishers, - Action configure = null, - TestSink sink = null) + Action? configure = null, + TestSink? sink = null) { var serviceCollection = new ServiceCollection(); serviceCollection.AddOptions(); @@ -488,20 +488,20 @@ namespace Microsoft.Extensions.Diagnostics.HealthChecks private class TestPublisher : IHealthCheckPublisher { - private TaskCompletionSource _started; + private TaskCompletionSource _started; public TestPublisher() { - _started = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); + _started = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); } public List<(HealthReport report, CancellationToken cancellationToken)> Entries { get; } = new List<(HealthReport report, CancellationToken cancellationToken)>(); - public Exception Exception { get; set; } + public Exception? Exception { get; set; } public Task Started => _started.Task; - public Task Wait { get; set; } + public Task? Wait { get; set; } public async Task PublishAsync(HealthReport report, CancellationToken cancellationToken) { diff --git a/src/HealthChecks/HealthChecks/test/Microsoft.Extensions.Diagnostics.HealthChecks.Tests.csproj b/src/HealthChecks/HealthChecks/test/Microsoft.Extensions.Diagnostics.HealthChecks.Tests.csproj index eb1d44441e..b58da42031 100644 --- a/src/HealthChecks/HealthChecks/test/Microsoft.Extensions.Diagnostics.HealthChecks.Tests.csproj +++ b/src/HealthChecks/HealthChecks/test/Microsoft.Extensions.Diagnostics.HealthChecks.Tests.csproj @@ -1,8 +1,9 @@ - + $(DefaultNetCoreTargetFramework);net472 Microsoft.Extensions.Diagnostics.HealthChecks + enable diff --git a/src/Shared/NonCapturingTimer/NonCapturingTimer.cs b/src/Shared/NonCapturingTimer/NonCapturingTimer.cs index 6f54b2db47..91a376baa3 100644 --- a/src/Shared/NonCapturingTimer/NonCapturingTimer.cs +++ b/src/Shared/NonCapturingTimer/NonCapturingTimer.cs @@ -1,5 +1,6 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +#nullable enable using System; using System.Threading; @@ -11,7 +12,7 @@ namespace Microsoft.Extensions.Internal // everywhere we use timers to avoid rooting any values stored in asynclocals. internal static class NonCapturingTimer { - public static Timer Create(TimerCallback callback, object state, TimeSpan dueTime, TimeSpan period) + public static Timer Create(TimerCallback callback, object? state, TimeSpan dueTime, TimeSpan period) { if (callback == null) { diff --git a/src/Shared/test/Shared.Tests/SingleThreadedSynchronizationContext.cs b/src/Shared/test/Shared.Tests/SingleThreadedSynchronizationContext.cs index 77312e0a05..7ac24722c9 100644 --- a/src/Shared/test/Shared.Tests/SingleThreadedSynchronizationContext.cs +++ b/src/Shared/test/Shared.Tests/SingleThreadedSynchronizationContext.cs @@ -1,6 +1,8 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +#nullable enable + using System; using System.Collections.Concurrent; using System.Threading; @@ -9,14 +11,14 @@ namespace Microsoft.Extensions.Internal { internal class SingleThreadedSynchronizationContext : SynchronizationContext { - private readonly BlockingCollection<(SendOrPostCallback Callback, object State)> _queue = new BlockingCollection<(SendOrPostCallback Callback, object State)>(); + private readonly BlockingCollection<(SendOrPostCallback Callback, object? State)> _queue = new BlockingCollection<(SendOrPostCallback Callback, object? State)>(); - public override void Send(SendOrPostCallback d, object state) // Sync operations + public override void Send(SendOrPostCallback d, object? state) // Sync operations { throw new NotSupportedException($"{nameof(SingleThreadedSynchronizationContext)} does not support synchronous operations."); } - public override void Post(SendOrPostCallback d, object state) // Async operations + public override void Post(SendOrPostCallback d, object? state) // Async operations { _queue.Add((d, state)); }