Source only package that exposes newer .NET and C# features to older runtimes.
The package targets netstandard2.0 and is designed to support the following runtimes.
- net461,- net462,- net47,- net471,- net472,- net48,- net481
- netcoreapp2.0,- netcoreapp2.1,- netcoreapp3.0,- netcoreapp3.1
- net5.0,- net6.0,- net7.0,- net8.0,- net9.0,- net10.0
- uap10
API count: 594
See Milestones for release notes.
It is recommended that projects that consume Polyfill multi-target all TFMs that the project is expected to be consumed in. See Polyfill and TargetFrameworks
This project uses features from the current stable SDK and C# language. As such consuming projects should target those:
<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <LangVersion>latest</LangVersion>{
  "sdk": {
    "version": "9.0.300",
    "rollForward": "latestFeature"
  }
}To consume Polyfill as a library (instead of a source-only package) see PolyfillLib
Make sure DefineConstants is not set from dotnet CLI, which would override important constants set by Polyfill.
Instead of using dotnet publish -p:DefineConstants=MY_CONSTANT, set the constant indirectly in the project:
<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <DefineConstants Condition="'$(MyConstant)' == 'true'">$(DefineConstants);MY_CONSTANT</DefineConstants>and use dotnet publish -p:MyConstant=true.
Reference: Module Initializers
static bool InitCalled;
[Test]
public void ModuleInitTest() =>
    Assert.True(InitCalled);
