Fjeller.Convenience 0.0.1-alpha-7

This is a prerelease version of Fjeller.Convenience.
There is a newer version of this package available.
See the version list below for details.
dotnet add package Fjeller.Convenience --version 0.0.1-alpha-7
                    
NuGet\Install-Package Fjeller.Convenience -Version 0.0.1-alpha-7
                    
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="Fjeller.Convenience" Version="0.0.1-alpha-7" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Fjeller.Convenience" Version="0.0.1-alpha-7" />
                    
Directory.Packages.props
<PackageReference Include="Fjeller.Convenience" />
                    
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 Fjeller.Convenience --version 0.0.1-alpha-7
                    
#r "nuget: Fjeller.Convenience, 0.0.1-alpha-7"
                    
#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 Fjeller.Convenience@0.0.1-alpha-7
                    
#: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=Fjeller.Convenience&version=0.0.1-alpha-7&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Fjeller.Convenience&version=0.0.1-alpha-7&prerelease
                    
Install as a Cake Tool

Fjeller.Convenience

A collection of convenience Methods and classes, mostly Extension methods, that provide some standard functionality for .NET Applications.

Overview

This repository contains a collection of extension methods and other classes for common .NET types, designed to simplify development and improve code readability. The reason to create this package was basically to have some convenience extension methods ready which I had to write everytime in every project.

Currently in alpha. Correct functionality not guaranteed.

The following methods are currently implemented. A more detailed documentation can be found in the github-repository under https://github.com/fjeller/Fjeller.Convenience:

Fjeller.Convenience.Extensions.DictionaryExtensions

Dictionary utility:

  • AddIfNotNull(): Adds a key-value pair to a dictionary only if the value is not null.
  • Get(key, defaultValue): Tries to get the value for a key; returns the provided default if the key is not found or is null.
  • Get(key): Tries to get the value for a key; returns the default value for the value type if the key is not found or is null.

Fjeller.Convenience.Extensions.EnumerableExtensions

IEnumerable sequence helpers:

  • WhereNotNull(): Filters a sequence to only include non-null reference type elements.
  • ForEach(): Executes an action for each element in a sequence.

Fjeller.Convenience.Extensions.GenericObjectExtensions

Null-checking helpers for reference types:

  • IsNotNull(): Returns true if the object is not null.
  • IsNull(): Returns true if the object is null.

Fjeller.Convenience.Extensions.ListExtensions

List utility:

  • AddIfNotNull(): Adds an item to a list only if it is not null.

Fjeller.Convenience.Extensions.NullableExtensions

Nullable value type helpers:

  • HasNoValue(): Returns true if a nullable value type has no value.
  • HasNoValueOrDefault(): Returns true if a nullable value type is unset or equals a specified default value.

Fjeller.Convenience.Extensions.StringExtensions

A comprehensive set of string extension methods for validation, conversion, and manipulation:

  • HasValue(): Checks if a string is not null, empty, or whitespace.
  • IsEmpty(): Checks if a string is null, empty, or whitespace.
  • ToInt32(): Converts a string to an integer, returning a default if conversion fails.
  • ToNullableInt32(): Converts a string to a nullable integer, or returns a default/null if conversion fails.
  • ToInt64(): Converts a string to a long, with a default fallback.
  • ToNullableInt64(): Converts a string to a nullable long, or returns a default/null if conversion fails.
  • ToDouble(): Converts a string to a double, using a specified or invariant culture, with a default fallback.
  • ToNullableDouble(): Converts a string to a nullable double, using a specified or invariant culture, or returns a default/null if conversion fails.
  • ToByte(): Converts a string to a byte, with a default fallback.
  • ToNullableByte(): Converts a string to a nullable byte, or returns a default/null if conversion fails.
  • ToGuid(): Converts a string to a Guid, with a default fallback.
  • ToNullableGuid(): Converts a string to a nullable Guid, or returns null if conversion fails.
  • ToSingle(): Converts a string to a float, using a specified or invariant culture, with a default fallback.
  • ToNullableSingle(): Converts a string to a nullable float, using a specified or invariant culture, or returns a default/null if conversion fails.
  • ToDecimal(): Converts a string to a decimal, using a specified or invariant culture, with a default fallback.
  • ToNullableDecimal(): Converts a string to a nullable decimal, using a specified or invariant culture, or returns a default/null if conversion fails.
  • ToInt16(): Converts a string to a short, with a default fallback.
  • ToNullableInt16(): Converts a string to a nullable short, or returns a default/null if conversion fails.
  • ToUInt16(): Converts a string to an unsigned short, with a default fallback.
  • ToNullableUInt16(): Converts a string to a nullable unsigned short, or returns a default/null if conversion fails.
  • ToUInt32(): Converts a string to an unsigned int, with a default fallback.
  • ToNullableUInt32(): Converts a string to a nullable unsigned int, or returns a default/null if conversion fails.
  • ToUInt64(): Converts a string to an unsigned long, with a default fallback.
  • ToNullableUInt64(): Converts a string to a nullable unsigned long, or returns a default/null if conversion fails.
  • ToSByte(): Converts a string to a signed byte, with a default fallback.
  • ToNullableSByte(): Converts a string to a nullable signed byte, or returns a default/null if conversion fails.
  • ToBoolean(): Converts a string to a boolean, with a default fallback.
  • ToCultureInfo(): Converts a string to a CultureInfo, or returns null if conversion fails.
  • IsUpper(): Checks if all letters in a string are uppercase.
  • IsLower(): Checks if all letters in a string are lowercase.
  • ValueOrDefault(): Returns the string or a fallback if it is null.
  • IsGuid(): Checks if a string is a valid Guid.
  • IsDateTime(): Checks if a string is a valid DateTime.
  • IsCulture(): Checks if a string is a valid culture name.
  • EnsureStartsWith(): Ensures a string starts with a given substring, adding it if missing.
  • EnsureEndsWith(): Ensures a string ends with a given substring, adding it if missing.
  • IsEmail(): Checks if a string matches an email address pattern.
  • IsUrl(): Checks if a string matches a URL pattern.
  • StripEvents(): Removes HTML event attributes (like onclick) from a string.
  • StripTags(): Removes all HTML tags from a string.
  • StripTags(allowedTags): Removes all HTML tags except those specified in an allowed list.
  • StripTags(semicolonSeparatedAllowedTags): Removes all HTML tags except those specified in a semicolon-separated list.

Fjeller.Convenience.SyncAsync.AsyncHelper

Async-to-sync bridging helpers:

  • RunSync<TResult>(): Runs an asynchronous function and returns its result synchronously.
  • RunSync(): Runs an asynchronous function synchronously, waiting for it to complete.

License

This project is licensed under the MIT License.

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 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.
  • net8.0

    • No dependencies.
  • net9.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
1.0.0 69 8/16/2025
0.0.1-alpha-8 56 6/28/2025
0.0.1-alpha-7 92 6/22/2025
0.0.1-alpha-6 60 6/21/2025
0.0.1-alpha-5 74 6/20/2025
0.0.1-alpha-4 68 6/20/2025