FrameworkExtensions.Backports 1.0.0.156

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

FrameworkExtensions.Backports

Build Tests

Last Commit NuGet Version License

Overview

FrameworkExtensions.Backports is a NuGet package that provides a collection of extensions (Polyfills) to ensure that newer compiler features work in older versions of the .NET Framework/Standard/Core. This package allows developers to use modern C# language features and .NET APIs even when working on projects targeting earlier versions down to Net2.0.

Note: Performance is not a primary concern here. This focuses mainly on functionality and ready-to-be-built without making adjustments to code.

Features

Interfaces

Types

Attributes

Delegates

  • System
    • Func<T> (up to 16 types)
    • Action<T> (up to 16 types)

Methods

  • System.Array

    • Span<T> AsSpan<T>(this T[] @this)
    • Span<T> AsSpan<T>(this T[] @this, int start)
    • Span<T> AsSpan<T>(this T[] @this, int start, int length)
    • Span<T> AsSpan<T>(this T[] @this, Index startIndex)
    • Span<T> AsSpan<T>(this T[] @this, Range range)
  • System.ReadOnlySpan

    • bool SequenceEqual<T>(this Span<T> span, ReadOnlySpan<T> other)
    • bool SequenceEqual<T>(this ReadOnlySpan<T> span, ReadOnlySpan<T> other)
    • bool SequenceEqual<T>(this ReadOnlySpan<T> span, ReadOnlySpan<T> other, IEqualityComparer<T> comparer)
    • int IndexOf<T>(this ReadOnlySpan<T> span, T value)
    • int IndexOf<T>(this ReadOnlySpan<T> span, ReadOnlySpan<T> value)
    • int IndexOf(this ReadOnlySpan<char> span, ReadOnlySpan<char> value, StringComparison comparisonType)
    • int LastIndexOf<T>(this ReadOnlySpan<T> span, T value)
    • int LastIndexOf<T>(this ReadOnlySpan<T> span, ReadOnlySpan<T> value)
    • int LastIndexOf(this ReadOnlySpan<char> span, ReadOnlySpan<char> value, StringComparison comparisonType)
    • bool StartsWith(this ReadOnlySpan<char> span, ReadOnlySpan<char> value, StringComparison comparisonType)
    • bool StartsWith<T>(this ReadOnlySpan<T> span, ReadOnlySpan<T> value)
    • bool StartsWith<T>(this Span<T> span, ReadOnlySpan<T> value)
  • System.Collections.Concurrent.ConcurrentBag

    • void Clear<T>(this ConcurrentBag<T>)
  • System.Collections.Concurrent.ConcurrentDictionary

    • TValue AddOrUpdate<TKey, TValue, TArg>(this ConcurrentDictionary<TKey, TValue> @this, TKey key, Func<TKey, TArg, TValue> addValueFactory, Func<TKey, TValue, TArg, TValue> updateValueFactory, TArg factoryArgument)
  • System.Collections.Concurrent.ConcurrentQueue

    • void Clear<T>(this ConcurrentQueue<T>)
  • System.Collections.Concurrent.ConcurrentStack

    • void Clear<T>(this ConcurrentStack<T>)
  • System.Collections.Generic.IEnumerable

    • HashSet<TItem> ToHashSet<TItem>(this IEnumerable<TItem> @this)
    • HashSet<TItem> ToHashSet<TItem>(this IEnumerable<TItem> @this, IEqualityComparer<TItem> comparer)
  • System.Collections.Generic.KeyValuePair

    • void Deconstruct<TKey, TValue>(this KeyValuePair<TKey, TValue> @this, out TKey key, out TValue value)
  • System.Collections.Generic.Stack

    • bool TryPop<TItem>(this Stack<TItem> @this, out TItem result)
    • bool TryPeek<TItem>(this Stack<TItem> @this, out TItem result)
  • System.DateTimeOffset

  • System.Diagnostics

    • void Restart(this Stopwatch @this)
  • System.Enum

    • bool HasFlag<T>(this T @this, T flag)
  • System.IO.DirectoryInfo

  • System.IO.FileInfo

    • void MoveTo(this FileInfo @this, string destFileName, bool overwrite)
  • System.IO.Stream

    • void CopyTo(this Stream @this, Stream target)
    • void Flush(this Stream @this, bool flushToDisk)
    • Task<int> ReadAsync(this Stream @this, byte[] buffer, int offset, int count)
    • Task<int> ReadAsync(this Stream @this, byte[] buffer, int offset, int count, CancellationToken cancellationToken)
    • Task WriteAsync(this Stream @this, byte[] buffer, int offset, int count)
    • Task WriteAsync(this Stream @this, byte[] buffer, int offset, int count, CancellationToken cancellationToken)
    • Task CopyToAsync(this Stream @this, Stream destination, int bufferSize, CancellationToken cancellationToken)
    • int Read(this Stream @this, Span<byte> buffer)
    • void Write(this Stream @this, ReadOnlySpan<byte> buffer)
  • System.Linq

    • TResult[] ToArray<TResult>(this IEnumerable<TResult> @this)
    • IEnumerable<TResult> Cast<TResult>(this IEnumerable @this)
    • IEnumerable<TSource> Where<TSource>(this IEnumerable<TSource> @this, Func<TSource, bool> predicate)
    • IEnumerable<TSource> Where<TSource>(this IEnumerable<TSource> @this, Func<TSource, int, bool> predicate)
    • IEnumerable<TResult> Select<TSource, TResult>(this IEnumerable<TSource> @this, Func<TSource, TResult> selector)
    • IEnumerable<TResult> Select<TSource, TResult>(this IEnumerable<TSource> @this, Func<TSource, int, TResult> selector)
    • IEnumerable<TSource> OrderBy<TSource, TKey>(this IEnumerable<TSource> @this, Func<TSource, TKey> keySelector)
    • IEnumerable<TSource> OrderBy<TSource, TKey>(this IEnumerable<TSource> @this, Func<TSource, TKey> keySelector, IComparer<TKey> comparer)
    • IEnumerable<TSource> ThenBy<TSource, TKey>(this IEnumerable<TSource> @this, Func<TSource, TKey> keySelector)
    • IEnumerable<TSource> ThenBy<TSource, TKey>(this IEnumerable<TSource> @this, Func<TSource, TKey> keySelector, IComparer<TKey> comparer)
    • TSource First<TSource>(this IEnumerable<TSource> @this)
    • TSource First<TSource>(this IEnumerable<TSource> @this, Func<TSource, bool> predicate)
    • TSource FirstOrDefault<TSource>(this IEnumerable<TSource> @this)
    • TSource FirstOrDefault<TSource>(this IEnumerable<TSource> @this, TSource defaultValue)
    • TSource FirstOrDefault<TSource>(this IEnumerable<TSource> @this, Func<TSource, bool> predicate)
    • TSource FirstOrDefault<TSource>(this IEnumerable<TSource> @this, Func<TSource, bool> predicate, TSource defaultValue)
    • TSource Single<TSource>(this IEnumerable<TSource> @this)
    • TSource Single<TSource>(this IEnumerable<TSource> @this, Func<TSource, bool> predicate)
    • TSource SingleOrDefault<TSource>(this IEnumerable<TSource> @this)
    • TSource SingleOrDefault<TSource>(this IEnumerable<TSource> @this, TSource defaultValue)
    • TSource SingleOrDefault<TSource>(this IEnumerable<TSource> @this, Func<TSource, bool> predicate, TSource defaultValue)
    • TSource SingleOrDefault<TSource>(this IEnumerable<TSource> @this, Func<TSource, bool> predicate)
    • TSource Last<TSource>(this IEnumerable<TSource> @this)
    • TSource Last<TSource>(this IEnumerable<TSource> @this, Func<TSource, bool> predicate)
    • TSource LastOrDefault<TSource>(this IEnumerable<TSource> @this)
    • TSource LastOrDefault<TSource>(this IEnumerable<TSource> @this, TSource defaultValue)
    • TSource LastOrDefault<TSource>(this IEnumerable<TSource> @this, Func<TSource, bool> predicate)
    • TSource LastOrDefault<TSource>(this IEnumerable<TSource> @this, Func<TSource, bool> predicate, TSource defaultValue)
    • TSource Min<TSource>(this IEnumerable<TSource> source)
    • TItem MinBy<TItem, TKey>(this IEnumerable<TItem> @this, Func<TItem, TKey> keySelector)
    • TItem MinBy<TItem, TKey>(this IEnumerable<TItem> @this, Func<TItem, TKey> keySelector, IComparer<TKey> comparer)
    • TSource Max<TSource>(this IEnumerable<TSource> source)
    • TItem MaxBy<TItem, TKey>(this IEnumerable<TItem> @this, Func<TItem, TKey> keySelector)
    • TItem MaxBy<TItem, TKey>(this IEnumerable<TItem> @this, Func<TItem, TKey> keySelector, IComparer<TKey> comparer)
    • IEnumerable<IGrouping<TKey, TSource>> GroupBy<TSource, TKey>(IEnumerable<TSource> source, Func<TSource, TKey> keySelector)
    • IEnumerable<TItem> Prepend<TItem>(this IEnumerable<TItem> @this, TItem item)
    • IEnumerable<TItem> Append<TItem>(this IEnumerable<TItem> @this, TItem item)
    • bool TryGetNonEnumeratedCount<TItem>(this IEnumerable<TItem> source, out int count)
    • IEnumerable<TItem> Zip<TFirst, TSecond, TResult>(IEnumerable<TFirst> @this, IEnumerable<TSecond> second, Func<TFirst, TSecond, TResult> resultSelector)
  • System.Random

    • long NextInt64(this Random @this)
    • long NextInt64(this Random @this, long maxValue)
    • long NextInt64(this Random @this, long minValue, long maxValue)
  • System.Reflection.Assembly

  • System.Reflection.Module

  • System.Reflection.MemberInfo

  • System.Reflection.ParameterInfo

  • System.Reflection.MethodInfo

  • System.String

    • bool Contains(this string @this, string value, StringComparison comparisonType)
    • bool Contains(this string @this, char value)
    • bool Contains(this string @this, char value, StringComparison comparisonType)
    • string[] Split(this string @this, char separator, StringSplitOptions options = StringSplitOptions.None)
    • string[] Split(this string @this, char separator, int count, StringSplitOptions options = StringSplitOptions.None)
    • string[] Split(this string @this, string separator, StringSplitOptions options = StringSplitOptions.None)
    • string[] Split(this string @this, string separator, int count, StringSplitOptions options = StringSplitOptions.None)
    • int IndexOf(this string @this, char value, StringComparison comparisonType)
    • ReadOnlySpan<char> AsSpan(this string @this)
    • ReadOnlySpan<char> AsSpan(this string @this, int start)
    • ReadOnlySpan<char> AsSpan(this string @this, int start, int length)
    • ReadOnlySpan<char> AsSpan(this string @this, Index startIndex)
    • ReadOnlySpan<char> AsSpan(this string @this, Range range)
  • System.RuntimeServices.CompilerServices.RuntimeHelpers

  • System.Text.StringBuilder

    • void Clear(this StringBuilder @this)
  • System.Threading.Tasks

    • TaskAwaiter GetAwaiter(this Task task)
    • TaskAwaiter<TResult> GetAwaiter<TResult>(this Task<TResult> task)
    • ConfiguredTaskAwaitable ConfigureAwait(this Task task, bool continueOnCapturedContext)
    • ConfiguredTaskAwaitable<TResult> ConfigureAwait<TResult>(this Task<TResult> task, bool continueOnCapturedContext)
  • System.Threading.WaitHandle

    • void Dispose(this WaitHandle @this)

