Skip to content

Commit

Permalink
Mark Task.IsFaulted as ensuring that Task.Exception is non-null (dotn…
Browse files Browse the repository at this point in the history
…et#80278)

* Mark Task.IsFaulted as ensuring that Task.Exception is non-null

* Address PR feedback

Co-authored-by: Stephen Toub <[email protected]>
  • Loading branch information
jasonmalinowski and stephentoub authored Jan 8, 2023
1 parent 13ce7b9 commit e4ada84
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Diagnostics.Tracing;
using System.Runtime.CompilerServices;
using System.Runtime.ExceptionServices;
Expand Down Expand Up @@ -1523,6 +1524,7 @@ internal bool ExceptionRecorded
/// <see cref="System.Threading.Tasks.TaskStatus.Faulted">TaskStatus.Faulted</see>, and its
/// <see cref="Exception"/> property will be non-null.
/// </remarks>
[MemberNotNullWhen(true, nameof(Exception))]
public bool IsFaulted =>
// Faulted is "king" -- if that bit is present (regardless of other bits), we are faulted.
(m_stateFlags & (int)TaskStateFlags.Faulted) != 0;
Expand Down
1 change: 1 addition & 0 deletions src/libraries/System.Runtime/ref/System.Runtime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14505,6 +14505,7 @@ public Task(System.Action<object?> action, object? state, System.Threading.Tasks
public bool IsCanceled { get { throw null; } }
public bool IsCompleted { get { throw null; } }
public bool IsCompletedSuccessfully { get { throw null; } }
[System.Diagnostics.CodeAnalysis.MemberNotNullWhenAttribute(true, nameof(System.Exception))]
public bool IsFaulted { get { throw null; } }
public System.Threading.Tasks.TaskStatus Status { get { throw null; } }
System.Threading.WaitHandle System.IAsyncResult.AsyncWaitHandle { get { throw null; } }
Expand Down

0 comments on commit e4ada84

Please sign in to comment.