Polyfill
May 8, 2026 · View on GitHub
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,net481netcoreapp2.0,netcoreapp2.1,netcoreapp3.0,netcoreapp3.1net5.0,net6.0,net7.0,net8.0,net9.0,net10.0,net11.0uap10
API count: 937
Per Target Framework
| Target | APIs |
|---|---|
net461 | 907 |
net462 | 907 |
net47 | 906 |
net471 | 905 |
net472 | 901 |
net48 | 901 |
net481 | 901 |
netstandard2.0 | 903 |
netstandard2.1 | 734 |
netcoreapp2.0 | 827 |
netcoreapp2.1 | 746 |
netcoreapp2.2 | 746 |
netcoreapp3.0 | 692 |
netcoreapp3.1 | 691 |
net5.0 | 563 |
net6.0 | 468 |
net7.0 | 315 |
net8.0 | 197 |
net9.0 | 128 |
net10.0 | 76 |
net11.0 | 57 |
uap10.0 | 893 |
See Milestones for release notes.
Powered by
Nuget
TargetFrameworks
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
SDK / LangVersion
This project uses features from the current stable SDK and C# language. As such consuming projects should target those:
LangVersion
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<LangVersion>latest</LangVersion>
global.json
{
"sdk": {
"version": "10.0.100",
"rollForward": "latestFeature"
}
}
Assembly size impact
Assembly Sizes
| Empty Assembly | With Polyfill | Diff | Ensure | ArgumentExceptions | StringInterpolation | Nullability | |
|---|---|---|---|---|---|---|---|
| netstandard2.0 | 8.0KB | 306.5KB | +298.5KB | +9.0KB | +6.5KB | +9.0KB | +14.0KB |
| netstandard2.1 | 8.5KB | 259.5KB | +251.0KB | +9.0KB | +6.5KB | +9.0KB | +14.0KB |
| net461 | 8.5KB | 305.0KB | +296.5KB | +9.0KB | +6.5KB | +9.0KB | +14.0KB |
| net462 | 7.0KB | 308.5KB | +301.5KB | +9.0KB | +6.5KB | +9.0KB | +14.0KB |
| net47 | 7.0KB | 308.5KB | +301.5KB | +9.0KB | +6.5KB | +9.0KB | +14.0KB |
| net471 | 8.5KB | 307.5KB | +299.0KB | +9.0KB | +6.5KB | +9.0KB | +14.0KB |
| net472 | 8.5KB | 306.0KB | +297.5KB | +9.0KB | +7.0KB | +9.5KB | +14.0KB |
| net48 | 8.5KB | 306.0KB | +297.5KB | +9.0KB | +6.5KB | +9.5KB | +14.0KB |
| net481 | 8.5KB | 306.5KB | +298.0KB | +8.5KB | +6.5KB | +9.0KB | +13.5KB |
| netcoreapp2.0 | 9.0KB | 282.5KB | +273.5KB | +9.0KB | +6.5KB | +9.0KB | +14.0KB |
| netcoreapp2.1 | 9.0KB | 262.0KB | +253.0KB | +9.0KB | +6.5KB | +9.0KB | +13.5KB |
| netcoreapp2.2 | 9.0KB | 262.0KB | +253.0KB | +9.0KB | +7.0KB | +9.0KB | +13.5KB |
| netcoreapp3.0 | 9.5KB | 253.5KB | +244.0KB | +9.0KB | +6.5KB | +9.0KB | +13.5KB |
| netcoreapp3.1 | 9.5KB | 251.5KB | +242.0KB | +9.0KB | +6.5KB | +9.0KB | +14.0KB |
| net5.0 | 9.5KB | 214.5KB | +205.0KB | +9.5KB | +7.0KB | +9.5KB | +14.5KB |
| net6.0 | 10.0KB | 153.0KB | +143.0KB | +10.0KB | +7.0KB | +512bytes | +4.0KB |
| net7.0 | 10.0KB | 118.0KB | +108.0KB | +9.0KB | +5.5KB | +512bytes | +3.5KB |
| net8.0 | 9.5KB | 89.5KB | +80.0KB | +8.5KB | +512bytes | +512bytes | +3.5KB |
| net9.0 | 9.5KB | 47.5KB | +38.0KB | +9.0KB | +512bytes | +3.5KB | |
| net10.0 | 10.0KB | 24.0KB | +14.0KB | +9.0KB | +512bytes | +3.5KB | |
| net11.0 | 10.0KB | 18.5KB | +8.5KB | +9.0KB | +512bytes | +3.5KB |
Assembly Sizes with EmbedUntrackedSources
| Empty Assembly | With Polyfill | Diff | Ensure | ArgumentExceptions | StringInterpolation | Nullability | |
|---|---|---|---|---|---|---|---|
| netstandard2.0 | 8.0KB | 446.3KB | +438.3KB | +16.7KB | +8.2KB | +13.9KB | +19.4KB |
| netstandard2.1 | 8.5KB | 374.1KB | +365.6KB | +16.7KB | +8.2KB | +13.9KB | +19.4KB |
| net461 | 8.5KB | 445.8KB | +437.3KB | +16.7KB | +8.2KB | +13.9KB | +19.4KB |
| net462 | 7.0KB | 449.3KB | +442.3KB | +16.7KB | +8.2KB | +13.9KB | +19.4KB |
| net47 | 7.0KB | 449.1KB | +442.1KB | +16.7KB | +8.2KB | +13.9KB | +19.4KB |
| net471 | 8.5KB | 447.7KB | +439.2KB | +16.7KB | +8.2KB | +13.9KB | +19.4KB |
| net472 | 8.5KB | 445.1KB | +436.6KB | +16.7KB | +8.7KB | +14.4KB | +19.4KB |
| net48 | 8.5KB | 445.1KB | +436.6KB | +16.7KB | +8.2KB | +14.4KB | +19.4KB |
| net481 | 8.5KB | 445.6KB | +437.1KB | +16.2KB | +8.2KB | +13.9KB | +18.9KB |
| netcoreapp2.0 | 9.0KB | 412.4KB | +403.4KB | +16.7KB | +8.2KB | +13.9KB | +19.4KB |
| netcoreapp2.1 | 9.0KB | 380.8KB | +371.8KB | +16.7KB | +8.2KB | +13.9KB | +18.9KB |
| netcoreapp2.2 | 9.0KB | 380.8KB | +371.8KB | +16.7KB | +8.7KB | +13.9KB | +18.9KB |
| netcoreapp3.0 | 9.5KB | 363.0KB | +353.5KB | +16.7KB | +8.2KB | +13.9KB | +18.9KB |
| netcoreapp3.1 | 9.5KB | 360.9KB | +351.4KB | +16.7KB | +8.2KB | +13.9KB | +19.4KB |
| net5.0 | 9.5KB | 305.8KB | +296.3KB | +17.2KB | +8.7KB | +14.4KB | +19.9KB |
| net6.0 | 10.0KB | 224.7KB | +214.7KB | +17.7KB | +8.7KB | +1.1KB | +4.7KB |
| net7.0 | 10.0KB | 170.9KB | +160.9KB | +16.6KB | +6.9KB | +1.1KB | +4.2KB |
| net8.0 | 9.5KB | 127.6KB | +118.1KB | +16.0KB | +811bytes | +1.1KB | +4.2KB |
| net9.0 | 9.5KB | 68.6KB | +59.1KB | +16.5KB | +1.1KB | +4.2KB | |
| net10.0 | 10.0KB | 36.5KB | +26.5KB | +16.5KB | +1.1KB | +4.2KB | |
| net11.0 | 10.0KB | 27.4KB | +17.4KB | +16.5KB | +1.1KB | +4.2KB |
PolyfillLib
To consume Polyfill as a library (instead of a source-only package) see PolyfillLib
Troubleshooting
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.
Included polyfills
ModuleInitializerAttribute
Reference: Module Initializers
static bool InitCalled;
[Test]
public async Task ModuleInitTest() =>
await Assert.That(InitCalled).IsTrue();
[ModuleInitializer]
public static void ModuleInit() =>
InitCalled = true;
IsExternalInit
Reference: init (C# Reference)
class InitSample
{
public int Member { get; init; }
}
Nullable attributes
- AllowNullAttribute
- DisallowNullAttribute
- DoesNotReturnAttribute
- DoesNotReturnIfAttribute
- MaybeNullAttribute
- MaybeNullWhenAttribute
- MemberNotNullAttribute
- MemberNotNullWhenAttribute
- NotNullAttribute
- NotNullIfNotNullAttribute
- NotNullWhenAttribute
Reference: Nullable reference types
Required attributes
Reference: C# required modifier
public class Person
{
public Person()
{
}
[SetsRequiredMembers]
public Person(string name) =>
Name = name;
public required string Name { get; init; }
}
CompilerFeatureRequiredAttribute
Indicates that compiler support for a particular feature is required for the location where this attribute is applied.
CollectionBuilderAttribute
Can be used to make types compatible with collection expressions
ConstantExpectedAttribute
Indicates that the specified method parameter expects a constant.
SkipLocalsInit
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]);
}
}
}
Index and Range
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.
class IndexRangeSample
{
[Test]
public async Task Range()
{
var substring = "value"[2..];
await Assert.That(substring).IsEqualTo("lue");
}
[Test]
public async Task Index()
{
var ch = "value"[^2];
await Assert.That(ch).IsEqualTo('u');
}
[Test]
public async Task ArrayIndex()
{
var array = new[]
{
"value1",
"value2"
};
var value = array[^2];
await Assert.That(value).IsEqualTo("value1");
}
}
OverloadResolutionPriority
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.
Usage
public class OverloadResolutionPriorityAttributeTests
{
[Test]
public Task Run()
{
int[] arr = [1, 2, 3];
//Prints "Span" because resolution priority is higher
Method(arr);
return Task.CompletedTask;
}
[OverloadResolutionPriority(2)]
static void Method(ReadOnlySpan<int> list) =>
Console.WriteLine("Span");
[OverloadResolutionPriority(1)]
static void Method(int[] list) =>
Console.WriteLine("Array");
}
UnscopedRefAttribute
Reference: Low Level Struct Improvements
struct UnscopedRefUsage
{
int field1;
[UnscopedRef] ref int Prop1 => ref field1;
}
RequiresPreviewFeaturesAttribute
CallerArgumentExpressionAttribute
Reference: CallerArgumentExpression
static class FileUtil
{
public static void FileExists(string path, [CallerArgumentExpression("path")] string name = "")
{
if (!File.Exists(path))
{
throw new ArgumentException($"File not found. Path: {path}", name);
}
}
}
static class FileUtilUsage
{
public static string[] Method(string path)
{
FileUtil.FileExists(path);
return File.ReadAllLines(path);
}
}
InterpolatedStringHandler
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.
StringSyntaxAttribute
Reference: .NET 7 - The StringSyntaxAttribute
Trimming annotation attributes
- DynamicallyAccessedMembersAttribute
- DynamicDependencyAttribute
- RequiresUnreferencedCodeAttribute
- RequiresDynamicCodeAttribute
- UnconditionalSuppressMessageAttribute
Reference: Prepare .NET libraries for trimming
Platform compatibility
- ObsoletedOSPlatformAttribute
- SupportedOSPlatformAttribute
- SupportedOSPlatformGuardAttribute
- TargetPlatformAttribute
- UnsupportedOSPlatformAttribute
- UnsupportedOSPlatformGuardAttribute
Reference: Platform compatibility analyzer
StackTraceHiddenAttribute
Reference: C# – Hide a method from the stack trace
UnmanagedCallersOnly
Reference: Improvements in native code interop in .NET 5.0
SuppressGCTransition
DisableRuntimeMarshalling
Extensions
The class Polyfill includes the following extension methods:
Extension methods
ArgumentException
ArgumentNullException
ArgumentOutOfRangeException
void ThrowIfEqual<T>(T, T) where T : IEquatable<T>?referencevoid ThrowIfGreaterThan(nint, nint)void ThrowIfGreaterThan<T>(T, T) where T : IComparable<T>referencevoid ThrowIfGreaterThanOrEqual(nint, nint)void ThrowIfGreaterThanOrEqual<T>(T, T) where T : IComparable<T>referencevoid ThrowIfLessThan(nint, nint)void ThrowIfLessThan<T>(T, T) where T : IComparable<T>referencevoid ThrowIfLessThanOrEqual(nint, nint)void ThrowIfLessThanOrEqual<T>(T, T) where T : IComparable<T>referencevoid ThrowIfNegative(nint)referencevoid ThrowIfNegative<T>(T) where T : struct, IComparable<T>referencevoid ThrowIfNegativeOrZero(nint)void ThrowIfNegativeOrZero<T>(T) where T : struct, IComparable<T>referencevoid ThrowIfNotEqual<T>(T, T) where T : IEquatable<T>?referencevoid ThrowIfZero(nint)void ThrowIfZero<T>(T) where T : struct, IEquatable<T>reference
ArraySegment
void CopyTo<T>(ArraySegment<T>)referencevoid CopyTo<T>(T[], int)referencevoid CopyTo<T>(T[])referenceArraySegmentEnumerator<T> GetEnumerator<T>()reference
BinaryPrimitives
double ReadDoubleBigEndian(ReadOnlySpan<byte>)referencedouble ReadDoubleLittleEndian(ReadOnlySpan<byte>)referencefloat ReadSingleBigEndian(ReadOnlySpan<byte>)referencefloat ReadSingleLittleEndian(ReadOnlySpan<byte>)referencebool TryReadDoubleBigEndian(ReadOnlySpan<byte>, double)referencebool TryReadDoubleLittleEndian(ReadOnlySpan<byte>, double)referencebool TryReadSingleBigEndian(ReadOnlySpan<byte>, float)referencebool TryReadSingleLittleEndian(ReadOnlySpan<byte>, float)referencebool TryWriteDoubleBigEndian(Span<byte>, double)referencebool TryWriteDoubleLittleEndian(Span<byte>, double)referencebool TryWriteSingleBigEndian(Span<byte>, float)referencebool TryWriteSingleLittleEndian(Span<byte>, float)referencevoid WriteDoubleBigEndian(Span<byte>, double)referencevoid WriteDoubleLittleEndian(Span<byte>, double)referencevoid WriteSingleBigEndian(Span<byte>, float)referencevoid WriteSingleLittleEndian(Span<byte>, float)reference
Boolean
bool TryFormat(Span<char>, int)reference
Byte
bool TryFormat(Span<byte>, int, ReadOnlySpan<char>, IFormatProvider?)referencebool TryFormat(Span<char>, int, ReadOnlySpan<char>, IFormatProvider?)referencebool TryParse(ReadOnlySpan<byte>, byte)referencebool TryParse(ReadOnlySpan<byte>, IFormatProvider?, byte)referencebool TryParse(ReadOnlySpan<byte>, NumberStyles, IFormatProvider?, byte)referencebool TryParse(ReadOnlySpan<char>, byte)referencebool TryParse(ReadOnlySpan<char>, IFormatProvider?, byte)referencebool TryParse(ReadOnlySpan<char>, NumberStyles, IFormatProvider?, byte)referencebool TryParse(string?, IFormatProvider?, byte)reference
CancellationToken
CancellationTokenRegistration Register(Action<object?, CancellationToken>, object?)referenceCancellationTokenRegistration UnsafeRegister(Action<object?, CancellationToken>, object?)referenceCancellationTokenRegistration UnsafeRegister(Action<object?>, object?)reference
CancellationTokenSource
Task CancelAsync()reference
Capture
ValueSpanreference
Char
bool Equals(char, StringComparison)referencebool IsAscii(char)referencebool IsAsciiDigit(char)referencebool IsAsciiHexDigit(char)referencebool IsAsciiHexDigitLower(char)referencebool IsAsciiHexDigitUpper(char)referencebool IsAsciiLetter(char)referencebool IsAsciiLetterLower(char)referencebool IsAsciiLetterOrDigit(char)referencebool IsAsciiLetterUpper(char)referencebool IsBetween(char, char, char)reference
ConcurrentBag
void Clear<T>()reference
ConcurrentDictionary<TKey, TValue>
TValue GetOrAdd<TKey, TValue, TArg>(TKey, Func<TKey, TArg, TValue>, TArg) where TKey : notnullreference
ConcurrentQueue
void Clear<T>()reference
Console
SafeFileHandle OpenStandardErrorHandle()referenceSafeFileHandle OpenStandardInputHandle()referenceSafeFileHandle OpenStandardOutputHandle()reference
Convert
OperationStatus FromHexString(ReadOnlySpan<byte>, Span<byte>, int, int)referencebyte[] FromHexString(ReadOnlySpan<byte>)referenceOperationStatus FromHexString(ReadOnlySpan<char>, Span<byte>, int, int)referencebyte[] FromHexString(ReadOnlySpan<char>)referenceOperationStatus FromHexString(string, Span<byte>, int, int)referencebyte[] FromHexString(string)referencestring ToHexString(byte[], int, int)referencestring ToHexString(byte[])referencestring ToHexString(ReadOnlySpan<byte>)referencestring ToHexStringLower(byte[], int, int)referencestring ToHexStringLower(byte[])referencestring ToHexStringLower(ReadOnlySpan<byte>)referencebool TryFromBase64Chars(ReadOnlySpan<char>, Span<byte>, int)referencebool TryFromBase64String(string, Span<byte>, int)referencebool TryToBase64Chars(ReadOnlySpan<byte>, Span<char>, int, Base64FormattingOptions)referencebool TryToHexString(ReadOnlySpan<byte>, Span<byte>, int)referencebool TryToHexString(ReadOnlySpan<byte>, Span<char>, int)referencebool TryToHexStringLower(ReadOnlySpan<byte>, Span<byte>, int)referencebool TryToHexStringLower(ReadOnlySpan<byte>, Span<char>, int)reference
DateOnly
void Deconstruct(int, int, int)referencebool TryFormat(Span<byte>, int, ReadOnlySpan<char>, IFormatProvider?)referencebool TryFormat(Span<char>, int, ReadOnlySpan<char>, IFormatProvider?)reference
DateTime
DateTime AddMicroseconds(double)referencevoid Deconstruct(DateOnly, TimeOnly)referencevoid Deconstruct(int, int, int)referencebool TryFormat(Span<byte>, int, ReadOnlySpan<char>, IFormatProvider?)referencebool TryFormat(Span<char>, int, ReadOnlySpan<char>, IFormatProvider?)referencebool TryParse(ReadOnlySpan<char>, DateTime)referencebool TryParse(ReadOnlySpan<char>, IFormatProvider?, DateTime)referencebool TryParse(ReadOnlySpan<char>, IFormatProvider?, DateTimeStyles, DateTime)referencebool TryParse(string?, IFormatProvider?, DateTime)referencebool TryParseExact(ReadOnlySpan<char>, ReadOnlySpan<char>, IFormatProvider?, DateTimeStyles, DateTime)referencebool TryParseExact(ReadOnlySpan<char>, string, IFormatProvider?, DateTimeStyles, DateTime)referenceMicrosecondreferenceNanosecondreference
DateTimeOffset
DateTimeOffset AddMicroseconds(double)referencevoid Deconstruct(DateOnly, TimeOnly, TimeSpan)referencebool TryFormat(Span<byte>, int, ReadOnlySpan<char>, IFormatProvider?)referencebool TryFormat(Span<char>, int, ReadOnlySpan<char>, IFormatProvider?)referencebool TryParse(ReadOnlySpan<char>, DateTimeOffset)referencebool TryParse(ReadOnlySpan<char>, IFormatProvider?, DateTimeOffset)referencebool TryParse(ReadOnlySpan<char>, IFormatProvider?, DateTimeStyles, DateTimeOffset)referencebool TryParse(string?, IFormatProvider?, DateTimeOffset)referencebool TryParseExact(ReadOnlySpan<char>, ReadOnlySpan<char>, IFormatProvider?, DateTimeStyles, DateTimeOffset)referencebool TryParseExact(ReadOnlySpan<char>, string, IFormatProvider?, DateTimeStyles, DateTimeOffset)referenceMicrosecondreferenceNanosecondreference
Decimal
bool TryFormat(Span<byte>, int, ReadOnlySpan<char>, IFormatProvider?)referencebool TryFormat(Span<char>, int, ReadOnlySpan<char>, IFormatProvider?)referencebool TryParse(ReadOnlySpan<byte>, decimal)referencebool TryParse(ReadOnlySpan<byte>, IFormatProvider?, decimal)referencebool TryParse(ReadOnlySpan<byte>, NumberStyles, IFormatProvider?, decimal)referencebool TryParse(ReadOnlySpan<char>, decimal)referencebool TryParse(ReadOnlySpan<char>, IFormatProvider?, decimal)referencebool TryParse(ReadOnlySpan<char>, NumberStyles, IFormatProvider?, decimal)referencebool TryParse(string?, IFormatProvider?, decimal)reference
DefaultInterpolatedStringHandler
void Clear()reference
Delegate
InvocationListEnumerator<TDelegate> EnumerateInvocationList<TDelegate>(TDelegate?) where TDelegate : DelegatereferenceHasSingleTargetreference
Dictionary<TKey, TValue>
void EnsureCapacity<TKey, TValue>(int)referencevoid TrimExcess<TKey, TValue>(int)referencevoid TrimExcess<TKey, TValue>()reference
DictionaryEntry
void Deconstruct(object, object?)reference
Directory
DirectoryInfo CreateTempSubdirectory(string?)referenceIEnumerable<string> EnumerateDirectories(string, string, EnumerationOptions)referenceIEnumerable<string> EnumerateFiles(string, string, EnumerationOptions)referenceIEnumerable<string> EnumerateFileSystemEntries(string, string, EnumerationOptions)referencestring[] GetDirectories(string, string, EnumerationOptions)referencestring[] GetFiles(string, string, EnumerationOptions)referencestring[] GetFileSystemEntries(string, string, EnumerationOptions)reference
DirectoryInfo
IEnumerable<DirectoryInfo> EnumerateDirectories(string, EnumerationOptions)referenceIEnumerable<FileInfo> EnumerateFiles(string, EnumerationOptions)referenceIEnumerable<FileSystemInfo> EnumerateFileSystemInfos(string, EnumerationOptions)referenceDirectoryInfo[] GetDirectories(string, EnumerationOptions)referenceFileInfo[] GetFiles(string, EnumerationOptions)referenceFileSystemInfo[] GetFileSystemInfos(string, EnumerationOptions)reference
Double
ulong DoubleToUInt64Bits(double)bool TryFormat(Span<byte>, int, ReadOnlySpan<char>, IFormatProvider?)referencebool TryFormat(Span<char>, int, ReadOnlySpan<char>, IFormatProvider?)referencebool TryParse(ReadOnlySpan<byte>, double)referencebool TryParse(ReadOnlySpan<byte>, IFormatProvider?, double)referencebool TryParse(ReadOnlySpan<byte>, NumberStyles, IFormatProvider?, double)referencebool TryParse(ReadOnlySpan<char>, double)referencebool TryParse(ReadOnlySpan<char>, IFormatProvider?, double)referencebool TryParse(ReadOnlySpan<char>, NumberStyles, IFormatProvider?, double)referencebool TryParse(string?, IFormatProvider?, double)reference
Encoding
int GetByteCount(ReadOnlySpan<char>)referenceint GetBytes(ReadOnlySpan<char>, Span<byte>)referenceint GetCharCount(ReadOnlySpan<byte>)referenceint GetChars(ReadOnlySpan<byte>, Span<char>)referencestring GetString(ReadOnlySpan<byte>)referencebool TryGetBytes(ReadOnlySpan<char>, Span<byte>, int)referencebool TryGetChars(ReadOnlySpan<byte>, Span<char>, int)referenceLatin1reference
Enum
string[] GetNames<TEnum>() where TEnum : struct, EnumreferenceTEnum[] GetValues<TEnum>() where TEnum : struct, EnumreferenceArray GetValuesAsUnderlyingType(Type)referenceArray GetValuesAsUnderlyingType<TEnum>() where TEnum : struct, Enumreferencebool IsDefined<TEnum>(TEnum) where TEnum : struct, EnumreferenceTEnum Parse<TEnum>(ReadOnlySpan<char>, bool) where TEnum : struct, EnumreferenceTEnum Parse<TEnum>(ReadOnlySpan<char>) where TEnum : struct, EnumreferenceTEnum Parse<TEnum>(string, bool) where TEnum : struct, EnumreferenceTEnum Parse<TEnum>(string) where TEnum : struct, Enumreferencebool TryFormat<TEnum>(TEnum, Span<char>, int, ReadOnlySpan<char>) where TEnum : struct, Enumreferencebool TryParse<TEnum>(ReadOnlySpan<char>, bool, TEnum) where TEnum : struct, Enumreferencebool TryParse<TEnum>(ReadOnlySpan<char>, TEnum) where TEnum : struct, Enumreference
Enumerable
IEnumerable<T> InfiniteSequence<T>(T, T) where T : IAdditionOperators<T, T, T>referenceIEnumerable<T> Sequence<T>(T, T, T) where T : INumber<T>reference
Environment
EqualityComparer
EqualityComparer<T> Create(Func<T?, T?, bool>, Func<T, int>?)reference
EventInfo
NullabilityState GetNullability()NullabilityInfo GetNullabilityInfo()bool IsNullable()
ExceptionDispatchInfo
Exception SetCurrentStackTrace(Exception)reference
FieldInfo
NullabilityState GetNullability()NullabilityInfo GetNullabilityInfo()bool IsNullable()
File
void AppendAllBytes(string, byte[])referencevoid AppendAllBytes(string, ReadOnlySpan<byte>)referenceTask AppendAllBytesAsync(string, byte[], CancellationToken)referenceTask AppendAllBytesAsync(string, ReadOnlyMemory<byte>, CancellationToken)referenceTask AppendAllLinesAsync(string, IEnumerable<string>, CancellationToken)referenceTask AppendAllLinesAsync(string, IEnumerable<string>, Encoding, CancellationToken)referencevoid AppendAllText(string, ReadOnlySpan<char>, Encoding)referencevoid AppendAllText(string, ReadOnlySpan<char>)referenceTask AppendAllTextAsync(string, ReadOnlyMemory<char>, CancellationToken)referenceTask AppendAllTextAsync(string, ReadOnlyMemory<char>, Encoding, CancellationToken)referenceTask AppendAllTextAsync(string, string?, CancellationToken)referenceTask AppendAllTextAsync(string, string?, Encoding, CancellationToken)referenceFileSystemInfo CreateHardLink(string, string)referencevoid Move(string, string, bool)referenceSafeFileHandle OpenNullHandle()referenceTask<byte[]> ReadAllBytesAsync(string, CancellationToken)referenceTask<string[]> ReadAllLinesAsync(string, CancellationToken)referenceTask<string[]> ReadAllLinesAsync(string, Encoding, CancellationToken)referenceTask<string> ReadAllTextAsync(string, CancellationToken)referenceTask<string> ReadAllTextAsync(string, Encoding, CancellationToken)referenceIAsyncEnumerable<string> ReadLinesAsync(string, CancellationToken)referenceIAsyncEnumerable<string> ReadLinesAsync(string, Encoding, CancellationToken)referenceTask WriteAllBytesAsync(string, byte[], CancellationToken)referenceTask WriteAllBytesAsync(string, ReadOnlyMemory<byte>, CancellationToken)referenceTask WriteAllLinesAsync(string, IEnumerable<string>, CancellationToken)referenceTask WriteAllLinesAsync(string, IEnumerable<string>, Encoding, CancellationToken)referencevoid WriteAllText(string, ReadOnlySpan<char>, Encoding)referencevoid WriteAllText(string, ReadOnlySpan<char>)referenceTask WriteAllTextAsync(string, string?, CancellationToken)referenceTask WriteAllTextAsync(string, string?, Encoding, CancellationToken)reference
FileInfo
void CreateAsHardLink(string)reference
FileUnixMode
GC
T[] AllocateUninitializedArray<T>(int, bool)reference
Guid
bool TryFormat(Span<byte>, int, ReadOnlySpan<char>)referencebool TryFormat(Span<char>, int, ReadOnlySpan<char>)referenceGuid CreateVersion7()referenceGuid CreateVersion7(DateTimeOffset)referenceGuid Parse(ReadOnlySpan<byte>)referencebool TryParse(ReadOnlySpan<byte>, Guid)referencebool TryParse(ReadOnlySpan<char>, Guid)referencebool TryParse(ReadOnlySpan<char>, IFormatProvider?, Guid)referencebool TryParse(string?, IFormatProvider?, Guid)referencebool TryParseExact(ReadOnlySpan<char>, ReadOnlySpan<char>, Guid)referenceAllBitsSetreference
HashSet
void EnsureCapacity<T>(int)referencevoid TrimExcess<T>(int)referencebool TryGetValue<T>(T, T)reference
HttpClient
Task<byte[]> GetByteArrayAsync(string, CancellationToken)referenceTask<byte[]> GetByteArrayAsync(Uri, CancellationToken)referenceTask<Stream> GetStreamAsync(string, CancellationToken)referenceTask<Stream> GetStreamAsync(Uri, CancellationToken)referenceTask<string> GetStringAsync(string, CancellationToken)referenceTask<string> GetStringAsync(Uri, CancellationToken)referenceTask<HttpResponseMessage> PatchAsync(string?, HttpContent?, CancellationToken)referenceTask<HttpResponseMessage> PatchAsync(string?, HttpContent?)referenceTask<HttpResponseMessage> PatchAsync(Uri?, HttpContent?, CancellationToken)referenceTask<HttpResponseMessage> PatchAsync(Uri?, HttpContent?)referenceHttpResponseMessage Send(HttpRequestMessage, CancellationToken)referenceHttpResponseMessage Send(HttpRequestMessage, HttpCompletionOption, CancellationToken)referenceHttpResponseMessage Send(HttpRequestMessage, HttpCompletionOption)referenceHttpResponseMessage Send(HttpRequestMessage)reference
HttpContent
void CopyTo(Stream, System.Net.TransportContext?, CancellationToken)referenceTask CopyToAsync(Stream, CancellationToken)referenceTask CopyToAsync(Stream, System.Net.TransportContext?, CancellationToken)referenceTask LoadIntoBufferAsync(CancellationToken)referenceTask LoadIntoBufferAsync(long, CancellationToken)referenceTask<byte[]> ReadAsByteArrayAsync(CancellationToken)referenceStream ReadAsStream(CancellationToken)referenceTask<Stream> ReadAsStreamAsync(CancellationToken)referenceTask<string> ReadAsStringAsync(CancellationToken)reference
IDictionary<TKey, TValue>
ReadOnlyDictionary<TKey, TValue> AsReadOnly<TKey, TValue>() where TKey : notnullreferencebool Remove<TKey, TValue>(TKey, TValue) where TKey : notnullreferencebool TryAdd<TKey, TValue>(TKey, TValue) where TKey : notnullreference
IEnumerable<KeyValuePair<TKey, TValue>>
Dictionary<TKey, TValue> ToDictionary<TKey, TValue>(IEqualityComparer<TKey>?) where TKey : notnullreference
IEnumerable
IOrderedEnumerable<T> Order<T>(IComparer<T>?)referenceIOrderedEnumerable<T> Order<T>()referenceIOrderedEnumerable<T> OrderDescending<T>(IComparer<T>?)referenceIOrderedEnumerable<T> OrderDescending<T>()reference
IEnumerable
IEnumerable<(TFirst First, TSecond Second, TThird Third)> Zip<TFirst, TSecond, TThird>(IEnumerable<TSecond>, IEnumerable<TThird>)referenceIEnumerable<(TFirst First, TSecond Second)> Zip<TFirst, TSecond>(IEnumerable<TSecond>)reference
IEnumerable
IEnumerable<TResult> LeftJoin<TOuter, TInner, TKey, TResult>(IEnumerable<TInner>, Func<TOuter, TKey>, Func<TInner, TKey>, Func<TOuter, TInner?, TResult>, IEqualityComparer<TKey>?)referenceIEnumerable<TResult> LeftJoin<TOuter, TInner, TKey, TResult>(IEnumerable<TInner>, Func<TOuter, TKey>, Func<TInner, TKey>, Func<TOuter, TInner?, TResult>)referenceIEnumerable<TResult> RightJoin<TOuter, TInner, TKey, TResult>(IEnumerable<TInner>, Func<TOuter, TKey>, Func<TInner, TKey>, Func<TOuter?, TInner, TResult>, IEqualityComparer<TKey>?)referenceIEnumerable<TResult> RightJoin<TOuter, TInner, TKey, TResult>(IEnumerable<TInner>, Func<TOuter, TKey>, Func<TInner, TKey>, Func<TOuter?, TInner, TResult>)reference
IEnumerable
IEnumerable<KeyValuePair<TKey, TAccumulate>> AggregateBy<TSource, TKey, TAccumulate>(Func<TSource, TKey>, Func<TKey, TAccumulate>, Func<TAccumulate, TSource, TAccumulate>, IEqualityComparer<TKey>?) where TKey : notnullreferenceIEnumerable<KeyValuePair<TKey, TAccumulate>> AggregateBy<TSource, TKey, TAccumulate>(Func<TSource, TKey>, TAccumulate, Func<TAccumulate, TSource, TAccumulate>, IEqualityComparer<TKey>?) where TKey : notnullreferenceIEnumerable<TSource> Append<TSource>(TSource)referenceIEnumerable<TSource[]> Chunk<TSource>(int)referenceIEnumerable<KeyValuePair<TKey, int>> CountBy<TSource, TKey>(Func<TSource, TKey>, IEqualityComparer<TKey>?) where TKey : notnullreferenceIEnumerable<TSource> DistinctBy<TSource, TKey>(Func<TSource, TKey>, IEqualityComparer<TKey>?)referenceIEnumerable<TSource> DistinctBy<TSource, TKey>(Func<TSource, TKey>)referenceTSource ElementAt<TSource>(Index)referenceTSource? ElementAtOrDefault<TSource>(Index)referenceIEnumerable<TSource> Except<TSource>(IEqualityComparer<TSource>?, TSource[])referenceIEnumerable<TSource> Except<TSource>(TSource, IEqualityComparer<TSource>?)referenceIEnumerable<TSource> Except<TSource>(TSource)referenceIEnumerable<TSource> ExceptBy<TSource, TKey>(IEnumerable<TKey>, Func<TSource, TKey>, IEqualityComparer<TKey>?)referenceIEnumerable<TSource> ExceptBy<TSource, TKey>(IEnumerable<TKey>, Func<TSource, TKey>)referenceTSource FirstOrDefault<TSource>(Func<TSource, bool>, TSource)referenceTSource FirstOrDefault<TSource>(TSource)referenceIEnumerable<(int Index, TSource Item)> Index<TSource>()referenceIEnumerable<TSource> IntersectBy<TSource, TKey>(IEnumerable<TKey>, Func<TSource, TKey>, IEqualityComparer<TKey>?)referenceIEnumerable<TSource> IntersectBy<TSource, TKey>(IEnumerable<TKey>, Func<TSource, TKey>)referenceTSource LastOrDefault<TSource>(Func<TSource, bool>, TSource)referenceTSource LastOrDefault<TSource>(TSource)referenceTSource? Max<TSource>(IComparer<TSource>?)referenceTSource? MaxBy<TSource, TKey>(Func<TSource, TKey>, IComparer<TKey>?)referenceTSource? MaxBy<TSource, TKey>(Func<TSource, TKey>)referenceTSource? Min<TSource>(IComparer<TSource>?)referenceTSource? MinBy<TSource, TKey>(Func<TSource, TKey>, IComparer<TKey>?)referenceTSource? MinBy<TSource, TKey>(Func<TSource, TKey>)referenceIEnumerable<TSource> Prepend<TSource>(TSource)referenceTSource SingleOrDefault<TSource>(Func<TSource, bool>, TSource)referenceTSource SingleOrDefault<TSource>(TSource)referenceIEnumerable<TSource> SkipLast<TSource>(int)referenceIEnumerable<TSource> Take<TSource>(Range)referenceIEnumerable<TSource> TakeLast<TSource>(int)referenceHashSet<TSource> ToHashSet<TSource>(IEqualityComparer<TSource>?)referencebool TryGetNonEnumeratedCount<TSource>(int)referenceIEnumerable<TSource> UnionBy<TSource, TKey>(IEnumerable<TSource>, Func<TSource, TKey>, IEqualityComparer<TKey>?)referenceIEnumerable<TSource> UnionBy<TSource, TKey>(IEnumerable<TSource>, Func<TSource, TKey>)reference
IList
ReadOnlyCollection<T> AsReadOnly<T>()reference
Int16
bool TryFormat(Span<byte>, int, ReadOnlySpan<char>, IFormatProvider?)referencebool TryFormat(Span<char>, int, ReadOnlySpan<char>, IFormatProvider?)referencebool TryParse(ReadOnlySpan<byte>, IFormatProvider?, short)referencebool TryParse(ReadOnlySpan<byte>, NumberStyles, IFormatProvider?, short)referencebool TryParse(ReadOnlySpan<byte>, short)referencebool TryParse(ReadOnlySpan<char>, IFormatProvider?, short)referencebool TryParse(ReadOnlySpan<char>, NumberStyles, IFormatProvider?, short)referencebool TryParse(ReadOnlySpan<char>, short)referencebool TryParse(string?, IFormatProvider?, short)reference
Int32
float Int32BitsToSingle(int)bool TryFormat(Span<byte>, int, ReadOnlySpan<char>, IFormatProvider?)referencebool TryFormat(Span<char>, int, ReadOnlySpan<char>, IFormatProvider?)referencebool TryParse(ReadOnlySpan<byte>, IFormatProvider?, int)referencebool TryParse(ReadOnlySpan<byte>, int)referencebool TryParse(ReadOnlySpan<byte>, NumberStyles, IFormatProvider?, int)referencebool TryParse(ReadOnlySpan<char>, IFormatProvider?, int)referencebool TryParse(ReadOnlySpan<char>, int)referencebool TryParse(ReadOnlySpan<char>, NumberStyles, IFormatProvider?, int)referencebool TryParse(string?, IFormatProvider?, int)reference
Int64
bool TryFormat(Span<byte>, int, ReadOnlySpan<char>, IFormatProvider?)referencebool TryFormat(Span<char>, int, ReadOnlySpan<char>, IFormatProvider?)referencebool TryParse(ReadOnlySpan<byte>, IFormatProvider?, long)referencebool TryParse(ReadOnlySpan<byte>, long)referencebool TryParse(ReadOnlySpan<byte>, NumberStyles, IFormatProvider?, long)referencebool TryParse(ReadOnlySpan<char>, IFormatProvider?, long)referencebool TryParse(ReadOnlySpan<char>, long)referencebool TryParse(ReadOnlySpan<char>, NumberStyles, IFormatProvider?, long)referencebool TryParse(string?, IFormatProvider?, long)reference
Interlocked
IntPtr
bool TryParse(ReadOnlySpan<byte>, IFormatProvider?, nint)referencebool TryParse(ReadOnlySpan<byte>, nint)referencebool TryParse(ReadOnlySpan<byte>, NumberStyles, IFormatProvider?, nint)referencebool TryParse(ReadOnlySpan<char>, IFormatProvider?, nint)referencebool TryParse(ReadOnlySpan<char>, nint)referencebool TryParse(ReadOnlySpan<char>, NumberStyles, IFormatProvider?, nint)referencebool TryParse(string?, IFormatProvider?, nint)referencebool TryParse(string?, nint)referencebool TryParse(string?, NumberStyles, IFormatProvider?, nint)reference
IPAddress
IPAddress Parse(ReadOnlySpan<char>)referencebool TryParse(ReadOnlySpan<byte>, IPAddress?)referencebool TryParse(ReadOnlySpan<char>, IPAddress?)reference
IReadOnlyDictionary<TKey, TValue>
TValue GetValueOrDefault<TKey, TValue>(TKey, TValue) where TKey : notnullreferenceTValue? GetValueOrDefault<TKey, TValue>(TKey)reference
ISet
ReadOnlySet<T> AsReadOnly<T>()reference
KeyValuePair<TKey, TValue>
void Deconstruct<TKey, TValue>(TKey, TValue)reference
List
void AddRange<T>(ReadOnlySpan<T>)referencevoid CopyTo<T>(Span<T>)referencevoid EnsureCapacity<T>(int)referencevoid InsertRange<T>(int, ReadOnlySpan<T>)referencevoid TrimExcess<T>()
Math
byte Clamp(byte, byte, byte)referencedecimal Clamp(decimal, decimal, decimal)referencedouble Clamp(double, double, double)referencefloat Clamp(float, float, float)referenceint Clamp(int, int, int)referencelong Clamp(long, long, long)referencenint Clamp(nint, nint, nint)referencenuint Clamp(nuint, nuint, nuint)referencesbyte Clamp(sbyte, sbyte, sbyte)referenceshort Clamp(short, short, short)referenceuint Clamp(uint, uint, uint)referenceulong Clamp(ulong, ulong, ulong)referenceushort Clamp(ushort, ushort, ushort)reference
MD5
byte[] HashData(byte[])referenceint HashData(ReadOnlySpan<byte>, Span<byte>)referencebyte[] HashData(ReadOnlySpan<byte>)referenceint HashData(Stream, Span<byte>)referencebyte[] HashData(Stream)referenceValueTask<byte[]> HashDataAsync(Stream, CancellationToken)referenceValueTask<int> HashDataAsync(Stream, Memory<byte>, CancellationToken)referencebool TryHashData(ReadOnlySpan<byte>, Span<byte>, int)reference
MemberInfo
NullabilityState GetNullability()NullabilityInfo GetNullabilityInfo()bool HasSameMetadataDefinitionAs(MemberInfo)referencebool IsNullable()
MethodInfo
T CreateDelegate<T>(object?) where T : DelegatereferenceT CreateDelegate<T>() where T : Delegatereference
ObjectDisposedException
OperatingSystem
bool IsAndroid()referencebool IsAndroidVersionAtLeast(int, int, int, int)referencebool IsBrowser()referencebool IsFreeBSD()referencebool IsFreeBSDVersionAtLeast(int, int, int, int)referencebool IsIOS()referencebool IsIOSVersionAtLeast(int, int, int)referencebool IsLinux()referencebool IsMacCatalyst()referencebool IsMacCatalystVersionAtLeast(int, int, int)referencebool IsMacOS()referencebool IsMacOSVersionAtLeast(int, int, int)referencebool IsOSPlatform(string)referencebool IsOSPlatformVersionAtLeast(string, int, int, int, int)referencebool IsTvOS()referencebool IsTvOSVersionAtLeast(int, int, int)referencebool IsWasi()referencebool IsWatchOS()referencebool IsWatchOSVersionAtLeast(int, int, int)referencebool IsWindows()referencebool IsWindowsVersionAtLeast(int, int, int, int)reference
OrderedDictionary<TKey, TValue>
bool TryAdd<TKey, TValue>(TKey, TValue, int) where TKey : notnullreferencebool TryGetValue<TKey, TValue>(TKey, TValue, int) where TKey : notnullreference
Parallel
Task ForEachAsync<T>(IAsyncEnumerable<T>, CancellationToken, Func<T, CancellationToken, ValueTask>)referenceTask ForEachAsync<T>(IAsyncEnumerable<T>, Func<T, CancellationToken, ValueTask>)referenceTask ForEachAsync<T>(IAsyncEnumerable<T>, ParallelOptions, Func<T, CancellationToken, ValueTask>)referenceTask ForEachAsync<T>(IEnumerable<T>, CancellationToken, Func<T, CancellationToken, ValueTask>)referenceTask ForEachAsync<T>(IEnumerable<T>, Func<T, CancellationToken, ValueTask>)referenceTask ForEachAsync<T>(IEnumerable<T>, ParallelOptions, Func<T, CancellationToken, ValueTask>)reference
ParameterInfo
NullabilityState GetNullability()NullabilityInfo GetNullabilityInfo()bool IsNullable()
Path
string Combine(ReadOnlySpan<string>)referencebool EndsInDirectorySeparator(ReadOnlySpan<char>)referencebool EndsInDirectorySeparator(string)referencebool Exists(string?)referenceReadOnlySpan<char> GetDirectoryName(ReadOnlySpan<char>)referenceReadOnlySpan<char> GetExtension(ReadOnlySpan<char>)referenceReadOnlySpan<char> GetFileName(ReadOnlySpan<char>)referenceReadOnlySpan<char> GetFileNameWithoutExtension(ReadOnlySpan<char>)referencestring GetRelativePath(string, string)referencebool HasExtension(ReadOnlySpan<char>)referencebool IsPathRooted(ReadOnlySpan<char>)referencestring Join(string?[])referenceReadOnlySpan<char> TrimEndingDirectorySeparator(ReadOnlySpan<char>)referencestring TrimEndingDirectorySeparator(string)reference
PriorityQueue<TElement, TPriority>
bool Remove<TElement, TPriority>(TElement, TElement, TPriority, IEqualityComparer<TElement>?)reference
Process
PropertyInfo
NullabilityState GetNullability()NullabilityInfo GetNullabilityInfo()bool IsNullable()
Queue
Random
string GetHexString(int, bool)referencevoid GetHexString(Span<char>, bool)referenceT[] GetItems<T>(ReadOnlySpan<T>, int)referencevoid GetItems<T>(ReadOnlySpan<T>, Span<T>)referenceT[] GetItems<T>(T[], int)referencestring GetString(ReadOnlySpan<char>, int)referencevoid NextBytes(Span<byte>)referencelong NextInt64(long, long)referencelong NextInt64(long)referencelong NextInt64()referencefloat NextSingle()referencevoid Shuffle<T>(Span<T>)referencevoid Shuffle<T>(T[])referenceSharedreference
RandomNumberGenerator
void Fill(Span<byte>)referencebyte[] GetBytes(int)referencestring GetHexString(int, bool)referencevoid GetHexString(Span<char>, bool)referenceint GetInt32(int, int)referenceint GetInt32(int)referenceT[] GetItems<T>(ReadOnlySpan<T>, int)referencevoid GetItems<T>(ReadOnlySpan<T>, Span<T>)referencestring GetString(ReadOnlySpan<char>, int)referencevoid Shuffle<T>(Span<T>)reference
ReadOnlySpan
bool EndsWith(string, StringComparison)referenceSpanLineEnumerator EnumerateLines()referenceint GetNormalizedLength(NormalizationForm)referencebool IsNormalized(NormalizationForm)referencebool SequenceEqual(string)referenceint Split(Span<Range>, char, StringSplitOptions)referenceint Split(Span<Range>, ReadOnlySpan<char>, StringSplitOptions)referenceint SplitAny(Span<Range>, ReadOnlySpan<char>, StringSplitOptions)referenceint SplitAny(Span<Range>, ReadOnlySpan<string>, StringSplitOptions)referencebool StartsWith(string, StringComparison)referencebool TryNormalize(Span<char>, int, NormalizationForm)reference
ReadOnlySpan
int CommonPrefixLength<T>(ReadOnlySpan<T>, IEqualityComparer<T>?)referenceint CommonPrefixLength<T>(ReadOnlySpan<T>)referencebool Contains<T>(T, IEqualityComparer<T>?)referencebool Contains<T>(T) where T : IEquatable<T>referencebool ContainsAnyExcept<T>(ReadOnlySpan<T>) where T : IEquatable<T>referencebool ContainsAnyExcept<T>(T, T, T) where T : IEquatable<T>referencebool ContainsAnyExcept<T>(T, T) where T : IEquatable<T>referencebool ContainsAnyExcept<T>(T) where T : IEquatable<T>referencebool ContainsAnyExceptInRange<T>(T, T) where T : IComparable<T>referencebool ContainsAnyInRange<T>(T, T) where T : IComparable<T>referenceint CountAny<T>(ReadOnlySpan<T>, IEqualityComparer<T>?)referenceint CountAny<T>(ReadOnlySpan<T>) where T : IEquatable<T>?referenceint CountAny<T>(SearchValues<T>) where T : IEquatable<T>?referencebool EndsWith<T>(T) where T : IEquatable<T>?referenceint IndexOf<T>(T, IEqualityComparer<T>?)referenceint IndexOfAny<T>(ReadOnlySpan<T>, IEqualityComparer<T>?)referenceint IndexOfAnyExcept<T>(ReadOnlySpan<T>) where T : IEquatable<T>referenceint IndexOfAnyExcept<T>(T, T, T) where T : IEquatable<T>referenceint IndexOfAnyExcept<T>(T, T) where T : IEquatable<T>referenceint IndexOfAnyExcept<T>(T) where T : IEquatable<T>referenceint LastIndexOfAnyExcept<T>(ReadOnlySpan<T>) where T : IEquatable<T>referenceint LastIndexOfAnyExcept<T>(T, T, T) where T : IEquatable<T>referenceint LastIndexOfAnyExcept<T>(T, T) where T : IEquatable<T>referenceint LastIndexOfAnyExcept<T>(T) where T : IEquatable<T>referenceSpanSplitEnumerator<T> Split<T>(ReadOnlySpan<T>) where T : IEquatable<T>referenceSpanSplitEnumerator<T> Split<T>(T) where T : IEquatable<T>referenceSpanSplitEnumerator<T> SplitAny<T>(ReadOnlySpan<T>) where T : IEquatable<T>referenceSpanSplitEnumerator<T> SplitAny<T>(SearchValues<T>) where T : IEquatable<T>referencebool StartsWith<T>(T) where T : IEquatable<T>?reference
Regex
int Count(ReadOnlySpan<char>, int)referenceint Count(ReadOnlySpan<char>)referenceint Count(string)referenceValueMatchEnumerator EnumerateMatches(ReadOnlySpan<char>, int)referenceValueMatchEnumerator EnumerateMatches(ReadOnlySpan<char>)referenceValueSplitEnumerator EnumerateSplits(ReadOnlySpan<char>, int, int)referenceValueSplitEnumerator EnumerateSplits(ReadOnlySpan<char>, int)referenceValueSplitEnumerator EnumerateSplits(ReadOnlySpan<char>)referencebool IsMatch(ReadOnlySpan<char>, int)referencebool IsMatch(ReadOnlySpan<char>)referenceint Count(ReadOnlySpan<char>, string, RegexOptions, TimeSpan)referenceint Count(ReadOnlySpan<char>, string, RegexOptions)referenceint Count(ReadOnlySpan<char>, string)referenceint Count(string, string, RegexOptions, TimeSpan)referenceint Count(string, string, RegexOptions)referenceint Count(string, string)referenceValueMatchEnumerator EnumerateMatches(ReadOnlySpan<char>, string, RegexOptions, TimeSpan)referenceValueMatchEnumerator EnumerateMatches(ReadOnlySpan<char>, string, RegexOptions)referenceValueMatchEnumerator EnumerateMatches(ReadOnlySpan<char>, string)referenceValueSplitEnumerator EnumerateSplits(ReadOnlySpan<char>, string, RegexOptions, TimeSpan)referenceValueSplitEnumerator EnumerateSplits(ReadOnlySpan<char>, string, RegexOptions)referenceValueSplitEnumerator EnumerateSplits(ReadOnlySpan<char>, string)referencebool IsMatch(ReadOnlySpan<char>, string, RegexOptions, TimeSpan)referencebool IsMatch(ReadOnlySpan<char>, string, RegexOptions)referencebool IsMatch(ReadOnlySpan<char>, string)reference
RuntimeFeature
IsMultithreadingSupportedreference
SByte
bool TryFormat(Span<byte>, int, ReadOnlySpan<char>, IFormatProvider?)referencebool TryFormat(Span<char>, int, ReadOnlySpan<char>, IFormatProvider?)referencebool TryParse(ReadOnlySpan<byte>, IFormatProvider?, sbyte)referencebool TryParse(ReadOnlySpan<byte>, NumberStyles, IFormatProvider?, sbyte)referencebool TryParse(ReadOnlySpan<byte>, sbyte)referencebool TryParse(ReadOnlySpan<char>, IFormatProvider?, sbyte)referencebool TryParse(ReadOnlySpan<char>, NumberStyles, IFormatProvider?, sbyte)referencebool TryParse(ReadOnlySpan<char>, sbyte)referencebool TryParse(string?, IFormatProvider?, sbyte)reference
SHA1
byte[] HashData(byte[])referenceint HashData(ReadOnlySpan<byte>, Span<byte>)referencebyte[] HashData(ReadOnlySpan<byte>)referenceint HashData(Stream, Span<byte>)referencebyte[] HashData(Stream)referenceValueTask<byte[]> HashDataAsync(Stream, CancellationToken)referenceValueTask<int> HashDataAsync(Stream, Memory<byte>, CancellationToken)referencebool TryHashData(ReadOnlySpan<byte>, Span<byte>, int)reference
SHA256
byte[] HashData(byte[])referenceint HashData(ReadOnlySpan<byte>, Span<byte>)referencebyte[] HashData(ReadOnlySpan<byte>)referenceint HashData(Stream, Span<byte>)referencebyte[] HashData(Stream)referenceValueTask<byte[]> HashDataAsync(Stream, CancellationToken)referenceValueTask<int> HashDataAsync(Stream, Memory<byte>, CancellationToken)referencebool TryHashData(ReadOnlySpan<byte>, Span<byte>, int)reference
SHA384
byte[] HashData(byte[])referenceint HashData(ReadOnlySpan<byte>, Span<byte>)referencebyte[] HashData(ReadOnlySpan<byte>)referenceint HashData(Stream, Span<byte>)referencebyte[] HashData(Stream)referenceValueTask<byte[]> HashDataAsync(Stream, CancellationToken)referenceValueTask<int> HashDataAsync(Stream, Memory<byte>, CancellationToken)referencebool TryHashData(ReadOnlySpan<byte>, Span<byte>, int)reference
SHA512
byte[] HashData(byte[])referenceint HashData(ReadOnlySpan<byte>, Span<byte>)referencebyte[] HashData(ReadOnlySpan<byte>)referenceint HashData(Stream, Span<byte>)referencebyte[] HashData(Stream)referenceValueTask<byte[]> HashDataAsync(Stream, CancellationToken)referenceValueTask<int> HashDataAsync(Stream, Memory<byte>, CancellationToken)referencebool TryHashData(ReadOnlySpan<byte>, Span<byte>, int)reference
Single
int SingleToInt32Bits(float)uint SingleToUInt32Bits(float)bool TryFormat(Span<byte>, int, ReadOnlySpan<char>, IFormatProvider?)referencebool TryFormat(Span<char>, int, ReadOnlySpan<char>, IFormatProvider?)referencebool TryParse(ReadOnlySpan<byte>, float)referencebool TryParse(ReadOnlySpan<byte>, IFormatProvider?, float)referencebool TryParse(ReadOnlySpan<byte>, NumberStyles, IFormatProvider?, float)referencebool TryParse(ReadOnlySpan<char>, float)referencebool TryParse(ReadOnlySpan<char>, IFormatProvider?, float)referencebool TryParse(ReadOnlySpan<char>, NumberStyles, IFormatProvider?, float)referencebool TryParse(string?, IFormatProvider?, float)reference
Socket
ValueTask ConnectAsync(EndPoint, CancellationToken)referenceValueTask DisconnectAsync(bool, CancellationToken)referenceValueTask<SocketReceiveFromResult> ReceiveFromAsync(Memory<byte>, SocketFlags, EndPoint, CancellationToken)referenceValueTask<int> SendToAsync(ReadOnlyMemory<byte>, SocketFlags, EndPoint, CancellationToken)reference
SortedList<TKey, TValue>
Span
bool EndsWith(string)referenceSpanLineEnumerator EnumerateLines()referencebool SequenceEqual(string)referencebool StartsWith(string)referenceSpan<char> TrimEnd()referenceSpan<char> TrimStart()reference
Span
int CommonPrefixLength<T>(ReadOnlySpan<T>, IEqualityComparer<T>?)referenceint CommonPrefixLength<T>(ReadOnlySpan<T>)referencebool Contains<T>(T) where T : IEquatable<T>referencebool ContainsAnyExcept<T>(ReadOnlySpan<T>) where T : IEquatable<T>referencebool ContainsAnyExcept<T>(T, T, T) where T : IEquatable<T>referencebool ContainsAnyExcept<T>(T, T) where T : IEquatable<T>referencebool ContainsAnyExcept<T>(T) where T : IEquatable<T>referencebool ContainsAnyExceptInRange<T>(T, T) where T : IComparable<T>referencebool ContainsAnyInRange<T>(T, T) where T : IComparable<T>referenceint IndexOfAnyExcept<T>(ReadOnlySpan<T>) where T : IEquatable<T>referenceint IndexOfAnyExcept<T>(T, T, T) where T : IEquatable<T>referenceint IndexOfAnyExcept<T>(T, T) where T : IEquatable<T>referenceint IndexOfAnyExcept<T>(T) where T : IEquatable<T>referenceint LastIndexOfAnyExcept<T>(ReadOnlySpan<T>) where T : IEquatable<T>referenceint LastIndexOfAnyExcept<T>(T, T, T) where T : IEquatable<T>referenceint LastIndexOfAnyExcept<T>(T, T) where T : IEquatable<T>referenceint LastIndexOfAnyExcept<T>(T) where T : IEquatable<T>referencevoid Sort<T>(Comparison<T>)void Sort<T>() where T : IComparable<T>reference
Span
void Sort<TKey, TValue, TComparer>(Span<TValue>, TComparer) where TComparer : IComparer<TKey>referencevoid Sort<TKey, TValue>(Span<TValue>, Comparison<TKey>)referencevoid Sort<TKey, TValue>(Span<TValue>)reference
Stack
void EnsureCapacity<T>(int)referencevoid TrimExcess<T>(int)referencebool TryPeek<T>(T)referencebool TryPop<T>(T)reference
Stopwatch
Stream
Task CopyToAsync(Stream, CancellationToken)referenceValueTask DisposeAsync()referenceint Read(Span<byte>)referenceValueTask<int> ReadAsync(Memory<byte>, CancellationToken)referenceint ReadAtLeast(Span<byte>, int, bool)referenceValueTask<int> ReadAtLeastAsync(Memory<byte>, int, bool, CancellationToken)referencevoid ReadExactly(byte[], int, int)referencevoid ReadExactly(Span<byte>)referenceValueTask ReadExactlyAsync(byte[], int, int, CancellationToken)referenceValueTask ReadExactlyAsync(Memory<byte>, CancellationToken)referencevoid Write(ReadOnlySpan<byte>)referenceValueTask WriteAsync(ReadOnlyMemory<byte>, CancellationToken)reference
String
bool Contains(char, StringComparison)referencebool Contains(char)referencebool Contains(string, StringComparison)referencevoid CopyTo(Span<char>)referencebool EndsWith(char, StringComparison)referencebool EndsWith(char)referenceint GetHashCode(StringComparison)referenceint IndexOf(char, int, int, StringComparison)referenceint IndexOf(char, int, StringComparison)referenceint IndexOf(char, StringComparison)referenceint LastIndexOf(char, int, int, StringComparison)referenceint LastIndexOf(char, int, StringComparison)referenceint LastIndexOf(char, StringComparison)referencestring ReplaceLineEndings(string)referencestring ReplaceLineEndings()referencestring[] Split(char, int, StringSplitOptions)referencestring[] Split(char, StringSplitOptions)referencestring[] Split(string, int, StringSplitOptions)referencestring[] Split(string, StringSplitOptions)referencebool StartsWith(char, StringComparison)referencebool StartsWith(char)referencebool TryCopyTo(Span<char>)referencestring Concat(ReadOnlySpan<object?>)referencestring Concat(ReadOnlySpan<string?>)referencestring Create<TState>(int, TState, System.Buffers.SpanAction<char, TState>)referenceint GetHashCode(ReadOnlySpan<char>, StringComparison)referenceint GetHashCode(ReadOnlySpan<char>)referencestring Join(char, object?[])referencestring Join(char, ReadOnlySpan<object?>)referencestring Join(char, ReadOnlySpan<string?>)referencestring Join(char, string?[], int, int)referencestring Join(char, string?[])referencestring Join(string?, ReadOnlySpan<object?>)referencestring Join(string?, ReadOnlySpan<string?>)referencestring Join<T>(char, IEnumerable<T>)reference
StringBuilder
StringBuilder Append(StringBuilder, AppendInterpolatedStringHandler)referenceStringBuilder Append(StringBuilder, IFormatProvider?, AppendInterpolatedStringHandler)referenceStringBuilder Append(StringBuilder, IFormatProvider?, StringBuilder.AppendInterpolatedStringHandler)referenceStringBuilder Append(ReadOnlySpan<char>)referenceStringBuilder Append(StringBuilder?, int, int)referenceStringBuilder Append(StringBuilder, StringBuilder.AppendInterpolatedStringHandler)referenceStringBuilder AppendJoin(char, object?[])referenceStringBuilder AppendJoin(char, string?[])referenceStringBuilder AppendJoin(string?, object?[])referenceStringBuilder AppendJoin(string?, string?[])referenceStringBuilder AppendJoin<T>(char, IEnumerable<T>)referenceStringBuilder AppendJoin<T>(char, T[])referenceStringBuilder AppendJoin<T>(string, T[])referenceStringBuilder AppendJoin<T>(string?, IEnumerable<T>)referenceStringBuilder AppendLine(StringBuilder, AppendInterpolatedStringHandler)referenceStringBuilder AppendLine(StringBuilder, IFormatProvider?, AppendInterpolatedStringHandler)referenceStringBuilder AppendLine(StringBuilder, IFormatProvider?, StringBuilder.AppendInterpolatedStringHandler)referenceStringBuilder AppendLine(StringBuilder, StringBuilder.AppendInterpolatedStringHandler)referencevoid CopyTo(int, Span<char>, int)referencebool Equals(ReadOnlySpan<char>)referenceChunkEnumerator GetChunks()referenceStringBuilder Insert(int, ReadOnlySpan<char>)referenceStringBuilder Replace(ReadOnlySpan<char>, ReadOnlySpan<char>, int, int)referenceStringBuilder Replace(ReadOnlySpan<char>, ReadOnlySpan<char>)reference
Task
ConfiguredTaskAwaitable ConfigureAwait(ConfigureAwaitOptions)referenceTask WaitAsync(CancellationToken)referenceTask WaitAsync(TimeSpan, CancellationToken)referenceTask WaitAsync(TimeSpan)referenceTask WhenAll(ReadOnlySpan<Task>)referenceTask<TResult[]> WhenAll<TResult>(ReadOnlySpan<Task<TResult>>)referenceTask<Task> WhenAny(ReadOnlySpan<Task>)referenceTask<Task<TResult>> WhenAny<TResult>(ReadOnlySpan<Task<TResult>>)reference
Task
ConfiguredTaskAwaitable<TResult> ConfigureAwait<TResult>(ConfigureAwaitOptions)referenceTask<TResult> WaitAsync<TResult>(CancellationToken)referenceTask<TResult> WaitAsync<TResult>(TimeSpan, CancellationToken)referenceTask<TResult> WaitAsync<TResult>(TimeSpan)reference
TaskCompletionSource
void SetCanceled<T>(CancellationToken)reference
TaskWhenEach
IAsyncEnumerable<Task> WhenEach(IEnumerable<Task>, CancellationToken)referenceIAsyncEnumerable<Task<TResult>> WhenEach<TResult>(IEnumerable<Task<TResult>>, CancellationToken)reference
TcpClient
ValueTask ConnectAsync(IPAddress, int, CancellationToken)referenceValueTask ConnectAsync(IPAddress[], int, CancellationToken)referenceValueTask ConnectAsync(IPEndPoint, CancellationToken)referenceValueTask ConnectAsync(string, int, CancellationToken)reference
TextReader
ValueTask<int> ReadAsync(Memory<char>, CancellationToken)referenceTask<string> ReadLineAsync(CancellationToken)referenceTask<string> ReadToEndAsync(CancellationToken)reference
TextWriter
Task FlushAsync(CancellationToken)referencevoid Write(ReadOnlySpan<char>)referencevoid Write(StringBuilder?)referenceValueTask WriteAsync(ReadOnlyMemory<char>, CancellationToken)referenceTask WriteAsync(string?, CancellationToken)referenceTask WriteAsync(StringBuilder?, CancellationToken)referencevoid WriteLine(ReadOnlySpan<char>)referenceTask WriteLineAsync(CancellationToken)referenceValueTask WriteLineAsync(ReadOnlyMemory<char>, CancellationToken)referenceTask WriteLineAsync(string?, CancellationToken)reference
TimeOnly
void Deconstruct(int, int, int, int, int)referencevoid Deconstruct(int, int, int, int)referencevoid Deconstruct(int, int, int)referencevoid Deconstruct(int, int)referencebool TryFormat(Span<byte>, int, ReadOnlySpan<char>, IFormatProvider?)referencebool TryFormat(Span<char>, int, ReadOnlySpan<char>, IFormatProvider?)reference
TimeSpan
bool TryFormat(Span<byte>, int, ReadOnlySpan<char>, IFormatProvider?)referencebool TryFormat(Span<char>, int, ReadOnlySpan<char>, IFormatProvider?)referenceTimeSpan FromDays(int, int, int, int, int, int)referenceTimeSpan FromHours(int, int, int, int, int)referenceTimeSpan FromMicroseconds(long)referenceTimeSpan FromMilliseconds(long, long)referenceTimeSpan FromMinutes(int, int, int, int)referenceTimeSpan FromSeconds(long, long, long)referenceMicrosecondsreferenceNanosecondsreference
Type
MemberInfo GetMemberWithSameMetadataDefinitionAs(MemberInfo)referenceMethodInfo? GetMethod(string, int, BindingFlags, Binder?, Type[], ParameterModifier[]?)referenceMethodInfo? GetMethod(string, int, BindingFlags, Type[])referencebool IsAssignableFrom<T>()bool IsAssignableTo(Type?)referencebool IsAssignableTo<T>()IsGenericMethodParameterreference
UdpClient
ValueTask<UdpReceiveResult> ReceiveAsync(CancellationToken)referenceint Send(ReadOnlySpan<byte>, IPEndPoint?)referenceint Send(ReadOnlySpan<byte>, string?, int)referenceint Send(ReadOnlySpan<byte>)referenceValueTask<int> SendAsync(ReadOnlyMemory<byte>, CancellationToken)referenceValueTask<int> SendAsync(ReadOnlyMemory<byte>, IPEndPoint?, CancellationToken)referenceValueTask<int> SendAsync(ReadOnlyMemory<byte>, string?, int, CancellationToken)reference
UInt16
bool TryFormat(Span<byte>, int, ReadOnlySpan<char>, IFormatProvider?)referencebool TryFormat(Span<char>, int, ReadOnlySpan<char>, IFormatProvider?)referencebool TryParse(ReadOnlySpan<byte>, IFormatProvider?, ushort)referencebool TryParse(ReadOnlySpan<byte>, NumberStyles, IFormatProvider?, ushort)referencebool TryParse(ReadOnlySpan<byte>, ushort)referencebool TryParse(ReadOnlySpan<char>, IFormatProvider?, ushort)referencebool TryParse(ReadOnlySpan<char>, NumberStyles, IFormatProvider?, ushort)referencebool TryParse(ReadOnlySpan<char>, ushort)referencebool TryParse(string?, IFormatProvider?, ushort)reference
UInt32
bool TryFormat(Span<byte>, int, ReadOnlySpan<char>, IFormatProvider?)referencebool TryFormat(Span<char>, int, ReadOnlySpan<char>, IFormatProvider?)referencefloat UInt32BitsToSingle(uint)bool TryParse(ReadOnlySpan<byte>, IFormatProvider?, uint)referencebool TryParse(ReadOnlySpan<byte>, NumberStyles, IFormatProvider?, uint)referencebool TryParse(ReadOnlySpan<byte>, uint)referencebool TryParse(ReadOnlySpan<char>, IFormatProvider?, uint)referencebool TryParse(ReadOnlySpan<char>, NumberStyles, IFormatProvider?, uint)referencebool TryParse(ReadOnlySpan<char>, uint)referencebool TryParse(string?, IFormatProvider?, uint)reference
UInt64
bool TryFormat(Span<byte>, int, ReadOnlySpan<char>, IFormatProvider?)referencebool TryFormat(Span<char>, int, ReadOnlySpan<char>, IFormatProvider?)referencedouble UInt64BitsToDouble(ulong)bool TryParse(ReadOnlySpan<byte>, IFormatProvider?, ulong)referencebool TryParse(ReadOnlySpan<byte>, NumberStyles, IFormatProvider?, ulong)referencebool TryParse(ReadOnlySpan<byte>, ulong)referencebool TryParse(ReadOnlySpan<char>, IFormatProvider?, ulong)referencebool TryParse(ReadOnlySpan<char>, NumberStyles, IFormatProvider?, ulong)referencebool TryParse(ReadOnlySpan<char>, ulong)referencebool TryParse(string?, IFormatProvider?, ulong)reference
UIntPtr
bool TryParse(ReadOnlySpan<byte>, IFormatProvider?, nuint)referencebool TryParse(ReadOnlySpan<byte>, nuint)referencebool TryParse(ReadOnlySpan<byte>, NumberStyles, IFormatProvider?, nuint)referencebool TryParse(ReadOnlySpan<char>, IFormatProvider?, nuint)referencebool TryParse(ReadOnlySpan<char>, nuint)referencebool TryParse(ReadOnlySpan<char>, NumberStyles, IFormatProvider?, nuint)referencebool TryParse(string?, IFormatProvider?, nuint)referencebool TryParse(string?, nuint)referencebool TryParse(string?, NumberStyles, IFormatProvider?, nuint)reference
ValueTask
CompletedTaskreference
XDocument
Task SaveAsync(Stream, SaveOptions, CancellationToken)referenceTask SaveAsync(TextWriter, SaveOptions, CancellationToken)referenceTask SaveAsync(XmlWriter, CancellationToken)referenceTask<XDocument> LoadAsync(Stream, LoadOptions, CancellationToken)referenceTask<XDocument> LoadAsync(TextReader, LoadOptions, CancellationToken)referenceTask<XDocument> LoadAsync(XmlReader, LoadOptions, CancellationToken)reference
XElement
Task SaveAsync(Stream, SaveOptions, CancellationToken)referenceTask SaveAsync(TextWriter, SaveOptions, CancellationToken)referenceTask SaveAsync(XmlWriter, CancellationToken)referenceTask<XElement> LoadAsync(Stream, LoadOptions, CancellationToken)referenceTask<XElement> LoadAsync(TextReader, LoadOptions, CancellationToken)referenceTask<XElement> LoadAsync(XmlReader, LoadOptions, CancellationToken)reference
XNode
Task WriteToAsync(XmlWriter, CancellationToken)referenceTask<XNode> ReadFromAsync(XmlReader, CancellationToken)reference
ZipArchive
Task<ZipArchiveEntry> CreateEntryFromFileAsync(string, string, CancellationToken)referenceTask<ZipArchiveEntry> CreateEntryFromFileAsync(string, string, CompressionLevel, CancellationToken)referencevoid ExtractToDirectory(string, bool)referenceTask ExtractToDirectoryAsync(string, bool, CancellationToken)referenceTask ExtractToDirectoryAsync(string, CancellationToken)reference
ZipArchiveEntry
Task ExtractToFileAsync(string, bool, CancellationToken)referenceTask ExtractToFileAsync(string, CancellationToken)referenceStream Open(FileAccess)referenceTask<Stream> OpenAsync(CancellationToken)referenceValueTask<Stream> OpenAsync(FileAccess, CancellationToken)referenceExternalAttributesreference
ZipFile
Task CreateFromDirectoryAsync(string, string, CancellationToken)referenceTask CreateFromDirectoryAsync(string, string, CompressionLevel, bool, CancellationToken)referenceTask CreateFromDirectoryAsync(string, string, CompressionLevel, bool, Encoding, CancellationToken)referenceTask ExtractToDirectoryAsync(string, string, bool, CancellationToken)referenceTask ExtractToDirectoryAsync(string, string, CancellationToken)referenceTask ExtractToDirectoryAsync(string, string, Encoding, bool, CancellationToken)referenceTask ExtractToDirectoryAsync(string, string, Encoding, CancellationToken)referenceTask<ZipArchive> OpenAsync(string, ZipArchiveMode, CancellationToken)referenceTask<ZipArchive> OpenAsync(string, ZipArchiveMode, Encoding?, CancellationToken)referenceTask<ZipArchive> OpenReadAsync(string, CancellationToken)reference
Ensure
void DirectoryExists(string)T Equal<T>(T, T)void FileExists(string)void NoDuplicates<T>(IEnumerable<T>)string? NotEmpty(string?)Memory<T>? NotEmpty<T>(Memory<T>?)Memory<T> NotEmpty<T>(Memory<T>)ReadOnlyMemory<T>? NotEmpty<T>(ReadOnlyMemory<T>?)ReadOnlyMemory<T> NotEmpty<T>(ReadOnlyMemory<T>)ReadOnlySpan<T> NotEmpty<T>(ReadOnlySpan<T>)Span<T> NotEmpty<T>(Span<T>)T? NotEmpty<T>(T?) where T : IEnumerableT NotEqual<T>(T, T)nint NotGreaterThan(nint, nint)T NotGreaterThan<T>(T, T) where T : IComparable<T>nint NotGreaterThanOrEqual(nint, nint)T NotGreaterThanOrEqual<T>(T, T) where T : IComparable<T>nint NotLessThan(nint, nint)T NotLessThan<T>(T, T) where T : IComparable<T>nint NotLessThanOrEqual(nint, nint)T NotLessThanOrEqual<T>(T, T) where T : IComparable<T>nint NotNegative(nint)T NotNegative<T>(T) where T : struct, IComparable<T>nint NotNegativeOrZero(nint)T NotNegativeOrZero<T>(T) where T : struct, IComparable<T>string NotNull(string?)T NotNull<T>(T?) where T : classMemory<char> NotNullOrEmpty(Memory<char>?)ReadOnlyMemory<char> NotNullOrEmpty(ReadOnlyMemory<char>?)string NotNullOrEmpty(string?)T NotNullOrEmpty<T>(T?) where T : IEnumerableMemory<char> NotNullOrWhiteSpace(Memory<char>?)ReadOnlyMemory<char> NotNullOrWhiteSpace(ReadOnlyMemory<char>?)string NotNullOrWhiteSpace(string?)Memory<char>? NotWhiteSpace(Memory<char>?)ReadOnlyMemory<char>? NotWhiteSpace(ReadOnlyMemory<char>?)ReadOnlySpan<char> NotWhiteSpace(ReadOnlySpan<char>)Span<char> NotWhiteSpace(Span<char>)string? NotWhiteSpace(string?)nint NotZero(nint)T NotZero<T>(T) where T : struct, IEquatable<T>
Lock
void Enter()Scope EnterScope()void Exit()bool TryEnter()bool TryEnter(int)bool TryEnter(TimeSpan)
KeyValuePair
KeyValuePair<TKey, TValue> Create<TKey, TValue>(TKey, TValue)reference
TaskCompletionSource
UnreachableException
References
If any of the below reference are not included, the related polyfills will be disabled.
System.ValueTuple
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'))" />
System.Memory
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'))" />
Version Warning
If System.Memory is installed but the version is older than 4.5.5, a build warning PolyfillMemoryVersion will be raised. This is because older versions lack the required types for FeatureMemory to be enabled, which can cause polyfills to silently fail.
To suppress this warning:
<PropertyGroup>
<PolyfillNoWarnIncorrectVersion>true</PolyfillNoWarnIncorrectVersion>
</PropertyGroup>
System.Threading.Tasks.Extensions
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'" />
System.Runtime.InteropServices
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'" />
NullabilityInfo
Enable by adding an MSBuild property PolyNullability
<PropertyGroup>
...
<PolyNullability>true</PolyNullability>
</PropertyGroup>
Example target class
Given the following class
class NullabilityTarget
{
public string? StringField;
public string?[] ArrayField;
public Dictionary<string, object?> GenericField;
}
NullabilityInfoContext
[Test]
public async Task Test()
{
var type = typeof(NullabilityTarget);
var arrayField = type.GetField("ArrayField")!;
var genericField = type.GetField("GenericField")!;
var context = new NullabilityInfoContext();
var arrayInfo = context.Create(arrayField);
await Assert.That(arrayInfo.ReadState).IsEqualTo(NullabilityState.NotNull);
await Assert.That(arrayInfo.ElementType!.ReadState).IsEqualTo(NullabilityState.Nullable);
var genericInfo = context.Create(genericField);
await Assert.That(genericInfo.ReadState).IsEqualTo(NullabilityState.NotNull);
await Assert.That(genericInfo.GenericTypeArguments[0].ReadState).IsEqualTo(NullabilityState.NotNull);
await Assert.That(genericInfo.GenericTypeArguments[1].ReadState).IsEqualTo(NullabilityState.Nullable);
}
NullabilityInfoExtensions
NullabilityInfoExtensions provides static and thread safe wrapper around NullabilityInfoContext. It adds three extension methods to each of ParameterInfo, PropertyInfo, EventInfo, and FieldInfo.
GetNullabilityInfo: returns theNullabilityInfofor the target info.GetNullability: returns theNullabilityStatefor the state (NullabilityInfo.ReadStateorNullabilityInfo.WriteStatedepending on which has more info) of target info.IsNullable: given the state (NullabilityInfo.ReadStateorNullabilityInfo.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
Ensure
Enable by adding an MSBuild property PolyEnsure
<PropertyGroup>
...
<PolyEnsure>true</PolyEnsure>
</PropertyGroup>
Ensure is designed to be an alternative to the Argument*Exception.ThrowIf* APIs added in net7.
ArgumentException.ThrowIf*referenceArgumentNullException.ThrowIf*referenceArgumentOutOfRangeException.ThrowIf*reference
With the equivalent Ensure APIs:
Ensure.NotNullOrEmptyEnsure.NotNullOrWhiteSpaceEnsure.NotNull
Justification
Argument*Exceptionare overly verboseArgument*Exceptiondo not provide "check return value value semantics"
Comparison
Argument*Exception example
void ArgumentExceptionExample(Order order, Customer customer, string customerId, string email, decimal discountPercentage, int quantity)
{
ArgumentNullException.ThrowIfNull(order);
ArgumentNullException.ThrowIfNull(customer);
ArgumentException.ThrowIfNullOrWhiteSpace(customerId);
ArgumentException.ThrowIfNullOrWhiteSpace(email);
ArgumentOutOfRangeException.ThrowIfGreaterThan(discountPercentage, 100m);
ArgumentOutOfRangeException.ThrowIfNegativeOrZero(quantity);
this.order = order;
this.customer = customer;
this.customerId = customerId;
this.email = email;
this.discountPercentage = discountPercentage;
this.quantity = quantity;
}
void ObjectDisposedExceptionExample(bool isDisposed)
{
ObjectDisposedException.ThrowIf(isDisposed, this);
ObjectDisposedException.ThrowIf(isDisposed, typeof(Consume));
}
Ensure example
void EnsureExample(Order order, Customer customer, string customerId, string email, decimal discountPercentage, int quantity)
{
this.order = Ensure.NotNull(order);
this.customer = Ensure.NotNull(customer);
this.customerId = Ensure.NotNullOrWhiteSpace(customerId);
this.email = Ensure.NotNullOrWhiteSpace(email);
this.discountPercentage = Ensure.NotGreaterThan(discountPercentage, 100m);
this.quantity = Ensure.NotNegativeOrZero(quantity);
}
APIs
Polyfills.Ensure provides the following APIs:
Ensure
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.IEnumerableT NotNull<T>(T)String NotNull(String)String NotNullOrEmpty(String)T NotNullOrEmpty<T>(T) where T : Collections.IEnumerableMemory<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>)
ArgumentException
Enable Argument*Exception polyfills by adding an MSBuild property PolyArgumentExceptions
<PropertyGroup>
...
<PolyArgumentExceptions>true</PolyArgumentExceptions>
</PropertyGroup>
Alternatives
PolyShim
https://github.com/Tyrrrz/PolyShim
PolySharp
https://github.com/Sergio0694/PolySharp
Theraot.Core
https://github.com/theraot/Theraot
Combination of
- https://github.com/manuelroemer/Nullable
- https://github.com/bgrainger/IndexRange
- https://github.com/manuelroemer/IsExternalInit
Reason this project was created instead of using the above
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.
Notes
Enumerable.Reverse for arrays
In C# 14, MemoryExtensions.Reverse(this Span<T>) becomes a candidate for array.Reverse() calls due to new implicit span conversions. This changes the behavior from returning IEnumerable<T> (via Enumerable.Reverse) to an in-place void reversal. .NET 10 fixes this by adding Enumerable.Reverse<T>(this T[]) to the BCL. This package includes a polyfill for that overload on older target frameworks.
This polyfill is placed in the System.Linq namespace (not Polyfills) because C# resolves extension methods from file-level using directives before global using directives. Since MemoryExtensions is found via using System;, a polyfill in Polyfills (available via global using) would not take precedence.
See compiler breaking changes - dotnet 10 for more details.
Icon
Crack designed by Adrien Coquet from The Noun Project.