Installation

You can install the FrameworkExtensions.Backports package via NuGet Package Manager or the .NET CLI:

NuGet Package Manager

Install-Package FrameworkExtensions.Backports

.NET CLI

dotnet add package FrameworkExtensions.Backports

Usage

Below are some examples of how to use the features provided by this package. Note that the namespaces are kept original, so no additional using directives are needed.

Range and Index

public class Program
{
    public static void Main()
    {
        int[] numbers = { 1, 2, 3, 4, 5 };
        var slice = numbers[1..^1];
        Console.WriteLine(string.Join(", ", slice)); // Output: 2, 3, 4
    }
}

Lazy Initialization

public class Program
{
    private static Lazy<int> lazyValue = new Lazy<int>(() => ComputeValue());

    public static void Main()
    {
        Console.WriteLine(lazyValue.Value); // Output: Computed Value
    }

    private static int ComputeValue()
    {
        Console.WriteLine("Computed Value");
        return 42;
    }
}

LINQ Methods

using System.Collections.Generic;
using System.Linq;

public class Program
{
    public static void Main()
    {
        List<int> numbers = new List<int> { 1, 2, 3, 4, 5 };

        var max = numbers.Max();
        var minBy = numbers.MinBy(n => n);

        Console.WriteLine($"Max: {max}");    // Output: Max: 5
        Console.WriteLine($"MinBy: {minBy}");// Output: MinBy: 1
    }
}

