1 // Licensed to the .NET Foundation under one or more agreements.
2 // The .NET Foundation licenses this file to you under the MIT license.
3 // See the LICENSE file in the project root for more information.
6 using System
.Collections
.Generic
;
7 using System
.Diagnostics
;
8 using System
.Diagnostics
.CodeAnalysis
;
9 using System
.Reflection
;
11 namespace System
.Diagnostics
.Contracts
13 public sealed class ContractFailedEventArgs
: EventArgs
15 private readonly ContractFailureKind _failureKind
;
16 private readonly string? _message
;
17 private readonly string? _condition
;
18 private readonly Exception
? _originalException
;
19 private bool _handled
;
22 internal Exception
? thrownDuringHandler
;
24 public ContractFailedEventArgs(ContractFailureKind failureKind
, string? message
, string? condition
, Exception
? originalException
)
26 Debug
.Assert(originalException
== null || failureKind
== ContractFailureKind
.PostconditionOnException
);
27 _failureKind
= failureKind
;
29 _condition
= condition
;
30 _originalException
= originalException
;
33 public string? Message
=> _message
;
34 public string? Condition
=> _condition
;
35 public ContractFailureKind FailureKind
=> _failureKind
;
36 public Exception
? OriginalException
=> _originalException
;
38 // Whether the event handler "handles" this contract failure, or to fail via escalation policy.
39 public bool Handled
=> _handled
;
41 public void SetHandled()
46 public bool Unwind
=> _unwind
;
48 public void SetUnwind()