diff --git a/api_list.include.md b/api_list.include.md index 383f4ae4..b2af3939 100644 --- a/api_list.include.md +++ b/api_list.include.md @@ -840,6 +840,11 @@ * `bool IsMatch(ReadOnlySpan, string)` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.text.regularexpressions.regex.ismatch?view=net-11.0#system-text-regularexpressions-regex-ismatch(system-readonlyspan((system-char))-system-string)) +#### RuntimeFeature + + * `IsMultithreadingSupported` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.runtimefeature.ismultithreadingsupported?view=net-11.0) + + #### SByte * `bool TryFormat(Span, int, ReadOnlySpan, IFormatProvider?)` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.sbyte.tryformat?view=net-11.0#system-sbyte-tryformat(system-span((system-byte))-system-int32@-system-readonlyspan((system-char))-system-iformatprovider)) diff --git a/src/Consume/Consume.cs b/src/Consume/Consume.cs index 418a338a..b45bb3a9 100644 --- a/src/Consume/Consume.cs +++ b/src/Consume/Consume.cs @@ -779,6 +779,13 @@ void Stopwatch_Methods() elapsed = Stopwatch.GetElapsedTime(timestamp, Stopwatch.GetTimestamp()); } +#if NET471_OR_GREATER || NETCOREAPP || NETSTANDARD2_1_OR_GREATER + void RuntimeFeature_Methods() + { + var supported = RuntimeFeature.IsMultithreadingSupported; + } +#endif + void Path_Methods() { var relative = Path.GetRelativePath("/folder1/folder2", "/folder1/folder3"); diff --git a/src/Polyfill/RuntimeFeaturePolyfill.cs b/src/Polyfill/RuntimeFeaturePolyfill.cs new file mode 100644 index 00000000..be728595 --- /dev/null +++ b/src/Polyfill/RuntimeFeaturePolyfill.cs @@ -0,0 +1,19 @@ +#if !NET11_0_OR_GREATER && (NET471_OR_GREATER || NETCOREAPP || NETSTANDARD2_1_OR_GREATER) + +namespace Polyfills; + +using System.Runtime.CompilerServices; + +static partial class Polyfill +{ + extension(RuntimeFeature) + { + /// + /// Gets a value that indicates whether the runtime supports multithreading. + /// + //Link: https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.runtimefeature.ismultithreadingsupported?view=net-11.0 + public static bool IsMultithreadingSupported => true; + } +} + +#endif diff --git a/src/Split/net10.0/RuntimeFeaturePolyfill.cs b/src/Split/net10.0/RuntimeFeaturePolyfill.cs new file mode 100644 index 00000000..95140e20 --- /dev/null +++ b/src/Split/net10.0/RuntimeFeaturePolyfill.cs @@ -0,0 +1,14 @@ +// +#pragma warning disable +namespace Polyfills; +using System.Runtime.CompilerServices; +static partial class Polyfill +{ + extension(RuntimeFeature) + { + /// + /// Gets a value that indicates whether the runtime supports multithreading. + /// + public static bool IsMultithreadingSupported => true; + } +} diff --git a/src/Split/net471/RuntimeFeaturePolyfill.cs b/src/Split/net471/RuntimeFeaturePolyfill.cs new file mode 100644 index 00000000..95140e20 --- /dev/null +++ b/src/Split/net471/RuntimeFeaturePolyfill.cs @@ -0,0 +1,14 @@ +// +#pragma warning disable +namespace Polyfills; +using System.Runtime.CompilerServices; +static partial class Polyfill +{ + extension(RuntimeFeature) + { + /// + /// Gets a value that indicates whether the runtime supports multithreading. + /// + public static bool IsMultithreadingSupported => true; + } +} diff --git a/src/Split/net472/RuntimeFeaturePolyfill.cs b/src/Split/net472/RuntimeFeaturePolyfill.cs new file mode 100644 index 00000000..95140e20 --- /dev/null +++ b/src/Split/net472/RuntimeFeaturePolyfill.cs @@ -0,0 +1,14 @@ +// +#pragma warning disable +namespace Polyfills; +using System.Runtime.CompilerServices; +static partial class Polyfill +{ + extension(RuntimeFeature) + { + /// + /// Gets a value that indicates whether the runtime supports multithreading. + /// + public static bool IsMultithreadingSupported => true; + } +} diff --git a/src/Split/net48/RuntimeFeaturePolyfill.cs b/src/Split/net48/RuntimeFeaturePolyfill.cs new file mode 100644 index 00000000..95140e20 --- /dev/null +++ b/src/Split/net48/RuntimeFeaturePolyfill.cs @@ -0,0 +1,14 @@ +// +#pragma warning disable +namespace Polyfills; +using System.Runtime.CompilerServices; +static partial class Polyfill +{ + extension(RuntimeFeature) + { + /// + /// Gets a value that indicates whether the runtime supports multithreading. + /// + public static bool IsMultithreadingSupported => true; + } +} diff --git a/src/Split/net481/RuntimeFeaturePolyfill.cs b/src/Split/net481/RuntimeFeaturePolyfill.cs new file mode 100644 index 00000000..95140e20 --- /dev/null +++ b/src/Split/net481/RuntimeFeaturePolyfill.cs @@ -0,0 +1,14 @@ +// +#pragma warning disable +namespace Polyfills; +using System.Runtime.CompilerServices; +static partial class Polyfill +{ + extension(RuntimeFeature) + { + /// + /// Gets a value that indicates whether the runtime supports multithreading. + /// + public static bool IsMultithreadingSupported => true; + } +} diff --git a/src/Split/net5.0/RuntimeFeaturePolyfill.cs b/src/Split/net5.0/RuntimeFeaturePolyfill.cs new file mode 100644 index 00000000..95140e20 --- /dev/null +++ b/src/Split/net5.0/RuntimeFeaturePolyfill.cs @@ -0,0 +1,14 @@ +// +#pragma warning disable +namespace Polyfills; +using System.Runtime.CompilerServices; +static partial class Polyfill +{ + extension(RuntimeFeature) + { + /// + /// Gets a value that indicates whether the runtime supports multithreading. + /// + public static bool IsMultithreadingSupported => true; + } +} diff --git a/src/Split/net6.0/RuntimeFeaturePolyfill.cs b/src/Split/net6.0/RuntimeFeaturePolyfill.cs new file mode 100644 index 00000000..95140e20 --- /dev/null +++ b/src/Split/net6.0/RuntimeFeaturePolyfill.cs @@ -0,0 +1,14 @@ +// +#pragma warning disable +namespace Polyfills; +using System.Runtime.CompilerServices; +static partial class Polyfill +{ + extension(RuntimeFeature) + { + /// + /// Gets a value that indicates whether the runtime supports multithreading. + /// + public static bool IsMultithreadingSupported => true; + } +} diff --git a/src/Split/net7.0/RuntimeFeaturePolyfill.cs b/src/Split/net7.0/RuntimeFeaturePolyfill.cs new file mode 100644 index 00000000..95140e20 --- /dev/null +++ b/src/Split/net7.0/RuntimeFeaturePolyfill.cs @@ -0,0 +1,14 @@ +// +#pragma warning disable +namespace Polyfills; +using System.Runtime.CompilerServices; +static partial class Polyfill +{ + extension(RuntimeFeature) + { + /// + /// Gets a value that indicates whether the runtime supports multithreading. + /// + public static bool IsMultithreadingSupported => true; + } +} diff --git a/src/Split/net8.0/RuntimeFeaturePolyfill.cs b/src/Split/net8.0/RuntimeFeaturePolyfill.cs new file mode 100644 index 00000000..95140e20 --- /dev/null +++ b/src/Split/net8.0/RuntimeFeaturePolyfill.cs @@ -0,0 +1,14 @@ +// +#pragma warning disable +namespace Polyfills; +using System.Runtime.CompilerServices; +static partial class Polyfill +{ + extension(RuntimeFeature) + { + /// + /// Gets a value that indicates whether the runtime supports multithreading. + /// + public static bool IsMultithreadingSupported => true; + } +} diff --git a/src/Split/net9.0/RuntimeFeaturePolyfill.cs b/src/Split/net9.0/RuntimeFeaturePolyfill.cs new file mode 100644 index 00000000..95140e20 --- /dev/null +++ b/src/Split/net9.0/RuntimeFeaturePolyfill.cs @@ -0,0 +1,14 @@ +// +#pragma warning disable +namespace Polyfills; +using System.Runtime.CompilerServices; +static partial class Polyfill +{ + extension(RuntimeFeature) + { + /// + /// Gets a value that indicates whether the runtime supports multithreading. + /// + public static bool IsMultithreadingSupported => true; + } +} diff --git a/src/Split/netcoreapp2.0/RuntimeFeaturePolyfill.cs b/src/Split/netcoreapp2.0/RuntimeFeaturePolyfill.cs new file mode 100644 index 00000000..95140e20 --- /dev/null +++ b/src/Split/netcoreapp2.0/RuntimeFeaturePolyfill.cs @@ -0,0 +1,14 @@ +// +#pragma warning disable +namespace Polyfills; +using System.Runtime.CompilerServices; +static partial class Polyfill +{ + extension(RuntimeFeature) + { + /// + /// Gets a value that indicates whether the runtime supports multithreading. + /// + public static bool IsMultithreadingSupported => true; + } +} diff --git a/src/Split/netcoreapp2.1/RuntimeFeaturePolyfill.cs b/src/Split/netcoreapp2.1/RuntimeFeaturePolyfill.cs new file mode 100644 index 00000000..95140e20 --- /dev/null +++ b/src/Split/netcoreapp2.1/RuntimeFeaturePolyfill.cs @@ -0,0 +1,14 @@ +// +#pragma warning disable +namespace Polyfills; +using System.Runtime.CompilerServices; +static partial class Polyfill +{ + extension(RuntimeFeature) + { + /// + /// Gets a value that indicates whether the runtime supports multithreading. + /// + public static bool IsMultithreadingSupported => true; + } +} diff --git a/src/Split/netcoreapp2.2/RuntimeFeaturePolyfill.cs b/src/Split/netcoreapp2.2/RuntimeFeaturePolyfill.cs new file mode 100644 index 00000000..95140e20 --- /dev/null +++ b/src/Split/netcoreapp2.2/RuntimeFeaturePolyfill.cs @@ -0,0 +1,14 @@ +// +#pragma warning disable +namespace Polyfills; +using System.Runtime.CompilerServices; +static partial class Polyfill +{ + extension(RuntimeFeature) + { + /// + /// Gets a value that indicates whether the runtime supports multithreading. + /// + public static bool IsMultithreadingSupported => true; + } +} diff --git a/src/Split/netcoreapp3.0/RuntimeFeaturePolyfill.cs b/src/Split/netcoreapp3.0/RuntimeFeaturePolyfill.cs new file mode 100644 index 00000000..95140e20 --- /dev/null +++ b/src/Split/netcoreapp3.0/RuntimeFeaturePolyfill.cs @@ -0,0 +1,14 @@ +// +#pragma warning disable +namespace Polyfills; +using System.Runtime.CompilerServices; +static partial class Polyfill +{ + extension(RuntimeFeature) + { + /// + /// Gets a value that indicates whether the runtime supports multithreading. + /// + public static bool IsMultithreadingSupported => true; + } +} diff --git a/src/Split/netcoreapp3.1/RuntimeFeaturePolyfill.cs b/src/Split/netcoreapp3.1/RuntimeFeaturePolyfill.cs new file mode 100644 index 00000000..95140e20 --- /dev/null +++ b/src/Split/netcoreapp3.1/RuntimeFeaturePolyfill.cs @@ -0,0 +1,14 @@ +// +#pragma warning disable +namespace Polyfills; +using System.Runtime.CompilerServices; +static partial class Polyfill +{ + extension(RuntimeFeature) + { + /// + /// Gets a value that indicates whether the runtime supports multithreading. + /// + public static bool IsMultithreadingSupported => true; + } +} diff --git a/src/Split/netstandard2.1/RuntimeFeaturePolyfill.cs b/src/Split/netstandard2.1/RuntimeFeaturePolyfill.cs new file mode 100644 index 00000000..95140e20 --- /dev/null +++ b/src/Split/netstandard2.1/RuntimeFeaturePolyfill.cs @@ -0,0 +1,14 @@ +// +#pragma warning disable +namespace Polyfills; +using System.Runtime.CompilerServices; +static partial class Polyfill +{ + extension(RuntimeFeature) + { + /// + /// Gets a value that indicates whether the runtime supports multithreading. + /// + public static bool IsMultithreadingSupported => true; + } +} diff --git a/src/Tests/PolyfillTests_RuntimeFeature.cs b/src/Tests/PolyfillTests_RuntimeFeature.cs new file mode 100644 index 00000000..96d3dc92 --- /dev/null +++ b/src/Tests/PolyfillTests_RuntimeFeature.cs @@ -0,0 +1,14 @@ +#if NET471_OR_GREATER || NETCOREAPP || NETSTANDARD2_1_OR_GREATER + +using System.Runtime.CompilerServices; + +partial class PolyfillTests +{ + [Test] + public async Task RuntimeFeatureIsMultithreadingSupported() + { + await Assert.That(RuntimeFeature.IsMultithreadingSupported).IsTrue(); + } +} + +#endif