Task Extensions

using System.Threading.Tasks;

public class Program
{
    public static async Task Main()
    {
        Task task = Task.Delay(1000);
        await task.ConfigureAwait(false);
        Console.WriteLine("Task completed");
    }
}

Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository.
  2. Create a new branch with a descriptive name.
  3. Make your changes.
  4. Remember: Everything public in here should polyfill existing Microsoft functionality and thus should be mentioned in the Readme with a link to its original documentation.
  5. Submit a pull request.

License

This project is licensed under the LGPL-3.0-or-later License. See the LICENSE file for details.

Acknowledgments

We appreciate the contributions of the .NET community in making this package possible.

Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 is compatible. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 is compatible. 
.NET Framework net20 is compatible.  net35 is compatible.  net40 is compatible.  net403 was computed.  net45 is compatible.  net451 was computed.  net452 was computed.  net46 was computed.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 is compatible.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETCoreApp 3.1

    • No dependencies.
  • .NETFramework 2.0

    • No dependencies.
  • .NETFramework 3.5

    • No dependencies.
  • .NETFramework 4.0

    • No dependencies.
  • .NETFramework 4.5

    • No dependencies.
  • .NETFramework 4.8

    • No dependencies.
  • .NETStandard 2.0

    • No dependencies.
  • .NETStandard 2.1

    • No dependencies.
  • net5.0

    • No dependencies.
  • net6.0

    • No dependencies.
  • net7.0

    • No dependencies.
  • net8.0

    • No dependencies.
  • net9.0

    • No dependencies.

