DMNSN.Core 8.0.1

dotnet add package DMNSN.Core --version 8.0.1
                    
NuGet\Install-Package DMNSN.Core -Version 8.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="DMNSN.Core" Version="8.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DMNSN.Core" Version="8.0.1" />
                    
Directory.Packages.props
<PackageReference Include="DMNSN.Core" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add DMNSN.Core --version 8.0.1
                    
#r "nuget: DMNSN.Core, 8.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.
#:package DMNSN.Core@8.0.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=DMNSN.Core&version=8.0.1
                    
Install as a Cake Addin
#tool nuget:?package=DMNSN.Core&version=8.0.1
                    
Install as a Cake Tool

DMNSN.Core

.NET 8 NuGet License

A comprehensive .NET 8 shared library providing essential utilities, extension methods, and configuration helpers for modern .NET applications.

📑 Table of Contents

✨ Features

🛠️ Extension Methods

  • String Conversion: Parse objects to strings with fallback defaults
  • String Manipulation: Trim strings to specific lengths and extract substrings from the end
  • Boolean Parsing: Parse various string representations as boolean values (case-insensitive)
  • Enum Utilities: Extract descriptions and custom attributes from enum values
  • Exception Handling: Enhanced exception message and stack trace extraction with inner exception support

⚙️ Configuration Utilities

  • Configuration Keys: Predefined constants for common configuration sections
  • Configuration Files: Standardized file name constants
  • Logging Settings: Comprehensive logging configuration with console and file output options

📆 Format Definitions

  • Date Formats: Predefined date format patterns
  • Time Formats: Various time representation formats
  • DateTime Formats: Combined date and time format patterns

✅ Test Coverage

  • Comprehensive Unit Tests: 82+ tests covering all functionality
  • Edge Case Testing: Thorough testing of null values, empty strings, and boundary conditions
  • Integration Testing: Tests for method chaining and combined operations

📦 Installation

Package Manager

Install-Package DMNSN.Core

.NET CLI

dotnet add package DMNSN.Core

PackageReference

<PackageReference Include="DMNSN.Core" Version="8.0.0" />

🚀 Quick Start

Add the using statement to access extension methods:

using DMNSN.Core.Extensions;
using DMNSN.Core.Settings;
using DMNSN.Core.Constraints;

Basic Usage

// String conversion with fallback
object value = null;
string result = value.ParseString("default"); // Returns "default"

// Boolean parsing (case-insensitive)
bool isTrue = "YES".ParseBoolean(); // Returns true
bool isFalse = "random".ParseBoolean(); // Returns false

// String manipulation
string text = "Hello World";
string trimmed = text.TrimLength(5); // Returns "Hello"
string lastPart = text.ReverseSubstring(5); // Returns "World"

// Enum descriptions
MyEnum value = MyEnum.SomeValue;
string description = value.Description();

📚 API Reference

Extension Methods

ConvertExtension (String Operations)
ParseString(object, string)

Converts any object to its string representation with a fallback default value.

public static string ParseString(this object ob, string defaultValue = "")

Examples:

int number = 42;
string result = number.ParseString(); // "42"

object nullValue = null;
string fallback = nullValue.ParseString("N/A"); // "N/A"
TrimLength(string, int)

Trims a string to the specified maximum length.

public static string TrimLength(this string s, int maxLength)

Examples:

string longText = "Hello World";
string short = longText.TrimLength(5); // "Hello"
ReverseSubstring(string, int)

Returns a substring containing the specified number of characters from the end.

public static string ReverseSubstring(this string s, int count = 1)

Examples:

string text = "Programming";
string last4 = text.ReverseSubstring(4); // "ming"
string lastChar = text.ReverseSubstring(); // "g"
ConvertExtension (Boolean Operations)
ParseBoolean(string)

Parses various string representations as boolean values (case-insensitive).

public static bool ParseBoolean(this string s)

True Values: "true", "yes", "y", "1" (case-insensitive)
False Values: Everything else, including null, empty, or whitespace

Examples:

"TRUE".ParseBoolean();    // true
"yes".ParseBoolean();     // true
"Y".ParseBoolean();       // true
"1".ParseBoolean();       // true
"false".ParseBoolean();   // false
"no".ParseBoolean();      // false
"anything".ParseBoolean(); // false
EnumExtension
Description(Enum)

Retrieves the description from a DescriptionAttribute applied to an enum value.

public static string? Description(this Enum value)
GetAttribute<TAttribute>(Enum)

Retrieves a custom attribute from an enum field.

public static TAttribute? GetAttribute<TAttribute>(this Enum value) where TAttribute : Attribute
ExceptionExtension
GetMessage(Exception, bool, string)

Retrieves exception messages including inner exceptions.

public static string GetMessage(this Exception ex, bool getInner = true, string inSeparator = " ===>>> Inner Exception ===>>> ")
GetStackTrace(Exception, bool, string)

Retrieves stack traces including

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • No dependencies.

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
8.0.1 105 7/5/2025