diff --git a/Optional/Option_Maybe.cs b/Optional/Option_Maybe.cs index 71a1581..f1d7417 100644 --- a/Optional/Option_Maybe.cs +++ b/Optional/Option_Maybe.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Diagnostics; using System.Linq; using System.Text; @@ -12,6 +13,7 @@ namespace Optional #if !NETSTANDARD [Serializable] #endif + [DebuggerDisplay("{" + nameof(DebugString) + "}")] public struct Option : IEquatable> { private readonly bool hasValue; @@ -91,6 +93,24 @@ public override int GetHashCode() return 0; } + string DebugString + { + get + { + if (hasValue) + { + if (value == null) + { + return "Some(null)"; + } + + return string.Format("Some({0})", value); + } + + return "None"; + } + } + /// /// Returns a string that represents the current optional. /// diff --git a/Portable.Optional/project.json b/Portable.Optional/project.json index 68f1424..905c2ea 100644 --- a/Portable.Optional/project.json +++ b/Portable.Optional/project.json @@ -3,7 +3,8 @@ "dependencies": { "Microsoft.NETCore.Portable.Compatibility": "1.0.1", "Microsoft.NETCore.Platforms": "1.0.1", - "System.Collections": "4.0.11" + "System.Collections": "4.0.11", + "System.Diagnostics.Debug": "4.0.11" }, "frameworks": { "netstandard1.0": {}