Exemple #1
0
        private string GetDebuggerDisplay()
        {
            if (Status == ReplyStatus.Ok)
            {
                string result;
                if (Result == null)
                {
                    result = typeof(TResult) == typeof(Microsoft.FSharp.Core.Unit) ? "()" : "null";
                }
                else if (typeof(TResult) == typeof(string))
                {
                    result = Text.DoubleQuote(Result.ToString());
                }
                else
                {
                    result = Result.ToString();
                }

                return(Error == null
                   ? "Reply(" + result + ")"
                   : "Reply(Ok, " + result + ", " + ErrorMessageList.GetDebuggerDisplay(Error) + ")");
            }
            else
            {
                var status = Status == ReplyStatus.Error ? "Error" :
                             Status == ReplyStatus.FatalError ? "FatalError" :
                             "(ReplyStatus)" + ((int)Status).ToString();

                return(Error == null
                   ? "Reply(" + status + ", NoErrorMessages)"
                   : "Reply(" + status + ", " + ErrorMessageList.GetDebuggerDisplay(Error) + ")");
            }
        }
Exemple #2
0
        internal string GetDebuggerDisplay()
        {
            switch (Type)
            {
            case ErrorMessageType.Expected:
                return(String == null
                       ? "Expected(null)"
                       : Text.DoubleQuote("Expected(", String, ")"));

            case ErrorMessageType.ExpectedString:
                return(String == null
                       ? "ExpectedString(null)"
                       : Text.DoubleQuote("ExpectedString(", String, ")"));

            case ErrorMessageType.ExpectedCaseInsensitiveString:
                return(String == null
                       ? "ExpectedCaseInsensitiveString(null)"
                       : Text.DoubleQuote("ExpectedCaseInsensitiveString(", String, ")"));

            case ErrorMessageType.Unexpected:
                return(String == null
                       ? "Unexpected(null)"
                       : Text.DoubleQuote("Unexpected(", String, ")"));

            case ErrorMessageType.UnexpectedString:
                return(String == null
                       ? "UnexpectedString(null)"
                       : Text.DoubleQuote("UnexpectedString(", String, ")"));

            case ErrorMessageType.UnexpectedCaseInsensitiveString:
                return(String == null
                       ? "UnexpectedCaseInsensitiveString(null)"
                       : Text.DoubleQuote("UnexpectedCaseInsensitiveString(", String, ")"));

            case ErrorMessageType.Message:
                return(String == null
                       ? "Message(null)"
                       : Text.DoubleQuote("Message(", String, ")"));

            case ErrorMessageType.NestedError: {
                var ne   = (NestedError)this;
                var pos  = ne.Position == null ? "null" : ne.Position.ToString();
                var msgs = ErrorMessageList.GetDebuggerDisplay(ne.Messages);
                return("NestedError(" + pos + ", ..., " + msgs + ")");
            }

            case ErrorMessageType.CompoundError: {
                var ce    = (CompoundError)this;
                var label = ce.String == null ? "null" : Text.Escape(ce.String, "", "\"", "\"", "", '"');
                var pos   = ce.NestedErrorPosition == null ? "" : ce.NestedErrorPosition.ToString();
                var msgs  = ErrorMessageList.GetDebuggerDisplay(ce.NestedErrorMessages);
                return("CompoundError(" + label + ", " + pos + ", ..., " + msgs + ")");
            }

            case ErrorMessageType.Other: {
                var oe = (Other)this;
                return(oe.Data == null ? "Other(null)" : "Other(" + oe.ToString() + ")");
            }

            default:
                throw new InvalidOperationException();
            }
        }