Meziantou.Polyfill 1.0.41

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package Meziantou.Polyfill --version 1.0.41                
NuGet\Install-Package Meziantou.Polyfill -Version 1.0.41                
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="Meziantou.Polyfill" Version="1.0.41">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Meziantou.Polyfill --version 1.0.41                
#r "nuget: Meziantou.Polyfill, 1.0.41"                
#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.
// Install Meziantou.Polyfill as a Cake Addin
#addin nuget:?package=Meziantou.Polyfill&version=1.0.41

// Install Meziantou.Polyfill as a Cake Tool
#tool nuget:?package=Meziantou.Polyfill&version=1.0.41                

Meziantou.Polyfill

NuGet

Source Generator that adds polyfill methods and types. This helps working with multi-targeted projects.

Read more about the project: Polyfills in .NET to ease multi-targeting

Installation

dotnet add package Meziantou.Polyfill

Then, you should see the generated types in the solution explorer

Generated files in the Visual Studio's Solution Explorer

Customization

By default, all needed polyfills are generated. You can configure which polyfills should be generated by editing the .csproj file and adding the following properties:

<PropertyGroup>
  
  
  <MeziantouPolyfill_IncludedPolyfills>T:Type1|T:Type2|M:Member1</MeziantouPolyfill_IncludedPolyfills>
  <MeziantouPolyfill_ExcludedPolyfills>M:System.Diagnostics.</MeziantouPolyfill_ExcludedPolyfills>

  
  <EmitCompilerGeneratedFiles>True</EmitCompilerGeneratedFiles>
  <CompilerGeneratedFilesOutputPath>$(BaseIntermediateOutputPath)\GeneratedFiles</CompilerGeneratedFilesOutputPath>
</PropertyGroup>

Supported polyfills

Types

  • System.Collections.Generic.PriorityQueue<TElement, TPriority>
  • System.Collections.Generic.ReferenceEqualityComparer
  • System.Diagnostics.CodeAnalysis.AllowNullAttribute
  • System.Diagnostics.CodeAnalysis.DisallowNullAttribute
  • System.Diagnostics.CodeAnalysis.DoesNotReturnAttribute
  • System.Diagnostics.CodeAnalysis.DoesNotReturnIfAttribute
  • System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute
  • System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes
  • System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute
  • System.Diagnostics.CodeAnalysis.ExperimentalAttribute
  • System.Diagnostics.CodeAnalysis.MaybeNullAttribute
  • System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute
  • System.Diagnostics.CodeAnalysis.MemberNotNullAttribute
  • System.Diagnostics.CodeAnalysis.MemberNotNullWhenAttribute
  • System.Diagnostics.CodeAnalysis.NotNullAttribute
  • System.Diagnostics.CodeAnalysis.NotNullIfNotNullAttribute
  • System.Diagnostics.CodeAnalysis.NotNullWhenAttribute
  • System.Diagnostics.CodeAnalysis.RequiresAssemblyFilesAttribute
  • System.Diagnostics.CodeAnalysis.RequiresDynamicCodeAttribute
  • System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute
  • System.Diagnostics.CodeAnalysis.SetsRequiredMembersAttribute
  • System.Diagnostics.CodeAnalysis.StringSyntaxAttribute
  • System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute
  • System.Diagnostics.CodeAnalysis.UnscopedRefAttribute
  • System.Diagnostics.StackTraceHiddenAttribute
  • System.HashCode
  • System.Index
  • System.Net.Http.ReadOnlyMemoryContent
  • System.Range
  • System.Runtime.CompilerServices.AsyncMethodBuilderAttribute
  • System.Runtime.CompilerServices.CallerArgumentExpressionAttribute
  • System.Runtime.CompilerServices.CollectionBuilderAttribute
  • System.Runtime.CompilerServices.CompilerFeatureRequiredAttribute
  • System.Runtime.CompilerServices.DisableRuntimeMarshallingAttribute
  • System.Runtime.CompilerServices.InterpolatedStringHandlerArgumentAttribute
  • System.Runtime.CompilerServices.InterpolatedStringHandlerAttribute
  • System.Runtime.CompilerServices.IsExternalInit
  • System.Runtime.CompilerServices.ModuleInitializerAttribute
  • System.Runtime.CompilerServices.OverloadResolutionPriorityAttribute
  • System.Runtime.CompilerServices.RequiredMemberAttribute
  • System.Runtime.CompilerServices.SkipLocalsInitAttribute
  • System.Runtime.CompilerServices.TupleElementNamesAttribute
  • System.Runtime.InteropServices.SuppressGCTransitionAttribute
  • System.Runtime.InteropServices.UnmanagedCallersOnlyAttribute
  • System.Runtime.Versioning.ObsoletedOSPlatformAttribute
  • System.Runtime.Versioning.RequiresPreviewFeaturesAttribute
  • System.Runtime.Versioning.SupportedOSPlatformAttribute
  • System.Runtime.Versioning.SupportedOSPlatformGuardAttribute
  • System.Runtime.Versioning.TargetPlatformAttribute
  • System.Runtime.Versioning.UnsupportedOSPlatformAttribute
  • System.Runtime.Versioning.UnsupportedOSPlatformGuardAttribute
  • System.Threading.Lock
  • System.Threading.Tasks.TaskToAsyncResult
  • System.ValueTuple
  • System.ValueTuple<T1>
  • System.ValueTuple<T1, T2>
  • System.ValueTuple<T1, T2, T3>
  • System.ValueTuple<T1, T2, T3, T4>
  • System.ValueTuple<T1, T2, T3, T4, T5>
  • System.ValueTuple<T1, T2, T3, T4, T5, T6>
  • System.ValueTuple<T1, T2, T3, T4, T5, T6, T7>
  • System.ValueTuple<T1, T2, T3, T4, T5, T6, T7, TRest> where TRest : struct
  • System.ITupleInternal

