Console.WriteLine() output truncated messages or wrong in a wrong order/incomplete

Console.WriteLine() output truncated messages or wrong in a wrong order/incomplete

Well, I don't know why this is happening, but this looks curious because I didn't find anything similar:

Well, I don't know why this is happening, but this looks curious because I didn't find anything similar:

As you can see inspectioning the full string we can see the entire output, but in console it looks truncated. Is the same as:

Do you notice it? Look on the first 4 lines. And look in the inspector. there are missing some tuple.Item1 and yuple.Item2.

There you can see is a problem on the LINQ select. But I can't figure out this why it's happening.

There you can see the entire code:

    private const string ClassName = "ClassName",
                         InheritedClass = "InheritedClass";

private static void Main(string[] args)
{
    var files = Directory.GetFiles(StaticPath, "*.cs", SearchOption.AllDirectories);

    var classes = files.Select(file => GetClassesInFile(file)).SelectMany(c => c).ToList();

    string fullMsg = string.Join(Environment.NewLine, classes.Select(tuple => $"{tuple.Item1}{(tuple.Item2.HasContent(string.Empty, " ") ? " : " + string.Join(", ", tuple.Item2) + " " : " ")}(on {Path.GetFileName(tuple.Item3)})"));
    Console.WriteLine(fullMsg);

    var unsealedClasses = classes.Where(c => !classes.Any(subClass => subClass.Item2.Contains(c.Item1))).ToList();

    string msg = $"Unsealed classes count: {unsealedClasses.Count} ({string.Join(", ", unsealedClasses.Select(c => c.Item1))})";
    Console.WriteLine(msg);

    Console.Read();
}

private static IEnumerable<Tuple<string, string[], string>> GetClassesInFile(string file)
{
    return Regex.Matches(File.ReadAllText(file), $"(public|internal|private) class (?<{ClassName}>(.+?))( : (?<{InheritedClass}>(.+?))|)\n")
        .Cast<Match>()
        .Select(m => new Tuple<string, string[], string>(GetGroupValue(m, ClassName), GetGroupValue(m, InheritedClass).CleanLineBreak().Split(','), file))
        .Where(t => !string.IsNullOrEmpty(t.Item1));
}

private static string GetGroupValue(Match m, string groupName)
{
    return m.Groups[groupName].Value.ToString();
}

  • GetGroupValue outputs a string from the Regex Group indexer.
  • GetClassesInFile outputs a IEnumerable of Tuple, where Item1 is the class name, Item2 is the classes/interfaces it depends on, and the third Item is the file path of this class.

Note: As you can see I'm also filtering null or empty strings on tuple.Item1.

I don't know what is happening here. But this is so weird and I saw this for first time.

Angular 9 Tutorial: Learn to Build a CRUD Angular App Quickly

What's new in Bootstrap 5 and when Bootstrap 5 release date?

Brave, Chrome, Firefox, Opera or Edge: Which is Better and Faster?

How to Build Progressive Web Apps (PWA) using Angular 9

What is new features in Javascript ES2020 ECMAScript 2020

C/C++ vs. Rust: A developer’s perspective

In this post, you'll see the difference between Rust and C/C++ in a developer’s perspective

Variable Introduction in C#[Bangla]

LIKE | COMMENT | SHARE | SUBSCRIBE A variable is nothing but a name given to a storage area that our programs can manipulate. Each variable in C# has a speci...