ConsoleBase - NKS0003

Use SetTitle() from ConsoleExtensions

This analyzer provides the following strings:

Context
String

Error List

Caller uses Console.Title instead of SetTitle()

Suggestion Box

Use SetTitle() instead of Console.Title

Description

SetTitle() uses the VT sequence to set the title, while Console.Title works in certain conditions.

Extended Description

This code analyzer detects the usage of Title from the standard Console class found in the System namespace. Based on our earlier tests with TMUX and Unix consoles, we've concluded that the VT sequence approach is better than using the normal Console.Title setter.

Analysis Comparison

To get a brief insight about how this analyzer works, compare the two code blocks shown to you below:

Before the fix

Somewhere in your mod code...
public static void MyFunction() =>
    Console.Title = "Hello, world!";

After the fix

Somewhere in your mod code...
public static void MyFunction() =>
    ConsoleMisc.SetTitle("Hello, world!");

Suppression

You can suppress this warning by including it in the appropriate place, whichever is convenient.

For more information about how to suppress any warning issued by the Nitrocid analyzer, visit the below page:

Recommendation

We recommend that every caller which use this property use the recommended abovementioned method.

Last updated