DotNetExtras.Common 1.0.5

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

DotNetExtras.Common

DotNetExtras.Common is a general-purpose .NET Core library that simplifies common operations frequently used in .NET applications.

Use the DotNetExtras.Common library to:

  • Generate fully qualified names for types, variables, and object properties (think of the nameof operator on steroids).
  • Retrieve application assembly information including company, version, and product details.
  • Retrieve error information from exceptions, including immediate and inner exceptions.
  • Serialize objects as JSON strings and deserialize JSON strings into objects with an option to mask or ignore specific properties.
  • Convert collections to comma-separated (or tokenized) string.
  • Compare complex object for equivalence or partial equivalence (by property, key, or element).
  • Deep clone complex objects (including all nested properties).
  • Get and set object values using compound (nested) property names (create property hierarchy if necessary).
  • Access enumeration metadata like descriptions, abbreviations, and custom attributes.
  • Check if objects are empty or determine type characteristics (primitive vs. complex).
  • Escape special characters for LDAP queries and SQL statements.

Usage

The following examples illustrates various operations implemented by the DotNetExtras.Common library.

DotNetExtras.Common namespace

using DotNetExtras.Common;
...
// Print: Some.Type.Property.SubProperty
Console.WriteLine(NameOf.Full(nameof(Some.Type.Property.SubProperty)));

// Print: some.type.property.subProperty
Console.WriteLine(NameOf.Full(nameof(Some.Type.Property.SubProperty), true));

// Print: Property.SubProperty
Console.WriteLine(NameOf.Long(someObject.Property.Subproperty)));

// Print: property.subProperty
Console.WriteLine(NameOf.Long(someObject.Property.Subproperty), true));

// Print: SubProperty
Console.WriteLine(NameOf.Short(someObject.Property.Subproperty)));

// Print: subProperty
Console.WriteLine(NameOf.Short(someObject.Property.Subproperty), true));

// Print the version and the copyright message such as: MyApp v1.0.8 � 2023 MyCompany
Console.WriteLine($"{PrimaryAssembly.Title} v{PrimaryAssembly.Version} {PrimaryAssembly.Copyright}");

DotNetExtras.Common.Exceptions namespace

using DotNetExtras.Common.Exceptions;
...
// Print exception messages from the immediate and all inner exceptions.
Console.WriteLine(ex.GetMessages());

DotNetExtras.Common.Extensions namespace

using DotNetExtras.Common.Extensions;
...
// Print received tags as a comma-separated string.
List<string> tags = GetTags();
Console.WriteLine($"Got tags: {tags.ToCsv()}.");

// Set a nested property value using a compound property name.
user.SetPropertyValue("Name.Surname", "Johnson");

// Get a nested property value using a compound property name.
string surname = user.GetPropertyValue<string>("Name.Surname");

// Compare two objects for equivalence.
bool equivalent = userA.IsEquivalentTo(userB));

// Compare two arrays for partial equivalence.
bool partiallyEquivalent = arrayA.IsPartiallyEquivalentTo(arrayB, 3));

DotNetExtras.Common.Json namespace

using DotNetExtras.Common.Json;
...

// Serialize an object to a JSON string.
string json = myObject.ToJson();

// Convert a JSON string to an object.
MyObjectType? myObject = json.FromJson();

Documentation

For complete documentation, usage details, and code samples, see:

Package

Install the latest version of the DotNetExtras.Common NuGet package from:

See also

Check out other DotNetExtras libraries at:

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 (4)

Showing the top 4 NuGet packages that depend on DotNetExtras.Common:

Package Downloads
DotNetExtras.Extended

A .NET Core library implementing less frequently used general-purpose operations.

DotNetExtras.OData

A .NET Core library implementing OData filter parsing and validation functions.

DotNetExtras.Mail

A .NET Core library implementing mail template functionality based on the Razor syntax.

DotNetExtras.Testing

A .NET Core library implementing helper functions for unit testing and validation based on xUnit.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.5 188 8/28/2025
1.0.2 145 8/25/2025
1.0.0 147 8/11/2025

Breaking change. Refactored some code. Changed and moved around classes. Moved classes from the extended namespace to a separate library.