namespace Fixie.Assertions
{
    using System;
    using System.Collections.Generic;

    public class AssertException : Exception
    {
        public static string FilterStackTraceAssemblyPrefix = "Fixie.Assertions.";

        public AssertException(string message)
            : base(message)
        {
        }

        public override string StackTrace => FilterStackTrace(base.StackTrace);

        static string FilterStackTrace(string stackTrace)
        {
            if (stackTrace == null)
                return null;

            var results = new List<string>();

            foreach (var line in SplitLines(stackTrace))
            {
                var trimmedLine = line.TrimStart();
                if (!trimmedLine.StartsWith( "at " + FilterStackTraceAssemblyPrefix) )
                    results.Add(line);
            }

            return string.Join(Environment.NewLine, results.ToArray());
        }

        // Our own custom string.Split because Silverlight/CoreCLR doesn't support the version we were using
        static IEnumerable<string> SplitLines(string input)
        {
            while (true)
            {
                int idx = input.IndexOf(Environment.NewLine);

                if (idx < 0)
                {
                    yield return input;
                    break;
                }

                yield return input.Substring(0, idx);
                input = input.Substring(idx + Environment.NewLine.Length);
            }
        }
    }
}
namespace Fixie.Assertions
{
    using System;
    using System.Collections.Generic;

    public class AssertException : Exception
    {
        public static string FilterStackTraceAssemblyPrefix = "Fixie.Assertions.";

        public AssertException(string message)
            : base(message)
        {
        }

        public override string StackTrace => FilterStackTrace(base.StackTrace);

        static string FilterStackTrace(string stackTrace)
        {
            if (stackTrace == null)
                return null;

            var results = new List<string>();

            foreach (var line in Lines(stackTrace))
            {
                var trimmedLine = line.TrimStart();
                if (!trimmedLine.StartsWith("at " + FilterStackTraceAssemblyPrefix))
                    results.Add(line);
            }

            return string.Join(Environment.NewLine, results.ToArray());
        }

        static string[] Lines(string input)
        {
            return input.Split(new[] {Environment.NewLine}, StringSplitOptions.None);
        }
    }
}
Use String.Split(...) instead of recreating it.
Use String.Split(...) instead of recreating it.
