The .NET base class libraries leave gaps β methods that obviously belong on a type and are not there, and whole types you end up rewriting in every project. These packages fill both, and Backports lets the same code use modern C# on runtimes that never had it.
The .NET base class libraries are missing things in two different ways: methods that obviously belong on a type and are not there, and whole types you end up writing again in every project. These packages fill both, and the Backports package adds a third β letting code written against modern C# compile and run on runtimes that predate it.
The aim is that reaching for an extension should feel like reaching for the BCL: the method is where you would have looked for it, named what you would have called it, and available on the oldest target you still have to support.
- Extension methods on the BCL types, placed where you would look for them
- The types the BCL lacks, rather than a copy of them per project
- Backports β modern C# language and library features on runtimes that never had them
- Split per assembly surface (Corlib, WinForms, WPF,
System.Drawing, ASP.NET, Win32, DirectoryServices, Office) so a project takes only what it uses - Multi-targeted from .NET Framework through current .NET
dotnet add package FrameworkExtensions.CorlibEvery package is listed in the package table below; take only the ones matching the assemblies your project already references.
using System;
// Methods that should have been on the type in the first place.
"a,b,,c".Split(',').Where(i => !string.IsNullOrEmpty(i)).ForEach(Console.WriteLine);The complete surface of each package is generated into its own REFERENCE.md, linked from the
package's README on nuget.org.
| Package | Description | Version | Downloads |
|---|---|---|---|
| FrameworkExtensions.Backports | Extensions to assure newer compiler features work in older versions. | ||
| FrameworkExtensions.Corlib | Extensions for every type of project. | ||
| FrameworkExtensions.ASP.NET | Extensions to ASP.NET. | ||
| FrameworkExtensions.DirectoryServices | Extensions to DirectoryServices. | ||
| FrameworkExtensions.Microsoft.Office | Extensions to Microsoft Office. | ||
| FrameworkExtensions.Microsoft.Win32 | Extensions to Microsoft.Win32. | ||
| FrameworkExtensions.PresentationCore | Extensions to WPF. | ||
| FrameworkExtensions.System.Drawing | Extensions to System.Drawing. | ||
| FrameworkExtensions.System.Windows.Forms | Extensions to WindowsForms. |
# Restore + build a single package (cross-platform packages build anywhere):
dotnet build Corlib.Extensions/Corlib.Extensions.csproj --configuration Release
# Run the unit tests (Windows; multi-target frameworks):
dotnet test Tests/Corlib.Tests/Corlib.Tests.csproj --configuration ReleaseCI builds the cross-platform packages on Linux and runs the test suite on
Windows across the supported target frameworks β see
CI/CD.
- give credit to Hawkynt when using
- please open pull requests if you add something
- report issues and get in contact via GitHub
See CONTRIBUTING for the contribution rules.
If this project saves you time or money, consider supporting its development:
Licensed under LGPL-3.0-or-later β see LICENSE.