[ModuleInitializer]
public static void ModuleInit() =>
    InitCalled = true;Reference: init (C# Reference)
class InitSample
{
    public int Member { get; init; }
}- AllowNullAttribute
- DisallowNullAttribute
- DoesNotReturnAttribute
- DoesNotReturnIfAttribute
- MaybeNullAttribute
- MaybeNullWhenAttribute
- MemberNotNullAttribute
- MemberNotNullWhenAttribute
- NotNullAttribute
- NotNullIfNotNullAttribute
- NotNullWhenAttribute
Reference: Nullable reference types
Reference: C# required modifier
public class Person
{
    public Person()
    {
    }
    [SetsRequiredMembers]
    public Person(string name) =>
        Name = name;
    public required string Name { get; init; }
}Indicates that compiler support for a particular feature is required for the location where this attribute is applied.
Can be used to make types compatible with collection expressions
Indicates that the specified method parameter expects a constant.
Reference: SkipLocalsInitAttribute
the SkipLocalsInit attribute prevents the compiler from setting the .locals init flag when emitting to metadata. The SkipLocalsInit attribute is a single-use attribute and can be applied to a method, a property, a class, a struct, an interface, or a module, but not to an assembly. SkipLocalsInit is an alias for SkipLocalsInitAttribute.
class SkipLocalsInitSample
{
    [SkipLocalsInit]
    static void ReadUninitializedMemory()
    {
        Span<int> numbers = stackalloc int[120];
        for (var i = 0; i < 120; i++)
        {
            Console.WriteLine(numbers[i]);
        }
    }
}Reference: Indices and ranges
If consuming in a project that targets net461 or net462, a reference to System.ValueTuple is required. See References: System.ValueTuple.
[TestFixture]
class IndexRangeSample
{
    [Test]
    public void Range()
    {
        var substring = "value"[2..];
        Assert.AreEqual("lue", substring);
    }
    [Test]
    public void Index()
    {
        var ch = "value"[^2];
        Assert.AreEqual('u', ch);
    }
    [Test]
    public void ArrayIndex()
    {
        var array = new[]
        {
            "value1",
            "value2"
        };
        var value = array[^2];
        Assert.AreEqual("value1", value);
    }
}C# introduces a new attribute, System.Runtime.CompilerServices.OverloadResolutionPriority, that can be used by API authors to adjust the relative priority of overloads within a single type as a means of steering API consumers to use specific APIs, even if those APIs would normally be considered ambiguous or otherwise not be chosen by C#'s overload resolution rules. This helps framework and library authors guide API usage as they APIs as they develop new and better patterns.
The OverloadResolutionPriorityAttribute can be used in conjunction with the ObsoleteAttribute. A library author may mark properties, methods, types and other programming elements as obsolete, while leaving them in place for backwards compatibility. Using programming elements marked with the ObsoleteAttribute will result in compiler warnings or errors. However, the type or member is still visible to overload resolution and may be selected over a better overload or cause an ambiguity failure. The OverloadResolutionPriorityAttribute lets library authors fix these problems by lowering the priority of obsolete members when there are better alternatives.
[TestFixture]
public class OverloadResolutionPriorityAttributeTests
{
    [Test]
    public void Run()
    {
        int[] arr = [1, 2, 3];
        //Prints "Span" because resolution priority is higher
        Method(arr);
    }
    [OverloadResolutionPriority(2)]
    static void Method(ReadOnlySpan<int> list) =>
        Console.WriteLine("Span");
    [OverloadResolutionPriority(1)]
    static void Method(int[] list) =>
        Console.WriteLine("Array");
}Reference: Low Level Struct Improvements
struct UnscopedRefUsage
{
    int field1;
    [UnscopedRef] ref int Prop1 => ref field1;
}Reference: CallerArgumentExpression
static class FileUtil
{
    public static void FileExists(string path, [CallerArgumentExpression("path")] string argumentName = "")
    {
        if (!File.Exists(path))
        {
            throw new ArgumentException($"File not found. Path: {path}", argumentName);
        }
    }
}
static class FileUtilUsage
{
    public static string[] Method(string path)
    {
        FileUtil.FileExists(path);
        return File.ReadAllLines(path);
    }
}Enable by adding an MSBuild property PolyStringInterpolation
<PropertyGroup>
  ...
  <PolyStringInterpolation>true</PolyStringInterpolation>
</PropertyGroup>
- AppendInterpolatedStringHandler
- DefaultInterpolatedStringHandler
- InterpolatedStringHandlerAttribute
- InterpolatedStringHandlerArgumentAttribute
- ISpanFormattable
References: String Interpolation in C# 10 and .NET 6, Write a custom string interpolation handler
Important
In the below extension method list, the methods using AppendInterpolatedStringHandler parameter are not extensions because the compiler prefers to use the overload with string parameter instead.
Reference: .NET 7 - The StringSyntaxAttribute
- DynamicallyAccessedMembersAttribute
- DynamicDependencyAttribute
- RequiresUnreferencedCodeAttribute
- RequiresDynamicCodeAttribute
- UnconditionalSuppressMessageAttribute
Reference: Prepare .NET libraries for trimming
- ObsoletedOSPlatformAttribute
- SupportedOSPlatformAttribute
- SupportedOSPlatformGuardAttribute
- TargetPlatformAttribute
- UnsupportedOSPlatformAttribute
- UnsupportedOSPlatformGuardAttribute
Reference: Platform compatibility analyzer
StackTraceHiddenAttribute
Reference: C# – Hide a method from the stack trace
Reference: Improvements in native code interop in .NET 5.0
The class Polyfill includes the following extension methods:
- void CopyTo<T>(ArraySegment<T>)reference
- void CopyTo<T>(T[], int)reference
- void CopyTo<T>(T[])reference
- ArraySegmentEnumerator<T> GetEnumerator<T>()reference
- bool TryFormat(Span<char>, int)reference
- bool TryFormat(Span<byte>, int, ReadOnlySpan<char>, IFormatProvider?)reference
- bool TryFormat(Span<char>, int, ReadOnlySpan<char>, IFormatProvider?)reference
- CancellationTokenRegistration Register(Action<object?, CancellationToken>, object?)reference
- CancellationTokenRegistration UnsafeRegister(Action<object?, CancellationToken>, object?)reference
- CancellationTokenRegistration UnsafeRegister(Action<object?>, object?)reference
- Task CancelAsync()reference
- void Clear<T>()reference
- TValue GetOrAdd<TKey, TValue, TArg>(TKey, Func<TKey, TArg, TValue>, TArg) where TKey : notnullreference
- void Clear<T>()reference
- void Deconstruct(int, int, int)reference
- bool TryFormat(Span<byte>, int, ReadOnlySpan<char>, IFormatProvider?)reference
- bool TryFormat(Span<char>, int, ReadOnlySpan<char>, IFormatProvider?)reference
- DateTime AddMicroseconds(double)reference
- void Deconstruct(DateOnly, TimeOnly)reference
- void Deconstruct(int, int, int)reference
- int Microsecond()reference
- int Nanosecond()reference
- bool TryFormat(Span<byte>, int, ReadOnlySpan<char>, IFormatProvider?)reference
- bool TryFormat(Span<char>, int, ReadOnlySpan<char>, IFormatProvider?)reference
- DateTimeOffset AddMicroseconds(double)reference
- void Deconstruct(DateOnly, TimeOnly, TimeSpan)reference
- int Microsecond()reference
- int Nanosecond()reference
- bool TryFormat(Span<byte>, int, ReadOnlySpan<char>, IFormatProvider?)reference
- bool TryFormat(Span<char>, int, ReadOnlySpan<char>, IFormatProvider?)reference
- bool TryFormat(Span<byte>, int, ReadOnlySpan<char>, IFormatProvider?)reference
- bool TryFormat(Span<char>, int, ReadOnlySpan<char>, IFormatProvider?)reference
- void Clear()reference
- bool HasSingleTarget()reference
- void EnsureCapacity<TKey, TValue>(int)reference
- void TrimExcess<TKey, TValue>(int)reference
- void TrimExcess<TKey, TValue>()reference
- void Deconstruct(object, object?)reference
- bool TryFormat(Span<byte>, int, ReadOnlySpan<char>, IFormatProvider?)reference
- bool TryFormat(Span<char>, int, ReadOnlySpan<char>, IFormatProvider?)reference
- int GetByteCount(ReadOnlySpan<char>)reference
- int GetBytes(ReadOnlySpan<char>, Span<byte>)reference
- int GetCharCount(ReadOnlySpan<byte>)reference
- int GetChars(ReadOnlySpan<byte>, Span<char>)reference
- string GetString(ReadOnlySpan<byte>)reference
- bool TryGetBytes(ReadOnlySpan<char>, Span<byte>, int)reference
- bool TryGetChars(ReadOnlySpan<byte>, Span<char>, int)reference
- NullabilityState GetNullability()
- NullabilityInfo GetNullabilityInfo()
- bool IsNullable()
- NullabilityState GetNullability()
- NullabilityInfo GetNullabilityInfo()
- bool IsNullable()
- bool TryFormat(Span<byte>, int, ReadOnlySpan<char>, IFormatProvider?)reference
- bool TryFormat(Span<char>, int, ReadOnlySpan<char>, IFormatProvider?)reference
- bool TryFormat(Span<byte>, int, ReadOnlySpan<char>)reference
- bool TryFormat(Span<char>, int, ReadOnlySpan<char>)reference
- void EnsureCapacity<T>(int)reference
- void TrimExcess<T>(int)reference
- bool TryGetValue<T>(T, T)reference
- Task<byte[]> GetByteArrayAsync(string, CancellationToken)reference
- Task<byte[]> GetByteArrayAsync(Uri, CancellationToken)reference
- Task<Stream> GetStreamAsync(string, CancellationToken)reference
- Task<Stream> GetStreamAsync(Uri, CancellationToken)reference
- Task<string> GetStringAsync(string, CancellationToken)reference
- Task<string> GetStringAsync(Uri, CancellationToken)reference
- Task<byte[]> ReadAsByteArrayAsync(CancellationToken)reference
- Task<Stream> ReadAsStreamAsync(CancellationToken)reference
- Task<string> ReadAsStringAsync(CancellationToken)reference
- ReadOnlyDictionary<TKey, TValue> AsReadOnly<TKey, TValue>() where TKey : notnullreference
- bool Remove<TKey, TValue>(TKey, TValue) where TKey : notnullreference
- bool TryAdd<TKey, TValue>(TKey, TValue) where TKey : notnullreference
- IEnumerable<(TFirst First, TSecond Second, TThird Third)> Zip<TFirst, TSecond, TThird>(IEnumerable<TSecond>, IEnumerable<TThird>)reference
- IEnumerable<(TFirst First, TSecond Second)> Zip<TFirst, TSecond>(IEnumerable<TSecond>)reference
- IEnumerable<KeyValuePair<TKey, TAccumulate>> AggregateBy<TSource, TKey, TAccumulate>(Func<TSource, TKey>, Func<TKey, TAccumulate>, Func<TAccumulate, TSource, TAccumulate>, IEqualityComparer<TKey>?) where TKey : notnullreference
- IEnumerable<KeyValuePair<TKey, TAccumulate>> AggregateBy<TSource, TKey, TAccumulate>(Func<TSource, TKey>, TAccumulate, Func<TAccumulate, TSource, TAccumulate>, IEqualityComparer<TKey>?) where TKey : notnullreference
- IEnumerable<TSource> Append<TSource>(TSource)reference
- IEnumerable<TSource[]> Chunk<TSource>(int)reference
- IEnumerable<KeyValuePair<TKey, int>> CountBy<TSource, TKey>(Func<TSource, TKey>, IEqualityComparer<TKey>?) where TKey : notnullreference
- IEnumerable<TSource> DistinctBy<TSource, TKey>(Func<TSource, TKey>, IEqualityComparer<TKey>?)reference
- IEnumerable<TSource> DistinctBy<TSource, TKey>(Func<TSource, TKey>)reference
- TSource ElementAt<TSource>(Index)reference
- TSource? ElementAtOrDefault<TSource>(Index)reference
- IEnumerable<TSource> Except<TSource>(IEqualityComparer<TSource>?, TSource[])reference
- IEnumerable<TSource> Except<TSource>(TSource, IEqualityComparer<TSource>?)reference
- IEnumerable<TSource> Except<TSource>(TSource)reference
- IEnumerable<TSource> ExceptBy<TSource, TKey>(IEnumerable<TKey>, Func<TSource, TKey>, IEqualityComparer<TKey>?)reference
- IEnumerable<TSource> ExceptBy<TSource, TKey>(IEnumerable<TKey>, Func<TSource, TKey>)reference
- TSource FirstOrDefault<TSource>(Func<TSource, bool>, TSource)reference
- TSource FirstOrDefault<TSource>(TSource)reference
- IEnumerable<(int Index, TSource Item)> Index<TSource>()reference
- TSource LastOrDefault<TSource>(Func<TSource, bool>, TSource)reference
- TSource LastOrDefault<TSource>(TSource)reference
- TSource? Max<TSource>(IComparer<TSource>?)reference
- TSource? MaxBy<TSource, TKey>(Func<TSource, TKey>, IComparer<TKey>?)reference
- TSource? MaxBy<TSource, TKey>(Func<TSource, TKey>)reference
- TSource? Min<TSource>(IComparer<TSource>?)reference
- TSource? MinBy<TSource, TKey>(Func<TSource, TKey>, IComparer<TKey>?)reference
- TSource? MinBy<TSource, TKey>(Func<TSource, TKey>)reference
- TSource SingleOrDefault<TSource>(Func<TSource, bool>, TSource)reference
- TSource SingleOrDefault<TSource>(TSource)reference
- IEnumerable<TSource> SkipLast<TSource>(int)reference
- IEnumerable<TSource> Take<TSource>(Range)reference
- IEnumerable<TSource> TakeLast<TSource>(int)reference
- HashSet<TSource> ToHashSet<TSource>(IEqualityComparer<TSource>?)reference
- bool TryGetNonEnumeratedCount<TSource>(int)reference
- IEnumerable<TSource> UnionBy<TSource, TKey>(IEnumerable<TSource>, Func<TSource, TKey>, IEqualityComparer<TKey>?)reference
- IEnumerable<TSource> UnionBy<TSource, TKey>(IEnumerable<TSource>, Func<TSource, TKey>)reference
- ReadOnlyCollection<T> AsReadOnly<T>()reference
- bool TryFormat(Span<byte>, int, ReadOnlySpan<char>, IFormatProvider?)reference
- bool TryFormat(Span<char>, int, ReadOnlySpan<char>, IFormatProvider?)reference
- TValue GetValueOrDefault<TKey, TValue>(TKey, TValue) where TKey : notnullreference
- TValue? GetValueOrDefault<TKey, TValue>(TKey)reference
- ReadOnlySet<T> AsReadOnly<T>()reference
- void Deconstruct<TKey, TValue>(TKey, TValue)reference
- void AddRange<T>(ReadOnlySpan<T>)reference
- void CopyTo<T>(Span<T>)reference
- void EnsureCapacity<T>(int)reference
- void InsertRange<T>(int, ReadOnlySpan<T>)reference
- void TrimExcess<T>()
- bool TryFormat(Span<byte>, int, ReadOnlySpan<char>, IFormatProvider?)reference
- bool TryFormat(Span<char>, int, ReadOnlySpan<char>, IFormatProvider?)reference
- NullabilityState GetNullability()
- NullabilityInfo GetNullabilityInfo()
- bool HasSameMetadataDefinitionAs(MemberInfo)reference
- bool IsNullable()
- T CreateDelegate<T>(object?) where T : Delegatereference
- T CreateDelegate<T>() where T : Delegatereference
- bool TryAdd<TKey, TValue>(TKey, TValue, int) where TKey : notnullreference
- bool TryGetValue<TKey, TValue>(TKey, TValue, int) where TKey : notnullreference
- NullabilityState GetNullability()
- NullabilityInfo GetNullabilityInfo()
- bool IsNullable()
- NullabilityState GetNullability()
- NullabilityInfo GetNullabilityInfo()
- bool IsNullable()
- T[] GetItems<T>(ReadOnlySpan<T>, int)reference
- void GetItems<T>(ReadOnlySpan<T>, Span<T>)reference
- T[] GetItems<T>(T[], int)reference
- void NextBytes(Span<byte>)reference
- void Shuffle<T>(Span<T>)reference
- void Shuffle<T>(T[])reference
- bool EndsWith(string, StringComparison)reference
- SpanLineEnumerator EnumerateLines()reference
- int GetNormalizedLength(NormalizationForm)reference
- bool IsNormalized(NormalizationForm)reference
- bool SequenceEqual(string)reference
- bool StartsWith(string, StringComparison)reference
- bool TryNormalize(Span<char>, int, NormalizationForm)reference
- int CommonPrefixLength<T>(ReadOnlySpan<T>, IEqualityComparer<T>?)reference
- int CommonPrefixLength<T>(ReadOnlySpan<T>)reference
- bool Contains<T>(T, IEqualityComparer<T>?)reference
- bool Contains<T>(T) where T : IEquatable<T>reference
- int CountAny<T>(ReadOnlySpan<T>, IEqualityComparer<T>?)reference
- int CountAny<T>(ReadOnlySpan<T>) where T : IEquatable<T>?reference
- int CountAny<T>(SearchValues<T>) where T : IEquatable<T>?reference
- bool EndsWith<T>(T) where T : IEquatable<T>?reference
- int IndexOf<T>(T, IEqualityComparer<T>?)reference
- int IndexOfAny<T>(ReadOnlySpan<T>, IEqualityComparer<T>?)reference
- SpanSplitEnumerator<T> Split<T>(ReadOnlySpan<T>) where T : IEquatable<T>reference
- SpanSplitEnumerator<T> Split<T>(T) where T : IEquatable<T>reference
- SpanSplitEnumerator<T> SplitAny<T>(ReadOnlySpan<T>) where T : IEquatable<T>reference
- SpanSplitEnumerator<T> SplitAny<T>(SearchValues<T>) where T : IEquatable<T>reference
- bool StartsWith<T>(T) where T : IEquatable<T>?reference
- ValueMatchEnumerator EnumerateMatches(ReadOnlySpan<char>, int)reference
- ValueMatchEnumerator EnumerateMatches(ReadOnlySpan<char>)reference
- bool IsMatch(ReadOnlySpan<char>, int)reference
- bool IsMatch(ReadOnlySpan<char>)reference
- bool TryFormat(Span<byte>, int, ReadOnlySpan<char>, IFormatProvider?)reference
- bool TryFormat(Span<char>, int, ReadOnlySpan<char>, IFormatProvider?)reference
- bool TryFormat(Span<byte>, int, ReadOnlySpan<char>, IFormatProvider?)reference
- bool TryFormat(Span<char>, int, ReadOnlySpan<char>, IFormatProvider?)reference
- bool EndsWith(string)reference
- SpanLineEnumerator EnumerateLines()reference
- bool SequenceEqual(string)reference
- bool StartsWith(string)reference
- Span<char> TrimEnd()reference
- Span<char> TrimStart()reference
- int CommonPrefixLength<T>(ReadOnlySpan<T>, IEqualityComparer<T>?)reference
- int CommonPrefixLength<T>(ReadOnlySpan<T>)reference
- bool Contains<T>(T) where T : IEquatable<T>reference
- void EnsureCapacity<T>(int)reference
- void TrimExcess<T>(int)reference
- bool TryPeek<T>(T)reference
- bool TryPop<T>(T)reference
- Task CopyToAsync(Stream, CancellationToken)reference
- ValueTask DisposeAsync()reference
- int Read(Span<byte>)reference
- ValueTask<int> ReadAsync(Memory<byte>, CancellationToken)reference
- int ReadAtLeast(Span<byte>, int, bool)reference
- ValueTask<int> ReadAtLeastAsync(Memory<byte>, int, bool, CancellationToken)reference
- void ReadExactly(byte[], int, int)reference
- void ReadExactly(Span<byte>)reference
- ValueTask ReadExactlyAsync(byte[], int, int, CancellationToken)reference
- ValueTask ReadExactlyAsync(Memory<byte>, CancellationToken)reference
- ValueTask WriteAsync(ReadOnlyMemory<byte>, CancellationToken)reference
- bool Contains(char, StringComparison)reference
- bool Contains(char)reference
- bool Contains(string, StringComparison)reference
- void CopyTo(Span<char>)reference
- bool EndsWith(char)reference
- int GetHashCode(StringComparison)reference
- int IndexOf(char, StringComparison)reference
- string ReplaceLineEndings(string)reference
- string ReplaceLineEndings()reference
- string[] Split(char, int, StringSplitOptions)reference
- string[] Split(char, StringSplitOptions)reference
- string[] Split(string, int, StringSplitOptions)reference
- string[] Split(string, StringSplitOptions)reference
- bool StartsWith(char)reference
- bool TryCopyTo(Span<char>)reference
- StringBuilder Append(StringBuilder, AppendInterpolatedStringHandler)reference
- StringBuilder Append(StringBuilder, IFormatProvider?, AppendInterpolatedStringHandler)reference
- StringBuilder Append(StringBuilder, IFormatProvider?, StringBuilder.AppendInterpolatedStringHandler)reference
- StringBuilder Append(ReadOnlySpan<char>)reference
- StringBuilder Append(StringBuilder?, int, int)reference
- StringBuilder Append(StringBuilder, StringBuilder.AppendInterpolatedStringHandler)reference
- StringBuilder AppendJoin(char, object?[])reference
- StringBuilder AppendJoin(char, string?[])reference
- StringBuilder AppendJoin(string?, object?[])reference
- StringBuilder AppendJoin(string?, string?[])reference
- StringBuilder AppendJoin<T>(char, IEnumerable<T>)reference
- StringBuilder AppendJoin<T>(char, T[])reference
- StringBuilder AppendJoin<T>(string, T[])reference
- StringBuilder AppendJoin<T>(string?, IEnumerable<T>)reference
- StringBuilder AppendLine(StringBuilder, AppendInterpolatedStringHandler)reference
- StringBuilder AppendLine(StringBuilder, IFormatProvider?, AppendInterpolatedStringHandler)reference
- StringBuilder AppendLine(StringBuilder, IFormatProvider?, StringBuilder.AppendInterpolatedStringHandler)reference
- StringBuilder AppendLine(StringBuilder, StringBuilder.AppendInterpolatedStringHandler)reference
- void CopyTo(int, Span<char>, int)reference
- bool Equals(ReadOnlySpan<char>)reference
- ChunkEnumerator GetChunks()reference
- StringBuilder Insert(int, ReadOnlySpan<char>)reference
- StringBuilder Replace(ReadOnlySpan<char>, ReadOnlySpan<char>, int, int)reference
- StringBuilder Replace(ReadOnlySpan<char>, ReadOnlySpan<char>)reference
- Task WaitAsync(CancellationToken)reference
- Task WaitAsync(TimeSpan, CancellationToken)reference
- Task WaitAsync(TimeSpan)reference
- Task<TResult> WaitAsync<TResult>(CancellationToken)reference
- Task<TResult> WaitAsync<TResult>(TimeSpan, CancellationToken)reference
- Task<TResult> WaitAsync<TResult>(TimeSpan)reference
- void SetCanceled<T>(CancellationToken)reference
- ValueTask<int> ReadAsync(Memory<char>, CancellationToken)reference
- Task<string> ReadLineAsync(CancellationToken)reference
- Task<string> ReadToEndAsync(CancellationToken)reference
- Task FlushAsync(CancellationToken)reference
- void Write(ReadOnlySpan<char>)reference
- void Write(StringBuilder?)reference
- ValueTask WriteAsync(ReadOnlyMemory<char>, CancellationToken)reference
- Task WriteAsync(StringBuilder?, CancellationToken)reference
- void WriteLine(ReadOnlySpan<char>)reference
- ValueTask WriteLineAsync(ReadOnlyMemory<char>, CancellationToken)reference
- void Deconstruct(int, int, int, int, int)reference
- void Deconstruct(int, int, int, int)reference
- void Deconstruct(int, int, int)reference
- void Deconstruct(int, int)reference
- bool TryFormat(Span<byte>, int, ReadOnlySpan<char>, IFormatProvider?)reference
- bool TryFormat(Span<char>, int, ReadOnlySpan<char>, IFormatProvider?)reference
- int Microseconds()reference
- int Nanoseconds()reference
- bool TryFormat(Span<byte>, int, ReadOnlySpan<char>, IFormatProvider?)reference
- bool TryFormat(Span<char>, int, ReadOnlySpan<char>, IFormatProvider?)reference
- MemberInfo GetMemberWithSameMetadataDefinitionAs(MemberInfo)reference
- MethodInfo? GetMethod(string, int, BindingFlags, Type[])reference
- bool IsAssignableFrom<T>()
- bool IsAssignableTo(Type?)reference
- bool IsAssignableTo<T>()
- bool IsGenericMethodParameter()reference
- bool TryFormat(Span<byte>, int, ReadOnlySpan<char>, IFormatProvider?)reference
- bool TryFormat(Span<char>, int, ReadOnlySpan<char>, IFormatProvider?)reference
- bool TryFormat(Span<byte>, int, ReadOnlySpan<char>, IFormatProvider?)reference
- bool TryFormat(Span<char>, int, ReadOnlySpan<char>, IFormatProvider?)reference
- bool TryFormat(Span<byte>, int, ReadOnlySpan<char>, IFormatProvider?)reference
- bool TryFormat(Span<char>, int, ReadOnlySpan<char>, IFormatProvider?)reference
- Task SaveAsync(Stream, SaveOptions, CancellationToken)reference
- Task SaveAsync(TextWriter, SaveOptions, CancellationToken)reference
- Task SaveAsync(XmlWriter, CancellationToken)reference
- Task SaveAsync(Stream, SaveOptions, CancellationToken)reference
- Task SaveAsync(TextWriter, SaveOptions, CancellationToken)reference
- Task SaveAsync(XmlWriter, CancellationToken)reference
- Task<ZipArchiveEntry> CreateEntryFromFileAsync(string, string, CancellationToken)reference
- Task<ZipArchiveEntry> CreateEntryFromFileAsync(string, string, CompressionLevel, CancellationToken)reference
- void ExtractToDirectory(string, bool)reference
- Task ExtractToDirectoryAsync(string, bool, CancellationToken)reference
- Task ExtractToDirectoryAsync(string, CancellationToken)reference
- Task ExtractToFileAsync(string, bool, CancellationToken)reference
- Task ExtractToFileAsync(string, CancellationToken)reference
- Task<Stream> OpenAsync(CancellationToken)reference
- bool TryParse(ReadOnlySpan<byte>, byte)reference
- bool TryParse(ReadOnlySpan<byte>, IFormatProvider?, byte)reference
- bool TryParse(ReadOnlySpan<byte>, NumberStyles, IFormatProvider?, byte)reference
- bool TryParse(ReadOnlySpan<char>, byte)reference
- bool TryParse(ReadOnlySpan<char>, IFormatProvider?, byte)reference
- bool TryParse(ReadOnlySpan<char>, NumberStyles, IFormatProvider?, byte)reference
- bool TryParse(string?, IFormatProvider?, byte)reference
- byte[] FromHexString(ReadOnlySpan<char>)reference
- byte[] FromHexString(string)reference
- string ToHexString(byte[], int, int)reference
- string ToHexString(byte[])reference
- string ToHexString(ReadOnlySpan<byte>)reference
- string ToHexStringLower(byte[], int, int)reference
- string ToHexStringLower(byte[])reference
- string ToHexStringLower(ReadOnlySpan<byte>)reference
- bool TryToHexString(ReadOnlySpan<byte>, Span<char>, int)reference
- bool TryToHexStringLower(ReadOnlySpan<byte>, Span<char>, int)reference
- bool TryParse(ReadOnlySpan<char>, DateTimeOffset)reference
- bool TryParse(ReadOnlySpan<char>, IFormatProvider?, DateTimeOffset)reference
- bool TryParse(ReadOnlySpan<char>, IFormatProvider?, DateTimeStyles, DateTimeOffset)reference
- bool TryParse(string?, IFormatProvider?, DateTimeOffset)reference
- bool TryParseExact(ReadOnlySpan<char>, ReadOnlySpan<char>, IFormatProvider?, DateTimeStyles, DateTimeOffset)reference
- bool TryParseExact(ReadOnlySpan<char>, string, IFormatProvider?, DateTimeStyles, DateTimeOffset)reference
- bool TryParse(ReadOnlySpan<char>, DateTime)reference
- bool TryParse(ReadOnlySpan<char>, IFormatProvider?, DateTime)reference
- bool TryParse(ReadOnlySpan<char>, IFormatProvider?, DateTimeStyles, DateTime)reference
- bool TryParse(string?, IFormatProvider?, DateTime)reference
- bool TryParseExact(ReadOnlySpan<char>, ReadOnlySpan<char>, IFormatProvider?, DateTimeStyles, DateTime)reference
- bool TryParseExact(ReadOnlySpan<char>, string, IFormatProvider?, DateTimeStyles, DateTime)reference
- InvocationListEnumerator<TDelegate> EnumerateInvocationList<TDelegate>(TDelegate?) where TDelegate : Delegatereference
- bool TryParse(ReadOnlySpan<byte>, double)reference
- bool TryParse(ReadOnlySpan<byte>, IFormatProvider?, double)reference
- bool TryParse(ReadOnlySpan<byte>, NumberStyles, IFormatProvider?, double)reference
- bool TryParse(ReadOnlySpan<char>, double)reference
- bool TryParse(ReadOnlySpan<char>, IFormatProvider?, double)reference
- bool TryParse(ReadOnlySpan<char>, NumberStyles, IFormatProvider?, double)reference
- bool TryParse(string?, IFormatProvider?, double)reference
- string[] GetNames<TEnum>() where TEnum : struct, Enumreference
- TEnum[] GetValues<TEnum>() where TEnum : struct, Enumreference
- bool IsDefined<TEnum>(TEnum) where TEnum : struct, Enumreference
- TEnum Parse<TEnum>(ReadOnlySpan<char>, bool) where TEnum : struct, Enumreference
- TEnum Parse<TEnum>(ReadOnlySpan<char>) where TEnum : struct, Enumreference
- TEnum Parse<TEnum>(string, bool) where TEnum : struct, Enumreference
- TEnum Parse<TEnum>(string) where TEnum : struct, Enumreference
- bool TryFormat<TEnum>(TEnum, Span<char>, int, ReadOnlySpan<char>) where TEnum : struct, Enumreference
- bool TryParse<TEnum>(ReadOnlySpan<char>, bool, TEnum) where TEnum : struct, Enumreference
- bool TryParse<TEnum>(ReadOnlySpan<char>, TEnum) where TEnum : struct, Enumreference
- void AppendAllBytes(string, byte[])reference
- void AppendAllBytes(string, ReadOnlySpan<byte>)reference
- Task AppendAllBytesAsync(string, byte[], CancellationToken)reference
- Task AppendAllBytesAsync(string, ReadOnlyMemory<byte>, CancellationToken)reference
- Task AppendAllLinesAsync(string, IEnumerable<string>, CancellationToken)reference
- Task AppendAllLinesAsync(string, IEnumerable<string>, Encoding, CancellationToken)reference
- void AppendAllText(string, ReadOnlySpan<char>, Encoding)reference
- void AppendAllText(string, ReadOnlySpan<char>)reference
- Task AppendAllTextAsync(string, ReadOnlyMemory<char>, CancellationToken)reference
- Task AppendAllTextAsync(string, ReadOnlyMemory<char>, Encoding, CancellationToken)reference
- Task AppendAllTextAsync(string, string?, CancellationToken)reference
- Task AppendAllTextAsync(string, string?, Encoding, CancellationToken)reference
- UnixFileMode GetUnixFileMode(string)reference
- void Move(string, string, bool)reference
- Task<byte[]> ReadAllBytesAsync(string, CancellationToken)reference
- Task<string[]> ReadAllLinesAsync(string, CancellationToken)reference
- Task<string[]> ReadAllLinesAsync(string, Encoding, CancellationToken)reference
- Task<string> ReadAllTextAsync(string, CancellationToken)reference
- Task<string> ReadAllTextAsync(string, Encoding, CancellationToken)reference
- IAsyncEnumerable<string> ReadLinesAsync(string, CancellationToken)reference
- IAsyncEnumerable<string> ReadLinesAsync(string, Encoding, CancellationToken)reference
- void SetUnixFileMode(string, UnixFileMode)reference
- Task WriteAllBytesAsync(string, byte[], CancellationToken)reference
- Task WriteAllBytesAsync(string, ReadOnlyMemory<byte>, CancellationToken)reference
- Task WriteAllLinesAsync(string, IEnumerable<string>, CancellationToken)reference
- Task WriteAllLinesAsync(string, IEnumerable<string>, Encoding, CancellationToken)reference
- void WriteAllText(string, ReadOnlySpan<char>, Encoding)reference
- void WriteAllText(string, ReadOnlySpan<char>)reference
- Task WriteAllTextAsync(string, string?, CancellationToken)reference
- Task WriteAllTextAsync(string, string?, Encoding, CancellationToken)reference
- Guid CreateVersion7()reference
- Guid CreateVersion7(DateTimeOffset)reference
- bool TryParse(ReadOnlySpan<char>, Guid)reference
- bool TryParse(ReadOnlySpan<char>, IFormatProvider?, Guid)reference
- bool TryParse(string?, IFormatProvider?, Guid)reference
- bool TryParseExact(ReadOnlySpan<char>, ReadOnlySpan<char>, Guid)reference
- bool TryParse(ReadOnlySpan<byte>, IFormatProvider?, int)reference
- bool TryParse(ReadOnlySpan<byte>, int)reference
- bool TryParse(ReadOnlySpan<byte>, NumberStyles, IFormatProvider?, int)reference
- bool TryParse(ReadOnlySpan<char>, IFormatProvider?, int)reference
- bool TryParse(ReadOnlySpan<char>, int)reference
- bool TryParse(ReadOnlySpan<char>, NumberStyles, IFormatProvider?, int)reference
- bool TryParse(string?, IFormatProvider?, int)reference
- bool TryParse(ReadOnlySpan<byte>, IFormatProvider?, long)reference
- bool TryParse(ReadOnlySpan<byte>, long)reference
- bool TryParse(ReadOnlySpan<byte>, NumberStyles, IFormatProvider?, long)reference
- bool TryParse(ReadOnlySpan<char>, IFormatProvider?, long)reference
- bool TryParse(ReadOnlySpan<char>, long)reference
- bool TryParse(ReadOnlySpan<char>, NumberStyles, IFormatProvider?, long)reference
- bool TryParse(string?, IFormatProvider?, long)reference
- byte Clamp(byte, byte, byte)reference
- decimal Clamp(decimal, decimal, decimal)reference
- double Clamp(double, double, double)reference
- float Clamp(float, float, float)reference
- int Clamp(int, int, int)reference
- long Clamp(long, long, long)reference
- nint Clamp(nint, nint, nint)reference
- nuint Clamp(nuint, nuint, nuint)reference
- sbyte Clamp(sbyte, sbyte, sbyte)reference
- short Clamp(short, short, short)reference
- uint Clamp(uint, uint, uint)reference
- ulong Clamp(ulong, ulong, ulong)reference
- ushort Clamp(ushort, ushort, ushort)reference
- bool IsAndroid()reference
- bool IsAndroidVersionAtLeast(int, int, int, int)reference
- bool IsBrowser()reference
- bool IsFreeBSD()reference
- bool IsFreeBSDVersionAtLeast(int, int, int, int)reference
- bool IsIOS()reference
- bool IsIOSVersionAtLeast(int, int, int)reference
- bool IsLinux()reference
- bool IsMacCatalyst()reference
- bool IsMacCatalystVersionAtLeast(int, int, int)reference
- bool IsMacOS()reference
- bool IsMacOSVersionAtLeast(int, int, int)reference
- bool IsOSPlatform(string)reference
- bool IsOSPlatformVersionAtLeast(string, int, int, int, int)reference
- bool IsTvOS()reference
- bool IsTvOSVersionAtLeast(int, int, int)reference
- bool IsWasi()reference
- bool IsWatchOS()reference
- bool IsWatchOSVersionAtLeast(int, int, int)reference
- bool IsWindows()reference
- bool IsWindowsVersionAtLeast(int, int, int, int)reference
- string Combine(ReadOnlySpan<string>)reference
- bool EndsInDirectorySeparator(ReadOnlySpan<char>)reference
- bool EndsInDirectorySeparator(string)reference
- bool Exists(string?)reference
- ReadOnlySpan<char> GetDirectoryName(ReadOnlySpan<char>)reference
- ReadOnlySpan<char> GetExtension(ReadOnlySpan<char>)reference
- ReadOnlySpan<char> GetFileName(ReadOnlySpan<char>)reference
- ReadOnlySpan<char> GetFileNameWithoutExtension(ReadOnlySpan<char>)reference
- bool HasExtension(ReadOnlySpan<char>)reference
- ReadOnlySpan<char> TrimEndingDirectorySeparator(ReadOnlySpan<char>)reference
- string TrimEndingDirectorySeparator(string)reference
- void Fill(Span<byte>)reference
- byte[] GetBytes(int)reference
- string GetHexString(int, bool)reference
- void GetHexString(Span<char>, bool)reference
- int GetInt32(int, int)reference
- int GetInt32(int)reference
- T[] GetItems<T>(ReadOnlySpan<T>, int)reference
- void GetItems<T>(ReadOnlySpan<T>, Span<T>)reference
- string GetString(ReadOnlySpan<char>, int)reference
- void Shuffle<T>(Span<T>)reference
- ValueMatchEnumerator EnumerateMatches(ReadOnlySpan<char>, string, RegexOptions, TimeSpan)reference
- ValueMatchEnumerator EnumerateMatches(ReadOnlySpan<char>, string, RegexOptions)reference
- ValueMatchEnumerator EnumerateMatches(ReadOnlySpan<char>, string)reference
- bool IsMatch(ReadOnlySpan<char>, string, RegexOptions, TimeSpan)reference
- bool IsMatch(ReadOnlySpan<char>, string, RegexOptions)reference
- bool IsMatch(ReadOnlySpan<char>, string)reference
- bool TryParse(ReadOnlySpan<byte>, IFormatProvider?, sbyte)reference
- bool TryParse(ReadOnlySpan<byte>, NumberStyles, IFormatProvider?, sbyte)reference
- bool TryParse(ReadOnlySpan<byte>, sbyte)reference
- bool TryParse(ReadOnlySpan<char>, IFormatProvider?, sbyte)reference
- bool TryParse(ReadOnlySpan<char>, NumberStyles, IFormatProvider?, sbyte)reference
- bool TryParse(ReadOnlySpan<char>, sbyte)reference
- bool TryParse(string?, IFormatProvider?, sbyte)reference
- byte[] HashData(byte[])reference
- int HashData(ReadOnlySpan<byte>, Span<byte>)reference
- byte[] HashData(ReadOnlySpan<byte>)reference
- int HashData(Stream, Span<byte>)reference
- byte[] HashData(Stream)reference
- ValueTask<byte[]> HashDataAsync(Stream, CancellationToken)reference
- ValueTask<int> HashDataAsync(Stream, Memory<byte>, CancellationToken)reference
- bool TryHashData(ReadOnlySpan<byte>, Span<byte>, int)reference
- byte[] HashData(byte[])reference
- int HashData(ReadOnlySpan<byte>, Span<byte>)reference
- byte[] HashData(ReadOnlySpan<byte>)reference
- int HashData(Stream, Span<byte>)reference
- byte[] HashData(Stream)reference
- ValueTask<byte[]> HashDataAsync(Stream, CancellationToken)reference
- ValueTask<int> HashDataAsync(Stream, Memory<byte>, CancellationToken)reference
- bool TryHashData(ReadOnlySpan<byte>, Span<byte>, int)reference
- bool TryParse(ReadOnlySpan<byte>, IFormatProvider?, short)reference
- bool TryParse(ReadOnlySpan<byte>, NumberStyles, IFormatProvider?, short)reference
- bool TryParse(ReadOnlySpan<byte>, short)reference
- bool TryParse(ReadOnlySpan<char>, IFormatProvider?, short)reference
- bool TryParse(ReadOnlySpan<char>, NumberStyles, IFormatProvider?, short)reference
- bool TryParse(ReadOnlySpan<char>, short)reference
- bool TryParse(string?, IFormatProvider?, short)reference
- string Join(char, object?[])reference
- string Join(char, ReadOnlySpan<object?>)reference
- string Join(char, ReadOnlySpan<string?>)reference
- string Join(char, string?[], int, int)reference
- string Join(char, string?[])reference
- string Join(string?, ReadOnlySpan<object?>)reference
- string Join(string?, ReadOnlySpan<string?>)reference
- string Join<T>(char, IEnumerable<T>)reference
- bool TryParse(ReadOnlySpan<byte>, IFormatProvider?, uint)reference
- bool TryParse(ReadOnlySpan<byte>, NumberStyles, IFormatProvider?, uint)reference
- bool TryParse(ReadOnlySpan<byte>, uint)reference
- bool TryParse(ReadOnlySpan<char>, IFormatProvider?, uint)reference
- bool TryParse(ReadOnlySpan<char>, NumberStyles, IFormatProvider?, uint)reference
- bool TryParse(ReadOnlySpan<char>, uint)reference
- bool TryParse(string?, IFormatProvider?, uint)reference
- bool TryParse(ReadOnlySpan<byte>, IFormatProvider?, ulong)reference
- bool TryParse(ReadOnlySpan<byte>, NumberStyles, IFormatProvider?, ulong)reference
- bool TryParse(ReadOnlySpan<byte>, ulong)reference
- bool TryParse(ReadOnlySpan<char>, IFormatProvider?, ulong)reference
- bool TryParse(ReadOnlySpan<char>, NumberStyles, IFormatProvider?, ulong)reference
- bool TryParse(ReadOnlySpan<char>, ulong)reference
- bool TryParse(string?, IFormatProvider?, ulong)reference
- bool TryParse(ReadOnlySpan<byte>, IFormatProvider?, ushort)reference
- bool TryParse(ReadOnlySpan<byte>, NumberStyles, IFormatProvider?, ushort)reference
- bool TryParse(ReadOnlySpan<byte>, ushort)reference
- bool TryParse(ReadOnlySpan<char>, IFormatProvider?, ushort)reference
- bool TryParse(ReadOnlySpan<char>, NumberStyles, IFormatProvider?, ushort)reference
- bool TryParse(ReadOnlySpan<char>, ushort)reference
- bool TryParse(string?, IFormatProvider?, ushort)reference
- void DirectoryExists(string)
- void FileExists(string)
- void NotEmpty(string?)
- void NotEmpty<T>(Memory<T>?)
- void NotEmpty<T>(Memory<T>)
- void NotEmpty<T>(ReadOnlyMemory<T>?)
- void NotEmpty<T>(ReadOnlyMemory<T>)
- void NotEmpty<T>(ReadOnlySpan<T>)
- void NotEmpty<T>(Span<T>)
- void NotEmpty<T>(T?) where T : IEnumerable
- string NotNull(string?)
- T NotNull<T>(T?) where T : class
- Memory<char> NotNullOrEmpty(Memory<char>?)
- ReadOnlyMemory<char> NotNullOrEmpty(ReadOnlyMemory<char>?)
- string NotNullOrEmpty(string?)
- T NotNullOrEmpty<T>(T?) where T : IEnumerable
- Memory<char> NotNullOrWhiteSpace(Memory<char>?)
- ReadOnlyMemory<char> NotNullOrWhiteSpace(ReadOnlyMemory<char>?)
- string NotNullOrWhiteSpace(string?)
- void NotWhiteSpace(Memory<char>?)
- void NotWhiteSpace(ReadOnlyMemory<char>?)
- void NotWhiteSpace(ReadOnlySpan<char>)
- void NotWhiteSpace(Span<char>)
- void NotWhiteSpace(string?)
- void Enter()
- Scope EnterScope()
- void Exit()
- bool TryEnter()
- bool TryEnter(int)
- bool TryEnter(TimeSpan)
- KeyValuePair<TKey, TValue> Create<TKey, TValue>(TKey, TValue)reference
If any of the below reference are not included, the related polyfills will be disabled.
If consuming in a project that targets net461 or net462, a reference to System.ValueTuple nuget is required.
<PackageReference Include="System.ValueTuple"
                  Version="4.5.0"
                  Condition="$(TargetFramework.StartsWith('net46'))" />If using Span APIs and consuming in a project that targets netstandard, netframework, or netcoreapp2*, a reference to System.Memory nuget is required.
<PackageReference Include="System.Memory"
                  Version="4.5.5"
                  Condition="$(TargetFrameworkIdentifier) == '.NETStandard' or
                             $(TargetFrameworkIdentifier) == '.NETFramework' or
                             $(TargetFramework.StartsWith('netcoreapp2'))" />If using ValueTask APIs and consuming in a project that target netframework, netstandard2, or netcoreapp2, a reference to System.Threading.Tasks.Extensions nuget is required.
<PackageReference Include="System.Threading.Tasks.Extensions"
                  Version="4.5.4"
                  Condition="$(TargetFramework) == 'netstandard2.0' or
                             $(TargetFramework) == 'netcoreapp2.0' or
                             $(TargetFrameworkIdentifier) == '.NETFramework'" />If using the RuntimeInformation class or OSPlatform struct and consuming in a project that targets netframework, a reference to System.Runtime.InteropServices.RuntimeInformation nuget is required.
<PackageReference Include="System.Runtime.InteropServices.RuntimeInformation"
                  Version="4.3.0"
                  Condition="$(TargetFrameworkIdentifier) == '.NETFramework'" />Enable by adding an MSBuild property PolyNullability
<PropertyGroup>
  ...
  <PolyNullability>true</PolyNullability>
</PropertyGroup>
Given the following class
class NullabilityTarget
{
    public string? StringField;
    public string?[] ArrayField;
    public Dictionary<string, object?> GenericField;
}[Test]
public void Test()
{
    var type = typeof(NullabilityTarget);
    var arrayField = type.GetField("ArrayField")!;
    var genericField = type.GetField("GenericField")!;
    var context = new NullabilityInfoContext();
    var arrayInfo = context.Create(arrayField);
    Assert.AreEqual(NullabilityState.NotNull, arrayInfo.ReadState);
    Assert.AreEqual(NullabilityState.Nullable, arrayInfo.ElementType!.ReadState);
    var genericInfo = context.Create(genericField);
    Assert.AreEqual(NullabilityState.NotNull, genericInfo.ReadState);
    Assert.AreEqual(NullabilityState.NotNull, genericInfo.GenericTypeArguments[0].ReadState);
    Assert.AreEqual(NullabilityState.Nullable, genericInfo.GenericTypeArguments[1].ReadState);
}NullabilityInfoExtensions provides static and thread safe wrapper around NullabilityInfoContext. It adds three extension methods to each of ParameterInfo, PropertyInfo, EventInfo, and FieldInfo.
- GetNullabilityInfo: returns the- NullabilityInfofor the target info.
- GetNullability: returns the- NullabilityStatefor the state (- NullabilityInfo.ReadStateor- NullabilityInfo.WriteStatedepending on which has more info) of target info.
- IsNullable: given the state (- NullabilityInfo.ReadStateor- NullabilityInfo.WriteStatedepending on which has more info) of the info:- Returns true if state is NullabilityState.Nullable.
- Returns false if state is NullabilityState.NotNull.
- Throws an exception if state is NullabilityState.Unknown.
 
- Returns true if state is 
Enable by adding an MSBuild property PolyGuard
<PropertyGroup>
  ...
  <PolyGuard>true</PolyGuard>
</PropertyGroup>
Guard is designed to be a an alternative to the Argument*Exception.ThrowIf* APIs added in net7.
- ArgumentException.ThrowIf*reference
- ArgumentNullException.ThrowIf*reference
- ArgumentOutOfRangeException.ThrowIf*reference
With the equivalent Guard APIs:
- Guard.NotNullOrEmpty
- Guard.NotNullOrWhiteSpace
- Guard.NotNull
Polyfills.Guard provides the following APIs:
- void DirectoryExists(String)
- void FileExists(String)
- void NotEmpty(String)
- void NotEmpty<T>(ReadOnlySpan<T>)
- void NotEmpty<T>(Span<T>)
- void NotEmpty<T>(Nullable<Memory<T>>)
- void NotEmpty<T>(Memory<T>)
- void NotEmpty<T>(Nullable<ReadOnlyMemory<T>>)
- void NotEmpty<T>(ReadOnlyMemory<T>)
- void NotEmpty<T>(T) where T : Collections.IEnumerable
- T NotNull<T>(T)
- String NotNull(String)
- String NotNullOrEmpty(String)
- T NotNullOrEmpty<T>(T) where T : Collections.IEnumerable
- Memory<Char> NotNullOrEmpty(Nullable<Memory<Char>>)
- ReadOnlyMemory<Char> NotNullOrEmpty(Nullable<ReadOnlyMemory<Char>>)
- String NotNullOrWhiteSpace(String)
- Memory<Char> NotNullOrWhiteSpace(Nullable<Memory<Char>>)
- ReadOnlyMemory<Char> NotNullOrWhiteSpace(Nullable<ReadOnlyMemory<Char>>)
- void NotWhiteSpace(String)
- void NotWhiteSpace(ReadOnlySpan<Char>)
- void NotWhiteSpace(Nullable<Memory<Char>>)
- void NotWhiteSpace(Nullable<ReadOnlyMemory<Char>>)
- void NotWhiteSpace(Span<Char>)
https://github.com/Tyrrrz/PolyShim
https://github.com/Sergio0694/PolySharp
https://github.com/theraot/Theraot
- https://github.com/manuelroemer/Nullable
- https://github.com/bgrainger/IndexRange
- https://github.com/manuelroemer/IsExternalInit
PolySharp uses c# source generators. In my opinion a "source-only package" implementation is better because:
- Simpler implementation
- Easier to debug if something goes wrong.
- Uses less memory at compile time. Since there is no source generator assembly to load.
- Faster at compile time. Since no source generator is required to execute.
The combination of the other 3 packages is not ideal because:
- Required multiple packages to be referenced.
- Does not cover all the scenarios included in this package.
Crack designed by Adrien Coquet from The Noun Project.
