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
<PackageReference Include="FrameworkExtensions.Backports" Version="1.0.0.156" />
<PackageVersion Include="FrameworkExtensions.Backports" Version="1.0.0.156" />
<PackageReference Include="FrameworkExtensions.Backports" />
paket add FrameworkExtensions.Backports --version 1.0.0.156
#r "nuget: FrameworkExtensions.Backports, 1.0.0.156"
#:package FrameworkExtensions.Backports@1.0.0.156
#addin nuget:?package=FrameworkExtensions.Backports&version=1.0.0.156
#tool nuget:?package=FrameworkExtensions.Backports&version=1.0.0.156
FrameworkExtensions.Backports
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
System
- IGrouping<out TKey, TElement>
- IParsable
- ISpanFormattable
- ISpanParsable
System.Collections
System.Collections.Generic
- IReadOnlyDictionary<TKey, TValue>
System.Runtime.CompilerServices
Types
System
- Index
- Lazy<T>
- MathF
- Range
- ReadOnlySpan<T>
- Span<T>
- Tuple<T> (up to 8 types)
- ValueTuple<T> (up to 8 types)
System.Buffers
- ArrayPool<T>
System.Collections.Concurrent
- ConcurrentBag<T>
- ConcurrentDictionary<TKey, TValue>
- ConcurrentQueue<T>
- ConcurrentStack<T>
System.Collections.Generic
- HashSet<T>
- ReadOnlyDictionary<TKey, TValue>
System.Numerics
System.Runtime.CompilerServices
System.Runtime.InteropServices
System.Runtime.Intrinsics
System.Runtime.Intrinsics.Arm
System.Runtime.Intrinsics.X86
System.Threading
Attributes
System.Diagnostics
System.Diagnostics.CodeAnalysis
System.Runtime.CompilerServices
Delegates
Methods
System.Array
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
System.Collections.Generic.KeyValuePair
- void Deconstruct<TKey, TValue>(this KeyValuePair<TKey, TValue> @this, out TKey key, out TValue value)
System.Collections.Generic.Stack
System.DateTimeOffset
- long ToUnixTimeMilliseconds(this DateTimeOffset @this)
- long ToUnixTimeSeconds(this DateTimeOffset @this)
System.Diagnostics
- void Restart(this Stopwatch @this)
System.Enum
- bool HasFlag<T>(this T @this, T flag)
System.IO.DirectoryInfo
- IEnumerable<FileSystemInfo> EnumerateFileSystemInfos(this DirectoryInfo @this)
- IEnumerable<FileInfo> EnumerateFiles(this DirectoryInfo @this)
- IEnumerable<DirectoryInfo> EnumerateDirectories(this DirectoryInfo @this)
- IEnumerable<FileInfo> EnumerateFiles(this DirectoryInfo @this, string searchPattern, SearchOption searchOption)
- IEnumerable<DirectoryInfo> EnumerateDirectories(this DirectoryInfo @this, string searchPattern, SearchOption searchOption)
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
System.Reflection.Assembly
- Attribute GetCustomAttribute(this Assembly element, Type attributeType)
- T GetCustomAttribute<T>(this Assembly element)
- IEnumerable<Attribute> GetCustomAttributes(this Assembly element)
- IEnumerable<Attribute> GetCustomAttributes(this Assembly element, Type attributeType)
- IEnumerable<T> GetCustomAttributes<T>(this Assembly element)
- bool IsDefined(this Assembly element, Type attributeType)
System.Reflection.Module
- Attribute GetCustomAttribute(this Module element, Type attributeType)
- T GetCustomAttribute<T>(this Module element)
- IEnumerable<Attribute> GetCustomAttributes(this Module element)
- IEnumerable<Attribute> GetCustomAttributes(this Module element, Type attributeType)
- IEnumerable<T> GetCustomAttributes<T>(this Module element)
- bool IsDefined(this Module element, Type attributeType)
System.Reflection.MemberInfo
- Attribute GetCustomAttribute(this MemberInfo element, Type attributeType)
- Attribute GetCustomAttribute(this MemberInfo element, Type attributeType, bool inherit)
- T GetCustomAttribute<T>(this MemberInfo element)
- T GetCustomAttribute<T>(this MemberInfo element, bool inherit)
- IEnumerable<Attribute> GetCustomAttributes(this MemberInfo element)
- IEnumerable<Attribute> GetCustomAttributes(this MemberInfo element, bool inherit)
- IEnumerable<Attribute> GetCustomAttributes(this MemberInfo element, Type attributeType)
- IEnumerable<Attribute> GetCustomAttributes(this MemberInfo element, Type attributeType, bool inherit)
- IEnumerable<T> GetCustomAttributes<T>(this MemberInfo element)
- IEnumerable<T> GetCustomAttributes<T>(this MemberInfo element, bool inherit)
- bool IsDefined(this MemberInfo element, Type attributeType)
- bool IsDefined(this MemberInfo element, Type attributeType, bool inherit)
System.Reflection.ParameterInfo
- Attribute GetCustomAttribute(this ParameterInfo element, Type attributeType)
- Attribute GetCustomAttribute(this ParameterInfo element, Type attributeType, bool inherit)
- T GetCustomAttribute<T>(this ParameterInfo element)
- T GetCustomAttribute<T>(this ParameterInfo element, bool inherit)
- IEnumerable<Attribute> GetCustomAttributes(this ParameterInfo element)
- IEnumerable<Attribute> GetCustomAttributes(this ParameterInfo element, bool inherit)
- IEnumerable<Attribute> GetCustomAttributes(this ParameterInfo element, Type attributeType)
- IEnumerable<Attribute> GetCustomAttributes(this ParameterInfo element, Type attributeType, bool inherit)
- IEnumerable<T> GetCustomAttributes<T>(this ParameterInfo element)
- IEnumerable<T> GetCustomAttributes<T>(this ParameterInfo element, bool inherit)
- bool IsDefined(this ParameterInfo element, Type attributeType)
- bool IsDefined(this ParameterInfo element, Type attributeType, bool inherit)
System.Reflection.MethodInfo
- Delegate CreateDelegate(this MethodInfo @this, Type result)
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
- T[] GetSubArray<T>(T[] array, Range range)
- int OffsetToStringData
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:
- Fork the repository.
- Create a new branch with a descriptive name.
- Make your changes.
- 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.
- 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 | Versions 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. |
-
.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 |