/// <summary>
        /// Writes the diagnostic and the offending code.
        /// </summary>
        /// <returns>A string for use in assert exception.</returns>
        internal string ToString(IReadOnlyList <string> sources)
        {
            if (this.HasPosition)
            {
                var path  = this.HasPath ? this.Span.Path : CodeReader.FileName(sources.Single());
                var match = sources.SingleOrDefault(x => CodeReader.FileName(x) == path);
                var line  = match != null?CodeReader.GetLineWithErrorIndicated(match, this.Span.StartLinePosition) : string.Empty;

                return($"{this.Id} {this.Message}\r\n" +
                       $"  at line {this.Span.StartLinePosition.Line} and character {this.Span.StartLinePosition.Character} in file {path} | {line.TrimStart(' ')}");
            }

            return($"{this.Id} {this.Message}");
        }