IceCream-Sharp 1.1.0

dotnet add package IceCream-Sharp --version 1.1.0                
NuGet\Install-Package IceCream-Sharp -Version 1.1.0                
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="IceCream-Sharp" Version="1.1.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add IceCream-Sharp --version 1.1.0                
#r "nuget: IceCream-Sharp, 1.1.0"                
#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 IceCream-Sharp as a Cake Addin
#addin nuget:?package=IceCream-Sharp&version=1.1.0

// Install IceCream-Sharp as a Cake Tool
#tool nuget:?package=IceCream-Sharp&version=1.1.0                

IceCream# — Never use Console.WriteLine() to debug in .NET again.

NuGet CI License

IceCream# is a C# port of the icecream library for Python.

Do you ever use Console.WriteLine() or Debug.WriteLine() to debug your code? Of course you do. IceCream, or ic for short, makes print debugging a little sweeter.

ic() is like Console.WriteLine(), but better:

  • It prints both expressions/variable names and their values.
  • It's 60% faster to type.
  • Data structures are pretty printed.
  • Output is syntax highlighted.
  • It optionally includes program context: filename, parent class, parent function, and line number.
using static IceCream.IceCream;

ic("Hello, World!");
>>> ic| Program > <Main>$:3 > param_0 = Hello, World!

Installation

Install the IceCream-Sharp NuGet package:

dotnet add package IceCream-Sharp

Usage

using static IceCream.IceCream;

ic("Hello, World!");

Documentation

ic(params object[] objects)

ic() is the main function of IceCream#.

ic("Hello, World!");
>>> ic| Program > <Main>$:3 > param_0 = Hello, World!

All other functions are prefixed with IC_ to prevent name collisions from static importing.

IC_Format(params object[] objects)

IC_Format() formats the given objects for debugging, returning the formatted string.

using static IceCream.IceCream;
string formatted = IC_Format("Hello, World!");
Console.WriteLine(formatted);
>>> ic| Program > <Main>$:2 > param_0 = Hello, World!

IC_SetPrefix(string value)

IC_SetPrefix() sets a custom string prefix for the debugging output (default: ic| ).

using static IceCream.IceCream;
IC_SetPrefix("DEBUG: ");
ic("Hello, World!");
DEBUG: Program > <Main>$:3 > param_0 = Hello, World!

IC_SetPrefix(Func<string> func)

IC_SetPrefix() sets a custom function that returns a string prefix for the debugging output.

using static IceCream.IceCream;
IC_SetPrefix(() => $"[{DateTime.Now}] ");
ic("Hello, World!");
IC_SetPrefix(() => $"{DateTimeOffset.Now.ToUnixTimeSeconds()} |> ");
ic("Hello, World!");
[10/22/2023 12:00:00 AM] Program > <Main>$:3 > param_0 = Hello, World!
1634870400 |> Program > <Main>$:5 > param_0 = Hello, World!

IC_IncludeContext(bool incContext)

IC_IncludeContext() configures whether to include contextual information (like filename, classname, etc.) in the debugging output (default: true).

using static IceCream.IceCream;
IC_IncludeContext(false);
ic("Hello, World!");
>>> ic| param_0 = Hello, World!

IC_Enable() and IC_Disable()

IC_Enable() and IC_Disable() enable and disable the ic() function, respectively. When disabled, ic() will not print to the console.

using static IceCream.IceCream;
ic(1)
IC_Disable()
ic(2)
IC_Enable()
ic(3)
>>> ic| Program > <Main>$:2 > param_0 = 1
>>> ic| Program > <Main>$:6 > param_0 = 3

IC_IncludeFilename(bool flag)

IC_IncludeFilename() configures whether to include the filename in the debugging output (default: false).

using static IceCream.IceCream;
IC_IncludeFilename(true);
ic("Hello, World!");
>>> ic| Program.cs > Program > <Main>$:3 > param_0 = Hello, World!

IC_IncludeClassName(bool flag)

IC_IncludeClassName() configures whether to include the class name in the debugging output (default: true).

using static IceCream.IceCream;
IC_IncludeClassName(false);
ic("Hello, World!");
>>> ic| <Main>$:3 > param_0 = Hello, World!

IC_IncludeAbsolutePath(bool flag)

IC_IncludeAbsolutePath() configures whether to include the absolute path of the file in the debugging output (default: false).

using static IceCream.IceCream;
IC_IncludeAbsolutePath(true);
ic("Hello, World!");
>>> ic| C:\\Absolute\\Path\\To\\Program.cs > Program > <Main>$:3 > param_0 = Hello, World!

IC_IncludeMethodName(bool flag)

IC_IncludeMethodName() configures whether to include the method name in the debugging output (default: true).

using static IceCream.IceCream;
IC_IncludeMethodName(false);
ic("Hello, World!");
>>> ic| Program > 3: param_0 = Hello, World!

IC_IncludeLineNumber(bool flag)

IC_IncludeLineNumber() configures whether to include the line number in the debugging output (default: true).

using static IceCream.IceCream;
IC_IncludeLineNumber(false);
ic("Hello, World!");
>>> ic| Program > <Main>$: param_0 = Hello, World!
Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  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. 
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
1.1.0 281 10/23/2023
1.0.5 118 10/23/2023
1.0.4 124 10/23/2023
1.0.3 123 10/23/2023
1.0.2 122 10/19/2023
1.0.1 119 10/19/2023
1.0.0 123 10/19/2023