Kuchulem.DotNet.ConsoleHelpers 2.0.1

dotnet add package Kuchulem.DotNet.ConsoleHelpers --version 2.0.1
NuGet\Install-Package Kuchulem.DotNet.ConsoleHelpers -Version 2.0.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Kuchulem.DotNet.ConsoleHelpers" Version="2.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Kuchulem.DotNet.ConsoleHelpers --version 2.0.1
#r "nuget: Kuchulem.DotNet.ConsoleHelpers, 2.0.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Kuchulem.DotNet.ConsoleHelpers as a Cake Addin
#addin nuget:?package=Kuchulem.DotNet.ConsoleHelpers&version=2.0.1

// Install Kuchulem.DotNet.ConsoleHelpers as a Cake Tool
#tool nuget:?package=Kuchulem.DotNet.ConsoleHelpers&version=2.0.1

DotNet.ConsoleHelpers

NuGet Version NuGet Preversion

CodeQL

Provides the static class ConsoleExtended witch helps to write easily in the console and extension methods to write clear debug.

How to install

Choose the method you prefere.

Package Manager

Install-Package Kuchulem.DotNet.ConsoleHelpers -Version 2.0.0-beta.1

.Net CLI

dotnet add package Kuchulem.DotNet.ConsoleHelpers --version 2.0.0-beta.1

Package reference

<PackageReference Include="Kuchulem.DotNet.ConsoleHelpers" Version="2.0.0-beta.1" />

Paket CLI

paket add Kuchulem.DotNet.ConsoleHelpers --version 2.0.0-beta.1

Usage

ConsoleExtended

// Write text align to left
ConsoleExtended.WriteLine("Welcome on the demo", ConsoleTextAlignment.Left);
// write a prefixed line with a yellow "Info" prefix :
ConsoleExtended.WritePrefixedLine("Info", "This is a prefixed", prefixColor: ConsoleColor.Yellow);
// Write a new empty line
ConsoleExtended.NewLine();
// Draw a pattern on the console
ConsoleExtended.DrawPattern(
    // first argument is the pattern
    "                       " + Environment.NewLine +
    "  **** **        ****  " + Environment.NewLine +
    "  **   **          **  " + Environment.NewLine +
    "  **   **     **   **  " + Environment.NewLine +
    "  **   **   **     **  " + Environment.NewLine +
    "  **   ** **       **  " + Environment.NewLine +
    "  **   **   **     **  " + Environment.NewLine +
    "  **   **     **   **  " + Environment.NewLine +
    "  **   **          **  " + Environment.NewLine +
    "  **** **        ****  " + Environment.NewLine +
    "                       ",
    // second argument is a dictrionnary that makes
    // a correspondance between a character and a color
    new Dictionary<char, ConsoleColor?>
    {
        { ' ', ConsoleColor.DarkBlue },
        { '*', ConsoleColor.Yellow }
    },
    // Third parameter to align the pattern (here centered)
    ConsoleTextAlignment.Center
);
// Other alignments
ConsoleExtended.WriteLine("Centered text", ConsoleTextAlignment.Center);
ConsoleExtended.WriteLine("Right aligned text", ConsoleTextAlignment.Right);
ConsoleExtended.WriteLine(
    "The alignment" + Environment.NewLine +
    "Can be kept on a multiline" + Environment.NewLine +
    "text",
    ConsoleTextAlignment.Center
); // Use Environment.NewLine for multiline text
// Change background and foregound color of the written line :
ConsoleExtended.WriteLine(
    "Line with cyan backgrounf and magenta foreground", 
    ConsoleTextAlignment.Left,
    ConsoleColor.Cyan, // background color
    ConsoleColor.Magenta // foreground color
); // Note : the folowing line will be back to previous colors

Extension methods

A bunch of extension methodes for the object type have been added

using Kuchulem.DotNet.ConsoleHelpers.Extensions;

namespace ExtensionsDemo
{
    class MyDemoClass
    {
        public void DoSomething()
        {
            // Write a line of debug with info prefix
            this.WriteInfoLine("Some info");
            // Write a simple debug line
            this.WriteDebugLine("Some debug");
            // Write an error line
            this.WriteErrorLine("Some error");
            // Write a warning line
            this.WriteWarningLine("Some warning");
        }
    }
}

In the console you will get :

Info MyDemoClass.DoSomething : Some info
Debug MyDemoClass.DoSomething : Some debug
Error MyDemoClass.DoSomething : Some error
Warn MyDemoClass.DoSomething : Some warning

Note that each prefix will have its own color : info → grey, debug → white, error → red, warning → yellow

Run the demo

The solution includes a demo project : Kuchulem.DotNet.ConsoleHelpers.Demo.

Run this project from your IDE to see the capabilities of the Kuchulem.DotNet.ConsoleHelpers library.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.0.1 337 11/23/2022
2.0.0 274 11/23/2022
2.0.0-beta.2 89 11/23/2022
2.0.0-beta.1 87 11/23/2022
1.1.0-beta.1 98 11/22/2022
1.0.0 576 11/29/2020