Methods

  • System.Collections.Concurrent.ConcurrentDictionary<TKey, TValue>.GetOrAdd<TArg>(TKey key, System.Func<TKey, TArg, TValue> valueFactory, TArg factoryArgument) where TArg : allows ref struct
  • System.Collections.Generic.CollectionExtensions.GetValueOrDefault<TKey, TValue>(this System.Collections.Generic.IReadOnlyDictionary<TKey, TValue> dictionary, TKey key)
  • System.Collections.Generic.CollectionExtensions.GetValueOrDefault<TKey, TValue>(this System.Collections.Generic.IReadOnlyDictionary<TKey, TValue> dictionary, TKey key, TValue defaultValue)
  • System.Collections.Generic.KeyValuePair<TKey, TValue>.Deconstruct(out TKey key, out TValue value)
  • System.Collections.Generic.Queue<T>.TryDequeue(out T result)
  • System.Collections.Immutable.ImmutableArray<T>.AsSpan(System.Int32 start, System.Int32 length)
  • System.Collections.Immutable.ImmutableArray<T>.AsSpan(System.Range range)
  • System.Diagnostics.Process.WaitForExitAsync([System.Threading.CancellationToken cancellationToken = default])
  • System.IO.Stream.Read(System.Span<System.Byte> buffer)
  • System.IO.Stream.ReadAsync(System.Memory<System.Byte> buffer, [System.Threading.CancellationToken cancellationToken = default])
  • System.IO.Stream.ReadAtLeast(System.Span<System.Byte> buffer, System.Int32 minimumBytes, [System.Boolean throwOnEndOfStream = true])
  • System.IO.Stream.ReadAtLeastAsync(System.Memory<System.Byte> buffer, System.Int32 minimumBytes, [System.Boolean throwOnEndOfStream = true], [System.Threading.CancellationToken cancellationToken = default])
  • System.IO.Stream.Write(System.ReadOnlySpan<System.Byte> buffer)
  • System.IO.Stream.WriteAsync(System.ReadOnlyMemory<System.Byte> buffer, [System.Threading.CancellationToken cancellationToken = default])
  • System.IO.StreamReader.ReadLineAsync()
  • System.IO.StreamReader.ReadLineAsync(System.Threading.CancellationToken cancellationToken)
  • System.IO.TextReader.ReadAsync(System.Memory<System.Char> buffer, [System.Threading.CancellationToken cancellationToken = default])
  • System.IO.TextReader.ReadToEndAsync(System.Threading.CancellationToken cancellationToken)
  • System.IO.TextWriter.WriteAsync(System.ReadOnlyMemory<System.Char> buffer, [System.Threading.CancellationToken cancellationToken = default])
  • System.Linq.Enumerable.AggregateBy<TSource, TKey, TAccumulate>(this System.Collections.Generic.IEnumerable<TSource> source, System.Func<TSource, TKey> keySelector, System.Func<TKey, TAccumulate> seedSelector, System.Func<TAccumulate, TSource, TAccumulate> func, [System.Collections.Generic.IEqualityComparer<TKey>? keyComparer = null]) where TKey : notnull
  • System.Linq.Enumerable.AggregateBy<TSource, TKey, TAccumulate>(this System.Collections.Generic.IEnumerable<TSource> source, System.Func<TSource, TKey> keySelector, TAccumulate seed, System.Func<TAccumulate, TSource, TAccumulate> func, [System.Collections.Generic.IEqualityComparer<TKey>? keyComparer = null]) where TKey : notnull
  • System.Linq.Enumerable.CountBy<TSource, TKey>(this System.Collections.Generic.IEnumerable<TSource> source, System.Func<TSource, TKey> keySelector, [System.Collections.Generic.IEqualityComparer<TKey>? keyComparer = null]) where TKey : notnull
  • System.Linq.Enumerable.DistinctBy<TSource, TKey>(this System.Collections.Generic.IEnumerable<TSource> source, System.Func<TSource, TKey> keySelector)
  • System.Linq.Enumerable.DistinctBy<TSource, TKey>(this System.Collections.Generic.IEnumerable<TSource> source, System.Func<TSource, TKey> keySelector, System.Collections.Generic.IEqualityComparer<TKey>? comparer)
  • System.Linq.Enumerable.Index<TSource>(this System.Collections.Generic.IEnumerable<TSource> source)
  • System.Linq.Enumerable.MaxBy<TSource, TKey>(this System.Collections.Generic.IEnumerable<TSource> source, System.Func<TSource, TKey> keySelector)
  • System.Linq.Enumerable.MaxBy<TSource, TKey>(this System.Collections.Generic.IEnumerable<TSource> source, System.Func<TSource, TKey> keySelector, System.Collections.Generic.IComparer<TKey>? comparer)
  • System.Linq.Enumerable.MinBy<TSource, TKey>(this System.Collections.Generic.IEnumerable<TSource> source, System.Func<TSource, TKey> keySelector)
  • System.Linq.Enumerable.MinBy<TSource, TKey>(this System.Collections.Generic.IEnumerable<TSource> source, System.Func<TSource, TKey> keySelector, System.Collections.Generic.IComparer<TKey>? comparer)
  • System.Linq.Enumerable.OrderDescending<T>(this System.Collections.Generic.IEnumerable<T> source)
  • System.Linq.Enumerable.OrderDescending<T>(this System.Collections.Generic.IEnumerable<T> source, System.Collections.Generic.IComparer<T>? comparer)
  • System.Linq.Enumerable.Order<T>(this System.Collections.Generic.IEnumerable<T> source)
  • System.Linq.Enumerable.Order<T>(this System.Collections.Generic.IEnumerable<T> source, System.Collections.Generic.IComparer<T>? comparer)
  • System.Linq.Enumerable.ToHashSet<TSource>(this System.Collections.Generic.IEnumerable<TSource> source)
  • System.Linq.Enumerable.ToHashSet<TSource>(this System.Collections.Generic.IEnumerable<TSource> source, System.Collections.Generic.IEqualityComparer<TSource>? comparer)
  • System.Linq.Enumerable.Zip<TFirst, TSecond>(this System.Collections.Generic.IEnumerable<TFirst> first, System.Collections.Generic.IEnumerable<TSecond> second)
  • System.MemoryExtensions.AsSpan(this System.String? text, System.Int32 start, System.Int32 length)
  • System.MemoryExtensions.CommonPrefixLength<T>(this System.ReadOnlySpan<T> span, System.ReadOnlySpan<T> other)
  • System.MemoryExtensions.CommonPrefixLength<T>(this System.ReadOnlySpan<T> span, System.ReadOnlySpan<T> other, System.Collections.Generic.IEqualityComparer<T>? comparer)
  • System.MemoryExtensions.CommonPrefixLength<T>(this System.Span<T> span, System.ReadOnlySpan<T> other)
  • System.MemoryExtensions.CommonPrefixLength<T>(this System.Span<T> span, System.ReadOnlySpan<T> other, System.Collections.Generic.IEqualityComparer<T>? comparer)
  • System.MemoryExtensions.ContainsAnyExcept<T>(this System.ReadOnlySpan<T> span, System.ReadOnlySpan<T> values) where T : System.IEquatable<T>?
  • System.MemoryExtensions.ContainsAnyExcept<T>(this System.ReadOnlySpan<T> span, T value) where T : System.IEquatable<T>?
  • System.MemoryExtensions.ContainsAnyExcept<T>(this System.ReadOnlySpan<T> span, T value0, T value1) where T : System.IEquatable<T>?
  • System.MemoryExtensions.ContainsAnyExcept<T>(this System.ReadOnlySpan<T> span, T value0, T value1, T value2) where T : System.IEquatable<T>?
  • System.MemoryExtensions.ContainsAnyExcept<T>(this System.Span<T> span, System.ReadOnlySpan<T> values) where T : System.IEquatable<T>?
  • System.MemoryExtensions.ContainsAnyExcept<T>(this System.Span<T> span, T value) where T : System.IEquatable<T>?
  • System.MemoryExtensions.ContainsAnyExcept<T>(this System.Span<T> span, T value0, T value1) where T : System.IEquatable<T>?
  • System.MemoryExtensions.ContainsAnyExcept<T>(this System.Span<T> span, T value0, T value1, T value2) where T : System.IEquatable<T>?
  • System.MemoryExtensions.ContainsAny<T>(this System.Span<T> span, System.ReadOnlySpan<T> values) where T : System.IEquatable<T>?
  • System.MemoryExtensions.ContainsAny<T>(this System.Span<T> span, T value0, T value1) where T : System.IEquatable<T>?
  • System.MemoryExtensions.ContainsAny<T>(this System.Span<T> span, T value0, T value1, T value2) where T : System.IEquatable<T>?
  • System.MemoryExtensions.Contains<T>(this System.ReadOnlySpan<T> span, T value) where T : System.IEquatable<T>?
  • System.MemoryExtensions.Contains<T>(this System.Span<T> span, T value) where T : System.IEquatable<T>?
  • System.MemoryExtensions.IndexOfAnyExcept<T>(this System.ReadOnlySpan<T> span, System.ReadOnlySpan<T> values) where T : System.IEquatable<T>?
  • System.MemoryExtensions.IndexOfAnyExcept<T>(this System.ReadOnlySpan<T> span, T value) where T : System.IEquatable<T>?
  • System.MemoryExtensions.IndexOfAnyExcept<T>(this System.ReadOnlySpan<T> span, T value0, T value1) where T : System.IEquatable<T>?
  • System.MemoryExtensions.IndexOfAnyExcept<T>(this System.ReadOnlySpan<T> span, T value0, T value1, T value2) where T : System.IEquatable<T>?
  • System.MemoryExtensions.IndexOfAnyExcept<T>(this System.Span<T> span, System.ReadOnlySpan<T> values) where T : System.IEquatable<T>?
  • System.MemoryExtensions.IndexOfAnyExcept<T>(this System.Span<T> span, T value) where T : System.IEquatable<T>?
  • System.MemoryExtensions.IndexOfAnyExcept<T>(this System.Span<T> span, T value0, T value1) where T : System.IEquatable<T>?
  • System.MemoryExtensions.IndexOfAnyExcept<T>(this System.Span<T> span, T value0, T value1, T value2) where T : System.IEquatable<T>?
  • System.Net.Http.HttpContent.CopyTo(System.IO.Stream stream, System.Net.TransportContext? context, System.Threading.CancellationToken cancellationToken)
  • System.Net.Http.HttpContent.CopyToAsync(System.IO.Stream stream)
  • System.Net.Http.HttpContent.CopyToAsync(System.IO.Stream stream, System.Net.TransportContext? context)
  • System.Net.Http.HttpContent.CopyToAsync(System.IO.Stream stream, System.Net.TransportContext? context, System.Threading.CancellationToken cancellationToken)
  • System.Net.Http.HttpContent.CopyToAsync(System.IO.Stream stream, System.Threading.CancellationToken cancellationToken)
  • System.Net.Http.HttpContent.ReadAsStream(System.Threading.CancellationToken cancellationToken)
  • System.Net.Http.HttpContent.ReadAsStream()
  • System.Net.Sockets.UdpClient.Send(System.ReadOnlySpan<System.Byte> datagram, System.Net.IPEndPoint? endPoint)
  • System.Net.Sockets.UdpClient.Send(System.ReadOnlySpan<System.Byte> datagram, System.String? hostname, System.Int32 port)
  • System.Net.Sockets.UdpClient.SendAsync(System.ReadOnlyMemory<System.Byte> datagram, System.Net.IPEndPoint? endPoint, [System.Threading.CancellationToken cancellationToken = default])
  • System.Net.Sockets.UdpClient.SendAsync(System.ReadOnlyMemory<System.Byte> datagram, System.String? hostname, System.Int32 port, [System.Threading.CancellationToken cancellationToken = default])
  • System.Net.Sockets.UdpClient.SendAsync(System.ReadOnlyMemory<System.Byte> datagram, [System.Threading.CancellationToken cancellationToken = default])
  • System.String.Contains(System.Char value)
  • System.String.Contains(System.Char value, System.StringComparison comparisonType)
  • System.String.Contains(System.String value, System.StringComparison comparisonType)
  • System.String.CopyTo(System.Span<System.Char> destination)
  • System.String.EndsWith(System.Char value)
  • System.String.GetHashCode(System.StringComparison comparisonType)
  • System.String.IndexOf(System.Char value, System.StringComparison comparisonType)
  • System.String.Replace(System.String oldValue, System.String? newValue, System.StringComparison comparisonType)
  • System.String.ReplaceLineEndings(System.String replacementText)
  • System.String.ReplaceLineEndings()
  • System.String.Split(System.Char separator, System.Int32 count, [System.StringSplitOptions options = System.StringSplitOptions.None])
  • System.String.Split(System.Char separator, [System.StringSplitOptions options = System.StringSplitOptions.None])
  • System.String.StartsWith(System.Char value)
  • System.String.TryCopyTo(System.Span<System.Char> destination)
  • System.Text.Encoding.GetString(System.ReadOnlySpan<System.Byte> bytes)
  • System.Text.StringBuilder.Append(System.ReadOnlyMemory<System.Char> value)
  • System.Text.StringBuilder.Append(System.ReadOnlySpan<System.Char> value)
  • System.Text.StringBuilder.AppendJoin(System.Char separator, params System.Object?[] values)
  • System.Text.StringBuilder.AppendJoin(System.Char separator, params System.String?[] values)
  • System.Text.StringBuilder.AppendJoin(System.String? separator, params System.Object?[] values)
  • System.Text.StringBuilder.AppendJoin(System.String? separator, params System.String?[] values)
  • System.Text.StringBuilder.AppendJoin<T>(System.Char separator, System.Collections.Generic.IEnumerable<T> values)
  • System.Text.StringBuilder.AppendJoin<T>(System.String? separator, System.Collections.Generic.IEnumerable<T> values)
  • System.Text.StringBuilder.Replace(System.ReadOnlySpan<System.Char> oldValue, System.ReadOnlySpan<System.Char> newValue)
  • System.Text.StringBuilder.Replace(System.ReadOnlySpan<System.Char> oldValue, System.ReadOnlySpan<System.Char> newValue, System.Int32 startIndex, System.Int32 count)
  • System.Threading.CancellationTokenSource.CancelAsync()
  • System.Threading.Tasks.Task.WaitAsync(System.Threading.CancellationToken cancellationToken)
  • System.Threading.Tasks.TaskAsyncEnumerableExtensions.ToBlockingEnumerable<T>(this System.Collections.Generic.IAsyncEnumerable<T> source, [System.Threading.CancellationToken cancellationToken = default])
  • System.Type.IsAssignableTo(System.Type? targetType)

