4 using System.Collections.Generic;
7 namespace SiliconStudio.Presentation.Extensions
11 public const int MaxStackTraceLines = 30;
15 var result =
new List<string>();
20 foreach (
char currentChar
in str)
25 if (
char.IsLower(prevChar) && char.IsUpper(currentChar))
27 var word = str.Substring(wordStart, wordLength);
29 wordStart += wordLength;
33 if (
char.IsUpper(prevChar) && char.IsLower(currentChar) && wordLength > 1)
35 var word = str.Substring(wordStart, wordLength - 1);
37 wordStart += wordLength - 1;
42 prevChar = currentChar;
45 result.Add(str.Substring(wordStart, wordLength));
53 while (exception.InnerException != null)
55 exception = exception.InnerException;
57 var stackTrace = ExtractStackTrace(exception, MaxStackTraceLines);
58 return string.Format(
"{0}{1}{2}{3}", startWithNewLine ? Environment.NewLine :
"", exception.Message, Environment.NewLine, stackTrace);
63 var message = string.Format(
"{0}{1}{2}{3}", exception.Message, Environment.NewLine, ExtractStackTrace(exception), Environment.NewLine);
64 var aggregateException = exception as AggregateException;
65 if (aggregateException != null)
67 message = aggregateException.InnerExceptions.Aggregate(message, (current, innerException) => current + FormatExceptionForReport(exception));
70 if (exception.InnerException != null)
72 message += FormatExceptionForReport(exception.InnerException);
77 private static string ExtractStackTrace(
Exception exception,
int maxLines = -1)
79 var stackTraceArray = exception.StackTrace.Split(
"\r\n".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
80 return string.Join(Environment.NewLine, maxLines > 0 ? stackTraceArray.Take(maxLines) : stackTraceArray);
static string FormatExceptionForMessageBox(Exception exception, bool startWithNewLine)
static string FormatExceptionForReport(Exception exception)
static List< string > CamelCaseSplit(this string str)