diff options
Diffstat (limited to 'src/System.Private.CoreLib/shared/System/Threading/Tasks/TaskCanceledException.cs')
-rw-r--r-- | src/System.Private.CoreLib/shared/System/Threading/Tasks/TaskCanceledException.cs | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/System.Private.CoreLib/shared/System/Threading/Tasks/TaskCanceledException.cs b/src/System.Private.CoreLib/shared/System/Threading/Tasks/TaskCanceledException.cs index c3ee31a53c..5147f116eb 100644 --- a/src/System.Private.CoreLib/shared/System/Threading/Tasks/TaskCanceledException.cs +++ b/src/System.Private.CoreLib/shared/System/Threading/Tasks/TaskCanceledException.cs @@ -10,8 +10,7 @@ // // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- -using System; -using System.Runtime.InteropServices; +#nullable enable using System.Runtime.Serialization; namespace System.Threading.Tasks @@ -24,7 +23,7 @@ namespace System.Threading.Tasks public class TaskCanceledException : OperationCanceledException { [NonSerialized] - private readonly Task _canceledTask; // The task which has been canceled. + private readonly Task? _canceledTask; // The task which has been canceled. /// <summary> /// Initializes a new instance of the <see cref="T:System.Threading.Tasks.TaskCanceledException"/> class. @@ -38,7 +37,7 @@ namespace System.Threading.Tasks /// class with a specified error message. /// </summary> /// <param name="message">The error message that explains the reason for the exception.</param> - public TaskCanceledException(string message) : base(message) + public TaskCanceledException(string? message) : base(message) { } @@ -49,7 +48,7 @@ namespace System.Threading.Tasks /// </summary> /// <param name="message">The error message that explains the reason for the exception.</param> /// <param name="innerException">The exception that is the cause of the current exception.</param> - public TaskCanceledException(string message, Exception innerException) : base(message, innerException) + public TaskCanceledException(string? message, Exception? innerException) : base(message, innerException) { } @@ -61,7 +60,7 @@ namespace System.Threading.Tasks /// <param name="message">The error message that explains the reason for the exception.</param> /// <param name="innerException">The exception that is the cause of the current exception.</param> /// <param name="token">The <see cref="CancellationToken"/> that triggered the cancellation.</param> - public TaskCanceledException(string message, Exception innerException, CancellationToken token) : base(message, innerException, token) + public TaskCanceledException(string? message, Exception? innerException, CancellationToken token) : base(message, innerException, token) { } @@ -70,7 +69,7 @@ namespace System.Threading.Tasks /// with a reference to the <see cref="T:System.Threading.Tasks.Task"/> that has been canceled. /// </summary> /// <param name="task">A task that has been canceled.</param> - public TaskCanceledException(Task task) : + public TaskCanceledException(Task? task) : base(SR.TaskCanceledException_ctor_DefaultMessage, task != null ? task.CancellationToken : new CancellationToken()) { _canceledTask = task; @@ -94,6 +93,6 @@ namespace System.Threading.Tasks /// <see cref="T:System.Threading.Tasks.TaskCanceledException"/>, in which case /// this property will return null. /// </remarks> - public Task Task => _canceledTask; + public Task? Task => _canceledTask; } } |