NE.Common 1.0.0

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

NE.Common

General-purpose .NET helpers, kept in one place so that every project does not grow its own copy: extension methods over the types the BCL leaves you to convert by hand, an object-graph serializer that survives cycles and polymorphism, asynchronous loggers, and two small collection types.

Targets net10.0. Its only dependency is Microsoft.Extensions.Logging, and only the logging half uses it.

Install

dotnet add package NE.Common

Released to nuget.org.

Extensions

NE.Common.Extensions — the largest part, and the reason the package exists.

StringExtensions TryToInt/ToInt/ToNullableInt and the same trio for every primitive, DateTime, TimeSpan and enums. Parsing a string you did not write, without a try block or an out you do not want.
CollectionExtensions IsNullOrEmpty, WhereNotNull, Groups/Partition, InsertSorted (ascending and descending, with or without a comparer), ForEach, and parallel variants.
DateTimeExtensions Unix seconds and milliseconds both ways, StartOfDay/EndOfDay, month and year boundaries, TrimMilliseconds.
TimeSpanExtensions IsZero, Abs, ToFormat.
EnumExtensions GetName, GetAttribute<T>, GetDescription and GetDescriptionOrName — the [Description] an enum member carries, with its name as the fallback.
TypeExtensions CreateInstance, ResolveType/TryResolveType from a type name.
ReflectionExtensions Read and write a property or a field by name, on an instance or through a Type; enumerate members by the attribute they carry or do not.
SerializationExtensions SerializeGraph/DeserializeGraph over the object-graph serializer, and SerializeJson/DeserializeJson over System.Text.Json.
using NE.Common.Extensions;

int port = configuration["port"].ToInt(8080);          // no parse, no out, no default-by-accident
DateTime? due = row["due"].ToNullableDate("yyyy-MM-dd");

foreach (IReadOnlyList<Order> batch in orders.Partition(100))
    await SendAsync(batch);

string label = status.GetDescriptionOrName();          // the [Description], or the member name

Object-graph serialization

NE.Common.SerializationObjectGraphSerializer writes an arbitrary object graph and reads it back: reference cycles are preserved rather than followed forever, and a member declared as a base type comes back as the derived one it was.

using NE.Common.Extensions;

string data = graph.SerializeGraph();                  // base64 by default
Node? restored = data.DeserializeGraph<Node>();

Node copy = graph.SerializeGraphCopy().DeserializeGraph<Node>()!;   // a deep copy, cycles and all

ObjectGraphSerializerOptions controls what is walked; a graph it cannot represent fails with ObjectGraphSerializationException rather than silently dropping part of itself.

Logging

NE.Common.Logging — loggers that do their formatting and their writing off the calling thread, so a log statement on a hot path costs an enqueue.

builder.Logging.AddAsyncConsoleLogger(LogLevel.Debug);
builder.Logging.AddAsyncFileLogger("logs", LogLevel.Information, retentionDays: 7);

DebugLogger is the one for a test or a scratch program: it writes through System.Diagnostics.Debug and needs no host.

Files

NE.Common.IOFileHelper and DirectoryHelper, with FileCopyOptions/DirectoryCopyOptions for the copy that has to say what it does about overwriting, recursion and filtering.

Types

NE.Common.TypesLimitedStack<T>, which drops its oldest item when it reaches its bound, and WeakDelegate, which holds a handler without keeping its target alive.

Contributing

This repository is a read-only mirror. Development happens in a private repository and everything here is generated from it, so pull requests are switched off here — anything merged would be erased by the next release.

Issues are open and welcome — bugs, questions and feature requests all belong here.

License

MIT. See LICENSE.

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

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 103 8/22/2026