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.

c-sharp

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

C. C++. C#. 차이점 알려드림. 5분 순삭. Explain C.C++.C#. Like I'm Five

C. C++. C#. 차이점 알려드림. 5분 순삭. Explain C.C++.C#. Like I'm Five. 아시죠? C는 C++.C# 줄인말이 아니라는거?

Learn how to perform CRUD operations using C Sharp

QuickStart: CRUD Operations in C Sharp. Learn how to perform CRUD operations using C Sharp for MongoDB databases.

Loops in C++ | For, While, and Do While Loops in C++

In this Video We are going to see how to use Loops in C++. We will see How to use For, While, and Do While Loops in C++.

Using isdigit() in C/C++

In this article, we'll take a look at using the isdigit() function in C/C++. This is a very simple way to check if any value is a digit or not. Let's look

C++ Tutorial for Beginners 19 - C++ Structures | Struct declaration | C++ Data Structures

Welcome to this course on C++ Tutorial for Beginners. In this video we will see How to use C++ Structures.