NuGet packages (5)

Showing the top 5 NuGet packages that depend on FrameworkExtensions.Backports:

Package Downloads
FrameworkExtensions.Corlib

Extensions to the Corlib.

FrameworkExtensions.PresentationCore

Extensions to WPF.

FrameworkExtensions.System.Windows.Forms

Extensions to WindowsForms.

FrameworkExtensions.System.Drawing

Extensions to System.Drawing

FrameworkExtensions.DirectoryServices

Extensions to DirectoryServices.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0.156 43 8/4/2025
1.0.0.147 281 7/21/2025
1.0.0.142 247 7/7/2025
1.0.0.137 164 6/23/2025
1.0.0.134 153 6/16/2025
1.0.0.132 153 5/26/2025
1.0.0.130 179 5/19/2025
1.0.0.114 174 5/5/2025
1.0.0.110 194 4/28/2025
1.0.0.103 195 4/21/2025
1.0.0.99 201 4/14/2025
1.0.0.97 192 4/7/2025
1.0.0.95 373 3/24/2025
1.0.0.94 245 3/10/2025
1.0.0.89 259 3/3/2025
1.0.0.87 159 2/24/2025
1.0.0.86 244 12/30/2024
1.0.0.84 283 12/2/2024
1.0.0.83 197 11/4/2024
1.0.0.82 2,157 6/24/2024
1.0.0.78 346 6/17/2024
1.0.0.73 302 6/10/2024
1.0.0.70 213 6/3/2024
1.0.0.56 311 5/27/2024
1.0.0.51 419 5/6/2024
1.0.0.48 293 4/29/2024
1.0.0.45 207 4/22/2024
1.0.0.37 257 4/1/2024
1.0.0.36 215 3/25/2024
1.0.0.34 265 3/18/2024
1.0.0.33 196 3/11/2024
1.0.0.32 432 3/5/2024
1.0.0.31 338 8/14/2023
1.0.0.29 208 7/21/2023
1.0.0.28 377 7/19/2023
1.0.0.27 238 7/19/2023
1.0.0.26 243 7/19/2023
1.0.0.25 1,523 7/19/2023