DKNet.Fw.Extensions 9.0.31

dotnet add package DKNet.Fw.Extensions --version 9.0.31
                    
NuGet\Install-Package DKNet.Fw.Extensions -Version 9.0.31
                    
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="DKNet.Fw.Extensions" Version="9.0.31" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DKNet.Fw.Extensions" Version="9.0.31" />
                    
Directory.Packages.props
<PackageReference Include="DKNet.Fw.Extensions" />
                    
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 DKNet.Fw.Extensions --version 9.0.31
                    
#r "nuget: DKNet.Fw.Extensions, 9.0.31"
                    
#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 DKNet.Fw.Extensions@9.0.31
                    
#: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=DKNet.Fw.Extensions&version=9.0.31
                    
Install as a Cake Addin
#tool nuget:?package=DKNet.Fw.Extensions&version=9.0.31
                    
Install as a Cake Tool

DKNet.Fw.Extensions

NuGet NuGet Downloads .NET License

A comprehensive collection of framework-level extensions and utilities for .NET applications. This package provides essential extension methods for common types, encryption utilities, and type manipulation tools to enhance productivity and code readability.

Features

  • String Extensions: Number validation, digit extraction, and type checking utilities
  • DateTime Extensions: Quarter calculations, month operations, and date manipulations
  • Enum Extensions: Display attribute retrieval and enum information extraction
  • Type Extensions: Generic type checking, value type validation, and reflection utilities
  • Async Extensions: IAsyncEnumerable utilities for async data processing
  • Property Extensions: Reflection-based property manipulation and type checking
  • Attribute Extensions: Custom attribute retrieval and metadata operations
  • Encryption Utilities: Built-in encryption and hashing capabilities

Supported Frameworks

  • .NET 9.0+

Installation

Install via NuGet Package Manager:

dotnet add package DKNet.Fw.Extensions

Or via Package Manager Console:

Install-Package DKNet.Fw.Extensions

Quick Start

String Extensions

using DKNet.Fw.Extensions;

// Extract digits from mixed content
string text = "Price: $123.45";
string digits = text.ExtractDigits(); // "123.45"

// Check if string is a valid number
bool isValid = "123.45".IsNumber(); // true

DateTime Extensions

using DKNet.Fw.Extensions;

var date = DateTime.Now;

// Get last day of current month
DateTime lastDay = date.LastDayOfMonth();

// Get quarter information
int quarter = date.Quarter(); // 1, 2, 3, or 4

Enum Extensions

using DKNet.Fw.Extensions;
using System.ComponentModel.DataAnnotations;

public enum Status
{
    [Display(Name = "Active Status")]
    Active,
    
    [Display(Name = "Inactive Status")]
    Inactive
}

var status = Status.Active;
var displayAttr = status.GetAttribute<DisplayAttribute>();
string displayName = displayAttr?.Name ?? status.ToString();

Async Extensions

using System.Collections.Generic;

IAsyncEnumerable<int> asyncNumbers = GetAsyncNumbers();
IList<int> numbers = await asyncNumbers.ToListAsync();

Configuration

This package requires no specific configuration. Simply add the using statements for the namespaces you need:

using DKNet.Fw.Extensions;           // Core extensions
using System.Collections.Generic;   // Async extensions

API Reference

StringExtensions

  • ExtractDigits(string) - Extracts numeric characters from a string
  • IsNumber(string) - Validates if a string represents a valid number
  • IsStringOrValueType(PropertyInfo) - Checks if property can store string or value types

DateTimeExtensions

  • LastDayOfMonth(DateTime) - Returns the last day of the month
  • Quarter(DateTime) - Determines the quarter of the year (1-4)

EnumExtensions

  • GetAttribute<T>(Enum) - Retrieves custom attributes from enum values
  • GetEnumInfo(Enum) - Gets comprehensive enum information including display attributes

TypeExtensions

  • IsStringOrValueType(Type) - Determines if type is string or value type
  • Various generic type checking utilities

AsyncEnumerableExtensions

  • ToListAsync<T>(IAsyncEnumerable<T>) - Converts async enumerable to list

Advanced Usage

Type Checking with Reflection

using DKNet.Fw.Extensions;
using System.Reflection;

public class Example
{
    public string Name { get; set; }
    public int Age { get; set; }
    public DateTime? BirthDate { get; set; }
}

// Check if properties can store simple values
var properties = typeof(Example).GetProperties();
foreach (var prop in properties)
{
    bool canStoreSimpleValue = prop.IsStringOrValueType();
    Console.WriteLine($"{prop.Name}: {canStoreSimpleValue}");
}

Working with Display Attributes

using DKNet.Fw.Extensions;
using System.ComponentModel.DataAnnotations;

public enum Priority
{
    [Display(Name = "Low Priority", Description = "Non-urgent items")]
    Low,
    
    [Display(Name = "High Priority", Description = "Urgent items")]
    High
}

// Get detailed enum information
var priority = Priority.High;
var enumInfo = priority.GetEnumInfo();
// Access enumInfo.DisplayName, enumInfo.Description, etc.

Thread Safety

  • All extension methods are thread-safe as they are stateless
  • Encryption utilities maintain thread safety
  • No shared mutable state across method calls

Performance Considerations

  • String operations use modern .NET patterns and are optimized for performance
  • Reflection-based operations are cached where possible
  • Async operations follow .NET async best practices

Contributing

See the main CONTRIBUTING.md for guidelines on how to contribute to this project.

License

This project is licensed under the MIT License.


Part of the DKNet Framework - A comprehensive .NET framework for building modern, scalable applications.

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  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.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on DKNet.Fw.Extensions:

Package Downloads
DKNet.EfCore.Extensions

Package Description

DKNet.EfCore.Hooks

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
9.0.31 55 9/19/2025
9.0.30 74 9/18/2025
9.0.29 69 9/18/2025
9.0.28 87 9/17/2025
9.0.27 81 9/17/2025
9.0.26 95 9/16/2025
9.0.25 103 9/15/2025
9.0.24 105 9/15/2025
9.0.23 125 9/6/2025
9.0.22 172 9/3/2025
9.0.21 145 9/1/2025
9.0.20 167 7/15/2025
9.0.19 164 7/14/2025
9.0.18 167 7/14/2025
9.0.17 162 7/14/2025
9.0.16 142 7/11/2025
9.0.15 152 7/11/2025
9.0.14 145 7/11/2025
9.0.13 154 7/11/2025
9.0.12 167 7/8/2025
9.0.11 165 7/8/2025
9.0.10 171 7/7/2025
9.0.9 170 7/2/2025
9.0.8 163 7/2/2025
9.0.7 164 7/1/2025
9.0.6 164 6/30/2025
9.0.5 165 6/24/2025
9.0.4 167 6/24/2025
9.0.3 168 6/23/2025
9.0.2 171 6/23/2025
9.0.1 169 6/23/2025