Fix IDE0025 (use expression body for properties)
[mono-project.git] / netcore / System.Private.CoreLib / shared / System / Diagnostics / Contracts / ContractFailedEventArgs.cs
blobbce8138b7670a23c9121cb732ef4b04edcfeb226
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.
5 using System;
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;
20 private bool _unwind;
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;
28 _message = message;
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()
43 _handled = true;
46 public bool Unwind => _unwind;
48 public void SetUnwind()
50 _unwind = true;