Contribution

How to add a new polyfill
  • Create a new file named <xml documentation id>.cs in the project Meziantou.Polyfill.Editor
  • Run Meziantou.Polyfill.Generator

Notes:

  • All files must be self contained. Use a file class if needed.
  • If you need to generate a file only when another polyfill is generated, add // when <xml documentation id> in the file
There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

  • .NETStandard 2.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories (6)

Showing the top 5 popular GitHub repositories that depend on Meziantou.Polyfill:

Repository Stars
riok/mapperly
A .NET source generator for generating object mappings. No runtime reflection.
bUnit-dev/bUnit
bUnit is a testing library for Blazor components that make tests look, feel, and runs like regular unit tests. bUnit makes it easy to render and control a component under test’s life-cycle, pass parameter and inject services into it, trigger event handlers, and verify the rendered markup from the component using a built-in semantic HTML comparer.
meziantou/Meziantou.Analyzer
A Roslyn analyzer to enforce some good practices in C#.
meziantou/Meziantou.Framework
minio/minio-dotnet
MinIO Client SDK for .NET
Version Downloads Last updated
1.0.42 658 11/16/2024
1.0.41 1,306 11/13/2024
1.0.40 4,350 10/9/2024
1.0.39 11,106 7/2/2024
1.0.38 9,966 4/27/2024
1.0.37 2,805 3/21/2024
1.0.36 4,401 2/28/2024
1.0.35 616 2/21/2024
1.0.34 3,780 2/7/2024
1.0.33 1,612 1/13/2024
1.0.32 390 1/10/2024
1.0.31 6,372 12/2/2023
1.0.30 9,969 10/10/2023
1.0.29 353 10/7/2023
1.0.28 527 10/5/2023
1.0.27 2,718 9/5/2023
1.0.26 4,190 8/12/2023
1.0.25 755 8/7/2023
1.0.24 578 8/7/2023
1.0.23 271 8/7/2023
1.0.22 323 8/7/2023
1.0.21 498 8/2/2023
1.0.20 219 8/2/2023
1.0.19 207 8/2/2023
1.0.18 485 7/18/2023
1.0.17 3,367 7/16/2023
1.0.16 1,286 7/12/2023
1.0.15 192 7/12/2023
1.0.14 897 7/7/2023
1.0.13 220 7/7/2023
1.0.12 243 7/7/2023
1.0.11 523 6/25/2023
1.0.10 187 6/25/2023
1.0.9 195 6/25/2023
1.0.8 184 6/25/2023
1.0.7 156 6/25/2023
1.0.6 162 6/23/2023
1.0.5 183 6/9/2023
1.0.4 199 6/9/2023
1.0.3 191 6/8/2023
1.0.2 175 6/7/2023
1.0.1 1,007 6/7/2023
1.0.0 219 6/7/2023