From 9b071457ea47b9711cb33bf7cdca02589dd5c343 Mon Sep 17 00:00:00 2001 From: Simon Cropp Date: Tue, 3 Mar 2026 20:34:27 +1100 Subject: [PATCH 1/2] AggressiveInlining --- src/Polyfill/ConsolePolyfill.cs | 4 ++++ src/Polyfill/ConvertPolyfill.cs | 8 +++++++ src/Polyfill/DateTimeOffsetPolyfill.cs | 7 ++++++ src/Polyfill/DateTimePolyfill.cs | 7 ++++++ src/Polyfill/DelegatePolyfill.cs | 2 ++ src/Polyfill/FilePolyfill.cs | 4 ++++ src/Polyfill/GuidPolyfill.cs | 8 +++++++ src/Polyfill/KeyValuePair.cs | 2 ++ src/Polyfill/Lock.cs | 6 +++++ src/Polyfill/Numbers/BytePolyfill.cs | 8 +++++++ src/Polyfill/Numbers/DoublePolyfill.cs | 8 +++++++ src/Polyfill/Numbers/Int16Polyfill.cs | 8 +++++++ src/Polyfill/Numbers/Int32Polyfill.cs | 8 +++++++ src/Polyfill/Numbers/Int64Polyfill.cs | 8 +++++++ src/Polyfill/Numbers/SBytePolyfill.cs | 8 +++++++ src/Polyfill/Numbers/UInt16Polyfill.cs | 8 +++++++ src/Polyfill/Numbers/UInt32Polyfill.cs | 8 +++++++ src/Polyfill/Numbers/UInt64Polyfill.cs | 8 +++++++ src/Polyfill/OperatingSystemPolyfill.cs | 22 +++++++++++++++++++ src/Polyfill/PathPolyfill.cs | 9 ++++++++ src/Split/net10.0/ConsolePolyfill.cs | 4 ++++ src/Split/net11.0/ConsolePolyfill.cs | 4 ++++ src/Split/net461/ConsolePolyfill.cs | 4 ++++ src/Split/net461/ConvertPolyfill.cs | 8 +++++++ src/Split/net461/DateTimeOffsetPolyfill.cs | 7 ++++++ src/Split/net461/DateTimePolyfill.cs | 7 ++++++ src/Split/net461/DelegatePolyfill.cs | 2 ++ src/Split/net461/FilePolyfill.cs | 4 ++++ src/Split/net461/GuidPolyfill.cs | 8 +++++++ src/Split/net461/KeyValuePair.cs | 2 ++ src/Split/net461/Lock.cs | 6 +++++ src/Split/net461/Numbers/BytePolyfill.cs | 8 +++++++ src/Split/net461/Numbers/DoublePolyfill.cs | 8 +++++++ src/Split/net461/Numbers/Int16Polyfill.cs | 8 +++++++ src/Split/net461/Numbers/Int32Polyfill.cs | 8 +++++++ src/Split/net461/Numbers/Int64Polyfill.cs | 8 +++++++ src/Split/net461/Numbers/SBytePolyfill.cs | 8 +++++++ src/Split/net461/Numbers/UInt16Polyfill.cs | 8 +++++++ src/Split/net461/Numbers/UInt32Polyfill.cs | 8 +++++++ src/Split/net461/Numbers/UInt64Polyfill.cs | 8 +++++++ src/Split/net461/OperatingSystemPolyfill.cs | 22 +++++++++++++++++++ src/Split/net461/PathPolyfill.cs | 9 ++++++++ src/Split/net462/ConsolePolyfill.cs | 4 ++++ src/Split/net462/ConvertPolyfill.cs | 8 +++++++ src/Split/net462/DateTimeOffsetPolyfill.cs | 7 ++++++ src/Split/net462/DateTimePolyfill.cs | 7 ++++++ src/Split/net462/DelegatePolyfill.cs | 2 ++ src/Split/net462/FilePolyfill.cs | 4 ++++ src/Split/net462/GuidPolyfill.cs | 8 +++++++ src/Split/net462/KeyValuePair.cs | 2 ++ src/Split/net462/Lock.cs | 6 +++++ src/Split/net462/Numbers/BytePolyfill.cs | 8 +++++++ src/Split/net462/Numbers/DoublePolyfill.cs | 8 +++++++ src/Split/net462/Numbers/Int16Polyfill.cs | 8 +++++++ src/Split/net462/Numbers/Int32Polyfill.cs | 8 +++++++ src/Split/net462/Numbers/Int64Polyfill.cs | 8 +++++++ src/Split/net462/Numbers/SBytePolyfill.cs | 8 +++++++ src/Split/net462/Numbers/UInt16Polyfill.cs | 8 +++++++ src/Split/net462/Numbers/UInt32Polyfill.cs | 8 +++++++ src/Split/net462/Numbers/UInt64Polyfill.cs | 8 +++++++ src/Split/net462/OperatingSystemPolyfill.cs | 22 +++++++++++++++++++ src/Split/net462/PathPolyfill.cs | 9 ++++++++ src/Split/net47/ConsolePolyfill.cs | 4 ++++ src/Split/net47/ConvertPolyfill.cs | 8 +++++++ src/Split/net47/DateTimeOffsetPolyfill.cs | 7 ++++++ src/Split/net47/DateTimePolyfill.cs | 7 ++++++ src/Split/net47/DelegatePolyfill.cs | 2 ++ src/Split/net47/FilePolyfill.cs | 4 ++++ src/Split/net47/GuidPolyfill.cs | 8 +++++++ src/Split/net47/KeyValuePair.cs | 2 ++ src/Split/net47/Lock.cs | 6 +++++ src/Split/net47/Numbers/BytePolyfill.cs | 8 +++++++ src/Split/net47/Numbers/DoublePolyfill.cs | 8 +++++++ src/Split/net47/Numbers/Int16Polyfill.cs | 8 +++++++ src/Split/net47/Numbers/Int32Polyfill.cs | 8 +++++++ src/Split/net47/Numbers/Int64Polyfill.cs | 8 +++++++ src/Split/net47/Numbers/SBytePolyfill.cs | 8 +++++++ src/Split/net47/Numbers/UInt16Polyfill.cs | 8 +++++++ src/Split/net47/Numbers/UInt32Polyfill.cs | 8 +++++++ src/Split/net47/Numbers/UInt64Polyfill.cs | 8 +++++++ src/Split/net47/OperatingSystemPolyfill.cs | 22 +++++++++++++++++++ src/Split/net47/PathPolyfill.cs | 9 ++++++++ src/Split/net471/ConsolePolyfill.cs | 4 ++++ src/Split/net471/ConvertPolyfill.cs | 8 +++++++ src/Split/net471/DateTimeOffsetPolyfill.cs | 7 ++++++ src/Split/net471/DateTimePolyfill.cs | 7 ++++++ src/Split/net471/DelegatePolyfill.cs | 2 ++ src/Split/net471/FilePolyfill.cs | 4 ++++ src/Split/net471/GuidPolyfill.cs | 8 +++++++ src/Split/net471/KeyValuePair.cs | 2 ++ src/Split/net471/Lock.cs | 6 +++++ src/Split/net471/Numbers/BytePolyfill.cs | 8 +++++++ src/Split/net471/Numbers/DoublePolyfill.cs | 8 +++++++ src/Split/net471/Numbers/Int16Polyfill.cs | 8 +++++++ src/Split/net471/Numbers/Int32Polyfill.cs | 8 +++++++ src/Split/net471/Numbers/Int64Polyfill.cs | 8 +++++++ src/Split/net471/Numbers/SBytePolyfill.cs | 8 +++++++ src/Split/net471/Numbers/UInt16Polyfill.cs | 8 +++++++ src/Split/net471/Numbers/UInt32Polyfill.cs | 8 +++++++ src/Split/net471/Numbers/UInt64Polyfill.cs | 8 +++++++ src/Split/net471/OperatingSystemPolyfill.cs | 22 +++++++++++++++++++ src/Split/net471/PathPolyfill.cs | 9 ++++++++ src/Split/net472/ConsolePolyfill.cs | 4 ++++ src/Split/net472/ConvertPolyfill.cs | 8 +++++++ src/Split/net472/DateTimeOffsetPolyfill.cs | 7 ++++++ src/Split/net472/DateTimePolyfill.cs | 7 ++++++ src/Split/net472/DelegatePolyfill.cs | 2 ++ src/Split/net472/FilePolyfill.cs | 4 ++++ src/Split/net472/GuidPolyfill.cs | 8 +++++++ src/Split/net472/KeyValuePair.cs | 2 ++ src/Split/net472/Lock.cs | 6 +++++ src/Split/net472/Numbers/BytePolyfill.cs | 8 +++++++ src/Split/net472/Numbers/DoublePolyfill.cs | 8 +++++++ src/Split/net472/Numbers/Int16Polyfill.cs | 8 +++++++ src/Split/net472/Numbers/Int32Polyfill.cs | 8 +++++++ src/Split/net472/Numbers/Int64Polyfill.cs | 8 +++++++ src/Split/net472/Numbers/SBytePolyfill.cs | 8 +++++++ src/Split/net472/Numbers/UInt16Polyfill.cs | 8 +++++++ src/Split/net472/Numbers/UInt32Polyfill.cs | 8 +++++++ src/Split/net472/Numbers/UInt64Polyfill.cs | 8 +++++++ src/Split/net472/OperatingSystemPolyfill.cs | 22 +++++++++++++++++++ src/Split/net472/PathPolyfill.cs | 9 ++++++++ src/Split/net48/ConsolePolyfill.cs | 4 ++++ src/Split/net48/ConvertPolyfill.cs | 8 +++++++ src/Split/net48/DateTimeOffsetPolyfill.cs | 7 ++++++ src/Split/net48/DateTimePolyfill.cs | 7 ++++++ src/Split/net48/DelegatePolyfill.cs | 2 ++ src/Split/net48/FilePolyfill.cs | 4 ++++ src/Split/net48/GuidPolyfill.cs | 8 +++++++ src/Split/net48/KeyValuePair.cs | 2 ++ src/Split/net48/Lock.cs | 6 +++++ src/Split/net48/Numbers/BytePolyfill.cs | 8 +++++++ src/Split/net48/Numbers/DoublePolyfill.cs | 8 +++++++ src/Split/net48/Numbers/Int16Polyfill.cs | 8 +++++++ src/Split/net48/Numbers/Int32Polyfill.cs | 8 +++++++ src/Split/net48/Numbers/Int64Polyfill.cs | 8 +++++++ src/Split/net48/Numbers/SBytePolyfill.cs | 8 +++++++ src/Split/net48/Numbers/UInt16Polyfill.cs | 8 +++++++ src/Split/net48/Numbers/UInt32Polyfill.cs | 8 +++++++ src/Split/net48/Numbers/UInt64Polyfill.cs | 8 +++++++ src/Split/net48/OperatingSystemPolyfill.cs | 22 +++++++++++++++++++ src/Split/net48/PathPolyfill.cs | 9 ++++++++ src/Split/net481/ConsolePolyfill.cs | 4 ++++ src/Split/net481/ConvertPolyfill.cs | 8 +++++++ src/Split/net481/DateTimeOffsetPolyfill.cs | 7 ++++++ src/Split/net481/DateTimePolyfill.cs | 7 ++++++ src/Split/net481/DelegatePolyfill.cs | 2 ++ src/Split/net481/FilePolyfill.cs | 4 ++++ src/Split/net481/GuidPolyfill.cs | 8 +++++++ src/Split/net481/KeyValuePair.cs | 2 ++ src/Split/net481/Lock.cs | 6 +++++ src/Split/net481/Numbers/BytePolyfill.cs | 8 +++++++ src/Split/net481/Numbers/DoublePolyfill.cs | 8 +++++++ src/Split/net481/Numbers/Int16Polyfill.cs | 8 +++++++ src/Split/net481/Numbers/Int32Polyfill.cs | 8 +++++++ src/Split/net481/Numbers/Int64Polyfill.cs | 8 +++++++ src/Split/net481/Numbers/SBytePolyfill.cs | 8 +++++++ src/Split/net481/Numbers/UInt16Polyfill.cs | 8 +++++++ src/Split/net481/Numbers/UInt32Polyfill.cs | 8 +++++++ src/Split/net481/Numbers/UInt64Polyfill.cs | 8 +++++++ src/Split/net481/OperatingSystemPolyfill.cs | 22 +++++++++++++++++++ src/Split/net481/PathPolyfill.cs | 9 ++++++++ src/Split/net5.0/ConsolePolyfill.cs | 4 ++++ src/Split/net5.0/ConvertPolyfill.cs | 4 ++++ src/Split/net5.0/DateTimeOffsetPolyfill.cs | 3 +++ src/Split/net5.0/DateTimePolyfill.cs | 4 ++++ src/Split/net5.0/DelegatePolyfill.cs | 2 ++ src/Split/net5.0/FilePolyfill.cs | 4 ++++ src/Split/net5.0/GuidPolyfill.cs | 6 +++++ src/Split/net5.0/Lock.cs | 6 +++++ src/Split/net5.0/Numbers/BytePolyfill.cs | 6 +++++ src/Split/net5.0/Numbers/DoublePolyfill.cs | 6 +++++ src/Split/net5.0/Numbers/Int16Polyfill.cs | 6 +++++ src/Split/net5.0/Numbers/Int32Polyfill.cs | 6 +++++ src/Split/net5.0/Numbers/Int64Polyfill.cs | 6 +++++ src/Split/net5.0/Numbers/SBytePolyfill.cs | 6 +++++ src/Split/net5.0/Numbers/UInt16Polyfill.cs | 6 +++++ src/Split/net5.0/Numbers/UInt32Polyfill.cs | 6 +++++ src/Split/net5.0/Numbers/UInt64Polyfill.cs | 6 +++++ src/Split/net5.0/OperatingSystemPolyfill.cs | 4 ++++ src/Split/net5.0/PathPolyfill.cs | 2 ++ src/Split/net6.0/ConsolePolyfill.cs | 4 ++++ src/Split/net6.0/ConvertPolyfill.cs | 4 ++++ src/Split/net6.0/DateTimeOffsetPolyfill.cs | 3 +++ src/Split/net6.0/DateTimePolyfill.cs | 4 ++++ src/Split/net6.0/DelegatePolyfill.cs | 2 ++ src/Split/net6.0/FilePolyfill.cs | 4 ++++ src/Split/net6.0/GuidPolyfill.cs | 6 +++++ src/Split/net6.0/Lock.cs | 6 +++++ src/Split/net6.0/Numbers/BytePolyfill.cs | 6 +++++ src/Split/net6.0/Numbers/DoublePolyfill.cs | 6 +++++ src/Split/net6.0/Numbers/Int16Polyfill.cs | 6 +++++ src/Split/net6.0/Numbers/Int32Polyfill.cs | 6 +++++ src/Split/net6.0/Numbers/Int64Polyfill.cs | 6 +++++ src/Split/net6.0/Numbers/SBytePolyfill.cs | 6 +++++ src/Split/net6.0/Numbers/UInt16Polyfill.cs | 6 +++++ src/Split/net6.0/Numbers/UInt32Polyfill.cs | 6 +++++ src/Split/net6.0/Numbers/UInt64Polyfill.cs | 6 +++++ src/Split/net6.0/OperatingSystemPolyfill.cs | 2 ++ src/Split/net6.0/PathPolyfill.cs | 2 ++ src/Split/net7.0/ConsolePolyfill.cs | 4 ++++ src/Split/net7.0/ConvertPolyfill.cs | 4 ++++ src/Split/net7.0/DateTimeOffsetPolyfill.cs | 2 ++ src/Split/net7.0/DateTimePolyfill.cs | 3 +++ src/Split/net7.0/DelegatePolyfill.cs | 2 ++ src/Split/net7.0/FilePolyfill.cs | 4 ++++ src/Split/net7.0/GuidPolyfill.cs | 4 ++++ src/Split/net7.0/Lock.cs | 6 +++++ src/Split/net7.0/Numbers/BytePolyfill.cs | 4 ++++ src/Split/net7.0/Numbers/DoublePolyfill.cs | 4 ++++ src/Split/net7.0/Numbers/Int16Polyfill.cs | 4 ++++ src/Split/net7.0/Numbers/Int32Polyfill.cs | 4 ++++ src/Split/net7.0/Numbers/Int64Polyfill.cs | 4 ++++ src/Split/net7.0/Numbers/SBytePolyfill.cs | 4 ++++ src/Split/net7.0/Numbers/UInt16Polyfill.cs | 4 ++++ src/Split/net7.0/Numbers/UInt32Polyfill.cs | 4 ++++ src/Split/net7.0/Numbers/UInt64Polyfill.cs | 4 ++++ src/Split/net7.0/OperatingSystemPolyfill.cs | 2 ++ src/Split/net7.0/PathPolyfill.cs | 2 ++ src/Split/net8.0/ConsolePolyfill.cs | 4 ++++ src/Split/net8.0/ConvertPolyfill.cs | 4 ++++ src/Split/net8.0/DelegatePolyfill.cs | 2 ++ src/Split/net8.0/FilePolyfill.cs | 4 ++++ src/Split/net8.0/GuidPolyfill.cs | 4 ++++ src/Split/net8.0/Lock.cs | 6 +++++ src/Split/net8.0/PathPolyfill.cs | 2 ++ src/Split/net9.0/ConsolePolyfill.cs | 4 ++++ src/Split/net9.0/GuidPolyfill.cs | 3 +++ src/Split/netcoreapp2.0/ConsolePolyfill.cs | 4 ++++ src/Split/netcoreapp2.0/ConvertPolyfill.cs | 8 +++++++ .../netcoreapp2.0/DateTimeOffsetPolyfill.cs | 7 ++++++ src/Split/netcoreapp2.0/DateTimePolyfill.cs | 7 ++++++ src/Split/netcoreapp2.0/DelegatePolyfill.cs | 2 ++ src/Split/netcoreapp2.0/FilePolyfill.cs | 4 ++++ src/Split/netcoreapp2.0/GuidPolyfill.cs | 8 +++++++ src/Split/netcoreapp2.0/Lock.cs | 6 +++++ .../netcoreapp2.0/Numbers/BytePolyfill.cs | 8 +++++++ .../netcoreapp2.0/Numbers/DoublePolyfill.cs | 8 +++++++ .../netcoreapp2.0/Numbers/Int16Polyfill.cs | 8 +++++++ .../netcoreapp2.0/Numbers/Int32Polyfill.cs | 8 +++++++ .../netcoreapp2.0/Numbers/Int64Polyfill.cs | 8 +++++++ .../netcoreapp2.0/Numbers/SBytePolyfill.cs | 8 +++++++ .../netcoreapp2.0/Numbers/UInt16Polyfill.cs | 8 +++++++ .../netcoreapp2.0/Numbers/UInt32Polyfill.cs | 8 +++++++ .../netcoreapp2.0/Numbers/UInt64Polyfill.cs | 8 +++++++ .../netcoreapp2.0/OperatingSystemPolyfill.cs | 22 +++++++++++++++++++ src/Split/netcoreapp2.0/PathPolyfill.cs | 9 ++++++++ src/Split/netcoreapp2.1/ConsolePolyfill.cs | 4 ++++ src/Split/netcoreapp2.1/ConvertPolyfill.cs | 8 +++++++ .../netcoreapp2.1/DateTimeOffsetPolyfill.cs | 6 +++++ src/Split/netcoreapp2.1/DateTimePolyfill.cs | 7 ++++++ src/Split/netcoreapp2.1/DelegatePolyfill.cs | 2 ++ src/Split/netcoreapp2.1/FilePolyfill.cs | 4 ++++ src/Split/netcoreapp2.1/GuidPolyfill.cs | 7 ++++++ src/Split/netcoreapp2.1/Lock.cs | 6 +++++ .../netcoreapp2.1/Numbers/BytePolyfill.cs | 6 +++++ .../netcoreapp2.1/Numbers/DoublePolyfill.cs | 6 +++++ .../netcoreapp2.1/Numbers/Int16Polyfill.cs | 6 +++++ .../netcoreapp2.1/Numbers/Int32Polyfill.cs | 6 +++++ .../netcoreapp2.1/Numbers/Int64Polyfill.cs | 6 +++++ .../netcoreapp2.1/Numbers/SBytePolyfill.cs | 6 +++++ .../netcoreapp2.1/Numbers/UInt16Polyfill.cs | 6 +++++ .../netcoreapp2.1/Numbers/UInt32Polyfill.cs | 6 +++++ .../netcoreapp2.1/Numbers/UInt64Polyfill.cs | 6 +++++ .../netcoreapp2.1/OperatingSystemPolyfill.cs | 22 +++++++++++++++++++ src/Split/netcoreapp2.1/PathPolyfill.cs | 4 ++++ src/Split/netcoreapp2.2/ConsolePolyfill.cs | 4 ++++ src/Split/netcoreapp2.2/ConvertPolyfill.cs | 8 +++++++ .../netcoreapp2.2/DateTimeOffsetPolyfill.cs | 6 +++++ src/Split/netcoreapp2.2/DateTimePolyfill.cs | 7 ++++++ src/Split/netcoreapp2.2/DelegatePolyfill.cs | 2 ++ src/Split/netcoreapp2.2/FilePolyfill.cs | 4 ++++ src/Split/netcoreapp2.2/GuidPolyfill.cs | 7 ++++++ src/Split/netcoreapp2.2/Lock.cs | 6 +++++ .../netcoreapp2.2/Numbers/BytePolyfill.cs | 6 +++++ .../netcoreapp2.2/Numbers/DoublePolyfill.cs | 6 +++++ .../netcoreapp2.2/Numbers/Int16Polyfill.cs | 6 +++++ .../netcoreapp2.2/Numbers/Int32Polyfill.cs | 6 +++++ .../netcoreapp2.2/Numbers/Int64Polyfill.cs | 6 +++++ .../netcoreapp2.2/Numbers/SBytePolyfill.cs | 6 +++++ .../netcoreapp2.2/Numbers/UInt16Polyfill.cs | 6 +++++ .../netcoreapp2.2/Numbers/UInt32Polyfill.cs | 6 +++++ .../netcoreapp2.2/Numbers/UInt64Polyfill.cs | 6 +++++ .../netcoreapp2.2/OperatingSystemPolyfill.cs | 22 +++++++++++++++++++ src/Split/netcoreapp2.2/PathPolyfill.cs | 4 ++++ src/Split/netcoreapp3.0/ConsolePolyfill.cs | 4 ++++ src/Split/netcoreapp3.0/ConvertPolyfill.cs | 8 +++++++ .../netcoreapp3.0/DateTimeOffsetPolyfill.cs | 6 +++++ src/Split/netcoreapp3.0/DateTimePolyfill.cs | 7 ++++++ src/Split/netcoreapp3.0/DelegatePolyfill.cs | 2 ++ src/Split/netcoreapp3.0/FilePolyfill.cs | 4 ++++ src/Split/netcoreapp3.0/GuidPolyfill.cs | 7 ++++++ src/Split/netcoreapp3.0/Lock.cs | 6 +++++ .../netcoreapp3.0/Numbers/BytePolyfill.cs | 6 +++++ .../netcoreapp3.0/Numbers/DoublePolyfill.cs | 6 +++++ .../netcoreapp3.0/Numbers/Int16Polyfill.cs | 6 +++++ .../netcoreapp3.0/Numbers/Int32Polyfill.cs | 6 +++++ .../netcoreapp3.0/Numbers/Int64Polyfill.cs | 6 +++++ .../netcoreapp3.0/Numbers/SBytePolyfill.cs | 6 +++++ .../netcoreapp3.0/Numbers/UInt16Polyfill.cs | 6 +++++ .../netcoreapp3.0/Numbers/UInt32Polyfill.cs | 6 +++++ .../netcoreapp3.0/Numbers/UInt64Polyfill.cs | 6 +++++ .../netcoreapp3.0/OperatingSystemPolyfill.cs | 22 +++++++++++++++++++ src/Split/netcoreapp3.0/PathPolyfill.cs | 2 ++ src/Split/netcoreapp3.1/ConsolePolyfill.cs | 4 ++++ src/Split/netcoreapp3.1/ConvertPolyfill.cs | 8 +++++++ .../netcoreapp3.1/DateTimeOffsetPolyfill.cs | 6 +++++ src/Split/netcoreapp3.1/DateTimePolyfill.cs | 7 ++++++ src/Split/netcoreapp3.1/DelegatePolyfill.cs | 2 ++ src/Split/netcoreapp3.1/FilePolyfill.cs | 4 ++++ src/Split/netcoreapp3.1/GuidPolyfill.cs | 7 ++++++ src/Split/netcoreapp3.1/Lock.cs | 6 +++++ .../netcoreapp3.1/Numbers/BytePolyfill.cs | 6 +++++ .../netcoreapp3.1/Numbers/DoublePolyfill.cs | 6 +++++ .../netcoreapp3.1/Numbers/Int16Polyfill.cs | 6 +++++ .../netcoreapp3.1/Numbers/Int32Polyfill.cs | 6 +++++ .../netcoreapp3.1/Numbers/Int64Polyfill.cs | 6 +++++ .../netcoreapp3.1/Numbers/SBytePolyfill.cs | 6 +++++ .../netcoreapp3.1/Numbers/UInt16Polyfill.cs | 6 +++++ .../netcoreapp3.1/Numbers/UInt32Polyfill.cs | 6 +++++ .../netcoreapp3.1/Numbers/UInt64Polyfill.cs | 6 +++++ .../netcoreapp3.1/OperatingSystemPolyfill.cs | 22 +++++++++++++++++++ src/Split/netcoreapp3.1/PathPolyfill.cs | 2 ++ src/Split/netstandard2.0/ConsolePolyfill.cs | 4 ++++ src/Split/netstandard2.0/ConvertPolyfill.cs | 8 +++++++ .../netstandard2.0/DateTimeOffsetPolyfill.cs | 7 ++++++ src/Split/netstandard2.0/DateTimePolyfill.cs | 7 ++++++ src/Split/netstandard2.0/DelegatePolyfill.cs | 2 ++ src/Split/netstandard2.0/FilePolyfill.cs | 4 ++++ src/Split/netstandard2.0/GuidPolyfill.cs | 8 +++++++ src/Split/netstandard2.0/KeyValuePair.cs | 2 ++ src/Split/netstandard2.0/Lock.cs | 6 +++++ .../netstandard2.0/Numbers/BytePolyfill.cs | 8 +++++++ .../netstandard2.0/Numbers/DoublePolyfill.cs | 8 +++++++ .../netstandard2.0/Numbers/Int16Polyfill.cs | 8 +++++++ .../netstandard2.0/Numbers/Int32Polyfill.cs | 8 +++++++ .../netstandard2.0/Numbers/Int64Polyfill.cs | 8 +++++++ .../netstandard2.0/Numbers/SBytePolyfill.cs | 8 +++++++ .../netstandard2.0/Numbers/UInt16Polyfill.cs | 8 +++++++ .../netstandard2.0/Numbers/UInt32Polyfill.cs | 8 +++++++ .../netstandard2.0/Numbers/UInt64Polyfill.cs | 8 +++++++ .../netstandard2.0/OperatingSystemPolyfill.cs | 22 +++++++++++++++++++ src/Split/netstandard2.0/PathPolyfill.cs | 9 ++++++++ src/Split/netstandard2.1/ConsolePolyfill.cs | 4 ++++ src/Split/netstandard2.1/ConvertPolyfill.cs | 8 +++++++ .../netstandard2.1/DateTimeOffsetPolyfill.cs | 3 +++ src/Split/netstandard2.1/DateTimePolyfill.cs | 4 ++++ src/Split/netstandard2.1/DelegatePolyfill.cs | 2 ++ src/Split/netstandard2.1/FilePolyfill.cs | 4 ++++ src/Split/netstandard2.1/GuidPolyfill.cs | 6 +++++ src/Split/netstandard2.1/Lock.cs | 6 +++++ .../netstandard2.1/Numbers/BytePolyfill.cs | 6 +++++ .../netstandard2.1/Numbers/DoublePolyfill.cs | 6 +++++ .../netstandard2.1/Numbers/Int16Polyfill.cs | 6 +++++ .../netstandard2.1/Numbers/Int32Polyfill.cs | 6 +++++ .../netstandard2.1/Numbers/Int64Polyfill.cs | 6 +++++ .../netstandard2.1/Numbers/SBytePolyfill.cs | 6 +++++ .../netstandard2.1/Numbers/UInt16Polyfill.cs | 6 +++++ .../netstandard2.1/Numbers/UInt32Polyfill.cs | 6 +++++ .../netstandard2.1/Numbers/UInt64Polyfill.cs | 6 +++++ .../netstandard2.1/OperatingSystemPolyfill.cs | 22 +++++++++++++++++++ src/Split/netstandard2.1/PathPolyfill.cs | 4 ++++ src/Split/uap10.0/ConsolePolyfill.cs | 4 ++++ src/Split/uap10.0/ConvertPolyfill.cs | 8 +++++++ src/Split/uap10.0/DateTimeOffsetPolyfill.cs | 7 ++++++ src/Split/uap10.0/DateTimePolyfill.cs | 7 ++++++ src/Split/uap10.0/DelegatePolyfill.cs | 2 ++ src/Split/uap10.0/FilePolyfill.cs | 4 ++++ src/Split/uap10.0/GuidPolyfill.cs | 8 +++++++ src/Split/uap10.0/Lock.cs | 6 +++++ src/Split/uap10.0/Numbers/BytePolyfill.cs | 8 +++++++ src/Split/uap10.0/Numbers/DoublePolyfill.cs | 8 +++++++ src/Split/uap10.0/Numbers/Int16Polyfill.cs | 8 +++++++ src/Split/uap10.0/Numbers/Int32Polyfill.cs | 8 +++++++ src/Split/uap10.0/Numbers/Int64Polyfill.cs | 8 +++++++ src/Split/uap10.0/Numbers/SBytePolyfill.cs | 8 +++++++ src/Split/uap10.0/Numbers/UInt16Polyfill.cs | 8 +++++++ src/Split/uap10.0/Numbers/UInt32Polyfill.cs | 8 +++++++ src/Split/uap10.0/Numbers/UInt64Polyfill.cs | 8 +++++++ src/Split/uap10.0/OperatingSystemPolyfill.cs | 22 +++++++++++++++++++ src/Split/uap10.0/PathPolyfill.cs | 9 ++++++++ 381 files changed, 2560 insertions(+) diff --git a/src/Polyfill/ConsolePolyfill.cs b/src/Polyfill/ConsolePolyfill.cs index 8a8bf9e9c..b51f88498 100644 --- a/src/Polyfill/ConsolePolyfill.cs +++ b/src/Polyfill/ConsolePolyfill.cs @@ -4,6 +4,7 @@ namespace Polyfills; using System; using System.Runtime.InteropServices; +using System.Runtime.CompilerServices; using Microsoft.Win32.SafeHandles; static partial class Polyfill @@ -14,6 +15,7 @@ static partial class Polyfill /// Gets a that wraps the operating system handle for standard input. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.console.openstandardinputhandle?view=net-11.0 + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static SafeFileHandle OpenStandardInputHandle() => StandardHandleHelper.GetStandardHandle(StandardHandleHelper.StdInput); @@ -21,6 +23,7 @@ public static SafeFileHandle OpenStandardInputHandle() => /// Gets a that wraps the operating system handle for standard output. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.console.openstandardoutputhandle?view=net-11.0 + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static SafeFileHandle OpenStandardOutputHandle() => StandardHandleHelper.GetStandardHandle(StandardHandleHelper.StdOutput); @@ -28,6 +31,7 @@ public static SafeFileHandle OpenStandardOutputHandle() => /// Gets a that wraps the operating system handle for standard error. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.console.openstandarderrorhandle?view=net-11.0 + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static SafeFileHandle OpenStandardErrorHandle() => StandardHandleHelper.GetStandardHandle(StandardHandleHelper.StdError); } diff --git a/src/Polyfill/ConvertPolyfill.cs b/src/Polyfill/ConvertPolyfill.cs index d05a819fd..093af7140 100644 --- a/src/Polyfill/ConvertPolyfill.cs +++ b/src/Polyfill/ConvertPolyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; +using System.Runtime.CompilerServices; static partial class Polyfill { @@ -15,6 +16,7 @@ static partial class Polyfill /// Parameters specify the subset as an offset in the input array and the number of elements in the array to convert. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.convert.tohexstring?view=net-11.0#system-convert-tohexstring(system-byte()-system-int32-system-int32) + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexString(byte[] inArray, int offset, int length) => ToHexString(inArray, offset, length, "X2"); #endif @@ -25,6 +27,7 @@ public static string ToHexString(byte[] inArray, int offset, int length) => /// Parameters specify the subset as an offset in the input array and the number of elements in the array to convert. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.convert.tohexstringlower?view=net-11.0#system-convert-tohexstringlower(system-byte()-system-int32-system-int32) + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexStringLower(byte[] inArray, int offset, int length) => ToHexString(inArray, offset, length, "x2"); @@ -32,6 +35,7 @@ public static string ToHexStringLower(byte[] inArray, int offset, int length) => /// Converts an array of 8-bit unsigned integers to its equivalent string representation that is encoded with lowercase hex characters. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.convert.tohexstringlower?view=net-11.0#system-convert-tohexstringlower(system-byte()) + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexStringLower(byte[] inArray) => Polyfill.ToHexStringLower(inArray, 0, inArray.Length); #endif @@ -40,6 +44,7 @@ public static string ToHexStringLower(byte[] inArray) => /// Converts an array of 8-bit unsigned integers to its equivalent string representation that is encoded with uppercase hex characters. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.convert.tohexstring?view=net-11.0#system-convert-tohexstring(system-byte()) + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexString(byte[] inArray) => Polyfill.ToHexString(inArray, 0, inArray.Length); @@ -79,6 +84,7 @@ static int GetHexValue(char hex) => /// Converts the span, which encodes binary data as hex characters, to an equivalent 8-bit unsigned integer array. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.convert.fromhexstring?view=net-11.0#system-convert-fromhexstring(system-readonlyspan((system-char))) + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static byte[] FromHexString(ReadOnlySpan chars) => Polyfill.FromHexString(chars.ToString()); @@ -86,6 +92,7 @@ public static byte[] FromHexString(ReadOnlySpan chars) => /// Converts a span of 8-bit unsigned integers to its equivalent string representation that is encoded with uppercase hex characters. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.convert.tohexstring?view=net-11.0#system-convert-tohexstring(system-readonlyspan((system-byte))) + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexString(ReadOnlySpan bytes) => Polyfill.ToHexString(bytes.ToArray()); #endif @@ -95,6 +102,7 @@ public static string ToHexString(ReadOnlySpan bytes) => /// Converts a span of 8-bit unsigned integers to its equivalent string representation that is encoded with lowercase hex characters. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.convert.tohexstringlower?view=net-11.0#system-convert-tohexstringlower(system-readonlyspan((system-byte))) + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexStringLower(ReadOnlySpan bytes) => Polyfill.ToHexStringLower(bytes.ToArray()); diff --git a/src/Polyfill/DateTimeOffsetPolyfill.cs b/src/Polyfill/DateTimeOffsetPolyfill.cs index f159c3291..df1a5de5e 100644 --- a/src/Polyfill/DateTimeOffsetPolyfill.cs +++ b/src/Polyfill/DateTimeOffsetPolyfill.cs @@ -6,6 +6,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; static partial class Polyfill { @@ -45,6 +46,7 @@ long TicksComponent() /// Tries to parse a string into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.datetimeoffset.tryparse?view=net-11.0#system-datetimeoffset-tryparse(system-string-system-iformatprovider-system-datetimeoffset@) + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out DateTimeOffset result) => DateTimeOffset.TryParse(s, provider, DateTimeStyles.None, out result); #endif @@ -56,6 +58,7 @@ public static bool TryParse(string? s, IFormatProvider? provider, out DateTimeOf /// Tries to parse a span of characters into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.datetimeoffset.tryparse?view=net-11.0#system-datetimeoffset-tryparse(system-readonlyspan((system-char))-system-iformatprovider-system-datetimeoffset@) + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out DateTimeOffset result) => DateTimeOffset.TryParse(s.ToString(), provider, DateTimeStyles.None, out result); #endif @@ -65,6 +68,7 @@ public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out /// Tries to parse a span of characters into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.datetimeoffset.tryparse?view=net-11.0#system-datetimeoffset-tryparse(system-readonlyspan((system-char))-system-datetimeoffset@) + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan input, out DateTimeOffset result) => DateTimeOffset.TryParse(input.ToString(), null, DateTimeStyles.None, out result); @@ -72,6 +76,7 @@ public static bool TryParse(ReadOnlySpan input, out DateTimeOffset result) /// Tries to parse a span of characters into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.datetimeoffset.tryparse?view=net-11.0#system-datetimeoffset-tryparse(system-readonlyspan((system-char))-system-iformatprovider-system-globalization-datetimestyles-system-datetimeoffset@) + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, DateTimeStyles styles, out DateTimeOffset result) => DateTimeOffset.TryParse(s.ToString(), provider, styles, out result); @@ -79,6 +84,7 @@ public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, Dat /// Tries to parse a span of characters into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.datetimeoffset.tryparseexact?view=net-11.0#system-datetimeoffset-tryparseexact(system-readonlyspan((system-char))-system-readonlyspan((system-char))-system-iformatprovider-system-globalization-datetimestyles-system-datetimeoffset@) + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParseExact(ReadOnlySpan input, string format, IFormatProvider? provider, DateTimeStyles styles, out DateTimeOffset result) => DateTimeOffset.TryParseExact(input.ToString(), format, provider, styles, out result); #endif @@ -88,6 +94,7 @@ public static bool TryParseExact(ReadOnlySpan input, string format, IForma /// Tries to parse a span of characters into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.datetimeoffset.tryparseexact?view=net-11.0#system-datetimeoffset-tryparseexact(system-readonlyspan((system-char))-system-readonlyspan((system-char))-system-iformatprovider-system-globalization-datetimestyles-system-datetimeoffset@) + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParseExact(ReadOnlySpan input, ReadOnlySpan format, IFormatProvider? provider, DateTimeStyles styles, out DateTimeOffset result) => DateTimeOffset.TryParseExact(input.ToString(), format.ToString(), provider, styles, out result); #endif diff --git a/src/Polyfill/DateTimePolyfill.cs b/src/Polyfill/DateTimePolyfill.cs index a413bccf6..852e78a4a 100644 --- a/src/Polyfill/DateTimePolyfill.cs +++ b/src/Polyfill/DateTimePolyfill.cs @@ -4,6 +4,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; static partial class Polyfill { @@ -41,6 +42,7 @@ long TicksComponent() /// Tries to parse a string into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.datetime.tryparse?view=net-11.0#system-datetime-tryparse(system-string-system-iformatprovider-system-datetime@) + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out DateTime result) => DateTime.TryParse(s, provider, DateTimeStyles.None, out result); #endif @@ -52,6 +54,7 @@ public static bool TryParse(string? s, IFormatProvider? provider, out DateTime r /// Tries to parse a span of characters into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.datetime.tryparse?view=net-11.0#system-datetime-tryparse(system-readonlyspan((system-char))-system-iformatprovider-system-datetime@) + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out DateTime result) => DateTime.TryParse(s.ToString(), provider, DateTimeStyles.None, out result); #endif @@ -61,6 +64,7 @@ public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out /// Tries to parse a span of characters into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.datetime.tryparse?view=net-11.0#system-datetime-tryparse(system-readonlyspan((system-char))-system-datetime@) + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out DateTime result) => DateTime.TryParse(s.ToString(), null, DateTimeStyles.None, out result); @@ -68,6 +72,7 @@ public static bool TryParse(ReadOnlySpan s, out DateTime result) => /// Tries to parse a span of characters into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.datetime.tryparse?view=net-11.0#system-datetime-tryparse(system-readonlyspan((system-char))-system-iformatprovider-system-globalization-datetimestyles-system-datetime@) + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, DateTimeStyles styles, out DateTime result) => DateTime.TryParse(s.ToString(), provider, styles, out result); @@ -75,6 +80,7 @@ public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, Dat /// Tries to parse a span of characters into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.datetime.tryparseexact?view=net-11.0#system-datetime-tryparseexact(system-readonlyspan((system-char))-system-readonlyspan((system-char))-system-iformatprovider-system-globalization-datetimestyles-system-datetime@) + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParseExact(ReadOnlySpan s, string format, IFormatProvider? provider, DateTimeStyles style, out DateTime result) => DateTime.TryParseExact(s.ToString(), format, provider, style, out result); #endif @@ -84,6 +90,7 @@ public static bool TryParseExact(ReadOnlySpan s, string format, IFormatPro /// Tries to parse a span of characters into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.datetime.tryparseexact?view=net-11.0#system-datetime-tryparseexact(system-readonlyspan((system-char))-system-readonlyspan((system-char))-system-iformatprovider-system-globalization-datetimestyles-system-datetime@) + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParseExact(ReadOnlySpan s, ReadOnlySpan format, IFormatProvider? provider, DateTimeStyles styles, out DateTime result) => DateTime.TryParseExact(s.ToString(), format.ToString(), provider, styles, out result); #endif diff --git a/src/Polyfill/DelegatePolyfill.cs b/src/Polyfill/DelegatePolyfill.cs index efdc07f9f..be369f206 100644 --- a/src/Polyfill/DelegatePolyfill.cs +++ b/src/Polyfill/DelegatePolyfill.cs @@ -4,6 +4,7 @@ namespace Polyfills; using System; using System.ComponentModel; +using System.Runtime.CompilerServices; static partial class Polyfill { @@ -49,6 +50,7 @@ public bool MoveNext() /// Gets an enumerator for the invocation targets of this delegate. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.delegate.enumerateinvocationlist?view=net-11.0 + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static InvocationListEnumerator EnumerateInvocationList(TDelegate? target) where TDelegate : Delegate => new(target); diff --git a/src/Polyfill/FilePolyfill.cs b/src/Polyfill/FilePolyfill.cs index 1a4f479a0..3499afb24 100644 --- a/src/Polyfill/FilePolyfill.cs +++ b/src/Polyfill/FilePolyfill.cs @@ -65,6 +65,7 @@ public static Task AppendAllTextAsync(string path, ReadOnlyMemory contents /// Appends the specified string to the file, creating the file if it does not already exist. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.io.file.appendalltext?view=net-11.0#system-io-file-appendalltext(system-string-system-readonlyspan((system-char))) + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void AppendAllText(string path, ReadOnlySpan contents) => File.AppendAllText(path, contents.ToString()); @@ -72,6 +73,7 @@ public static void AppendAllText(string path, ReadOnlySpan contents) => /// Appends the specified string to the file, creating the file if it does not already exist. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.io.file.appendalltext?view=net-11.0#system-io-file-appendalltext(system-string-system-readonlyspan((system-char))-system-text-encoding) + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void AppendAllText(string path, ReadOnlySpan contents, Encoding encoding) => File.AppendAllText(path, contents.ToString(), encoding); @@ -101,6 +103,7 @@ public static async Task WriteAllBytesAsync(string path, ReadOnlyMemory by /// If the target file already exists, it is truncated and overwritten. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.io.file.writealltext?view=net-11.0#system-io-file-writealltext(system-string-system-readonlyspan((system-char))) + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void WriteAllText(string path, ReadOnlySpan contents) => File.WriteAllText(path, contents.ToString()); @@ -109,6 +112,7 @@ public static void WriteAllText(string path, ReadOnlySpan contents) => /// If the target file already exists, it is truncated and overwritten. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.io.file.writealltext?view=net-11.0#system-io-file-writealltext(system-string-system-readonlyspan((system-char))-system-text-encoding) + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void WriteAllText(string path, ReadOnlySpan contents, Encoding encoding) => File.WriteAllText(path, contents.ToString(), encoding); diff --git a/src/Polyfill/GuidPolyfill.cs b/src/Polyfill/GuidPolyfill.cs index c4e8f23ea..fe3f17c52 100644 --- a/src/Polyfill/GuidPolyfill.cs +++ b/src/Polyfill/GuidPolyfill.cs @@ -7,6 +7,7 @@ namespace Polyfills; using System.Text; using System; using System.Security.Cryptography; +using System.Runtime.CompilerServices; static partial class Polyfill { @@ -18,6 +19,7 @@ static partial class Polyfill /// Tries to parse a string into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.guid.tryparse?view=net-11.0#system-guid-tryparse(system-string-system-iformatprovider-system-guid@) + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out Guid result) => Guid.TryParse(s, out result); @@ -27,6 +29,7 @@ public static bool TryParse(string? s, IFormatProvider? provider, out Guid resul /// Creates a new according to RFC 9562, following the Version 7 format. //Link: https://learn.microsoft.com/en-us/dotnet/api/system.guid.createversion7?view=net-11.0#system-guid-createversion7 + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Guid CreateVersion7() => CreateVersion7(DateTimeOffset.UtcNow); /// Creates a new according to RFC 9562, following the Version 7 format. @@ -87,6 +90,7 @@ public static Guid CreateVersion7(DateTimeOffset timestamp) /// Converts span of characters representing the GUID to the equivalent Guid structure, provided that the string is in the specified format. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.guid.tryparseexact?view=net-11.0#system-guid-tryparseexact(system-readonlyspan((system-char))-system-readonlyspan((system-char))-system-guid@) + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParseExact(ReadOnlySpan input, ReadOnlySpan format, out Guid result) => Guid.TryParseExact(input.ToString(), format.ToString(), out result); @@ -98,6 +102,7 @@ public static bool TryParseExact(ReadOnlySpan input, ReadOnlySpan fo /// Tries to parse a span of UTF-8 characters into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.guid.tryparse?view=net-11.0#system-guid-tryparse(system-readonlyspan((system-char))-system-iformatprovider-system-guid@) + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out Guid result) => Guid.TryParse(s.ToString(), out result); @@ -109,6 +114,7 @@ public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out /// Tries to parse a span of UTF-8 characters into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.guid.tryparse?view=net-11.0#system-guid-tryparse(system-readonlyspan((system-char))-system-guid@) + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan input, out Guid result) => Guid.TryParse(input.ToString(), out result); @@ -119,6 +125,7 @@ public static bool TryParse(ReadOnlySpan input, out Guid result) => /// Tries to parse a span of UTF-8 bytes into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.guid.tryparse?view=net-11.0#system-guid-tryparse(system-readonlyspan((system-byte))-system-guid@) + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out Guid result) => Guid.TryParse(Encoding.UTF8.GetString(utf8Text), out result); @@ -126,6 +133,7 @@ public static bool TryParse(ReadOnlySpan utf8Text, out Guid result) => /// Parse a span of UTF-8 bytes into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.guid.parse?view=net-11.0#system-guid-parse(system-readonlyspan((system-byte))) + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Guid Parse(ReadOnlySpan utf8Text) => Guid.Parse(Encoding.UTF8.GetString(utf8Text)); diff --git a/src/Polyfill/KeyValuePair.cs b/src/Polyfill/KeyValuePair.cs index 8eb6e53fa..8440024a1 100644 --- a/src/Polyfill/KeyValuePair.cs +++ b/src/Polyfill/KeyValuePair.cs @@ -6,6 +6,7 @@ namespace System.Collections.Generic; // ReSharper disable RedundantNameQualifier using System.Diagnostics; using System.Diagnostics.CodeAnalysis; +using System.Runtime.CompilerServices; // ReSharper restore RedundantNameQualifier [ExcludeFromCodeCoverage] @@ -24,6 +25,7 @@ static class KeyValuePair /// Creates a new key/value pair instance using provided values. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.keyvaluepair.create?view=net-11.0 + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static KeyValuePair Create(TKey key, TValue value) => new(key, value); } diff --git a/src/Polyfill/Lock.cs b/src/Polyfill/Lock.cs index c93a914f7..cf928f5c9 100644 --- a/src/Polyfill/Lock.cs +++ b/src/Polyfill/Lock.cs @@ -8,6 +8,7 @@ namespace System.Threading; using Diagnostics; using Diagnostics.CodeAnalysis; +using Runtime.CompilerServices; /// /// Provides a way to get mutual exclusion in regions of code between different threads. A lock may be held by one thread at @@ -29,30 +30,35 @@ class Lock /// /// Enters the lock. Once the method returns, the calling thread would be the only thread that holds the lock. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Enter() => Monitor.Enter(this); /// /// Tries to enter the lock without waiting. If the lock is entered, the calling thread would be the only thread that /// holds the lock. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool TryEnter() => Monitor.TryEnter(this); /// /// Tries to enter the lock, waiting for roughly the specified duration. If the lock is entered, the calling thread /// would be the only thread that holds the lock. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool TryEnter(TimeSpan timeout) => Monitor.TryEnter(this, timeout); /// /// Tries to enter the lock, waiting for roughly the specified duration. If the lock is entered, the calling thread /// would be the only thread that holds the lock. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool TryEnter(int millisecondsTimeout) => TryEnter(TimeSpan.FromMilliseconds(millisecondsTimeout)); /// /// Exits the lock. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Exit() => Monitor.Exit(this); /// diff --git a/src/Polyfill/Numbers/BytePolyfill.cs b/src/Polyfill/Numbers/BytePolyfill.cs index 38418da21..4e5f4cb85 100644 --- a/src/Polyfill/Numbers/BytePolyfill.cs +++ b/src/Polyfill/Numbers/BytePolyfill.cs @@ -6,6 +6,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; // ReSharper disable once RedundantUsingDirective using System.Text; @@ -19,6 +20,7 @@ static partial class Polyfill /// Tries to parse a string into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.byte.tryparse?view=net-11.0#system-byte-tryparse(system-string-system-iformatprovider-system-byte@) + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out byte result) => byte.TryParse(s, NumberStyles.Integer, provider, out result); @@ -32,6 +34,7 @@ public static bool TryParse(string? s, IFormatProvider? provider, out byte resul /// Tries to parse a span of characters into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.byte.tryparse?view=net-11.0#system-byte-tryparse(system-readonlyspan((system-char))-system-iformatprovider-system-byte@) + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out byte result) => byte.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); @@ -43,6 +46,7 @@ public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out /// Tries to parse a span of UTF-8 characters into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.byte.tryparse?view=net-11.0#system-byte-tryparse(system-readonlyspan((system-byte))-system-iformatprovider-system-byte@) + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out byte result) => byte.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); @@ -50,6 +54,7 @@ public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provid /// Tries to parse a span of UTF-8 characters into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.byte.tryparse?view=net-11.0#system-byte-tryparse(system-readonlyspan((system-byte))-system-globalization-numberstyles-system-iformatprovider-system-byte@) + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out byte result) => byte.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); @@ -57,6 +62,7 @@ public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFo /// Tries to convert a UTF-8 character span containing the string representation of a number to its byte equivalent. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.byte.tryparse?view=net-11.0#system-byte-tryparse(system-readonlyspan((system-char))-system-globalization-numberstyles-system-iformatprovider-system-byte@) + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out byte result) => byte.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); @@ -68,6 +74,7 @@ public static bool TryParse(ReadOnlySpan utf8Text, out byte result) => /// Converts the span representation of a number in a specified style and culture-specific format to its byte equivalent. A return value indicates whether the conversion succeeded. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.byte.tryparse?view=net-11.0#system-byte-tryparse(system-readonlyspan((system-char))-system-byte@) + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out byte result) => byte.TryParse(s.ToString(), out result); @@ -75,6 +82,7 @@ public static bool TryParse(ReadOnlySpan s, out byte result) => /// Converts the span representation of a number in a specified style and culture-specific format to its byte equivalent. A return value indicates whether the conversion succeeded. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.byte.tryparse?view=net-11.0#system-byte-tryparse(system-readonlyspan((system-char))-system-globalization-numberstyles-system-iformatprovider-system-byte@) + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out byte result) => byte.TryParse(s.ToString(), style, provider, out result); diff --git a/src/Polyfill/Numbers/DoublePolyfill.cs b/src/Polyfill/Numbers/DoublePolyfill.cs index 592d359c4..c3fe1340d 100644 --- a/src/Polyfill/Numbers/DoublePolyfill.cs +++ b/src/Polyfill/Numbers/DoublePolyfill.cs @@ -4,6 +4,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; // ReSharper disable once RedundantUsingDirective using System.Text; @@ -17,6 +18,7 @@ static partial class Polyfill /// Tries to parse a string into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.double.tryparse?view=net-11.0#system-double-tryparse(system-string-system-iformatprovider-system-double@) + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out double result) => double.TryParse(s, NumberStyles.Float, provider, out result); @@ -29,6 +31,7 @@ public static bool TryParse(string? s, IFormatProvider? provider, out double res /// Tries to parse a span of UTF-8 characters into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.double.tryparse?view=net-11.0#system-double-tryparse(system-readonlyspan((system-byte))-system-iformatprovider-system-double@) + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out double result) => double.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Float, provider, out result); @@ -36,6 +39,7 @@ public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provid /// Tries to parse a span of UTF-8 characters into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.double.tryparse?view=net-11.0#system-double-tryparse(system-readonlyspan((system-byte))-system-globalization-numberstyles-system-iformatprovider-system-double@) + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out double result) => double.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); @@ -43,6 +47,7 @@ public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFo /// Tries to convert a UTF-8 character span containing the string representation of a number to its double-precision floating-point number equivalent.. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.double.tryparse?view=net-11.0#system-double-tryparse(system-readonlyspan((system-byte))-system-double@) + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out double result) => double.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Float, null, out result); @@ -54,6 +59,7 @@ public static bool TryParse(ReadOnlySpan utf8Text, out double result) => /// Converts the span representation of a number in a specified style and culture-specific format to its double-precision floating-point number equivalent. A return value indicates whether the conversion succeeded or failed. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.double.tryparse?view=net-11.0#system-double-tryparse(system-readonlyspan((system-char))-system-double@) + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out double result) => double.TryParse(s.ToString(), out result); @@ -61,6 +67,7 @@ public static bool TryParse(ReadOnlySpan s, out double result) => /// Converts the string representation of a number in a specified style and culture-specific format to its double-precision floating-point number equivalent. A return value indicates whether the conversion succeeded or failed. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.double.tryparse?view=net-11.0#system-double-tryparse(system-readonlyspan((system-char))-system-globalization-numberstyles-system-iformatprovider-system-double@) + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out double result) => double.TryParse(s.ToString(), style, provider, out result); @@ -72,6 +79,7 @@ public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatPro /// Tries to parse a span of characters into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.double.tryparse?view=net-11.0#system-double-tryparse(system-readonlyspan((system-char))-system-iformatprovider-system-double@) + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out double result) => double.TryParse(s.ToString(), NumberStyles.Float, provider, out result); diff --git a/src/Polyfill/Numbers/Int16Polyfill.cs b/src/Polyfill/Numbers/Int16Polyfill.cs index d8b641c7a..4e62137bf 100644 --- a/src/Polyfill/Numbers/Int16Polyfill.cs +++ b/src/Polyfill/Numbers/Int16Polyfill.cs @@ -4,6 +4,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; // ReSharper disable once RedundantUsingDirective using System.Text; @@ -17,6 +18,7 @@ static partial class Polyfill /// Tries to parse a string into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.int16.tryparse?view=net-11.0#system-int16-tryparse(system-string-system-iformatprovider-system-int16@) + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out short result) => short.TryParse(s, NumberStyles.Integer, provider, out result); @@ -29,6 +31,7 @@ public static bool TryParse(string? s, IFormatProvider? provider, out short resu /// Tries to parse a span of UTF-8 characters into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.int16.tryparse?view=net-11.0#system-int16-tryparse(system-readonlyspan((system-byte))-system-iformatprovider-system-int16@) + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out short result) => short.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); @@ -36,6 +39,7 @@ public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provid /// Tries to parse a span of UTF-8 characters into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.int16.tryparse?view=net-11.0#system-int16-tryparse(system-readonlyspan((system-byte))-system-globalization-numberstyles-system-iformatprovider-system-int16@) + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out short result) => short.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); @@ -43,6 +47,7 @@ public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFo /// Tries to convert a UTF-8 character span containing the string representation of a number to its short equivalent. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.int16.tryparse?view=net-11.0#system-int16-tryparse(system-readonlyspan((system-char))-system-globalization-numberstyles-system-iformatprovider-system-int16@) + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out short result) => short.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); @@ -54,6 +59,7 @@ public static bool TryParse(ReadOnlySpan utf8Text, out short result) => /// Converts the span representation of a number in a specified style and culture-specific format to its short equivalent. A return value indicates whether the conversion succeeded. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.int16.tryparse?view=net-11.0#system-int16-tryparse(system-readonlyspan((system-char))-system-int16@) + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out short result) => short.TryParse(s.ToString(), out result); @@ -61,6 +67,7 @@ public static bool TryParse(ReadOnlySpan s, out short result) => /// Converts the span representation of a number in a specified style and culture-specific format to its short equivalent. A return value indicates whether the conversion succeeded. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.int16.tryparse?view=net-11.0#system-int16-tryparse(system-readonlyspan((system-char))-system-globalization-numberstyles-system-iformatprovider-system-int16@) + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out short result) => short.TryParse(s.ToString(), style, provider, out result); @@ -72,6 +79,7 @@ public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatPro /// Tries to parse a span of characters into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.int16.tryparse?view=net-11.0#system-int16-tryparse(system-readonlyspan((system-char))-system-iformatprovider-system-int16@) + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out short result) => short.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); diff --git a/src/Polyfill/Numbers/Int32Polyfill.cs b/src/Polyfill/Numbers/Int32Polyfill.cs index b35e2c548..6f363aaf9 100644 --- a/src/Polyfill/Numbers/Int32Polyfill.cs +++ b/src/Polyfill/Numbers/Int32Polyfill.cs @@ -4,6 +4,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; // ReSharper disable once RedundantUsingDirective using System.Text; @@ -17,6 +18,7 @@ static partial class Polyfill /// Tries to parse a string into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.int32.tryparse?view=net-11.0#system-int32-tryparse(system-string-system-iformatprovider-system-int32@) + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out int result) => int.TryParse(s, NumberStyles.Integer, provider, out result); @@ -30,6 +32,7 @@ public static bool TryParse(string? s, IFormatProvider? provider, out int result /// Tries to parse a span of UTF-8 characters into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.int32.tryparse?view=net-11.0#system-int32-tryparse(system-readonlyspan((system-byte))-system-iformatprovider-system-int32@) + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out int result) => int.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); @@ -37,6 +40,7 @@ public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provid /// Tries to parse a span of UTF-8 characters into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.int32.tryparse?view=net-11.0#system-int32-tryparse(system-readonlyspan((system-byte))-system-globalization-numberstyles-system-iformatprovider-system-int32@) + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out int result) => int.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); @@ -44,6 +48,7 @@ public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFo /// Tries to convert a UTF-8 character span containing the string representation of a number to its 32-bit signed integer equivalent. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.int32.tryparse?view=net-11.0#system-int32-tryparse(system-readonlyspan((system-char))-system-globalization-numberstyles-system-iformatprovider-system-int32@) + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out int result) => int.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); @@ -55,6 +60,7 @@ public static bool TryParse(ReadOnlySpan utf8Text, out int result) => /// Converts the span representation of a number in a specified style and culture-specific format to its 32-bit signed integer equivalent. A return value indicates whether the conversion succeeded. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.int32.tryparse?view=net-11.0#system-int32-tryparse(system-readonlyspan((system-char))-system-int32@) + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out int result) => int.TryParse(s.ToString(), out result); @@ -62,6 +68,7 @@ public static bool TryParse(ReadOnlySpan s, out int result) => /// Converts the span representation of a number in a specified style and culture-specific format to its 32-bit signed integer equivalent. A return value indicates whether the conversion succeeded. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.int32.tryparse?view=net-11.0#system-int32-tryparse(system-readonlyspan((system-char))-system-globalization-numberstyles-system-iformatprovider-system-int32@) + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out int result) => int.TryParse(s.ToString(), style, provider, out result); @@ -73,6 +80,7 @@ public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatPro /// Tries to parse a span of characters into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.int32.tryparse?view=net-11.0#system-int32-tryparse(system-readonlyspan((system-char))-system-iformatprovider-system-int32@) + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out int result) => int.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); diff --git a/src/Polyfill/Numbers/Int64Polyfill.cs b/src/Polyfill/Numbers/Int64Polyfill.cs index 2402d0e23..07507e1a4 100644 --- a/src/Polyfill/Numbers/Int64Polyfill.cs +++ b/src/Polyfill/Numbers/Int64Polyfill.cs @@ -4,6 +4,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; // ReSharper disable once RedundantUsingDirective using System.Text; @@ -17,6 +18,7 @@ static partial class Polyfill /// Tries to parse a string into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.int64.tryparse?view=net-11.0#system-int64-tryparse(system-string-system-iformatprovider-system-int64@) + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out long result) => long.TryParse(s, NumberStyles.Integer, provider, out result); @@ -30,6 +32,7 @@ public static bool TryParse(string? s, IFormatProvider? provider, out long resul /// Tries to parse a span of UTF-8 characters into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.int64.tryparse?view=net-11.0#system-int64-tryparse(system-readonlyspan((system-byte))-system-iformatprovider-system-int64@) + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out long result) => long.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); @@ -37,6 +40,7 @@ public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provid /// Tries to parse a span of UTF-8 characters into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.int64.tryparse?view=net-11.0#system-int64-tryparse(system-readonlyspan((system-byte))-system-globalization-numberstyles-system-iformatprovider-system-int64@) + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out long result) => long.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); @@ -44,6 +48,7 @@ public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFo /// Tries to convert a UTF-8 character span containing the string representation of a number to its 64-bit signed integer equivalent. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.int64.tryparse?view=net-11.0#system-int64-tryparse(system-readonlyspan((system-char))-system-globalization-numberstyles-system-iformatprovider-system-int64@) + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out long result) => long.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); @@ -55,6 +60,7 @@ public static bool TryParse(ReadOnlySpan utf8Text, out long result) => /// Converts the span representation of a number in a specified style and culture-specific format to its 32-bit signed integer equivalent. A return value indicates whether the conversion succeeded. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.int64.tryparse?view=net-11.0#system-int64-tryparse(system-readonlyspan((system-char))-system-int64@) + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out long result) => long.TryParse(s.ToString(), out result); @@ -62,6 +68,7 @@ public static bool TryParse(ReadOnlySpan s, out long result) => /// Converts the span representation of a number in a specified style and culture-specific format to its 64-bit signed integer equivalent. A return value indicates whether the conversion succeeded. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.int64.tryparse?view=net-11.0#system-int64-tryparse(system-readonlyspan((system-char))-system-globalization-numberstyles-system-iformatprovider-system-int64@) + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out long result) => long.TryParse(s.ToString(), style, provider, out result); @@ -73,6 +80,7 @@ public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatPro /// Tries to parse a span of characters into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.int64.tryparse?view=net-11.0#system-int64-tryparse(system-readonlyspan((system-char))-system-iformatprovider-system-int64@) + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out long result) => long.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); diff --git a/src/Polyfill/Numbers/SBytePolyfill.cs b/src/Polyfill/Numbers/SBytePolyfill.cs index 9ba772561..8f91b75e2 100644 --- a/src/Polyfill/Numbers/SBytePolyfill.cs +++ b/src/Polyfill/Numbers/SBytePolyfill.cs @@ -4,6 +4,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; // ReSharper disable once RedundantUsingDirective using System.Text; @@ -17,6 +18,7 @@ static partial class Polyfill /// Tries to parse a string into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.sbyte.tryparse?view=net-11.0#system-sbyte-tryparse(system-string-system-iformatprovider-system-sbyte@) + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out sbyte result) => sbyte.TryParse(s, NumberStyles.Integer, provider, out result); @@ -30,6 +32,7 @@ public static bool TryParse(string? s, IFormatProvider? provider, out sbyte resu /// Tries to parse a span of UTF-8 characters into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.sbyte.tryparse?view=net-11.0#system-sbyte-tryparse(system-readonlyspan((system-byte))-system-iformatprovider-system-sbyte@) + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out sbyte result) => sbyte.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); @@ -37,6 +40,7 @@ public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provid /// Tries to parse a span of UTF-8 characters into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.sbyte.tryparse?view=net-11.0#system-sbyte-tryparse(system-readonlyspan((system-byte))-system-globalization-numberstyles-system-iformatprovider-system-sbyte@) + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out sbyte result) => sbyte.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); @@ -44,6 +48,7 @@ public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFo /// Tries to convert a UTF-8 character span containing the string representation of a number to its sbyte equivalent. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.sbyte.tryparse?view=net-11.0#system-sbyte-tryparse(system-readonlyspan((system-char))-system-globalization-numberstyles-system-iformatprovider-system-sbyte@) + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out sbyte result) => sbyte.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); @@ -55,6 +60,7 @@ public static bool TryParse(ReadOnlySpan utf8Text, out sbyte result) => /// Converts the span representation of a number in a specified style and culture-specific format to its sbyte equivalent. A return value indicates whether the conversion succeeded. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.sbyte.tryparse?view=net-11.0#system-sbyte-tryparse(system-readonlyspan((system-char))-system-sbyte@) + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out sbyte result) => sbyte.TryParse(s.ToString(), out result); @@ -62,6 +68,7 @@ public static bool TryParse(ReadOnlySpan s, out sbyte result) => /// Converts the span representation of a number in a specified style and culture-specific format to its sbyte equivalent. A return value indicates whether the conversion succeeded. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.sbyte.tryparse?view=net-11.0#system-sbyte-tryparse(system-readonlyspan((system-char))-system-globalization-numberstyles-system-iformatprovider-system-sbyte@) + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out sbyte result) => sbyte.TryParse(s.ToString(), style, provider, out result); @@ -73,6 +80,7 @@ public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatPro /// Tries to parse a span of characters into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.sbyte.tryparse?view=net-11.0#system-sbyte-tryparse(system-readonlyspan((system-char))-system-iformatprovider-system-sbyte@) + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out sbyte result) => sbyte.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); diff --git a/src/Polyfill/Numbers/UInt16Polyfill.cs b/src/Polyfill/Numbers/UInt16Polyfill.cs index e792053bf..c3f661c5a 100644 --- a/src/Polyfill/Numbers/UInt16Polyfill.cs +++ b/src/Polyfill/Numbers/UInt16Polyfill.cs @@ -4,6 +4,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; // ReSharper disable once RedundantUsingDirective using System.Text; @@ -17,6 +18,7 @@ static partial class Polyfill /// Tries to parse a string into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.uint16.tryparse?view=net-11.0#system-uint16-tryparse(system-string-system-iformatprovider-system-uint16@) + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out ushort result) => ushort.TryParse(s, NumberStyles.Integer, provider, out result); @@ -30,6 +32,7 @@ public static bool TryParse(string? s, IFormatProvider? provider, out ushort res /// Tries to parse a span of UTF-8 characters into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.uint16.tryparse?view=net-11.0#system-uint16-tryparse(system-readonlyspan((system-byte))-system-iformatprovider-system-uint16@) + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out ushort result) => ushort.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); @@ -37,6 +40,7 @@ public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provid /// Tries to parse a span of UTF-8 characters into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.uint16.tryparse?view=net-11.0#system-uint16-tryparse(system-readonlyspan((system-byte))-system-globalization-numberstyles-system-iformatprovider-system-uint16@) + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out ushort result) => ushort.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); @@ -44,6 +48,7 @@ public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFo /// Tries to convert a UTF-8 character span containing the string representation of a number to its ushort equivalent. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.uint16.tryparse?view=net-11.0#system-uint16-tryparse(system-readonlyspan((system-char))-system-globalization-numberstyles-system-iformatprovider-system-uint16@) + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out ushort result) => ushort.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); #endif @@ -54,6 +59,7 @@ public static bool TryParse(ReadOnlySpan utf8Text, out ushort result) => /// Converts the span representation of a number in a specified style and culture-specific format to its ushort equivalent. A return value indicates whether the conversion succeeded. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.uint16.tryparse?view=net-11.0#system-uint16-tryparse(system-readonlyspan((system-char))-system-uint16@) + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out ushort result) => ushort.TryParse(s.ToString(), out result); @@ -61,6 +67,7 @@ public static bool TryParse(ReadOnlySpan s, out ushort result) => /// Converts the span representation of a number in a specified style and culture-specific format to its ushort equivalent. A return value indicates whether the conversion succeeded. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.uint16.tryparse?view=net-11.0#system-uint16-tryparse(system-readonlyspan((system-char))-system-globalization-numberstyles-system-iformatprovider-system-uint16@) + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out ushort result) => ushort.TryParse(s.ToString(), style, provider, out result); @@ -72,6 +79,7 @@ public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatPro /// Tries to parse a span of characters into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.uint16.tryparse?view=net-11.0#system-uint16-tryparse(system-readonlyspan((system-char))-system-iformatprovider-system-uint16@) + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out ushort result) => ushort.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); diff --git a/src/Polyfill/Numbers/UInt32Polyfill.cs b/src/Polyfill/Numbers/UInt32Polyfill.cs index 4fcc745cd..3dcfbe833 100644 --- a/src/Polyfill/Numbers/UInt32Polyfill.cs +++ b/src/Polyfill/Numbers/UInt32Polyfill.cs @@ -4,6 +4,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; // ReSharper disable once RedundantUsingDirective using System.Text; @@ -17,6 +18,7 @@ static partial class Polyfill /// Tries to parse a string into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.uint32.tryparse?view=net-11.0#system-uint32-tryparse(system-string-system-iformatprovider-system-uint32@) + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out uint result) => uint.TryParse(s, NumberStyles.Integer, provider, out result); @@ -30,6 +32,7 @@ public static bool TryParse(string? s, IFormatProvider? provider, out uint resul /// Tries to parse a span of UTF-8 characters into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.uint32.tryparse?view=net-11.0#system-uint32-tryparse(system-readonlyspan((system-byte))-system-iformatprovider-system-uint32@) + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out uint result) => uint.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); @@ -37,6 +40,7 @@ public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provid /// Tries to parse a span of UTF-8 characters into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.uint32.tryparse?view=net-11.0#system-uint32-tryparse(system-readonlyspan((system-byte))-system-globalization-numberstyles-system-iformatprovider-system-uint32@) + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out uint result) => uint.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); @@ -44,6 +48,7 @@ public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFo /// Tries to convert a UTF-8 character span containing the string representation of a number to its uint equivalent. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.uint32.tryparse?view=net-11.0#system-uint32-tryparse(system-readonlyspan((system-char))-system-globalization-numberstyles-system-iformatprovider-system-uint32@) + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out uint result) => uint.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); @@ -55,6 +60,7 @@ public static bool TryParse(ReadOnlySpan utf8Text, out uint result) => /// Converts the span representation of a number in a specified style and culture-specific format to its uint equivalent. A return value indicates whether the conversion succeeded. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.uint32.tryparse?view=net-11.0#system-uint32-tryparse(system-readonlyspan((system-char))-system-uint32@) + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out uint result) => uint.TryParse(s.ToString(), out result); @@ -62,6 +68,7 @@ public static bool TryParse(ReadOnlySpan s, out uint result) => /// Converts the span representation of a number in a specified style and culture-specific format to its uint equivalent. A return value indicates whether the conversion succeeded. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.uint32.tryparse?view=net-11.0#system-uint32-tryparse(system-readonlyspan((system-char))-system-globalization-numberstyles-system-iformatprovider-system-uint32@) + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out uint result) => uint.TryParse(s.ToString(), style, provider, out result); @@ -73,6 +80,7 @@ public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatPro /// Tries to parse a span of characters into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.uint32.tryparse?view=net-11.0#system-uint32-tryparse(system-readonlyspan((system-char))-system-iformatprovider-system-uint32@) + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out uint result) => uint.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); diff --git a/src/Polyfill/Numbers/UInt64Polyfill.cs b/src/Polyfill/Numbers/UInt64Polyfill.cs index ced8b84f3..b6006cc72 100644 --- a/src/Polyfill/Numbers/UInt64Polyfill.cs +++ b/src/Polyfill/Numbers/UInt64Polyfill.cs @@ -4,6 +4,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; // ReSharper disable once RedundantUsingDirective using System.Text; @@ -17,6 +18,7 @@ static partial class Polyfill /// Tries to parse a string into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.uint64.tryparse?view=net-11.0#system-uint64-tryparse(system-string-system-iformatprovider-system-uint64@) + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out ulong result) => ulong.TryParse(s, NumberStyles.Integer, provider, out result); @@ -30,6 +32,7 @@ public static bool TryParse(string? s, IFormatProvider? provider, out ulong resu /// Tries to parse a span of UTF-8 characters into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.uint64.tryparse?view=net-11.0#system-uint64-tryparse(system-readonlyspan((system-byte))-system-iformatprovider-system-uint64@) + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out ulong result) => ulong.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); @@ -37,6 +40,7 @@ public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provid /// Tries to parse a span of UTF-8 characters into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.uint64.tryparse?view=net-11.0#system-uint64-tryparse(system-readonlyspan((system-byte))-system-globalization-numberstyles-system-iformatprovider-system-uint64@) + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpanutf8Text, NumberStyles style, IFormatProvider? provider, out ulong result) => ulong.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); @@ -44,6 +48,7 @@ public static bool TryParse(ReadOnlySpanutf8Text, NumberStyles style, IFor /// Tries to convert a UTF-8 character span containing the string representation of a number to its ulong equivalent. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.uint64.tryparse?view=net-11.0#system-uint64-tryparse(system-readonlyspan((system-char))-system-globalization-numberstyles-system-iformatprovider-system-uint64@) + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out ulong result) => ulong.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); @@ -55,6 +60,7 @@ public static bool TryParse(ReadOnlySpan utf8Text, out ulong result) => /// Converts the span representation of a number in a specified style and culture-specific format to its ulong equivalent. A return value indicates whether the conversion succeeded. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.uint64.tryparse?view=net-11.0#system-uint64-tryparse(system-readonlyspan((system-char))-system-uint64@) + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out ulong result) => ulong.TryParse(s.ToString(), out result); @@ -62,6 +68,7 @@ public static bool TryParse(ReadOnlySpan s, out ulong result) => /// Converts the span representation of a number in a specified style and culture-specific format to its ulong equivalent. A return value indicates whether the conversion succeeded. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.uint64.tryparse?view=net-11.0#system-uint64-tryparse(system-readonlyspan((system-char))-system-globalization-numberstyles-system-iformatprovider-system-uint64@) + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out ulong result) => ulong.TryParse(s.ToString(), style, provider, out result); @@ -73,6 +80,7 @@ public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatPro /// Tries to parse a span of characters into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.uint64.tryparse?view=net-11.0#system-uint64-tryparse(system-readonlyspan((system-char))-system-iformatprovider-system-uint64@) + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out ulong result) => ulong.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); diff --git a/src/Polyfill/OperatingSystemPolyfill.cs b/src/Polyfill/OperatingSystemPolyfill.cs index f02477d3b..b0f949067 100644 --- a/src/Polyfill/OperatingSystemPolyfill.cs +++ b/src/Polyfill/OperatingSystemPolyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; +using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; @@ -19,6 +20,7 @@ static bool IsOsVersionAtLeast(int major, int minor = 0, int build = 0, int revi /// Indicates whether the current application is running as WASI. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.operatingsystem.iswasi?view=net-11.0 + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsWasi() => RuntimeInformation.IsOSPlatform(OSPlatform.Create("WASI")); @@ -30,6 +32,7 @@ public static bool IsWasi() => /// Indicates whether the current application is running on Mac Catalyst. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.operatingsystem.ismaccatalyst?view=net-11.0 + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsMacCatalyst() => OperatingSystem.IsMacOS() || OperatingSystem.IsIOS(); @@ -38,6 +41,7 @@ public static bool IsMacCatalyst() => /// Check for the Mac Catalyst version (iOS version as presented in Apple documentation) with a ≤ version comparison. Used to guard APIs that were added in the given Mac Catalyst release. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.operatingsystem.ismaccatalystversionatleast?view=net-11.0 + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsMacCatalystVersionAtLeast(int major, int minor = 0, int build = 0) => IsMacCatalyst() && IsOsVersionAtLeast(major, minor, build); @@ -50,6 +54,7 @@ public static bool IsMacCatalystVersionAtLeast(int major, int minor = 0, int bui /// Checks if the macOS version (returned by libobjc.get_operatingSystemVersion) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified macOS version. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.operatingsystem.ismacosversionatleast?view=net-11.0 + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsMacOSVersionAtLeast(int major, int minor = 0, int build = 0) => OperatingSystemCache.IsMacOSVersionAtLeast(major, minor, build); @@ -58,6 +63,7 @@ public static bool IsMacOSVersionAtLeast(int major, int minor = 0, int build = 0 /// This method can be used to guard APIs that were added in the specified version. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.operatingsystem.isfreebsdversionatleast?view=net-11.0 + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsFreeBSDVersionAtLeast(int major, int minor, int build = 0, int revision = 0) => OperatingSystemCache.IsFreeBSDVersionAtLeast(major, minor, build, revision); @@ -65,6 +71,7 @@ public static bool IsFreeBSDVersionAtLeast(int major, int minor, int build = 0, /// Indicates whether the current application is running on Android. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.operatingsystem.isandroid?view=net-11.0 + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsAndroid() => OperatingSystemCache.IsAndroid(); @@ -72,6 +79,7 @@ public static bool IsAndroid() => /// Checks if the Android version (returned by the Linux command uname) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified version. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.operatingsystem.isandroidversionatleast?view=net-11.0 + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsAndroidVersionAtLeast(int major, int minor = 0, int build = 0, int revision = 0) => OperatingSystemCache.IsAndroidVersionAtLeast(major, minor, build, revision); @@ -79,6 +87,7 @@ public static bool IsAndroidVersionAtLeast(int major, int minor = 0, int build = /// Checks if the Windows version (returned by RtlGetVersion) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified Windows version. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.operatingsystem.iswindowsversionatleast?view=net-11.0 + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsWindowsVersionAtLeast(int major, int minor = 0, int build = 0, int revision = 0) => OperatingSystemCache.IsWindowsVersionAtLeast(major, minor, build, revision); @@ -86,6 +95,7 @@ public static bool IsWindowsVersionAtLeast(int major, int minor = 0, int build = /// Indicates whether the current application is running on the specified platform. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.operatingsystem.isosplatform?view=net-11.0 + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsOSPlatform(string platform) => RuntimeInformation.IsOSPlatform(OSPlatform.Create(platform)); @@ -93,6 +103,7 @@ public static bool IsOSPlatform(string platform) => /// Checks if the operating system version is greater than or equal to the specified platform version. This method can be used to guard APIs that were added in the specified OS version. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.operatingsystem.isosplatformversionatleast?view=net-11.0 + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsOSPlatformVersionAtLeast(string platform, int major, int minor = 0, int build = 0, int revision = 0) => IsOSPlatform(platform) && IsOsVersionAtLeast(major, minor, build, revision); @@ -101,6 +112,7 @@ public static bool IsOSPlatformVersionAtLeast(string platform, int major, int mi /// Indicates whether the current application is running on Windows. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.operatingsystem.iswindows?view=net-11.0 + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsWindows() => RuntimeInformation.IsOSPlatform(OSPlatform.Windows); @@ -108,6 +120,7 @@ public static bool IsWindows() => /// Indicates whether the current application is running on macOS. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.operatingsystem.ismacos?view=net-11.0 + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsMacOS() => RuntimeInformation.IsOSPlatform(OSPlatform.OSX); @@ -115,6 +128,7 @@ public static bool IsMacOS() => /// Indicates whether the current application is running on iOS or MacCatalyst. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.operatingsystem.isios?view=net-11.0 + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsIOS() => RuntimeInformation.IsOSPlatform(OSPlatform.Create("IOS")); @@ -122,6 +136,7 @@ public static bool IsIOS() => /// Indicates whether the current application is running on Linux. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.operatingsystem.islinux?view=net-11.0 + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsLinux() => RuntimeInformation.IsOSPlatform(OSPlatform.Linux); @@ -129,6 +144,7 @@ public static bool IsLinux() => /// Indicates whether the current application is running on FreeBSD. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.operatingsystem.isfreebsd?view=net-11.0 + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsFreeBSD() => RuntimeInformation.OSDescription.ToLower().Contains("freebsd"); @@ -136,6 +152,7 @@ public static bool IsFreeBSD() => /// Checks if the iOS/MacCatalyst version (returned by libobjc.get_operatingSystemVersion) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified iOS version. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.operatingsystem.isiosversionatleast?view=net-11.0 + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsIOSVersionAtLeast(int major, int minor = 0, int build = 0) => IsIOS() && IsOsVersionAtLeast(major, minor, build); @@ -144,6 +161,7 @@ public static bool IsIOSVersionAtLeast(int major, int minor = 0, int build = 0) /// Checks if the tvOS version (returned by libobjc.get_operatingSystemVersion) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified tvOS version. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.operatingsystem.istvosversionatleast?view=net-11.0 + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsTvOSVersionAtLeast(int major, int minor = 0, int build = 0) => IsTvOS() && IsOsVersionAtLeast(major, minor, build); @@ -152,6 +170,7 @@ public static bool IsTvOSVersionAtLeast(int major, int minor = 0, int build = 0) /// Indicates whether the current application is running on tvOS. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.operatingsystem.istvos?view=net-11.0 + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsTvOS() => RuntimeInformation.IsOSPlatform(OSPlatform.Create("TVOS")); @@ -159,6 +178,7 @@ public static bool IsTvOS() => /// Indicates whether the current application is running on watchOS. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.operatingsystem.iswatchos?view=net-11.0 + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsWatchOS() => IsIOS() || RuntimeInformation.OSDescription.ToLower().Contains("watchos"); @@ -167,6 +187,7 @@ public static bool IsWatchOS() => /// Checks if the watchOS version (returned by libobjc.get_operatingSystemVersion) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified watchOS version. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.operatingsystem.iswatchosversionatleast?view=net-11.0 + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsWatchOSVersionAtLeast(int major, int minor = 0, int build = 0) => IsWatchOS() && IsOsVersionAtLeast(major, minor, build); @@ -175,6 +196,7 @@ public static bool IsWatchOSVersionAtLeast(int major, int minor = 0, int build = /// Indicates whether the current application is running as WASM in a browser. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.operatingsystem.isbrowser?view=net-11.0 + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsBrowser() => RuntimeInformation.IsOSPlatform(OSPlatform.Create("BROWSER")); diff --git a/src/Polyfill/PathPolyfill.cs b/src/Polyfill/PathPolyfill.cs index f54a21764..a5e8202a5 100644 --- a/src/Polyfill/PathPolyfill.cs +++ b/src/Polyfill/PathPolyfill.cs @@ -4,6 +4,7 @@ namespace Polyfills; using System; using System.IO; +using System.Runtime.CompilerServices; static partial class Polyfill { @@ -15,6 +16,7 @@ static partial class Polyfill /// Returns the directory information for the specified path represented by a character span. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.io.path.getdirectoryname?view=net-11.0#system-io-path-getdirectoryname(system-readonlyspan((system-char))) + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ReadOnlySpan GetDirectoryName(ReadOnlySpan path) => Path.GetDirectoryName(path.ToString()).AsSpan(); @@ -22,6 +24,7 @@ public static ReadOnlySpan GetDirectoryName(ReadOnlySpan path) => /// Returns the file name and extension of a file path that is represented by a read-only character span. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.io.path.getfilename?view=net-11.0#system-io-path-getfilename(system-readonlyspan((system-char))) + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ReadOnlySpan GetFileName(ReadOnlySpan path) => Path.GetFileName(path.ToString()).AsSpan(); @@ -29,6 +32,7 @@ public static ReadOnlySpan GetFileName(ReadOnlySpan path) => /// Returns the file name without the extension of a file path that is represented by a read-only character span. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.io.path.getfilenamewithoutextension?view=net-11.0#system-io-path-getfilenamewithoutextension(system-readonlyspan((system-char))) + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ReadOnlySpan GetFileNameWithoutExtension(ReadOnlySpan path) => Path.GetFileNameWithoutExtension(path.ToString()).AsSpan(); @@ -36,6 +40,7 @@ public static ReadOnlySpan GetFileNameWithoutExtension(ReadOnlySpan /// Determines whether the path represented by the specified character span includes a file name extension. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.io.path.getfilenamewithoutextension?view=net-11.0#system-io-path-getfilenamewithoutextension(system-readonlyspan((system-char))) + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool HasExtension(ReadOnlySpan path) => Path.HasExtension(path.ToString()); @@ -43,6 +48,7 @@ public static bool HasExtension(ReadOnlySpan path) => /// Returns the extension of the given path. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.io.path.getextension?view=net-11.0#system-io-path-getextension(system-readonlyspan((system-char))) + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ReadOnlySpan GetExtension(ReadOnlySpan path) => Path.GetExtension(path.ToString()).AsSpan(); #endif @@ -52,6 +58,7 @@ public static ReadOnlySpan GetExtension(ReadOnlySpan path) => /// Combines a span of strings into a path. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.io.path.combine?view=net-11.0#system-io-path-combine(system-readonlyspan((system-string))) + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string Combine(scoped ReadOnlySpan paths) => Path.Combine(paths.ToArray()); #endif @@ -61,6 +68,7 @@ public static string Combine(scoped ReadOnlySpan paths) => /// Returns a value that indicates whether the path, specified as a read-only span, ends in a directory separator. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.io.path.endsindirectoryseparator?view=net-11.0#system-io-path-endsindirectoryseparator(system-readonlyspan((system-char))) + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool EndsInDirectorySeparator (ReadOnlySpan path) => EndsInDirectorySeparator(path.ToString()); @@ -68,6 +76,7 @@ public static bool EndsInDirectorySeparator (ReadOnlySpan path) => /// Trims one trailing directory separator beyond the root of the specified path. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.io.path.trimendingdirectoryseparator?view=net-11.0#system-io-path-trimendingdirectoryseparator(system-readonlyspan((system-char))) + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ReadOnlySpan TrimEndingDirectorySeparator(ReadOnlySpan path) => TrimEndingDirectorySeparator(path.ToString()).AsSpan(); #endif diff --git a/src/Split/net10.0/ConsolePolyfill.cs b/src/Split/net10.0/ConsolePolyfill.cs index 425364db8..5ad0342de 100644 --- a/src/Split/net10.0/ConsolePolyfill.cs +++ b/src/Split/net10.0/ConsolePolyfill.cs @@ -4,6 +4,7 @@ namespace Polyfills; using System; using System.Runtime.InteropServices; +using System.Runtime.CompilerServices; using Microsoft.Win32.SafeHandles; static partial class Polyfill { @@ -12,16 +13,19 @@ static partial class Polyfill /// /// Gets a that wraps the operating system handle for standard input. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static SafeFileHandle OpenStandardInputHandle() => StandardHandleHelper.GetStandardHandle(StandardHandleHelper.StdInput); /// /// Gets a that wraps the operating system handle for standard output. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static SafeFileHandle OpenStandardOutputHandle() => StandardHandleHelper.GetStandardHandle(StandardHandleHelper.StdOutput); /// /// Gets a that wraps the operating system handle for standard error. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static SafeFileHandle OpenStandardErrorHandle() => StandardHandleHelper.GetStandardHandle(StandardHandleHelper.StdError); } diff --git a/src/Split/net11.0/ConsolePolyfill.cs b/src/Split/net11.0/ConsolePolyfill.cs index 425364db8..5ad0342de 100644 --- a/src/Split/net11.0/ConsolePolyfill.cs +++ b/src/Split/net11.0/ConsolePolyfill.cs @@ -4,6 +4,7 @@ namespace Polyfills; using System; using System.Runtime.InteropServices; +using System.Runtime.CompilerServices; using Microsoft.Win32.SafeHandles; static partial class Polyfill { @@ -12,16 +13,19 @@ static partial class Polyfill /// /// Gets a that wraps the operating system handle for standard input. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static SafeFileHandle OpenStandardInputHandle() => StandardHandleHelper.GetStandardHandle(StandardHandleHelper.StdInput); /// /// Gets a that wraps the operating system handle for standard output. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static SafeFileHandle OpenStandardOutputHandle() => StandardHandleHelper.GetStandardHandle(StandardHandleHelper.StdOutput); /// /// Gets a that wraps the operating system handle for standard error. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static SafeFileHandle OpenStandardErrorHandle() => StandardHandleHelper.GetStandardHandle(StandardHandleHelper.StdError); } diff --git a/src/Split/net461/ConsolePolyfill.cs b/src/Split/net461/ConsolePolyfill.cs index 425364db8..5ad0342de 100644 --- a/src/Split/net461/ConsolePolyfill.cs +++ b/src/Split/net461/ConsolePolyfill.cs @@ -4,6 +4,7 @@ namespace Polyfills; using System; using System.Runtime.InteropServices; +using System.Runtime.CompilerServices; using Microsoft.Win32.SafeHandles; static partial class Polyfill { @@ -12,16 +13,19 @@ static partial class Polyfill /// /// Gets a that wraps the operating system handle for standard input. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static SafeFileHandle OpenStandardInputHandle() => StandardHandleHelper.GetStandardHandle(StandardHandleHelper.StdInput); /// /// Gets a that wraps the operating system handle for standard output. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static SafeFileHandle OpenStandardOutputHandle() => StandardHandleHelper.GetStandardHandle(StandardHandleHelper.StdOutput); /// /// Gets a that wraps the operating system handle for standard error. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static SafeFileHandle OpenStandardErrorHandle() => StandardHandleHelper.GetStandardHandle(StandardHandleHelper.StdError); } diff --git a/src/Split/net461/ConvertPolyfill.cs b/src/Split/net461/ConvertPolyfill.cs index 8ca6da94f..5f80df1f7 100644 --- a/src/Split/net461/ConvertPolyfill.cs +++ b/src/Split/net461/ConvertPolyfill.cs @@ -2,6 +2,7 @@ #pragma warning disable namespace Polyfills; using System; +using System.Runtime.CompilerServices; static partial class Polyfill { extension(Convert) @@ -10,22 +11,26 @@ static partial class Polyfill /// Converts a subset of an array of 8-bit unsigned integers to its equivalent string representation that is encoded with uppercase hex characters. /// Parameters specify the subset as an offset in the input array and the number of elements in the array to convert. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexString(byte[] inArray, int offset, int length) => ToHexString(inArray, offset, length, "X2"); /// /// Converts a subset of an array of 8-bit unsigned integers to its equivalent string representation that is encoded with lowercase hex characters. /// Parameters specify the subset as an offset in the input array and the number of elements in the array to convert. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexStringLower(byte[] inArray, int offset, int length) => ToHexString(inArray, offset, length, "x2"); /// /// Converts an array of 8-bit unsigned integers to its equivalent string representation that is encoded with lowercase hex characters. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexStringLower(byte[] inArray) => Polyfill.ToHexStringLower(inArray, 0, inArray.Length); /// /// Converts an array of 8-bit unsigned integers to its equivalent string representation that is encoded with uppercase hex characters. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexString(byte[] inArray) => Polyfill.ToHexString(inArray, 0, inArray.Length); /// @@ -54,16 +59,19 @@ static int GetHexValue(char hex) => /// /// Converts the span, which encodes binary data as hex characters, to an equivalent 8-bit unsigned integer array. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static byte[] FromHexString(ReadOnlySpan chars) => Polyfill.FromHexString(chars.ToString()); /// /// Converts a span of 8-bit unsigned integers to its equivalent string representation that is encoded with uppercase hex characters. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexString(ReadOnlySpan bytes) => Polyfill.ToHexString(bytes.ToArray()); /// /// Converts a span of 8-bit unsigned integers to its equivalent string representation that is encoded with lowercase hex characters. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexStringLower(ReadOnlySpan bytes) => Polyfill.ToHexStringLower(bytes.ToArray()); /// diff --git a/src/Split/net461/DateTimeOffsetPolyfill.cs b/src/Split/net461/DateTimeOffsetPolyfill.cs index 6837790e5..7bb9a5ad7 100644 --- a/src/Split/net461/DateTimeOffsetPolyfill.cs +++ b/src/Split/net461/DateTimeOffsetPolyfill.cs @@ -4,6 +4,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; static partial class Polyfill { extension(DateTimeOffset target) @@ -30,32 +31,38 @@ long TicksComponent() /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out DateTimeOffset result) => DateTimeOffset.TryParse(s, provider, DateTimeStyles.None, out result); #if FeatureMemory /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out DateTimeOffset result) => DateTimeOffset.TryParse(s.ToString(), provider, DateTimeStyles.None, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan input, out DateTimeOffset result) => DateTimeOffset.TryParse(input.ToString(), null, DateTimeStyles.None, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, DateTimeStyles styles, out DateTimeOffset result) => DateTimeOffset.TryParse(s.ToString(), provider, styles, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParseExact(ReadOnlySpan input, string format, IFormatProvider? provider, DateTimeStyles styles, out DateTimeOffset result) => DateTimeOffset.TryParseExact(input.ToString(), format, provider, styles, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParseExact(ReadOnlySpan input, ReadOnlySpan format, IFormatProvider? provider, DateTimeStyles styles, out DateTimeOffset result) => DateTimeOffset.TryParseExact(input.ToString(), format.ToString(), provider, styles, out result); #endif diff --git a/src/Split/net461/DateTimePolyfill.cs b/src/Split/net461/DateTimePolyfill.cs index 4641f3e59..4d329796a 100644 --- a/src/Split/net461/DateTimePolyfill.cs +++ b/src/Split/net461/DateTimePolyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; static partial class Polyfill { extension(DateTime target) @@ -29,32 +30,38 @@ long TicksComponent() /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out DateTime result) => DateTime.TryParse(s, provider, DateTimeStyles.None, out result); #if FeatureMemory /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out DateTime result) => DateTime.TryParse(s.ToString(), provider, DateTimeStyles.None, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out DateTime result) => DateTime.TryParse(s.ToString(), null, DateTimeStyles.None, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, DateTimeStyles styles, out DateTime result) => DateTime.TryParse(s.ToString(), provider, styles, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParseExact(ReadOnlySpan s, string format, IFormatProvider? provider, DateTimeStyles style, out DateTime result) => DateTime.TryParseExact(s.ToString(), format, provider, style, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParseExact(ReadOnlySpan s, ReadOnlySpan format, IFormatProvider? provider, DateTimeStyles styles, out DateTime result) => DateTime.TryParseExact(s.ToString(), format.ToString(), provider, styles, out result); #endif diff --git a/src/Split/net461/DelegatePolyfill.cs b/src/Split/net461/DelegatePolyfill.cs index effdb1267..59cc5e315 100644 --- a/src/Split/net461/DelegatePolyfill.cs +++ b/src/Split/net461/DelegatePolyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.ComponentModel; +using System.Runtime.CompilerServices; static partial class Polyfill { /// @@ -39,6 +40,7 @@ public bool MoveNext() /// /// Gets an enumerator for the invocation targets of this delegate. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static InvocationListEnumerator EnumerateInvocationList(TDelegate? target) where TDelegate : Delegate => new(target); diff --git a/src/Split/net461/FilePolyfill.cs b/src/Split/net461/FilePolyfill.cs index c6112e74d..66cb81a14 100644 --- a/src/Split/net461/FilePolyfill.cs +++ b/src/Split/net461/FilePolyfill.cs @@ -48,11 +48,13 @@ public static Task AppendAllTextAsync(string path, ReadOnlyMemory contents /// /// Appends the specified string to the file, creating the file if it does not already exist. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void AppendAllText(string path, ReadOnlySpan contents) => File.AppendAllText(path, contents.ToString()); /// /// Appends the specified string to the file, creating the file if it does not already exist. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void AppendAllText(string path, ReadOnlySpan contents, Encoding encoding) => File.AppendAllText(path, contents.ToString(), encoding); /// @@ -76,12 +78,14 @@ public static async Task WriteAllBytesAsync(string path, ReadOnlyMemory by /// Creates a new file, writes the specified string to the file, and then closes the file. /// If the target file already exists, it is truncated and overwritten. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void WriteAllText(string path, ReadOnlySpan contents) => File.WriteAllText(path, contents.ToString()); /// /// Creates a new file, writes the specified string to the file using the specified encoding, and then closes the file. /// If the target file already exists, it is truncated and overwritten. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void WriteAllText(string path, ReadOnlySpan contents, Encoding encoding) => File.WriteAllText(path, contents.ToString(), encoding); /// diff --git a/src/Split/net461/GuidPolyfill.cs b/src/Split/net461/GuidPolyfill.cs index 2bd536736..bc6b9129b 100644 --- a/src/Split/net461/GuidPolyfill.cs +++ b/src/Split/net461/GuidPolyfill.cs @@ -4,6 +4,7 @@ namespace Polyfills; using System.Text; using System; using System.Security.Cryptography; +using System.Runtime.CompilerServices; static partial class Polyfill { extension(Guid) @@ -11,9 +12,11 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out Guid result) => Guid.TryParse(s, out result); /// Creates a new according to RFC 9562, following the Version 7 format. + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Guid CreateVersion7() => CreateVersion7(DateTimeOffset.UtcNow); /// Creates a new according to RFC 9562, following the Version 7 format. public static Guid CreateVersion7(DateTimeOffset timestamp) @@ -40,26 +43,31 @@ public static Guid CreateVersion7(DateTimeOffset timestamp) /// /// Converts span of characters representing the GUID to the equivalent Guid structure, provided that the string is in the specified format. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParseExact(ReadOnlySpan input, ReadOnlySpan format, out Guid result) => Guid.TryParseExact(input.ToString(), format.ToString(), out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out Guid result) => Guid.TryParse(s.ToString(), out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan input, out Guid result) => Guid.TryParse(input.ToString(), out result); /// /// Tries to parse a span of UTF-8 bytes into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out Guid result) => Guid.TryParse(Encoding.UTF8.GetString(utf8Text), out result); /// /// Parse a span of UTF-8 bytes into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Guid Parse(ReadOnlySpan utf8Text) => Guid.Parse(Encoding.UTF8.GetString(utf8Text)); #endif diff --git a/src/Split/net461/KeyValuePair.cs b/src/Split/net461/KeyValuePair.cs index 7e5d58959..e94cbbf2f 100644 --- a/src/Split/net461/KeyValuePair.cs +++ b/src/Split/net461/KeyValuePair.cs @@ -4,6 +4,7 @@ namespace System.Collections.Generic; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; +using System.Runtime.CompilerServices; [ExcludeFromCodeCoverage] [DebuggerNonUserCode] #if PolyUseEmbeddedAttribute @@ -17,6 +18,7 @@ static class KeyValuePair /// /// Creates a new key/value pair instance using provided values. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static KeyValuePair Create(TKey key, TValue value) => new(key, value); } diff --git a/src/Split/net461/Lock.cs b/src/Split/net461/Lock.cs index 94fcf1ff9..36946028c 100644 --- a/src/Split/net461/Lock.cs +++ b/src/Split/net461/Lock.cs @@ -5,6 +5,7 @@ namespace System.Threading; using Diagnostics; using Diagnostics.CodeAnalysis; +using Runtime.CompilerServices; /// /// Provides a way to get mutual exclusion in regions of code between different threads. A lock may be held by one thread at /// a time. @@ -23,26 +24,31 @@ class Lock /// /// Enters the lock. Once the method returns, the calling thread would be the only thread that holds the lock. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Enter() => Monitor.Enter(this); /// /// Tries to enter the lock without waiting. If the lock is entered, the calling thread would be the only thread that /// holds the lock. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool TryEnter() => Monitor.TryEnter(this); /// /// Tries to enter the lock, waiting for roughly the specified duration. If the lock is entered, the calling thread /// would be the only thread that holds the lock. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool TryEnter(TimeSpan timeout) => Monitor.TryEnter(this, timeout); /// /// Tries to enter the lock, waiting for roughly the specified duration. If the lock is entered, the calling thread /// would be the only thread that holds the lock. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool TryEnter(int millisecondsTimeout) => TryEnter(TimeSpan.FromMilliseconds(millisecondsTimeout)); /// /// Exits the lock. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Exit() => Monitor.Exit(this); /// /// Enters the lock and returns a that may be disposed to exit the lock. Once the method returns, diff --git a/src/Split/net461/Numbers/BytePolyfill.cs b/src/Split/net461/Numbers/BytePolyfill.cs index ef3f744ed..0ea017afd 100644 --- a/src/Split/net461/Numbers/BytePolyfill.cs +++ b/src/Split/net461/Numbers/BytePolyfill.cs @@ -4,6 +4,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -12,37 +13,44 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out byte result) => byte.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out byte result) => byte.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out byte result) => byte.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out byte result) => byte.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its byte equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out byte result) => byte.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its byte equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out byte result) => byte.TryParse(s.ToString(), out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its byte equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out byte result) => byte.TryParse(s.ToString(), style, provider, out result); #endif diff --git a/src/Split/net461/Numbers/DoublePolyfill.cs b/src/Split/net461/Numbers/DoublePolyfill.cs index ba5333f69..d903ddfe1 100644 --- a/src/Split/net461/Numbers/DoublePolyfill.cs +++ b/src/Split/net461/Numbers/DoublePolyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,37 +12,44 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out double result) => double.TryParse(s, NumberStyles.Float, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out double result) => double.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Float, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out double result) => double.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its double-precision floating-point number equivalent.. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out double result) => double.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Float, null, out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its double-precision floating-point number equivalent. A return value indicates whether the conversion succeeded or failed. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out double result) => double.TryParse(s.ToString(), out result); /// /// Converts the string representation of a number in a specified style and culture-specific format to its double-precision floating-point number equivalent. A return value indicates whether the conversion succeeded or failed. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out double result) => double.TryParse(s.ToString(), style, provider, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out double result) => double.TryParse(s.ToString(), NumberStyles.Float, provider, out result); #endif diff --git a/src/Split/net461/Numbers/Int16Polyfill.cs b/src/Split/net461/Numbers/Int16Polyfill.cs index 5eb1b384e..960cf68ce 100644 --- a/src/Split/net461/Numbers/Int16Polyfill.cs +++ b/src/Split/net461/Numbers/Int16Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,37 +12,44 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out short result) => short.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out short result) => short.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out short result) => short.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its short equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out short result) => short.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its short equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out short result) => short.TryParse(s.ToString(), out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its short equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out short result) => short.TryParse(s.ToString(), style, provider, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out short result) => short.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/net461/Numbers/Int32Polyfill.cs b/src/Split/net461/Numbers/Int32Polyfill.cs index 549ff1896..2920eae4a 100644 --- a/src/Split/net461/Numbers/Int32Polyfill.cs +++ b/src/Split/net461/Numbers/Int32Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,37 +12,44 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out int result) => int.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out int result) => int.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out int result) => int.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its 32-bit signed integer equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out int result) => int.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its 32-bit signed integer equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out int result) => int.TryParse(s.ToString(), out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its 32-bit signed integer equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out int result) => int.TryParse(s.ToString(), style, provider, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out int result) => int.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/net461/Numbers/Int64Polyfill.cs b/src/Split/net461/Numbers/Int64Polyfill.cs index bd33ce0e6..0b7b1b100 100644 --- a/src/Split/net461/Numbers/Int64Polyfill.cs +++ b/src/Split/net461/Numbers/Int64Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,37 +12,44 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out long result) => long.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out long result) => long.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out long result) => long.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its 64-bit signed integer equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out long result) => long.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its 32-bit signed integer equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out long result) => long.TryParse(s.ToString(), out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its 64-bit signed integer equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out long result) => long.TryParse(s.ToString(), style, provider, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out long result) => long.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/net461/Numbers/SBytePolyfill.cs b/src/Split/net461/Numbers/SBytePolyfill.cs index 974115654..890452b1c 100644 --- a/src/Split/net461/Numbers/SBytePolyfill.cs +++ b/src/Split/net461/Numbers/SBytePolyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,37 +12,44 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out sbyte result) => sbyte.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out sbyte result) => sbyte.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out sbyte result) => sbyte.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its sbyte equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out sbyte result) => sbyte.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its sbyte equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out sbyte result) => sbyte.TryParse(s.ToString(), out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its sbyte equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out sbyte result) => sbyte.TryParse(s.ToString(), style, provider, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out sbyte result) => sbyte.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/net461/Numbers/UInt16Polyfill.cs b/src/Split/net461/Numbers/UInt16Polyfill.cs index 34f39f97c..ed0958805 100644 --- a/src/Split/net461/Numbers/UInt16Polyfill.cs +++ b/src/Split/net461/Numbers/UInt16Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,37 +12,44 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out ushort result) => ushort.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out ushort result) => ushort.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out ushort result) => ushort.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its ushort equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out ushort result) => ushort.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its ushort equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out ushort result) => ushort.TryParse(s.ToString(), out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its ushort equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out ushort result) => ushort.TryParse(s.ToString(), style, provider, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out ushort result) => ushort.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/net461/Numbers/UInt32Polyfill.cs b/src/Split/net461/Numbers/UInt32Polyfill.cs index 859149bed..e11b65c90 100644 --- a/src/Split/net461/Numbers/UInt32Polyfill.cs +++ b/src/Split/net461/Numbers/UInt32Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,37 +12,44 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out uint result) => uint.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out uint result) => uint.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out uint result) => uint.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its uint equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out uint result) => uint.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its uint equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out uint result) => uint.TryParse(s.ToString(), out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its uint equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out uint result) => uint.TryParse(s.ToString(), style, provider, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out uint result) => uint.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/net461/Numbers/UInt64Polyfill.cs b/src/Split/net461/Numbers/UInt64Polyfill.cs index c14bb347c..10122d2b4 100644 --- a/src/Split/net461/Numbers/UInt64Polyfill.cs +++ b/src/Split/net461/Numbers/UInt64Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,37 +12,44 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out ulong result) => ulong.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out ulong result) => ulong.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpanutf8Text, NumberStyles style, IFormatProvider? provider, out ulong result) => ulong.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its ulong equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out ulong result) => ulong.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its ulong equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out ulong result) => ulong.TryParse(s.ToString(), out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its ulong equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out ulong result) => ulong.TryParse(s.ToString(), style, provider, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out ulong result) => ulong.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/net461/OperatingSystemPolyfill.cs b/src/Split/net461/OperatingSystemPolyfill.cs index 5d1f8de36..68413c7d5 100644 --- a/src/Split/net461/OperatingSystemPolyfill.cs +++ b/src/Split/net461/OperatingSystemPolyfill.cs @@ -3,6 +3,7 @@ #if FeatureRuntimeInformation namespace Polyfills; using System; +using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; static partial class Polyfill @@ -14,114 +15,135 @@ static bool IsOsVersionAtLeast(int major, int minor = 0, int build = 0, int revi /// /// Indicates whether the current application is running as WASI. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsWasi() => RuntimeInformation.IsOSPlatform(OSPlatform.Create("WASI")); /// /// Indicates whether the current application is running on Mac Catalyst. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsMacCatalyst() => OperatingSystem.IsMacOS() || OperatingSystem.IsIOS(); /// /// Check for the Mac Catalyst version (iOS version as presented in Apple documentation) with a ≤ version comparison. Used to guard APIs that were added in the given Mac Catalyst release. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsMacCatalystVersionAtLeast(int major, int minor = 0, int build = 0) => IsMacCatalyst() && IsOsVersionAtLeast(major, minor, build); /// /// Checks if the macOS version (returned by libobjc.get_operatingSystemVersion) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified macOS version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsMacOSVersionAtLeast(int major, int minor = 0, int build = 0) => OperatingSystemCache.IsMacOSVersionAtLeast(major, minor, build); /// /// Checks if the FreeBSD version (returned by the Linux command uname) is greater than or equal to the specified version. /// This method can be used to guard APIs that were added in the specified version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsFreeBSDVersionAtLeast(int major, int minor, int build = 0, int revision = 0) => OperatingSystemCache.IsFreeBSDVersionAtLeast(major, minor, build, revision); /// /// Indicates whether the current application is running on Android. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsAndroid() => OperatingSystemCache.IsAndroid(); /// /// Checks if the Android version (returned by the Linux command uname) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsAndroidVersionAtLeast(int major, int minor = 0, int build = 0, int revision = 0) => OperatingSystemCache.IsAndroidVersionAtLeast(major, minor, build, revision); /// /// Checks if the Windows version (returned by RtlGetVersion) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified Windows version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsWindowsVersionAtLeast(int major, int minor = 0, int build = 0, int revision = 0) => OperatingSystemCache.IsWindowsVersionAtLeast(major, minor, build, revision); /// /// Indicates whether the current application is running on the specified platform. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsOSPlatform(string platform) => RuntimeInformation.IsOSPlatform(OSPlatform.Create(platform)); /// /// Checks if the operating system version is greater than or equal to the specified platform version. This method can be used to guard APIs that were added in the specified OS version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsOSPlatformVersionAtLeast(string platform, int major, int minor = 0, int build = 0, int revision = 0) => IsOSPlatform(platform) && IsOsVersionAtLeast(major, minor, build, revision); /// /// Indicates whether the current application is running on Windows. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsWindows() => RuntimeInformation.IsOSPlatform(OSPlatform.Windows); /// /// Indicates whether the current application is running on macOS. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsMacOS() => RuntimeInformation.IsOSPlatform(OSPlatform.OSX); /// /// Indicates whether the current application is running on iOS or MacCatalyst. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsIOS() => RuntimeInformation.IsOSPlatform(OSPlatform.Create("IOS")); /// /// Indicates whether the current application is running on Linux. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsLinux() => RuntimeInformation.IsOSPlatform(OSPlatform.Linux); /// /// Indicates whether the current application is running on FreeBSD. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsFreeBSD() => RuntimeInformation.OSDescription.ToLower().Contains("freebsd"); /// /// Checks if the iOS/MacCatalyst version (returned by libobjc.get_operatingSystemVersion) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified iOS version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsIOSVersionAtLeast(int major, int minor = 0, int build = 0) => IsIOS() && IsOsVersionAtLeast(major, minor, build); /// /// Checks if the tvOS version (returned by libobjc.get_operatingSystemVersion) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified tvOS version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsTvOSVersionAtLeast(int major, int minor = 0, int build = 0) => IsTvOS() && IsOsVersionAtLeast(major, minor, build); /// /// Indicates whether the current application is running on tvOS. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsTvOS() => RuntimeInformation.IsOSPlatform(OSPlatform.Create("TVOS")); /// /// Indicates whether the current application is running on watchOS. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsWatchOS() => IsIOS() || RuntimeInformation.OSDescription.ToLower().Contains("watchos"); /// /// Checks if the watchOS version (returned by libobjc.get_operatingSystemVersion) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified watchOS version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsWatchOSVersionAtLeast(int major, int minor = 0, int build = 0) => IsWatchOS() && IsOsVersionAtLeast(major, minor, build); /// /// Indicates whether the current application is running as WASM in a browser. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsBrowser() => RuntimeInformation.IsOSPlatform(OSPlatform.Create("BROWSER")); } diff --git a/src/Split/net461/PathPolyfill.cs b/src/Split/net461/PathPolyfill.cs index fb4329ac6..fc8009da8 100644 --- a/src/Split/net461/PathPolyfill.cs +++ b/src/Split/net461/PathPolyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.IO; +using System.Runtime.CompilerServices; static partial class Polyfill { extension(Path) @@ -11,41 +12,49 @@ static partial class Polyfill /// /// Returns the directory information for the specified path represented by a character span. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ReadOnlySpan GetDirectoryName(ReadOnlySpan path) => Path.GetDirectoryName(path.ToString()).AsSpan(); /// /// Returns the file name and extension of a file path that is represented by a read-only character span. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ReadOnlySpan GetFileName(ReadOnlySpan path) => Path.GetFileName(path.ToString()).AsSpan(); /// /// Returns the file name without the extension of a file path that is represented by a read-only character span. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ReadOnlySpan GetFileNameWithoutExtension(ReadOnlySpan path) => Path.GetFileNameWithoutExtension(path.ToString()).AsSpan(); /// /// Determines whether the path represented by the specified character span includes a file name extension. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool HasExtension(ReadOnlySpan path) => Path.HasExtension(path.ToString()); /// /// Returns the extension of the given path. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ReadOnlySpan GetExtension(ReadOnlySpan path) => Path.GetExtension(path.ToString()).AsSpan(); /// /// Combines a span of strings into a path. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string Combine(scoped ReadOnlySpan paths) => Path.Combine(paths.ToArray()); /// /// Returns a value that indicates whether the path, specified as a read-only span, ends in a directory separator. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool EndsInDirectorySeparator (ReadOnlySpan path) => EndsInDirectorySeparator(path.ToString()); /// /// Trims one trailing directory separator beyond the root of the specified path. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ReadOnlySpan TrimEndingDirectorySeparator(ReadOnlySpan path) => TrimEndingDirectorySeparator(path.ToString()).AsSpan(); #endif diff --git a/src/Split/net462/ConsolePolyfill.cs b/src/Split/net462/ConsolePolyfill.cs index 425364db8..5ad0342de 100644 --- a/src/Split/net462/ConsolePolyfill.cs +++ b/src/Split/net462/ConsolePolyfill.cs @@ -4,6 +4,7 @@ namespace Polyfills; using System; using System.Runtime.InteropServices; +using System.Runtime.CompilerServices; using Microsoft.Win32.SafeHandles; static partial class Polyfill { @@ -12,16 +13,19 @@ static partial class Polyfill /// /// Gets a that wraps the operating system handle for standard input. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static SafeFileHandle OpenStandardInputHandle() => StandardHandleHelper.GetStandardHandle(StandardHandleHelper.StdInput); /// /// Gets a that wraps the operating system handle for standard output. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static SafeFileHandle OpenStandardOutputHandle() => StandardHandleHelper.GetStandardHandle(StandardHandleHelper.StdOutput); /// /// Gets a that wraps the operating system handle for standard error. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static SafeFileHandle OpenStandardErrorHandle() => StandardHandleHelper.GetStandardHandle(StandardHandleHelper.StdError); } diff --git a/src/Split/net462/ConvertPolyfill.cs b/src/Split/net462/ConvertPolyfill.cs index 8ca6da94f..5f80df1f7 100644 --- a/src/Split/net462/ConvertPolyfill.cs +++ b/src/Split/net462/ConvertPolyfill.cs @@ -2,6 +2,7 @@ #pragma warning disable namespace Polyfills; using System; +using System.Runtime.CompilerServices; static partial class Polyfill { extension(Convert) @@ -10,22 +11,26 @@ static partial class Polyfill /// Converts a subset of an array of 8-bit unsigned integers to its equivalent string representation that is encoded with uppercase hex characters. /// Parameters specify the subset as an offset in the input array and the number of elements in the array to convert. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexString(byte[] inArray, int offset, int length) => ToHexString(inArray, offset, length, "X2"); /// /// Converts a subset of an array of 8-bit unsigned integers to its equivalent string representation that is encoded with lowercase hex characters. /// Parameters specify the subset as an offset in the input array and the number of elements in the array to convert. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexStringLower(byte[] inArray, int offset, int length) => ToHexString(inArray, offset, length, "x2"); /// /// Converts an array of 8-bit unsigned integers to its equivalent string representation that is encoded with lowercase hex characters. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexStringLower(byte[] inArray) => Polyfill.ToHexStringLower(inArray, 0, inArray.Length); /// /// Converts an array of 8-bit unsigned integers to its equivalent string representation that is encoded with uppercase hex characters. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexString(byte[] inArray) => Polyfill.ToHexString(inArray, 0, inArray.Length); /// @@ -54,16 +59,19 @@ static int GetHexValue(char hex) => /// /// Converts the span, which encodes binary data as hex characters, to an equivalent 8-bit unsigned integer array. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static byte[] FromHexString(ReadOnlySpan chars) => Polyfill.FromHexString(chars.ToString()); /// /// Converts a span of 8-bit unsigned integers to its equivalent string representation that is encoded with uppercase hex characters. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexString(ReadOnlySpan bytes) => Polyfill.ToHexString(bytes.ToArray()); /// /// Converts a span of 8-bit unsigned integers to its equivalent string representation that is encoded with lowercase hex characters. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexStringLower(ReadOnlySpan bytes) => Polyfill.ToHexStringLower(bytes.ToArray()); /// diff --git a/src/Split/net462/DateTimeOffsetPolyfill.cs b/src/Split/net462/DateTimeOffsetPolyfill.cs index 6837790e5..7bb9a5ad7 100644 --- a/src/Split/net462/DateTimeOffsetPolyfill.cs +++ b/src/Split/net462/DateTimeOffsetPolyfill.cs @@ -4,6 +4,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; static partial class Polyfill { extension(DateTimeOffset target) @@ -30,32 +31,38 @@ long TicksComponent() /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out DateTimeOffset result) => DateTimeOffset.TryParse(s, provider, DateTimeStyles.None, out result); #if FeatureMemory /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out DateTimeOffset result) => DateTimeOffset.TryParse(s.ToString(), provider, DateTimeStyles.None, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan input, out DateTimeOffset result) => DateTimeOffset.TryParse(input.ToString(), null, DateTimeStyles.None, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, DateTimeStyles styles, out DateTimeOffset result) => DateTimeOffset.TryParse(s.ToString(), provider, styles, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParseExact(ReadOnlySpan input, string format, IFormatProvider? provider, DateTimeStyles styles, out DateTimeOffset result) => DateTimeOffset.TryParseExact(input.ToString(), format, provider, styles, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParseExact(ReadOnlySpan input, ReadOnlySpan format, IFormatProvider? provider, DateTimeStyles styles, out DateTimeOffset result) => DateTimeOffset.TryParseExact(input.ToString(), format.ToString(), provider, styles, out result); #endif diff --git a/src/Split/net462/DateTimePolyfill.cs b/src/Split/net462/DateTimePolyfill.cs index 4641f3e59..4d329796a 100644 --- a/src/Split/net462/DateTimePolyfill.cs +++ b/src/Split/net462/DateTimePolyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; static partial class Polyfill { extension(DateTime target) @@ -29,32 +30,38 @@ long TicksComponent() /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out DateTime result) => DateTime.TryParse(s, provider, DateTimeStyles.None, out result); #if FeatureMemory /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out DateTime result) => DateTime.TryParse(s.ToString(), provider, DateTimeStyles.None, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out DateTime result) => DateTime.TryParse(s.ToString(), null, DateTimeStyles.None, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, DateTimeStyles styles, out DateTime result) => DateTime.TryParse(s.ToString(), provider, styles, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParseExact(ReadOnlySpan s, string format, IFormatProvider? provider, DateTimeStyles style, out DateTime result) => DateTime.TryParseExact(s.ToString(), format, provider, style, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParseExact(ReadOnlySpan s, ReadOnlySpan format, IFormatProvider? provider, DateTimeStyles styles, out DateTime result) => DateTime.TryParseExact(s.ToString(), format.ToString(), provider, styles, out result); #endif diff --git a/src/Split/net462/DelegatePolyfill.cs b/src/Split/net462/DelegatePolyfill.cs index effdb1267..59cc5e315 100644 --- a/src/Split/net462/DelegatePolyfill.cs +++ b/src/Split/net462/DelegatePolyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.ComponentModel; +using System.Runtime.CompilerServices; static partial class Polyfill { /// @@ -39,6 +40,7 @@ public bool MoveNext() /// /// Gets an enumerator for the invocation targets of this delegate. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static InvocationListEnumerator EnumerateInvocationList(TDelegate? target) where TDelegate : Delegate => new(target); diff --git a/src/Split/net462/FilePolyfill.cs b/src/Split/net462/FilePolyfill.cs index c6112e74d..66cb81a14 100644 --- a/src/Split/net462/FilePolyfill.cs +++ b/src/Split/net462/FilePolyfill.cs @@ -48,11 +48,13 @@ public static Task AppendAllTextAsync(string path, ReadOnlyMemory contents /// /// Appends the specified string to the file, creating the file if it does not already exist. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void AppendAllText(string path, ReadOnlySpan contents) => File.AppendAllText(path, contents.ToString()); /// /// Appends the specified string to the file, creating the file if it does not already exist. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void AppendAllText(string path, ReadOnlySpan contents, Encoding encoding) => File.AppendAllText(path, contents.ToString(), encoding); /// @@ -76,12 +78,14 @@ public static async Task WriteAllBytesAsync(string path, ReadOnlyMemory by /// Creates a new file, writes the specified string to the file, and then closes the file. /// If the target file already exists, it is truncated and overwritten. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void WriteAllText(string path, ReadOnlySpan contents) => File.WriteAllText(path, contents.ToString()); /// /// Creates a new file, writes the specified string to the file using the specified encoding, and then closes the file. /// If the target file already exists, it is truncated and overwritten. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void WriteAllText(string path, ReadOnlySpan contents, Encoding encoding) => File.WriteAllText(path, contents.ToString(), encoding); /// diff --git a/src/Split/net462/GuidPolyfill.cs b/src/Split/net462/GuidPolyfill.cs index 2bd536736..bc6b9129b 100644 --- a/src/Split/net462/GuidPolyfill.cs +++ b/src/Split/net462/GuidPolyfill.cs @@ -4,6 +4,7 @@ namespace Polyfills; using System.Text; using System; using System.Security.Cryptography; +using System.Runtime.CompilerServices; static partial class Polyfill { extension(Guid) @@ -11,9 +12,11 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out Guid result) => Guid.TryParse(s, out result); /// Creates a new according to RFC 9562, following the Version 7 format. + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Guid CreateVersion7() => CreateVersion7(DateTimeOffset.UtcNow); /// Creates a new according to RFC 9562, following the Version 7 format. public static Guid CreateVersion7(DateTimeOffset timestamp) @@ -40,26 +43,31 @@ public static Guid CreateVersion7(DateTimeOffset timestamp) /// /// Converts span of characters representing the GUID to the equivalent Guid structure, provided that the string is in the specified format. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParseExact(ReadOnlySpan input, ReadOnlySpan format, out Guid result) => Guid.TryParseExact(input.ToString(), format.ToString(), out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out Guid result) => Guid.TryParse(s.ToString(), out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan input, out Guid result) => Guid.TryParse(input.ToString(), out result); /// /// Tries to parse a span of UTF-8 bytes into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out Guid result) => Guid.TryParse(Encoding.UTF8.GetString(utf8Text), out result); /// /// Parse a span of UTF-8 bytes into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Guid Parse(ReadOnlySpan utf8Text) => Guid.Parse(Encoding.UTF8.GetString(utf8Text)); #endif diff --git a/src/Split/net462/KeyValuePair.cs b/src/Split/net462/KeyValuePair.cs index 7e5d58959..e94cbbf2f 100644 --- a/src/Split/net462/KeyValuePair.cs +++ b/src/Split/net462/KeyValuePair.cs @@ -4,6 +4,7 @@ namespace System.Collections.Generic; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; +using System.Runtime.CompilerServices; [ExcludeFromCodeCoverage] [DebuggerNonUserCode] #if PolyUseEmbeddedAttribute @@ -17,6 +18,7 @@ static class KeyValuePair /// /// Creates a new key/value pair instance using provided values. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static KeyValuePair Create(TKey key, TValue value) => new(key, value); } diff --git a/src/Split/net462/Lock.cs b/src/Split/net462/Lock.cs index 94fcf1ff9..36946028c 100644 --- a/src/Split/net462/Lock.cs +++ b/src/Split/net462/Lock.cs @@ -5,6 +5,7 @@ namespace System.Threading; using Diagnostics; using Diagnostics.CodeAnalysis; +using Runtime.CompilerServices; /// /// Provides a way to get mutual exclusion in regions of code between different threads. A lock may be held by one thread at /// a time. @@ -23,26 +24,31 @@ class Lock /// /// Enters the lock. Once the method returns, the calling thread would be the only thread that holds the lock. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Enter() => Monitor.Enter(this); /// /// Tries to enter the lock without waiting. If the lock is entered, the calling thread would be the only thread that /// holds the lock. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool TryEnter() => Monitor.TryEnter(this); /// /// Tries to enter the lock, waiting for roughly the specified duration. If the lock is entered, the calling thread /// would be the only thread that holds the lock. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool TryEnter(TimeSpan timeout) => Monitor.TryEnter(this, timeout); /// /// Tries to enter the lock, waiting for roughly the specified duration. If the lock is entered, the calling thread /// would be the only thread that holds the lock. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool TryEnter(int millisecondsTimeout) => TryEnter(TimeSpan.FromMilliseconds(millisecondsTimeout)); /// /// Exits the lock. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Exit() => Monitor.Exit(this); /// /// Enters the lock and returns a that may be disposed to exit the lock. Once the method returns, diff --git a/src/Split/net462/Numbers/BytePolyfill.cs b/src/Split/net462/Numbers/BytePolyfill.cs index ef3f744ed..0ea017afd 100644 --- a/src/Split/net462/Numbers/BytePolyfill.cs +++ b/src/Split/net462/Numbers/BytePolyfill.cs @@ -4,6 +4,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -12,37 +13,44 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out byte result) => byte.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out byte result) => byte.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out byte result) => byte.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out byte result) => byte.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its byte equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out byte result) => byte.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its byte equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out byte result) => byte.TryParse(s.ToString(), out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its byte equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out byte result) => byte.TryParse(s.ToString(), style, provider, out result); #endif diff --git a/src/Split/net462/Numbers/DoublePolyfill.cs b/src/Split/net462/Numbers/DoublePolyfill.cs index ba5333f69..d903ddfe1 100644 --- a/src/Split/net462/Numbers/DoublePolyfill.cs +++ b/src/Split/net462/Numbers/DoublePolyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,37 +12,44 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out double result) => double.TryParse(s, NumberStyles.Float, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out double result) => double.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Float, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out double result) => double.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its double-precision floating-point number equivalent.. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out double result) => double.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Float, null, out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its double-precision floating-point number equivalent. A return value indicates whether the conversion succeeded or failed. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out double result) => double.TryParse(s.ToString(), out result); /// /// Converts the string representation of a number in a specified style and culture-specific format to its double-precision floating-point number equivalent. A return value indicates whether the conversion succeeded or failed. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out double result) => double.TryParse(s.ToString(), style, provider, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out double result) => double.TryParse(s.ToString(), NumberStyles.Float, provider, out result); #endif diff --git a/src/Split/net462/Numbers/Int16Polyfill.cs b/src/Split/net462/Numbers/Int16Polyfill.cs index 5eb1b384e..960cf68ce 100644 --- a/src/Split/net462/Numbers/Int16Polyfill.cs +++ b/src/Split/net462/Numbers/Int16Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,37 +12,44 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out short result) => short.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out short result) => short.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out short result) => short.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its short equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out short result) => short.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its short equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out short result) => short.TryParse(s.ToString(), out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its short equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out short result) => short.TryParse(s.ToString(), style, provider, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out short result) => short.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/net462/Numbers/Int32Polyfill.cs b/src/Split/net462/Numbers/Int32Polyfill.cs index 549ff1896..2920eae4a 100644 --- a/src/Split/net462/Numbers/Int32Polyfill.cs +++ b/src/Split/net462/Numbers/Int32Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,37 +12,44 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out int result) => int.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out int result) => int.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out int result) => int.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its 32-bit signed integer equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out int result) => int.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its 32-bit signed integer equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out int result) => int.TryParse(s.ToString(), out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its 32-bit signed integer equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out int result) => int.TryParse(s.ToString(), style, provider, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out int result) => int.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/net462/Numbers/Int64Polyfill.cs b/src/Split/net462/Numbers/Int64Polyfill.cs index bd33ce0e6..0b7b1b100 100644 --- a/src/Split/net462/Numbers/Int64Polyfill.cs +++ b/src/Split/net462/Numbers/Int64Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,37 +12,44 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out long result) => long.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out long result) => long.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out long result) => long.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its 64-bit signed integer equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out long result) => long.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its 32-bit signed integer equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out long result) => long.TryParse(s.ToString(), out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its 64-bit signed integer equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out long result) => long.TryParse(s.ToString(), style, provider, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out long result) => long.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/net462/Numbers/SBytePolyfill.cs b/src/Split/net462/Numbers/SBytePolyfill.cs index 974115654..890452b1c 100644 --- a/src/Split/net462/Numbers/SBytePolyfill.cs +++ b/src/Split/net462/Numbers/SBytePolyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,37 +12,44 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out sbyte result) => sbyte.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out sbyte result) => sbyte.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out sbyte result) => sbyte.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its sbyte equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out sbyte result) => sbyte.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its sbyte equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out sbyte result) => sbyte.TryParse(s.ToString(), out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its sbyte equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out sbyte result) => sbyte.TryParse(s.ToString(), style, provider, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out sbyte result) => sbyte.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/net462/Numbers/UInt16Polyfill.cs b/src/Split/net462/Numbers/UInt16Polyfill.cs index 34f39f97c..ed0958805 100644 --- a/src/Split/net462/Numbers/UInt16Polyfill.cs +++ b/src/Split/net462/Numbers/UInt16Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,37 +12,44 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out ushort result) => ushort.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out ushort result) => ushort.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out ushort result) => ushort.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its ushort equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out ushort result) => ushort.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its ushort equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out ushort result) => ushort.TryParse(s.ToString(), out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its ushort equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out ushort result) => ushort.TryParse(s.ToString(), style, provider, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out ushort result) => ushort.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/net462/Numbers/UInt32Polyfill.cs b/src/Split/net462/Numbers/UInt32Polyfill.cs index 859149bed..e11b65c90 100644 --- a/src/Split/net462/Numbers/UInt32Polyfill.cs +++ b/src/Split/net462/Numbers/UInt32Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,37 +12,44 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out uint result) => uint.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out uint result) => uint.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out uint result) => uint.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its uint equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out uint result) => uint.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its uint equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out uint result) => uint.TryParse(s.ToString(), out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its uint equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out uint result) => uint.TryParse(s.ToString(), style, provider, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out uint result) => uint.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/net462/Numbers/UInt64Polyfill.cs b/src/Split/net462/Numbers/UInt64Polyfill.cs index c14bb347c..10122d2b4 100644 --- a/src/Split/net462/Numbers/UInt64Polyfill.cs +++ b/src/Split/net462/Numbers/UInt64Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,37 +12,44 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out ulong result) => ulong.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out ulong result) => ulong.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpanutf8Text, NumberStyles style, IFormatProvider? provider, out ulong result) => ulong.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its ulong equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out ulong result) => ulong.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its ulong equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out ulong result) => ulong.TryParse(s.ToString(), out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its ulong equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out ulong result) => ulong.TryParse(s.ToString(), style, provider, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out ulong result) => ulong.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/net462/OperatingSystemPolyfill.cs b/src/Split/net462/OperatingSystemPolyfill.cs index 5d1f8de36..68413c7d5 100644 --- a/src/Split/net462/OperatingSystemPolyfill.cs +++ b/src/Split/net462/OperatingSystemPolyfill.cs @@ -3,6 +3,7 @@ #if FeatureRuntimeInformation namespace Polyfills; using System; +using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; static partial class Polyfill @@ -14,114 +15,135 @@ static bool IsOsVersionAtLeast(int major, int minor = 0, int build = 0, int revi /// /// Indicates whether the current application is running as WASI. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsWasi() => RuntimeInformation.IsOSPlatform(OSPlatform.Create("WASI")); /// /// Indicates whether the current application is running on Mac Catalyst. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsMacCatalyst() => OperatingSystem.IsMacOS() || OperatingSystem.IsIOS(); /// /// Check for the Mac Catalyst version (iOS version as presented in Apple documentation) with a ≤ version comparison. Used to guard APIs that were added in the given Mac Catalyst release. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsMacCatalystVersionAtLeast(int major, int minor = 0, int build = 0) => IsMacCatalyst() && IsOsVersionAtLeast(major, minor, build); /// /// Checks if the macOS version (returned by libobjc.get_operatingSystemVersion) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified macOS version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsMacOSVersionAtLeast(int major, int minor = 0, int build = 0) => OperatingSystemCache.IsMacOSVersionAtLeast(major, minor, build); /// /// Checks if the FreeBSD version (returned by the Linux command uname) is greater than or equal to the specified version. /// This method can be used to guard APIs that were added in the specified version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsFreeBSDVersionAtLeast(int major, int minor, int build = 0, int revision = 0) => OperatingSystemCache.IsFreeBSDVersionAtLeast(major, minor, build, revision); /// /// Indicates whether the current application is running on Android. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsAndroid() => OperatingSystemCache.IsAndroid(); /// /// Checks if the Android version (returned by the Linux command uname) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsAndroidVersionAtLeast(int major, int minor = 0, int build = 0, int revision = 0) => OperatingSystemCache.IsAndroidVersionAtLeast(major, minor, build, revision); /// /// Checks if the Windows version (returned by RtlGetVersion) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified Windows version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsWindowsVersionAtLeast(int major, int minor = 0, int build = 0, int revision = 0) => OperatingSystemCache.IsWindowsVersionAtLeast(major, minor, build, revision); /// /// Indicates whether the current application is running on the specified platform. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsOSPlatform(string platform) => RuntimeInformation.IsOSPlatform(OSPlatform.Create(platform)); /// /// Checks if the operating system version is greater than or equal to the specified platform version. This method can be used to guard APIs that were added in the specified OS version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsOSPlatformVersionAtLeast(string platform, int major, int minor = 0, int build = 0, int revision = 0) => IsOSPlatform(platform) && IsOsVersionAtLeast(major, minor, build, revision); /// /// Indicates whether the current application is running on Windows. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsWindows() => RuntimeInformation.IsOSPlatform(OSPlatform.Windows); /// /// Indicates whether the current application is running on macOS. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsMacOS() => RuntimeInformation.IsOSPlatform(OSPlatform.OSX); /// /// Indicates whether the current application is running on iOS or MacCatalyst. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsIOS() => RuntimeInformation.IsOSPlatform(OSPlatform.Create("IOS")); /// /// Indicates whether the current application is running on Linux. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsLinux() => RuntimeInformation.IsOSPlatform(OSPlatform.Linux); /// /// Indicates whether the current application is running on FreeBSD. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsFreeBSD() => RuntimeInformation.OSDescription.ToLower().Contains("freebsd"); /// /// Checks if the iOS/MacCatalyst version (returned by libobjc.get_operatingSystemVersion) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified iOS version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsIOSVersionAtLeast(int major, int minor = 0, int build = 0) => IsIOS() && IsOsVersionAtLeast(major, minor, build); /// /// Checks if the tvOS version (returned by libobjc.get_operatingSystemVersion) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified tvOS version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsTvOSVersionAtLeast(int major, int minor = 0, int build = 0) => IsTvOS() && IsOsVersionAtLeast(major, minor, build); /// /// Indicates whether the current application is running on tvOS. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsTvOS() => RuntimeInformation.IsOSPlatform(OSPlatform.Create("TVOS")); /// /// Indicates whether the current application is running on watchOS. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsWatchOS() => IsIOS() || RuntimeInformation.OSDescription.ToLower().Contains("watchos"); /// /// Checks if the watchOS version (returned by libobjc.get_operatingSystemVersion) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified watchOS version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsWatchOSVersionAtLeast(int major, int minor = 0, int build = 0) => IsWatchOS() && IsOsVersionAtLeast(major, minor, build); /// /// Indicates whether the current application is running as WASM in a browser. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsBrowser() => RuntimeInformation.IsOSPlatform(OSPlatform.Create("BROWSER")); } diff --git a/src/Split/net462/PathPolyfill.cs b/src/Split/net462/PathPolyfill.cs index fb4329ac6..fc8009da8 100644 --- a/src/Split/net462/PathPolyfill.cs +++ b/src/Split/net462/PathPolyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.IO; +using System.Runtime.CompilerServices; static partial class Polyfill { extension(Path) @@ -11,41 +12,49 @@ static partial class Polyfill /// /// Returns the directory information for the specified path represented by a character span. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ReadOnlySpan GetDirectoryName(ReadOnlySpan path) => Path.GetDirectoryName(path.ToString()).AsSpan(); /// /// Returns the file name and extension of a file path that is represented by a read-only character span. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ReadOnlySpan GetFileName(ReadOnlySpan path) => Path.GetFileName(path.ToString()).AsSpan(); /// /// Returns the file name without the extension of a file path that is represented by a read-only character span. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ReadOnlySpan GetFileNameWithoutExtension(ReadOnlySpan path) => Path.GetFileNameWithoutExtension(path.ToString()).AsSpan(); /// /// Determines whether the path represented by the specified character span includes a file name extension. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool HasExtension(ReadOnlySpan path) => Path.HasExtension(path.ToString()); /// /// Returns the extension of the given path. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ReadOnlySpan GetExtension(ReadOnlySpan path) => Path.GetExtension(path.ToString()).AsSpan(); /// /// Combines a span of strings into a path. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string Combine(scoped ReadOnlySpan paths) => Path.Combine(paths.ToArray()); /// /// Returns a value that indicates whether the path, specified as a read-only span, ends in a directory separator. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool EndsInDirectorySeparator (ReadOnlySpan path) => EndsInDirectorySeparator(path.ToString()); /// /// Trims one trailing directory separator beyond the root of the specified path. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ReadOnlySpan TrimEndingDirectorySeparator(ReadOnlySpan path) => TrimEndingDirectorySeparator(path.ToString()).AsSpan(); #endif diff --git a/src/Split/net47/ConsolePolyfill.cs b/src/Split/net47/ConsolePolyfill.cs index 425364db8..5ad0342de 100644 --- a/src/Split/net47/ConsolePolyfill.cs +++ b/src/Split/net47/ConsolePolyfill.cs @@ -4,6 +4,7 @@ namespace Polyfills; using System; using System.Runtime.InteropServices; +using System.Runtime.CompilerServices; using Microsoft.Win32.SafeHandles; static partial class Polyfill { @@ -12,16 +13,19 @@ static partial class Polyfill /// /// Gets a that wraps the operating system handle for standard input. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static SafeFileHandle OpenStandardInputHandle() => StandardHandleHelper.GetStandardHandle(StandardHandleHelper.StdInput); /// /// Gets a that wraps the operating system handle for standard output. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static SafeFileHandle OpenStandardOutputHandle() => StandardHandleHelper.GetStandardHandle(StandardHandleHelper.StdOutput); /// /// Gets a that wraps the operating system handle for standard error. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static SafeFileHandle OpenStandardErrorHandle() => StandardHandleHelper.GetStandardHandle(StandardHandleHelper.StdError); } diff --git a/src/Split/net47/ConvertPolyfill.cs b/src/Split/net47/ConvertPolyfill.cs index 8ca6da94f..5f80df1f7 100644 --- a/src/Split/net47/ConvertPolyfill.cs +++ b/src/Split/net47/ConvertPolyfill.cs @@ -2,6 +2,7 @@ #pragma warning disable namespace Polyfills; using System; +using System.Runtime.CompilerServices; static partial class Polyfill { extension(Convert) @@ -10,22 +11,26 @@ static partial class Polyfill /// Converts a subset of an array of 8-bit unsigned integers to its equivalent string representation that is encoded with uppercase hex characters. /// Parameters specify the subset as an offset in the input array and the number of elements in the array to convert. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexString(byte[] inArray, int offset, int length) => ToHexString(inArray, offset, length, "X2"); /// /// Converts a subset of an array of 8-bit unsigned integers to its equivalent string representation that is encoded with lowercase hex characters. /// Parameters specify the subset as an offset in the input array and the number of elements in the array to convert. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexStringLower(byte[] inArray, int offset, int length) => ToHexString(inArray, offset, length, "x2"); /// /// Converts an array of 8-bit unsigned integers to its equivalent string representation that is encoded with lowercase hex characters. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexStringLower(byte[] inArray) => Polyfill.ToHexStringLower(inArray, 0, inArray.Length); /// /// Converts an array of 8-bit unsigned integers to its equivalent string representation that is encoded with uppercase hex characters. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexString(byte[] inArray) => Polyfill.ToHexString(inArray, 0, inArray.Length); /// @@ -54,16 +59,19 @@ static int GetHexValue(char hex) => /// /// Converts the span, which encodes binary data as hex characters, to an equivalent 8-bit unsigned integer array. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static byte[] FromHexString(ReadOnlySpan chars) => Polyfill.FromHexString(chars.ToString()); /// /// Converts a span of 8-bit unsigned integers to its equivalent string representation that is encoded with uppercase hex characters. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexString(ReadOnlySpan bytes) => Polyfill.ToHexString(bytes.ToArray()); /// /// Converts a span of 8-bit unsigned integers to its equivalent string representation that is encoded with lowercase hex characters. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexStringLower(ReadOnlySpan bytes) => Polyfill.ToHexStringLower(bytes.ToArray()); /// diff --git a/src/Split/net47/DateTimeOffsetPolyfill.cs b/src/Split/net47/DateTimeOffsetPolyfill.cs index 6837790e5..7bb9a5ad7 100644 --- a/src/Split/net47/DateTimeOffsetPolyfill.cs +++ b/src/Split/net47/DateTimeOffsetPolyfill.cs @@ -4,6 +4,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; static partial class Polyfill { extension(DateTimeOffset target) @@ -30,32 +31,38 @@ long TicksComponent() /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out DateTimeOffset result) => DateTimeOffset.TryParse(s, provider, DateTimeStyles.None, out result); #if FeatureMemory /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out DateTimeOffset result) => DateTimeOffset.TryParse(s.ToString(), provider, DateTimeStyles.None, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan input, out DateTimeOffset result) => DateTimeOffset.TryParse(input.ToString(), null, DateTimeStyles.None, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, DateTimeStyles styles, out DateTimeOffset result) => DateTimeOffset.TryParse(s.ToString(), provider, styles, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParseExact(ReadOnlySpan input, string format, IFormatProvider? provider, DateTimeStyles styles, out DateTimeOffset result) => DateTimeOffset.TryParseExact(input.ToString(), format, provider, styles, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParseExact(ReadOnlySpan input, ReadOnlySpan format, IFormatProvider? provider, DateTimeStyles styles, out DateTimeOffset result) => DateTimeOffset.TryParseExact(input.ToString(), format.ToString(), provider, styles, out result); #endif diff --git a/src/Split/net47/DateTimePolyfill.cs b/src/Split/net47/DateTimePolyfill.cs index 4641f3e59..4d329796a 100644 --- a/src/Split/net47/DateTimePolyfill.cs +++ b/src/Split/net47/DateTimePolyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; static partial class Polyfill { extension(DateTime target) @@ -29,32 +30,38 @@ long TicksComponent() /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out DateTime result) => DateTime.TryParse(s, provider, DateTimeStyles.None, out result); #if FeatureMemory /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out DateTime result) => DateTime.TryParse(s.ToString(), provider, DateTimeStyles.None, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out DateTime result) => DateTime.TryParse(s.ToString(), null, DateTimeStyles.None, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, DateTimeStyles styles, out DateTime result) => DateTime.TryParse(s.ToString(), provider, styles, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParseExact(ReadOnlySpan s, string format, IFormatProvider? provider, DateTimeStyles style, out DateTime result) => DateTime.TryParseExact(s.ToString(), format, provider, style, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParseExact(ReadOnlySpan s, ReadOnlySpan format, IFormatProvider? provider, DateTimeStyles styles, out DateTime result) => DateTime.TryParseExact(s.ToString(), format.ToString(), provider, styles, out result); #endif diff --git a/src/Split/net47/DelegatePolyfill.cs b/src/Split/net47/DelegatePolyfill.cs index effdb1267..59cc5e315 100644 --- a/src/Split/net47/DelegatePolyfill.cs +++ b/src/Split/net47/DelegatePolyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.ComponentModel; +using System.Runtime.CompilerServices; static partial class Polyfill { /// @@ -39,6 +40,7 @@ public bool MoveNext() /// /// Gets an enumerator for the invocation targets of this delegate. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static InvocationListEnumerator EnumerateInvocationList(TDelegate? target) where TDelegate : Delegate => new(target); diff --git a/src/Split/net47/FilePolyfill.cs b/src/Split/net47/FilePolyfill.cs index c6112e74d..66cb81a14 100644 --- a/src/Split/net47/FilePolyfill.cs +++ b/src/Split/net47/FilePolyfill.cs @@ -48,11 +48,13 @@ public static Task AppendAllTextAsync(string path, ReadOnlyMemory contents /// /// Appends the specified string to the file, creating the file if it does not already exist. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void AppendAllText(string path, ReadOnlySpan contents) => File.AppendAllText(path, contents.ToString()); /// /// Appends the specified string to the file, creating the file if it does not already exist. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void AppendAllText(string path, ReadOnlySpan contents, Encoding encoding) => File.AppendAllText(path, contents.ToString(), encoding); /// @@ -76,12 +78,14 @@ public static async Task WriteAllBytesAsync(string path, ReadOnlyMemory by /// Creates a new file, writes the specified string to the file, and then closes the file. /// If the target file already exists, it is truncated and overwritten. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void WriteAllText(string path, ReadOnlySpan contents) => File.WriteAllText(path, contents.ToString()); /// /// Creates a new file, writes the specified string to the file using the specified encoding, and then closes the file. /// If the target file already exists, it is truncated and overwritten. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void WriteAllText(string path, ReadOnlySpan contents, Encoding encoding) => File.WriteAllText(path, contents.ToString(), encoding); /// diff --git a/src/Split/net47/GuidPolyfill.cs b/src/Split/net47/GuidPolyfill.cs index 2bd536736..bc6b9129b 100644 --- a/src/Split/net47/GuidPolyfill.cs +++ b/src/Split/net47/GuidPolyfill.cs @@ -4,6 +4,7 @@ namespace Polyfills; using System.Text; using System; using System.Security.Cryptography; +using System.Runtime.CompilerServices; static partial class Polyfill { extension(Guid) @@ -11,9 +12,11 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out Guid result) => Guid.TryParse(s, out result); /// Creates a new according to RFC 9562, following the Version 7 format. + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Guid CreateVersion7() => CreateVersion7(DateTimeOffset.UtcNow); /// Creates a new according to RFC 9562, following the Version 7 format. public static Guid CreateVersion7(DateTimeOffset timestamp) @@ -40,26 +43,31 @@ public static Guid CreateVersion7(DateTimeOffset timestamp) /// /// Converts span of characters representing the GUID to the equivalent Guid structure, provided that the string is in the specified format. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParseExact(ReadOnlySpan input, ReadOnlySpan format, out Guid result) => Guid.TryParseExact(input.ToString(), format.ToString(), out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out Guid result) => Guid.TryParse(s.ToString(), out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan input, out Guid result) => Guid.TryParse(input.ToString(), out result); /// /// Tries to parse a span of UTF-8 bytes into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out Guid result) => Guid.TryParse(Encoding.UTF8.GetString(utf8Text), out result); /// /// Parse a span of UTF-8 bytes into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Guid Parse(ReadOnlySpan utf8Text) => Guid.Parse(Encoding.UTF8.GetString(utf8Text)); #endif diff --git a/src/Split/net47/KeyValuePair.cs b/src/Split/net47/KeyValuePair.cs index 7e5d58959..e94cbbf2f 100644 --- a/src/Split/net47/KeyValuePair.cs +++ b/src/Split/net47/KeyValuePair.cs @@ -4,6 +4,7 @@ namespace System.Collections.Generic; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; +using System.Runtime.CompilerServices; [ExcludeFromCodeCoverage] [DebuggerNonUserCode] #if PolyUseEmbeddedAttribute @@ -17,6 +18,7 @@ static class KeyValuePair /// /// Creates a new key/value pair instance using provided values. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static KeyValuePair Create(TKey key, TValue value) => new(key, value); } diff --git a/src/Split/net47/Lock.cs b/src/Split/net47/Lock.cs index 94fcf1ff9..36946028c 100644 --- a/src/Split/net47/Lock.cs +++ b/src/Split/net47/Lock.cs @@ -5,6 +5,7 @@ namespace System.Threading; using Diagnostics; using Diagnostics.CodeAnalysis; +using Runtime.CompilerServices; /// /// Provides a way to get mutual exclusion in regions of code between different threads. A lock may be held by one thread at /// a time. @@ -23,26 +24,31 @@ class Lock /// /// Enters the lock. Once the method returns, the calling thread would be the only thread that holds the lock. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Enter() => Monitor.Enter(this); /// /// Tries to enter the lock without waiting. If the lock is entered, the calling thread would be the only thread that /// holds the lock. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool TryEnter() => Monitor.TryEnter(this); /// /// Tries to enter the lock, waiting for roughly the specified duration. If the lock is entered, the calling thread /// would be the only thread that holds the lock. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool TryEnter(TimeSpan timeout) => Monitor.TryEnter(this, timeout); /// /// Tries to enter the lock, waiting for roughly the specified duration. If the lock is entered, the calling thread /// would be the only thread that holds the lock. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool TryEnter(int millisecondsTimeout) => TryEnter(TimeSpan.FromMilliseconds(millisecondsTimeout)); /// /// Exits the lock. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Exit() => Monitor.Exit(this); /// /// Enters the lock and returns a that may be disposed to exit the lock. Once the method returns, diff --git a/src/Split/net47/Numbers/BytePolyfill.cs b/src/Split/net47/Numbers/BytePolyfill.cs index ef3f744ed..0ea017afd 100644 --- a/src/Split/net47/Numbers/BytePolyfill.cs +++ b/src/Split/net47/Numbers/BytePolyfill.cs @@ -4,6 +4,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -12,37 +13,44 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out byte result) => byte.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out byte result) => byte.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out byte result) => byte.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out byte result) => byte.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its byte equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out byte result) => byte.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its byte equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out byte result) => byte.TryParse(s.ToString(), out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its byte equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out byte result) => byte.TryParse(s.ToString(), style, provider, out result); #endif diff --git a/src/Split/net47/Numbers/DoublePolyfill.cs b/src/Split/net47/Numbers/DoublePolyfill.cs index ba5333f69..d903ddfe1 100644 --- a/src/Split/net47/Numbers/DoublePolyfill.cs +++ b/src/Split/net47/Numbers/DoublePolyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,37 +12,44 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out double result) => double.TryParse(s, NumberStyles.Float, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out double result) => double.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Float, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out double result) => double.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its double-precision floating-point number equivalent.. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out double result) => double.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Float, null, out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its double-precision floating-point number equivalent. A return value indicates whether the conversion succeeded or failed. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out double result) => double.TryParse(s.ToString(), out result); /// /// Converts the string representation of a number in a specified style and culture-specific format to its double-precision floating-point number equivalent. A return value indicates whether the conversion succeeded or failed. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out double result) => double.TryParse(s.ToString(), style, provider, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out double result) => double.TryParse(s.ToString(), NumberStyles.Float, provider, out result); #endif diff --git a/src/Split/net47/Numbers/Int16Polyfill.cs b/src/Split/net47/Numbers/Int16Polyfill.cs index 5eb1b384e..960cf68ce 100644 --- a/src/Split/net47/Numbers/Int16Polyfill.cs +++ b/src/Split/net47/Numbers/Int16Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,37 +12,44 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out short result) => short.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out short result) => short.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out short result) => short.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its short equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out short result) => short.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its short equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out short result) => short.TryParse(s.ToString(), out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its short equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out short result) => short.TryParse(s.ToString(), style, provider, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out short result) => short.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/net47/Numbers/Int32Polyfill.cs b/src/Split/net47/Numbers/Int32Polyfill.cs index 549ff1896..2920eae4a 100644 --- a/src/Split/net47/Numbers/Int32Polyfill.cs +++ b/src/Split/net47/Numbers/Int32Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,37 +12,44 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out int result) => int.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out int result) => int.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out int result) => int.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its 32-bit signed integer equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out int result) => int.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its 32-bit signed integer equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out int result) => int.TryParse(s.ToString(), out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its 32-bit signed integer equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out int result) => int.TryParse(s.ToString(), style, provider, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out int result) => int.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/net47/Numbers/Int64Polyfill.cs b/src/Split/net47/Numbers/Int64Polyfill.cs index bd33ce0e6..0b7b1b100 100644 --- a/src/Split/net47/Numbers/Int64Polyfill.cs +++ b/src/Split/net47/Numbers/Int64Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,37 +12,44 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out long result) => long.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out long result) => long.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out long result) => long.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its 64-bit signed integer equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out long result) => long.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its 32-bit signed integer equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out long result) => long.TryParse(s.ToString(), out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its 64-bit signed integer equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out long result) => long.TryParse(s.ToString(), style, provider, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out long result) => long.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/net47/Numbers/SBytePolyfill.cs b/src/Split/net47/Numbers/SBytePolyfill.cs index 974115654..890452b1c 100644 --- a/src/Split/net47/Numbers/SBytePolyfill.cs +++ b/src/Split/net47/Numbers/SBytePolyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,37 +12,44 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out sbyte result) => sbyte.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out sbyte result) => sbyte.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out sbyte result) => sbyte.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its sbyte equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out sbyte result) => sbyte.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its sbyte equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out sbyte result) => sbyte.TryParse(s.ToString(), out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its sbyte equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out sbyte result) => sbyte.TryParse(s.ToString(), style, provider, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out sbyte result) => sbyte.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/net47/Numbers/UInt16Polyfill.cs b/src/Split/net47/Numbers/UInt16Polyfill.cs index 34f39f97c..ed0958805 100644 --- a/src/Split/net47/Numbers/UInt16Polyfill.cs +++ b/src/Split/net47/Numbers/UInt16Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,37 +12,44 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out ushort result) => ushort.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out ushort result) => ushort.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out ushort result) => ushort.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its ushort equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out ushort result) => ushort.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its ushort equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out ushort result) => ushort.TryParse(s.ToString(), out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its ushort equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out ushort result) => ushort.TryParse(s.ToString(), style, provider, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out ushort result) => ushort.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/net47/Numbers/UInt32Polyfill.cs b/src/Split/net47/Numbers/UInt32Polyfill.cs index 859149bed..e11b65c90 100644 --- a/src/Split/net47/Numbers/UInt32Polyfill.cs +++ b/src/Split/net47/Numbers/UInt32Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,37 +12,44 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out uint result) => uint.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out uint result) => uint.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out uint result) => uint.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its uint equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out uint result) => uint.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its uint equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out uint result) => uint.TryParse(s.ToString(), out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its uint equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out uint result) => uint.TryParse(s.ToString(), style, provider, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out uint result) => uint.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/net47/Numbers/UInt64Polyfill.cs b/src/Split/net47/Numbers/UInt64Polyfill.cs index c14bb347c..10122d2b4 100644 --- a/src/Split/net47/Numbers/UInt64Polyfill.cs +++ b/src/Split/net47/Numbers/UInt64Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,37 +12,44 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out ulong result) => ulong.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out ulong result) => ulong.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpanutf8Text, NumberStyles style, IFormatProvider? provider, out ulong result) => ulong.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its ulong equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out ulong result) => ulong.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its ulong equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out ulong result) => ulong.TryParse(s.ToString(), out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its ulong equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out ulong result) => ulong.TryParse(s.ToString(), style, provider, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out ulong result) => ulong.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/net47/OperatingSystemPolyfill.cs b/src/Split/net47/OperatingSystemPolyfill.cs index 5d1f8de36..68413c7d5 100644 --- a/src/Split/net47/OperatingSystemPolyfill.cs +++ b/src/Split/net47/OperatingSystemPolyfill.cs @@ -3,6 +3,7 @@ #if FeatureRuntimeInformation namespace Polyfills; using System; +using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; static partial class Polyfill @@ -14,114 +15,135 @@ static bool IsOsVersionAtLeast(int major, int minor = 0, int build = 0, int revi /// /// Indicates whether the current application is running as WASI. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsWasi() => RuntimeInformation.IsOSPlatform(OSPlatform.Create("WASI")); /// /// Indicates whether the current application is running on Mac Catalyst. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsMacCatalyst() => OperatingSystem.IsMacOS() || OperatingSystem.IsIOS(); /// /// Check for the Mac Catalyst version (iOS version as presented in Apple documentation) with a ≤ version comparison. Used to guard APIs that were added in the given Mac Catalyst release. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsMacCatalystVersionAtLeast(int major, int minor = 0, int build = 0) => IsMacCatalyst() && IsOsVersionAtLeast(major, minor, build); /// /// Checks if the macOS version (returned by libobjc.get_operatingSystemVersion) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified macOS version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsMacOSVersionAtLeast(int major, int minor = 0, int build = 0) => OperatingSystemCache.IsMacOSVersionAtLeast(major, minor, build); /// /// Checks if the FreeBSD version (returned by the Linux command uname) is greater than or equal to the specified version. /// This method can be used to guard APIs that were added in the specified version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsFreeBSDVersionAtLeast(int major, int minor, int build = 0, int revision = 0) => OperatingSystemCache.IsFreeBSDVersionAtLeast(major, minor, build, revision); /// /// Indicates whether the current application is running on Android. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsAndroid() => OperatingSystemCache.IsAndroid(); /// /// Checks if the Android version (returned by the Linux command uname) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsAndroidVersionAtLeast(int major, int minor = 0, int build = 0, int revision = 0) => OperatingSystemCache.IsAndroidVersionAtLeast(major, minor, build, revision); /// /// Checks if the Windows version (returned by RtlGetVersion) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified Windows version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsWindowsVersionAtLeast(int major, int minor = 0, int build = 0, int revision = 0) => OperatingSystemCache.IsWindowsVersionAtLeast(major, minor, build, revision); /// /// Indicates whether the current application is running on the specified platform. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsOSPlatform(string platform) => RuntimeInformation.IsOSPlatform(OSPlatform.Create(platform)); /// /// Checks if the operating system version is greater than or equal to the specified platform version. This method can be used to guard APIs that were added in the specified OS version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsOSPlatformVersionAtLeast(string platform, int major, int minor = 0, int build = 0, int revision = 0) => IsOSPlatform(platform) && IsOsVersionAtLeast(major, minor, build, revision); /// /// Indicates whether the current application is running on Windows. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsWindows() => RuntimeInformation.IsOSPlatform(OSPlatform.Windows); /// /// Indicates whether the current application is running on macOS. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsMacOS() => RuntimeInformation.IsOSPlatform(OSPlatform.OSX); /// /// Indicates whether the current application is running on iOS or MacCatalyst. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsIOS() => RuntimeInformation.IsOSPlatform(OSPlatform.Create("IOS")); /// /// Indicates whether the current application is running on Linux. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsLinux() => RuntimeInformation.IsOSPlatform(OSPlatform.Linux); /// /// Indicates whether the current application is running on FreeBSD. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsFreeBSD() => RuntimeInformation.OSDescription.ToLower().Contains("freebsd"); /// /// Checks if the iOS/MacCatalyst version (returned by libobjc.get_operatingSystemVersion) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified iOS version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsIOSVersionAtLeast(int major, int minor = 0, int build = 0) => IsIOS() && IsOsVersionAtLeast(major, minor, build); /// /// Checks if the tvOS version (returned by libobjc.get_operatingSystemVersion) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified tvOS version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsTvOSVersionAtLeast(int major, int minor = 0, int build = 0) => IsTvOS() && IsOsVersionAtLeast(major, minor, build); /// /// Indicates whether the current application is running on tvOS. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsTvOS() => RuntimeInformation.IsOSPlatform(OSPlatform.Create("TVOS")); /// /// Indicates whether the current application is running on watchOS. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsWatchOS() => IsIOS() || RuntimeInformation.OSDescription.ToLower().Contains("watchos"); /// /// Checks if the watchOS version (returned by libobjc.get_operatingSystemVersion) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified watchOS version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsWatchOSVersionAtLeast(int major, int minor = 0, int build = 0) => IsWatchOS() && IsOsVersionAtLeast(major, minor, build); /// /// Indicates whether the current application is running as WASM in a browser. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsBrowser() => RuntimeInformation.IsOSPlatform(OSPlatform.Create("BROWSER")); } diff --git a/src/Split/net47/PathPolyfill.cs b/src/Split/net47/PathPolyfill.cs index fb4329ac6..fc8009da8 100644 --- a/src/Split/net47/PathPolyfill.cs +++ b/src/Split/net47/PathPolyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.IO; +using System.Runtime.CompilerServices; static partial class Polyfill { extension(Path) @@ -11,41 +12,49 @@ static partial class Polyfill /// /// Returns the directory information for the specified path represented by a character span. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ReadOnlySpan GetDirectoryName(ReadOnlySpan path) => Path.GetDirectoryName(path.ToString()).AsSpan(); /// /// Returns the file name and extension of a file path that is represented by a read-only character span. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ReadOnlySpan GetFileName(ReadOnlySpan path) => Path.GetFileName(path.ToString()).AsSpan(); /// /// Returns the file name without the extension of a file path that is represented by a read-only character span. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ReadOnlySpan GetFileNameWithoutExtension(ReadOnlySpan path) => Path.GetFileNameWithoutExtension(path.ToString()).AsSpan(); /// /// Determines whether the path represented by the specified character span includes a file name extension. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool HasExtension(ReadOnlySpan path) => Path.HasExtension(path.ToString()); /// /// Returns the extension of the given path. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ReadOnlySpan GetExtension(ReadOnlySpan path) => Path.GetExtension(path.ToString()).AsSpan(); /// /// Combines a span of strings into a path. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string Combine(scoped ReadOnlySpan paths) => Path.Combine(paths.ToArray()); /// /// Returns a value that indicates whether the path, specified as a read-only span, ends in a directory separator. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool EndsInDirectorySeparator (ReadOnlySpan path) => EndsInDirectorySeparator(path.ToString()); /// /// Trims one trailing directory separator beyond the root of the specified path. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ReadOnlySpan TrimEndingDirectorySeparator(ReadOnlySpan path) => TrimEndingDirectorySeparator(path.ToString()).AsSpan(); #endif diff --git a/src/Split/net471/ConsolePolyfill.cs b/src/Split/net471/ConsolePolyfill.cs index 425364db8..5ad0342de 100644 --- a/src/Split/net471/ConsolePolyfill.cs +++ b/src/Split/net471/ConsolePolyfill.cs @@ -4,6 +4,7 @@ namespace Polyfills; using System; using System.Runtime.InteropServices; +using System.Runtime.CompilerServices; using Microsoft.Win32.SafeHandles; static partial class Polyfill { @@ -12,16 +13,19 @@ static partial class Polyfill /// /// Gets a that wraps the operating system handle for standard input. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static SafeFileHandle OpenStandardInputHandle() => StandardHandleHelper.GetStandardHandle(StandardHandleHelper.StdInput); /// /// Gets a that wraps the operating system handle for standard output. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static SafeFileHandle OpenStandardOutputHandle() => StandardHandleHelper.GetStandardHandle(StandardHandleHelper.StdOutput); /// /// Gets a that wraps the operating system handle for standard error. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static SafeFileHandle OpenStandardErrorHandle() => StandardHandleHelper.GetStandardHandle(StandardHandleHelper.StdError); } diff --git a/src/Split/net471/ConvertPolyfill.cs b/src/Split/net471/ConvertPolyfill.cs index 8ca6da94f..5f80df1f7 100644 --- a/src/Split/net471/ConvertPolyfill.cs +++ b/src/Split/net471/ConvertPolyfill.cs @@ -2,6 +2,7 @@ #pragma warning disable namespace Polyfills; using System; +using System.Runtime.CompilerServices; static partial class Polyfill { extension(Convert) @@ -10,22 +11,26 @@ static partial class Polyfill /// Converts a subset of an array of 8-bit unsigned integers to its equivalent string representation that is encoded with uppercase hex characters. /// Parameters specify the subset as an offset in the input array and the number of elements in the array to convert. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexString(byte[] inArray, int offset, int length) => ToHexString(inArray, offset, length, "X2"); /// /// Converts a subset of an array of 8-bit unsigned integers to its equivalent string representation that is encoded with lowercase hex characters. /// Parameters specify the subset as an offset in the input array and the number of elements in the array to convert. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexStringLower(byte[] inArray, int offset, int length) => ToHexString(inArray, offset, length, "x2"); /// /// Converts an array of 8-bit unsigned integers to its equivalent string representation that is encoded with lowercase hex characters. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexStringLower(byte[] inArray) => Polyfill.ToHexStringLower(inArray, 0, inArray.Length); /// /// Converts an array of 8-bit unsigned integers to its equivalent string representation that is encoded with uppercase hex characters. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexString(byte[] inArray) => Polyfill.ToHexString(inArray, 0, inArray.Length); /// @@ -54,16 +59,19 @@ static int GetHexValue(char hex) => /// /// Converts the span, which encodes binary data as hex characters, to an equivalent 8-bit unsigned integer array. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static byte[] FromHexString(ReadOnlySpan chars) => Polyfill.FromHexString(chars.ToString()); /// /// Converts a span of 8-bit unsigned integers to its equivalent string representation that is encoded with uppercase hex characters. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexString(ReadOnlySpan bytes) => Polyfill.ToHexString(bytes.ToArray()); /// /// Converts a span of 8-bit unsigned integers to its equivalent string representation that is encoded with lowercase hex characters. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexStringLower(ReadOnlySpan bytes) => Polyfill.ToHexStringLower(bytes.ToArray()); /// diff --git a/src/Split/net471/DateTimeOffsetPolyfill.cs b/src/Split/net471/DateTimeOffsetPolyfill.cs index 6837790e5..7bb9a5ad7 100644 --- a/src/Split/net471/DateTimeOffsetPolyfill.cs +++ b/src/Split/net471/DateTimeOffsetPolyfill.cs @@ -4,6 +4,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; static partial class Polyfill { extension(DateTimeOffset target) @@ -30,32 +31,38 @@ long TicksComponent() /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out DateTimeOffset result) => DateTimeOffset.TryParse(s, provider, DateTimeStyles.None, out result); #if FeatureMemory /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out DateTimeOffset result) => DateTimeOffset.TryParse(s.ToString(), provider, DateTimeStyles.None, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan input, out DateTimeOffset result) => DateTimeOffset.TryParse(input.ToString(), null, DateTimeStyles.None, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, DateTimeStyles styles, out DateTimeOffset result) => DateTimeOffset.TryParse(s.ToString(), provider, styles, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParseExact(ReadOnlySpan input, string format, IFormatProvider? provider, DateTimeStyles styles, out DateTimeOffset result) => DateTimeOffset.TryParseExact(input.ToString(), format, provider, styles, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParseExact(ReadOnlySpan input, ReadOnlySpan format, IFormatProvider? provider, DateTimeStyles styles, out DateTimeOffset result) => DateTimeOffset.TryParseExact(input.ToString(), format.ToString(), provider, styles, out result); #endif diff --git a/src/Split/net471/DateTimePolyfill.cs b/src/Split/net471/DateTimePolyfill.cs index 4641f3e59..4d329796a 100644 --- a/src/Split/net471/DateTimePolyfill.cs +++ b/src/Split/net471/DateTimePolyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; static partial class Polyfill { extension(DateTime target) @@ -29,32 +30,38 @@ long TicksComponent() /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out DateTime result) => DateTime.TryParse(s, provider, DateTimeStyles.None, out result); #if FeatureMemory /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out DateTime result) => DateTime.TryParse(s.ToString(), provider, DateTimeStyles.None, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out DateTime result) => DateTime.TryParse(s.ToString(), null, DateTimeStyles.None, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, DateTimeStyles styles, out DateTime result) => DateTime.TryParse(s.ToString(), provider, styles, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParseExact(ReadOnlySpan s, string format, IFormatProvider? provider, DateTimeStyles style, out DateTime result) => DateTime.TryParseExact(s.ToString(), format, provider, style, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParseExact(ReadOnlySpan s, ReadOnlySpan format, IFormatProvider? provider, DateTimeStyles styles, out DateTime result) => DateTime.TryParseExact(s.ToString(), format.ToString(), provider, styles, out result); #endif diff --git a/src/Split/net471/DelegatePolyfill.cs b/src/Split/net471/DelegatePolyfill.cs index effdb1267..59cc5e315 100644 --- a/src/Split/net471/DelegatePolyfill.cs +++ b/src/Split/net471/DelegatePolyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.ComponentModel; +using System.Runtime.CompilerServices; static partial class Polyfill { /// @@ -39,6 +40,7 @@ public bool MoveNext() /// /// Gets an enumerator for the invocation targets of this delegate. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static InvocationListEnumerator EnumerateInvocationList(TDelegate? target) where TDelegate : Delegate => new(target); diff --git a/src/Split/net471/FilePolyfill.cs b/src/Split/net471/FilePolyfill.cs index c6112e74d..66cb81a14 100644 --- a/src/Split/net471/FilePolyfill.cs +++ b/src/Split/net471/FilePolyfill.cs @@ -48,11 +48,13 @@ public static Task AppendAllTextAsync(string path, ReadOnlyMemory contents /// /// Appends the specified string to the file, creating the file if it does not already exist. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void AppendAllText(string path, ReadOnlySpan contents) => File.AppendAllText(path, contents.ToString()); /// /// Appends the specified string to the file, creating the file if it does not already exist. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void AppendAllText(string path, ReadOnlySpan contents, Encoding encoding) => File.AppendAllText(path, contents.ToString(), encoding); /// @@ -76,12 +78,14 @@ public static async Task WriteAllBytesAsync(string path, ReadOnlyMemory by /// Creates a new file, writes the specified string to the file, and then closes the file. /// If the target file already exists, it is truncated and overwritten. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void WriteAllText(string path, ReadOnlySpan contents) => File.WriteAllText(path, contents.ToString()); /// /// Creates a new file, writes the specified string to the file using the specified encoding, and then closes the file. /// If the target file already exists, it is truncated and overwritten. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void WriteAllText(string path, ReadOnlySpan contents, Encoding encoding) => File.WriteAllText(path, contents.ToString(), encoding); /// diff --git a/src/Split/net471/GuidPolyfill.cs b/src/Split/net471/GuidPolyfill.cs index 2bd536736..bc6b9129b 100644 --- a/src/Split/net471/GuidPolyfill.cs +++ b/src/Split/net471/GuidPolyfill.cs @@ -4,6 +4,7 @@ namespace Polyfills; using System.Text; using System; using System.Security.Cryptography; +using System.Runtime.CompilerServices; static partial class Polyfill { extension(Guid) @@ -11,9 +12,11 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out Guid result) => Guid.TryParse(s, out result); /// Creates a new according to RFC 9562, following the Version 7 format. + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Guid CreateVersion7() => CreateVersion7(DateTimeOffset.UtcNow); /// Creates a new according to RFC 9562, following the Version 7 format. public static Guid CreateVersion7(DateTimeOffset timestamp) @@ -40,26 +43,31 @@ public static Guid CreateVersion7(DateTimeOffset timestamp) /// /// Converts span of characters representing the GUID to the equivalent Guid structure, provided that the string is in the specified format. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParseExact(ReadOnlySpan input, ReadOnlySpan format, out Guid result) => Guid.TryParseExact(input.ToString(), format.ToString(), out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out Guid result) => Guid.TryParse(s.ToString(), out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan input, out Guid result) => Guid.TryParse(input.ToString(), out result); /// /// Tries to parse a span of UTF-8 bytes into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out Guid result) => Guid.TryParse(Encoding.UTF8.GetString(utf8Text), out result); /// /// Parse a span of UTF-8 bytes into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Guid Parse(ReadOnlySpan utf8Text) => Guid.Parse(Encoding.UTF8.GetString(utf8Text)); #endif diff --git a/src/Split/net471/KeyValuePair.cs b/src/Split/net471/KeyValuePair.cs index 7e5d58959..e94cbbf2f 100644 --- a/src/Split/net471/KeyValuePair.cs +++ b/src/Split/net471/KeyValuePair.cs @@ -4,6 +4,7 @@ namespace System.Collections.Generic; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; +using System.Runtime.CompilerServices; [ExcludeFromCodeCoverage] [DebuggerNonUserCode] #if PolyUseEmbeddedAttribute @@ -17,6 +18,7 @@ static class KeyValuePair /// /// Creates a new key/value pair instance using provided values. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static KeyValuePair Create(TKey key, TValue value) => new(key, value); } diff --git a/src/Split/net471/Lock.cs b/src/Split/net471/Lock.cs index 94fcf1ff9..36946028c 100644 --- a/src/Split/net471/Lock.cs +++ b/src/Split/net471/Lock.cs @@ -5,6 +5,7 @@ namespace System.Threading; using Diagnostics; using Diagnostics.CodeAnalysis; +using Runtime.CompilerServices; /// /// Provides a way to get mutual exclusion in regions of code between different threads. A lock may be held by one thread at /// a time. @@ -23,26 +24,31 @@ class Lock /// /// Enters the lock. Once the method returns, the calling thread would be the only thread that holds the lock. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Enter() => Monitor.Enter(this); /// /// Tries to enter the lock without waiting. If the lock is entered, the calling thread would be the only thread that /// holds the lock. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool TryEnter() => Monitor.TryEnter(this); /// /// Tries to enter the lock, waiting for roughly the specified duration. If the lock is entered, the calling thread /// would be the only thread that holds the lock. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool TryEnter(TimeSpan timeout) => Monitor.TryEnter(this, timeout); /// /// Tries to enter the lock, waiting for roughly the specified duration. If the lock is entered, the calling thread /// would be the only thread that holds the lock. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool TryEnter(int millisecondsTimeout) => TryEnter(TimeSpan.FromMilliseconds(millisecondsTimeout)); /// /// Exits the lock. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Exit() => Monitor.Exit(this); /// /// Enters the lock and returns a that may be disposed to exit the lock. Once the method returns, diff --git a/src/Split/net471/Numbers/BytePolyfill.cs b/src/Split/net471/Numbers/BytePolyfill.cs index ef3f744ed..0ea017afd 100644 --- a/src/Split/net471/Numbers/BytePolyfill.cs +++ b/src/Split/net471/Numbers/BytePolyfill.cs @@ -4,6 +4,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -12,37 +13,44 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out byte result) => byte.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out byte result) => byte.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out byte result) => byte.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out byte result) => byte.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its byte equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out byte result) => byte.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its byte equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out byte result) => byte.TryParse(s.ToString(), out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its byte equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out byte result) => byte.TryParse(s.ToString(), style, provider, out result); #endif diff --git a/src/Split/net471/Numbers/DoublePolyfill.cs b/src/Split/net471/Numbers/DoublePolyfill.cs index ba5333f69..d903ddfe1 100644 --- a/src/Split/net471/Numbers/DoublePolyfill.cs +++ b/src/Split/net471/Numbers/DoublePolyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,37 +12,44 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out double result) => double.TryParse(s, NumberStyles.Float, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out double result) => double.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Float, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out double result) => double.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its double-precision floating-point number equivalent.. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out double result) => double.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Float, null, out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its double-precision floating-point number equivalent. A return value indicates whether the conversion succeeded or failed. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out double result) => double.TryParse(s.ToString(), out result); /// /// Converts the string representation of a number in a specified style and culture-specific format to its double-precision floating-point number equivalent. A return value indicates whether the conversion succeeded or failed. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out double result) => double.TryParse(s.ToString(), style, provider, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out double result) => double.TryParse(s.ToString(), NumberStyles.Float, provider, out result); #endif diff --git a/src/Split/net471/Numbers/Int16Polyfill.cs b/src/Split/net471/Numbers/Int16Polyfill.cs index 5eb1b384e..960cf68ce 100644 --- a/src/Split/net471/Numbers/Int16Polyfill.cs +++ b/src/Split/net471/Numbers/Int16Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,37 +12,44 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out short result) => short.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out short result) => short.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out short result) => short.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its short equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out short result) => short.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its short equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out short result) => short.TryParse(s.ToString(), out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its short equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out short result) => short.TryParse(s.ToString(), style, provider, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out short result) => short.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/net471/Numbers/Int32Polyfill.cs b/src/Split/net471/Numbers/Int32Polyfill.cs index 549ff1896..2920eae4a 100644 --- a/src/Split/net471/Numbers/Int32Polyfill.cs +++ b/src/Split/net471/Numbers/Int32Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,37 +12,44 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out int result) => int.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out int result) => int.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out int result) => int.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its 32-bit signed integer equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out int result) => int.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its 32-bit signed integer equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out int result) => int.TryParse(s.ToString(), out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its 32-bit signed integer equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out int result) => int.TryParse(s.ToString(), style, provider, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out int result) => int.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/net471/Numbers/Int64Polyfill.cs b/src/Split/net471/Numbers/Int64Polyfill.cs index bd33ce0e6..0b7b1b100 100644 --- a/src/Split/net471/Numbers/Int64Polyfill.cs +++ b/src/Split/net471/Numbers/Int64Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,37 +12,44 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out long result) => long.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out long result) => long.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out long result) => long.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its 64-bit signed integer equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out long result) => long.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its 32-bit signed integer equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out long result) => long.TryParse(s.ToString(), out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its 64-bit signed integer equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out long result) => long.TryParse(s.ToString(), style, provider, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out long result) => long.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/net471/Numbers/SBytePolyfill.cs b/src/Split/net471/Numbers/SBytePolyfill.cs index 974115654..890452b1c 100644 --- a/src/Split/net471/Numbers/SBytePolyfill.cs +++ b/src/Split/net471/Numbers/SBytePolyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,37 +12,44 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out sbyte result) => sbyte.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out sbyte result) => sbyte.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out sbyte result) => sbyte.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its sbyte equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out sbyte result) => sbyte.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its sbyte equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out sbyte result) => sbyte.TryParse(s.ToString(), out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its sbyte equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out sbyte result) => sbyte.TryParse(s.ToString(), style, provider, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out sbyte result) => sbyte.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/net471/Numbers/UInt16Polyfill.cs b/src/Split/net471/Numbers/UInt16Polyfill.cs index 34f39f97c..ed0958805 100644 --- a/src/Split/net471/Numbers/UInt16Polyfill.cs +++ b/src/Split/net471/Numbers/UInt16Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,37 +12,44 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out ushort result) => ushort.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out ushort result) => ushort.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out ushort result) => ushort.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its ushort equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out ushort result) => ushort.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its ushort equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out ushort result) => ushort.TryParse(s.ToString(), out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its ushort equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out ushort result) => ushort.TryParse(s.ToString(), style, provider, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out ushort result) => ushort.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/net471/Numbers/UInt32Polyfill.cs b/src/Split/net471/Numbers/UInt32Polyfill.cs index 859149bed..e11b65c90 100644 --- a/src/Split/net471/Numbers/UInt32Polyfill.cs +++ b/src/Split/net471/Numbers/UInt32Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,37 +12,44 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out uint result) => uint.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out uint result) => uint.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out uint result) => uint.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its uint equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out uint result) => uint.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its uint equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out uint result) => uint.TryParse(s.ToString(), out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its uint equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out uint result) => uint.TryParse(s.ToString(), style, provider, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out uint result) => uint.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/net471/Numbers/UInt64Polyfill.cs b/src/Split/net471/Numbers/UInt64Polyfill.cs index c14bb347c..10122d2b4 100644 --- a/src/Split/net471/Numbers/UInt64Polyfill.cs +++ b/src/Split/net471/Numbers/UInt64Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,37 +12,44 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out ulong result) => ulong.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out ulong result) => ulong.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpanutf8Text, NumberStyles style, IFormatProvider? provider, out ulong result) => ulong.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its ulong equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out ulong result) => ulong.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its ulong equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out ulong result) => ulong.TryParse(s.ToString(), out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its ulong equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out ulong result) => ulong.TryParse(s.ToString(), style, provider, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out ulong result) => ulong.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/net471/OperatingSystemPolyfill.cs b/src/Split/net471/OperatingSystemPolyfill.cs index 5d1f8de36..68413c7d5 100644 --- a/src/Split/net471/OperatingSystemPolyfill.cs +++ b/src/Split/net471/OperatingSystemPolyfill.cs @@ -3,6 +3,7 @@ #if FeatureRuntimeInformation namespace Polyfills; using System; +using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; static partial class Polyfill @@ -14,114 +15,135 @@ static bool IsOsVersionAtLeast(int major, int minor = 0, int build = 0, int revi /// /// Indicates whether the current application is running as WASI. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsWasi() => RuntimeInformation.IsOSPlatform(OSPlatform.Create("WASI")); /// /// Indicates whether the current application is running on Mac Catalyst. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsMacCatalyst() => OperatingSystem.IsMacOS() || OperatingSystem.IsIOS(); /// /// Check for the Mac Catalyst version (iOS version as presented in Apple documentation) with a ≤ version comparison. Used to guard APIs that were added in the given Mac Catalyst release. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsMacCatalystVersionAtLeast(int major, int minor = 0, int build = 0) => IsMacCatalyst() && IsOsVersionAtLeast(major, minor, build); /// /// Checks if the macOS version (returned by libobjc.get_operatingSystemVersion) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified macOS version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsMacOSVersionAtLeast(int major, int minor = 0, int build = 0) => OperatingSystemCache.IsMacOSVersionAtLeast(major, minor, build); /// /// Checks if the FreeBSD version (returned by the Linux command uname) is greater than or equal to the specified version. /// This method can be used to guard APIs that were added in the specified version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsFreeBSDVersionAtLeast(int major, int minor, int build = 0, int revision = 0) => OperatingSystemCache.IsFreeBSDVersionAtLeast(major, minor, build, revision); /// /// Indicates whether the current application is running on Android. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsAndroid() => OperatingSystemCache.IsAndroid(); /// /// Checks if the Android version (returned by the Linux command uname) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsAndroidVersionAtLeast(int major, int minor = 0, int build = 0, int revision = 0) => OperatingSystemCache.IsAndroidVersionAtLeast(major, minor, build, revision); /// /// Checks if the Windows version (returned by RtlGetVersion) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified Windows version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsWindowsVersionAtLeast(int major, int minor = 0, int build = 0, int revision = 0) => OperatingSystemCache.IsWindowsVersionAtLeast(major, minor, build, revision); /// /// Indicates whether the current application is running on the specified platform. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsOSPlatform(string platform) => RuntimeInformation.IsOSPlatform(OSPlatform.Create(platform)); /// /// Checks if the operating system version is greater than or equal to the specified platform version. This method can be used to guard APIs that were added in the specified OS version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsOSPlatformVersionAtLeast(string platform, int major, int minor = 0, int build = 0, int revision = 0) => IsOSPlatform(platform) && IsOsVersionAtLeast(major, minor, build, revision); /// /// Indicates whether the current application is running on Windows. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsWindows() => RuntimeInformation.IsOSPlatform(OSPlatform.Windows); /// /// Indicates whether the current application is running on macOS. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsMacOS() => RuntimeInformation.IsOSPlatform(OSPlatform.OSX); /// /// Indicates whether the current application is running on iOS or MacCatalyst. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsIOS() => RuntimeInformation.IsOSPlatform(OSPlatform.Create("IOS")); /// /// Indicates whether the current application is running on Linux. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsLinux() => RuntimeInformation.IsOSPlatform(OSPlatform.Linux); /// /// Indicates whether the current application is running on FreeBSD. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsFreeBSD() => RuntimeInformation.OSDescription.ToLower().Contains("freebsd"); /// /// Checks if the iOS/MacCatalyst version (returned by libobjc.get_operatingSystemVersion) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified iOS version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsIOSVersionAtLeast(int major, int minor = 0, int build = 0) => IsIOS() && IsOsVersionAtLeast(major, minor, build); /// /// Checks if the tvOS version (returned by libobjc.get_operatingSystemVersion) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified tvOS version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsTvOSVersionAtLeast(int major, int minor = 0, int build = 0) => IsTvOS() && IsOsVersionAtLeast(major, minor, build); /// /// Indicates whether the current application is running on tvOS. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsTvOS() => RuntimeInformation.IsOSPlatform(OSPlatform.Create("TVOS")); /// /// Indicates whether the current application is running on watchOS. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsWatchOS() => IsIOS() || RuntimeInformation.OSDescription.ToLower().Contains("watchos"); /// /// Checks if the watchOS version (returned by libobjc.get_operatingSystemVersion) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified watchOS version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsWatchOSVersionAtLeast(int major, int minor = 0, int build = 0) => IsWatchOS() && IsOsVersionAtLeast(major, minor, build); /// /// Indicates whether the current application is running as WASM in a browser. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsBrowser() => RuntimeInformation.IsOSPlatform(OSPlatform.Create("BROWSER")); } diff --git a/src/Split/net471/PathPolyfill.cs b/src/Split/net471/PathPolyfill.cs index fb4329ac6..fc8009da8 100644 --- a/src/Split/net471/PathPolyfill.cs +++ b/src/Split/net471/PathPolyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.IO; +using System.Runtime.CompilerServices; static partial class Polyfill { extension(Path) @@ -11,41 +12,49 @@ static partial class Polyfill /// /// Returns the directory information for the specified path represented by a character span. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ReadOnlySpan GetDirectoryName(ReadOnlySpan path) => Path.GetDirectoryName(path.ToString()).AsSpan(); /// /// Returns the file name and extension of a file path that is represented by a read-only character span. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ReadOnlySpan GetFileName(ReadOnlySpan path) => Path.GetFileName(path.ToString()).AsSpan(); /// /// Returns the file name without the extension of a file path that is represented by a read-only character span. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ReadOnlySpan GetFileNameWithoutExtension(ReadOnlySpan path) => Path.GetFileNameWithoutExtension(path.ToString()).AsSpan(); /// /// Determines whether the path represented by the specified character span includes a file name extension. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool HasExtension(ReadOnlySpan path) => Path.HasExtension(path.ToString()); /// /// Returns the extension of the given path. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ReadOnlySpan GetExtension(ReadOnlySpan path) => Path.GetExtension(path.ToString()).AsSpan(); /// /// Combines a span of strings into a path. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string Combine(scoped ReadOnlySpan paths) => Path.Combine(paths.ToArray()); /// /// Returns a value that indicates whether the path, specified as a read-only span, ends in a directory separator. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool EndsInDirectorySeparator (ReadOnlySpan path) => EndsInDirectorySeparator(path.ToString()); /// /// Trims one trailing directory separator beyond the root of the specified path. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ReadOnlySpan TrimEndingDirectorySeparator(ReadOnlySpan path) => TrimEndingDirectorySeparator(path.ToString()).AsSpan(); #endif diff --git a/src/Split/net472/ConsolePolyfill.cs b/src/Split/net472/ConsolePolyfill.cs index 425364db8..5ad0342de 100644 --- a/src/Split/net472/ConsolePolyfill.cs +++ b/src/Split/net472/ConsolePolyfill.cs @@ -4,6 +4,7 @@ namespace Polyfills; using System; using System.Runtime.InteropServices; +using System.Runtime.CompilerServices; using Microsoft.Win32.SafeHandles; static partial class Polyfill { @@ -12,16 +13,19 @@ static partial class Polyfill /// /// Gets a that wraps the operating system handle for standard input. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static SafeFileHandle OpenStandardInputHandle() => StandardHandleHelper.GetStandardHandle(StandardHandleHelper.StdInput); /// /// Gets a that wraps the operating system handle for standard output. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static SafeFileHandle OpenStandardOutputHandle() => StandardHandleHelper.GetStandardHandle(StandardHandleHelper.StdOutput); /// /// Gets a that wraps the operating system handle for standard error. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static SafeFileHandle OpenStandardErrorHandle() => StandardHandleHelper.GetStandardHandle(StandardHandleHelper.StdError); } diff --git a/src/Split/net472/ConvertPolyfill.cs b/src/Split/net472/ConvertPolyfill.cs index 8ca6da94f..5f80df1f7 100644 --- a/src/Split/net472/ConvertPolyfill.cs +++ b/src/Split/net472/ConvertPolyfill.cs @@ -2,6 +2,7 @@ #pragma warning disable namespace Polyfills; using System; +using System.Runtime.CompilerServices; static partial class Polyfill { extension(Convert) @@ -10,22 +11,26 @@ static partial class Polyfill /// Converts a subset of an array of 8-bit unsigned integers to its equivalent string representation that is encoded with uppercase hex characters. /// Parameters specify the subset as an offset in the input array and the number of elements in the array to convert. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexString(byte[] inArray, int offset, int length) => ToHexString(inArray, offset, length, "X2"); /// /// Converts a subset of an array of 8-bit unsigned integers to its equivalent string representation that is encoded with lowercase hex characters. /// Parameters specify the subset as an offset in the input array and the number of elements in the array to convert. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexStringLower(byte[] inArray, int offset, int length) => ToHexString(inArray, offset, length, "x2"); /// /// Converts an array of 8-bit unsigned integers to its equivalent string representation that is encoded with lowercase hex characters. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexStringLower(byte[] inArray) => Polyfill.ToHexStringLower(inArray, 0, inArray.Length); /// /// Converts an array of 8-bit unsigned integers to its equivalent string representation that is encoded with uppercase hex characters. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexString(byte[] inArray) => Polyfill.ToHexString(inArray, 0, inArray.Length); /// @@ -54,16 +59,19 @@ static int GetHexValue(char hex) => /// /// Converts the span, which encodes binary data as hex characters, to an equivalent 8-bit unsigned integer array. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static byte[] FromHexString(ReadOnlySpan chars) => Polyfill.FromHexString(chars.ToString()); /// /// Converts a span of 8-bit unsigned integers to its equivalent string representation that is encoded with uppercase hex characters. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexString(ReadOnlySpan bytes) => Polyfill.ToHexString(bytes.ToArray()); /// /// Converts a span of 8-bit unsigned integers to its equivalent string representation that is encoded with lowercase hex characters. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexStringLower(ReadOnlySpan bytes) => Polyfill.ToHexStringLower(bytes.ToArray()); /// diff --git a/src/Split/net472/DateTimeOffsetPolyfill.cs b/src/Split/net472/DateTimeOffsetPolyfill.cs index 6837790e5..7bb9a5ad7 100644 --- a/src/Split/net472/DateTimeOffsetPolyfill.cs +++ b/src/Split/net472/DateTimeOffsetPolyfill.cs @@ -4,6 +4,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; static partial class Polyfill { extension(DateTimeOffset target) @@ -30,32 +31,38 @@ long TicksComponent() /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out DateTimeOffset result) => DateTimeOffset.TryParse(s, provider, DateTimeStyles.None, out result); #if FeatureMemory /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out DateTimeOffset result) => DateTimeOffset.TryParse(s.ToString(), provider, DateTimeStyles.None, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan input, out DateTimeOffset result) => DateTimeOffset.TryParse(input.ToString(), null, DateTimeStyles.None, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, DateTimeStyles styles, out DateTimeOffset result) => DateTimeOffset.TryParse(s.ToString(), provider, styles, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParseExact(ReadOnlySpan input, string format, IFormatProvider? provider, DateTimeStyles styles, out DateTimeOffset result) => DateTimeOffset.TryParseExact(input.ToString(), format, provider, styles, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParseExact(ReadOnlySpan input, ReadOnlySpan format, IFormatProvider? provider, DateTimeStyles styles, out DateTimeOffset result) => DateTimeOffset.TryParseExact(input.ToString(), format.ToString(), provider, styles, out result); #endif diff --git a/src/Split/net472/DateTimePolyfill.cs b/src/Split/net472/DateTimePolyfill.cs index 4641f3e59..4d329796a 100644 --- a/src/Split/net472/DateTimePolyfill.cs +++ b/src/Split/net472/DateTimePolyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; static partial class Polyfill { extension(DateTime target) @@ -29,32 +30,38 @@ long TicksComponent() /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out DateTime result) => DateTime.TryParse(s, provider, DateTimeStyles.None, out result); #if FeatureMemory /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out DateTime result) => DateTime.TryParse(s.ToString(), provider, DateTimeStyles.None, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out DateTime result) => DateTime.TryParse(s.ToString(), null, DateTimeStyles.None, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, DateTimeStyles styles, out DateTime result) => DateTime.TryParse(s.ToString(), provider, styles, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParseExact(ReadOnlySpan s, string format, IFormatProvider? provider, DateTimeStyles style, out DateTime result) => DateTime.TryParseExact(s.ToString(), format, provider, style, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParseExact(ReadOnlySpan s, ReadOnlySpan format, IFormatProvider? provider, DateTimeStyles styles, out DateTime result) => DateTime.TryParseExact(s.ToString(), format.ToString(), provider, styles, out result); #endif diff --git a/src/Split/net472/DelegatePolyfill.cs b/src/Split/net472/DelegatePolyfill.cs index effdb1267..59cc5e315 100644 --- a/src/Split/net472/DelegatePolyfill.cs +++ b/src/Split/net472/DelegatePolyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.ComponentModel; +using System.Runtime.CompilerServices; static partial class Polyfill { /// @@ -39,6 +40,7 @@ public bool MoveNext() /// /// Gets an enumerator for the invocation targets of this delegate. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static InvocationListEnumerator EnumerateInvocationList(TDelegate? target) where TDelegate : Delegate => new(target); diff --git a/src/Split/net472/FilePolyfill.cs b/src/Split/net472/FilePolyfill.cs index c6112e74d..66cb81a14 100644 --- a/src/Split/net472/FilePolyfill.cs +++ b/src/Split/net472/FilePolyfill.cs @@ -48,11 +48,13 @@ public static Task AppendAllTextAsync(string path, ReadOnlyMemory contents /// /// Appends the specified string to the file, creating the file if it does not already exist. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void AppendAllText(string path, ReadOnlySpan contents) => File.AppendAllText(path, contents.ToString()); /// /// Appends the specified string to the file, creating the file if it does not already exist. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void AppendAllText(string path, ReadOnlySpan contents, Encoding encoding) => File.AppendAllText(path, contents.ToString(), encoding); /// @@ -76,12 +78,14 @@ public static async Task WriteAllBytesAsync(string path, ReadOnlyMemory by /// Creates a new file, writes the specified string to the file, and then closes the file. /// If the target file already exists, it is truncated and overwritten. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void WriteAllText(string path, ReadOnlySpan contents) => File.WriteAllText(path, contents.ToString()); /// /// Creates a new file, writes the specified string to the file using the specified encoding, and then closes the file. /// If the target file already exists, it is truncated and overwritten. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void WriteAllText(string path, ReadOnlySpan contents, Encoding encoding) => File.WriteAllText(path, contents.ToString(), encoding); /// diff --git a/src/Split/net472/GuidPolyfill.cs b/src/Split/net472/GuidPolyfill.cs index 2bd536736..bc6b9129b 100644 --- a/src/Split/net472/GuidPolyfill.cs +++ b/src/Split/net472/GuidPolyfill.cs @@ -4,6 +4,7 @@ namespace Polyfills; using System.Text; using System; using System.Security.Cryptography; +using System.Runtime.CompilerServices; static partial class Polyfill { extension(Guid) @@ -11,9 +12,11 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out Guid result) => Guid.TryParse(s, out result); /// Creates a new according to RFC 9562, following the Version 7 format. + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Guid CreateVersion7() => CreateVersion7(DateTimeOffset.UtcNow); /// Creates a new according to RFC 9562, following the Version 7 format. public static Guid CreateVersion7(DateTimeOffset timestamp) @@ -40,26 +43,31 @@ public static Guid CreateVersion7(DateTimeOffset timestamp) /// /// Converts span of characters representing the GUID to the equivalent Guid structure, provided that the string is in the specified format. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParseExact(ReadOnlySpan input, ReadOnlySpan format, out Guid result) => Guid.TryParseExact(input.ToString(), format.ToString(), out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out Guid result) => Guid.TryParse(s.ToString(), out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan input, out Guid result) => Guid.TryParse(input.ToString(), out result); /// /// Tries to parse a span of UTF-8 bytes into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out Guid result) => Guid.TryParse(Encoding.UTF8.GetString(utf8Text), out result); /// /// Parse a span of UTF-8 bytes into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Guid Parse(ReadOnlySpan utf8Text) => Guid.Parse(Encoding.UTF8.GetString(utf8Text)); #endif diff --git a/src/Split/net472/KeyValuePair.cs b/src/Split/net472/KeyValuePair.cs index 7e5d58959..e94cbbf2f 100644 --- a/src/Split/net472/KeyValuePair.cs +++ b/src/Split/net472/KeyValuePair.cs @@ -4,6 +4,7 @@ namespace System.Collections.Generic; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; +using System.Runtime.CompilerServices; [ExcludeFromCodeCoverage] [DebuggerNonUserCode] #if PolyUseEmbeddedAttribute @@ -17,6 +18,7 @@ static class KeyValuePair /// /// Creates a new key/value pair instance using provided values. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static KeyValuePair Create(TKey key, TValue value) => new(key, value); } diff --git a/src/Split/net472/Lock.cs b/src/Split/net472/Lock.cs index 94fcf1ff9..36946028c 100644 --- a/src/Split/net472/Lock.cs +++ b/src/Split/net472/Lock.cs @@ -5,6 +5,7 @@ namespace System.Threading; using Diagnostics; using Diagnostics.CodeAnalysis; +using Runtime.CompilerServices; /// /// Provides a way to get mutual exclusion in regions of code between different threads. A lock may be held by one thread at /// a time. @@ -23,26 +24,31 @@ class Lock /// /// Enters the lock. Once the method returns, the calling thread would be the only thread that holds the lock. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Enter() => Monitor.Enter(this); /// /// Tries to enter the lock without waiting. If the lock is entered, the calling thread would be the only thread that /// holds the lock. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool TryEnter() => Monitor.TryEnter(this); /// /// Tries to enter the lock, waiting for roughly the specified duration. If the lock is entered, the calling thread /// would be the only thread that holds the lock. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool TryEnter(TimeSpan timeout) => Monitor.TryEnter(this, timeout); /// /// Tries to enter the lock, waiting for roughly the specified duration. If the lock is entered, the calling thread /// would be the only thread that holds the lock. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool TryEnter(int millisecondsTimeout) => TryEnter(TimeSpan.FromMilliseconds(millisecondsTimeout)); /// /// Exits the lock. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Exit() => Monitor.Exit(this); /// /// Enters the lock and returns a that may be disposed to exit the lock. Once the method returns, diff --git a/src/Split/net472/Numbers/BytePolyfill.cs b/src/Split/net472/Numbers/BytePolyfill.cs index ef3f744ed..0ea017afd 100644 --- a/src/Split/net472/Numbers/BytePolyfill.cs +++ b/src/Split/net472/Numbers/BytePolyfill.cs @@ -4,6 +4,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -12,37 +13,44 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out byte result) => byte.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out byte result) => byte.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out byte result) => byte.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out byte result) => byte.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its byte equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out byte result) => byte.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its byte equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out byte result) => byte.TryParse(s.ToString(), out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its byte equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out byte result) => byte.TryParse(s.ToString(), style, provider, out result); #endif diff --git a/src/Split/net472/Numbers/DoublePolyfill.cs b/src/Split/net472/Numbers/DoublePolyfill.cs index ba5333f69..d903ddfe1 100644 --- a/src/Split/net472/Numbers/DoublePolyfill.cs +++ b/src/Split/net472/Numbers/DoublePolyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,37 +12,44 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out double result) => double.TryParse(s, NumberStyles.Float, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out double result) => double.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Float, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out double result) => double.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its double-precision floating-point number equivalent.. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out double result) => double.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Float, null, out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its double-precision floating-point number equivalent. A return value indicates whether the conversion succeeded or failed. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out double result) => double.TryParse(s.ToString(), out result); /// /// Converts the string representation of a number in a specified style and culture-specific format to its double-precision floating-point number equivalent. A return value indicates whether the conversion succeeded or failed. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out double result) => double.TryParse(s.ToString(), style, provider, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out double result) => double.TryParse(s.ToString(), NumberStyles.Float, provider, out result); #endif diff --git a/src/Split/net472/Numbers/Int16Polyfill.cs b/src/Split/net472/Numbers/Int16Polyfill.cs index 5eb1b384e..960cf68ce 100644 --- a/src/Split/net472/Numbers/Int16Polyfill.cs +++ b/src/Split/net472/Numbers/Int16Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,37 +12,44 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out short result) => short.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out short result) => short.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out short result) => short.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its short equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out short result) => short.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its short equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out short result) => short.TryParse(s.ToString(), out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its short equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out short result) => short.TryParse(s.ToString(), style, provider, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out short result) => short.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/net472/Numbers/Int32Polyfill.cs b/src/Split/net472/Numbers/Int32Polyfill.cs index 549ff1896..2920eae4a 100644 --- a/src/Split/net472/Numbers/Int32Polyfill.cs +++ b/src/Split/net472/Numbers/Int32Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,37 +12,44 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out int result) => int.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out int result) => int.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out int result) => int.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its 32-bit signed integer equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out int result) => int.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its 32-bit signed integer equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out int result) => int.TryParse(s.ToString(), out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its 32-bit signed integer equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out int result) => int.TryParse(s.ToString(), style, provider, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out int result) => int.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/net472/Numbers/Int64Polyfill.cs b/src/Split/net472/Numbers/Int64Polyfill.cs index bd33ce0e6..0b7b1b100 100644 --- a/src/Split/net472/Numbers/Int64Polyfill.cs +++ b/src/Split/net472/Numbers/Int64Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,37 +12,44 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out long result) => long.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out long result) => long.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out long result) => long.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its 64-bit signed integer equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out long result) => long.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its 32-bit signed integer equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out long result) => long.TryParse(s.ToString(), out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its 64-bit signed integer equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out long result) => long.TryParse(s.ToString(), style, provider, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out long result) => long.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/net472/Numbers/SBytePolyfill.cs b/src/Split/net472/Numbers/SBytePolyfill.cs index 974115654..890452b1c 100644 --- a/src/Split/net472/Numbers/SBytePolyfill.cs +++ b/src/Split/net472/Numbers/SBytePolyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,37 +12,44 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out sbyte result) => sbyte.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out sbyte result) => sbyte.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out sbyte result) => sbyte.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its sbyte equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out sbyte result) => sbyte.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its sbyte equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out sbyte result) => sbyte.TryParse(s.ToString(), out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its sbyte equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out sbyte result) => sbyte.TryParse(s.ToString(), style, provider, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out sbyte result) => sbyte.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/net472/Numbers/UInt16Polyfill.cs b/src/Split/net472/Numbers/UInt16Polyfill.cs index 34f39f97c..ed0958805 100644 --- a/src/Split/net472/Numbers/UInt16Polyfill.cs +++ b/src/Split/net472/Numbers/UInt16Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,37 +12,44 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out ushort result) => ushort.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out ushort result) => ushort.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out ushort result) => ushort.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its ushort equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out ushort result) => ushort.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its ushort equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out ushort result) => ushort.TryParse(s.ToString(), out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its ushort equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out ushort result) => ushort.TryParse(s.ToString(), style, provider, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out ushort result) => ushort.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/net472/Numbers/UInt32Polyfill.cs b/src/Split/net472/Numbers/UInt32Polyfill.cs index 859149bed..e11b65c90 100644 --- a/src/Split/net472/Numbers/UInt32Polyfill.cs +++ b/src/Split/net472/Numbers/UInt32Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,37 +12,44 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out uint result) => uint.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out uint result) => uint.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out uint result) => uint.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its uint equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out uint result) => uint.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its uint equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out uint result) => uint.TryParse(s.ToString(), out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its uint equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out uint result) => uint.TryParse(s.ToString(), style, provider, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out uint result) => uint.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/net472/Numbers/UInt64Polyfill.cs b/src/Split/net472/Numbers/UInt64Polyfill.cs index c14bb347c..10122d2b4 100644 --- a/src/Split/net472/Numbers/UInt64Polyfill.cs +++ b/src/Split/net472/Numbers/UInt64Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,37 +12,44 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out ulong result) => ulong.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out ulong result) => ulong.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpanutf8Text, NumberStyles style, IFormatProvider? provider, out ulong result) => ulong.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its ulong equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out ulong result) => ulong.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its ulong equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out ulong result) => ulong.TryParse(s.ToString(), out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its ulong equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out ulong result) => ulong.TryParse(s.ToString(), style, provider, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out ulong result) => ulong.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/net472/OperatingSystemPolyfill.cs b/src/Split/net472/OperatingSystemPolyfill.cs index 5d1f8de36..68413c7d5 100644 --- a/src/Split/net472/OperatingSystemPolyfill.cs +++ b/src/Split/net472/OperatingSystemPolyfill.cs @@ -3,6 +3,7 @@ #if FeatureRuntimeInformation namespace Polyfills; using System; +using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; static partial class Polyfill @@ -14,114 +15,135 @@ static bool IsOsVersionAtLeast(int major, int minor = 0, int build = 0, int revi /// /// Indicates whether the current application is running as WASI. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsWasi() => RuntimeInformation.IsOSPlatform(OSPlatform.Create("WASI")); /// /// Indicates whether the current application is running on Mac Catalyst. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsMacCatalyst() => OperatingSystem.IsMacOS() || OperatingSystem.IsIOS(); /// /// Check for the Mac Catalyst version (iOS version as presented in Apple documentation) with a ≤ version comparison. Used to guard APIs that were added in the given Mac Catalyst release. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsMacCatalystVersionAtLeast(int major, int minor = 0, int build = 0) => IsMacCatalyst() && IsOsVersionAtLeast(major, minor, build); /// /// Checks if the macOS version (returned by libobjc.get_operatingSystemVersion) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified macOS version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsMacOSVersionAtLeast(int major, int minor = 0, int build = 0) => OperatingSystemCache.IsMacOSVersionAtLeast(major, minor, build); /// /// Checks if the FreeBSD version (returned by the Linux command uname) is greater than or equal to the specified version. /// This method can be used to guard APIs that were added in the specified version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsFreeBSDVersionAtLeast(int major, int minor, int build = 0, int revision = 0) => OperatingSystemCache.IsFreeBSDVersionAtLeast(major, minor, build, revision); /// /// Indicates whether the current application is running on Android. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsAndroid() => OperatingSystemCache.IsAndroid(); /// /// Checks if the Android version (returned by the Linux command uname) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsAndroidVersionAtLeast(int major, int minor = 0, int build = 0, int revision = 0) => OperatingSystemCache.IsAndroidVersionAtLeast(major, minor, build, revision); /// /// Checks if the Windows version (returned by RtlGetVersion) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified Windows version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsWindowsVersionAtLeast(int major, int minor = 0, int build = 0, int revision = 0) => OperatingSystemCache.IsWindowsVersionAtLeast(major, minor, build, revision); /// /// Indicates whether the current application is running on the specified platform. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsOSPlatform(string platform) => RuntimeInformation.IsOSPlatform(OSPlatform.Create(platform)); /// /// Checks if the operating system version is greater than or equal to the specified platform version. This method can be used to guard APIs that were added in the specified OS version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsOSPlatformVersionAtLeast(string platform, int major, int minor = 0, int build = 0, int revision = 0) => IsOSPlatform(platform) && IsOsVersionAtLeast(major, minor, build, revision); /// /// Indicates whether the current application is running on Windows. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsWindows() => RuntimeInformation.IsOSPlatform(OSPlatform.Windows); /// /// Indicates whether the current application is running on macOS. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsMacOS() => RuntimeInformation.IsOSPlatform(OSPlatform.OSX); /// /// Indicates whether the current application is running on iOS or MacCatalyst. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsIOS() => RuntimeInformation.IsOSPlatform(OSPlatform.Create("IOS")); /// /// Indicates whether the current application is running on Linux. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsLinux() => RuntimeInformation.IsOSPlatform(OSPlatform.Linux); /// /// Indicates whether the current application is running on FreeBSD. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsFreeBSD() => RuntimeInformation.OSDescription.ToLower().Contains("freebsd"); /// /// Checks if the iOS/MacCatalyst version (returned by libobjc.get_operatingSystemVersion) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified iOS version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsIOSVersionAtLeast(int major, int minor = 0, int build = 0) => IsIOS() && IsOsVersionAtLeast(major, minor, build); /// /// Checks if the tvOS version (returned by libobjc.get_operatingSystemVersion) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified tvOS version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsTvOSVersionAtLeast(int major, int minor = 0, int build = 0) => IsTvOS() && IsOsVersionAtLeast(major, minor, build); /// /// Indicates whether the current application is running on tvOS. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsTvOS() => RuntimeInformation.IsOSPlatform(OSPlatform.Create("TVOS")); /// /// Indicates whether the current application is running on watchOS. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsWatchOS() => IsIOS() || RuntimeInformation.OSDescription.ToLower().Contains("watchos"); /// /// Checks if the watchOS version (returned by libobjc.get_operatingSystemVersion) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified watchOS version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsWatchOSVersionAtLeast(int major, int minor = 0, int build = 0) => IsWatchOS() && IsOsVersionAtLeast(major, minor, build); /// /// Indicates whether the current application is running as WASM in a browser. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsBrowser() => RuntimeInformation.IsOSPlatform(OSPlatform.Create("BROWSER")); } diff --git a/src/Split/net472/PathPolyfill.cs b/src/Split/net472/PathPolyfill.cs index fb4329ac6..fc8009da8 100644 --- a/src/Split/net472/PathPolyfill.cs +++ b/src/Split/net472/PathPolyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.IO; +using System.Runtime.CompilerServices; static partial class Polyfill { extension(Path) @@ -11,41 +12,49 @@ static partial class Polyfill /// /// Returns the directory information for the specified path represented by a character span. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ReadOnlySpan GetDirectoryName(ReadOnlySpan path) => Path.GetDirectoryName(path.ToString()).AsSpan(); /// /// Returns the file name and extension of a file path that is represented by a read-only character span. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ReadOnlySpan GetFileName(ReadOnlySpan path) => Path.GetFileName(path.ToString()).AsSpan(); /// /// Returns the file name without the extension of a file path that is represented by a read-only character span. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ReadOnlySpan GetFileNameWithoutExtension(ReadOnlySpan path) => Path.GetFileNameWithoutExtension(path.ToString()).AsSpan(); /// /// Determines whether the path represented by the specified character span includes a file name extension. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool HasExtension(ReadOnlySpan path) => Path.HasExtension(path.ToString()); /// /// Returns the extension of the given path. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ReadOnlySpan GetExtension(ReadOnlySpan path) => Path.GetExtension(path.ToString()).AsSpan(); /// /// Combines a span of strings into a path. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string Combine(scoped ReadOnlySpan paths) => Path.Combine(paths.ToArray()); /// /// Returns a value that indicates whether the path, specified as a read-only span, ends in a directory separator. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool EndsInDirectorySeparator (ReadOnlySpan path) => EndsInDirectorySeparator(path.ToString()); /// /// Trims one trailing directory separator beyond the root of the specified path. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ReadOnlySpan TrimEndingDirectorySeparator(ReadOnlySpan path) => TrimEndingDirectorySeparator(path.ToString()).AsSpan(); #endif diff --git a/src/Split/net48/ConsolePolyfill.cs b/src/Split/net48/ConsolePolyfill.cs index 425364db8..5ad0342de 100644 --- a/src/Split/net48/ConsolePolyfill.cs +++ b/src/Split/net48/ConsolePolyfill.cs @@ -4,6 +4,7 @@ namespace Polyfills; using System; using System.Runtime.InteropServices; +using System.Runtime.CompilerServices; using Microsoft.Win32.SafeHandles; static partial class Polyfill { @@ -12,16 +13,19 @@ static partial class Polyfill /// /// Gets a that wraps the operating system handle for standard input. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static SafeFileHandle OpenStandardInputHandle() => StandardHandleHelper.GetStandardHandle(StandardHandleHelper.StdInput); /// /// Gets a that wraps the operating system handle for standard output. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static SafeFileHandle OpenStandardOutputHandle() => StandardHandleHelper.GetStandardHandle(StandardHandleHelper.StdOutput); /// /// Gets a that wraps the operating system handle for standard error. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static SafeFileHandle OpenStandardErrorHandle() => StandardHandleHelper.GetStandardHandle(StandardHandleHelper.StdError); } diff --git a/src/Split/net48/ConvertPolyfill.cs b/src/Split/net48/ConvertPolyfill.cs index 8ca6da94f..5f80df1f7 100644 --- a/src/Split/net48/ConvertPolyfill.cs +++ b/src/Split/net48/ConvertPolyfill.cs @@ -2,6 +2,7 @@ #pragma warning disable namespace Polyfills; using System; +using System.Runtime.CompilerServices; static partial class Polyfill { extension(Convert) @@ -10,22 +11,26 @@ static partial class Polyfill /// Converts a subset of an array of 8-bit unsigned integers to its equivalent string representation that is encoded with uppercase hex characters. /// Parameters specify the subset as an offset in the input array and the number of elements in the array to convert. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexString(byte[] inArray, int offset, int length) => ToHexString(inArray, offset, length, "X2"); /// /// Converts a subset of an array of 8-bit unsigned integers to its equivalent string representation that is encoded with lowercase hex characters. /// Parameters specify the subset as an offset in the input array and the number of elements in the array to convert. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexStringLower(byte[] inArray, int offset, int length) => ToHexString(inArray, offset, length, "x2"); /// /// Converts an array of 8-bit unsigned integers to its equivalent string representation that is encoded with lowercase hex characters. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexStringLower(byte[] inArray) => Polyfill.ToHexStringLower(inArray, 0, inArray.Length); /// /// Converts an array of 8-bit unsigned integers to its equivalent string representation that is encoded with uppercase hex characters. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexString(byte[] inArray) => Polyfill.ToHexString(inArray, 0, inArray.Length); /// @@ -54,16 +59,19 @@ static int GetHexValue(char hex) => /// /// Converts the span, which encodes binary data as hex characters, to an equivalent 8-bit unsigned integer array. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static byte[] FromHexString(ReadOnlySpan chars) => Polyfill.FromHexString(chars.ToString()); /// /// Converts a span of 8-bit unsigned integers to its equivalent string representation that is encoded with uppercase hex characters. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexString(ReadOnlySpan bytes) => Polyfill.ToHexString(bytes.ToArray()); /// /// Converts a span of 8-bit unsigned integers to its equivalent string representation that is encoded with lowercase hex characters. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexStringLower(ReadOnlySpan bytes) => Polyfill.ToHexStringLower(bytes.ToArray()); /// diff --git a/src/Split/net48/DateTimeOffsetPolyfill.cs b/src/Split/net48/DateTimeOffsetPolyfill.cs index 6837790e5..7bb9a5ad7 100644 --- a/src/Split/net48/DateTimeOffsetPolyfill.cs +++ b/src/Split/net48/DateTimeOffsetPolyfill.cs @@ -4,6 +4,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; static partial class Polyfill { extension(DateTimeOffset target) @@ -30,32 +31,38 @@ long TicksComponent() /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out DateTimeOffset result) => DateTimeOffset.TryParse(s, provider, DateTimeStyles.None, out result); #if FeatureMemory /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out DateTimeOffset result) => DateTimeOffset.TryParse(s.ToString(), provider, DateTimeStyles.None, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan input, out DateTimeOffset result) => DateTimeOffset.TryParse(input.ToString(), null, DateTimeStyles.None, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, DateTimeStyles styles, out DateTimeOffset result) => DateTimeOffset.TryParse(s.ToString(), provider, styles, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParseExact(ReadOnlySpan input, string format, IFormatProvider? provider, DateTimeStyles styles, out DateTimeOffset result) => DateTimeOffset.TryParseExact(input.ToString(), format, provider, styles, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParseExact(ReadOnlySpan input, ReadOnlySpan format, IFormatProvider? provider, DateTimeStyles styles, out DateTimeOffset result) => DateTimeOffset.TryParseExact(input.ToString(), format.ToString(), provider, styles, out result); #endif diff --git a/src/Split/net48/DateTimePolyfill.cs b/src/Split/net48/DateTimePolyfill.cs index 4641f3e59..4d329796a 100644 --- a/src/Split/net48/DateTimePolyfill.cs +++ b/src/Split/net48/DateTimePolyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; static partial class Polyfill { extension(DateTime target) @@ -29,32 +30,38 @@ long TicksComponent() /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out DateTime result) => DateTime.TryParse(s, provider, DateTimeStyles.None, out result); #if FeatureMemory /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out DateTime result) => DateTime.TryParse(s.ToString(), provider, DateTimeStyles.None, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out DateTime result) => DateTime.TryParse(s.ToString(), null, DateTimeStyles.None, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, DateTimeStyles styles, out DateTime result) => DateTime.TryParse(s.ToString(), provider, styles, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParseExact(ReadOnlySpan s, string format, IFormatProvider? provider, DateTimeStyles style, out DateTime result) => DateTime.TryParseExact(s.ToString(), format, provider, style, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParseExact(ReadOnlySpan s, ReadOnlySpan format, IFormatProvider? provider, DateTimeStyles styles, out DateTime result) => DateTime.TryParseExact(s.ToString(), format.ToString(), provider, styles, out result); #endif diff --git a/src/Split/net48/DelegatePolyfill.cs b/src/Split/net48/DelegatePolyfill.cs index effdb1267..59cc5e315 100644 --- a/src/Split/net48/DelegatePolyfill.cs +++ b/src/Split/net48/DelegatePolyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.ComponentModel; +using System.Runtime.CompilerServices; static partial class Polyfill { /// @@ -39,6 +40,7 @@ public bool MoveNext() /// /// Gets an enumerator for the invocation targets of this delegate. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static InvocationListEnumerator EnumerateInvocationList(TDelegate? target) where TDelegate : Delegate => new(target); diff --git a/src/Split/net48/FilePolyfill.cs b/src/Split/net48/FilePolyfill.cs index c6112e74d..66cb81a14 100644 --- a/src/Split/net48/FilePolyfill.cs +++ b/src/Split/net48/FilePolyfill.cs @@ -48,11 +48,13 @@ public static Task AppendAllTextAsync(string path, ReadOnlyMemory contents /// /// Appends the specified string to the file, creating the file if it does not already exist. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void AppendAllText(string path, ReadOnlySpan contents) => File.AppendAllText(path, contents.ToString()); /// /// Appends the specified string to the file, creating the file if it does not already exist. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void AppendAllText(string path, ReadOnlySpan contents, Encoding encoding) => File.AppendAllText(path, contents.ToString(), encoding); /// @@ -76,12 +78,14 @@ public static async Task WriteAllBytesAsync(string path, ReadOnlyMemory by /// Creates a new file, writes the specified string to the file, and then closes the file. /// If the target file already exists, it is truncated and overwritten. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void WriteAllText(string path, ReadOnlySpan contents) => File.WriteAllText(path, contents.ToString()); /// /// Creates a new file, writes the specified string to the file using the specified encoding, and then closes the file. /// If the target file already exists, it is truncated and overwritten. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void WriteAllText(string path, ReadOnlySpan contents, Encoding encoding) => File.WriteAllText(path, contents.ToString(), encoding); /// diff --git a/src/Split/net48/GuidPolyfill.cs b/src/Split/net48/GuidPolyfill.cs index 2bd536736..bc6b9129b 100644 --- a/src/Split/net48/GuidPolyfill.cs +++ b/src/Split/net48/GuidPolyfill.cs @@ -4,6 +4,7 @@ namespace Polyfills; using System.Text; using System; using System.Security.Cryptography; +using System.Runtime.CompilerServices; static partial class Polyfill { extension(Guid) @@ -11,9 +12,11 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out Guid result) => Guid.TryParse(s, out result); /// Creates a new according to RFC 9562, following the Version 7 format. + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Guid CreateVersion7() => CreateVersion7(DateTimeOffset.UtcNow); /// Creates a new according to RFC 9562, following the Version 7 format. public static Guid CreateVersion7(DateTimeOffset timestamp) @@ -40,26 +43,31 @@ public static Guid CreateVersion7(DateTimeOffset timestamp) /// /// Converts span of characters representing the GUID to the equivalent Guid structure, provided that the string is in the specified format. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParseExact(ReadOnlySpan input, ReadOnlySpan format, out Guid result) => Guid.TryParseExact(input.ToString(), format.ToString(), out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out Guid result) => Guid.TryParse(s.ToString(), out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan input, out Guid result) => Guid.TryParse(input.ToString(), out result); /// /// Tries to parse a span of UTF-8 bytes into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out Guid result) => Guid.TryParse(Encoding.UTF8.GetString(utf8Text), out result); /// /// Parse a span of UTF-8 bytes into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Guid Parse(ReadOnlySpan utf8Text) => Guid.Parse(Encoding.UTF8.GetString(utf8Text)); #endif diff --git a/src/Split/net48/KeyValuePair.cs b/src/Split/net48/KeyValuePair.cs index 7e5d58959..e94cbbf2f 100644 --- a/src/Split/net48/KeyValuePair.cs +++ b/src/Split/net48/KeyValuePair.cs @@ -4,6 +4,7 @@ namespace System.Collections.Generic; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; +using System.Runtime.CompilerServices; [ExcludeFromCodeCoverage] [DebuggerNonUserCode] #if PolyUseEmbeddedAttribute @@ -17,6 +18,7 @@ static class KeyValuePair /// /// Creates a new key/value pair instance using provided values. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static KeyValuePair Create(TKey key, TValue value) => new(key, value); } diff --git a/src/Split/net48/Lock.cs b/src/Split/net48/Lock.cs index 94fcf1ff9..36946028c 100644 --- a/src/Split/net48/Lock.cs +++ b/src/Split/net48/Lock.cs @@ -5,6 +5,7 @@ namespace System.Threading; using Diagnostics; using Diagnostics.CodeAnalysis; +using Runtime.CompilerServices; /// /// Provides a way to get mutual exclusion in regions of code between different threads. A lock may be held by one thread at /// a time. @@ -23,26 +24,31 @@ class Lock /// /// Enters the lock. Once the method returns, the calling thread would be the only thread that holds the lock. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Enter() => Monitor.Enter(this); /// /// Tries to enter the lock without waiting. If the lock is entered, the calling thread would be the only thread that /// holds the lock. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool TryEnter() => Monitor.TryEnter(this); /// /// Tries to enter the lock, waiting for roughly the specified duration. If the lock is entered, the calling thread /// would be the only thread that holds the lock. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool TryEnter(TimeSpan timeout) => Monitor.TryEnter(this, timeout); /// /// Tries to enter the lock, waiting for roughly the specified duration. If the lock is entered, the calling thread /// would be the only thread that holds the lock. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool TryEnter(int millisecondsTimeout) => TryEnter(TimeSpan.FromMilliseconds(millisecondsTimeout)); /// /// Exits the lock. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Exit() => Monitor.Exit(this); /// /// Enters the lock and returns a that may be disposed to exit the lock. Once the method returns, diff --git a/src/Split/net48/Numbers/BytePolyfill.cs b/src/Split/net48/Numbers/BytePolyfill.cs index ef3f744ed..0ea017afd 100644 --- a/src/Split/net48/Numbers/BytePolyfill.cs +++ b/src/Split/net48/Numbers/BytePolyfill.cs @@ -4,6 +4,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -12,37 +13,44 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out byte result) => byte.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out byte result) => byte.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out byte result) => byte.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out byte result) => byte.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its byte equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out byte result) => byte.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its byte equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out byte result) => byte.TryParse(s.ToString(), out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its byte equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out byte result) => byte.TryParse(s.ToString(), style, provider, out result); #endif diff --git a/src/Split/net48/Numbers/DoublePolyfill.cs b/src/Split/net48/Numbers/DoublePolyfill.cs index ba5333f69..d903ddfe1 100644 --- a/src/Split/net48/Numbers/DoublePolyfill.cs +++ b/src/Split/net48/Numbers/DoublePolyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,37 +12,44 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out double result) => double.TryParse(s, NumberStyles.Float, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out double result) => double.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Float, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out double result) => double.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its double-precision floating-point number equivalent.. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out double result) => double.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Float, null, out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its double-precision floating-point number equivalent. A return value indicates whether the conversion succeeded or failed. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out double result) => double.TryParse(s.ToString(), out result); /// /// Converts the string representation of a number in a specified style and culture-specific format to its double-precision floating-point number equivalent. A return value indicates whether the conversion succeeded or failed. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out double result) => double.TryParse(s.ToString(), style, provider, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out double result) => double.TryParse(s.ToString(), NumberStyles.Float, provider, out result); #endif diff --git a/src/Split/net48/Numbers/Int16Polyfill.cs b/src/Split/net48/Numbers/Int16Polyfill.cs index 5eb1b384e..960cf68ce 100644 --- a/src/Split/net48/Numbers/Int16Polyfill.cs +++ b/src/Split/net48/Numbers/Int16Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,37 +12,44 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out short result) => short.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out short result) => short.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out short result) => short.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its short equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out short result) => short.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its short equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out short result) => short.TryParse(s.ToString(), out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its short equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out short result) => short.TryParse(s.ToString(), style, provider, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out short result) => short.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/net48/Numbers/Int32Polyfill.cs b/src/Split/net48/Numbers/Int32Polyfill.cs index 549ff1896..2920eae4a 100644 --- a/src/Split/net48/Numbers/Int32Polyfill.cs +++ b/src/Split/net48/Numbers/Int32Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,37 +12,44 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out int result) => int.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out int result) => int.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out int result) => int.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its 32-bit signed integer equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out int result) => int.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its 32-bit signed integer equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out int result) => int.TryParse(s.ToString(), out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its 32-bit signed integer equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out int result) => int.TryParse(s.ToString(), style, provider, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out int result) => int.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/net48/Numbers/Int64Polyfill.cs b/src/Split/net48/Numbers/Int64Polyfill.cs index bd33ce0e6..0b7b1b100 100644 --- a/src/Split/net48/Numbers/Int64Polyfill.cs +++ b/src/Split/net48/Numbers/Int64Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,37 +12,44 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out long result) => long.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out long result) => long.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out long result) => long.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its 64-bit signed integer equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out long result) => long.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its 32-bit signed integer equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out long result) => long.TryParse(s.ToString(), out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its 64-bit signed integer equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out long result) => long.TryParse(s.ToString(), style, provider, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out long result) => long.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/net48/Numbers/SBytePolyfill.cs b/src/Split/net48/Numbers/SBytePolyfill.cs index 974115654..890452b1c 100644 --- a/src/Split/net48/Numbers/SBytePolyfill.cs +++ b/src/Split/net48/Numbers/SBytePolyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,37 +12,44 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out sbyte result) => sbyte.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out sbyte result) => sbyte.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out sbyte result) => sbyte.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its sbyte equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out sbyte result) => sbyte.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its sbyte equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out sbyte result) => sbyte.TryParse(s.ToString(), out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its sbyte equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out sbyte result) => sbyte.TryParse(s.ToString(), style, provider, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out sbyte result) => sbyte.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/net48/Numbers/UInt16Polyfill.cs b/src/Split/net48/Numbers/UInt16Polyfill.cs index 34f39f97c..ed0958805 100644 --- a/src/Split/net48/Numbers/UInt16Polyfill.cs +++ b/src/Split/net48/Numbers/UInt16Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,37 +12,44 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out ushort result) => ushort.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out ushort result) => ushort.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out ushort result) => ushort.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its ushort equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out ushort result) => ushort.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its ushort equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out ushort result) => ushort.TryParse(s.ToString(), out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its ushort equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out ushort result) => ushort.TryParse(s.ToString(), style, provider, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out ushort result) => ushort.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/net48/Numbers/UInt32Polyfill.cs b/src/Split/net48/Numbers/UInt32Polyfill.cs index 859149bed..e11b65c90 100644 --- a/src/Split/net48/Numbers/UInt32Polyfill.cs +++ b/src/Split/net48/Numbers/UInt32Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,37 +12,44 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out uint result) => uint.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out uint result) => uint.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out uint result) => uint.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its uint equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out uint result) => uint.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its uint equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out uint result) => uint.TryParse(s.ToString(), out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its uint equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out uint result) => uint.TryParse(s.ToString(), style, provider, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out uint result) => uint.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/net48/Numbers/UInt64Polyfill.cs b/src/Split/net48/Numbers/UInt64Polyfill.cs index c14bb347c..10122d2b4 100644 --- a/src/Split/net48/Numbers/UInt64Polyfill.cs +++ b/src/Split/net48/Numbers/UInt64Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,37 +12,44 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out ulong result) => ulong.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out ulong result) => ulong.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpanutf8Text, NumberStyles style, IFormatProvider? provider, out ulong result) => ulong.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its ulong equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out ulong result) => ulong.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its ulong equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out ulong result) => ulong.TryParse(s.ToString(), out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its ulong equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out ulong result) => ulong.TryParse(s.ToString(), style, provider, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out ulong result) => ulong.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/net48/OperatingSystemPolyfill.cs b/src/Split/net48/OperatingSystemPolyfill.cs index 5d1f8de36..68413c7d5 100644 --- a/src/Split/net48/OperatingSystemPolyfill.cs +++ b/src/Split/net48/OperatingSystemPolyfill.cs @@ -3,6 +3,7 @@ #if FeatureRuntimeInformation namespace Polyfills; using System; +using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; static partial class Polyfill @@ -14,114 +15,135 @@ static bool IsOsVersionAtLeast(int major, int minor = 0, int build = 0, int revi /// /// Indicates whether the current application is running as WASI. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsWasi() => RuntimeInformation.IsOSPlatform(OSPlatform.Create("WASI")); /// /// Indicates whether the current application is running on Mac Catalyst. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsMacCatalyst() => OperatingSystem.IsMacOS() || OperatingSystem.IsIOS(); /// /// Check for the Mac Catalyst version (iOS version as presented in Apple documentation) with a ≤ version comparison. Used to guard APIs that were added in the given Mac Catalyst release. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsMacCatalystVersionAtLeast(int major, int minor = 0, int build = 0) => IsMacCatalyst() && IsOsVersionAtLeast(major, minor, build); /// /// Checks if the macOS version (returned by libobjc.get_operatingSystemVersion) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified macOS version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsMacOSVersionAtLeast(int major, int minor = 0, int build = 0) => OperatingSystemCache.IsMacOSVersionAtLeast(major, minor, build); /// /// Checks if the FreeBSD version (returned by the Linux command uname) is greater than or equal to the specified version. /// This method can be used to guard APIs that were added in the specified version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsFreeBSDVersionAtLeast(int major, int minor, int build = 0, int revision = 0) => OperatingSystemCache.IsFreeBSDVersionAtLeast(major, minor, build, revision); /// /// Indicates whether the current application is running on Android. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsAndroid() => OperatingSystemCache.IsAndroid(); /// /// Checks if the Android version (returned by the Linux command uname) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsAndroidVersionAtLeast(int major, int minor = 0, int build = 0, int revision = 0) => OperatingSystemCache.IsAndroidVersionAtLeast(major, minor, build, revision); /// /// Checks if the Windows version (returned by RtlGetVersion) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified Windows version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsWindowsVersionAtLeast(int major, int minor = 0, int build = 0, int revision = 0) => OperatingSystemCache.IsWindowsVersionAtLeast(major, minor, build, revision); /// /// Indicates whether the current application is running on the specified platform. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsOSPlatform(string platform) => RuntimeInformation.IsOSPlatform(OSPlatform.Create(platform)); /// /// Checks if the operating system version is greater than or equal to the specified platform version. This method can be used to guard APIs that were added in the specified OS version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsOSPlatformVersionAtLeast(string platform, int major, int minor = 0, int build = 0, int revision = 0) => IsOSPlatform(platform) && IsOsVersionAtLeast(major, minor, build, revision); /// /// Indicates whether the current application is running on Windows. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsWindows() => RuntimeInformation.IsOSPlatform(OSPlatform.Windows); /// /// Indicates whether the current application is running on macOS. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsMacOS() => RuntimeInformation.IsOSPlatform(OSPlatform.OSX); /// /// Indicates whether the current application is running on iOS or MacCatalyst. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsIOS() => RuntimeInformation.IsOSPlatform(OSPlatform.Create("IOS")); /// /// Indicates whether the current application is running on Linux. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsLinux() => RuntimeInformation.IsOSPlatform(OSPlatform.Linux); /// /// Indicates whether the current application is running on FreeBSD. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsFreeBSD() => RuntimeInformation.OSDescription.ToLower().Contains("freebsd"); /// /// Checks if the iOS/MacCatalyst version (returned by libobjc.get_operatingSystemVersion) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified iOS version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsIOSVersionAtLeast(int major, int minor = 0, int build = 0) => IsIOS() && IsOsVersionAtLeast(major, minor, build); /// /// Checks if the tvOS version (returned by libobjc.get_operatingSystemVersion) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified tvOS version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsTvOSVersionAtLeast(int major, int minor = 0, int build = 0) => IsTvOS() && IsOsVersionAtLeast(major, minor, build); /// /// Indicates whether the current application is running on tvOS. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsTvOS() => RuntimeInformation.IsOSPlatform(OSPlatform.Create("TVOS")); /// /// Indicates whether the current application is running on watchOS. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsWatchOS() => IsIOS() || RuntimeInformation.OSDescription.ToLower().Contains("watchos"); /// /// Checks if the watchOS version (returned by libobjc.get_operatingSystemVersion) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified watchOS version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsWatchOSVersionAtLeast(int major, int minor = 0, int build = 0) => IsWatchOS() && IsOsVersionAtLeast(major, minor, build); /// /// Indicates whether the current application is running as WASM in a browser. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsBrowser() => RuntimeInformation.IsOSPlatform(OSPlatform.Create("BROWSER")); } diff --git a/src/Split/net48/PathPolyfill.cs b/src/Split/net48/PathPolyfill.cs index fb4329ac6..fc8009da8 100644 --- a/src/Split/net48/PathPolyfill.cs +++ b/src/Split/net48/PathPolyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.IO; +using System.Runtime.CompilerServices; static partial class Polyfill { extension(Path) @@ -11,41 +12,49 @@ static partial class Polyfill /// /// Returns the directory information for the specified path represented by a character span. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ReadOnlySpan GetDirectoryName(ReadOnlySpan path) => Path.GetDirectoryName(path.ToString()).AsSpan(); /// /// Returns the file name and extension of a file path that is represented by a read-only character span. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ReadOnlySpan GetFileName(ReadOnlySpan path) => Path.GetFileName(path.ToString()).AsSpan(); /// /// Returns the file name without the extension of a file path that is represented by a read-only character span. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ReadOnlySpan GetFileNameWithoutExtension(ReadOnlySpan path) => Path.GetFileNameWithoutExtension(path.ToString()).AsSpan(); /// /// Determines whether the path represented by the specified character span includes a file name extension. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool HasExtension(ReadOnlySpan path) => Path.HasExtension(path.ToString()); /// /// Returns the extension of the given path. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ReadOnlySpan GetExtension(ReadOnlySpan path) => Path.GetExtension(path.ToString()).AsSpan(); /// /// Combines a span of strings into a path. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string Combine(scoped ReadOnlySpan paths) => Path.Combine(paths.ToArray()); /// /// Returns a value that indicates whether the path, specified as a read-only span, ends in a directory separator. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool EndsInDirectorySeparator (ReadOnlySpan path) => EndsInDirectorySeparator(path.ToString()); /// /// Trims one trailing directory separator beyond the root of the specified path. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ReadOnlySpan TrimEndingDirectorySeparator(ReadOnlySpan path) => TrimEndingDirectorySeparator(path.ToString()).AsSpan(); #endif diff --git a/src/Split/net481/ConsolePolyfill.cs b/src/Split/net481/ConsolePolyfill.cs index 425364db8..5ad0342de 100644 --- a/src/Split/net481/ConsolePolyfill.cs +++ b/src/Split/net481/ConsolePolyfill.cs @@ -4,6 +4,7 @@ namespace Polyfills; using System; using System.Runtime.InteropServices; +using System.Runtime.CompilerServices; using Microsoft.Win32.SafeHandles; static partial class Polyfill { @@ -12,16 +13,19 @@ static partial class Polyfill /// /// Gets a that wraps the operating system handle for standard input. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static SafeFileHandle OpenStandardInputHandle() => StandardHandleHelper.GetStandardHandle(StandardHandleHelper.StdInput); /// /// Gets a that wraps the operating system handle for standard output. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static SafeFileHandle OpenStandardOutputHandle() => StandardHandleHelper.GetStandardHandle(StandardHandleHelper.StdOutput); /// /// Gets a that wraps the operating system handle for standard error. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static SafeFileHandle OpenStandardErrorHandle() => StandardHandleHelper.GetStandardHandle(StandardHandleHelper.StdError); } diff --git a/src/Split/net481/ConvertPolyfill.cs b/src/Split/net481/ConvertPolyfill.cs index 8ca6da94f..5f80df1f7 100644 --- a/src/Split/net481/ConvertPolyfill.cs +++ b/src/Split/net481/ConvertPolyfill.cs @@ -2,6 +2,7 @@ #pragma warning disable namespace Polyfills; using System; +using System.Runtime.CompilerServices; static partial class Polyfill { extension(Convert) @@ -10,22 +11,26 @@ static partial class Polyfill /// Converts a subset of an array of 8-bit unsigned integers to its equivalent string representation that is encoded with uppercase hex characters. /// Parameters specify the subset as an offset in the input array and the number of elements in the array to convert. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexString(byte[] inArray, int offset, int length) => ToHexString(inArray, offset, length, "X2"); /// /// Converts a subset of an array of 8-bit unsigned integers to its equivalent string representation that is encoded with lowercase hex characters. /// Parameters specify the subset as an offset in the input array and the number of elements in the array to convert. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexStringLower(byte[] inArray, int offset, int length) => ToHexString(inArray, offset, length, "x2"); /// /// Converts an array of 8-bit unsigned integers to its equivalent string representation that is encoded with lowercase hex characters. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexStringLower(byte[] inArray) => Polyfill.ToHexStringLower(inArray, 0, inArray.Length); /// /// Converts an array of 8-bit unsigned integers to its equivalent string representation that is encoded with uppercase hex characters. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexString(byte[] inArray) => Polyfill.ToHexString(inArray, 0, inArray.Length); /// @@ -54,16 +59,19 @@ static int GetHexValue(char hex) => /// /// Converts the span, which encodes binary data as hex characters, to an equivalent 8-bit unsigned integer array. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static byte[] FromHexString(ReadOnlySpan chars) => Polyfill.FromHexString(chars.ToString()); /// /// Converts a span of 8-bit unsigned integers to its equivalent string representation that is encoded with uppercase hex characters. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexString(ReadOnlySpan bytes) => Polyfill.ToHexString(bytes.ToArray()); /// /// Converts a span of 8-bit unsigned integers to its equivalent string representation that is encoded with lowercase hex characters. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexStringLower(ReadOnlySpan bytes) => Polyfill.ToHexStringLower(bytes.ToArray()); /// diff --git a/src/Split/net481/DateTimeOffsetPolyfill.cs b/src/Split/net481/DateTimeOffsetPolyfill.cs index 6837790e5..7bb9a5ad7 100644 --- a/src/Split/net481/DateTimeOffsetPolyfill.cs +++ b/src/Split/net481/DateTimeOffsetPolyfill.cs @@ -4,6 +4,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; static partial class Polyfill { extension(DateTimeOffset target) @@ -30,32 +31,38 @@ long TicksComponent() /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out DateTimeOffset result) => DateTimeOffset.TryParse(s, provider, DateTimeStyles.None, out result); #if FeatureMemory /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out DateTimeOffset result) => DateTimeOffset.TryParse(s.ToString(), provider, DateTimeStyles.None, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan input, out DateTimeOffset result) => DateTimeOffset.TryParse(input.ToString(), null, DateTimeStyles.None, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, DateTimeStyles styles, out DateTimeOffset result) => DateTimeOffset.TryParse(s.ToString(), provider, styles, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParseExact(ReadOnlySpan input, string format, IFormatProvider? provider, DateTimeStyles styles, out DateTimeOffset result) => DateTimeOffset.TryParseExact(input.ToString(), format, provider, styles, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParseExact(ReadOnlySpan input, ReadOnlySpan format, IFormatProvider? provider, DateTimeStyles styles, out DateTimeOffset result) => DateTimeOffset.TryParseExact(input.ToString(), format.ToString(), provider, styles, out result); #endif diff --git a/src/Split/net481/DateTimePolyfill.cs b/src/Split/net481/DateTimePolyfill.cs index 4641f3e59..4d329796a 100644 --- a/src/Split/net481/DateTimePolyfill.cs +++ b/src/Split/net481/DateTimePolyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; static partial class Polyfill { extension(DateTime target) @@ -29,32 +30,38 @@ long TicksComponent() /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out DateTime result) => DateTime.TryParse(s, provider, DateTimeStyles.None, out result); #if FeatureMemory /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out DateTime result) => DateTime.TryParse(s.ToString(), provider, DateTimeStyles.None, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out DateTime result) => DateTime.TryParse(s.ToString(), null, DateTimeStyles.None, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, DateTimeStyles styles, out DateTime result) => DateTime.TryParse(s.ToString(), provider, styles, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParseExact(ReadOnlySpan s, string format, IFormatProvider? provider, DateTimeStyles style, out DateTime result) => DateTime.TryParseExact(s.ToString(), format, provider, style, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParseExact(ReadOnlySpan s, ReadOnlySpan format, IFormatProvider? provider, DateTimeStyles styles, out DateTime result) => DateTime.TryParseExact(s.ToString(), format.ToString(), provider, styles, out result); #endif diff --git a/src/Split/net481/DelegatePolyfill.cs b/src/Split/net481/DelegatePolyfill.cs index effdb1267..59cc5e315 100644 --- a/src/Split/net481/DelegatePolyfill.cs +++ b/src/Split/net481/DelegatePolyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.ComponentModel; +using System.Runtime.CompilerServices; static partial class Polyfill { /// @@ -39,6 +40,7 @@ public bool MoveNext() /// /// Gets an enumerator for the invocation targets of this delegate. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static InvocationListEnumerator EnumerateInvocationList(TDelegate? target) where TDelegate : Delegate => new(target); diff --git a/src/Split/net481/FilePolyfill.cs b/src/Split/net481/FilePolyfill.cs index c6112e74d..66cb81a14 100644 --- a/src/Split/net481/FilePolyfill.cs +++ b/src/Split/net481/FilePolyfill.cs @@ -48,11 +48,13 @@ public static Task AppendAllTextAsync(string path, ReadOnlyMemory contents /// /// Appends the specified string to the file, creating the file if it does not already exist. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void AppendAllText(string path, ReadOnlySpan contents) => File.AppendAllText(path, contents.ToString()); /// /// Appends the specified string to the file, creating the file if it does not already exist. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void AppendAllText(string path, ReadOnlySpan contents, Encoding encoding) => File.AppendAllText(path, contents.ToString(), encoding); /// @@ -76,12 +78,14 @@ public static async Task WriteAllBytesAsync(string path, ReadOnlyMemory by /// Creates a new file, writes the specified string to the file, and then closes the file. /// If the target file already exists, it is truncated and overwritten. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void WriteAllText(string path, ReadOnlySpan contents) => File.WriteAllText(path, contents.ToString()); /// /// Creates a new file, writes the specified string to the file using the specified encoding, and then closes the file. /// If the target file already exists, it is truncated and overwritten. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void WriteAllText(string path, ReadOnlySpan contents, Encoding encoding) => File.WriteAllText(path, contents.ToString(), encoding); /// diff --git a/src/Split/net481/GuidPolyfill.cs b/src/Split/net481/GuidPolyfill.cs index 2bd536736..bc6b9129b 100644 --- a/src/Split/net481/GuidPolyfill.cs +++ b/src/Split/net481/GuidPolyfill.cs @@ -4,6 +4,7 @@ namespace Polyfills; using System.Text; using System; using System.Security.Cryptography; +using System.Runtime.CompilerServices; static partial class Polyfill { extension(Guid) @@ -11,9 +12,11 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out Guid result) => Guid.TryParse(s, out result); /// Creates a new according to RFC 9562, following the Version 7 format. + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Guid CreateVersion7() => CreateVersion7(DateTimeOffset.UtcNow); /// Creates a new according to RFC 9562, following the Version 7 format. public static Guid CreateVersion7(DateTimeOffset timestamp) @@ -40,26 +43,31 @@ public static Guid CreateVersion7(DateTimeOffset timestamp) /// /// Converts span of characters representing the GUID to the equivalent Guid structure, provided that the string is in the specified format. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParseExact(ReadOnlySpan input, ReadOnlySpan format, out Guid result) => Guid.TryParseExact(input.ToString(), format.ToString(), out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out Guid result) => Guid.TryParse(s.ToString(), out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan input, out Guid result) => Guid.TryParse(input.ToString(), out result); /// /// Tries to parse a span of UTF-8 bytes into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out Guid result) => Guid.TryParse(Encoding.UTF8.GetString(utf8Text), out result); /// /// Parse a span of UTF-8 bytes into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Guid Parse(ReadOnlySpan utf8Text) => Guid.Parse(Encoding.UTF8.GetString(utf8Text)); #endif diff --git a/src/Split/net481/KeyValuePair.cs b/src/Split/net481/KeyValuePair.cs index 7e5d58959..e94cbbf2f 100644 --- a/src/Split/net481/KeyValuePair.cs +++ b/src/Split/net481/KeyValuePair.cs @@ -4,6 +4,7 @@ namespace System.Collections.Generic; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; +using System.Runtime.CompilerServices; [ExcludeFromCodeCoverage] [DebuggerNonUserCode] #if PolyUseEmbeddedAttribute @@ -17,6 +18,7 @@ static class KeyValuePair /// /// Creates a new key/value pair instance using provided values. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static KeyValuePair Create(TKey key, TValue value) => new(key, value); } diff --git a/src/Split/net481/Lock.cs b/src/Split/net481/Lock.cs index 94fcf1ff9..36946028c 100644 --- a/src/Split/net481/Lock.cs +++ b/src/Split/net481/Lock.cs @@ -5,6 +5,7 @@ namespace System.Threading; using Diagnostics; using Diagnostics.CodeAnalysis; +using Runtime.CompilerServices; /// /// Provides a way to get mutual exclusion in regions of code between different threads. A lock may be held by one thread at /// a time. @@ -23,26 +24,31 @@ class Lock /// /// Enters the lock. Once the method returns, the calling thread would be the only thread that holds the lock. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Enter() => Monitor.Enter(this); /// /// Tries to enter the lock without waiting. If the lock is entered, the calling thread would be the only thread that /// holds the lock. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool TryEnter() => Monitor.TryEnter(this); /// /// Tries to enter the lock, waiting for roughly the specified duration. If the lock is entered, the calling thread /// would be the only thread that holds the lock. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool TryEnter(TimeSpan timeout) => Monitor.TryEnter(this, timeout); /// /// Tries to enter the lock, waiting for roughly the specified duration. If the lock is entered, the calling thread /// would be the only thread that holds the lock. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool TryEnter(int millisecondsTimeout) => TryEnter(TimeSpan.FromMilliseconds(millisecondsTimeout)); /// /// Exits the lock. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Exit() => Monitor.Exit(this); /// /// Enters the lock and returns a that may be disposed to exit the lock. Once the method returns, diff --git a/src/Split/net481/Numbers/BytePolyfill.cs b/src/Split/net481/Numbers/BytePolyfill.cs index ef3f744ed..0ea017afd 100644 --- a/src/Split/net481/Numbers/BytePolyfill.cs +++ b/src/Split/net481/Numbers/BytePolyfill.cs @@ -4,6 +4,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -12,37 +13,44 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out byte result) => byte.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out byte result) => byte.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out byte result) => byte.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out byte result) => byte.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its byte equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out byte result) => byte.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its byte equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out byte result) => byte.TryParse(s.ToString(), out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its byte equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out byte result) => byte.TryParse(s.ToString(), style, provider, out result); #endif diff --git a/src/Split/net481/Numbers/DoublePolyfill.cs b/src/Split/net481/Numbers/DoublePolyfill.cs index ba5333f69..d903ddfe1 100644 --- a/src/Split/net481/Numbers/DoublePolyfill.cs +++ b/src/Split/net481/Numbers/DoublePolyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,37 +12,44 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out double result) => double.TryParse(s, NumberStyles.Float, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out double result) => double.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Float, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out double result) => double.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its double-precision floating-point number equivalent.. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out double result) => double.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Float, null, out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its double-precision floating-point number equivalent. A return value indicates whether the conversion succeeded or failed. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out double result) => double.TryParse(s.ToString(), out result); /// /// Converts the string representation of a number in a specified style and culture-specific format to its double-precision floating-point number equivalent. A return value indicates whether the conversion succeeded or failed. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out double result) => double.TryParse(s.ToString(), style, provider, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out double result) => double.TryParse(s.ToString(), NumberStyles.Float, provider, out result); #endif diff --git a/src/Split/net481/Numbers/Int16Polyfill.cs b/src/Split/net481/Numbers/Int16Polyfill.cs index 5eb1b384e..960cf68ce 100644 --- a/src/Split/net481/Numbers/Int16Polyfill.cs +++ b/src/Split/net481/Numbers/Int16Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,37 +12,44 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out short result) => short.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out short result) => short.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out short result) => short.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its short equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out short result) => short.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its short equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out short result) => short.TryParse(s.ToString(), out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its short equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out short result) => short.TryParse(s.ToString(), style, provider, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out short result) => short.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/net481/Numbers/Int32Polyfill.cs b/src/Split/net481/Numbers/Int32Polyfill.cs index 549ff1896..2920eae4a 100644 --- a/src/Split/net481/Numbers/Int32Polyfill.cs +++ b/src/Split/net481/Numbers/Int32Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,37 +12,44 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out int result) => int.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out int result) => int.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out int result) => int.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its 32-bit signed integer equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out int result) => int.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its 32-bit signed integer equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out int result) => int.TryParse(s.ToString(), out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its 32-bit signed integer equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out int result) => int.TryParse(s.ToString(), style, provider, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out int result) => int.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/net481/Numbers/Int64Polyfill.cs b/src/Split/net481/Numbers/Int64Polyfill.cs index bd33ce0e6..0b7b1b100 100644 --- a/src/Split/net481/Numbers/Int64Polyfill.cs +++ b/src/Split/net481/Numbers/Int64Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,37 +12,44 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out long result) => long.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out long result) => long.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out long result) => long.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its 64-bit signed integer equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out long result) => long.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its 32-bit signed integer equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out long result) => long.TryParse(s.ToString(), out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its 64-bit signed integer equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out long result) => long.TryParse(s.ToString(), style, provider, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out long result) => long.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/net481/Numbers/SBytePolyfill.cs b/src/Split/net481/Numbers/SBytePolyfill.cs index 974115654..890452b1c 100644 --- a/src/Split/net481/Numbers/SBytePolyfill.cs +++ b/src/Split/net481/Numbers/SBytePolyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,37 +12,44 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out sbyte result) => sbyte.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out sbyte result) => sbyte.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out sbyte result) => sbyte.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its sbyte equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out sbyte result) => sbyte.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its sbyte equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out sbyte result) => sbyte.TryParse(s.ToString(), out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its sbyte equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out sbyte result) => sbyte.TryParse(s.ToString(), style, provider, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out sbyte result) => sbyte.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/net481/Numbers/UInt16Polyfill.cs b/src/Split/net481/Numbers/UInt16Polyfill.cs index 34f39f97c..ed0958805 100644 --- a/src/Split/net481/Numbers/UInt16Polyfill.cs +++ b/src/Split/net481/Numbers/UInt16Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,37 +12,44 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out ushort result) => ushort.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out ushort result) => ushort.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out ushort result) => ushort.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its ushort equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out ushort result) => ushort.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its ushort equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out ushort result) => ushort.TryParse(s.ToString(), out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its ushort equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out ushort result) => ushort.TryParse(s.ToString(), style, provider, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out ushort result) => ushort.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/net481/Numbers/UInt32Polyfill.cs b/src/Split/net481/Numbers/UInt32Polyfill.cs index 859149bed..e11b65c90 100644 --- a/src/Split/net481/Numbers/UInt32Polyfill.cs +++ b/src/Split/net481/Numbers/UInt32Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,37 +12,44 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out uint result) => uint.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out uint result) => uint.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out uint result) => uint.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its uint equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out uint result) => uint.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its uint equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out uint result) => uint.TryParse(s.ToString(), out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its uint equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out uint result) => uint.TryParse(s.ToString(), style, provider, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out uint result) => uint.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/net481/Numbers/UInt64Polyfill.cs b/src/Split/net481/Numbers/UInt64Polyfill.cs index c14bb347c..10122d2b4 100644 --- a/src/Split/net481/Numbers/UInt64Polyfill.cs +++ b/src/Split/net481/Numbers/UInt64Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,37 +12,44 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out ulong result) => ulong.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out ulong result) => ulong.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpanutf8Text, NumberStyles style, IFormatProvider? provider, out ulong result) => ulong.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its ulong equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out ulong result) => ulong.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its ulong equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out ulong result) => ulong.TryParse(s.ToString(), out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its ulong equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out ulong result) => ulong.TryParse(s.ToString(), style, provider, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out ulong result) => ulong.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/net481/OperatingSystemPolyfill.cs b/src/Split/net481/OperatingSystemPolyfill.cs index 5d1f8de36..68413c7d5 100644 --- a/src/Split/net481/OperatingSystemPolyfill.cs +++ b/src/Split/net481/OperatingSystemPolyfill.cs @@ -3,6 +3,7 @@ #if FeatureRuntimeInformation namespace Polyfills; using System; +using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; static partial class Polyfill @@ -14,114 +15,135 @@ static bool IsOsVersionAtLeast(int major, int minor = 0, int build = 0, int revi /// /// Indicates whether the current application is running as WASI. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsWasi() => RuntimeInformation.IsOSPlatform(OSPlatform.Create("WASI")); /// /// Indicates whether the current application is running on Mac Catalyst. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsMacCatalyst() => OperatingSystem.IsMacOS() || OperatingSystem.IsIOS(); /// /// Check for the Mac Catalyst version (iOS version as presented in Apple documentation) with a ≤ version comparison. Used to guard APIs that were added in the given Mac Catalyst release. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsMacCatalystVersionAtLeast(int major, int minor = 0, int build = 0) => IsMacCatalyst() && IsOsVersionAtLeast(major, minor, build); /// /// Checks if the macOS version (returned by libobjc.get_operatingSystemVersion) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified macOS version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsMacOSVersionAtLeast(int major, int minor = 0, int build = 0) => OperatingSystemCache.IsMacOSVersionAtLeast(major, minor, build); /// /// Checks if the FreeBSD version (returned by the Linux command uname) is greater than or equal to the specified version. /// This method can be used to guard APIs that were added in the specified version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsFreeBSDVersionAtLeast(int major, int minor, int build = 0, int revision = 0) => OperatingSystemCache.IsFreeBSDVersionAtLeast(major, minor, build, revision); /// /// Indicates whether the current application is running on Android. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsAndroid() => OperatingSystemCache.IsAndroid(); /// /// Checks if the Android version (returned by the Linux command uname) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsAndroidVersionAtLeast(int major, int minor = 0, int build = 0, int revision = 0) => OperatingSystemCache.IsAndroidVersionAtLeast(major, minor, build, revision); /// /// Checks if the Windows version (returned by RtlGetVersion) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified Windows version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsWindowsVersionAtLeast(int major, int minor = 0, int build = 0, int revision = 0) => OperatingSystemCache.IsWindowsVersionAtLeast(major, minor, build, revision); /// /// Indicates whether the current application is running on the specified platform. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsOSPlatform(string platform) => RuntimeInformation.IsOSPlatform(OSPlatform.Create(platform)); /// /// Checks if the operating system version is greater than or equal to the specified platform version. This method can be used to guard APIs that were added in the specified OS version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsOSPlatformVersionAtLeast(string platform, int major, int minor = 0, int build = 0, int revision = 0) => IsOSPlatform(platform) && IsOsVersionAtLeast(major, minor, build, revision); /// /// Indicates whether the current application is running on Windows. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsWindows() => RuntimeInformation.IsOSPlatform(OSPlatform.Windows); /// /// Indicates whether the current application is running on macOS. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsMacOS() => RuntimeInformation.IsOSPlatform(OSPlatform.OSX); /// /// Indicates whether the current application is running on iOS or MacCatalyst. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsIOS() => RuntimeInformation.IsOSPlatform(OSPlatform.Create("IOS")); /// /// Indicates whether the current application is running on Linux. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsLinux() => RuntimeInformation.IsOSPlatform(OSPlatform.Linux); /// /// Indicates whether the current application is running on FreeBSD. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsFreeBSD() => RuntimeInformation.OSDescription.ToLower().Contains("freebsd"); /// /// Checks if the iOS/MacCatalyst version (returned by libobjc.get_operatingSystemVersion) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified iOS version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsIOSVersionAtLeast(int major, int minor = 0, int build = 0) => IsIOS() && IsOsVersionAtLeast(major, minor, build); /// /// Checks if the tvOS version (returned by libobjc.get_operatingSystemVersion) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified tvOS version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsTvOSVersionAtLeast(int major, int minor = 0, int build = 0) => IsTvOS() && IsOsVersionAtLeast(major, minor, build); /// /// Indicates whether the current application is running on tvOS. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsTvOS() => RuntimeInformation.IsOSPlatform(OSPlatform.Create("TVOS")); /// /// Indicates whether the current application is running on watchOS. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsWatchOS() => IsIOS() || RuntimeInformation.OSDescription.ToLower().Contains("watchos"); /// /// Checks if the watchOS version (returned by libobjc.get_operatingSystemVersion) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified watchOS version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsWatchOSVersionAtLeast(int major, int minor = 0, int build = 0) => IsWatchOS() && IsOsVersionAtLeast(major, minor, build); /// /// Indicates whether the current application is running as WASM in a browser. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsBrowser() => RuntimeInformation.IsOSPlatform(OSPlatform.Create("BROWSER")); } diff --git a/src/Split/net481/PathPolyfill.cs b/src/Split/net481/PathPolyfill.cs index fb4329ac6..fc8009da8 100644 --- a/src/Split/net481/PathPolyfill.cs +++ b/src/Split/net481/PathPolyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.IO; +using System.Runtime.CompilerServices; static partial class Polyfill { extension(Path) @@ -11,41 +12,49 @@ static partial class Polyfill /// /// Returns the directory information for the specified path represented by a character span. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ReadOnlySpan GetDirectoryName(ReadOnlySpan path) => Path.GetDirectoryName(path.ToString()).AsSpan(); /// /// Returns the file name and extension of a file path that is represented by a read-only character span. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ReadOnlySpan GetFileName(ReadOnlySpan path) => Path.GetFileName(path.ToString()).AsSpan(); /// /// Returns the file name without the extension of a file path that is represented by a read-only character span. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ReadOnlySpan GetFileNameWithoutExtension(ReadOnlySpan path) => Path.GetFileNameWithoutExtension(path.ToString()).AsSpan(); /// /// Determines whether the path represented by the specified character span includes a file name extension. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool HasExtension(ReadOnlySpan path) => Path.HasExtension(path.ToString()); /// /// Returns the extension of the given path. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ReadOnlySpan GetExtension(ReadOnlySpan path) => Path.GetExtension(path.ToString()).AsSpan(); /// /// Combines a span of strings into a path. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string Combine(scoped ReadOnlySpan paths) => Path.Combine(paths.ToArray()); /// /// Returns a value that indicates whether the path, specified as a read-only span, ends in a directory separator. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool EndsInDirectorySeparator (ReadOnlySpan path) => EndsInDirectorySeparator(path.ToString()); /// /// Trims one trailing directory separator beyond the root of the specified path. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ReadOnlySpan TrimEndingDirectorySeparator(ReadOnlySpan path) => TrimEndingDirectorySeparator(path.ToString()).AsSpan(); #endif diff --git a/src/Split/net5.0/ConsolePolyfill.cs b/src/Split/net5.0/ConsolePolyfill.cs index 425364db8..5ad0342de 100644 --- a/src/Split/net5.0/ConsolePolyfill.cs +++ b/src/Split/net5.0/ConsolePolyfill.cs @@ -4,6 +4,7 @@ namespace Polyfills; using System; using System.Runtime.InteropServices; +using System.Runtime.CompilerServices; using Microsoft.Win32.SafeHandles; static partial class Polyfill { @@ -12,16 +13,19 @@ static partial class Polyfill /// /// Gets a that wraps the operating system handle for standard input. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static SafeFileHandle OpenStandardInputHandle() => StandardHandleHelper.GetStandardHandle(StandardHandleHelper.StdInput); /// /// Gets a that wraps the operating system handle for standard output. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static SafeFileHandle OpenStandardOutputHandle() => StandardHandleHelper.GetStandardHandle(StandardHandleHelper.StdOutput); /// /// Gets a that wraps the operating system handle for standard error. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static SafeFileHandle OpenStandardErrorHandle() => StandardHandleHelper.GetStandardHandle(StandardHandleHelper.StdError); } diff --git a/src/Split/net5.0/ConvertPolyfill.cs b/src/Split/net5.0/ConvertPolyfill.cs index 2ba95a78e..0744e77df 100644 --- a/src/Split/net5.0/ConvertPolyfill.cs +++ b/src/Split/net5.0/ConvertPolyfill.cs @@ -2,6 +2,7 @@ #pragma warning disable namespace Polyfills; using System; +using System.Runtime.CompilerServices; static partial class Polyfill { extension(Convert) @@ -10,17 +11,20 @@ static partial class Polyfill /// Converts a subset of an array of 8-bit unsigned integers to its equivalent string representation that is encoded with lowercase hex characters. /// Parameters specify the subset as an offset in the input array and the number of elements in the array to convert. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexStringLower(byte[] inArray, int offset, int length) => ToHexString(inArray, offset, length, "x2"); /// /// Converts an array of 8-bit unsigned integers to its equivalent string representation that is encoded with lowercase hex characters. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexStringLower(byte[] inArray) => Polyfill.ToHexStringLower(inArray, 0, inArray.Length); #if FeatureMemory /// /// Converts a span of 8-bit unsigned integers to its equivalent string representation that is encoded with lowercase hex characters. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexStringLower(ReadOnlySpan bytes) => Polyfill.ToHexStringLower(bytes.ToArray()); /// diff --git a/src/Split/net5.0/DateTimeOffsetPolyfill.cs b/src/Split/net5.0/DateTimeOffsetPolyfill.cs index 15ba54f72..add60f3ab 100644 --- a/src/Split/net5.0/DateTimeOffsetPolyfill.cs +++ b/src/Split/net5.0/DateTimeOffsetPolyfill.cs @@ -4,6 +4,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; static partial class Polyfill { extension(DateTimeOffset target) @@ -30,12 +31,14 @@ long TicksComponent() /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out DateTimeOffset result) => DateTimeOffset.TryParse(s, provider, DateTimeStyles.None, out result); #if FeatureMemory /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out DateTimeOffset result) => DateTimeOffset.TryParse(s.ToString(), provider, DateTimeStyles.None, out result); #endif diff --git a/src/Split/net5.0/DateTimePolyfill.cs b/src/Split/net5.0/DateTimePolyfill.cs index 8eb8c705b..29ae6c626 100644 --- a/src/Split/net5.0/DateTimePolyfill.cs +++ b/src/Split/net5.0/DateTimePolyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; static partial class Polyfill { extension(DateTime target) @@ -29,17 +30,20 @@ long TicksComponent() /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out DateTime result) => DateTime.TryParse(s, provider, DateTimeStyles.None, out result); #if FeatureMemory /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out DateTime result) => DateTime.TryParse(s.ToString(), provider, DateTimeStyles.None, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParseExact(ReadOnlySpan s, ReadOnlySpan format, IFormatProvider? provider, DateTimeStyles styles, out DateTime result) => DateTime.TryParseExact(s.ToString(), format.ToString(), provider, styles, out result); #endif diff --git a/src/Split/net5.0/DelegatePolyfill.cs b/src/Split/net5.0/DelegatePolyfill.cs index effdb1267..59cc5e315 100644 --- a/src/Split/net5.0/DelegatePolyfill.cs +++ b/src/Split/net5.0/DelegatePolyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.ComponentModel; +using System.Runtime.CompilerServices; static partial class Polyfill { /// @@ -39,6 +40,7 @@ public bool MoveNext() /// /// Gets an enumerator for the invocation targets of this delegate. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static InvocationListEnumerator EnumerateInvocationList(TDelegate? target) where TDelegate : Delegate => new(target); diff --git a/src/Split/net5.0/FilePolyfill.cs b/src/Split/net5.0/FilePolyfill.cs index ff68c4d3c..66d68b0ad 100644 --- a/src/Split/net5.0/FilePolyfill.cs +++ b/src/Split/net5.0/FilePolyfill.cs @@ -48,11 +48,13 @@ public static Task AppendAllTextAsync(string path, ReadOnlyMemory contents /// /// Appends the specified string to the file, creating the file if it does not already exist. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void AppendAllText(string path, ReadOnlySpan contents) => File.AppendAllText(path, contents.ToString()); /// /// Appends the specified string to the file, creating the file if it does not already exist. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void AppendAllText(string path, ReadOnlySpan contents, Encoding encoding) => File.AppendAllText(path, contents.ToString(), encoding); /// @@ -76,12 +78,14 @@ public static async Task WriteAllBytesAsync(string path, ReadOnlyMemory by /// Creates a new file, writes the specified string to the file, and then closes the file. /// If the target file already exists, it is truncated and overwritten. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void WriteAllText(string path, ReadOnlySpan contents) => File.WriteAllText(path, contents.ToString()); /// /// Creates a new file, writes the specified string to the file using the specified encoding, and then closes the file. /// If the target file already exists, it is truncated and overwritten. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void WriteAllText(string path, ReadOnlySpan contents, Encoding encoding) => File.WriteAllText(path, contents.ToString(), encoding); /// diff --git a/src/Split/net5.0/GuidPolyfill.cs b/src/Split/net5.0/GuidPolyfill.cs index c61f69729..44d9c654c 100644 --- a/src/Split/net5.0/GuidPolyfill.cs +++ b/src/Split/net5.0/GuidPolyfill.cs @@ -4,6 +4,7 @@ namespace Polyfills; using System.Text; using System; using System.Security.Cryptography; +using System.Runtime.CompilerServices; static partial class Polyfill { extension(Guid) @@ -11,9 +12,11 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out Guid result) => Guid.TryParse(s, out result); /// Creates a new according to RFC 9562, following the Version 7 format. + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Guid CreateVersion7() => CreateVersion7(DateTimeOffset.UtcNow); /// Creates a new according to RFC 9562, following the Version 7 format. public static Guid CreateVersion7(DateTimeOffset timestamp) @@ -40,16 +43,19 @@ public static Guid CreateVersion7(DateTimeOffset timestamp) /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out Guid result) => Guid.TryParse(s.ToString(), out result); /// /// Tries to parse a span of UTF-8 bytes into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out Guid result) => Guid.TryParse(Encoding.UTF8.GetString(utf8Text), out result); /// /// Parse a span of UTF-8 bytes into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Guid Parse(ReadOnlySpan utf8Text) => Guid.Parse(Encoding.UTF8.GetString(utf8Text)); #endif diff --git a/src/Split/net5.0/Lock.cs b/src/Split/net5.0/Lock.cs index 94fcf1ff9..36946028c 100644 --- a/src/Split/net5.0/Lock.cs +++ b/src/Split/net5.0/Lock.cs @@ -5,6 +5,7 @@ namespace System.Threading; using Diagnostics; using Diagnostics.CodeAnalysis; +using Runtime.CompilerServices; /// /// Provides a way to get mutual exclusion in regions of code between different threads. A lock may be held by one thread at /// a time. @@ -23,26 +24,31 @@ class Lock /// /// Enters the lock. Once the method returns, the calling thread would be the only thread that holds the lock. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Enter() => Monitor.Enter(this); /// /// Tries to enter the lock without waiting. If the lock is entered, the calling thread would be the only thread that /// holds the lock. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool TryEnter() => Monitor.TryEnter(this); /// /// Tries to enter the lock, waiting for roughly the specified duration. If the lock is entered, the calling thread /// would be the only thread that holds the lock. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool TryEnter(TimeSpan timeout) => Monitor.TryEnter(this, timeout); /// /// Tries to enter the lock, waiting for roughly the specified duration. If the lock is entered, the calling thread /// would be the only thread that holds the lock. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool TryEnter(int millisecondsTimeout) => TryEnter(TimeSpan.FromMilliseconds(millisecondsTimeout)); /// /// Exits the lock. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Exit() => Monitor.Exit(this); /// /// Enters the lock and returns a that may be disposed to exit the lock. Once the method returns, diff --git a/src/Split/net5.0/Numbers/BytePolyfill.cs b/src/Split/net5.0/Numbers/BytePolyfill.cs index b32351497..fd1d5aa6f 100644 --- a/src/Split/net5.0/Numbers/BytePolyfill.cs +++ b/src/Split/net5.0/Numbers/BytePolyfill.cs @@ -4,6 +4,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -12,27 +13,32 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out byte result) => byte.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out byte result) => byte.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out byte result) => byte.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out byte result) => byte.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its byte equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out byte result) => byte.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); #endif diff --git a/src/Split/net5.0/Numbers/DoublePolyfill.cs b/src/Split/net5.0/Numbers/DoublePolyfill.cs index ff9f8aca6..94b44e869 100644 --- a/src/Split/net5.0/Numbers/DoublePolyfill.cs +++ b/src/Split/net5.0/Numbers/DoublePolyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,27 +12,32 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out double result) => double.TryParse(s, NumberStyles.Float, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out double result) => double.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Float, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out double result) => double.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its double-precision floating-point number equivalent.. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out double result) => double.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Float, null, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out double result) => double.TryParse(s.ToString(), NumberStyles.Float, provider, out result); #endif diff --git a/src/Split/net5.0/Numbers/Int16Polyfill.cs b/src/Split/net5.0/Numbers/Int16Polyfill.cs index 7a1f0b7c0..4447a9ecf 100644 --- a/src/Split/net5.0/Numbers/Int16Polyfill.cs +++ b/src/Split/net5.0/Numbers/Int16Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,27 +12,32 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out short result) => short.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out short result) => short.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out short result) => short.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its short equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out short result) => short.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out short result) => short.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/net5.0/Numbers/Int32Polyfill.cs b/src/Split/net5.0/Numbers/Int32Polyfill.cs index 853dfb518..587b2be91 100644 --- a/src/Split/net5.0/Numbers/Int32Polyfill.cs +++ b/src/Split/net5.0/Numbers/Int32Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,27 +12,32 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out int result) => int.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out int result) => int.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out int result) => int.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its 32-bit signed integer equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out int result) => int.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out int result) => int.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/net5.0/Numbers/Int64Polyfill.cs b/src/Split/net5.0/Numbers/Int64Polyfill.cs index e97be4775..3d7b5c57f 100644 --- a/src/Split/net5.0/Numbers/Int64Polyfill.cs +++ b/src/Split/net5.0/Numbers/Int64Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,27 +12,32 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out long result) => long.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out long result) => long.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out long result) => long.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its 64-bit signed integer equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out long result) => long.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out long result) => long.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/net5.0/Numbers/SBytePolyfill.cs b/src/Split/net5.0/Numbers/SBytePolyfill.cs index 9085c3aec..8de2ac072 100644 --- a/src/Split/net5.0/Numbers/SBytePolyfill.cs +++ b/src/Split/net5.0/Numbers/SBytePolyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,27 +12,32 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out sbyte result) => sbyte.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out sbyte result) => sbyte.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out sbyte result) => sbyte.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its sbyte equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out sbyte result) => sbyte.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out sbyte result) => sbyte.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/net5.0/Numbers/UInt16Polyfill.cs b/src/Split/net5.0/Numbers/UInt16Polyfill.cs index 11d4c4ed7..b3b68b25f 100644 --- a/src/Split/net5.0/Numbers/UInt16Polyfill.cs +++ b/src/Split/net5.0/Numbers/UInt16Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,27 +12,32 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out ushort result) => ushort.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out ushort result) => ushort.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out ushort result) => ushort.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its ushort equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out ushort result) => ushort.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out ushort result) => ushort.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/net5.0/Numbers/UInt32Polyfill.cs b/src/Split/net5.0/Numbers/UInt32Polyfill.cs index abdf707dd..4ba985db3 100644 --- a/src/Split/net5.0/Numbers/UInt32Polyfill.cs +++ b/src/Split/net5.0/Numbers/UInt32Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,27 +12,32 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out uint result) => uint.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out uint result) => uint.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out uint result) => uint.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its uint equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out uint result) => uint.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out uint result) => uint.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/net5.0/Numbers/UInt64Polyfill.cs b/src/Split/net5.0/Numbers/UInt64Polyfill.cs index 1a1bc228c..08e8b0fad 100644 --- a/src/Split/net5.0/Numbers/UInt64Polyfill.cs +++ b/src/Split/net5.0/Numbers/UInt64Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,27 +12,32 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out ulong result) => ulong.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out ulong result) => ulong.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpanutf8Text, NumberStyles style, IFormatProvider? provider, out ulong result) => ulong.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its ulong equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out ulong result) => ulong.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out ulong result) => ulong.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/net5.0/OperatingSystemPolyfill.cs b/src/Split/net5.0/OperatingSystemPolyfill.cs index ebb874fff..c995c6bec 100644 --- a/src/Split/net5.0/OperatingSystemPolyfill.cs +++ b/src/Split/net5.0/OperatingSystemPolyfill.cs @@ -3,6 +3,7 @@ #if FeatureRuntimeInformation namespace Polyfills; using System; +using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; static partial class Polyfill @@ -14,17 +15,20 @@ static bool IsOsVersionAtLeast(int major, int minor = 0, int build = 0, int revi /// /// Indicates whether the current application is running as WASI. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsWasi() => RuntimeInformation.IsOSPlatform(OSPlatform.Create("WASI")); /// /// Indicates whether the current application is running on Mac Catalyst. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsMacCatalyst() => OperatingSystem.IsMacOS() || OperatingSystem.IsIOS(); /// /// Check for the Mac Catalyst version (iOS version as presented in Apple documentation) with a ≤ version comparison. Used to guard APIs that were added in the given Mac Catalyst release. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsMacCatalystVersionAtLeast(int major, int minor = 0, int build = 0) => IsMacCatalyst() && IsOsVersionAtLeast(major, minor, build); diff --git a/src/Split/net5.0/PathPolyfill.cs b/src/Split/net5.0/PathPolyfill.cs index 268c89cfc..39af87506 100644 --- a/src/Split/net5.0/PathPolyfill.cs +++ b/src/Split/net5.0/PathPolyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.IO; +using System.Runtime.CompilerServices; static partial class Polyfill { extension(Path) @@ -11,6 +12,7 @@ static partial class Polyfill /// /// Combines a span of strings into a path. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string Combine(scoped ReadOnlySpan paths) => Path.Combine(paths.ToArray()); #endif diff --git a/src/Split/net6.0/ConsolePolyfill.cs b/src/Split/net6.0/ConsolePolyfill.cs index 425364db8..5ad0342de 100644 --- a/src/Split/net6.0/ConsolePolyfill.cs +++ b/src/Split/net6.0/ConsolePolyfill.cs @@ -4,6 +4,7 @@ namespace Polyfills; using System; using System.Runtime.InteropServices; +using System.Runtime.CompilerServices; using Microsoft.Win32.SafeHandles; static partial class Polyfill { @@ -12,16 +13,19 @@ static partial class Polyfill /// /// Gets a that wraps the operating system handle for standard input. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static SafeFileHandle OpenStandardInputHandle() => StandardHandleHelper.GetStandardHandle(StandardHandleHelper.StdInput); /// /// Gets a that wraps the operating system handle for standard output. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static SafeFileHandle OpenStandardOutputHandle() => StandardHandleHelper.GetStandardHandle(StandardHandleHelper.StdOutput); /// /// Gets a that wraps the operating system handle for standard error. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static SafeFileHandle OpenStandardErrorHandle() => StandardHandleHelper.GetStandardHandle(StandardHandleHelper.StdError); } diff --git a/src/Split/net6.0/ConvertPolyfill.cs b/src/Split/net6.0/ConvertPolyfill.cs index 2ba95a78e..0744e77df 100644 --- a/src/Split/net6.0/ConvertPolyfill.cs +++ b/src/Split/net6.0/ConvertPolyfill.cs @@ -2,6 +2,7 @@ #pragma warning disable namespace Polyfills; using System; +using System.Runtime.CompilerServices; static partial class Polyfill { extension(Convert) @@ -10,17 +11,20 @@ static partial class Polyfill /// Converts a subset of an array of 8-bit unsigned integers to its equivalent string representation that is encoded with lowercase hex characters. /// Parameters specify the subset as an offset in the input array and the number of elements in the array to convert. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexStringLower(byte[] inArray, int offset, int length) => ToHexString(inArray, offset, length, "x2"); /// /// Converts an array of 8-bit unsigned integers to its equivalent string representation that is encoded with lowercase hex characters. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexStringLower(byte[] inArray) => Polyfill.ToHexStringLower(inArray, 0, inArray.Length); #if FeatureMemory /// /// Converts a span of 8-bit unsigned integers to its equivalent string representation that is encoded with lowercase hex characters. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexStringLower(ReadOnlySpan bytes) => Polyfill.ToHexStringLower(bytes.ToArray()); /// diff --git a/src/Split/net6.0/DateTimeOffsetPolyfill.cs b/src/Split/net6.0/DateTimeOffsetPolyfill.cs index 15ba54f72..add60f3ab 100644 --- a/src/Split/net6.0/DateTimeOffsetPolyfill.cs +++ b/src/Split/net6.0/DateTimeOffsetPolyfill.cs @@ -4,6 +4,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; static partial class Polyfill { extension(DateTimeOffset target) @@ -30,12 +31,14 @@ long TicksComponent() /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out DateTimeOffset result) => DateTimeOffset.TryParse(s, provider, DateTimeStyles.None, out result); #if FeatureMemory /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out DateTimeOffset result) => DateTimeOffset.TryParse(s.ToString(), provider, DateTimeStyles.None, out result); #endif diff --git a/src/Split/net6.0/DateTimePolyfill.cs b/src/Split/net6.0/DateTimePolyfill.cs index 8eb8c705b..29ae6c626 100644 --- a/src/Split/net6.0/DateTimePolyfill.cs +++ b/src/Split/net6.0/DateTimePolyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; static partial class Polyfill { extension(DateTime target) @@ -29,17 +30,20 @@ long TicksComponent() /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out DateTime result) => DateTime.TryParse(s, provider, DateTimeStyles.None, out result); #if FeatureMemory /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out DateTime result) => DateTime.TryParse(s.ToString(), provider, DateTimeStyles.None, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParseExact(ReadOnlySpan s, ReadOnlySpan format, IFormatProvider? provider, DateTimeStyles styles, out DateTime result) => DateTime.TryParseExact(s.ToString(), format.ToString(), provider, styles, out result); #endif diff --git a/src/Split/net6.0/DelegatePolyfill.cs b/src/Split/net6.0/DelegatePolyfill.cs index effdb1267..59cc5e315 100644 --- a/src/Split/net6.0/DelegatePolyfill.cs +++ b/src/Split/net6.0/DelegatePolyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.ComponentModel; +using System.Runtime.CompilerServices; static partial class Polyfill { /// @@ -39,6 +40,7 @@ public bool MoveNext() /// /// Gets an enumerator for the invocation targets of this delegate. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static InvocationListEnumerator EnumerateInvocationList(TDelegate? target) where TDelegate : Delegate => new(target); diff --git a/src/Split/net6.0/FilePolyfill.cs b/src/Split/net6.0/FilePolyfill.cs index 87911de48..376bbc2be 100644 --- a/src/Split/net6.0/FilePolyfill.cs +++ b/src/Split/net6.0/FilePolyfill.cs @@ -48,11 +48,13 @@ public static Task AppendAllTextAsync(string path, ReadOnlyMemory contents /// /// Appends the specified string to the file, creating the file if it does not already exist. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void AppendAllText(string path, ReadOnlySpan contents) => File.AppendAllText(path, contents.ToString()); /// /// Appends the specified string to the file, creating the file if it does not already exist. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void AppendAllText(string path, ReadOnlySpan contents, Encoding encoding) => File.AppendAllText(path, contents.ToString(), encoding); /// @@ -76,12 +78,14 @@ public static async Task WriteAllBytesAsync(string path, ReadOnlyMemory by /// Creates a new file, writes the specified string to the file, and then closes the file. /// If the target file already exists, it is truncated and overwritten. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void WriteAllText(string path, ReadOnlySpan contents) => File.WriteAllText(path, contents.ToString()); /// /// Creates a new file, writes the specified string to the file using the specified encoding, and then closes the file. /// If the target file already exists, it is truncated and overwritten. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void WriteAllText(string path, ReadOnlySpan contents, Encoding encoding) => File.WriteAllText(path, contents.ToString(), encoding); /// diff --git a/src/Split/net6.0/GuidPolyfill.cs b/src/Split/net6.0/GuidPolyfill.cs index c61f69729..44d9c654c 100644 --- a/src/Split/net6.0/GuidPolyfill.cs +++ b/src/Split/net6.0/GuidPolyfill.cs @@ -4,6 +4,7 @@ namespace Polyfills; using System.Text; using System; using System.Security.Cryptography; +using System.Runtime.CompilerServices; static partial class Polyfill { extension(Guid) @@ -11,9 +12,11 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out Guid result) => Guid.TryParse(s, out result); /// Creates a new according to RFC 9562, following the Version 7 format. + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Guid CreateVersion7() => CreateVersion7(DateTimeOffset.UtcNow); /// Creates a new according to RFC 9562, following the Version 7 format. public static Guid CreateVersion7(DateTimeOffset timestamp) @@ -40,16 +43,19 @@ public static Guid CreateVersion7(DateTimeOffset timestamp) /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out Guid result) => Guid.TryParse(s.ToString(), out result); /// /// Tries to parse a span of UTF-8 bytes into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out Guid result) => Guid.TryParse(Encoding.UTF8.GetString(utf8Text), out result); /// /// Parse a span of UTF-8 bytes into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Guid Parse(ReadOnlySpan utf8Text) => Guid.Parse(Encoding.UTF8.GetString(utf8Text)); #endif diff --git a/src/Split/net6.0/Lock.cs b/src/Split/net6.0/Lock.cs index 94fcf1ff9..36946028c 100644 --- a/src/Split/net6.0/Lock.cs +++ b/src/Split/net6.0/Lock.cs @@ -5,6 +5,7 @@ namespace System.Threading; using Diagnostics; using Diagnostics.CodeAnalysis; +using Runtime.CompilerServices; /// /// Provides a way to get mutual exclusion in regions of code between different threads. A lock may be held by one thread at /// a time. @@ -23,26 +24,31 @@ class Lock /// /// Enters the lock. Once the method returns, the calling thread would be the only thread that holds the lock. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Enter() => Monitor.Enter(this); /// /// Tries to enter the lock without waiting. If the lock is entered, the calling thread would be the only thread that /// holds the lock. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool TryEnter() => Monitor.TryEnter(this); /// /// Tries to enter the lock, waiting for roughly the specified duration. If the lock is entered, the calling thread /// would be the only thread that holds the lock. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool TryEnter(TimeSpan timeout) => Monitor.TryEnter(this, timeout); /// /// Tries to enter the lock, waiting for roughly the specified duration. If the lock is entered, the calling thread /// would be the only thread that holds the lock. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool TryEnter(int millisecondsTimeout) => TryEnter(TimeSpan.FromMilliseconds(millisecondsTimeout)); /// /// Exits the lock. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Exit() => Monitor.Exit(this); /// /// Enters the lock and returns a that may be disposed to exit the lock. Once the method returns, diff --git a/src/Split/net6.0/Numbers/BytePolyfill.cs b/src/Split/net6.0/Numbers/BytePolyfill.cs index b32351497..fd1d5aa6f 100644 --- a/src/Split/net6.0/Numbers/BytePolyfill.cs +++ b/src/Split/net6.0/Numbers/BytePolyfill.cs @@ -4,6 +4,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -12,27 +13,32 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out byte result) => byte.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out byte result) => byte.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out byte result) => byte.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out byte result) => byte.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its byte equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out byte result) => byte.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); #endif diff --git a/src/Split/net6.0/Numbers/DoublePolyfill.cs b/src/Split/net6.0/Numbers/DoublePolyfill.cs index ff9f8aca6..94b44e869 100644 --- a/src/Split/net6.0/Numbers/DoublePolyfill.cs +++ b/src/Split/net6.0/Numbers/DoublePolyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,27 +12,32 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out double result) => double.TryParse(s, NumberStyles.Float, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out double result) => double.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Float, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out double result) => double.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its double-precision floating-point number equivalent.. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out double result) => double.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Float, null, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out double result) => double.TryParse(s.ToString(), NumberStyles.Float, provider, out result); #endif diff --git a/src/Split/net6.0/Numbers/Int16Polyfill.cs b/src/Split/net6.0/Numbers/Int16Polyfill.cs index 7a1f0b7c0..4447a9ecf 100644 --- a/src/Split/net6.0/Numbers/Int16Polyfill.cs +++ b/src/Split/net6.0/Numbers/Int16Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,27 +12,32 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out short result) => short.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out short result) => short.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out short result) => short.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its short equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out short result) => short.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out short result) => short.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/net6.0/Numbers/Int32Polyfill.cs b/src/Split/net6.0/Numbers/Int32Polyfill.cs index 853dfb518..587b2be91 100644 --- a/src/Split/net6.0/Numbers/Int32Polyfill.cs +++ b/src/Split/net6.0/Numbers/Int32Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,27 +12,32 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out int result) => int.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out int result) => int.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out int result) => int.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its 32-bit signed integer equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out int result) => int.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out int result) => int.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/net6.0/Numbers/Int64Polyfill.cs b/src/Split/net6.0/Numbers/Int64Polyfill.cs index e97be4775..3d7b5c57f 100644 --- a/src/Split/net6.0/Numbers/Int64Polyfill.cs +++ b/src/Split/net6.0/Numbers/Int64Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,27 +12,32 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out long result) => long.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out long result) => long.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out long result) => long.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its 64-bit signed integer equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out long result) => long.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out long result) => long.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/net6.0/Numbers/SBytePolyfill.cs b/src/Split/net6.0/Numbers/SBytePolyfill.cs index 9085c3aec..8de2ac072 100644 --- a/src/Split/net6.0/Numbers/SBytePolyfill.cs +++ b/src/Split/net6.0/Numbers/SBytePolyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,27 +12,32 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out sbyte result) => sbyte.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out sbyte result) => sbyte.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out sbyte result) => sbyte.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its sbyte equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out sbyte result) => sbyte.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out sbyte result) => sbyte.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/net6.0/Numbers/UInt16Polyfill.cs b/src/Split/net6.0/Numbers/UInt16Polyfill.cs index 11d4c4ed7..b3b68b25f 100644 --- a/src/Split/net6.0/Numbers/UInt16Polyfill.cs +++ b/src/Split/net6.0/Numbers/UInt16Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,27 +12,32 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out ushort result) => ushort.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out ushort result) => ushort.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out ushort result) => ushort.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its ushort equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out ushort result) => ushort.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out ushort result) => ushort.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/net6.0/Numbers/UInt32Polyfill.cs b/src/Split/net6.0/Numbers/UInt32Polyfill.cs index abdf707dd..4ba985db3 100644 --- a/src/Split/net6.0/Numbers/UInt32Polyfill.cs +++ b/src/Split/net6.0/Numbers/UInt32Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,27 +12,32 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out uint result) => uint.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out uint result) => uint.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out uint result) => uint.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its uint equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out uint result) => uint.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out uint result) => uint.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/net6.0/Numbers/UInt64Polyfill.cs b/src/Split/net6.0/Numbers/UInt64Polyfill.cs index 1a1bc228c..08e8b0fad 100644 --- a/src/Split/net6.0/Numbers/UInt64Polyfill.cs +++ b/src/Split/net6.0/Numbers/UInt64Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,27 +12,32 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out ulong result) => ulong.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out ulong result) => ulong.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpanutf8Text, NumberStyles style, IFormatProvider? provider, out ulong result) => ulong.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its ulong equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out ulong result) => ulong.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out ulong result) => ulong.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/net6.0/OperatingSystemPolyfill.cs b/src/Split/net6.0/OperatingSystemPolyfill.cs index b444ca73b..38650120a 100644 --- a/src/Split/net6.0/OperatingSystemPolyfill.cs +++ b/src/Split/net6.0/OperatingSystemPolyfill.cs @@ -3,6 +3,7 @@ #if FeatureRuntimeInformation namespace Polyfills; using System; +using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; static partial class Polyfill @@ -14,6 +15,7 @@ static bool IsOsVersionAtLeast(int major, int minor = 0, int build = 0, int revi /// /// Indicates whether the current application is running as WASI. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsWasi() => RuntimeInformation.IsOSPlatform(OSPlatform.Create("WASI")); } diff --git a/src/Split/net6.0/PathPolyfill.cs b/src/Split/net6.0/PathPolyfill.cs index 268c89cfc..39af87506 100644 --- a/src/Split/net6.0/PathPolyfill.cs +++ b/src/Split/net6.0/PathPolyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.IO; +using System.Runtime.CompilerServices; static partial class Polyfill { extension(Path) @@ -11,6 +12,7 @@ static partial class Polyfill /// /// Combines a span of strings into a path. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string Combine(scoped ReadOnlySpan paths) => Path.Combine(paths.ToArray()); #endif diff --git a/src/Split/net7.0/ConsolePolyfill.cs b/src/Split/net7.0/ConsolePolyfill.cs index 425364db8..5ad0342de 100644 --- a/src/Split/net7.0/ConsolePolyfill.cs +++ b/src/Split/net7.0/ConsolePolyfill.cs @@ -4,6 +4,7 @@ namespace Polyfills; using System; using System.Runtime.InteropServices; +using System.Runtime.CompilerServices; using Microsoft.Win32.SafeHandles; static partial class Polyfill { @@ -12,16 +13,19 @@ static partial class Polyfill /// /// Gets a that wraps the operating system handle for standard input. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static SafeFileHandle OpenStandardInputHandle() => StandardHandleHelper.GetStandardHandle(StandardHandleHelper.StdInput); /// /// Gets a that wraps the operating system handle for standard output. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static SafeFileHandle OpenStandardOutputHandle() => StandardHandleHelper.GetStandardHandle(StandardHandleHelper.StdOutput); /// /// Gets a that wraps the operating system handle for standard error. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static SafeFileHandle OpenStandardErrorHandle() => StandardHandleHelper.GetStandardHandle(StandardHandleHelper.StdError); } diff --git a/src/Split/net7.0/ConvertPolyfill.cs b/src/Split/net7.0/ConvertPolyfill.cs index 2ba95a78e..0744e77df 100644 --- a/src/Split/net7.0/ConvertPolyfill.cs +++ b/src/Split/net7.0/ConvertPolyfill.cs @@ -2,6 +2,7 @@ #pragma warning disable namespace Polyfills; using System; +using System.Runtime.CompilerServices; static partial class Polyfill { extension(Convert) @@ -10,17 +11,20 @@ static partial class Polyfill /// Converts a subset of an array of 8-bit unsigned integers to its equivalent string representation that is encoded with lowercase hex characters. /// Parameters specify the subset as an offset in the input array and the number of elements in the array to convert. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexStringLower(byte[] inArray, int offset, int length) => ToHexString(inArray, offset, length, "x2"); /// /// Converts an array of 8-bit unsigned integers to its equivalent string representation that is encoded with lowercase hex characters. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexStringLower(byte[] inArray) => Polyfill.ToHexStringLower(inArray, 0, inArray.Length); #if FeatureMemory /// /// Converts a span of 8-bit unsigned integers to its equivalent string representation that is encoded with lowercase hex characters. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexStringLower(ReadOnlySpan bytes) => Polyfill.ToHexStringLower(bytes.ToArray()); /// diff --git a/src/Split/net7.0/DateTimeOffsetPolyfill.cs b/src/Split/net7.0/DateTimeOffsetPolyfill.cs index 78c58e2dc..55d098936 100644 --- a/src/Split/net7.0/DateTimeOffsetPolyfill.cs +++ b/src/Split/net7.0/DateTimeOffsetPolyfill.cs @@ -4,6 +4,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; static partial class Polyfill { extension(DateTimeOffset) @@ -12,6 +13,7 @@ static partial class Polyfill /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out DateTimeOffset result) => DateTimeOffset.TryParse(s.ToString(), provider, DateTimeStyles.None, out result); #endif diff --git a/src/Split/net7.0/DateTimePolyfill.cs b/src/Split/net7.0/DateTimePolyfill.cs index 6a3cb556d..48f71f97e 100644 --- a/src/Split/net7.0/DateTimePolyfill.cs +++ b/src/Split/net7.0/DateTimePolyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; static partial class Polyfill { extension(DateTime) @@ -11,11 +12,13 @@ static partial class Polyfill /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out DateTime result) => DateTime.TryParse(s.ToString(), provider, DateTimeStyles.None, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParseExact(ReadOnlySpan s, ReadOnlySpan format, IFormatProvider? provider, DateTimeStyles styles, out DateTime result) => DateTime.TryParseExact(s.ToString(), format.ToString(), provider, styles, out result); #endif diff --git a/src/Split/net7.0/DelegatePolyfill.cs b/src/Split/net7.0/DelegatePolyfill.cs index effdb1267..59cc5e315 100644 --- a/src/Split/net7.0/DelegatePolyfill.cs +++ b/src/Split/net7.0/DelegatePolyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.ComponentModel; +using System.Runtime.CompilerServices; static partial class Polyfill { /// @@ -39,6 +40,7 @@ public bool MoveNext() /// /// Gets an enumerator for the invocation targets of this delegate. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static InvocationListEnumerator EnumerateInvocationList(TDelegate? target) where TDelegate : Delegate => new(target); diff --git a/src/Split/net7.0/FilePolyfill.cs b/src/Split/net7.0/FilePolyfill.cs index cd559610b..1762c39c7 100644 --- a/src/Split/net7.0/FilePolyfill.cs +++ b/src/Split/net7.0/FilePolyfill.cs @@ -48,11 +48,13 @@ public static Task AppendAllTextAsync(string path, ReadOnlyMemory contents /// /// Appends the specified string to the file, creating the file if it does not already exist. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void AppendAllText(string path, ReadOnlySpan contents) => File.AppendAllText(path, contents.ToString()); /// /// Appends the specified string to the file, creating the file if it does not already exist. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void AppendAllText(string path, ReadOnlySpan contents, Encoding encoding) => File.AppendAllText(path, contents.ToString(), encoding); /// @@ -76,12 +78,14 @@ public static async Task WriteAllBytesAsync(string path, ReadOnlyMemory by /// Creates a new file, writes the specified string to the file, and then closes the file. /// If the target file already exists, it is truncated and overwritten. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void WriteAllText(string path, ReadOnlySpan contents) => File.WriteAllText(path, contents.ToString()); /// /// Creates a new file, writes the specified string to the file using the specified encoding, and then closes the file. /// If the target file already exists, it is truncated and overwritten. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void WriteAllText(string path, ReadOnlySpan contents, Encoding encoding) => File.WriteAllText(path, contents.ToString(), encoding); /// diff --git a/src/Split/net7.0/GuidPolyfill.cs b/src/Split/net7.0/GuidPolyfill.cs index 42acf37e7..d98f66f9d 100644 --- a/src/Split/net7.0/GuidPolyfill.cs +++ b/src/Split/net7.0/GuidPolyfill.cs @@ -4,11 +4,13 @@ namespace Polyfills; using System.Text; using System; using System.Security.Cryptography; +using System.Runtime.CompilerServices; static partial class Polyfill { extension(Guid) { /// Creates a new according to RFC 9562, following the Version 7 format. + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Guid CreateVersion7() => CreateVersion7(DateTimeOffset.UtcNow); /// Creates a new according to RFC 9562, following the Version 7 format. public static Guid CreateVersion7(DateTimeOffset timestamp) @@ -35,11 +37,13 @@ public static Guid CreateVersion7(DateTimeOffset timestamp) /// /// Tries to parse a span of UTF-8 bytes into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out Guid result) => Guid.TryParse(Encoding.UTF8.GetString(utf8Text), out result); /// /// Parse a span of UTF-8 bytes into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Guid Parse(ReadOnlySpan utf8Text) => Guid.Parse(Encoding.UTF8.GetString(utf8Text)); #endif diff --git a/src/Split/net7.0/Lock.cs b/src/Split/net7.0/Lock.cs index 94fcf1ff9..36946028c 100644 --- a/src/Split/net7.0/Lock.cs +++ b/src/Split/net7.0/Lock.cs @@ -5,6 +5,7 @@ namespace System.Threading; using Diagnostics; using Diagnostics.CodeAnalysis; +using Runtime.CompilerServices; /// /// Provides a way to get mutual exclusion in regions of code between different threads. A lock may be held by one thread at /// a time. @@ -23,26 +24,31 @@ class Lock /// /// Enters the lock. Once the method returns, the calling thread would be the only thread that holds the lock. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Enter() => Monitor.Enter(this); /// /// Tries to enter the lock without waiting. If the lock is entered, the calling thread would be the only thread that /// holds the lock. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool TryEnter() => Monitor.TryEnter(this); /// /// Tries to enter the lock, waiting for roughly the specified duration. If the lock is entered, the calling thread /// would be the only thread that holds the lock. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool TryEnter(TimeSpan timeout) => Monitor.TryEnter(this, timeout); /// /// Tries to enter the lock, waiting for roughly the specified duration. If the lock is entered, the calling thread /// would be the only thread that holds the lock. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool TryEnter(int millisecondsTimeout) => TryEnter(TimeSpan.FromMilliseconds(millisecondsTimeout)); /// /// Exits the lock. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Exit() => Monitor.Exit(this); /// /// Enters the lock and returns a that may be disposed to exit the lock. Once the method returns, diff --git a/src/Split/net7.0/Numbers/BytePolyfill.cs b/src/Split/net7.0/Numbers/BytePolyfill.cs index 572eab88f..142f2c3ef 100644 --- a/src/Split/net7.0/Numbers/BytePolyfill.cs +++ b/src/Split/net7.0/Numbers/BytePolyfill.cs @@ -4,6 +4,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -13,16 +14,19 @@ static partial class Polyfill /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out byte result) => byte.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out byte result) => byte.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its byte equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out byte result) => byte.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); #endif diff --git a/src/Split/net7.0/Numbers/DoublePolyfill.cs b/src/Split/net7.0/Numbers/DoublePolyfill.cs index 53d86a1a7..d98449182 100644 --- a/src/Split/net7.0/Numbers/DoublePolyfill.cs +++ b/src/Split/net7.0/Numbers/DoublePolyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -12,16 +13,19 @@ static partial class Polyfill /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out double result) => double.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Float, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out double result) => double.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its double-precision floating-point number equivalent.. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out double result) => double.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Float, null, out result); #endif diff --git a/src/Split/net7.0/Numbers/Int16Polyfill.cs b/src/Split/net7.0/Numbers/Int16Polyfill.cs index c87eac7f0..cc6620202 100644 --- a/src/Split/net7.0/Numbers/Int16Polyfill.cs +++ b/src/Split/net7.0/Numbers/Int16Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -12,16 +13,19 @@ static partial class Polyfill /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out short result) => short.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out short result) => short.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its short equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out short result) => short.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); #endif diff --git a/src/Split/net7.0/Numbers/Int32Polyfill.cs b/src/Split/net7.0/Numbers/Int32Polyfill.cs index 9e07d4b5b..8196cec12 100644 --- a/src/Split/net7.0/Numbers/Int32Polyfill.cs +++ b/src/Split/net7.0/Numbers/Int32Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -12,16 +13,19 @@ static partial class Polyfill /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out int result) => int.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out int result) => int.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its 32-bit signed integer equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out int result) => int.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); #endif diff --git a/src/Split/net7.0/Numbers/Int64Polyfill.cs b/src/Split/net7.0/Numbers/Int64Polyfill.cs index 3c23329bd..5f047e81f 100644 --- a/src/Split/net7.0/Numbers/Int64Polyfill.cs +++ b/src/Split/net7.0/Numbers/Int64Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -12,16 +13,19 @@ static partial class Polyfill /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out long result) => long.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out long result) => long.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its 64-bit signed integer equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out long result) => long.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); #endif diff --git a/src/Split/net7.0/Numbers/SBytePolyfill.cs b/src/Split/net7.0/Numbers/SBytePolyfill.cs index 488c8b8e3..f128a0a8a 100644 --- a/src/Split/net7.0/Numbers/SBytePolyfill.cs +++ b/src/Split/net7.0/Numbers/SBytePolyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -12,16 +13,19 @@ static partial class Polyfill /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out sbyte result) => sbyte.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out sbyte result) => sbyte.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its sbyte equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out sbyte result) => sbyte.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); #endif diff --git a/src/Split/net7.0/Numbers/UInt16Polyfill.cs b/src/Split/net7.0/Numbers/UInt16Polyfill.cs index 347c4a427..826d2fe86 100644 --- a/src/Split/net7.0/Numbers/UInt16Polyfill.cs +++ b/src/Split/net7.0/Numbers/UInt16Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -12,16 +13,19 @@ static partial class Polyfill /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out ushort result) => ushort.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out ushort result) => ushort.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its ushort equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out ushort result) => ushort.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); #endif diff --git a/src/Split/net7.0/Numbers/UInt32Polyfill.cs b/src/Split/net7.0/Numbers/UInt32Polyfill.cs index fc6b06726..21b64bd13 100644 --- a/src/Split/net7.0/Numbers/UInt32Polyfill.cs +++ b/src/Split/net7.0/Numbers/UInt32Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -12,16 +13,19 @@ static partial class Polyfill /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out uint result) => uint.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out uint result) => uint.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its uint equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out uint result) => uint.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); #endif diff --git a/src/Split/net7.0/Numbers/UInt64Polyfill.cs b/src/Split/net7.0/Numbers/UInt64Polyfill.cs index 96cf2e216..ace06b315 100644 --- a/src/Split/net7.0/Numbers/UInt64Polyfill.cs +++ b/src/Split/net7.0/Numbers/UInt64Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -12,16 +13,19 @@ static partial class Polyfill /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out ulong result) => ulong.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpanutf8Text, NumberStyles style, IFormatProvider? provider, out ulong result) => ulong.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its ulong equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out ulong result) => ulong.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); #endif diff --git a/src/Split/net7.0/OperatingSystemPolyfill.cs b/src/Split/net7.0/OperatingSystemPolyfill.cs index b444ca73b..38650120a 100644 --- a/src/Split/net7.0/OperatingSystemPolyfill.cs +++ b/src/Split/net7.0/OperatingSystemPolyfill.cs @@ -3,6 +3,7 @@ #if FeatureRuntimeInformation namespace Polyfills; using System; +using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; static partial class Polyfill @@ -14,6 +15,7 @@ static bool IsOsVersionAtLeast(int major, int minor = 0, int build = 0, int revi /// /// Indicates whether the current application is running as WASI. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsWasi() => RuntimeInformation.IsOSPlatform(OSPlatform.Create("WASI")); } diff --git a/src/Split/net7.0/PathPolyfill.cs b/src/Split/net7.0/PathPolyfill.cs index 9cb9a871a..19d455dc4 100644 --- a/src/Split/net7.0/PathPolyfill.cs +++ b/src/Split/net7.0/PathPolyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.IO; +using System.Runtime.CompilerServices; static partial class Polyfill { extension(Path) @@ -11,6 +12,7 @@ static partial class Polyfill /// /// Combines a span of strings into a path. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string Combine(scoped ReadOnlySpan paths) => Path.Combine(paths.ToArray()); #endif diff --git a/src/Split/net8.0/ConsolePolyfill.cs b/src/Split/net8.0/ConsolePolyfill.cs index 425364db8..5ad0342de 100644 --- a/src/Split/net8.0/ConsolePolyfill.cs +++ b/src/Split/net8.0/ConsolePolyfill.cs @@ -4,6 +4,7 @@ namespace Polyfills; using System; using System.Runtime.InteropServices; +using System.Runtime.CompilerServices; using Microsoft.Win32.SafeHandles; static partial class Polyfill { @@ -12,16 +13,19 @@ static partial class Polyfill /// /// Gets a that wraps the operating system handle for standard input. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static SafeFileHandle OpenStandardInputHandle() => StandardHandleHelper.GetStandardHandle(StandardHandleHelper.StdInput); /// /// Gets a that wraps the operating system handle for standard output. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static SafeFileHandle OpenStandardOutputHandle() => StandardHandleHelper.GetStandardHandle(StandardHandleHelper.StdOutput); /// /// Gets a that wraps the operating system handle for standard error. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static SafeFileHandle OpenStandardErrorHandle() => StandardHandleHelper.GetStandardHandle(StandardHandleHelper.StdError); } diff --git a/src/Split/net8.0/ConvertPolyfill.cs b/src/Split/net8.0/ConvertPolyfill.cs index 2ba95a78e..0744e77df 100644 --- a/src/Split/net8.0/ConvertPolyfill.cs +++ b/src/Split/net8.0/ConvertPolyfill.cs @@ -2,6 +2,7 @@ #pragma warning disable namespace Polyfills; using System; +using System.Runtime.CompilerServices; static partial class Polyfill { extension(Convert) @@ -10,17 +11,20 @@ static partial class Polyfill /// Converts a subset of an array of 8-bit unsigned integers to its equivalent string representation that is encoded with lowercase hex characters. /// Parameters specify the subset as an offset in the input array and the number of elements in the array to convert. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexStringLower(byte[] inArray, int offset, int length) => ToHexString(inArray, offset, length, "x2"); /// /// Converts an array of 8-bit unsigned integers to its equivalent string representation that is encoded with lowercase hex characters. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexStringLower(byte[] inArray) => Polyfill.ToHexStringLower(inArray, 0, inArray.Length); #if FeatureMemory /// /// Converts a span of 8-bit unsigned integers to its equivalent string representation that is encoded with lowercase hex characters. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexStringLower(ReadOnlySpan bytes) => Polyfill.ToHexStringLower(bytes.ToArray()); /// diff --git a/src/Split/net8.0/DelegatePolyfill.cs b/src/Split/net8.0/DelegatePolyfill.cs index effdb1267..59cc5e315 100644 --- a/src/Split/net8.0/DelegatePolyfill.cs +++ b/src/Split/net8.0/DelegatePolyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.ComponentModel; +using System.Runtime.CompilerServices; static partial class Polyfill { /// @@ -39,6 +40,7 @@ public bool MoveNext() /// /// Gets an enumerator for the invocation targets of this delegate. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static InvocationListEnumerator EnumerateInvocationList(TDelegate? target) where TDelegate : Delegate => new(target); diff --git a/src/Split/net8.0/FilePolyfill.cs b/src/Split/net8.0/FilePolyfill.cs index cd559610b..1762c39c7 100644 --- a/src/Split/net8.0/FilePolyfill.cs +++ b/src/Split/net8.0/FilePolyfill.cs @@ -48,11 +48,13 @@ public static Task AppendAllTextAsync(string path, ReadOnlyMemory contents /// /// Appends the specified string to the file, creating the file if it does not already exist. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void AppendAllText(string path, ReadOnlySpan contents) => File.AppendAllText(path, contents.ToString()); /// /// Appends the specified string to the file, creating the file if it does not already exist. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void AppendAllText(string path, ReadOnlySpan contents, Encoding encoding) => File.AppendAllText(path, contents.ToString(), encoding); /// @@ -76,12 +78,14 @@ public static async Task WriteAllBytesAsync(string path, ReadOnlyMemory by /// Creates a new file, writes the specified string to the file, and then closes the file. /// If the target file already exists, it is truncated and overwritten. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void WriteAllText(string path, ReadOnlySpan contents) => File.WriteAllText(path, contents.ToString()); /// /// Creates a new file, writes the specified string to the file using the specified encoding, and then closes the file. /// If the target file already exists, it is truncated and overwritten. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void WriteAllText(string path, ReadOnlySpan contents, Encoding encoding) => File.WriteAllText(path, contents.ToString(), encoding); /// diff --git a/src/Split/net8.0/GuidPolyfill.cs b/src/Split/net8.0/GuidPolyfill.cs index 7666507b0..2f5150133 100644 --- a/src/Split/net8.0/GuidPolyfill.cs +++ b/src/Split/net8.0/GuidPolyfill.cs @@ -4,11 +4,13 @@ namespace Polyfills; using System.Text; using System; using System.Security.Cryptography; +using System.Runtime.CompilerServices; static partial class Polyfill { extension(Guid) { /// Creates a new according to RFC 9562, following the Version 7 format. + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Guid CreateVersion7() => CreateVersion7(DateTimeOffset.UtcNow); /// Creates a new according to RFC 9562, following the Version 7 format. public static Guid CreateVersion7(DateTimeOffset timestamp) @@ -31,11 +33,13 @@ public static Guid CreateVersion7(DateTimeOffset timestamp) /// /// Tries to parse a span of UTF-8 bytes into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out Guid result) => Guid.TryParse(Encoding.UTF8.GetString(utf8Text), out result); /// /// Parse a span of UTF-8 bytes into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Guid Parse(ReadOnlySpan utf8Text) => Guid.Parse(Encoding.UTF8.GetString(utf8Text)); #endif diff --git a/src/Split/net8.0/Lock.cs b/src/Split/net8.0/Lock.cs index 94fcf1ff9..36946028c 100644 --- a/src/Split/net8.0/Lock.cs +++ b/src/Split/net8.0/Lock.cs @@ -5,6 +5,7 @@ namespace System.Threading; using Diagnostics; using Diagnostics.CodeAnalysis; +using Runtime.CompilerServices; /// /// Provides a way to get mutual exclusion in regions of code between different threads. A lock may be held by one thread at /// a time. @@ -23,26 +24,31 @@ class Lock /// /// Enters the lock. Once the method returns, the calling thread would be the only thread that holds the lock. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Enter() => Monitor.Enter(this); /// /// Tries to enter the lock without waiting. If the lock is entered, the calling thread would be the only thread that /// holds the lock. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool TryEnter() => Monitor.TryEnter(this); /// /// Tries to enter the lock, waiting for roughly the specified duration. If the lock is entered, the calling thread /// would be the only thread that holds the lock. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool TryEnter(TimeSpan timeout) => Monitor.TryEnter(this, timeout); /// /// Tries to enter the lock, waiting for roughly the specified duration. If the lock is entered, the calling thread /// would be the only thread that holds the lock. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool TryEnter(int millisecondsTimeout) => TryEnter(TimeSpan.FromMilliseconds(millisecondsTimeout)); /// /// Exits the lock. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Exit() => Monitor.Exit(this); /// /// Enters the lock and returns a that may be disposed to exit the lock. Once the method returns, diff --git a/src/Split/net8.0/PathPolyfill.cs b/src/Split/net8.0/PathPolyfill.cs index 9cb9a871a..19d455dc4 100644 --- a/src/Split/net8.0/PathPolyfill.cs +++ b/src/Split/net8.0/PathPolyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.IO; +using System.Runtime.CompilerServices; static partial class Polyfill { extension(Path) @@ -11,6 +12,7 @@ static partial class Polyfill /// /// Combines a span of strings into a path. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string Combine(scoped ReadOnlySpan paths) => Path.Combine(paths.ToArray()); #endif diff --git a/src/Split/net9.0/ConsolePolyfill.cs b/src/Split/net9.0/ConsolePolyfill.cs index 425364db8..5ad0342de 100644 --- a/src/Split/net9.0/ConsolePolyfill.cs +++ b/src/Split/net9.0/ConsolePolyfill.cs @@ -4,6 +4,7 @@ namespace Polyfills; using System; using System.Runtime.InteropServices; +using System.Runtime.CompilerServices; using Microsoft.Win32.SafeHandles; static partial class Polyfill { @@ -12,16 +13,19 @@ static partial class Polyfill /// /// Gets a that wraps the operating system handle for standard input. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static SafeFileHandle OpenStandardInputHandle() => StandardHandleHelper.GetStandardHandle(StandardHandleHelper.StdInput); /// /// Gets a that wraps the operating system handle for standard output. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static SafeFileHandle OpenStandardOutputHandle() => StandardHandleHelper.GetStandardHandle(StandardHandleHelper.StdOutput); /// /// Gets a that wraps the operating system handle for standard error. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static SafeFileHandle OpenStandardErrorHandle() => StandardHandleHelper.GetStandardHandle(StandardHandleHelper.StdError); } diff --git a/src/Split/net9.0/GuidPolyfill.cs b/src/Split/net9.0/GuidPolyfill.cs index ff436246e..df4f5db1e 100644 --- a/src/Split/net9.0/GuidPolyfill.cs +++ b/src/Split/net9.0/GuidPolyfill.cs @@ -4,6 +4,7 @@ namespace Polyfills; using System.Text; using System; using System.Security.Cryptography; +using System.Runtime.CompilerServices; static partial class Polyfill { extension(Guid) @@ -12,11 +13,13 @@ static partial class Polyfill /// /// Tries to parse a span of UTF-8 bytes into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out Guid result) => Guid.TryParse(Encoding.UTF8.GetString(utf8Text), out result); /// /// Parse a span of UTF-8 bytes into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Guid Parse(ReadOnlySpan utf8Text) => Guid.Parse(Encoding.UTF8.GetString(utf8Text)); #endif diff --git a/src/Split/netcoreapp2.0/ConsolePolyfill.cs b/src/Split/netcoreapp2.0/ConsolePolyfill.cs index 425364db8..5ad0342de 100644 --- a/src/Split/netcoreapp2.0/ConsolePolyfill.cs +++ b/src/Split/netcoreapp2.0/ConsolePolyfill.cs @@ -4,6 +4,7 @@ namespace Polyfills; using System; using System.Runtime.InteropServices; +using System.Runtime.CompilerServices; using Microsoft.Win32.SafeHandles; static partial class Polyfill { @@ -12,16 +13,19 @@ static partial class Polyfill /// /// Gets a that wraps the operating system handle for standard input. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static SafeFileHandle OpenStandardInputHandle() => StandardHandleHelper.GetStandardHandle(StandardHandleHelper.StdInput); /// /// Gets a that wraps the operating system handle for standard output. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static SafeFileHandle OpenStandardOutputHandle() => StandardHandleHelper.GetStandardHandle(StandardHandleHelper.StdOutput); /// /// Gets a that wraps the operating system handle for standard error. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static SafeFileHandle OpenStandardErrorHandle() => StandardHandleHelper.GetStandardHandle(StandardHandleHelper.StdError); } diff --git a/src/Split/netcoreapp2.0/ConvertPolyfill.cs b/src/Split/netcoreapp2.0/ConvertPolyfill.cs index 8ca6da94f..5f80df1f7 100644 --- a/src/Split/netcoreapp2.0/ConvertPolyfill.cs +++ b/src/Split/netcoreapp2.0/ConvertPolyfill.cs @@ -2,6 +2,7 @@ #pragma warning disable namespace Polyfills; using System; +using System.Runtime.CompilerServices; static partial class Polyfill { extension(Convert) @@ -10,22 +11,26 @@ static partial class Polyfill /// Converts a subset of an array of 8-bit unsigned integers to its equivalent string representation that is encoded with uppercase hex characters. /// Parameters specify the subset as an offset in the input array and the number of elements in the array to convert. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexString(byte[] inArray, int offset, int length) => ToHexString(inArray, offset, length, "X2"); /// /// Converts a subset of an array of 8-bit unsigned integers to its equivalent string representation that is encoded with lowercase hex characters. /// Parameters specify the subset as an offset in the input array and the number of elements in the array to convert. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexStringLower(byte[] inArray, int offset, int length) => ToHexString(inArray, offset, length, "x2"); /// /// Converts an array of 8-bit unsigned integers to its equivalent string representation that is encoded with lowercase hex characters. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexStringLower(byte[] inArray) => Polyfill.ToHexStringLower(inArray, 0, inArray.Length); /// /// Converts an array of 8-bit unsigned integers to its equivalent string representation that is encoded with uppercase hex characters. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexString(byte[] inArray) => Polyfill.ToHexString(inArray, 0, inArray.Length); /// @@ -54,16 +59,19 @@ static int GetHexValue(char hex) => /// /// Converts the span, which encodes binary data as hex characters, to an equivalent 8-bit unsigned integer array. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static byte[] FromHexString(ReadOnlySpan chars) => Polyfill.FromHexString(chars.ToString()); /// /// Converts a span of 8-bit unsigned integers to its equivalent string representation that is encoded with uppercase hex characters. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexString(ReadOnlySpan bytes) => Polyfill.ToHexString(bytes.ToArray()); /// /// Converts a span of 8-bit unsigned integers to its equivalent string representation that is encoded with lowercase hex characters. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexStringLower(ReadOnlySpan bytes) => Polyfill.ToHexStringLower(bytes.ToArray()); /// diff --git a/src/Split/netcoreapp2.0/DateTimeOffsetPolyfill.cs b/src/Split/netcoreapp2.0/DateTimeOffsetPolyfill.cs index 6837790e5..7bb9a5ad7 100644 --- a/src/Split/netcoreapp2.0/DateTimeOffsetPolyfill.cs +++ b/src/Split/netcoreapp2.0/DateTimeOffsetPolyfill.cs @@ -4,6 +4,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; static partial class Polyfill { extension(DateTimeOffset target) @@ -30,32 +31,38 @@ long TicksComponent() /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out DateTimeOffset result) => DateTimeOffset.TryParse(s, provider, DateTimeStyles.None, out result); #if FeatureMemory /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out DateTimeOffset result) => DateTimeOffset.TryParse(s.ToString(), provider, DateTimeStyles.None, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan input, out DateTimeOffset result) => DateTimeOffset.TryParse(input.ToString(), null, DateTimeStyles.None, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, DateTimeStyles styles, out DateTimeOffset result) => DateTimeOffset.TryParse(s.ToString(), provider, styles, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParseExact(ReadOnlySpan input, string format, IFormatProvider? provider, DateTimeStyles styles, out DateTimeOffset result) => DateTimeOffset.TryParseExact(input.ToString(), format, provider, styles, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParseExact(ReadOnlySpan input, ReadOnlySpan format, IFormatProvider? provider, DateTimeStyles styles, out DateTimeOffset result) => DateTimeOffset.TryParseExact(input.ToString(), format.ToString(), provider, styles, out result); #endif diff --git a/src/Split/netcoreapp2.0/DateTimePolyfill.cs b/src/Split/netcoreapp2.0/DateTimePolyfill.cs index 4641f3e59..4d329796a 100644 --- a/src/Split/netcoreapp2.0/DateTimePolyfill.cs +++ b/src/Split/netcoreapp2.0/DateTimePolyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; static partial class Polyfill { extension(DateTime target) @@ -29,32 +30,38 @@ long TicksComponent() /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out DateTime result) => DateTime.TryParse(s, provider, DateTimeStyles.None, out result); #if FeatureMemory /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out DateTime result) => DateTime.TryParse(s.ToString(), provider, DateTimeStyles.None, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out DateTime result) => DateTime.TryParse(s.ToString(), null, DateTimeStyles.None, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, DateTimeStyles styles, out DateTime result) => DateTime.TryParse(s.ToString(), provider, styles, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParseExact(ReadOnlySpan s, string format, IFormatProvider? provider, DateTimeStyles style, out DateTime result) => DateTime.TryParseExact(s.ToString(), format, provider, style, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParseExact(ReadOnlySpan s, ReadOnlySpan format, IFormatProvider? provider, DateTimeStyles styles, out DateTime result) => DateTime.TryParseExact(s.ToString(), format.ToString(), provider, styles, out result); #endif diff --git a/src/Split/netcoreapp2.0/DelegatePolyfill.cs b/src/Split/netcoreapp2.0/DelegatePolyfill.cs index effdb1267..59cc5e315 100644 --- a/src/Split/netcoreapp2.0/DelegatePolyfill.cs +++ b/src/Split/netcoreapp2.0/DelegatePolyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.ComponentModel; +using System.Runtime.CompilerServices; static partial class Polyfill { /// @@ -39,6 +40,7 @@ public bool MoveNext() /// /// Gets an enumerator for the invocation targets of this delegate. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static InvocationListEnumerator EnumerateInvocationList(TDelegate? target) where TDelegate : Delegate => new(target); diff --git a/src/Split/netcoreapp2.0/FilePolyfill.cs b/src/Split/netcoreapp2.0/FilePolyfill.cs index 3e55baa26..fa568149e 100644 --- a/src/Split/netcoreapp2.0/FilePolyfill.cs +++ b/src/Split/netcoreapp2.0/FilePolyfill.cs @@ -48,11 +48,13 @@ public static Task AppendAllTextAsync(string path, ReadOnlyMemory contents /// /// Appends the specified string to the file, creating the file if it does not already exist. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void AppendAllText(string path, ReadOnlySpan contents) => File.AppendAllText(path, contents.ToString()); /// /// Appends the specified string to the file, creating the file if it does not already exist. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void AppendAllText(string path, ReadOnlySpan contents, Encoding encoding) => File.AppendAllText(path, contents.ToString(), encoding); /// @@ -76,12 +78,14 @@ public static async Task WriteAllBytesAsync(string path, ReadOnlyMemory by /// Creates a new file, writes the specified string to the file, and then closes the file. /// If the target file already exists, it is truncated and overwritten. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void WriteAllText(string path, ReadOnlySpan contents) => File.WriteAllText(path, contents.ToString()); /// /// Creates a new file, writes the specified string to the file using the specified encoding, and then closes the file. /// If the target file already exists, it is truncated and overwritten. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void WriteAllText(string path, ReadOnlySpan contents, Encoding encoding) => File.WriteAllText(path, contents.ToString(), encoding); /// diff --git a/src/Split/netcoreapp2.0/GuidPolyfill.cs b/src/Split/netcoreapp2.0/GuidPolyfill.cs index 2bd536736..bc6b9129b 100644 --- a/src/Split/netcoreapp2.0/GuidPolyfill.cs +++ b/src/Split/netcoreapp2.0/GuidPolyfill.cs @@ -4,6 +4,7 @@ namespace Polyfills; using System.Text; using System; using System.Security.Cryptography; +using System.Runtime.CompilerServices; static partial class Polyfill { extension(Guid) @@ -11,9 +12,11 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out Guid result) => Guid.TryParse(s, out result); /// Creates a new according to RFC 9562, following the Version 7 format. + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Guid CreateVersion7() => CreateVersion7(DateTimeOffset.UtcNow); /// Creates a new according to RFC 9562, following the Version 7 format. public static Guid CreateVersion7(DateTimeOffset timestamp) @@ -40,26 +43,31 @@ public static Guid CreateVersion7(DateTimeOffset timestamp) /// /// Converts span of characters representing the GUID to the equivalent Guid structure, provided that the string is in the specified format. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParseExact(ReadOnlySpan input, ReadOnlySpan format, out Guid result) => Guid.TryParseExact(input.ToString(), format.ToString(), out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out Guid result) => Guid.TryParse(s.ToString(), out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan input, out Guid result) => Guid.TryParse(input.ToString(), out result); /// /// Tries to parse a span of UTF-8 bytes into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out Guid result) => Guid.TryParse(Encoding.UTF8.GetString(utf8Text), out result); /// /// Parse a span of UTF-8 bytes into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Guid Parse(ReadOnlySpan utf8Text) => Guid.Parse(Encoding.UTF8.GetString(utf8Text)); #endif diff --git a/src/Split/netcoreapp2.0/Lock.cs b/src/Split/netcoreapp2.0/Lock.cs index 94fcf1ff9..36946028c 100644 --- a/src/Split/netcoreapp2.0/Lock.cs +++ b/src/Split/netcoreapp2.0/Lock.cs @@ -5,6 +5,7 @@ namespace System.Threading; using Diagnostics; using Diagnostics.CodeAnalysis; +using Runtime.CompilerServices; /// /// Provides a way to get mutual exclusion in regions of code between different threads. A lock may be held by one thread at /// a time. @@ -23,26 +24,31 @@ class Lock /// /// Enters the lock. Once the method returns, the calling thread would be the only thread that holds the lock. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Enter() => Monitor.Enter(this); /// /// Tries to enter the lock without waiting. If the lock is entered, the calling thread would be the only thread that /// holds the lock. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool TryEnter() => Monitor.TryEnter(this); /// /// Tries to enter the lock, waiting for roughly the specified duration. If the lock is entered, the calling thread /// would be the only thread that holds the lock. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool TryEnter(TimeSpan timeout) => Monitor.TryEnter(this, timeout); /// /// Tries to enter the lock, waiting for roughly the specified duration. If the lock is entered, the calling thread /// would be the only thread that holds the lock. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool TryEnter(int millisecondsTimeout) => TryEnter(TimeSpan.FromMilliseconds(millisecondsTimeout)); /// /// Exits the lock. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Exit() => Monitor.Exit(this); /// /// Enters the lock and returns a that may be disposed to exit the lock. Once the method returns, diff --git a/src/Split/netcoreapp2.0/Numbers/BytePolyfill.cs b/src/Split/netcoreapp2.0/Numbers/BytePolyfill.cs index ef3f744ed..0ea017afd 100644 --- a/src/Split/netcoreapp2.0/Numbers/BytePolyfill.cs +++ b/src/Split/netcoreapp2.0/Numbers/BytePolyfill.cs @@ -4,6 +4,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -12,37 +13,44 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out byte result) => byte.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out byte result) => byte.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out byte result) => byte.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out byte result) => byte.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its byte equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out byte result) => byte.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its byte equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out byte result) => byte.TryParse(s.ToString(), out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its byte equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out byte result) => byte.TryParse(s.ToString(), style, provider, out result); #endif diff --git a/src/Split/netcoreapp2.0/Numbers/DoublePolyfill.cs b/src/Split/netcoreapp2.0/Numbers/DoublePolyfill.cs index ba5333f69..d903ddfe1 100644 --- a/src/Split/netcoreapp2.0/Numbers/DoublePolyfill.cs +++ b/src/Split/netcoreapp2.0/Numbers/DoublePolyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,37 +12,44 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out double result) => double.TryParse(s, NumberStyles.Float, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out double result) => double.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Float, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out double result) => double.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its double-precision floating-point number equivalent.. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out double result) => double.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Float, null, out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its double-precision floating-point number equivalent. A return value indicates whether the conversion succeeded or failed. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out double result) => double.TryParse(s.ToString(), out result); /// /// Converts the string representation of a number in a specified style and culture-specific format to its double-precision floating-point number equivalent. A return value indicates whether the conversion succeeded or failed. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out double result) => double.TryParse(s.ToString(), style, provider, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out double result) => double.TryParse(s.ToString(), NumberStyles.Float, provider, out result); #endif diff --git a/src/Split/netcoreapp2.0/Numbers/Int16Polyfill.cs b/src/Split/netcoreapp2.0/Numbers/Int16Polyfill.cs index 5eb1b384e..960cf68ce 100644 --- a/src/Split/netcoreapp2.0/Numbers/Int16Polyfill.cs +++ b/src/Split/netcoreapp2.0/Numbers/Int16Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,37 +12,44 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out short result) => short.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out short result) => short.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out short result) => short.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its short equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out short result) => short.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its short equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out short result) => short.TryParse(s.ToString(), out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its short equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out short result) => short.TryParse(s.ToString(), style, provider, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out short result) => short.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/netcoreapp2.0/Numbers/Int32Polyfill.cs b/src/Split/netcoreapp2.0/Numbers/Int32Polyfill.cs index 549ff1896..2920eae4a 100644 --- a/src/Split/netcoreapp2.0/Numbers/Int32Polyfill.cs +++ b/src/Split/netcoreapp2.0/Numbers/Int32Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,37 +12,44 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out int result) => int.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out int result) => int.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out int result) => int.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its 32-bit signed integer equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out int result) => int.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its 32-bit signed integer equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out int result) => int.TryParse(s.ToString(), out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its 32-bit signed integer equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out int result) => int.TryParse(s.ToString(), style, provider, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out int result) => int.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/netcoreapp2.0/Numbers/Int64Polyfill.cs b/src/Split/netcoreapp2.0/Numbers/Int64Polyfill.cs index bd33ce0e6..0b7b1b100 100644 --- a/src/Split/netcoreapp2.0/Numbers/Int64Polyfill.cs +++ b/src/Split/netcoreapp2.0/Numbers/Int64Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,37 +12,44 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out long result) => long.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out long result) => long.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out long result) => long.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its 64-bit signed integer equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out long result) => long.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its 32-bit signed integer equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out long result) => long.TryParse(s.ToString(), out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its 64-bit signed integer equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out long result) => long.TryParse(s.ToString(), style, provider, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out long result) => long.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/netcoreapp2.0/Numbers/SBytePolyfill.cs b/src/Split/netcoreapp2.0/Numbers/SBytePolyfill.cs index 974115654..890452b1c 100644 --- a/src/Split/netcoreapp2.0/Numbers/SBytePolyfill.cs +++ b/src/Split/netcoreapp2.0/Numbers/SBytePolyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,37 +12,44 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out sbyte result) => sbyte.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out sbyte result) => sbyte.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out sbyte result) => sbyte.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its sbyte equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out sbyte result) => sbyte.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its sbyte equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out sbyte result) => sbyte.TryParse(s.ToString(), out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its sbyte equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out sbyte result) => sbyte.TryParse(s.ToString(), style, provider, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out sbyte result) => sbyte.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/netcoreapp2.0/Numbers/UInt16Polyfill.cs b/src/Split/netcoreapp2.0/Numbers/UInt16Polyfill.cs index 34f39f97c..ed0958805 100644 --- a/src/Split/netcoreapp2.0/Numbers/UInt16Polyfill.cs +++ b/src/Split/netcoreapp2.0/Numbers/UInt16Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,37 +12,44 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out ushort result) => ushort.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out ushort result) => ushort.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out ushort result) => ushort.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its ushort equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out ushort result) => ushort.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its ushort equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out ushort result) => ushort.TryParse(s.ToString(), out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its ushort equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out ushort result) => ushort.TryParse(s.ToString(), style, provider, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out ushort result) => ushort.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/netcoreapp2.0/Numbers/UInt32Polyfill.cs b/src/Split/netcoreapp2.0/Numbers/UInt32Polyfill.cs index 859149bed..e11b65c90 100644 --- a/src/Split/netcoreapp2.0/Numbers/UInt32Polyfill.cs +++ b/src/Split/netcoreapp2.0/Numbers/UInt32Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,37 +12,44 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out uint result) => uint.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out uint result) => uint.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out uint result) => uint.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its uint equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out uint result) => uint.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its uint equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out uint result) => uint.TryParse(s.ToString(), out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its uint equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out uint result) => uint.TryParse(s.ToString(), style, provider, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out uint result) => uint.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/netcoreapp2.0/Numbers/UInt64Polyfill.cs b/src/Split/netcoreapp2.0/Numbers/UInt64Polyfill.cs index c14bb347c..10122d2b4 100644 --- a/src/Split/netcoreapp2.0/Numbers/UInt64Polyfill.cs +++ b/src/Split/netcoreapp2.0/Numbers/UInt64Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,37 +12,44 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out ulong result) => ulong.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out ulong result) => ulong.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpanutf8Text, NumberStyles style, IFormatProvider? provider, out ulong result) => ulong.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its ulong equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out ulong result) => ulong.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its ulong equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out ulong result) => ulong.TryParse(s.ToString(), out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its ulong equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out ulong result) => ulong.TryParse(s.ToString(), style, provider, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out ulong result) => ulong.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/netcoreapp2.0/OperatingSystemPolyfill.cs b/src/Split/netcoreapp2.0/OperatingSystemPolyfill.cs index 5d1f8de36..68413c7d5 100644 --- a/src/Split/netcoreapp2.0/OperatingSystemPolyfill.cs +++ b/src/Split/netcoreapp2.0/OperatingSystemPolyfill.cs @@ -3,6 +3,7 @@ #if FeatureRuntimeInformation namespace Polyfills; using System; +using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; static partial class Polyfill @@ -14,114 +15,135 @@ static bool IsOsVersionAtLeast(int major, int minor = 0, int build = 0, int revi /// /// Indicates whether the current application is running as WASI. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsWasi() => RuntimeInformation.IsOSPlatform(OSPlatform.Create("WASI")); /// /// Indicates whether the current application is running on Mac Catalyst. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsMacCatalyst() => OperatingSystem.IsMacOS() || OperatingSystem.IsIOS(); /// /// Check for the Mac Catalyst version (iOS version as presented in Apple documentation) with a ≤ version comparison. Used to guard APIs that were added in the given Mac Catalyst release. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsMacCatalystVersionAtLeast(int major, int minor = 0, int build = 0) => IsMacCatalyst() && IsOsVersionAtLeast(major, minor, build); /// /// Checks if the macOS version (returned by libobjc.get_operatingSystemVersion) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified macOS version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsMacOSVersionAtLeast(int major, int minor = 0, int build = 0) => OperatingSystemCache.IsMacOSVersionAtLeast(major, minor, build); /// /// Checks if the FreeBSD version (returned by the Linux command uname) is greater than or equal to the specified version. /// This method can be used to guard APIs that were added in the specified version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsFreeBSDVersionAtLeast(int major, int minor, int build = 0, int revision = 0) => OperatingSystemCache.IsFreeBSDVersionAtLeast(major, minor, build, revision); /// /// Indicates whether the current application is running on Android. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsAndroid() => OperatingSystemCache.IsAndroid(); /// /// Checks if the Android version (returned by the Linux command uname) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsAndroidVersionAtLeast(int major, int minor = 0, int build = 0, int revision = 0) => OperatingSystemCache.IsAndroidVersionAtLeast(major, minor, build, revision); /// /// Checks if the Windows version (returned by RtlGetVersion) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified Windows version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsWindowsVersionAtLeast(int major, int minor = 0, int build = 0, int revision = 0) => OperatingSystemCache.IsWindowsVersionAtLeast(major, minor, build, revision); /// /// Indicates whether the current application is running on the specified platform. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsOSPlatform(string platform) => RuntimeInformation.IsOSPlatform(OSPlatform.Create(platform)); /// /// Checks if the operating system version is greater than or equal to the specified platform version. This method can be used to guard APIs that were added in the specified OS version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsOSPlatformVersionAtLeast(string platform, int major, int minor = 0, int build = 0, int revision = 0) => IsOSPlatform(platform) && IsOsVersionAtLeast(major, minor, build, revision); /// /// Indicates whether the current application is running on Windows. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsWindows() => RuntimeInformation.IsOSPlatform(OSPlatform.Windows); /// /// Indicates whether the current application is running on macOS. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsMacOS() => RuntimeInformation.IsOSPlatform(OSPlatform.OSX); /// /// Indicates whether the current application is running on iOS or MacCatalyst. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsIOS() => RuntimeInformation.IsOSPlatform(OSPlatform.Create("IOS")); /// /// Indicates whether the current application is running on Linux. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsLinux() => RuntimeInformation.IsOSPlatform(OSPlatform.Linux); /// /// Indicates whether the current application is running on FreeBSD. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsFreeBSD() => RuntimeInformation.OSDescription.ToLower().Contains("freebsd"); /// /// Checks if the iOS/MacCatalyst version (returned by libobjc.get_operatingSystemVersion) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified iOS version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsIOSVersionAtLeast(int major, int minor = 0, int build = 0) => IsIOS() && IsOsVersionAtLeast(major, minor, build); /// /// Checks if the tvOS version (returned by libobjc.get_operatingSystemVersion) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified tvOS version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsTvOSVersionAtLeast(int major, int minor = 0, int build = 0) => IsTvOS() && IsOsVersionAtLeast(major, minor, build); /// /// Indicates whether the current application is running on tvOS. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsTvOS() => RuntimeInformation.IsOSPlatform(OSPlatform.Create("TVOS")); /// /// Indicates whether the current application is running on watchOS. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsWatchOS() => IsIOS() || RuntimeInformation.OSDescription.ToLower().Contains("watchos"); /// /// Checks if the watchOS version (returned by libobjc.get_operatingSystemVersion) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified watchOS version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsWatchOSVersionAtLeast(int major, int minor = 0, int build = 0) => IsWatchOS() && IsOsVersionAtLeast(major, minor, build); /// /// Indicates whether the current application is running as WASM in a browser. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsBrowser() => RuntimeInformation.IsOSPlatform(OSPlatform.Create("BROWSER")); } diff --git a/src/Split/netcoreapp2.0/PathPolyfill.cs b/src/Split/netcoreapp2.0/PathPolyfill.cs index fb4329ac6..fc8009da8 100644 --- a/src/Split/netcoreapp2.0/PathPolyfill.cs +++ b/src/Split/netcoreapp2.0/PathPolyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.IO; +using System.Runtime.CompilerServices; static partial class Polyfill { extension(Path) @@ -11,41 +12,49 @@ static partial class Polyfill /// /// Returns the directory information for the specified path represented by a character span. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ReadOnlySpan GetDirectoryName(ReadOnlySpan path) => Path.GetDirectoryName(path.ToString()).AsSpan(); /// /// Returns the file name and extension of a file path that is represented by a read-only character span. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ReadOnlySpan GetFileName(ReadOnlySpan path) => Path.GetFileName(path.ToString()).AsSpan(); /// /// Returns the file name without the extension of a file path that is represented by a read-only character span. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ReadOnlySpan GetFileNameWithoutExtension(ReadOnlySpan path) => Path.GetFileNameWithoutExtension(path.ToString()).AsSpan(); /// /// Determines whether the path represented by the specified character span includes a file name extension. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool HasExtension(ReadOnlySpan path) => Path.HasExtension(path.ToString()); /// /// Returns the extension of the given path. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ReadOnlySpan GetExtension(ReadOnlySpan path) => Path.GetExtension(path.ToString()).AsSpan(); /// /// Combines a span of strings into a path. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string Combine(scoped ReadOnlySpan paths) => Path.Combine(paths.ToArray()); /// /// Returns a value that indicates whether the path, specified as a read-only span, ends in a directory separator. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool EndsInDirectorySeparator (ReadOnlySpan path) => EndsInDirectorySeparator(path.ToString()); /// /// Trims one trailing directory separator beyond the root of the specified path. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ReadOnlySpan TrimEndingDirectorySeparator(ReadOnlySpan path) => TrimEndingDirectorySeparator(path.ToString()).AsSpan(); #endif diff --git a/src/Split/netcoreapp2.1/ConsolePolyfill.cs b/src/Split/netcoreapp2.1/ConsolePolyfill.cs index 425364db8..5ad0342de 100644 --- a/src/Split/netcoreapp2.1/ConsolePolyfill.cs +++ b/src/Split/netcoreapp2.1/ConsolePolyfill.cs @@ -4,6 +4,7 @@ namespace Polyfills; using System; using System.Runtime.InteropServices; +using System.Runtime.CompilerServices; using Microsoft.Win32.SafeHandles; static partial class Polyfill { @@ -12,16 +13,19 @@ static partial class Polyfill /// /// Gets a that wraps the operating system handle for standard input. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static SafeFileHandle OpenStandardInputHandle() => StandardHandleHelper.GetStandardHandle(StandardHandleHelper.StdInput); /// /// Gets a that wraps the operating system handle for standard output. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static SafeFileHandle OpenStandardOutputHandle() => StandardHandleHelper.GetStandardHandle(StandardHandleHelper.StdOutput); /// /// Gets a that wraps the operating system handle for standard error. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static SafeFileHandle OpenStandardErrorHandle() => StandardHandleHelper.GetStandardHandle(StandardHandleHelper.StdError); } diff --git a/src/Split/netcoreapp2.1/ConvertPolyfill.cs b/src/Split/netcoreapp2.1/ConvertPolyfill.cs index 8ca6da94f..5f80df1f7 100644 --- a/src/Split/netcoreapp2.1/ConvertPolyfill.cs +++ b/src/Split/netcoreapp2.1/ConvertPolyfill.cs @@ -2,6 +2,7 @@ #pragma warning disable namespace Polyfills; using System; +using System.Runtime.CompilerServices; static partial class Polyfill { extension(Convert) @@ -10,22 +11,26 @@ static partial class Polyfill /// Converts a subset of an array of 8-bit unsigned integers to its equivalent string representation that is encoded with uppercase hex characters. /// Parameters specify the subset as an offset in the input array and the number of elements in the array to convert. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexString(byte[] inArray, int offset, int length) => ToHexString(inArray, offset, length, "X2"); /// /// Converts a subset of an array of 8-bit unsigned integers to its equivalent string representation that is encoded with lowercase hex characters. /// Parameters specify the subset as an offset in the input array and the number of elements in the array to convert. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexStringLower(byte[] inArray, int offset, int length) => ToHexString(inArray, offset, length, "x2"); /// /// Converts an array of 8-bit unsigned integers to its equivalent string representation that is encoded with lowercase hex characters. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexStringLower(byte[] inArray) => Polyfill.ToHexStringLower(inArray, 0, inArray.Length); /// /// Converts an array of 8-bit unsigned integers to its equivalent string representation that is encoded with uppercase hex characters. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexString(byte[] inArray) => Polyfill.ToHexString(inArray, 0, inArray.Length); /// @@ -54,16 +59,19 @@ static int GetHexValue(char hex) => /// /// Converts the span, which encodes binary data as hex characters, to an equivalent 8-bit unsigned integer array. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static byte[] FromHexString(ReadOnlySpan chars) => Polyfill.FromHexString(chars.ToString()); /// /// Converts a span of 8-bit unsigned integers to its equivalent string representation that is encoded with uppercase hex characters. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexString(ReadOnlySpan bytes) => Polyfill.ToHexString(bytes.ToArray()); /// /// Converts a span of 8-bit unsigned integers to its equivalent string representation that is encoded with lowercase hex characters. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexStringLower(ReadOnlySpan bytes) => Polyfill.ToHexStringLower(bytes.ToArray()); /// diff --git a/src/Split/netcoreapp2.1/DateTimeOffsetPolyfill.cs b/src/Split/netcoreapp2.1/DateTimeOffsetPolyfill.cs index 5a5018208..11ea73e02 100644 --- a/src/Split/netcoreapp2.1/DateTimeOffsetPolyfill.cs +++ b/src/Split/netcoreapp2.1/DateTimeOffsetPolyfill.cs @@ -4,6 +4,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; static partial class Polyfill { extension(DateTimeOffset target) @@ -30,27 +31,32 @@ long TicksComponent() /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out DateTimeOffset result) => DateTimeOffset.TryParse(s, provider, DateTimeStyles.None, out result); #if FeatureMemory /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out DateTimeOffset result) => DateTimeOffset.TryParse(s.ToString(), provider, DateTimeStyles.None, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan input, out DateTimeOffset result) => DateTimeOffset.TryParse(input.ToString(), null, DateTimeStyles.None, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, DateTimeStyles styles, out DateTimeOffset result) => DateTimeOffset.TryParse(s.ToString(), provider, styles, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParseExact(ReadOnlySpan input, string format, IFormatProvider? provider, DateTimeStyles styles, out DateTimeOffset result) => DateTimeOffset.TryParseExact(input.ToString(), format, provider, styles, out result); #endif diff --git a/src/Split/netcoreapp2.1/DateTimePolyfill.cs b/src/Split/netcoreapp2.1/DateTimePolyfill.cs index 4641f3e59..4d329796a 100644 --- a/src/Split/netcoreapp2.1/DateTimePolyfill.cs +++ b/src/Split/netcoreapp2.1/DateTimePolyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; static partial class Polyfill { extension(DateTime target) @@ -29,32 +30,38 @@ long TicksComponent() /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out DateTime result) => DateTime.TryParse(s, provider, DateTimeStyles.None, out result); #if FeatureMemory /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out DateTime result) => DateTime.TryParse(s.ToString(), provider, DateTimeStyles.None, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out DateTime result) => DateTime.TryParse(s.ToString(), null, DateTimeStyles.None, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, DateTimeStyles styles, out DateTime result) => DateTime.TryParse(s.ToString(), provider, styles, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParseExact(ReadOnlySpan s, string format, IFormatProvider? provider, DateTimeStyles style, out DateTime result) => DateTime.TryParseExact(s.ToString(), format, provider, style, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParseExact(ReadOnlySpan s, ReadOnlySpan format, IFormatProvider? provider, DateTimeStyles styles, out DateTime result) => DateTime.TryParseExact(s.ToString(), format.ToString(), provider, styles, out result); #endif diff --git a/src/Split/netcoreapp2.1/DelegatePolyfill.cs b/src/Split/netcoreapp2.1/DelegatePolyfill.cs index effdb1267..59cc5e315 100644 --- a/src/Split/netcoreapp2.1/DelegatePolyfill.cs +++ b/src/Split/netcoreapp2.1/DelegatePolyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.ComponentModel; +using System.Runtime.CompilerServices; static partial class Polyfill { /// @@ -39,6 +40,7 @@ public bool MoveNext() /// /// Gets an enumerator for the invocation targets of this delegate. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static InvocationListEnumerator EnumerateInvocationList(TDelegate? target) where TDelegate : Delegate => new(target); diff --git a/src/Split/netcoreapp2.1/FilePolyfill.cs b/src/Split/netcoreapp2.1/FilePolyfill.cs index 3e55baa26..fa568149e 100644 --- a/src/Split/netcoreapp2.1/FilePolyfill.cs +++ b/src/Split/netcoreapp2.1/FilePolyfill.cs @@ -48,11 +48,13 @@ public static Task AppendAllTextAsync(string path, ReadOnlyMemory contents /// /// Appends the specified string to the file, creating the file if it does not already exist. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void AppendAllText(string path, ReadOnlySpan contents) => File.AppendAllText(path, contents.ToString()); /// /// Appends the specified string to the file, creating the file if it does not already exist. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void AppendAllText(string path, ReadOnlySpan contents, Encoding encoding) => File.AppendAllText(path, contents.ToString(), encoding); /// @@ -76,12 +78,14 @@ public static async Task WriteAllBytesAsync(string path, ReadOnlyMemory by /// Creates a new file, writes the specified string to the file, and then closes the file. /// If the target file already exists, it is truncated and overwritten. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void WriteAllText(string path, ReadOnlySpan contents) => File.WriteAllText(path, contents.ToString()); /// /// Creates a new file, writes the specified string to the file using the specified encoding, and then closes the file. /// If the target file already exists, it is truncated and overwritten. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void WriteAllText(string path, ReadOnlySpan contents, Encoding encoding) => File.WriteAllText(path, contents.ToString(), encoding); /// diff --git a/src/Split/netcoreapp2.1/GuidPolyfill.cs b/src/Split/netcoreapp2.1/GuidPolyfill.cs index a29acf18a..90b6c9f48 100644 --- a/src/Split/netcoreapp2.1/GuidPolyfill.cs +++ b/src/Split/netcoreapp2.1/GuidPolyfill.cs @@ -4,6 +4,7 @@ namespace Polyfills; using System.Text; using System; using System.Security.Cryptography; +using System.Runtime.CompilerServices; static partial class Polyfill { extension(Guid) @@ -11,9 +12,11 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out Guid result) => Guid.TryParse(s, out result); /// Creates a new according to RFC 9562, following the Version 7 format. + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Guid CreateVersion7() => CreateVersion7(DateTimeOffset.UtcNow); /// Creates a new according to RFC 9562, following the Version 7 format. public static Guid CreateVersion7(DateTimeOffset timestamp) @@ -40,21 +43,25 @@ public static Guid CreateVersion7(DateTimeOffset timestamp) /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out Guid result) => Guid.TryParse(s.ToString(), out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan input, out Guid result) => Guid.TryParse(input.ToString(), out result); /// /// Tries to parse a span of UTF-8 bytes into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out Guid result) => Guid.TryParse(Encoding.UTF8.GetString(utf8Text), out result); /// /// Parse a span of UTF-8 bytes into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Guid Parse(ReadOnlySpan utf8Text) => Guid.Parse(Encoding.UTF8.GetString(utf8Text)); #endif diff --git a/src/Split/netcoreapp2.1/Lock.cs b/src/Split/netcoreapp2.1/Lock.cs index 94fcf1ff9..36946028c 100644 --- a/src/Split/netcoreapp2.1/Lock.cs +++ b/src/Split/netcoreapp2.1/Lock.cs @@ -5,6 +5,7 @@ namespace System.Threading; using Diagnostics; using Diagnostics.CodeAnalysis; +using Runtime.CompilerServices; /// /// Provides a way to get mutual exclusion in regions of code between different threads. A lock may be held by one thread at /// a time. @@ -23,26 +24,31 @@ class Lock /// /// Enters the lock. Once the method returns, the calling thread would be the only thread that holds the lock. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Enter() => Monitor.Enter(this); /// /// Tries to enter the lock without waiting. If the lock is entered, the calling thread would be the only thread that /// holds the lock. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool TryEnter() => Monitor.TryEnter(this); /// /// Tries to enter the lock, waiting for roughly the specified duration. If the lock is entered, the calling thread /// would be the only thread that holds the lock. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool TryEnter(TimeSpan timeout) => Monitor.TryEnter(this, timeout); /// /// Tries to enter the lock, waiting for roughly the specified duration. If the lock is entered, the calling thread /// would be the only thread that holds the lock. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool TryEnter(int millisecondsTimeout) => TryEnter(TimeSpan.FromMilliseconds(millisecondsTimeout)); /// /// Exits the lock. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Exit() => Monitor.Exit(this); /// /// Enters the lock and returns a that may be disposed to exit the lock. Once the method returns, diff --git a/src/Split/netcoreapp2.1/Numbers/BytePolyfill.cs b/src/Split/netcoreapp2.1/Numbers/BytePolyfill.cs index b32351497..fd1d5aa6f 100644 --- a/src/Split/netcoreapp2.1/Numbers/BytePolyfill.cs +++ b/src/Split/netcoreapp2.1/Numbers/BytePolyfill.cs @@ -4,6 +4,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -12,27 +13,32 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out byte result) => byte.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out byte result) => byte.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out byte result) => byte.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out byte result) => byte.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its byte equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out byte result) => byte.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); #endif diff --git a/src/Split/netcoreapp2.1/Numbers/DoublePolyfill.cs b/src/Split/netcoreapp2.1/Numbers/DoublePolyfill.cs index ff9f8aca6..94b44e869 100644 --- a/src/Split/netcoreapp2.1/Numbers/DoublePolyfill.cs +++ b/src/Split/netcoreapp2.1/Numbers/DoublePolyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,27 +12,32 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out double result) => double.TryParse(s, NumberStyles.Float, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out double result) => double.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Float, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out double result) => double.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its double-precision floating-point number equivalent.. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out double result) => double.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Float, null, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out double result) => double.TryParse(s.ToString(), NumberStyles.Float, provider, out result); #endif diff --git a/src/Split/netcoreapp2.1/Numbers/Int16Polyfill.cs b/src/Split/netcoreapp2.1/Numbers/Int16Polyfill.cs index 7a1f0b7c0..4447a9ecf 100644 --- a/src/Split/netcoreapp2.1/Numbers/Int16Polyfill.cs +++ b/src/Split/netcoreapp2.1/Numbers/Int16Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,27 +12,32 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out short result) => short.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out short result) => short.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out short result) => short.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its short equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out short result) => short.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out short result) => short.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/netcoreapp2.1/Numbers/Int32Polyfill.cs b/src/Split/netcoreapp2.1/Numbers/Int32Polyfill.cs index 853dfb518..587b2be91 100644 --- a/src/Split/netcoreapp2.1/Numbers/Int32Polyfill.cs +++ b/src/Split/netcoreapp2.1/Numbers/Int32Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,27 +12,32 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out int result) => int.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out int result) => int.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out int result) => int.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its 32-bit signed integer equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out int result) => int.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out int result) => int.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/netcoreapp2.1/Numbers/Int64Polyfill.cs b/src/Split/netcoreapp2.1/Numbers/Int64Polyfill.cs index e97be4775..3d7b5c57f 100644 --- a/src/Split/netcoreapp2.1/Numbers/Int64Polyfill.cs +++ b/src/Split/netcoreapp2.1/Numbers/Int64Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,27 +12,32 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out long result) => long.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out long result) => long.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out long result) => long.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its 64-bit signed integer equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out long result) => long.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out long result) => long.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/netcoreapp2.1/Numbers/SBytePolyfill.cs b/src/Split/netcoreapp2.1/Numbers/SBytePolyfill.cs index 9085c3aec..8de2ac072 100644 --- a/src/Split/netcoreapp2.1/Numbers/SBytePolyfill.cs +++ b/src/Split/netcoreapp2.1/Numbers/SBytePolyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,27 +12,32 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out sbyte result) => sbyte.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out sbyte result) => sbyte.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out sbyte result) => sbyte.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its sbyte equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out sbyte result) => sbyte.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out sbyte result) => sbyte.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/netcoreapp2.1/Numbers/UInt16Polyfill.cs b/src/Split/netcoreapp2.1/Numbers/UInt16Polyfill.cs index 11d4c4ed7..b3b68b25f 100644 --- a/src/Split/netcoreapp2.1/Numbers/UInt16Polyfill.cs +++ b/src/Split/netcoreapp2.1/Numbers/UInt16Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,27 +12,32 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out ushort result) => ushort.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out ushort result) => ushort.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out ushort result) => ushort.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its ushort equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out ushort result) => ushort.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out ushort result) => ushort.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/netcoreapp2.1/Numbers/UInt32Polyfill.cs b/src/Split/netcoreapp2.1/Numbers/UInt32Polyfill.cs index abdf707dd..4ba985db3 100644 --- a/src/Split/netcoreapp2.1/Numbers/UInt32Polyfill.cs +++ b/src/Split/netcoreapp2.1/Numbers/UInt32Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,27 +12,32 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out uint result) => uint.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out uint result) => uint.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out uint result) => uint.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its uint equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out uint result) => uint.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out uint result) => uint.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/netcoreapp2.1/Numbers/UInt64Polyfill.cs b/src/Split/netcoreapp2.1/Numbers/UInt64Polyfill.cs index 1a1bc228c..08e8b0fad 100644 --- a/src/Split/netcoreapp2.1/Numbers/UInt64Polyfill.cs +++ b/src/Split/netcoreapp2.1/Numbers/UInt64Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,27 +12,32 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out ulong result) => ulong.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out ulong result) => ulong.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpanutf8Text, NumberStyles style, IFormatProvider? provider, out ulong result) => ulong.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its ulong equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out ulong result) => ulong.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out ulong result) => ulong.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/netcoreapp2.1/OperatingSystemPolyfill.cs b/src/Split/netcoreapp2.1/OperatingSystemPolyfill.cs index 5d1f8de36..68413c7d5 100644 --- a/src/Split/netcoreapp2.1/OperatingSystemPolyfill.cs +++ b/src/Split/netcoreapp2.1/OperatingSystemPolyfill.cs @@ -3,6 +3,7 @@ #if FeatureRuntimeInformation namespace Polyfills; using System; +using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; static partial class Polyfill @@ -14,114 +15,135 @@ static bool IsOsVersionAtLeast(int major, int minor = 0, int build = 0, int revi /// /// Indicates whether the current application is running as WASI. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsWasi() => RuntimeInformation.IsOSPlatform(OSPlatform.Create("WASI")); /// /// Indicates whether the current application is running on Mac Catalyst. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsMacCatalyst() => OperatingSystem.IsMacOS() || OperatingSystem.IsIOS(); /// /// Check for the Mac Catalyst version (iOS version as presented in Apple documentation) with a ≤ version comparison. Used to guard APIs that were added in the given Mac Catalyst release. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsMacCatalystVersionAtLeast(int major, int minor = 0, int build = 0) => IsMacCatalyst() && IsOsVersionAtLeast(major, minor, build); /// /// Checks if the macOS version (returned by libobjc.get_operatingSystemVersion) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified macOS version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsMacOSVersionAtLeast(int major, int minor = 0, int build = 0) => OperatingSystemCache.IsMacOSVersionAtLeast(major, minor, build); /// /// Checks if the FreeBSD version (returned by the Linux command uname) is greater than or equal to the specified version. /// This method can be used to guard APIs that were added in the specified version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsFreeBSDVersionAtLeast(int major, int minor, int build = 0, int revision = 0) => OperatingSystemCache.IsFreeBSDVersionAtLeast(major, minor, build, revision); /// /// Indicates whether the current application is running on Android. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsAndroid() => OperatingSystemCache.IsAndroid(); /// /// Checks if the Android version (returned by the Linux command uname) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsAndroidVersionAtLeast(int major, int minor = 0, int build = 0, int revision = 0) => OperatingSystemCache.IsAndroidVersionAtLeast(major, minor, build, revision); /// /// Checks if the Windows version (returned by RtlGetVersion) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified Windows version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsWindowsVersionAtLeast(int major, int minor = 0, int build = 0, int revision = 0) => OperatingSystemCache.IsWindowsVersionAtLeast(major, minor, build, revision); /// /// Indicates whether the current application is running on the specified platform. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsOSPlatform(string platform) => RuntimeInformation.IsOSPlatform(OSPlatform.Create(platform)); /// /// Checks if the operating system version is greater than or equal to the specified platform version. This method can be used to guard APIs that were added in the specified OS version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsOSPlatformVersionAtLeast(string platform, int major, int minor = 0, int build = 0, int revision = 0) => IsOSPlatform(platform) && IsOsVersionAtLeast(major, minor, build, revision); /// /// Indicates whether the current application is running on Windows. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsWindows() => RuntimeInformation.IsOSPlatform(OSPlatform.Windows); /// /// Indicates whether the current application is running on macOS. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsMacOS() => RuntimeInformation.IsOSPlatform(OSPlatform.OSX); /// /// Indicates whether the current application is running on iOS or MacCatalyst. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsIOS() => RuntimeInformation.IsOSPlatform(OSPlatform.Create("IOS")); /// /// Indicates whether the current application is running on Linux. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsLinux() => RuntimeInformation.IsOSPlatform(OSPlatform.Linux); /// /// Indicates whether the current application is running on FreeBSD. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsFreeBSD() => RuntimeInformation.OSDescription.ToLower().Contains("freebsd"); /// /// Checks if the iOS/MacCatalyst version (returned by libobjc.get_operatingSystemVersion) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified iOS version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsIOSVersionAtLeast(int major, int minor = 0, int build = 0) => IsIOS() && IsOsVersionAtLeast(major, minor, build); /// /// Checks if the tvOS version (returned by libobjc.get_operatingSystemVersion) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified tvOS version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsTvOSVersionAtLeast(int major, int minor = 0, int build = 0) => IsTvOS() && IsOsVersionAtLeast(major, minor, build); /// /// Indicates whether the current application is running on tvOS. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsTvOS() => RuntimeInformation.IsOSPlatform(OSPlatform.Create("TVOS")); /// /// Indicates whether the current application is running on watchOS. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsWatchOS() => IsIOS() || RuntimeInformation.OSDescription.ToLower().Contains("watchos"); /// /// Checks if the watchOS version (returned by libobjc.get_operatingSystemVersion) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified watchOS version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsWatchOSVersionAtLeast(int major, int minor = 0, int build = 0) => IsWatchOS() && IsOsVersionAtLeast(major, minor, build); /// /// Indicates whether the current application is running as WASM in a browser. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsBrowser() => RuntimeInformation.IsOSPlatform(OSPlatform.Create("BROWSER")); } diff --git a/src/Split/netcoreapp2.1/PathPolyfill.cs b/src/Split/netcoreapp2.1/PathPolyfill.cs index dc917864e..607d9e14e 100644 --- a/src/Split/netcoreapp2.1/PathPolyfill.cs +++ b/src/Split/netcoreapp2.1/PathPolyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.IO; +using System.Runtime.CompilerServices; static partial class Polyfill { extension(Path) @@ -11,16 +12,19 @@ static partial class Polyfill /// /// Combines a span of strings into a path. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string Combine(scoped ReadOnlySpan paths) => Path.Combine(paths.ToArray()); /// /// Returns a value that indicates whether the path, specified as a read-only span, ends in a directory separator. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool EndsInDirectorySeparator (ReadOnlySpan path) => EndsInDirectorySeparator(path.ToString()); /// /// Trims one trailing directory separator beyond the root of the specified path. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ReadOnlySpan TrimEndingDirectorySeparator(ReadOnlySpan path) => TrimEndingDirectorySeparator(path.ToString()).AsSpan(); #endif diff --git a/src/Split/netcoreapp2.2/ConsolePolyfill.cs b/src/Split/netcoreapp2.2/ConsolePolyfill.cs index 425364db8..5ad0342de 100644 --- a/src/Split/netcoreapp2.2/ConsolePolyfill.cs +++ b/src/Split/netcoreapp2.2/ConsolePolyfill.cs @@ -4,6 +4,7 @@ namespace Polyfills; using System; using System.Runtime.InteropServices; +using System.Runtime.CompilerServices; using Microsoft.Win32.SafeHandles; static partial class Polyfill { @@ -12,16 +13,19 @@ static partial class Polyfill /// /// Gets a that wraps the operating system handle for standard input. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static SafeFileHandle OpenStandardInputHandle() => StandardHandleHelper.GetStandardHandle(StandardHandleHelper.StdInput); /// /// Gets a that wraps the operating system handle for standard output. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static SafeFileHandle OpenStandardOutputHandle() => StandardHandleHelper.GetStandardHandle(StandardHandleHelper.StdOutput); /// /// Gets a that wraps the operating system handle for standard error. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static SafeFileHandle OpenStandardErrorHandle() => StandardHandleHelper.GetStandardHandle(StandardHandleHelper.StdError); } diff --git a/src/Split/netcoreapp2.2/ConvertPolyfill.cs b/src/Split/netcoreapp2.2/ConvertPolyfill.cs index 8ca6da94f..5f80df1f7 100644 --- a/src/Split/netcoreapp2.2/ConvertPolyfill.cs +++ b/src/Split/netcoreapp2.2/ConvertPolyfill.cs @@ -2,6 +2,7 @@ #pragma warning disable namespace Polyfills; using System; +using System.Runtime.CompilerServices; static partial class Polyfill { extension(Convert) @@ -10,22 +11,26 @@ static partial class Polyfill /// Converts a subset of an array of 8-bit unsigned integers to its equivalent string representation that is encoded with uppercase hex characters. /// Parameters specify the subset as an offset in the input array and the number of elements in the array to convert. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexString(byte[] inArray, int offset, int length) => ToHexString(inArray, offset, length, "X2"); /// /// Converts a subset of an array of 8-bit unsigned integers to its equivalent string representation that is encoded with lowercase hex characters. /// Parameters specify the subset as an offset in the input array and the number of elements in the array to convert. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexStringLower(byte[] inArray, int offset, int length) => ToHexString(inArray, offset, length, "x2"); /// /// Converts an array of 8-bit unsigned integers to its equivalent string representation that is encoded with lowercase hex characters. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexStringLower(byte[] inArray) => Polyfill.ToHexStringLower(inArray, 0, inArray.Length); /// /// Converts an array of 8-bit unsigned integers to its equivalent string representation that is encoded with uppercase hex characters. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexString(byte[] inArray) => Polyfill.ToHexString(inArray, 0, inArray.Length); /// @@ -54,16 +59,19 @@ static int GetHexValue(char hex) => /// /// Converts the span, which encodes binary data as hex characters, to an equivalent 8-bit unsigned integer array. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static byte[] FromHexString(ReadOnlySpan chars) => Polyfill.FromHexString(chars.ToString()); /// /// Converts a span of 8-bit unsigned integers to its equivalent string representation that is encoded with uppercase hex characters. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexString(ReadOnlySpan bytes) => Polyfill.ToHexString(bytes.ToArray()); /// /// Converts a span of 8-bit unsigned integers to its equivalent string representation that is encoded with lowercase hex characters. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexStringLower(ReadOnlySpan bytes) => Polyfill.ToHexStringLower(bytes.ToArray()); /// diff --git a/src/Split/netcoreapp2.2/DateTimeOffsetPolyfill.cs b/src/Split/netcoreapp2.2/DateTimeOffsetPolyfill.cs index 5a5018208..11ea73e02 100644 --- a/src/Split/netcoreapp2.2/DateTimeOffsetPolyfill.cs +++ b/src/Split/netcoreapp2.2/DateTimeOffsetPolyfill.cs @@ -4,6 +4,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; static partial class Polyfill { extension(DateTimeOffset target) @@ -30,27 +31,32 @@ long TicksComponent() /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out DateTimeOffset result) => DateTimeOffset.TryParse(s, provider, DateTimeStyles.None, out result); #if FeatureMemory /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out DateTimeOffset result) => DateTimeOffset.TryParse(s.ToString(), provider, DateTimeStyles.None, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan input, out DateTimeOffset result) => DateTimeOffset.TryParse(input.ToString(), null, DateTimeStyles.None, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, DateTimeStyles styles, out DateTimeOffset result) => DateTimeOffset.TryParse(s.ToString(), provider, styles, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParseExact(ReadOnlySpan input, string format, IFormatProvider? provider, DateTimeStyles styles, out DateTimeOffset result) => DateTimeOffset.TryParseExact(input.ToString(), format, provider, styles, out result); #endif diff --git a/src/Split/netcoreapp2.2/DateTimePolyfill.cs b/src/Split/netcoreapp2.2/DateTimePolyfill.cs index 4641f3e59..4d329796a 100644 --- a/src/Split/netcoreapp2.2/DateTimePolyfill.cs +++ b/src/Split/netcoreapp2.2/DateTimePolyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; static partial class Polyfill { extension(DateTime target) @@ -29,32 +30,38 @@ long TicksComponent() /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out DateTime result) => DateTime.TryParse(s, provider, DateTimeStyles.None, out result); #if FeatureMemory /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out DateTime result) => DateTime.TryParse(s.ToString(), provider, DateTimeStyles.None, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out DateTime result) => DateTime.TryParse(s.ToString(), null, DateTimeStyles.None, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, DateTimeStyles styles, out DateTime result) => DateTime.TryParse(s.ToString(), provider, styles, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParseExact(ReadOnlySpan s, string format, IFormatProvider? provider, DateTimeStyles style, out DateTime result) => DateTime.TryParseExact(s.ToString(), format, provider, style, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParseExact(ReadOnlySpan s, ReadOnlySpan format, IFormatProvider? provider, DateTimeStyles styles, out DateTime result) => DateTime.TryParseExact(s.ToString(), format.ToString(), provider, styles, out result); #endif diff --git a/src/Split/netcoreapp2.2/DelegatePolyfill.cs b/src/Split/netcoreapp2.2/DelegatePolyfill.cs index effdb1267..59cc5e315 100644 --- a/src/Split/netcoreapp2.2/DelegatePolyfill.cs +++ b/src/Split/netcoreapp2.2/DelegatePolyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.ComponentModel; +using System.Runtime.CompilerServices; static partial class Polyfill { /// @@ -39,6 +40,7 @@ public bool MoveNext() /// /// Gets an enumerator for the invocation targets of this delegate. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static InvocationListEnumerator EnumerateInvocationList(TDelegate? target) where TDelegate : Delegate => new(target); diff --git a/src/Split/netcoreapp2.2/FilePolyfill.cs b/src/Split/netcoreapp2.2/FilePolyfill.cs index 3e55baa26..fa568149e 100644 --- a/src/Split/netcoreapp2.2/FilePolyfill.cs +++ b/src/Split/netcoreapp2.2/FilePolyfill.cs @@ -48,11 +48,13 @@ public static Task AppendAllTextAsync(string path, ReadOnlyMemory contents /// /// Appends the specified string to the file, creating the file if it does not already exist. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void AppendAllText(string path, ReadOnlySpan contents) => File.AppendAllText(path, contents.ToString()); /// /// Appends the specified string to the file, creating the file if it does not already exist. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void AppendAllText(string path, ReadOnlySpan contents, Encoding encoding) => File.AppendAllText(path, contents.ToString(), encoding); /// @@ -76,12 +78,14 @@ public static async Task WriteAllBytesAsync(string path, ReadOnlyMemory by /// Creates a new file, writes the specified string to the file, and then closes the file. /// If the target file already exists, it is truncated and overwritten. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void WriteAllText(string path, ReadOnlySpan contents) => File.WriteAllText(path, contents.ToString()); /// /// Creates a new file, writes the specified string to the file using the specified encoding, and then closes the file. /// If the target file already exists, it is truncated and overwritten. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void WriteAllText(string path, ReadOnlySpan contents, Encoding encoding) => File.WriteAllText(path, contents.ToString(), encoding); /// diff --git a/src/Split/netcoreapp2.2/GuidPolyfill.cs b/src/Split/netcoreapp2.2/GuidPolyfill.cs index a29acf18a..90b6c9f48 100644 --- a/src/Split/netcoreapp2.2/GuidPolyfill.cs +++ b/src/Split/netcoreapp2.2/GuidPolyfill.cs @@ -4,6 +4,7 @@ namespace Polyfills; using System.Text; using System; using System.Security.Cryptography; +using System.Runtime.CompilerServices; static partial class Polyfill { extension(Guid) @@ -11,9 +12,11 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out Guid result) => Guid.TryParse(s, out result); /// Creates a new according to RFC 9562, following the Version 7 format. + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Guid CreateVersion7() => CreateVersion7(DateTimeOffset.UtcNow); /// Creates a new according to RFC 9562, following the Version 7 format. public static Guid CreateVersion7(DateTimeOffset timestamp) @@ -40,21 +43,25 @@ public static Guid CreateVersion7(DateTimeOffset timestamp) /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out Guid result) => Guid.TryParse(s.ToString(), out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan input, out Guid result) => Guid.TryParse(input.ToString(), out result); /// /// Tries to parse a span of UTF-8 bytes into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out Guid result) => Guid.TryParse(Encoding.UTF8.GetString(utf8Text), out result); /// /// Parse a span of UTF-8 bytes into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Guid Parse(ReadOnlySpan utf8Text) => Guid.Parse(Encoding.UTF8.GetString(utf8Text)); #endif diff --git a/src/Split/netcoreapp2.2/Lock.cs b/src/Split/netcoreapp2.2/Lock.cs index 94fcf1ff9..36946028c 100644 --- a/src/Split/netcoreapp2.2/Lock.cs +++ b/src/Split/netcoreapp2.2/Lock.cs @@ -5,6 +5,7 @@ namespace System.Threading; using Diagnostics; using Diagnostics.CodeAnalysis; +using Runtime.CompilerServices; /// /// Provides a way to get mutual exclusion in regions of code between different threads. A lock may be held by one thread at /// a time. @@ -23,26 +24,31 @@ class Lock /// /// Enters the lock. Once the method returns, the calling thread would be the only thread that holds the lock. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Enter() => Monitor.Enter(this); /// /// Tries to enter the lock without waiting. If the lock is entered, the calling thread would be the only thread that /// holds the lock. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool TryEnter() => Monitor.TryEnter(this); /// /// Tries to enter the lock, waiting for roughly the specified duration. If the lock is entered, the calling thread /// would be the only thread that holds the lock. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool TryEnter(TimeSpan timeout) => Monitor.TryEnter(this, timeout); /// /// Tries to enter the lock, waiting for roughly the specified duration. If the lock is entered, the calling thread /// would be the only thread that holds the lock. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool TryEnter(int millisecondsTimeout) => TryEnter(TimeSpan.FromMilliseconds(millisecondsTimeout)); /// /// Exits the lock. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Exit() => Monitor.Exit(this); /// /// Enters the lock and returns a that may be disposed to exit the lock. Once the method returns, diff --git a/src/Split/netcoreapp2.2/Numbers/BytePolyfill.cs b/src/Split/netcoreapp2.2/Numbers/BytePolyfill.cs index b32351497..fd1d5aa6f 100644 --- a/src/Split/netcoreapp2.2/Numbers/BytePolyfill.cs +++ b/src/Split/netcoreapp2.2/Numbers/BytePolyfill.cs @@ -4,6 +4,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -12,27 +13,32 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out byte result) => byte.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out byte result) => byte.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out byte result) => byte.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out byte result) => byte.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its byte equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out byte result) => byte.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); #endif diff --git a/src/Split/netcoreapp2.2/Numbers/DoublePolyfill.cs b/src/Split/netcoreapp2.2/Numbers/DoublePolyfill.cs index ff9f8aca6..94b44e869 100644 --- a/src/Split/netcoreapp2.2/Numbers/DoublePolyfill.cs +++ b/src/Split/netcoreapp2.2/Numbers/DoublePolyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,27 +12,32 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out double result) => double.TryParse(s, NumberStyles.Float, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out double result) => double.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Float, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out double result) => double.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its double-precision floating-point number equivalent.. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out double result) => double.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Float, null, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out double result) => double.TryParse(s.ToString(), NumberStyles.Float, provider, out result); #endif diff --git a/src/Split/netcoreapp2.2/Numbers/Int16Polyfill.cs b/src/Split/netcoreapp2.2/Numbers/Int16Polyfill.cs index 7a1f0b7c0..4447a9ecf 100644 --- a/src/Split/netcoreapp2.2/Numbers/Int16Polyfill.cs +++ b/src/Split/netcoreapp2.2/Numbers/Int16Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,27 +12,32 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out short result) => short.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out short result) => short.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out short result) => short.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its short equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out short result) => short.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out short result) => short.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/netcoreapp2.2/Numbers/Int32Polyfill.cs b/src/Split/netcoreapp2.2/Numbers/Int32Polyfill.cs index 853dfb518..587b2be91 100644 --- a/src/Split/netcoreapp2.2/Numbers/Int32Polyfill.cs +++ b/src/Split/netcoreapp2.2/Numbers/Int32Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,27 +12,32 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out int result) => int.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out int result) => int.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out int result) => int.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its 32-bit signed integer equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out int result) => int.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out int result) => int.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/netcoreapp2.2/Numbers/Int64Polyfill.cs b/src/Split/netcoreapp2.2/Numbers/Int64Polyfill.cs index e97be4775..3d7b5c57f 100644 --- a/src/Split/netcoreapp2.2/Numbers/Int64Polyfill.cs +++ b/src/Split/netcoreapp2.2/Numbers/Int64Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,27 +12,32 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out long result) => long.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out long result) => long.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out long result) => long.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its 64-bit signed integer equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out long result) => long.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out long result) => long.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/netcoreapp2.2/Numbers/SBytePolyfill.cs b/src/Split/netcoreapp2.2/Numbers/SBytePolyfill.cs index 9085c3aec..8de2ac072 100644 --- a/src/Split/netcoreapp2.2/Numbers/SBytePolyfill.cs +++ b/src/Split/netcoreapp2.2/Numbers/SBytePolyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,27 +12,32 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out sbyte result) => sbyte.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out sbyte result) => sbyte.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out sbyte result) => sbyte.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its sbyte equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out sbyte result) => sbyte.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out sbyte result) => sbyte.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/netcoreapp2.2/Numbers/UInt16Polyfill.cs b/src/Split/netcoreapp2.2/Numbers/UInt16Polyfill.cs index 11d4c4ed7..b3b68b25f 100644 --- a/src/Split/netcoreapp2.2/Numbers/UInt16Polyfill.cs +++ b/src/Split/netcoreapp2.2/Numbers/UInt16Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,27 +12,32 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out ushort result) => ushort.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out ushort result) => ushort.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out ushort result) => ushort.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its ushort equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out ushort result) => ushort.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out ushort result) => ushort.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/netcoreapp2.2/Numbers/UInt32Polyfill.cs b/src/Split/netcoreapp2.2/Numbers/UInt32Polyfill.cs index abdf707dd..4ba985db3 100644 --- a/src/Split/netcoreapp2.2/Numbers/UInt32Polyfill.cs +++ b/src/Split/netcoreapp2.2/Numbers/UInt32Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,27 +12,32 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out uint result) => uint.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out uint result) => uint.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out uint result) => uint.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its uint equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out uint result) => uint.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out uint result) => uint.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/netcoreapp2.2/Numbers/UInt64Polyfill.cs b/src/Split/netcoreapp2.2/Numbers/UInt64Polyfill.cs index 1a1bc228c..08e8b0fad 100644 --- a/src/Split/netcoreapp2.2/Numbers/UInt64Polyfill.cs +++ b/src/Split/netcoreapp2.2/Numbers/UInt64Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,27 +12,32 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out ulong result) => ulong.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out ulong result) => ulong.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpanutf8Text, NumberStyles style, IFormatProvider? provider, out ulong result) => ulong.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its ulong equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out ulong result) => ulong.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out ulong result) => ulong.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/netcoreapp2.2/OperatingSystemPolyfill.cs b/src/Split/netcoreapp2.2/OperatingSystemPolyfill.cs index 5d1f8de36..68413c7d5 100644 --- a/src/Split/netcoreapp2.2/OperatingSystemPolyfill.cs +++ b/src/Split/netcoreapp2.2/OperatingSystemPolyfill.cs @@ -3,6 +3,7 @@ #if FeatureRuntimeInformation namespace Polyfills; using System; +using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; static partial class Polyfill @@ -14,114 +15,135 @@ static bool IsOsVersionAtLeast(int major, int minor = 0, int build = 0, int revi /// /// Indicates whether the current application is running as WASI. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsWasi() => RuntimeInformation.IsOSPlatform(OSPlatform.Create("WASI")); /// /// Indicates whether the current application is running on Mac Catalyst. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsMacCatalyst() => OperatingSystem.IsMacOS() || OperatingSystem.IsIOS(); /// /// Check for the Mac Catalyst version (iOS version as presented in Apple documentation) with a ≤ version comparison. Used to guard APIs that were added in the given Mac Catalyst release. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsMacCatalystVersionAtLeast(int major, int minor = 0, int build = 0) => IsMacCatalyst() && IsOsVersionAtLeast(major, minor, build); /// /// Checks if the macOS version (returned by libobjc.get_operatingSystemVersion) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified macOS version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsMacOSVersionAtLeast(int major, int minor = 0, int build = 0) => OperatingSystemCache.IsMacOSVersionAtLeast(major, minor, build); /// /// Checks if the FreeBSD version (returned by the Linux command uname) is greater than or equal to the specified version. /// This method can be used to guard APIs that were added in the specified version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsFreeBSDVersionAtLeast(int major, int minor, int build = 0, int revision = 0) => OperatingSystemCache.IsFreeBSDVersionAtLeast(major, minor, build, revision); /// /// Indicates whether the current application is running on Android. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsAndroid() => OperatingSystemCache.IsAndroid(); /// /// Checks if the Android version (returned by the Linux command uname) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsAndroidVersionAtLeast(int major, int minor = 0, int build = 0, int revision = 0) => OperatingSystemCache.IsAndroidVersionAtLeast(major, minor, build, revision); /// /// Checks if the Windows version (returned by RtlGetVersion) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified Windows version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsWindowsVersionAtLeast(int major, int minor = 0, int build = 0, int revision = 0) => OperatingSystemCache.IsWindowsVersionAtLeast(major, minor, build, revision); /// /// Indicates whether the current application is running on the specified platform. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsOSPlatform(string platform) => RuntimeInformation.IsOSPlatform(OSPlatform.Create(platform)); /// /// Checks if the operating system version is greater than or equal to the specified platform version. This method can be used to guard APIs that were added in the specified OS version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsOSPlatformVersionAtLeast(string platform, int major, int minor = 0, int build = 0, int revision = 0) => IsOSPlatform(platform) && IsOsVersionAtLeast(major, minor, build, revision); /// /// Indicates whether the current application is running on Windows. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsWindows() => RuntimeInformation.IsOSPlatform(OSPlatform.Windows); /// /// Indicates whether the current application is running on macOS. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsMacOS() => RuntimeInformation.IsOSPlatform(OSPlatform.OSX); /// /// Indicates whether the current application is running on iOS or MacCatalyst. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsIOS() => RuntimeInformation.IsOSPlatform(OSPlatform.Create("IOS")); /// /// Indicates whether the current application is running on Linux. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsLinux() => RuntimeInformation.IsOSPlatform(OSPlatform.Linux); /// /// Indicates whether the current application is running on FreeBSD. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsFreeBSD() => RuntimeInformation.OSDescription.ToLower().Contains("freebsd"); /// /// Checks if the iOS/MacCatalyst version (returned by libobjc.get_operatingSystemVersion) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified iOS version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsIOSVersionAtLeast(int major, int minor = 0, int build = 0) => IsIOS() && IsOsVersionAtLeast(major, minor, build); /// /// Checks if the tvOS version (returned by libobjc.get_operatingSystemVersion) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified tvOS version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsTvOSVersionAtLeast(int major, int minor = 0, int build = 0) => IsTvOS() && IsOsVersionAtLeast(major, minor, build); /// /// Indicates whether the current application is running on tvOS. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsTvOS() => RuntimeInformation.IsOSPlatform(OSPlatform.Create("TVOS")); /// /// Indicates whether the current application is running on watchOS. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsWatchOS() => IsIOS() || RuntimeInformation.OSDescription.ToLower().Contains("watchos"); /// /// Checks if the watchOS version (returned by libobjc.get_operatingSystemVersion) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified watchOS version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsWatchOSVersionAtLeast(int major, int minor = 0, int build = 0) => IsWatchOS() && IsOsVersionAtLeast(major, minor, build); /// /// Indicates whether the current application is running as WASM in a browser. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsBrowser() => RuntimeInformation.IsOSPlatform(OSPlatform.Create("BROWSER")); } diff --git a/src/Split/netcoreapp2.2/PathPolyfill.cs b/src/Split/netcoreapp2.2/PathPolyfill.cs index dc917864e..607d9e14e 100644 --- a/src/Split/netcoreapp2.2/PathPolyfill.cs +++ b/src/Split/netcoreapp2.2/PathPolyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.IO; +using System.Runtime.CompilerServices; static partial class Polyfill { extension(Path) @@ -11,16 +12,19 @@ static partial class Polyfill /// /// Combines a span of strings into a path. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string Combine(scoped ReadOnlySpan paths) => Path.Combine(paths.ToArray()); /// /// Returns a value that indicates whether the path, specified as a read-only span, ends in a directory separator. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool EndsInDirectorySeparator (ReadOnlySpan path) => EndsInDirectorySeparator(path.ToString()); /// /// Trims one trailing directory separator beyond the root of the specified path. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ReadOnlySpan TrimEndingDirectorySeparator(ReadOnlySpan path) => TrimEndingDirectorySeparator(path.ToString()).AsSpan(); #endif diff --git a/src/Split/netcoreapp3.0/ConsolePolyfill.cs b/src/Split/netcoreapp3.0/ConsolePolyfill.cs index 425364db8..5ad0342de 100644 --- a/src/Split/netcoreapp3.0/ConsolePolyfill.cs +++ b/src/Split/netcoreapp3.0/ConsolePolyfill.cs @@ -4,6 +4,7 @@ namespace Polyfills; using System; using System.Runtime.InteropServices; +using System.Runtime.CompilerServices; using Microsoft.Win32.SafeHandles; static partial class Polyfill { @@ -12,16 +13,19 @@ static partial class Polyfill /// /// Gets a that wraps the operating system handle for standard input. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static SafeFileHandle OpenStandardInputHandle() => StandardHandleHelper.GetStandardHandle(StandardHandleHelper.StdInput); /// /// Gets a that wraps the operating system handle for standard output. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static SafeFileHandle OpenStandardOutputHandle() => StandardHandleHelper.GetStandardHandle(StandardHandleHelper.StdOutput); /// /// Gets a that wraps the operating system handle for standard error. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static SafeFileHandle OpenStandardErrorHandle() => StandardHandleHelper.GetStandardHandle(StandardHandleHelper.StdError); } diff --git a/src/Split/netcoreapp3.0/ConvertPolyfill.cs b/src/Split/netcoreapp3.0/ConvertPolyfill.cs index 8ca6da94f..5f80df1f7 100644 --- a/src/Split/netcoreapp3.0/ConvertPolyfill.cs +++ b/src/Split/netcoreapp3.0/ConvertPolyfill.cs @@ -2,6 +2,7 @@ #pragma warning disable namespace Polyfills; using System; +using System.Runtime.CompilerServices; static partial class Polyfill { extension(Convert) @@ -10,22 +11,26 @@ static partial class Polyfill /// Converts a subset of an array of 8-bit unsigned integers to its equivalent string representation that is encoded with uppercase hex characters. /// Parameters specify the subset as an offset in the input array and the number of elements in the array to convert. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexString(byte[] inArray, int offset, int length) => ToHexString(inArray, offset, length, "X2"); /// /// Converts a subset of an array of 8-bit unsigned integers to its equivalent string representation that is encoded with lowercase hex characters. /// Parameters specify the subset as an offset in the input array and the number of elements in the array to convert. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexStringLower(byte[] inArray, int offset, int length) => ToHexString(inArray, offset, length, "x2"); /// /// Converts an array of 8-bit unsigned integers to its equivalent string representation that is encoded with lowercase hex characters. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexStringLower(byte[] inArray) => Polyfill.ToHexStringLower(inArray, 0, inArray.Length); /// /// Converts an array of 8-bit unsigned integers to its equivalent string representation that is encoded with uppercase hex characters. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexString(byte[] inArray) => Polyfill.ToHexString(inArray, 0, inArray.Length); /// @@ -54,16 +59,19 @@ static int GetHexValue(char hex) => /// /// Converts the span, which encodes binary data as hex characters, to an equivalent 8-bit unsigned integer array. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static byte[] FromHexString(ReadOnlySpan chars) => Polyfill.FromHexString(chars.ToString()); /// /// Converts a span of 8-bit unsigned integers to its equivalent string representation that is encoded with uppercase hex characters. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexString(ReadOnlySpan bytes) => Polyfill.ToHexString(bytes.ToArray()); /// /// Converts a span of 8-bit unsigned integers to its equivalent string representation that is encoded with lowercase hex characters. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexStringLower(ReadOnlySpan bytes) => Polyfill.ToHexStringLower(bytes.ToArray()); /// diff --git a/src/Split/netcoreapp3.0/DateTimeOffsetPolyfill.cs b/src/Split/netcoreapp3.0/DateTimeOffsetPolyfill.cs index 5a5018208..11ea73e02 100644 --- a/src/Split/netcoreapp3.0/DateTimeOffsetPolyfill.cs +++ b/src/Split/netcoreapp3.0/DateTimeOffsetPolyfill.cs @@ -4,6 +4,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; static partial class Polyfill { extension(DateTimeOffset target) @@ -30,27 +31,32 @@ long TicksComponent() /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out DateTimeOffset result) => DateTimeOffset.TryParse(s, provider, DateTimeStyles.None, out result); #if FeatureMemory /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out DateTimeOffset result) => DateTimeOffset.TryParse(s.ToString(), provider, DateTimeStyles.None, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan input, out DateTimeOffset result) => DateTimeOffset.TryParse(input.ToString(), null, DateTimeStyles.None, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, DateTimeStyles styles, out DateTimeOffset result) => DateTimeOffset.TryParse(s.ToString(), provider, styles, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParseExact(ReadOnlySpan input, string format, IFormatProvider? provider, DateTimeStyles styles, out DateTimeOffset result) => DateTimeOffset.TryParseExact(input.ToString(), format, provider, styles, out result); #endif diff --git a/src/Split/netcoreapp3.0/DateTimePolyfill.cs b/src/Split/netcoreapp3.0/DateTimePolyfill.cs index 4641f3e59..4d329796a 100644 --- a/src/Split/netcoreapp3.0/DateTimePolyfill.cs +++ b/src/Split/netcoreapp3.0/DateTimePolyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; static partial class Polyfill { extension(DateTime target) @@ -29,32 +30,38 @@ long TicksComponent() /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out DateTime result) => DateTime.TryParse(s, provider, DateTimeStyles.None, out result); #if FeatureMemory /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out DateTime result) => DateTime.TryParse(s.ToString(), provider, DateTimeStyles.None, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out DateTime result) => DateTime.TryParse(s.ToString(), null, DateTimeStyles.None, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, DateTimeStyles styles, out DateTime result) => DateTime.TryParse(s.ToString(), provider, styles, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParseExact(ReadOnlySpan s, string format, IFormatProvider? provider, DateTimeStyles style, out DateTime result) => DateTime.TryParseExact(s.ToString(), format, provider, style, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParseExact(ReadOnlySpan s, ReadOnlySpan format, IFormatProvider? provider, DateTimeStyles styles, out DateTime result) => DateTime.TryParseExact(s.ToString(), format.ToString(), provider, styles, out result); #endif diff --git a/src/Split/netcoreapp3.0/DelegatePolyfill.cs b/src/Split/netcoreapp3.0/DelegatePolyfill.cs index effdb1267..59cc5e315 100644 --- a/src/Split/netcoreapp3.0/DelegatePolyfill.cs +++ b/src/Split/netcoreapp3.0/DelegatePolyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.ComponentModel; +using System.Runtime.CompilerServices; static partial class Polyfill { /// @@ -39,6 +40,7 @@ public bool MoveNext() /// /// Gets an enumerator for the invocation targets of this delegate. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static InvocationListEnumerator EnumerateInvocationList(TDelegate? target) where TDelegate : Delegate => new(target); diff --git a/src/Split/netcoreapp3.0/FilePolyfill.cs b/src/Split/netcoreapp3.0/FilePolyfill.cs index ff68c4d3c..66d68b0ad 100644 --- a/src/Split/netcoreapp3.0/FilePolyfill.cs +++ b/src/Split/netcoreapp3.0/FilePolyfill.cs @@ -48,11 +48,13 @@ public static Task AppendAllTextAsync(string path, ReadOnlyMemory contents /// /// Appends the specified string to the file, creating the file if it does not already exist. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void AppendAllText(string path, ReadOnlySpan contents) => File.AppendAllText(path, contents.ToString()); /// /// Appends the specified string to the file, creating the file if it does not already exist. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void AppendAllText(string path, ReadOnlySpan contents, Encoding encoding) => File.AppendAllText(path, contents.ToString(), encoding); /// @@ -76,12 +78,14 @@ public static async Task WriteAllBytesAsync(string path, ReadOnlyMemory by /// Creates a new file, writes the specified string to the file, and then closes the file. /// If the target file already exists, it is truncated and overwritten. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void WriteAllText(string path, ReadOnlySpan contents) => File.WriteAllText(path, contents.ToString()); /// /// Creates a new file, writes the specified string to the file using the specified encoding, and then closes the file. /// If the target file already exists, it is truncated and overwritten. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void WriteAllText(string path, ReadOnlySpan contents, Encoding encoding) => File.WriteAllText(path, contents.ToString(), encoding); /// diff --git a/src/Split/netcoreapp3.0/GuidPolyfill.cs b/src/Split/netcoreapp3.0/GuidPolyfill.cs index a29acf18a..90b6c9f48 100644 --- a/src/Split/netcoreapp3.0/GuidPolyfill.cs +++ b/src/Split/netcoreapp3.0/GuidPolyfill.cs @@ -4,6 +4,7 @@ namespace Polyfills; using System.Text; using System; using System.Security.Cryptography; +using System.Runtime.CompilerServices; static partial class Polyfill { extension(Guid) @@ -11,9 +12,11 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out Guid result) => Guid.TryParse(s, out result); /// Creates a new according to RFC 9562, following the Version 7 format. + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Guid CreateVersion7() => CreateVersion7(DateTimeOffset.UtcNow); /// Creates a new according to RFC 9562, following the Version 7 format. public static Guid CreateVersion7(DateTimeOffset timestamp) @@ -40,21 +43,25 @@ public static Guid CreateVersion7(DateTimeOffset timestamp) /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out Guid result) => Guid.TryParse(s.ToString(), out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan input, out Guid result) => Guid.TryParse(input.ToString(), out result); /// /// Tries to parse a span of UTF-8 bytes into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out Guid result) => Guid.TryParse(Encoding.UTF8.GetString(utf8Text), out result); /// /// Parse a span of UTF-8 bytes into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Guid Parse(ReadOnlySpan utf8Text) => Guid.Parse(Encoding.UTF8.GetString(utf8Text)); #endif diff --git a/src/Split/netcoreapp3.0/Lock.cs b/src/Split/netcoreapp3.0/Lock.cs index 94fcf1ff9..36946028c 100644 --- a/src/Split/netcoreapp3.0/Lock.cs +++ b/src/Split/netcoreapp3.0/Lock.cs @@ -5,6 +5,7 @@ namespace System.Threading; using Diagnostics; using Diagnostics.CodeAnalysis; +using Runtime.CompilerServices; /// /// Provides a way to get mutual exclusion in regions of code between different threads. A lock may be held by one thread at /// a time. @@ -23,26 +24,31 @@ class Lock /// /// Enters the lock. Once the method returns, the calling thread would be the only thread that holds the lock. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Enter() => Monitor.Enter(this); /// /// Tries to enter the lock without waiting. If the lock is entered, the calling thread would be the only thread that /// holds the lock. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool TryEnter() => Monitor.TryEnter(this); /// /// Tries to enter the lock, waiting for roughly the specified duration. If the lock is entered, the calling thread /// would be the only thread that holds the lock. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool TryEnter(TimeSpan timeout) => Monitor.TryEnter(this, timeout); /// /// Tries to enter the lock, waiting for roughly the specified duration. If the lock is entered, the calling thread /// would be the only thread that holds the lock. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool TryEnter(int millisecondsTimeout) => TryEnter(TimeSpan.FromMilliseconds(millisecondsTimeout)); /// /// Exits the lock. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Exit() => Monitor.Exit(this); /// /// Enters the lock and returns a that may be disposed to exit the lock. Once the method returns, diff --git a/src/Split/netcoreapp3.0/Numbers/BytePolyfill.cs b/src/Split/netcoreapp3.0/Numbers/BytePolyfill.cs index b32351497..fd1d5aa6f 100644 --- a/src/Split/netcoreapp3.0/Numbers/BytePolyfill.cs +++ b/src/Split/netcoreapp3.0/Numbers/BytePolyfill.cs @@ -4,6 +4,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -12,27 +13,32 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out byte result) => byte.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out byte result) => byte.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out byte result) => byte.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out byte result) => byte.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its byte equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out byte result) => byte.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); #endif diff --git a/src/Split/netcoreapp3.0/Numbers/DoublePolyfill.cs b/src/Split/netcoreapp3.0/Numbers/DoublePolyfill.cs index ff9f8aca6..94b44e869 100644 --- a/src/Split/netcoreapp3.0/Numbers/DoublePolyfill.cs +++ b/src/Split/netcoreapp3.0/Numbers/DoublePolyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,27 +12,32 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out double result) => double.TryParse(s, NumberStyles.Float, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out double result) => double.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Float, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out double result) => double.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its double-precision floating-point number equivalent.. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out double result) => double.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Float, null, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out double result) => double.TryParse(s.ToString(), NumberStyles.Float, provider, out result); #endif diff --git a/src/Split/netcoreapp3.0/Numbers/Int16Polyfill.cs b/src/Split/netcoreapp3.0/Numbers/Int16Polyfill.cs index 7a1f0b7c0..4447a9ecf 100644 --- a/src/Split/netcoreapp3.0/Numbers/Int16Polyfill.cs +++ b/src/Split/netcoreapp3.0/Numbers/Int16Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,27 +12,32 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out short result) => short.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out short result) => short.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out short result) => short.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its short equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out short result) => short.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out short result) => short.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/netcoreapp3.0/Numbers/Int32Polyfill.cs b/src/Split/netcoreapp3.0/Numbers/Int32Polyfill.cs index 853dfb518..587b2be91 100644 --- a/src/Split/netcoreapp3.0/Numbers/Int32Polyfill.cs +++ b/src/Split/netcoreapp3.0/Numbers/Int32Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,27 +12,32 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out int result) => int.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out int result) => int.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out int result) => int.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its 32-bit signed integer equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out int result) => int.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out int result) => int.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/netcoreapp3.0/Numbers/Int64Polyfill.cs b/src/Split/netcoreapp3.0/Numbers/Int64Polyfill.cs index e97be4775..3d7b5c57f 100644 --- a/src/Split/netcoreapp3.0/Numbers/Int64Polyfill.cs +++ b/src/Split/netcoreapp3.0/Numbers/Int64Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,27 +12,32 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out long result) => long.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out long result) => long.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out long result) => long.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its 64-bit signed integer equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out long result) => long.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out long result) => long.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/netcoreapp3.0/Numbers/SBytePolyfill.cs b/src/Split/netcoreapp3.0/Numbers/SBytePolyfill.cs index 9085c3aec..8de2ac072 100644 --- a/src/Split/netcoreapp3.0/Numbers/SBytePolyfill.cs +++ b/src/Split/netcoreapp3.0/Numbers/SBytePolyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,27 +12,32 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out sbyte result) => sbyte.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out sbyte result) => sbyte.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out sbyte result) => sbyte.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its sbyte equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out sbyte result) => sbyte.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out sbyte result) => sbyte.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/netcoreapp3.0/Numbers/UInt16Polyfill.cs b/src/Split/netcoreapp3.0/Numbers/UInt16Polyfill.cs index 11d4c4ed7..b3b68b25f 100644 --- a/src/Split/netcoreapp3.0/Numbers/UInt16Polyfill.cs +++ b/src/Split/netcoreapp3.0/Numbers/UInt16Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,27 +12,32 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out ushort result) => ushort.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out ushort result) => ushort.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out ushort result) => ushort.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its ushort equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out ushort result) => ushort.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out ushort result) => ushort.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/netcoreapp3.0/Numbers/UInt32Polyfill.cs b/src/Split/netcoreapp3.0/Numbers/UInt32Polyfill.cs index abdf707dd..4ba985db3 100644 --- a/src/Split/netcoreapp3.0/Numbers/UInt32Polyfill.cs +++ b/src/Split/netcoreapp3.0/Numbers/UInt32Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,27 +12,32 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out uint result) => uint.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out uint result) => uint.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out uint result) => uint.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its uint equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out uint result) => uint.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out uint result) => uint.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/netcoreapp3.0/Numbers/UInt64Polyfill.cs b/src/Split/netcoreapp3.0/Numbers/UInt64Polyfill.cs index 1a1bc228c..08e8b0fad 100644 --- a/src/Split/netcoreapp3.0/Numbers/UInt64Polyfill.cs +++ b/src/Split/netcoreapp3.0/Numbers/UInt64Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,27 +12,32 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out ulong result) => ulong.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out ulong result) => ulong.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpanutf8Text, NumberStyles style, IFormatProvider? provider, out ulong result) => ulong.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its ulong equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out ulong result) => ulong.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out ulong result) => ulong.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/netcoreapp3.0/OperatingSystemPolyfill.cs b/src/Split/netcoreapp3.0/OperatingSystemPolyfill.cs index 5d1f8de36..68413c7d5 100644 --- a/src/Split/netcoreapp3.0/OperatingSystemPolyfill.cs +++ b/src/Split/netcoreapp3.0/OperatingSystemPolyfill.cs @@ -3,6 +3,7 @@ #if FeatureRuntimeInformation namespace Polyfills; using System; +using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; static partial class Polyfill @@ -14,114 +15,135 @@ static bool IsOsVersionAtLeast(int major, int minor = 0, int build = 0, int revi /// /// Indicates whether the current application is running as WASI. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsWasi() => RuntimeInformation.IsOSPlatform(OSPlatform.Create("WASI")); /// /// Indicates whether the current application is running on Mac Catalyst. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsMacCatalyst() => OperatingSystem.IsMacOS() || OperatingSystem.IsIOS(); /// /// Check for the Mac Catalyst version (iOS version as presented in Apple documentation) with a ≤ version comparison. Used to guard APIs that were added in the given Mac Catalyst release. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsMacCatalystVersionAtLeast(int major, int minor = 0, int build = 0) => IsMacCatalyst() && IsOsVersionAtLeast(major, minor, build); /// /// Checks if the macOS version (returned by libobjc.get_operatingSystemVersion) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified macOS version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsMacOSVersionAtLeast(int major, int minor = 0, int build = 0) => OperatingSystemCache.IsMacOSVersionAtLeast(major, minor, build); /// /// Checks if the FreeBSD version (returned by the Linux command uname) is greater than or equal to the specified version. /// This method can be used to guard APIs that were added in the specified version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsFreeBSDVersionAtLeast(int major, int minor, int build = 0, int revision = 0) => OperatingSystemCache.IsFreeBSDVersionAtLeast(major, minor, build, revision); /// /// Indicates whether the current application is running on Android. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsAndroid() => OperatingSystemCache.IsAndroid(); /// /// Checks if the Android version (returned by the Linux command uname) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsAndroidVersionAtLeast(int major, int minor = 0, int build = 0, int revision = 0) => OperatingSystemCache.IsAndroidVersionAtLeast(major, minor, build, revision); /// /// Checks if the Windows version (returned by RtlGetVersion) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified Windows version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsWindowsVersionAtLeast(int major, int minor = 0, int build = 0, int revision = 0) => OperatingSystemCache.IsWindowsVersionAtLeast(major, minor, build, revision); /// /// Indicates whether the current application is running on the specified platform. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsOSPlatform(string platform) => RuntimeInformation.IsOSPlatform(OSPlatform.Create(platform)); /// /// Checks if the operating system version is greater than or equal to the specified platform version. This method can be used to guard APIs that were added in the specified OS version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsOSPlatformVersionAtLeast(string platform, int major, int minor = 0, int build = 0, int revision = 0) => IsOSPlatform(platform) && IsOsVersionAtLeast(major, minor, build, revision); /// /// Indicates whether the current application is running on Windows. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsWindows() => RuntimeInformation.IsOSPlatform(OSPlatform.Windows); /// /// Indicates whether the current application is running on macOS. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsMacOS() => RuntimeInformation.IsOSPlatform(OSPlatform.OSX); /// /// Indicates whether the current application is running on iOS or MacCatalyst. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsIOS() => RuntimeInformation.IsOSPlatform(OSPlatform.Create("IOS")); /// /// Indicates whether the current application is running on Linux. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsLinux() => RuntimeInformation.IsOSPlatform(OSPlatform.Linux); /// /// Indicates whether the current application is running on FreeBSD. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsFreeBSD() => RuntimeInformation.OSDescription.ToLower().Contains("freebsd"); /// /// Checks if the iOS/MacCatalyst version (returned by libobjc.get_operatingSystemVersion) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified iOS version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsIOSVersionAtLeast(int major, int minor = 0, int build = 0) => IsIOS() && IsOsVersionAtLeast(major, minor, build); /// /// Checks if the tvOS version (returned by libobjc.get_operatingSystemVersion) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified tvOS version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsTvOSVersionAtLeast(int major, int minor = 0, int build = 0) => IsTvOS() && IsOsVersionAtLeast(major, minor, build); /// /// Indicates whether the current application is running on tvOS. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsTvOS() => RuntimeInformation.IsOSPlatform(OSPlatform.Create("TVOS")); /// /// Indicates whether the current application is running on watchOS. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsWatchOS() => IsIOS() || RuntimeInformation.OSDescription.ToLower().Contains("watchos"); /// /// Checks if the watchOS version (returned by libobjc.get_operatingSystemVersion) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified watchOS version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsWatchOSVersionAtLeast(int major, int minor = 0, int build = 0) => IsWatchOS() && IsOsVersionAtLeast(major, minor, build); /// /// Indicates whether the current application is running as WASM in a browser. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsBrowser() => RuntimeInformation.IsOSPlatform(OSPlatform.Create("BROWSER")); } diff --git a/src/Split/netcoreapp3.0/PathPolyfill.cs b/src/Split/netcoreapp3.0/PathPolyfill.cs index 268c89cfc..39af87506 100644 --- a/src/Split/netcoreapp3.0/PathPolyfill.cs +++ b/src/Split/netcoreapp3.0/PathPolyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.IO; +using System.Runtime.CompilerServices; static partial class Polyfill { extension(Path) @@ -11,6 +12,7 @@ static partial class Polyfill /// /// Combines a span of strings into a path. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string Combine(scoped ReadOnlySpan paths) => Path.Combine(paths.ToArray()); #endif diff --git a/src/Split/netcoreapp3.1/ConsolePolyfill.cs b/src/Split/netcoreapp3.1/ConsolePolyfill.cs index 425364db8..5ad0342de 100644 --- a/src/Split/netcoreapp3.1/ConsolePolyfill.cs +++ b/src/Split/netcoreapp3.1/ConsolePolyfill.cs @@ -4,6 +4,7 @@ namespace Polyfills; using System; using System.Runtime.InteropServices; +using System.Runtime.CompilerServices; using Microsoft.Win32.SafeHandles; static partial class Polyfill { @@ -12,16 +13,19 @@ static partial class Polyfill /// /// Gets a that wraps the operating system handle for standard input. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static SafeFileHandle OpenStandardInputHandle() => StandardHandleHelper.GetStandardHandle(StandardHandleHelper.StdInput); /// /// Gets a that wraps the operating system handle for standard output. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static SafeFileHandle OpenStandardOutputHandle() => StandardHandleHelper.GetStandardHandle(StandardHandleHelper.StdOutput); /// /// Gets a that wraps the operating system handle for standard error. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static SafeFileHandle OpenStandardErrorHandle() => StandardHandleHelper.GetStandardHandle(StandardHandleHelper.StdError); } diff --git a/src/Split/netcoreapp3.1/ConvertPolyfill.cs b/src/Split/netcoreapp3.1/ConvertPolyfill.cs index 8ca6da94f..5f80df1f7 100644 --- a/src/Split/netcoreapp3.1/ConvertPolyfill.cs +++ b/src/Split/netcoreapp3.1/ConvertPolyfill.cs @@ -2,6 +2,7 @@ #pragma warning disable namespace Polyfills; using System; +using System.Runtime.CompilerServices; static partial class Polyfill { extension(Convert) @@ -10,22 +11,26 @@ static partial class Polyfill /// Converts a subset of an array of 8-bit unsigned integers to its equivalent string representation that is encoded with uppercase hex characters. /// Parameters specify the subset as an offset in the input array and the number of elements in the array to convert. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexString(byte[] inArray, int offset, int length) => ToHexString(inArray, offset, length, "X2"); /// /// Converts a subset of an array of 8-bit unsigned integers to its equivalent string representation that is encoded with lowercase hex characters. /// Parameters specify the subset as an offset in the input array and the number of elements in the array to convert. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexStringLower(byte[] inArray, int offset, int length) => ToHexString(inArray, offset, length, "x2"); /// /// Converts an array of 8-bit unsigned integers to its equivalent string representation that is encoded with lowercase hex characters. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexStringLower(byte[] inArray) => Polyfill.ToHexStringLower(inArray, 0, inArray.Length); /// /// Converts an array of 8-bit unsigned integers to its equivalent string representation that is encoded with uppercase hex characters. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexString(byte[] inArray) => Polyfill.ToHexString(inArray, 0, inArray.Length); /// @@ -54,16 +59,19 @@ static int GetHexValue(char hex) => /// /// Converts the span, which encodes binary data as hex characters, to an equivalent 8-bit unsigned integer array. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static byte[] FromHexString(ReadOnlySpan chars) => Polyfill.FromHexString(chars.ToString()); /// /// Converts a span of 8-bit unsigned integers to its equivalent string representation that is encoded with uppercase hex characters. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexString(ReadOnlySpan bytes) => Polyfill.ToHexString(bytes.ToArray()); /// /// Converts a span of 8-bit unsigned integers to its equivalent string representation that is encoded with lowercase hex characters. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexStringLower(ReadOnlySpan bytes) => Polyfill.ToHexStringLower(bytes.ToArray()); /// diff --git a/src/Split/netcoreapp3.1/DateTimeOffsetPolyfill.cs b/src/Split/netcoreapp3.1/DateTimeOffsetPolyfill.cs index 5a5018208..11ea73e02 100644 --- a/src/Split/netcoreapp3.1/DateTimeOffsetPolyfill.cs +++ b/src/Split/netcoreapp3.1/DateTimeOffsetPolyfill.cs @@ -4,6 +4,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; static partial class Polyfill { extension(DateTimeOffset target) @@ -30,27 +31,32 @@ long TicksComponent() /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out DateTimeOffset result) => DateTimeOffset.TryParse(s, provider, DateTimeStyles.None, out result); #if FeatureMemory /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out DateTimeOffset result) => DateTimeOffset.TryParse(s.ToString(), provider, DateTimeStyles.None, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan input, out DateTimeOffset result) => DateTimeOffset.TryParse(input.ToString(), null, DateTimeStyles.None, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, DateTimeStyles styles, out DateTimeOffset result) => DateTimeOffset.TryParse(s.ToString(), provider, styles, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParseExact(ReadOnlySpan input, string format, IFormatProvider? provider, DateTimeStyles styles, out DateTimeOffset result) => DateTimeOffset.TryParseExact(input.ToString(), format, provider, styles, out result); #endif diff --git a/src/Split/netcoreapp3.1/DateTimePolyfill.cs b/src/Split/netcoreapp3.1/DateTimePolyfill.cs index 4641f3e59..4d329796a 100644 --- a/src/Split/netcoreapp3.1/DateTimePolyfill.cs +++ b/src/Split/netcoreapp3.1/DateTimePolyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; static partial class Polyfill { extension(DateTime target) @@ -29,32 +30,38 @@ long TicksComponent() /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out DateTime result) => DateTime.TryParse(s, provider, DateTimeStyles.None, out result); #if FeatureMemory /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out DateTime result) => DateTime.TryParse(s.ToString(), provider, DateTimeStyles.None, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out DateTime result) => DateTime.TryParse(s.ToString(), null, DateTimeStyles.None, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, DateTimeStyles styles, out DateTime result) => DateTime.TryParse(s.ToString(), provider, styles, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParseExact(ReadOnlySpan s, string format, IFormatProvider? provider, DateTimeStyles style, out DateTime result) => DateTime.TryParseExact(s.ToString(), format, provider, style, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParseExact(ReadOnlySpan s, ReadOnlySpan format, IFormatProvider? provider, DateTimeStyles styles, out DateTime result) => DateTime.TryParseExact(s.ToString(), format.ToString(), provider, styles, out result); #endif diff --git a/src/Split/netcoreapp3.1/DelegatePolyfill.cs b/src/Split/netcoreapp3.1/DelegatePolyfill.cs index effdb1267..59cc5e315 100644 --- a/src/Split/netcoreapp3.1/DelegatePolyfill.cs +++ b/src/Split/netcoreapp3.1/DelegatePolyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.ComponentModel; +using System.Runtime.CompilerServices; static partial class Polyfill { /// @@ -39,6 +40,7 @@ public bool MoveNext() /// /// Gets an enumerator for the invocation targets of this delegate. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static InvocationListEnumerator EnumerateInvocationList(TDelegate? target) where TDelegate : Delegate => new(target); diff --git a/src/Split/netcoreapp3.1/FilePolyfill.cs b/src/Split/netcoreapp3.1/FilePolyfill.cs index ff68c4d3c..66d68b0ad 100644 --- a/src/Split/netcoreapp3.1/FilePolyfill.cs +++ b/src/Split/netcoreapp3.1/FilePolyfill.cs @@ -48,11 +48,13 @@ public static Task AppendAllTextAsync(string path, ReadOnlyMemory contents /// /// Appends the specified string to the file, creating the file if it does not already exist. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void AppendAllText(string path, ReadOnlySpan contents) => File.AppendAllText(path, contents.ToString()); /// /// Appends the specified string to the file, creating the file if it does not already exist. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void AppendAllText(string path, ReadOnlySpan contents, Encoding encoding) => File.AppendAllText(path, contents.ToString(), encoding); /// @@ -76,12 +78,14 @@ public static async Task WriteAllBytesAsync(string path, ReadOnlyMemory by /// Creates a new file, writes the specified string to the file, and then closes the file. /// If the target file already exists, it is truncated and overwritten. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void WriteAllText(string path, ReadOnlySpan contents) => File.WriteAllText(path, contents.ToString()); /// /// Creates a new file, writes the specified string to the file using the specified encoding, and then closes the file. /// If the target file already exists, it is truncated and overwritten. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void WriteAllText(string path, ReadOnlySpan contents, Encoding encoding) => File.WriteAllText(path, contents.ToString(), encoding); /// diff --git a/src/Split/netcoreapp3.1/GuidPolyfill.cs b/src/Split/netcoreapp3.1/GuidPolyfill.cs index a29acf18a..90b6c9f48 100644 --- a/src/Split/netcoreapp3.1/GuidPolyfill.cs +++ b/src/Split/netcoreapp3.1/GuidPolyfill.cs @@ -4,6 +4,7 @@ namespace Polyfills; using System.Text; using System; using System.Security.Cryptography; +using System.Runtime.CompilerServices; static partial class Polyfill { extension(Guid) @@ -11,9 +12,11 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out Guid result) => Guid.TryParse(s, out result); /// Creates a new according to RFC 9562, following the Version 7 format. + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Guid CreateVersion7() => CreateVersion7(DateTimeOffset.UtcNow); /// Creates a new according to RFC 9562, following the Version 7 format. public static Guid CreateVersion7(DateTimeOffset timestamp) @@ -40,21 +43,25 @@ public static Guid CreateVersion7(DateTimeOffset timestamp) /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out Guid result) => Guid.TryParse(s.ToString(), out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan input, out Guid result) => Guid.TryParse(input.ToString(), out result); /// /// Tries to parse a span of UTF-8 bytes into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out Guid result) => Guid.TryParse(Encoding.UTF8.GetString(utf8Text), out result); /// /// Parse a span of UTF-8 bytes into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Guid Parse(ReadOnlySpan utf8Text) => Guid.Parse(Encoding.UTF8.GetString(utf8Text)); #endif diff --git a/src/Split/netcoreapp3.1/Lock.cs b/src/Split/netcoreapp3.1/Lock.cs index 94fcf1ff9..36946028c 100644 --- a/src/Split/netcoreapp3.1/Lock.cs +++ b/src/Split/netcoreapp3.1/Lock.cs @@ -5,6 +5,7 @@ namespace System.Threading; using Diagnostics; using Diagnostics.CodeAnalysis; +using Runtime.CompilerServices; /// /// Provides a way to get mutual exclusion in regions of code between different threads. A lock may be held by one thread at /// a time. @@ -23,26 +24,31 @@ class Lock /// /// Enters the lock. Once the method returns, the calling thread would be the only thread that holds the lock. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Enter() => Monitor.Enter(this); /// /// Tries to enter the lock without waiting. If the lock is entered, the calling thread would be the only thread that /// holds the lock. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool TryEnter() => Monitor.TryEnter(this); /// /// Tries to enter the lock, waiting for roughly the specified duration. If the lock is entered, the calling thread /// would be the only thread that holds the lock. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool TryEnter(TimeSpan timeout) => Monitor.TryEnter(this, timeout); /// /// Tries to enter the lock, waiting for roughly the specified duration. If the lock is entered, the calling thread /// would be the only thread that holds the lock. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool TryEnter(int millisecondsTimeout) => TryEnter(TimeSpan.FromMilliseconds(millisecondsTimeout)); /// /// Exits the lock. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Exit() => Monitor.Exit(this); /// /// Enters the lock and returns a that may be disposed to exit the lock. Once the method returns, diff --git a/src/Split/netcoreapp3.1/Numbers/BytePolyfill.cs b/src/Split/netcoreapp3.1/Numbers/BytePolyfill.cs index b32351497..fd1d5aa6f 100644 --- a/src/Split/netcoreapp3.1/Numbers/BytePolyfill.cs +++ b/src/Split/netcoreapp3.1/Numbers/BytePolyfill.cs @@ -4,6 +4,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -12,27 +13,32 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out byte result) => byte.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out byte result) => byte.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out byte result) => byte.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out byte result) => byte.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its byte equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out byte result) => byte.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); #endif diff --git a/src/Split/netcoreapp3.1/Numbers/DoublePolyfill.cs b/src/Split/netcoreapp3.1/Numbers/DoublePolyfill.cs index ff9f8aca6..94b44e869 100644 --- a/src/Split/netcoreapp3.1/Numbers/DoublePolyfill.cs +++ b/src/Split/netcoreapp3.1/Numbers/DoublePolyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,27 +12,32 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out double result) => double.TryParse(s, NumberStyles.Float, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out double result) => double.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Float, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out double result) => double.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its double-precision floating-point number equivalent.. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out double result) => double.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Float, null, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out double result) => double.TryParse(s.ToString(), NumberStyles.Float, provider, out result); #endif diff --git a/src/Split/netcoreapp3.1/Numbers/Int16Polyfill.cs b/src/Split/netcoreapp3.1/Numbers/Int16Polyfill.cs index 7a1f0b7c0..4447a9ecf 100644 --- a/src/Split/netcoreapp3.1/Numbers/Int16Polyfill.cs +++ b/src/Split/netcoreapp3.1/Numbers/Int16Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,27 +12,32 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out short result) => short.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out short result) => short.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out short result) => short.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its short equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out short result) => short.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out short result) => short.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/netcoreapp3.1/Numbers/Int32Polyfill.cs b/src/Split/netcoreapp3.1/Numbers/Int32Polyfill.cs index 853dfb518..587b2be91 100644 --- a/src/Split/netcoreapp3.1/Numbers/Int32Polyfill.cs +++ b/src/Split/netcoreapp3.1/Numbers/Int32Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,27 +12,32 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out int result) => int.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out int result) => int.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out int result) => int.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its 32-bit signed integer equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out int result) => int.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out int result) => int.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/netcoreapp3.1/Numbers/Int64Polyfill.cs b/src/Split/netcoreapp3.1/Numbers/Int64Polyfill.cs index e97be4775..3d7b5c57f 100644 --- a/src/Split/netcoreapp3.1/Numbers/Int64Polyfill.cs +++ b/src/Split/netcoreapp3.1/Numbers/Int64Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,27 +12,32 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out long result) => long.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out long result) => long.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out long result) => long.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its 64-bit signed integer equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out long result) => long.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out long result) => long.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/netcoreapp3.1/Numbers/SBytePolyfill.cs b/src/Split/netcoreapp3.1/Numbers/SBytePolyfill.cs index 9085c3aec..8de2ac072 100644 --- a/src/Split/netcoreapp3.1/Numbers/SBytePolyfill.cs +++ b/src/Split/netcoreapp3.1/Numbers/SBytePolyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,27 +12,32 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out sbyte result) => sbyte.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out sbyte result) => sbyte.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out sbyte result) => sbyte.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its sbyte equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out sbyte result) => sbyte.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out sbyte result) => sbyte.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/netcoreapp3.1/Numbers/UInt16Polyfill.cs b/src/Split/netcoreapp3.1/Numbers/UInt16Polyfill.cs index 11d4c4ed7..b3b68b25f 100644 --- a/src/Split/netcoreapp3.1/Numbers/UInt16Polyfill.cs +++ b/src/Split/netcoreapp3.1/Numbers/UInt16Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,27 +12,32 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out ushort result) => ushort.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out ushort result) => ushort.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out ushort result) => ushort.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its ushort equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out ushort result) => ushort.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out ushort result) => ushort.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/netcoreapp3.1/Numbers/UInt32Polyfill.cs b/src/Split/netcoreapp3.1/Numbers/UInt32Polyfill.cs index abdf707dd..4ba985db3 100644 --- a/src/Split/netcoreapp3.1/Numbers/UInt32Polyfill.cs +++ b/src/Split/netcoreapp3.1/Numbers/UInt32Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,27 +12,32 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out uint result) => uint.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out uint result) => uint.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out uint result) => uint.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its uint equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out uint result) => uint.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out uint result) => uint.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/netcoreapp3.1/Numbers/UInt64Polyfill.cs b/src/Split/netcoreapp3.1/Numbers/UInt64Polyfill.cs index 1a1bc228c..08e8b0fad 100644 --- a/src/Split/netcoreapp3.1/Numbers/UInt64Polyfill.cs +++ b/src/Split/netcoreapp3.1/Numbers/UInt64Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,27 +12,32 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out ulong result) => ulong.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out ulong result) => ulong.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpanutf8Text, NumberStyles style, IFormatProvider? provider, out ulong result) => ulong.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its ulong equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out ulong result) => ulong.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out ulong result) => ulong.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/netcoreapp3.1/OperatingSystemPolyfill.cs b/src/Split/netcoreapp3.1/OperatingSystemPolyfill.cs index 5d1f8de36..68413c7d5 100644 --- a/src/Split/netcoreapp3.1/OperatingSystemPolyfill.cs +++ b/src/Split/netcoreapp3.1/OperatingSystemPolyfill.cs @@ -3,6 +3,7 @@ #if FeatureRuntimeInformation namespace Polyfills; using System; +using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; static partial class Polyfill @@ -14,114 +15,135 @@ static bool IsOsVersionAtLeast(int major, int minor = 0, int build = 0, int revi /// /// Indicates whether the current application is running as WASI. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsWasi() => RuntimeInformation.IsOSPlatform(OSPlatform.Create("WASI")); /// /// Indicates whether the current application is running on Mac Catalyst. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsMacCatalyst() => OperatingSystem.IsMacOS() || OperatingSystem.IsIOS(); /// /// Check for the Mac Catalyst version (iOS version as presented in Apple documentation) with a ≤ version comparison. Used to guard APIs that were added in the given Mac Catalyst release. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsMacCatalystVersionAtLeast(int major, int minor = 0, int build = 0) => IsMacCatalyst() && IsOsVersionAtLeast(major, minor, build); /// /// Checks if the macOS version (returned by libobjc.get_operatingSystemVersion) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified macOS version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsMacOSVersionAtLeast(int major, int minor = 0, int build = 0) => OperatingSystemCache.IsMacOSVersionAtLeast(major, minor, build); /// /// Checks if the FreeBSD version (returned by the Linux command uname) is greater than or equal to the specified version. /// This method can be used to guard APIs that were added in the specified version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsFreeBSDVersionAtLeast(int major, int minor, int build = 0, int revision = 0) => OperatingSystemCache.IsFreeBSDVersionAtLeast(major, minor, build, revision); /// /// Indicates whether the current application is running on Android. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsAndroid() => OperatingSystemCache.IsAndroid(); /// /// Checks if the Android version (returned by the Linux command uname) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsAndroidVersionAtLeast(int major, int minor = 0, int build = 0, int revision = 0) => OperatingSystemCache.IsAndroidVersionAtLeast(major, minor, build, revision); /// /// Checks if the Windows version (returned by RtlGetVersion) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified Windows version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsWindowsVersionAtLeast(int major, int minor = 0, int build = 0, int revision = 0) => OperatingSystemCache.IsWindowsVersionAtLeast(major, minor, build, revision); /// /// Indicates whether the current application is running on the specified platform. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsOSPlatform(string platform) => RuntimeInformation.IsOSPlatform(OSPlatform.Create(platform)); /// /// Checks if the operating system version is greater than or equal to the specified platform version. This method can be used to guard APIs that were added in the specified OS version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsOSPlatformVersionAtLeast(string platform, int major, int minor = 0, int build = 0, int revision = 0) => IsOSPlatform(platform) && IsOsVersionAtLeast(major, minor, build, revision); /// /// Indicates whether the current application is running on Windows. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsWindows() => RuntimeInformation.IsOSPlatform(OSPlatform.Windows); /// /// Indicates whether the current application is running on macOS. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsMacOS() => RuntimeInformation.IsOSPlatform(OSPlatform.OSX); /// /// Indicates whether the current application is running on iOS or MacCatalyst. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsIOS() => RuntimeInformation.IsOSPlatform(OSPlatform.Create("IOS")); /// /// Indicates whether the current application is running on Linux. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsLinux() => RuntimeInformation.IsOSPlatform(OSPlatform.Linux); /// /// Indicates whether the current application is running on FreeBSD. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsFreeBSD() => RuntimeInformation.OSDescription.ToLower().Contains("freebsd"); /// /// Checks if the iOS/MacCatalyst version (returned by libobjc.get_operatingSystemVersion) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified iOS version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsIOSVersionAtLeast(int major, int minor = 0, int build = 0) => IsIOS() && IsOsVersionAtLeast(major, minor, build); /// /// Checks if the tvOS version (returned by libobjc.get_operatingSystemVersion) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified tvOS version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsTvOSVersionAtLeast(int major, int minor = 0, int build = 0) => IsTvOS() && IsOsVersionAtLeast(major, minor, build); /// /// Indicates whether the current application is running on tvOS. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsTvOS() => RuntimeInformation.IsOSPlatform(OSPlatform.Create("TVOS")); /// /// Indicates whether the current application is running on watchOS. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsWatchOS() => IsIOS() || RuntimeInformation.OSDescription.ToLower().Contains("watchos"); /// /// Checks if the watchOS version (returned by libobjc.get_operatingSystemVersion) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified watchOS version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsWatchOSVersionAtLeast(int major, int minor = 0, int build = 0) => IsWatchOS() && IsOsVersionAtLeast(major, minor, build); /// /// Indicates whether the current application is running as WASM in a browser. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsBrowser() => RuntimeInformation.IsOSPlatform(OSPlatform.Create("BROWSER")); } diff --git a/src/Split/netcoreapp3.1/PathPolyfill.cs b/src/Split/netcoreapp3.1/PathPolyfill.cs index 268c89cfc..39af87506 100644 --- a/src/Split/netcoreapp3.1/PathPolyfill.cs +++ b/src/Split/netcoreapp3.1/PathPolyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.IO; +using System.Runtime.CompilerServices; static partial class Polyfill { extension(Path) @@ -11,6 +12,7 @@ static partial class Polyfill /// /// Combines a span of strings into a path. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string Combine(scoped ReadOnlySpan paths) => Path.Combine(paths.ToArray()); #endif diff --git a/src/Split/netstandard2.0/ConsolePolyfill.cs b/src/Split/netstandard2.0/ConsolePolyfill.cs index 425364db8..5ad0342de 100644 --- a/src/Split/netstandard2.0/ConsolePolyfill.cs +++ b/src/Split/netstandard2.0/ConsolePolyfill.cs @@ -4,6 +4,7 @@ namespace Polyfills; using System; using System.Runtime.InteropServices; +using System.Runtime.CompilerServices; using Microsoft.Win32.SafeHandles; static partial class Polyfill { @@ -12,16 +13,19 @@ static partial class Polyfill /// /// Gets a that wraps the operating system handle for standard input. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static SafeFileHandle OpenStandardInputHandle() => StandardHandleHelper.GetStandardHandle(StandardHandleHelper.StdInput); /// /// Gets a that wraps the operating system handle for standard output. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static SafeFileHandle OpenStandardOutputHandle() => StandardHandleHelper.GetStandardHandle(StandardHandleHelper.StdOutput); /// /// Gets a that wraps the operating system handle for standard error. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static SafeFileHandle OpenStandardErrorHandle() => StandardHandleHelper.GetStandardHandle(StandardHandleHelper.StdError); } diff --git a/src/Split/netstandard2.0/ConvertPolyfill.cs b/src/Split/netstandard2.0/ConvertPolyfill.cs index 8ca6da94f..5f80df1f7 100644 --- a/src/Split/netstandard2.0/ConvertPolyfill.cs +++ b/src/Split/netstandard2.0/ConvertPolyfill.cs @@ -2,6 +2,7 @@ #pragma warning disable namespace Polyfills; using System; +using System.Runtime.CompilerServices; static partial class Polyfill { extension(Convert) @@ -10,22 +11,26 @@ static partial class Polyfill /// Converts a subset of an array of 8-bit unsigned integers to its equivalent string representation that is encoded with uppercase hex characters. /// Parameters specify the subset as an offset in the input array and the number of elements in the array to convert. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexString(byte[] inArray, int offset, int length) => ToHexString(inArray, offset, length, "X2"); /// /// Converts a subset of an array of 8-bit unsigned integers to its equivalent string representation that is encoded with lowercase hex characters. /// Parameters specify the subset as an offset in the input array and the number of elements in the array to convert. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexStringLower(byte[] inArray, int offset, int length) => ToHexString(inArray, offset, length, "x2"); /// /// Converts an array of 8-bit unsigned integers to its equivalent string representation that is encoded with lowercase hex characters. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexStringLower(byte[] inArray) => Polyfill.ToHexStringLower(inArray, 0, inArray.Length); /// /// Converts an array of 8-bit unsigned integers to its equivalent string representation that is encoded with uppercase hex characters. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexString(byte[] inArray) => Polyfill.ToHexString(inArray, 0, inArray.Length); /// @@ -54,16 +59,19 @@ static int GetHexValue(char hex) => /// /// Converts the span, which encodes binary data as hex characters, to an equivalent 8-bit unsigned integer array. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static byte[] FromHexString(ReadOnlySpan chars) => Polyfill.FromHexString(chars.ToString()); /// /// Converts a span of 8-bit unsigned integers to its equivalent string representation that is encoded with uppercase hex characters. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexString(ReadOnlySpan bytes) => Polyfill.ToHexString(bytes.ToArray()); /// /// Converts a span of 8-bit unsigned integers to its equivalent string representation that is encoded with lowercase hex characters. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexStringLower(ReadOnlySpan bytes) => Polyfill.ToHexStringLower(bytes.ToArray()); /// diff --git a/src/Split/netstandard2.0/DateTimeOffsetPolyfill.cs b/src/Split/netstandard2.0/DateTimeOffsetPolyfill.cs index 6837790e5..7bb9a5ad7 100644 --- a/src/Split/netstandard2.0/DateTimeOffsetPolyfill.cs +++ b/src/Split/netstandard2.0/DateTimeOffsetPolyfill.cs @@ -4,6 +4,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; static partial class Polyfill { extension(DateTimeOffset target) @@ -30,32 +31,38 @@ long TicksComponent() /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out DateTimeOffset result) => DateTimeOffset.TryParse(s, provider, DateTimeStyles.None, out result); #if FeatureMemory /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out DateTimeOffset result) => DateTimeOffset.TryParse(s.ToString(), provider, DateTimeStyles.None, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan input, out DateTimeOffset result) => DateTimeOffset.TryParse(input.ToString(), null, DateTimeStyles.None, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, DateTimeStyles styles, out DateTimeOffset result) => DateTimeOffset.TryParse(s.ToString(), provider, styles, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParseExact(ReadOnlySpan input, string format, IFormatProvider? provider, DateTimeStyles styles, out DateTimeOffset result) => DateTimeOffset.TryParseExact(input.ToString(), format, provider, styles, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParseExact(ReadOnlySpan input, ReadOnlySpan format, IFormatProvider? provider, DateTimeStyles styles, out DateTimeOffset result) => DateTimeOffset.TryParseExact(input.ToString(), format.ToString(), provider, styles, out result); #endif diff --git a/src/Split/netstandard2.0/DateTimePolyfill.cs b/src/Split/netstandard2.0/DateTimePolyfill.cs index 4641f3e59..4d329796a 100644 --- a/src/Split/netstandard2.0/DateTimePolyfill.cs +++ b/src/Split/netstandard2.0/DateTimePolyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; static partial class Polyfill { extension(DateTime target) @@ -29,32 +30,38 @@ long TicksComponent() /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out DateTime result) => DateTime.TryParse(s, provider, DateTimeStyles.None, out result); #if FeatureMemory /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out DateTime result) => DateTime.TryParse(s.ToString(), provider, DateTimeStyles.None, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out DateTime result) => DateTime.TryParse(s.ToString(), null, DateTimeStyles.None, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, DateTimeStyles styles, out DateTime result) => DateTime.TryParse(s.ToString(), provider, styles, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParseExact(ReadOnlySpan s, string format, IFormatProvider? provider, DateTimeStyles style, out DateTime result) => DateTime.TryParseExact(s.ToString(), format, provider, style, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParseExact(ReadOnlySpan s, ReadOnlySpan format, IFormatProvider? provider, DateTimeStyles styles, out DateTime result) => DateTime.TryParseExact(s.ToString(), format.ToString(), provider, styles, out result); #endif diff --git a/src/Split/netstandard2.0/DelegatePolyfill.cs b/src/Split/netstandard2.0/DelegatePolyfill.cs index effdb1267..59cc5e315 100644 --- a/src/Split/netstandard2.0/DelegatePolyfill.cs +++ b/src/Split/netstandard2.0/DelegatePolyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.ComponentModel; +using System.Runtime.CompilerServices; static partial class Polyfill { /// @@ -39,6 +40,7 @@ public bool MoveNext() /// /// Gets an enumerator for the invocation targets of this delegate. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static InvocationListEnumerator EnumerateInvocationList(TDelegate? target) where TDelegate : Delegate => new(target); diff --git a/src/Split/netstandard2.0/FilePolyfill.cs b/src/Split/netstandard2.0/FilePolyfill.cs index 6dda0398b..42fd2619b 100644 --- a/src/Split/netstandard2.0/FilePolyfill.cs +++ b/src/Split/netstandard2.0/FilePolyfill.cs @@ -48,11 +48,13 @@ public static Task AppendAllTextAsync(string path, ReadOnlyMemory contents /// /// Appends the specified string to the file, creating the file if it does not already exist. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void AppendAllText(string path, ReadOnlySpan contents) => File.AppendAllText(path, contents.ToString()); /// /// Appends the specified string to the file, creating the file if it does not already exist. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void AppendAllText(string path, ReadOnlySpan contents, Encoding encoding) => File.AppendAllText(path, contents.ToString(), encoding); /// @@ -76,12 +78,14 @@ public static async Task WriteAllBytesAsync(string path, ReadOnlyMemory by /// Creates a new file, writes the specified string to the file, and then closes the file. /// If the target file already exists, it is truncated and overwritten. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void WriteAllText(string path, ReadOnlySpan contents) => File.WriteAllText(path, contents.ToString()); /// /// Creates a new file, writes the specified string to the file using the specified encoding, and then closes the file. /// If the target file already exists, it is truncated and overwritten. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void WriteAllText(string path, ReadOnlySpan contents, Encoding encoding) => File.WriteAllText(path, contents.ToString(), encoding); /// diff --git a/src/Split/netstandard2.0/GuidPolyfill.cs b/src/Split/netstandard2.0/GuidPolyfill.cs index 2bd536736..bc6b9129b 100644 --- a/src/Split/netstandard2.0/GuidPolyfill.cs +++ b/src/Split/netstandard2.0/GuidPolyfill.cs @@ -4,6 +4,7 @@ namespace Polyfills; using System.Text; using System; using System.Security.Cryptography; +using System.Runtime.CompilerServices; static partial class Polyfill { extension(Guid) @@ -11,9 +12,11 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out Guid result) => Guid.TryParse(s, out result); /// Creates a new according to RFC 9562, following the Version 7 format. + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Guid CreateVersion7() => CreateVersion7(DateTimeOffset.UtcNow); /// Creates a new according to RFC 9562, following the Version 7 format. public static Guid CreateVersion7(DateTimeOffset timestamp) @@ -40,26 +43,31 @@ public static Guid CreateVersion7(DateTimeOffset timestamp) /// /// Converts span of characters representing the GUID to the equivalent Guid structure, provided that the string is in the specified format. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParseExact(ReadOnlySpan input, ReadOnlySpan format, out Guid result) => Guid.TryParseExact(input.ToString(), format.ToString(), out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out Guid result) => Guid.TryParse(s.ToString(), out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan input, out Guid result) => Guid.TryParse(input.ToString(), out result); /// /// Tries to parse a span of UTF-8 bytes into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out Guid result) => Guid.TryParse(Encoding.UTF8.GetString(utf8Text), out result); /// /// Parse a span of UTF-8 bytes into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Guid Parse(ReadOnlySpan utf8Text) => Guid.Parse(Encoding.UTF8.GetString(utf8Text)); #endif diff --git a/src/Split/netstandard2.0/KeyValuePair.cs b/src/Split/netstandard2.0/KeyValuePair.cs index 7e5d58959..e94cbbf2f 100644 --- a/src/Split/netstandard2.0/KeyValuePair.cs +++ b/src/Split/netstandard2.0/KeyValuePair.cs @@ -4,6 +4,7 @@ namespace System.Collections.Generic; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; +using System.Runtime.CompilerServices; [ExcludeFromCodeCoverage] [DebuggerNonUserCode] #if PolyUseEmbeddedAttribute @@ -17,6 +18,7 @@ static class KeyValuePair /// /// Creates a new key/value pair instance using provided values. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static KeyValuePair Create(TKey key, TValue value) => new(key, value); } diff --git a/src/Split/netstandard2.0/Lock.cs b/src/Split/netstandard2.0/Lock.cs index 94fcf1ff9..36946028c 100644 --- a/src/Split/netstandard2.0/Lock.cs +++ b/src/Split/netstandard2.0/Lock.cs @@ -5,6 +5,7 @@ namespace System.Threading; using Diagnostics; using Diagnostics.CodeAnalysis; +using Runtime.CompilerServices; /// /// Provides a way to get mutual exclusion in regions of code between different threads. A lock may be held by one thread at /// a time. @@ -23,26 +24,31 @@ class Lock /// /// Enters the lock. Once the method returns, the calling thread would be the only thread that holds the lock. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Enter() => Monitor.Enter(this); /// /// Tries to enter the lock without waiting. If the lock is entered, the calling thread would be the only thread that /// holds the lock. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool TryEnter() => Monitor.TryEnter(this); /// /// Tries to enter the lock, waiting for roughly the specified duration. If the lock is entered, the calling thread /// would be the only thread that holds the lock. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool TryEnter(TimeSpan timeout) => Monitor.TryEnter(this, timeout); /// /// Tries to enter the lock, waiting for roughly the specified duration. If the lock is entered, the calling thread /// would be the only thread that holds the lock. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool TryEnter(int millisecondsTimeout) => TryEnter(TimeSpan.FromMilliseconds(millisecondsTimeout)); /// /// Exits the lock. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Exit() => Monitor.Exit(this); /// /// Enters the lock and returns a that may be disposed to exit the lock. Once the method returns, diff --git a/src/Split/netstandard2.0/Numbers/BytePolyfill.cs b/src/Split/netstandard2.0/Numbers/BytePolyfill.cs index ef3f744ed..0ea017afd 100644 --- a/src/Split/netstandard2.0/Numbers/BytePolyfill.cs +++ b/src/Split/netstandard2.0/Numbers/BytePolyfill.cs @@ -4,6 +4,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -12,37 +13,44 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out byte result) => byte.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out byte result) => byte.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out byte result) => byte.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out byte result) => byte.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its byte equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out byte result) => byte.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its byte equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out byte result) => byte.TryParse(s.ToString(), out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its byte equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out byte result) => byte.TryParse(s.ToString(), style, provider, out result); #endif diff --git a/src/Split/netstandard2.0/Numbers/DoublePolyfill.cs b/src/Split/netstandard2.0/Numbers/DoublePolyfill.cs index ba5333f69..d903ddfe1 100644 --- a/src/Split/netstandard2.0/Numbers/DoublePolyfill.cs +++ b/src/Split/netstandard2.0/Numbers/DoublePolyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,37 +12,44 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out double result) => double.TryParse(s, NumberStyles.Float, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out double result) => double.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Float, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out double result) => double.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its double-precision floating-point number equivalent.. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out double result) => double.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Float, null, out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its double-precision floating-point number equivalent. A return value indicates whether the conversion succeeded or failed. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out double result) => double.TryParse(s.ToString(), out result); /// /// Converts the string representation of a number in a specified style and culture-specific format to its double-precision floating-point number equivalent. A return value indicates whether the conversion succeeded or failed. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out double result) => double.TryParse(s.ToString(), style, provider, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out double result) => double.TryParse(s.ToString(), NumberStyles.Float, provider, out result); #endif diff --git a/src/Split/netstandard2.0/Numbers/Int16Polyfill.cs b/src/Split/netstandard2.0/Numbers/Int16Polyfill.cs index 5eb1b384e..960cf68ce 100644 --- a/src/Split/netstandard2.0/Numbers/Int16Polyfill.cs +++ b/src/Split/netstandard2.0/Numbers/Int16Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,37 +12,44 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out short result) => short.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out short result) => short.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out short result) => short.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its short equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out short result) => short.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its short equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out short result) => short.TryParse(s.ToString(), out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its short equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out short result) => short.TryParse(s.ToString(), style, provider, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out short result) => short.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/netstandard2.0/Numbers/Int32Polyfill.cs b/src/Split/netstandard2.0/Numbers/Int32Polyfill.cs index 549ff1896..2920eae4a 100644 --- a/src/Split/netstandard2.0/Numbers/Int32Polyfill.cs +++ b/src/Split/netstandard2.0/Numbers/Int32Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,37 +12,44 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out int result) => int.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out int result) => int.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out int result) => int.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its 32-bit signed integer equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out int result) => int.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its 32-bit signed integer equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out int result) => int.TryParse(s.ToString(), out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its 32-bit signed integer equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out int result) => int.TryParse(s.ToString(), style, provider, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out int result) => int.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/netstandard2.0/Numbers/Int64Polyfill.cs b/src/Split/netstandard2.0/Numbers/Int64Polyfill.cs index bd33ce0e6..0b7b1b100 100644 --- a/src/Split/netstandard2.0/Numbers/Int64Polyfill.cs +++ b/src/Split/netstandard2.0/Numbers/Int64Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,37 +12,44 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out long result) => long.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out long result) => long.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out long result) => long.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its 64-bit signed integer equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out long result) => long.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its 32-bit signed integer equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out long result) => long.TryParse(s.ToString(), out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its 64-bit signed integer equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out long result) => long.TryParse(s.ToString(), style, provider, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out long result) => long.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/netstandard2.0/Numbers/SBytePolyfill.cs b/src/Split/netstandard2.0/Numbers/SBytePolyfill.cs index 974115654..890452b1c 100644 --- a/src/Split/netstandard2.0/Numbers/SBytePolyfill.cs +++ b/src/Split/netstandard2.0/Numbers/SBytePolyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,37 +12,44 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out sbyte result) => sbyte.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out sbyte result) => sbyte.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out sbyte result) => sbyte.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its sbyte equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out sbyte result) => sbyte.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its sbyte equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out sbyte result) => sbyte.TryParse(s.ToString(), out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its sbyte equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out sbyte result) => sbyte.TryParse(s.ToString(), style, provider, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out sbyte result) => sbyte.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/netstandard2.0/Numbers/UInt16Polyfill.cs b/src/Split/netstandard2.0/Numbers/UInt16Polyfill.cs index 34f39f97c..ed0958805 100644 --- a/src/Split/netstandard2.0/Numbers/UInt16Polyfill.cs +++ b/src/Split/netstandard2.0/Numbers/UInt16Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,37 +12,44 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out ushort result) => ushort.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out ushort result) => ushort.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out ushort result) => ushort.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its ushort equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out ushort result) => ushort.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its ushort equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out ushort result) => ushort.TryParse(s.ToString(), out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its ushort equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out ushort result) => ushort.TryParse(s.ToString(), style, provider, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out ushort result) => ushort.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/netstandard2.0/Numbers/UInt32Polyfill.cs b/src/Split/netstandard2.0/Numbers/UInt32Polyfill.cs index 859149bed..e11b65c90 100644 --- a/src/Split/netstandard2.0/Numbers/UInt32Polyfill.cs +++ b/src/Split/netstandard2.0/Numbers/UInt32Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,37 +12,44 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out uint result) => uint.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out uint result) => uint.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out uint result) => uint.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its uint equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out uint result) => uint.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its uint equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out uint result) => uint.TryParse(s.ToString(), out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its uint equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out uint result) => uint.TryParse(s.ToString(), style, provider, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out uint result) => uint.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/netstandard2.0/Numbers/UInt64Polyfill.cs b/src/Split/netstandard2.0/Numbers/UInt64Polyfill.cs index c14bb347c..10122d2b4 100644 --- a/src/Split/netstandard2.0/Numbers/UInt64Polyfill.cs +++ b/src/Split/netstandard2.0/Numbers/UInt64Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,37 +12,44 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out ulong result) => ulong.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out ulong result) => ulong.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpanutf8Text, NumberStyles style, IFormatProvider? provider, out ulong result) => ulong.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its ulong equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out ulong result) => ulong.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its ulong equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out ulong result) => ulong.TryParse(s.ToString(), out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its ulong equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out ulong result) => ulong.TryParse(s.ToString(), style, provider, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out ulong result) => ulong.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/netstandard2.0/OperatingSystemPolyfill.cs b/src/Split/netstandard2.0/OperatingSystemPolyfill.cs index 5d1f8de36..68413c7d5 100644 --- a/src/Split/netstandard2.0/OperatingSystemPolyfill.cs +++ b/src/Split/netstandard2.0/OperatingSystemPolyfill.cs @@ -3,6 +3,7 @@ #if FeatureRuntimeInformation namespace Polyfills; using System; +using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; static partial class Polyfill @@ -14,114 +15,135 @@ static bool IsOsVersionAtLeast(int major, int minor = 0, int build = 0, int revi /// /// Indicates whether the current application is running as WASI. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsWasi() => RuntimeInformation.IsOSPlatform(OSPlatform.Create("WASI")); /// /// Indicates whether the current application is running on Mac Catalyst. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsMacCatalyst() => OperatingSystem.IsMacOS() || OperatingSystem.IsIOS(); /// /// Check for the Mac Catalyst version (iOS version as presented in Apple documentation) with a ≤ version comparison. Used to guard APIs that were added in the given Mac Catalyst release. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsMacCatalystVersionAtLeast(int major, int minor = 0, int build = 0) => IsMacCatalyst() && IsOsVersionAtLeast(major, minor, build); /// /// Checks if the macOS version (returned by libobjc.get_operatingSystemVersion) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified macOS version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsMacOSVersionAtLeast(int major, int minor = 0, int build = 0) => OperatingSystemCache.IsMacOSVersionAtLeast(major, minor, build); /// /// Checks if the FreeBSD version (returned by the Linux command uname) is greater than or equal to the specified version. /// This method can be used to guard APIs that were added in the specified version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsFreeBSDVersionAtLeast(int major, int minor, int build = 0, int revision = 0) => OperatingSystemCache.IsFreeBSDVersionAtLeast(major, minor, build, revision); /// /// Indicates whether the current application is running on Android. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsAndroid() => OperatingSystemCache.IsAndroid(); /// /// Checks if the Android version (returned by the Linux command uname) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsAndroidVersionAtLeast(int major, int minor = 0, int build = 0, int revision = 0) => OperatingSystemCache.IsAndroidVersionAtLeast(major, minor, build, revision); /// /// Checks if the Windows version (returned by RtlGetVersion) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified Windows version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsWindowsVersionAtLeast(int major, int minor = 0, int build = 0, int revision = 0) => OperatingSystemCache.IsWindowsVersionAtLeast(major, minor, build, revision); /// /// Indicates whether the current application is running on the specified platform. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsOSPlatform(string platform) => RuntimeInformation.IsOSPlatform(OSPlatform.Create(platform)); /// /// Checks if the operating system version is greater than or equal to the specified platform version. This method can be used to guard APIs that were added in the specified OS version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsOSPlatformVersionAtLeast(string platform, int major, int minor = 0, int build = 0, int revision = 0) => IsOSPlatform(platform) && IsOsVersionAtLeast(major, minor, build, revision); /// /// Indicates whether the current application is running on Windows. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsWindows() => RuntimeInformation.IsOSPlatform(OSPlatform.Windows); /// /// Indicates whether the current application is running on macOS. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsMacOS() => RuntimeInformation.IsOSPlatform(OSPlatform.OSX); /// /// Indicates whether the current application is running on iOS or MacCatalyst. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsIOS() => RuntimeInformation.IsOSPlatform(OSPlatform.Create("IOS")); /// /// Indicates whether the current application is running on Linux. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsLinux() => RuntimeInformation.IsOSPlatform(OSPlatform.Linux); /// /// Indicates whether the current application is running on FreeBSD. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsFreeBSD() => RuntimeInformation.OSDescription.ToLower().Contains("freebsd"); /// /// Checks if the iOS/MacCatalyst version (returned by libobjc.get_operatingSystemVersion) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified iOS version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsIOSVersionAtLeast(int major, int minor = 0, int build = 0) => IsIOS() && IsOsVersionAtLeast(major, minor, build); /// /// Checks if the tvOS version (returned by libobjc.get_operatingSystemVersion) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified tvOS version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsTvOSVersionAtLeast(int major, int minor = 0, int build = 0) => IsTvOS() && IsOsVersionAtLeast(major, minor, build); /// /// Indicates whether the current application is running on tvOS. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsTvOS() => RuntimeInformation.IsOSPlatform(OSPlatform.Create("TVOS")); /// /// Indicates whether the current application is running on watchOS. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsWatchOS() => IsIOS() || RuntimeInformation.OSDescription.ToLower().Contains("watchos"); /// /// Checks if the watchOS version (returned by libobjc.get_operatingSystemVersion) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified watchOS version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsWatchOSVersionAtLeast(int major, int minor = 0, int build = 0) => IsWatchOS() && IsOsVersionAtLeast(major, minor, build); /// /// Indicates whether the current application is running as WASM in a browser. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsBrowser() => RuntimeInformation.IsOSPlatform(OSPlatform.Create("BROWSER")); } diff --git a/src/Split/netstandard2.0/PathPolyfill.cs b/src/Split/netstandard2.0/PathPolyfill.cs index fb4329ac6..fc8009da8 100644 --- a/src/Split/netstandard2.0/PathPolyfill.cs +++ b/src/Split/netstandard2.0/PathPolyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.IO; +using System.Runtime.CompilerServices; static partial class Polyfill { extension(Path) @@ -11,41 +12,49 @@ static partial class Polyfill /// /// Returns the directory information for the specified path represented by a character span. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ReadOnlySpan GetDirectoryName(ReadOnlySpan path) => Path.GetDirectoryName(path.ToString()).AsSpan(); /// /// Returns the file name and extension of a file path that is represented by a read-only character span. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ReadOnlySpan GetFileName(ReadOnlySpan path) => Path.GetFileName(path.ToString()).AsSpan(); /// /// Returns the file name without the extension of a file path that is represented by a read-only character span. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ReadOnlySpan GetFileNameWithoutExtension(ReadOnlySpan path) => Path.GetFileNameWithoutExtension(path.ToString()).AsSpan(); /// /// Determines whether the path represented by the specified character span includes a file name extension. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool HasExtension(ReadOnlySpan path) => Path.HasExtension(path.ToString()); /// /// Returns the extension of the given path. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ReadOnlySpan GetExtension(ReadOnlySpan path) => Path.GetExtension(path.ToString()).AsSpan(); /// /// Combines a span of strings into a path. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string Combine(scoped ReadOnlySpan paths) => Path.Combine(paths.ToArray()); /// /// Returns a value that indicates whether the path, specified as a read-only span, ends in a directory separator. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool EndsInDirectorySeparator (ReadOnlySpan path) => EndsInDirectorySeparator(path.ToString()); /// /// Trims one trailing directory separator beyond the root of the specified path. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ReadOnlySpan TrimEndingDirectorySeparator(ReadOnlySpan path) => TrimEndingDirectorySeparator(path.ToString()).AsSpan(); #endif diff --git a/src/Split/netstandard2.1/ConsolePolyfill.cs b/src/Split/netstandard2.1/ConsolePolyfill.cs index 425364db8..5ad0342de 100644 --- a/src/Split/netstandard2.1/ConsolePolyfill.cs +++ b/src/Split/netstandard2.1/ConsolePolyfill.cs @@ -4,6 +4,7 @@ namespace Polyfills; using System; using System.Runtime.InteropServices; +using System.Runtime.CompilerServices; using Microsoft.Win32.SafeHandles; static partial class Polyfill { @@ -12,16 +13,19 @@ static partial class Polyfill /// /// Gets a that wraps the operating system handle for standard input. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static SafeFileHandle OpenStandardInputHandle() => StandardHandleHelper.GetStandardHandle(StandardHandleHelper.StdInput); /// /// Gets a that wraps the operating system handle for standard output. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static SafeFileHandle OpenStandardOutputHandle() => StandardHandleHelper.GetStandardHandle(StandardHandleHelper.StdOutput); /// /// Gets a that wraps the operating system handle for standard error. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static SafeFileHandle OpenStandardErrorHandle() => StandardHandleHelper.GetStandardHandle(StandardHandleHelper.StdError); } diff --git a/src/Split/netstandard2.1/ConvertPolyfill.cs b/src/Split/netstandard2.1/ConvertPolyfill.cs index 8ca6da94f..5f80df1f7 100644 --- a/src/Split/netstandard2.1/ConvertPolyfill.cs +++ b/src/Split/netstandard2.1/ConvertPolyfill.cs @@ -2,6 +2,7 @@ #pragma warning disable namespace Polyfills; using System; +using System.Runtime.CompilerServices; static partial class Polyfill { extension(Convert) @@ -10,22 +11,26 @@ static partial class Polyfill /// Converts a subset of an array of 8-bit unsigned integers to its equivalent string representation that is encoded with uppercase hex characters. /// Parameters specify the subset as an offset in the input array and the number of elements in the array to convert. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexString(byte[] inArray, int offset, int length) => ToHexString(inArray, offset, length, "X2"); /// /// Converts a subset of an array of 8-bit unsigned integers to its equivalent string representation that is encoded with lowercase hex characters. /// Parameters specify the subset as an offset in the input array and the number of elements in the array to convert. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexStringLower(byte[] inArray, int offset, int length) => ToHexString(inArray, offset, length, "x2"); /// /// Converts an array of 8-bit unsigned integers to its equivalent string representation that is encoded with lowercase hex characters. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexStringLower(byte[] inArray) => Polyfill.ToHexStringLower(inArray, 0, inArray.Length); /// /// Converts an array of 8-bit unsigned integers to its equivalent string representation that is encoded with uppercase hex characters. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexString(byte[] inArray) => Polyfill.ToHexString(inArray, 0, inArray.Length); /// @@ -54,16 +59,19 @@ static int GetHexValue(char hex) => /// /// Converts the span, which encodes binary data as hex characters, to an equivalent 8-bit unsigned integer array. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static byte[] FromHexString(ReadOnlySpan chars) => Polyfill.FromHexString(chars.ToString()); /// /// Converts a span of 8-bit unsigned integers to its equivalent string representation that is encoded with uppercase hex characters. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexString(ReadOnlySpan bytes) => Polyfill.ToHexString(bytes.ToArray()); /// /// Converts a span of 8-bit unsigned integers to its equivalent string representation that is encoded with lowercase hex characters. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexStringLower(ReadOnlySpan bytes) => Polyfill.ToHexStringLower(bytes.ToArray()); /// diff --git a/src/Split/netstandard2.1/DateTimeOffsetPolyfill.cs b/src/Split/netstandard2.1/DateTimeOffsetPolyfill.cs index 15ba54f72..add60f3ab 100644 --- a/src/Split/netstandard2.1/DateTimeOffsetPolyfill.cs +++ b/src/Split/netstandard2.1/DateTimeOffsetPolyfill.cs @@ -4,6 +4,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; static partial class Polyfill { extension(DateTimeOffset target) @@ -30,12 +31,14 @@ long TicksComponent() /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out DateTimeOffset result) => DateTimeOffset.TryParse(s, provider, DateTimeStyles.None, out result); #if FeatureMemory /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out DateTimeOffset result) => DateTimeOffset.TryParse(s.ToString(), provider, DateTimeStyles.None, out result); #endif diff --git a/src/Split/netstandard2.1/DateTimePolyfill.cs b/src/Split/netstandard2.1/DateTimePolyfill.cs index 8eb8c705b..29ae6c626 100644 --- a/src/Split/netstandard2.1/DateTimePolyfill.cs +++ b/src/Split/netstandard2.1/DateTimePolyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; static partial class Polyfill { extension(DateTime target) @@ -29,17 +30,20 @@ long TicksComponent() /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out DateTime result) => DateTime.TryParse(s, provider, DateTimeStyles.None, out result); #if FeatureMemory /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out DateTime result) => DateTime.TryParse(s.ToString(), provider, DateTimeStyles.None, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParseExact(ReadOnlySpan s, ReadOnlySpan format, IFormatProvider? provider, DateTimeStyles styles, out DateTime result) => DateTime.TryParseExact(s.ToString(), format.ToString(), provider, styles, out result); #endif diff --git a/src/Split/netstandard2.1/DelegatePolyfill.cs b/src/Split/netstandard2.1/DelegatePolyfill.cs index effdb1267..59cc5e315 100644 --- a/src/Split/netstandard2.1/DelegatePolyfill.cs +++ b/src/Split/netstandard2.1/DelegatePolyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.ComponentModel; +using System.Runtime.CompilerServices; static partial class Polyfill { /// @@ -39,6 +40,7 @@ public bool MoveNext() /// /// Gets an enumerator for the invocation targets of this delegate. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static InvocationListEnumerator EnumerateInvocationList(TDelegate? target) where TDelegate : Delegate => new(target); diff --git a/src/Split/netstandard2.1/FilePolyfill.cs b/src/Split/netstandard2.1/FilePolyfill.cs index 3e55baa26..fa568149e 100644 --- a/src/Split/netstandard2.1/FilePolyfill.cs +++ b/src/Split/netstandard2.1/FilePolyfill.cs @@ -48,11 +48,13 @@ public static Task AppendAllTextAsync(string path, ReadOnlyMemory contents /// /// Appends the specified string to the file, creating the file if it does not already exist. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void AppendAllText(string path, ReadOnlySpan contents) => File.AppendAllText(path, contents.ToString()); /// /// Appends the specified string to the file, creating the file if it does not already exist. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void AppendAllText(string path, ReadOnlySpan contents, Encoding encoding) => File.AppendAllText(path, contents.ToString(), encoding); /// @@ -76,12 +78,14 @@ public static async Task WriteAllBytesAsync(string path, ReadOnlyMemory by /// Creates a new file, writes the specified string to the file, and then closes the file. /// If the target file already exists, it is truncated and overwritten. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void WriteAllText(string path, ReadOnlySpan contents) => File.WriteAllText(path, contents.ToString()); /// /// Creates a new file, writes the specified string to the file using the specified encoding, and then closes the file. /// If the target file already exists, it is truncated and overwritten. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void WriteAllText(string path, ReadOnlySpan contents, Encoding encoding) => File.WriteAllText(path, contents.ToString(), encoding); /// diff --git a/src/Split/netstandard2.1/GuidPolyfill.cs b/src/Split/netstandard2.1/GuidPolyfill.cs index c61f69729..44d9c654c 100644 --- a/src/Split/netstandard2.1/GuidPolyfill.cs +++ b/src/Split/netstandard2.1/GuidPolyfill.cs @@ -4,6 +4,7 @@ namespace Polyfills; using System.Text; using System; using System.Security.Cryptography; +using System.Runtime.CompilerServices; static partial class Polyfill { extension(Guid) @@ -11,9 +12,11 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out Guid result) => Guid.TryParse(s, out result); /// Creates a new according to RFC 9562, following the Version 7 format. + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Guid CreateVersion7() => CreateVersion7(DateTimeOffset.UtcNow); /// Creates a new according to RFC 9562, following the Version 7 format. public static Guid CreateVersion7(DateTimeOffset timestamp) @@ -40,16 +43,19 @@ public static Guid CreateVersion7(DateTimeOffset timestamp) /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out Guid result) => Guid.TryParse(s.ToString(), out result); /// /// Tries to parse a span of UTF-8 bytes into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out Guid result) => Guid.TryParse(Encoding.UTF8.GetString(utf8Text), out result); /// /// Parse a span of UTF-8 bytes into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Guid Parse(ReadOnlySpan utf8Text) => Guid.Parse(Encoding.UTF8.GetString(utf8Text)); #endif diff --git a/src/Split/netstandard2.1/Lock.cs b/src/Split/netstandard2.1/Lock.cs index 94fcf1ff9..36946028c 100644 --- a/src/Split/netstandard2.1/Lock.cs +++ b/src/Split/netstandard2.1/Lock.cs @@ -5,6 +5,7 @@ namespace System.Threading; using Diagnostics; using Diagnostics.CodeAnalysis; +using Runtime.CompilerServices; /// /// Provides a way to get mutual exclusion in regions of code between different threads. A lock may be held by one thread at /// a time. @@ -23,26 +24,31 @@ class Lock /// /// Enters the lock. Once the method returns, the calling thread would be the only thread that holds the lock. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Enter() => Monitor.Enter(this); /// /// Tries to enter the lock without waiting. If the lock is entered, the calling thread would be the only thread that /// holds the lock. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool TryEnter() => Monitor.TryEnter(this); /// /// Tries to enter the lock, waiting for roughly the specified duration. If the lock is entered, the calling thread /// would be the only thread that holds the lock. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool TryEnter(TimeSpan timeout) => Monitor.TryEnter(this, timeout); /// /// Tries to enter the lock, waiting for roughly the specified duration. If the lock is entered, the calling thread /// would be the only thread that holds the lock. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool TryEnter(int millisecondsTimeout) => TryEnter(TimeSpan.FromMilliseconds(millisecondsTimeout)); /// /// Exits the lock. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Exit() => Monitor.Exit(this); /// /// Enters the lock and returns a that may be disposed to exit the lock. Once the method returns, diff --git a/src/Split/netstandard2.1/Numbers/BytePolyfill.cs b/src/Split/netstandard2.1/Numbers/BytePolyfill.cs index b32351497..fd1d5aa6f 100644 --- a/src/Split/netstandard2.1/Numbers/BytePolyfill.cs +++ b/src/Split/netstandard2.1/Numbers/BytePolyfill.cs @@ -4,6 +4,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -12,27 +13,32 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out byte result) => byte.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out byte result) => byte.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out byte result) => byte.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out byte result) => byte.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its byte equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out byte result) => byte.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); #endif diff --git a/src/Split/netstandard2.1/Numbers/DoublePolyfill.cs b/src/Split/netstandard2.1/Numbers/DoublePolyfill.cs index ff9f8aca6..94b44e869 100644 --- a/src/Split/netstandard2.1/Numbers/DoublePolyfill.cs +++ b/src/Split/netstandard2.1/Numbers/DoublePolyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,27 +12,32 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out double result) => double.TryParse(s, NumberStyles.Float, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out double result) => double.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Float, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out double result) => double.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its double-precision floating-point number equivalent.. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out double result) => double.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Float, null, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out double result) => double.TryParse(s.ToString(), NumberStyles.Float, provider, out result); #endif diff --git a/src/Split/netstandard2.1/Numbers/Int16Polyfill.cs b/src/Split/netstandard2.1/Numbers/Int16Polyfill.cs index 7a1f0b7c0..4447a9ecf 100644 --- a/src/Split/netstandard2.1/Numbers/Int16Polyfill.cs +++ b/src/Split/netstandard2.1/Numbers/Int16Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,27 +12,32 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out short result) => short.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out short result) => short.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out short result) => short.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its short equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out short result) => short.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out short result) => short.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/netstandard2.1/Numbers/Int32Polyfill.cs b/src/Split/netstandard2.1/Numbers/Int32Polyfill.cs index 853dfb518..587b2be91 100644 --- a/src/Split/netstandard2.1/Numbers/Int32Polyfill.cs +++ b/src/Split/netstandard2.1/Numbers/Int32Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,27 +12,32 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out int result) => int.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out int result) => int.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out int result) => int.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its 32-bit signed integer equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out int result) => int.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out int result) => int.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/netstandard2.1/Numbers/Int64Polyfill.cs b/src/Split/netstandard2.1/Numbers/Int64Polyfill.cs index e97be4775..3d7b5c57f 100644 --- a/src/Split/netstandard2.1/Numbers/Int64Polyfill.cs +++ b/src/Split/netstandard2.1/Numbers/Int64Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,27 +12,32 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out long result) => long.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out long result) => long.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out long result) => long.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its 64-bit signed integer equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out long result) => long.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out long result) => long.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/netstandard2.1/Numbers/SBytePolyfill.cs b/src/Split/netstandard2.1/Numbers/SBytePolyfill.cs index 9085c3aec..8de2ac072 100644 --- a/src/Split/netstandard2.1/Numbers/SBytePolyfill.cs +++ b/src/Split/netstandard2.1/Numbers/SBytePolyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,27 +12,32 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out sbyte result) => sbyte.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out sbyte result) => sbyte.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out sbyte result) => sbyte.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its sbyte equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out sbyte result) => sbyte.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out sbyte result) => sbyte.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/netstandard2.1/Numbers/UInt16Polyfill.cs b/src/Split/netstandard2.1/Numbers/UInt16Polyfill.cs index 11d4c4ed7..b3b68b25f 100644 --- a/src/Split/netstandard2.1/Numbers/UInt16Polyfill.cs +++ b/src/Split/netstandard2.1/Numbers/UInt16Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,27 +12,32 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out ushort result) => ushort.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out ushort result) => ushort.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out ushort result) => ushort.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its ushort equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out ushort result) => ushort.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out ushort result) => ushort.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/netstandard2.1/Numbers/UInt32Polyfill.cs b/src/Split/netstandard2.1/Numbers/UInt32Polyfill.cs index abdf707dd..4ba985db3 100644 --- a/src/Split/netstandard2.1/Numbers/UInt32Polyfill.cs +++ b/src/Split/netstandard2.1/Numbers/UInt32Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,27 +12,32 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out uint result) => uint.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out uint result) => uint.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out uint result) => uint.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its uint equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out uint result) => uint.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out uint result) => uint.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/netstandard2.1/Numbers/UInt64Polyfill.cs b/src/Split/netstandard2.1/Numbers/UInt64Polyfill.cs index 1a1bc228c..08e8b0fad 100644 --- a/src/Split/netstandard2.1/Numbers/UInt64Polyfill.cs +++ b/src/Split/netstandard2.1/Numbers/UInt64Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,27 +12,32 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out ulong result) => ulong.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out ulong result) => ulong.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpanutf8Text, NumberStyles style, IFormatProvider? provider, out ulong result) => ulong.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its ulong equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out ulong result) => ulong.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out ulong result) => ulong.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/netstandard2.1/OperatingSystemPolyfill.cs b/src/Split/netstandard2.1/OperatingSystemPolyfill.cs index 5d1f8de36..68413c7d5 100644 --- a/src/Split/netstandard2.1/OperatingSystemPolyfill.cs +++ b/src/Split/netstandard2.1/OperatingSystemPolyfill.cs @@ -3,6 +3,7 @@ #if FeatureRuntimeInformation namespace Polyfills; using System; +using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; static partial class Polyfill @@ -14,114 +15,135 @@ static bool IsOsVersionAtLeast(int major, int minor = 0, int build = 0, int revi /// /// Indicates whether the current application is running as WASI. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsWasi() => RuntimeInformation.IsOSPlatform(OSPlatform.Create("WASI")); /// /// Indicates whether the current application is running on Mac Catalyst. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsMacCatalyst() => OperatingSystem.IsMacOS() || OperatingSystem.IsIOS(); /// /// Check for the Mac Catalyst version (iOS version as presented in Apple documentation) with a ≤ version comparison. Used to guard APIs that were added in the given Mac Catalyst release. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsMacCatalystVersionAtLeast(int major, int minor = 0, int build = 0) => IsMacCatalyst() && IsOsVersionAtLeast(major, minor, build); /// /// Checks if the macOS version (returned by libobjc.get_operatingSystemVersion) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified macOS version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsMacOSVersionAtLeast(int major, int minor = 0, int build = 0) => OperatingSystemCache.IsMacOSVersionAtLeast(major, minor, build); /// /// Checks if the FreeBSD version (returned by the Linux command uname) is greater than or equal to the specified version. /// This method can be used to guard APIs that were added in the specified version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsFreeBSDVersionAtLeast(int major, int minor, int build = 0, int revision = 0) => OperatingSystemCache.IsFreeBSDVersionAtLeast(major, minor, build, revision); /// /// Indicates whether the current application is running on Android. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsAndroid() => OperatingSystemCache.IsAndroid(); /// /// Checks if the Android version (returned by the Linux command uname) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsAndroidVersionAtLeast(int major, int minor = 0, int build = 0, int revision = 0) => OperatingSystemCache.IsAndroidVersionAtLeast(major, minor, build, revision); /// /// Checks if the Windows version (returned by RtlGetVersion) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified Windows version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsWindowsVersionAtLeast(int major, int minor = 0, int build = 0, int revision = 0) => OperatingSystemCache.IsWindowsVersionAtLeast(major, minor, build, revision); /// /// Indicates whether the current application is running on the specified platform. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsOSPlatform(string platform) => RuntimeInformation.IsOSPlatform(OSPlatform.Create(platform)); /// /// Checks if the operating system version is greater than or equal to the specified platform version. This method can be used to guard APIs that were added in the specified OS version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsOSPlatformVersionAtLeast(string platform, int major, int minor = 0, int build = 0, int revision = 0) => IsOSPlatform(platform) && IsOsVersionAtLeast(major, minor, build, revision); /// /// Indicates whether the current application is running on Windows. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsWindows() => RuntimeInformation.IsOSPlatform(OSPlatform.Windows); /// /// Indicates whether the current application is running on macOS. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsMacOS() => RuntimeInformation.IsOSPlatform(OSPlatform.OSX); /// /// Indicates whether the current application is running on iOS or MacCatalyst. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsIOS() => RuntimeInformation.IsOSPlatform(OSPlatform.Create("IOS")); /// /// Indicates whether the current application is running on Linux. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsLinux() => RuntimeInformation.IsOSPlatform(OSPlatform.Linux); /// /// Indicates whether the current application is running on FreeBSD. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsFreeBSD() => RuntimeInformation.OSDescription.ToLower().Contains("freebsd"); /// /// Checks if the iOS/MacCatalyst version (returned by libobjc.get_operatingSystemVersion) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified iOS version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsIOSVersionAtLeast(int major, int minor = 0, int build = 0) => IsIOS() && IsOsVersionAtLeast(major, minor, build); /// /// Checks if the tvOS version (returned by libobjc.get_operatingSystemVersion) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified tvOS version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsTvOSVersionAtLeast(int major, int minor = 0, int build = 0) => IsTvOS() && IsOsVersionAtLeast(major, minor, build); /// /// Indicates whether the current application is running on tvOS. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsTvOS() => RuntimeInformation.IsOSPlatform(OSPlatform.Create("TVOS")); /// /// Indicates whether the current application is running on watchOS. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsWatchOS() => IsIOS() || RuntimeInformation.OSDescription.ToLower().Contains("watchos"); /// /// Checks if the watchOS version (returned by libobjc.get_operatingSystemVersion) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified watchOS version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsWatchOSVersionAtLeast(int major, int minor = 0, int build = 0) => IsWatchOS() && IsOsVersionAtLeast(major, minor, build); /// /// Indicates whether the current application is running as WASM in a browser. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsBrowser() => RuntimeInformation.IsOSPlatform(OSPlatform.Create("BROWSER")); } diff --git a/src/Split/netstandard2.1/PathPolyfill.cs b/src/Split/netstandard2.1/PathPolyfill.cs index dc917864e..607d9e14e 100644 --- a/src/Split/netstandard2.1/PathPolyfill.cs +++ b/src/Split/netstandard2.1/PathPolyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.IO; +using System.Runtime.CompilerServices; static partial class Polyfill { extension(Path) @@ -11,16 +12,19 @@ static partial class Polyfill /// /// Combines a span of strings into a path. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string Combine(scoped ReadOnlySpan paths) => Path.Combine(paths.ToArray()); /// /// Returns a value that indicates whether the path, specified as a read-only span, ends in a directory separator. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool EndsInDirectorySeparator (ReadOnlySpan path) => EndsInDirectorySeparator(path.ToString()); /// /// Trims one trailing directory separator beyond the root of the specified path. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ReadOnlySpan TrimEndingDirectorySeparator(ReadOnlySpan path) => TrimEndingDirectorySeparator(path.ToString()).AsSpan(); #endif diff --git a/src/Split/uap10.0/ConsolePolyfill.cs b/src/Split/uap10.0/ConsolePolyfill.cs index 425364db8..5ad0342de 100644 --- a/src/Split/uap10.0/ConsolePolyfill.cs +++ b/src/Split/uap10.0/ConsolePolyfill.cs @@ -4,6 +4,7 @@ namespace Polyfills; using System; using System.Runtime.InteropServices; +using System.Runtime.CompilerServices; using Microsoft.Win32.SafeHandles; static partial class Polyfill { @@ -12,16 +13,19 @@ static partial class Polyfill /// /// Gets a that wraps the operating system handle for standard input. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static SafeFileHandle OpenStandardInputHandle() => StandardHandleHelper.GetStandardHandle(StandardHandleHelper.StdInput); /// /// Gets a that wraps the operating system handle for standard output. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static SafeFileHandle OpenStandardOutputHandle() => StandardHandleHelper.GetStandardHandle(StandardHandleHelper.StdOutput); /// /// Gets a that wraps the operating system handle for standard error. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static SafeFileHandle OpenStandardErrorHandle() => StandardHandleHelper.GetStandardHandle(StandardHandleHelper.StdError); } diff --git a/src/Split/uap10.0/ConvertPolyfill.cs b/src/Split/uap10.0/ConvertPolyfill.cs index 8ca6da94f..5f80df1f7 100644 --- a/src/Split/uap10.0/ConvertPolyfill.cs +++ b/src/Split/uap10.0/ConvertPolyfill.cs @@ -2,6 +2,7 @@ #pragma warning disable namespace Polyfills; using System; +using System.Runtime.CompilerServices; static partial class Polyfill { extension(Convert) @@ -10,22 +11,26 @@ static partial class Polyfill /// Converts a subset of an array of 8-bit unsigned integers to its equivalent string representation that is encoded with uppercase hex characters. /// Parameters specify the subset as an offset in the input array and the number of elements in the array to convert. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexString(byte[] inArray, int offset, int length) => ToHexString(inArray, offset, length, "X2"); /// /// Converts a subset of an array of 8-bit unsigned integers to its equivalent string representation that is encoded with lowercase hex characters. /// Parameters specify the subset as an offset in the input array and the number of elements in the array to convert. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexStringLower(byte[] inArray, int offset, int length) => ToHexString(inArray, offset, length, "x2"); /// /// Converts an array of 8-bit unsigned integers to its equivalent string representation that is encoded with lowercase hex characters. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexStringLower(byte[] inArray) => Polyfill.ToHexStringLower(inArray, 0, inArray.Length); /// /// Converts an array of 8-bit unsigned integers to its equivalent string representation that is encoded with uppercase hex characters. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexString(byte[] inArray) => Polyfill.ToHexString(inArray, 0, inArray.Length); /// @@ -54,16 +59,19 @@ static int GetHexValue(char hex) => /// /// Converts the span, which encodes binary data as hex characters, to an equivalent 8-bit unsigned integer array. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static byte[] FromHexString(ReadOnlySpan chars) => Polyfill.FromHexString(chars.ToString()); /// /// Converts a span of 8-bit unsigned integers to its equivalent string representation that is encoded with uppercase hex characters. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexString(ReadOnlySpan bytes) => Polyfill.ToHexString(bytes.ToArray()); /// /// Converts a span of 8-bit unsigned integers to its equivalent string representation that is encoded with lowercase hex characters. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexStringLower(ReadOnlySpan bytes) => Polyfill.ToHexStringLower(bytes.ToArray()); /// diff --git a/src/Split/uap10.0/DateTimeOffsetPolyfill.cs b/src/Split/uap10.0/DateTimeOffsetPolyfill.cs index 6837790e5..7bb9a5ad7 100644 --- a/src/Split/uap10.0/DateTimeOffsetPolyfill.cs +++ b/src/Split/uap10.0/DateTimeOffsetPolyfill.cs @@ -4,6 +4,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; static partial class Polyfill { extension(DateTimeOffset target) @@ -30,32 +31,38 @@ long TicksComponent() /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out DateTimeOffset result) => DateTimeOffset.TryParse(s, provider, DateTimeStyles.None, out result); #if FeatureMemory /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out DateTimeOffset result) => DateTimeOffset.TryParse(s.ToString(), provider, DateTimeStyles.None, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan input, out DateTimeOffset result) => DateTimeOffset.TryParse(input.ToString(), null, DateTimeStyles.None, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, DateTimeStyles styles, out DateTimeOffset result) => DateTimeOffset.TryParse(s.ToString(), provider, styles, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParseExact(ReadOnlySpan input, string format, IFormatProvider? provider, DateTimeStyles styles, out DateTimeOffset result) => DateTimeOffset.TryParseExact(input.ToString(), format, provider, styles, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParseExact(ReadOnlySpan input, ReadOnlySpan format, IFormatProvider? provider, DateTimeStyles styles, out DateTimeOffset result) => DateTimeOffset.TryParseExact(input.ToString(), format.ToString(), provider, styles, out result); #endif diff --git a/src/Split/uap10.0/DateTimePolyfill.cs b/src/Split/uap10.0/DateTimePolyfill.cs index 4641f3e59..4d329796a 100644 --- a/src/Split/uap10.0/DateTimePolyfill.cs +++ b/src/Split/uap10.0/DateTimePolyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; static partial class Polyfill { extension(DateTime target) @@ -29,32 +30,38 @@ long TicksComponent() /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out DateTime result) => DateTime.TryParse(s, provider, DateTimeStyles.None, out result); #if FeatureMemory /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out DateTime result) => DateTime.TryParse(s.ToString(), provider, DateTimeStyles.None, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out DateTime result) => DateTime.TryParse(s.ToString(), null, DateTimeStyles.None, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, DateTimeStyles styles, out DateTime result) => DateTime.TryParse(s.ToString(), provider, styles, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParseExact(ReadOnlySpan s, string format, IFormatProvider? provider, DateTimeStyles style, out DateTime result) => DateTime.TryParseExact(s.ToString(), format, provider, style, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParseExact(ReadOnlySpan s, ReadOnlySpan format, IFormatProvider? provider, DateTimeStyles styles, out DateTime result) => DateTime.TryParseExact(s.ToString(), format.ToString(), provider, styles, out result); #endif diff --git a/src/Split/uap10.0/DelegatePolyfill.cs b/src/Split/uap10.0/DelegatePolyfill.cs index effdb1267..59cc5e315 100644 --- a/src/Split/uap10.0/DelegatePolyfill.cs +++ b/src/Split/uap10.0/DelegatePolyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.ComponentModel; +using System.Runtime.CompilerServices; static partial class Polyfill { /// @@ -39,6 +40,7 @@ public bool MoveNext() /// /// Gets an enumerator for the invocation targets of this delegate. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static InvocationListEnumerator EnumerateInvocationList(TDelegate? target) where TDelegate : Delegate => new(target); diff --git a/src/Split/uap10.0/FilePolyfill.cs b/src/Split/uap10.0/FilePolyfill.cs index 6dda0398b..42fd2619b 100644 --- a/src/Split/uap10.0/FilePolyfill.cs +++ b/src/Split/uap10.0/FilePolyfill.cs @@ -48,11 +48,13 @@ public static Task AppendAllTextAsync(string path, ReadOnlyMemory contents /// /// Appends the specified string to the file, creating the file if it does not already exist. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void AppendAllText(string path, ReadOnlySpan contents) => File.AppendAllText(path, contents.ToString()); /// /// Appends the specified string to the file, creating the file if it does not already exist. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void AppendAllText(string path, ReadOnlySpan contents, Encoding encoding) => File.AppendAllText(path, contents.ToString(), encoding); /// @@ -76,12 +78,14 @@ public static async Task WriteAllBytesAsync(string path, ReadOnlyMemory by /// Creates a new file, writes the specified string to the file, and then closes the file. /// If the target file already exists, it is truncated and overwritten. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void WriteAllText(string path, ReadOnlySpan contents) => File.WriteAllText(path, contents.ToString()); /// /// Creates a new file, writes the specified string to the file using the specified encoding, and then closes the file. /// If the target file already exists, it is truncated and overwritten. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void WriteAllText(string path, ReadOnlySpan contents, Encoding encoding) => File.WriteAllText(path, contents.ToString(), encoding); /// diff --git a/src/Split/uap10.0/GuidPolyfill.cs b/src/Split/uap10.0/GuidPolyfill.cs index 2bd536736..bc6b9129b 100644 --- a/src/Split/uap10.0/GuidPolyfill.cs +++ b/src/Split/uap10.0/GuidPolyfill.cs @@ -4,6 +4,7 @@ namespace Polyfills; using System.Text; using System; using System.Security.Cryptography; +using System.Runtime.CompilerServices; static partial class Polyfill { extension(Guid) @@ -11,9 +12,11 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out Guid result) => Guid.TryParse(s, out result); /// Creates a new according to RFC 9562, following the Version 7 format. + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Guid CreateVersion7() => CreateVersion7(DateTimeOffset.UtcNow); /// Creates a new according to RFC 9562, following the Version 7 format. public static Guid CreateVersion7(DateTimeOffset timestamp) @@ -40,26 +43,31 @@ public static Guid CreateVersion7(DateTimeOffset timestamp) /// /// Converts span of characters representing the GUID to the equivalent Guid structure, provided that the string is in the specified format. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParseExact(ReadOnlySpan input, ReadOnlySpan format, out Guid result) => Guid.TryParseExact(input.ToString(), format.ToString(), out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out Guid result) => Guid.TryParse(s.ToString(), out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan input, out Guid result) => Guid.TryParse(input.ToString(), out result); /// /// Tries to parse a span of UTF-8 bytes into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out Guid result) => Guid.TryParse(Encoding.UTF8.GetString(utf8Text), out result); /// /// Parse a span of UTF-8 bytes into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Guid Parse(ReadOnlySpan utf8Text) => Guid.Parse(Encoding.UTF8.GetString(utf8Text)); #endif diff --git a/src/Split/uap10.0/Lock.cs b/src/Split/uap10.0/Lock.cs index 94fcf1ff9..36946028c 100644 --- a/src/Split/uap10.0/Lock.cs +++ b/src/Split/uap10.0/Lock.cs @@ -5,6 +5,7 @@ namespace System.Threading; using Diagnostics; using Diagnostics.CodeAnalysis; +using Runtime.CompilerServices; /// /// Provides a way to get mutual exclusion in regions of code between different threads. A lock may be held by one thread at /// a time. @@ -23,26 +24,31 @@ class Lock /// /// Enters the lock. Once the method returns, the calling thread would be the only thread that holds the lock. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Enter() => Monitor.Enter(this); /// /// Tries to enter the lock without waiting. If the lock is entered, the calling thread would be the only thread that /// holds the lock. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool TryEnter() => Monitor.TryEnter(this); /// /// Tries to enter the lock, waiting for roughly the specified duration. If the lock is entered, the calling thread /// would be the only thread that holds the lock. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool TryEnter(TimeSpan timeout) => Monitor.TryEnter(this, timeout); /// /// Tries to enter the lock, waiting for roughly the specified duration. If the lock is entered, the calling thread /// would be the only thread that holds the lock. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool TryEnter(int millisecondsTimeout) => TryEnter(TimeSpan.FromMilliseconds(millisecondsTimeout)); /// /// Exits the lock. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Exit() => Monitor.Exit(this); /// /// Enters the lock and returns a that may be disposed to exit the lock. Once the method returns, diff --git a/src/Split/uap10.0/Numbers/BytePolyfill.cs b/src/Split/uap10.0/Numbers/BytePolyfill.cs index ef3f744ed..0ea017afd 100644 --- a/src/Split/uap10.0/Numbers/BytePolyfill.cs +++ b/src/Split/uap10.0/Numbers/BytePolyfill.cs @@ -4,6 +4,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -12,37 +13,44 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out byte result) => byte.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out byte result) => byte.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out byte result) => byte.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out byte result) => byte.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its byte equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out byte result) => byte.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its byte equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out byte result) => byte.TryParse(s.ToString(), out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its byte equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out byte result) => byte.TryParse(s.ToString(), style, provider, out result); #endif diff --git a/src/Split/uap10.0/Numbers/DoublePolyfill.cs b/src/Split/uap10.0/Numbers/DoublePolyfill.cs index ba5333f69..d903ddfe1 100644 --- a/src/Split/uap10.0/Numbers/DoublePolyfill.cs +++ b/src/Split/uap10.0/Numbers/DoublePolyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,37 +12,44 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out double result) => double.TryParse(s, NumberStyles.Float, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out double result) => double.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Float, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out double result) => double.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its double-precision floating-point number equivalent.. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out double result) => double.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Float, null, out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its double-precision floating-point number equivalent. A return value indicates whether the conversion succeeded or failed. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out double result) => double.TryParse(s.ToString(), out result); /// /// Converts the string representation of a number in a specified style and culture-specific format to its double-precision floating-point number equivalent. A return value indicates whether the conversion succeeded or failed. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out double result) => double.TryParse(s.ToString(), style, provider, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out double result) => double.TryParse(s.ToString(), NumberStyles.Float, provider, out result); #endif diff --git a/src/Split/uap10.0/Numbers/Int16Polyfill.cs b/src/Split/uap10.0/Numbers/Int16Polyfill.cs index 5eb1b384e..960cf68ce 100644 --- a/src/Split/uap10.0/Numbers/Int16Polyfill.cs +++ b/src/Split/uap10.0/Numbers/Int16Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,37 +12,44 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out short result) => short.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out short result) => short.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out short result) => short.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its short equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out short result) => short.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its short equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out short result) => short.TryParse(s.ToString(), out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its short equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out short result) => short.TryParse(s.ToString(), style, provider, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out short result) => short.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/uap10.0/Numbers/Int32Polyfill.cs b/src/Split/uap10.0/Numbers/Int32Polyfill.cs index 549ff1896..2920eae4a 100644 --- a/src/Split/uap10.0/Numbers/Int32Polyfill.cs +++ b/src/Split/uap10.0/Numbers/Int32Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,37 +12,44 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out int result) => int.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out int result) => int.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out int result) => int.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its 32-bit signed integer equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out int result) => int.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its 32-bit signed integer equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out int result) => int.TryParse(s.ToString(), out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its 32-bit signed integer equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out int result) => int.TryParse(s.ToString(), style, provider, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out int result) => int.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/uap10.0/Numbers/Int64Polyfill.cs b/src/Split/uap10.0/Numbers/Int64Polyfill.cs index bd33ce0e6..0b7b1b100 100644 --- a/src/Split/uap10.0/Numbers/Int64Polyfill.cs +++ b/src/Split/uap10.0/Numbers/Int64Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,37 +12,44 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out long result) => long.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out long result) => long.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out long result) => long.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its 64-bit signed integer equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out long result) => long.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its 32-bit signed integer equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out long result) => long.TryParse(s.ToString(), out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its 64-bit signed integer equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out long result) => long.TryParse(s.ToString(), style, provider, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out long result) => long.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/uap10.0/Numbers/SBytePolyfill.cs b/src/Split/uap10.0/Numbers/SBytePolyfill.cs index 974115654..890452b1c 100644 --- a/src/Split/uap10.0/Numbers/SBytePolyfill.cs +++ b/src/Split/uap10.0/Numbers/SBytePolyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,37 +12,44 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out sbyte result) => sbyte.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out sbyte result) => sbyte.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out sbyte result) => sbyte.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its sbyte equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out sbyte result) => sbyte.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its sbyte equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out sbyte result) => sbyte.TryParse(s.ToString(), out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its sbyte equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out sbyte result) => sbyte.TryParse(s.ToString(), style, provider, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out sbyte result) => sbyte.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/uap10.0/Numbers/UInt16Polyfill.cs b/src/Split/uap10.0/Numbers/UInt16Polyfill.cs index 34f39f97c..ed0958805 100644 --- a/src/Split/uap10.0/Numbers/UInt16Polyfill.cs +++ b/src/Split/uap10.0/Numbers/UInt16Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,37 +12,44 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out ushort result) => ushort.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out ushort result) => ushort.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out ushort result) => ushort.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its ushort equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out ushort result) => ushort.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its ushort equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out ushort result) => ushort.TryParse(s.ToString(), out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its ushort equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out ushort result) => ushort.TryParse(s.ToString(), style, provider, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out ushort result) => ushort.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/uap10.0/Numbers/UInt32Polyfill.cs b/src/Split/uap10.0/Numbers/UInt32Polyfill.cs index 859149bed..e11b65c90 100644 --- a/src/Split/uap10.0/Numbers/UInt32Polyfill.cs +++ b/src/Split/uap10.0/Numbers/UInt32Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,37 +12,44 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out uint result) => uint.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out uint result) => uint.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out uint result) => uint.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its uint equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out uint result) => uint.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its uint equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out uint result) => uint.TryParse(s.ToString(), out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its uint equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out uint result) => uint.TryParse(s.ToString(), style, provider, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out uint result) => uint.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/uap10.0/Numbers/UInt64Polyfill.cs b/src/Split/uap10.0/Numbers/UInt64Polyfill.cs index c14bb347c..10122d2b4 100644 --- a/src/Split/uap10.0/Numbers/UInt64Polyfill.cs +++ b/src/Split/uap10.0/Numbers/UInt64Polyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; static partial class Polyfill { @@ -11,37 +12,44 @@ static partial class Polyfill /// /// Tries to parse a string into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out ulong result) => ulong.TryParse(s, NumberStyles.Integer, provider, out result); #if FeatureMemory /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out ulong result) => ulong.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); /// /// Tries to parse a span of UTF-8 characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpanutf8Text, NumberStyles style, IFormatProvider? provider, out ulong result) => ulong.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); /// /// Tries to convert a UTF-8 character span containing the string representation of a number to its ulong equivalent. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out ulong result) => ulong.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its ulong equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out ulong result) => ulong.TryParse(s.ToString(), out result); /// /// Converts the span representation of a number in a specified style and culture-specific format to its ulong equivalent. A return value indicates whether the conversion succeeded. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out ulong result) => ulong.TryParse(s.ToString(), style, provider, out result); /// /// Tries to parse a span of characters into a value. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out ulong result) => ulong.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); #endif diff --git a/src/Split/uap10.0/OperatingSystemPolyfill.cs b/src/Split/uap10.0/OperatingSystemPolyfill.cs index 5d1f8de36..68413c7d5 100644 --- a/src/Split/uap10.0/OperatingSystemPolyfill.cs +++ b/src/Split/uap10.0/OperatingSystemPolyfill.cs @@ -3,6 +3,7 @@ #if FeatureRuntimeInformation namespace Polyfills; using System; +using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; static partial class Polyfill @@ -14,114 +15,135 @@ static bool IsOsVersionAtLeast(int major, int minor = 0, int build = 0, int revi /// /// Indicates whether the current application is running as WASI. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsWasi() => RuntimeInformation.IsOSPlatform(OSPlatform.Create("WASI")); /// /// Indicates whether the current application is running on Mac Catalyst. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsMacCatalyst() => OperatingSystem.IsMacOS() || OperatingSystem.IsIOS(); /// /// Check for the Mac Catalyst version (iOS version as presented in Apple documentation) with a ≤ version comparison. Used to guard APIs that were added in the given Mac Catalyst release. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsMacCatalystVersionAtLeast(int major, int minor = 0, int build = 0) => IsMacCatalyst() && IsOsVersionAtLeast(major, minor, build); /// /// Checks if the macOS version (returned by libobjc.get_operatingSystemVersion) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified macOS version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsMacOSVersionAtLeast(int major, int minor = 0, int build = 0) => OperatingSystemCache.IsMacOSVersionAtLeast(major, minor, build); /// /// Checks if the FreeBSD version (returned by the Linux command uname) is greater than or equal to the specified version. /// This method can be used to guard APIs that were added in the specified version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsFreeBSDVersionAtLeast(int major, int minor, int build = 0, int revision = 0) => OperatingSystemCache.IsFreeBSDVersionAtLeast(major, minor, build, revision); /// /// Indicates whether the current application is running on Android. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsAndroid() => OperatingSystemCache.IsAndroid(); /// /// Checks if the Android version (returned by the Linux command uname) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsAndroidVersionAtLeast(int major, int minor = 0, int build = 0, int revision = 0) => OperatingSystemCache.IsAndroidVersionAtLeast(major, minor, build, revision); /// /// Checks if the Windows version (returned by RtlGetVersion) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified Windows version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsWindowsVersionAtLeast(int major, int minor = 0, int build = 0, int revision = 0) => OperatingSystemCache.IsWindowsVersionAtLeast(major, minor, build, revision); /// /// Indicates whether the current application is running on the specified platform. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsOSPlatform(string platform) => RuntimeInformation.IsOSPlatform(OSPlatform.Create(platform)); /// /// Checks if the operating system version is greater than or equal to the specified platform version. This method can be used to guard APIs that were added in the specified OS version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsOSPlatformVersionAtLeast(string platform, int major, int minor = 0, int build = 0, int revision = 0) => IsOSPlatform(platform) && IsOsVersionAtLeast(major, minor, build, revision); /// /// Indicates whether the current application is running on Windows. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsWindows() => RuntimeInformation.IsOSPlatform(OSPlatform.Windows); /// /// Indicates whether the current application is running on macOS. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsMacOS() => RuntimeInformation.IsOSPlatform(OSPlatform.OSX); /// /// Indicates whether the current application is running on iOS or MacCatalyst. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsIOS() => RuntimeInformation.IsOSPlatform(OSPlatform.Create("IOS")); /// /// Indicates whether the current application is running on Linux. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsLinux() => RuntimeInformation.IsOSPlatform(OSPlatform.Linux); /// /// Indicates whether the current application is running on FreeBSD. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsFreeBSD() => RuntimeInformation.OSDescription.ToLower().Contains("freebsd"); /// /// Checks if the iOS/MacCatalyst version (returned by libobjc.get_operatingSystemVersion) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified iOS version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsIOSVersionAtLeast(int major, int minor = 0, int build = 0) => IsIOS() && IsOsVersionAtLeast(major, minor, build); /// /// Checks if the tvOS version (returned by libobjc.get_operatingSystemVersion) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified tvOS version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsTvOSVersionAtLeast(int major, int minor = 0, int build = 0) => IsTvOS() && IsOsVersionAtLeast(major, minor, build); /// /// Indicates whether the current application is running on tvOS. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsTvOS() => RuntimeInformation.IsOSPlatform(OSPlatform.Create("TVOS")); /// /// Indicates whether the current application is running on watchOS. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsWatchOS() => IsIOS() || RuntimeInformation.OSDescription.ToLower().Contains("watchos"); /// /// Checks if the watchOS version (returned by libobjc.get_operatingSystemVersion) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified watchOS version. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsWatchOSVersionAtLeast(int major, int minor = 0, int build = 0) => IsWatchOS() && IsOsVersionAtLeast(major, minor, build); /// /// Indicates whether the current application is running as WASM in a browser. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsBrowser() => RuntimeInformation.IsOSPlatform(OSPlatform.Create("BROWSER")); } diff --git a/src/Split/uap10.0/PathPolyfill.cs b/src/Split/uap10.0/PathPolyfill.cs index fb4329ac6..fc8009da8 100644 --- a/src/Split/uap10.0/PathPolyfill.cs +++ b/src/Split/uap10.0/PathPolyfill.cs @@ -3,6 +3,7 @@ namespace Polyfills; using System; using System.IO; +using System.Runtime.CompilerServices; static partial class Polyfill { extension(Path) @@ -11,41 +12,49 @@ static partial class Polyfill /// /// Returns the directory information for the specified path represented by a character span. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ReadOnlySpan GetDirectoryName(ReadOnlySpan path) => Path.GetDirectoryName(path.ToString()).AsSpan(); /// /// Returns the file name and extension of a file path that is represented by a read-only character span. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ReadOnlySpan GetFileName(ReadOnlySpan path) => Path.GetFileName(path.ToString()).AsSpan(); /// /// Returns the file name without the extension of a file path that is represented by a read-only character span. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ReadOnlySpan GetFileNameWithoutExtension(ReadOnlySpan path) => Path.GetFileNameWithoutExtension(path.ToString()).AsSpan(); /// /// Determines whether the path represented by the specified character span includes a file name extension. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool HasExtension(ReadOnlySpan path) => Path.HasExtension(path.ToString()); /// /// Returns the extension of the given path. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ReadOnlySpan GetExtension(ReadOnlySpan path) => Path.GetExtension(path.ToString()).AsSpan(); /// /// Combines a span of strings into a path. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string Combine(scoped ReadOnlySpan paths) => Path.Combine(paths.ToArray()); /// /// Returns a value that indicates whether the path, specified as a read-only span, ends in a directory separator. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool EndsInDirectorySeparator (ReadOnlySpan path) => EndsInDirectorySeparator(path.ToString()); /// /// Trims one trailing directory separator beyond the root of the specified path. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ReadOnlySpan TrimEndingDirectorySeparator(ReadOnlySpan path) => TrimEndingDirectorySeparator(path.ToString()).AsSpan(); #endif From 6650d64d5b196a0e29f68359850bf366afa75f3a Mon Sep 17 00:00:00 2001 From: Simon Cropp Date: Tue, 3 Mar 2026 20:44:53 +1100 Subject: [PATCH 2/2] . --- src/Polyfill/ConsolePolyfill.cs | 4 ---- src/Polyfill/ConvertPolyfill.cs | 8 -------- src/Polyfill/DateTimeOffsetPolyfill.cs | 7 ------- src/Polyfill/DateTimePolyfill.cs | 7 ------- src/Polyfill/DelegatePolyfill.cs | 2 -- src/Polyfill/FilePolyfill.cs | 4 ---- src/Polyfill/GuidPolyfill.cs | 8 -------- src/Polyfill/KeyValuePair.cs | 2 -- src/Polyfill/Lock.cs | 6 ------ src/Polyfill/Numbers/BytePolyfill.cs | 8 -------- src/Polyfill/Numbers/DoublePolyfill.cs | 8 -------- src/Polyfill/Numbers/Int16Polyfill.cs | 8 -------- src/Polyfill/Numbers/Int32Polyfill.cs | 8 -------- src/Polyfill/Numbers/Int64Polyfill.cs | 8 -------- src/Polyfill/Numbers/SBytePolyfill.cs | 8 -------- src/Polyfill/Numbers/UInt16Polyfill.cs | 8 -------- src/Polyfill/Numbers/UInt32Polyfill.cs | 8 -------- src/Polyfill/Numbers/UInt64Polyfill.cs | 8 -------- src/Polyfill/OperatingSystemPolyfill.cs | 20 -------------------- src/Polyfill/PathPolyfill.cs | 9 --------- 20 files changed, 149 deletions(-) diff --git a/src/Polyfill/ConsolePolyfill.cs b/src/Polyfill/ConsolePolyfill.cs index b51f88498..8a8bf9e9c 100644 --- a/src/Polyfill/ConsolePolyfill.cs +++ b/src/Polyfill/ConsolePolyfill.cs @@ -4,7 +4,6 @@ namespace Polyfills; using System; using System.Runtime.InteropServices; -using System.Runtime.CompilerServices; using Microsoft.Win32.SafeHandles; static partial class Polyfill @@ -15,7 +14,6 @@ static partial class Polyfill /// Gets a that wraps the operating system handle for standard input. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.console.openstandardinputhandle?view=net-11.0 - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static SafeFileHandle OpenStandardInputHandle() => StandardHandleHelper.GetStandardHandle(StandardHandleHelper.StdInput); @@ -23,7 +21,6 @@ public static SafeFileHandle OpenStandardInputHandle() => /// Gets a that wraps the operating system handle for standard output. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.console.openstandardoutputhandle?view=net-11.0 - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static SafeFileHandle OpenStandardOutputHandle() => StandardHandleHelper.GetStandardHandle(StandardHandleHelper.StdOutput); @@ -31,7 +28,6 @@ public static SafeFileHandle OpenStandardOutputHandle() => /// Gets a that wraps the operating system handle for standard error. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.console.openstandarderrorhandle?view=net-11.0 - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static SafeFileHandle OpenStandardErrorHandle() => StandardHandleHelper.GetStandardHandle(StandardHandleHelper.StdError); } diff --git a/src/Polyfill/ConvertPolyfill.cs b/src/Polyfill/ConvertPolyfill.cs index 093af7140..d05a819fd 100644 --- a/src/Polyfill/ConvertPolyfill.cs +++ b/src/Polyfill/ConvertPolyfill.cs @@ -3,7 +3,6 @@ namespace Polyfills; using System; -using System.Runtime.CompilerServices; static partial class Polyfill { @@ -16,7 +15,6 @@ static partial class Polyfill /// Parameters specify the subset as an offset in the input array and the number of elements in the array to convert. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.convert.tohexstring?view=net-11.0#system-convert-tohexstring(system-byte()-system-int32-system-int32) - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexString(byte[] inArray, int offset, int length) => ToHexString(inArray, offset, length, "X2"); #endif @@ -27,7 +25,6 @@ public static string ToHexString(byte[] inArray, int offset, int length) => /// Parameters specify the subset as an offset in the input array and the number of elements in the array to convert. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.convert.tohexstringlower?view=net-11.0#system-convert-tohexstringlower(system-byte()-system-int32-system-int32) - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexStringLower(byte[] inArray, int offset, int length) => ToHexString(inArray, offset, length, "x2"); @@ -35,7 +32,6 @@ public static string ToHexStringLower(byte[] inArray, int offset, int length) => /// Converts an array of 8-bit unsigned integers to its equivalent string representation that is encoded with lowercase hex characters. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.convert.tohexstringlower?view=net-11.0#system-convert-tohexstringlower(system-byte()) - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexStringLower(byte[] inArray) => Polyfill.ToHexStringLower(inArray, 0, inArray.Length); #endif @@ -44,7 +40,6 @@ public static string ToHexStringLower(byte[] inArray) => /// Converts an array of 8-bit unsigned integers to its equivalent string representation that is encoded with uppercase hex characters. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.convert.tohexstring?view=net-11.0#system-convert-tohexstring(system-byte()) - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexString(byte[] inArray) => Polyfill.ToHexString(inArray, 0, inArray.Length); @@ -84,7 +79,6 @@ static int GetHexValue(char hex) => /// Converts the span, which encodes binary data as hex characters, to an equivalent 8-bit unsigned integer array. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.convert.fromhexstring?view=net-11.0#system-convert-fromhexstring(system-readonlyspan((system-char))) - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static byte[] FromHexString(ReadOnlySpan chars) => Polyfill.FromHexString(chars.ToString()); @@ -92,7 +86,6 @@ public static byte[] FromHexString(ReadOnlySpan chars) => /// Converts a span of 8-bit unsigned integers to its equivalent string representation that is encoded with uppercase hex characters. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.convert.tohexstring?view=net-11.0#system-convert-tohexstring(system-readonlyspan((system-byte))) - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexString(ReadOnlySpan bytes) => Polyfill.ToHexString(bytes.ToArray()); #endif @@ -102,7 +95,6 @@ public static string ToHexString(ReadOnlySpan bytes) => /// Converts a span of 8-bit unsigned integers to its equivalent string representation that is encoded with lowercase hex characters. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.convert.tohexstringlower?view=net-11.0#system-convert-tohexstringlower(system-readonlyspan((system-byte))) - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToHexStringLower(ReadOnlySpan bytes) => Polyfill.ToHexStringLower(bytes.ToArray()); diff --git a/src/Polyfill/DateTimeOffsetPolyfill.cs b/src/Polyfill/DateTimeOffsetPolyfill.cs index df1a5de5e..f159c3291 100644 --- a/src/Polyfill/DateTimeOffsetPolyfill.cs +++ b/src/Polyfill/DateTimeOffsetPolyfill.cs @@ -6,7 +6,6 @@ namespace Polyfills; using System; using System.Globalization; -using System.Runtime.CompilerServices; static partial class Polyfill { @@ -46,7 +45,6 @@ long TicksComponent() /// Tries to parse a string into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.datetimeoffset.tryparse?view=net-11.0#system-datetimeoffset-tryparse(system-string-system-iformatprovider-system-datetimeoffset@) - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out DateTimeOffset result) => DateTimeOffset.TryParse(s, provider, DateTimeStyles.None, out result); #endif @@ -58,7 +56,6 @@ public static bool TryParse(string? s, IFormatProvider? provider, out DateTimeOf /// Tries to parse a span of characters into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.datetimeoffset.tryparse?view=net-11.0#system-datetimeoffset-tryparse(system-readonlyspan((system-char))-system-iformatprovider-system-datetimeoffset@) - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out DateTimeOffset result) => DateTimeOffset.TryParse(s.ToString(), provider, DateTimeStyles.None, out result); #endif @@ -68,7 +65,6 @@ public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out /// Tries to parse a span of characters into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.datetimeoffset.tryparse?view=net-11.0#system-datetimeoffset-tryparse(system-readonlyspan((system-char))-system-datetimeoffset@) - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan input, out DateTimeOffset result) => DateTimeOffset.TryParse(input.ToString(), null, DateTimeStyles.None, out result); @@ -76,7 +72,6 @@ public static bool TryParse(ReadOnlySpan input, out DateTimeOffset result) /// Tries to parse a span of characters into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.datetimeoffset.tryparse?view=net-11.0#system-datetimeoffset-tryparse(system-readonlyspan((system-char))-system-iformatprovider-system-globalization-datetimestyles-system-datetimeoffset@) - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, DateTimeStyles styles, out DateTimeOffset result) => DateTimeOffset.TryParse(s.ToString(), provider, styles, out result); @@ -84,7 +79,6 @@ public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, Dat /// Tries to parse a span of characters into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.datetimeoffset.tryparseexact?view=net-11.0#system-datetimeoffset-tryparseexact(system-readonlyspan((system-char))-system-readonlyspan((system-char))-system-iformatprovider-system-globalization-datetimestyles-system-datetimeoffset@) - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParseExact(ReadOnlySpan input, string format, IFormatProvider? provider, DateTimeStyles styles, out DateTimeOffset result) => DateTimeOffset.TryParseExact(input.ToString(), format, provider, styles, out result); #endif @@ -94,7 +88,6 @@ public static bool TryParseExact(ReadOnlySpan input, string format, IForma /// Tries to parse a span of characters into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.datetimeoffset.tryparseexact?view=net-11.0#system-datetimeoffset-tryparseexact(system-readonlyspan((system-char))-system-readonlyspan((system-char))-system-iformatprovider-system-globalization-datetimestyles-system-datetimeoffset@) - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParseExact(ReadOnlySpan input, ReadOnlySpan format, IFormatProvider? provider, DateTimeStyles styles, out DateTimeOffset result) => DateTimeOffset.TryParseExact(input.ToString(), format.ToString(), provider, styles, out result); #endif diff --git a/src/Polyfill/DateTimePolyfill.cs b/src/Polyfill/DateTimePolyfill.cs index 852e78a4a..a413bccf6 100644 --- a/src/Polyfill/DateTimePolyfill.cs +++ b/src/Polyfill/DateTimePolyfill.cs @@ -4,7 +4,6 @@ namespace Polyfills; using System; using System.Globalization; -using System.Runtime.CompilerServices; static partial class Polyfill { @@ -42,7 +41,6 @@ long TicksComponent() /// Tries to parse a string into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.datetime.tryparse?view=net-11.0#system-datetime-tryparse(system-string-system-iformatprovider-system-datetime@) - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out DateTime result) => DateTime.TryParse(s, provider, DateTimeStyles.None, out result); #endif @@ -54,7 +52,6 @@ public static bool TryParse(string? s, IFormatProvider? provider, out DateTime r /// Tries to parse a span of characters into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.datetime.tryparse?view=net-11.0#system-datetime-tryparse(system-readonlyspan((system-char))-system-iformatprovider-system-datetime@) - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out DateTime result) => DateTime.TryParse(s.ToString(), provider, DateTimeStyles.None, out result); #endif @@ -64,7 +61,6 @@ public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out /// Tries to parse a span of characters into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.datetime.tryparse?view=net-11.0#system-datetime-tryparse(system-readonlyspan((system-char))-system-datetime@) - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out DateTime result) => DateTime.TryParse(s.ToString(), null, DateTimeStyles.None, out result); @@ -72,7 +68,6 @@ public static bool TryParse(ReadOnlySpan s, out DateTime result) => /// Tries to parse a span of characters into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.datetime.tryparse?view=net-11.0#system-datetime-tryparse(system-readonlyspan((system-char))-system-iformatprovider-system-globalization-datetimestyles-system-datetime@) - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, DateTimeStyles styles, out DateTime result) => DateTime.TryParse(s.ToString(), provider, styles, out result); @@ -80,7 +75,6 @@ public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, Dat /// Tries to parse a span of characters into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.datetime.tryparseexact?view=net-11.0#system-datetime-tryparseexact(system-readonlyspan((system-char))-system-readonlyspan((system-char))-system-iformatprovider-system-globalization-datetimestyles-system-datetime@) - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParseExact(ReadOnlySpan s, string format, IFormatProvider? provider, DateTimeStyles style, out DateTime result) => DateTime.TryParseExact(s.ToString(), format, provider, style, out result); #endif @@ -90,7 +84,6 @@ public static bool TryParseExact(ReadOnlySpan s, string format, IFormatPro /// Tries to parse a span of characters into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.datetime.tryparseexact?view=net-11.0#system-datetime-tryparseexact(system-readonlyspan((system-char))-system-readonlyspan((system-char))-system-iformatprovider-system-globalization-datetimestyles-system-datetime@) - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParseExact(ReadOnlySpan s, ReadOnlySpan format, IFormatProvider? provider, DateTimeStyles styles, out DateTime result) => DateTime.TryParseExact(s.ToString(), format.ToString(), provider, styles, out result); #endif diff --git a/src/Polyfill/DelegatePolyfill.cs b/src/Polyfill/DelegatePolyfill.cs index be369f206..efdc07f9f 100644 --- a/src/Polyfill/DelegatePolyfill.cs +++ b/src/Polyfill/DelegatePolyfill.cs @@ -4,7 +4,6 @@ namespace Polyfills; using System; using System.ComponentModel; -using System.Runtime.CompilerServices; static partial class Polyfill { @@ -50,7 +49,6 @@ public bool MoveNext() /// Gets an enumerator for the invocation targets of this delegate. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.delegate.enumerateinvocationlist?view=net-11.0 - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static InvocationListEnumerator EnumerateInvocationList(TDelegate? target) where TDelegate : Delegate => new(target); diff --git a/src/Polyfill/FilePolyfill.cs b/src/Polyfill/FilePolyfill.cs index 3499afb24..1a4f479a0 100644 --- a/src/Polyfill/FilePolyfill.cs +++ b/src/Polyfill/FilePolyfill.cs @@ -65,7 +65,6 @@ public static Task AppendAllTextAsync(string path, ReadOnlyMemory contents /// Appends the specified string to the file, creating the file if it does not already exist. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.io.file.appendalltext?view=net-11.0#system-io-file-appendalltext(system-string-system-readonlyspan((system-char))) - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void AppendAllText(string path, ReadOnlySpan contents) => File.AppendAllText(path, contents.ToString()); @@ -73,7 +72,6 @@ public static void AppendAllText(string path, ReadOnlySpan contents) => /// Appends the specified string to the file, creating the file if it does not already exist. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.io.file.appendalltext?view=net-11.0#system-io-file-appendalltext(system-string-system-readonlyspan((system-char))-system-text-encoding) - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void AppendAllText(string path, ReadOnlySpan contents, Encoding encoding) => File.AppendAllText(path, contents.ToString(), encoding); @@ -103,7 +101,6 @@ public static async Task WriteAllBytesAsync(string path, ReadOnlyMemory by /// If the target file already exists, it is truncated and overwritten. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.io.file.writealltext?view=net-11.0#system-io-file-writealltext(system-string-system-readonlyspan((system-char))) - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void WriteAllText(string path, ReadOnlySpan contents) => File.WriteAllText(path, contents.ToString()); @@ -112,7 +109,6 @@ public static void WriteAllText(string path, ReadOnlySpan contents) => /// If the target file already exists, it is truncated and overwritten. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.io.file.writealltext?view=net-11.0#system-io-file-writealltext(system-string-system-readonlyspan((system-char))-system-text-encoding) - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void WriteAllText(string path, ReadOnlySpan contents, Encoding encoding) => File.WriteAllText(path, contents.ToString(), encoding); diff --git a/src/Polyfill/GuidPolyfill.cs b/src/Polyfill/GuidPolyfill.cs index fe3f17c52..c4e8f23ea 100644 --- a/src/Polyfill/GuidPolyfill.cs +++ b/src/Polyfill/GuidPolyfill.cs @@ -7,7 +7,6 @@ namespace Polyfills; using System.Text; using System; using System.Security.Cryptography; -using System.Runtime.CompilerServices; static partial class Polyfill { @@ -19,7 +18,6 @@ static partial class Polyfill /// Tries to parse a string into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.guid.tryparse?view=net-11.0#system-guid-tryparse(system-string-system-iformatprovider-system-guid@) - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out Guid result) => Guid.TryParse(s, out result); @@ -29,7 +27,6 @@ public static bool TryParse(string? s, IFormatProvider? provider, out Guid resul /// Creates a new according to RFC 9562, following the Version 7 format. //Link: https://learn.microsoft.com/en-us/dotnet/api/system.guid.createversion7?view=net-11.0#system-guid-createversion7 - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Guid CreateVersion7() => CreateVersion7(DateTimeOffset.UtcNow); /// Creates a new according to RFC 9562, following the Version 7 format. @@ -90,7 +87,6 @@ public static Guid CreateVersion7(DateTimeOffset timestamp) /// Converts span of characters representing the GUID to the equivalent Guid structure, provided that the string is in the specified format. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.guid.tryparseexact?view=net-11.0#system-guid-tryparseexact(system-readonlyspan((system-char))-system-readonlyspan((system-char))-system-guid@) - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParseExact(ReadOnlySpan input, ReadOnlySpan format, out Guid result) => Guid.TryParseExact(input.ToString(), format.ToString(), out result); @@ -102,7 +98,6 @@ public static bool TryParseExact(ReadOnlySpan input, ReadOnlySpan fo /// Tries to parse a span of UTF-8 characters into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.guid.tryparse?view=net-11.0#system-guid-tryparse(system-readonlyspan((system-char))-system-iformatprovider-system-guid@) - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out Guid result) => Guid.TryParse(s.ToString(), out result); @@ -114,7 +109,6 @@ public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out /// Tries to parse a span of UTF-8 characters into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.guid.tryparse?view=net-11.0#system-guid-tryparse(system-readonlyspan((system-char))-system-guid@) - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan input, out Guid result) => Guid.TryParse(input.ToString(), out result); @@ -125,7 +119,6 @@ public static bool TryParse(ReadOnlySpan input, out Guid result) => /// Tries to parse a span of UTF-8 bytes into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.guid.tryparse?view=net-11.0#system-guid-tryparse(system-readonlyspan((system-byte))-system-guid@) - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out Guid result) => Guid.TryParse(Encoding.UTF8.GetString(utf8Text), out result); @@ -133,7 +126,6 @@ public static bool TryParse(ReadOnlySpan utf8Text, out Guid result) => /// Parse a span of UTF-8 bytes into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.guid.parse?view=net-11.0#system-guid-parse(system-readonlyspan((system-byte))) - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Guid Parse(ReadOnlySpan utf8Text) => Guid.Parse(Encoding.UTF8.GetString(utf8Text)); diff --git a/src/Polyfill/KeyValuePair.cs b/src/Polyfill/KeyValuePair.cs index 8440024a1..8eb6e53fa 100644 --- a/src/Polyfill/KeyValuePair.cs +++ b/src/Polyfill/KeyValuePair.cs @@ -6,7 +6,6 @@ namespace System.Collections.Generic; // ReSharper disable RedundantNameQualifier using System.Diagnostics; using System.Diagnostics.CodeAnalysis; -using System.Runtime.CompilerServices; // ReSharper restore RedundantNameQualifier [ExcludeFromCodeCoverage] @@ -25,7 +24,6 @@ static class KeyValuePair /// Creates a new key/value pair instance using provided values. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.keyvaluepair.create?view=net-11.0 - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static KeyValuePair Create(TKey key, TValue value) => new(key, value); } diff --git a/src/Polyfill/Lock.cs b/src/Polyfill/Lock.cs index cf928f5c9..c93a914f7 100644 --- a/src/Polyfill/Lock.cs +++ b/src/Polyfill/Lock.cs @@ -8,7 +8,6 @@ namespace System.Threading; using Diagnostics; using Diagnostics.CodeAnalysis; -using Runtime.CompilerServices; /// /// Provides a way to get mutual exclusion in regions of code between different threads. A lock may be held by one thread at @@ -30,35 +29,30 @@ class Lock /// /// Enters the lock. Once the method returns, the calling thread would be the only thread that holds the lock. /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Enter() => Monitor.Enter(this); /// /// Tries to enter the lock without waiting. If the lock is entered, the calling thread would be the only thread that /// holds the lock. /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool TryEnter() => Monitor.TryEnter(this); /// /// Tries to enter the lock, waiting for roughly the specified duration. If the lock is entered, the calling thread /// would be the only thread that holds the lock. /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool TryEnter(TimeSpan timeout) => Monitor.TryEnter(this, timeout); /// /// Tries to enter the lock, waiting for roughly the specified duration. If the lock is entered, the calling thread /// would be the only thread that holds the lock. /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool TryEnter(int millisecondsTimeout) => TryEnter(TimeSpan.FromMilliseconds(millisecondsTimeout)); /// /// Exits the lock. /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Exit() => Monitor.Exit(this); /// diff --git a/src/Polyfill/Numbers/BytePolyfill.cs b/src/Polyfill/Numbers/BytePolyfill.cs index 4e5f4cb85..38418da21 100644 --- a/src/Polyfill/Numbers/BytePolyfill.cs +++ b/src/Polyfill/Numbers/BytePolyfill.cs @@ -6,7 +6,6 @@ namespace Polyfills; using System; using System.Globalization; -using System.Runtime.CompilerServices; // ReSharper disable once RedundantUsingDirective using System.Text; @@ -20,7 +19,6 @@ static partial class Polyfill /// Tries to parse a string into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.byte.tryparse?view=net-11.0#system-byte-tryparse(system-string-system-iformatprovider-system-byte@) - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out byte result) => byte.TryParse(s, NumberStyles.Integer, provider, out result); @@ -34,7 +32,6 @@ public static bool TryParse(string? s, IFormatProvider? provider, out byte resul /// Tries to parse a span of characters into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.byte.tryparse?view=net-11.0#system-byte-tryparse(system-readonlyspan((system-char))-system-iformatprovider-system-byte@) - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out byte result) => byte.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); @@ -46,7 +43,6 @@ public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out /// Tries to parse a span of UTF-8 characters into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.byte.tryparse?view=net-11.0#system-byte-tryparse(system-readonlyspan((system-byte))-system-iformatprovider-system-byte@) - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out byte result) => byte.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); @@ -54,7 +50,6 @@ public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provid /// Tries to parse a span of UTF-8 characters into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.byte.tryparse?view=net-11.0#system-byte-tryparse(system-readonlyspan((system-byte))-system-globalization-numberstyles-system-iformatprovider-system-byte@) - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out byte result) => byte.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); @@ -62,7 +57,6 @@ public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFo /// Tries to convert a UTF-8 character span containing the string representation of a number to its byte equivalent. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.byte.tryparse?view=net-11.0#system-byte-tryparse(system-readonlyspan((system-char))-system-globalization-numberstyles-system-iformatprovider-system-byte@) - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out byte result) => byte.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); @@ -74,7 +68,6 @@ public static bool TryParse(ReadOnlySpan utf8Text, out byte result) => /// Converts the span representation of a number in a specified style and culture-specific format to its byte equivalent. A return value indicates whether the conversion succeeded. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.byte.tryparse?view=net-11.0#system-byte-tryparse(system-readonlyspan((system-char))-system-byte@) - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out byte result) => byte.TryParse(s.ToString(), out result); @@ -82,7 +75,6 @@ public static bool TryParse(ReadOnlySpan s, out byte result) => /// Converts the span representation of a number in a specified style and culture-specific format to its byte equivalent. A return value indicates whether the conversion succeeded. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.byte.tryparse?view=net-11.0#system-byte-tryparse(system-readonlyspan((system-char))-system-globalization-numberstyles-system-iformatprovider-system-byte@) - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out byte result) => byte.TryParse(s.ToString(), style, provider, out result); diff --git a/src/Polyfill/Numbers/DoublePolyfill.cs b/src/Polyfill/Numbers/DoublePolyfill.cs index c3fe1340d..592d359c4 100644 --- a/src/Polyfill/Numbers/DoublePolyfill.cs +++ b/src/Polyfill/Numbers/DoublePolyfill.cs @@ -4,7 +4,6 @@ namespace Polyfills; using System; using System.Globalization; -using System.Runtime.CompilerServices; // ReSharper disable once RedundantUsingDirective using System.Text; @@ -18,7 +17,6 @@ static partial class Polyfill /// Tries to parse a string into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.double.tryparse?view=net-11.0#system-double-tryparse(system-string-system-iformatprovider-system-double@) - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out double result) => double.TryParse(s, NumberStyles.Float, provider, out result); @@ -31,7 +29,6 @@ public static bool TryParse(string? s, IFormatProvider? provider, out double res /// Tries to parse a span of UTF-8 characters into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.double.tryparse?view=net-11.0#system-double-tryparse(system-readonlyspan((system-byte))-system-iformatprovider-system-double@) - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out double result) => double.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Float, provider, out result); @@ -39,7 +36,6 @@ public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provid /// Tries to parse a span of UTF-8 characters into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.double.tryparse?view=net-11.0#system-double-tryparse(system-readonlyspan((system-byte))-system-globalization-numberstyles-system-iformatprovider-system-double@) - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out double result) => double.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); @@ -47,7 +43,6 @@ public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFo /// Tries to convert a UTF-8 character span containing the string representation of a number to its double-precision floating-point number equivalent.. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.double.tryparse?view=net-11.0#system-double-tryparse(system-readonlyspan((system-byte))-system-double@) - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out double result) => double.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Float, null, out result); @@ -59,7 +54,6 @@ public static bool TryParse(ReadOnlySpan utf8Text, out double result) => /// Converts the span representation of a number in a specified style and culture-specific format to its double-precision floating-point number equivalent. A return value indicates whether the conversion succeeded or failed. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.double.tryparse?view=net-11.0#system-double-tryparse(system-readonlyspan((system-char))-system-double@) - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out double result) => double.TryParse(s.ToString(), out result); @@ -67,7 +61,6 @@ public static bool TryParse(ReadOnlySpan s, out double result) => /// Converts the string representation of a number in a specified style and culture-specific format to its double-precision floating-point number equivalent. A return value indicates whether the conversion succeeded or failed. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.double.tryparse?view=net-11.0#system-double-tryparse(system-readonlyspan((system-char))-system-globalization-numberstyles-system-iformatprovider-system-double@) - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out double result) => double.TryParse(s.ToString(), style, provider, out result); @@ -79,7 +72,6 @@ public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatPro /// Tries to parse a span of characters into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.double.tryparse?view=net-11.0#system-double-tryparse(system-readonlyspan((system-char))-system-iformatprovider-system-double@) - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out double result) => double.TryParse(s.ToString(), NumberStyles.Float, provider, out result); diff --git a/src/Polyfill/Numbers/Int16Polyfill.cs b/src/Polyfill/Numbers/Int16Polyfill.cs index 4e62137bf..d8b641c7a 100644 --- a/src/Polyfill/Numbers/Int16Polyfill.cs +++ b/src/Polyfill/Numbers/Int16Polyfill.cs @@ -4,7 +4,6 @@ namespace Polyfills; using System; using System.Globalization; -using System.Runtime.CompilerServices; // ReSharper disable once RedundantUsingDirective using System.Text; @@ -18,7 +17,6 @@ static partial class Polyfill /// Tries to parse a string into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.int16.tryparse?view=net-11.0#system-int16-tryparse(system-string-system-iformatprovider-system-int16@) - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out short result) => short.TryParse(s, NumberStyles.Integer, provider, out result); @@ -31,7 +29,6 @@ public static bool TryParse(string? s, IFormatProvider? provider, out short resu /// Tries to parse a span of UTF-8 characters into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.int16.tryparse?view=net-11.0#system-int16-tryparse(system-readonlyspan((system-byte))-system-iformatprovider-system-int16@) - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out short result) => short.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); @@ -39,7 +36,6 @@ public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provid /// Tries to parse a span of UTF-8 characters into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.int16.tryparse?view=net-11.0#system-int16-tryparse(system-readonlyspan((system-byte))-system-globalization-numberstyles-system-iformatprovider-system-int16@) - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out short result) => short.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); @@ -47,7 +43,6 @@ public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFo /// Tries to convert a UTF-8 character span containing the string representation of a number to its short equivalent. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.int16.tryparse?view=net-11.0#system-int16-tryparse(system-readonlyspan((system-char))-system-globalization-numberstyles-system-iformatprovider-system-int16@) - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out short result) => short.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); @@ -59,7 +54,6 @@ public static bool TryParse(ReadOnlySpan utf8Text, out short result) => /// Converts the span representation of a number in a specified style and culture-specific format to its short equivalent. A return value indicates whether the conversion succeeded. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.int16.tryparse?view=net-11.0#system-int16-tryparse(system-readonlyspan((system-char))-system-int16@) - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out short result) => short.TryParse(s.ToString(), out result); @@ -67,7 +61,6 @@ public static bool TryParse(ReadOnlySpan s, out short result) => /// Converts the span representation of a number in a specified style and culture-specific format to its short equivalent. A return value indicates whether the conversion succeeded. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.int16.tryparse?view=net-11.0#system-int16-tryparse(system-readonlyspan((system-char))-system-globalization-numberstyles-system-iformatprovider-system-int16@) - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out short result) => short.TryParse(s.ToString(), style, provider, out result); @@ -79,7 +72,6 @@ public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatPro /// Tries to parse a span of characters into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.int16.tryparse?view=net-11.0#system-int16-tryparse(system-readonlyspan((system-char))-system-iformatprovider-system-int16@) - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out short result) => short.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); diff --git a/src/Polyfill/Numbers/Int32Polyfill.cs b/src/Polyfill/Numbers/Int32Polyfill.cs index 6f363aaf9..b35e2c548 100644 --- a/src/Polyfill/Numbers/Int32Polyfill.cs +++ b/src/Polyfill/Numbers/Int32Polyfill.cs @@ -4,7 +4,6 @@ namespace Polyfills; using System; using System.Globalization; -using System.Runtime.CompilerServices; // ReSharper disable once RedundantUsingDirective using System.Text; @@ -18,7 +17,6 @@ static partial class Polyfill /// Tries to parse a string into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.int32.tryparse?view=net-11.0#system-int32-tryparse(system-string-system-iformatprovider-system-int32@) - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out int result) => int.TryParse(s, NumberStyles.Integer, provider, out result); @@ -32,7 +30,6 @@ public static bool TryParse(string? s, IFormatProvider? provider, out int result /// Tries to parse a span of UTF-8 characters into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.int32.tryparse?view=net-11.0#system-int32-tryparse(system-readonlyspan((system-byte))-system-iformatprovider-system-int32@) - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out int result) => int.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); @@ -40,7 +37,6 @@ public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provid /// Tries to parse a span of UTF-8 characters into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.int32.tryparse?view=net-11.0#system-int32-tryparse(system-readonlyspan((system-byte))-system-globalization-numberstyles-system-iformatprovider-system-int32@) - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out int result) => int.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); @@ -48,7 +44,6 @@ public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFo /// Tries to convert a UTF-8 character span containing the string representation of a number to its 32-bit signed integer equivalent. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.int32.tryparse?view=net-11.0#system-int32-tryparse(system-readonlyspan((system-char))-system-globalization-numberstyles-system-iformatprovider-system-int32@) - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out int result) => int.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); @@ -60,7 +55,6 @@ public static bool TryParse(ReadOnlySpan utf8Text, out int result) => /// Converts the span representation of a number in a specified style and culture-specific format to its 32-bit signed integer equivalent. A return value indicates whether the conversion succeeded. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.int32.tryparse?view=net-11.0#system-int32-tryparse(system-readonlyspan((system-char))-system-int32@) - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out int result) => int.TryParse(s.ToString(), out result); @@ -68,7 +62,6 @@ public static bool TryParse(ReadOnlySpan s, out int result) => /// Converts the span representation of a number in a specified style and culture-specific format to its 32-bit signed integer equivalent. A return value indicates whether the conversion succeeded. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.int32.tryparse?view=net-11.0#system-int32-tryparse(system-readonlyspan((system-char))-system-globalization-numberstyles-system-iformatprovider-system-int32@) - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out int result) => int.TryParse(s.ToString(), style, provider, out result); @@ -80,7 +73,6 @@ public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatPro /// Tries to parse a span of characters into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.int32.tryparse?view=net-11.0#system-int32-tryparse(system-readonlyspan((system-char))-system-iformatprovider-system-int32@) - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out int result) => int.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); diff --git a/src/Polyfill/Numbers/Int64Polyfill.cs b/src/Polyfill/Numbers/Int64Polyfill.cs index 07507e1a4..2402d0e23 100644 --- a/src/Polyfill/Numbers/Int64Polyfill.cs +++ b/src/Polyfill/Numbers/Int64Polyfill.cs @@ -4,7 +4,6 @@ namespace Polyfills; using System; using System.Globalization; -using System.Runtime.CompilerServices; // ReSharper disable once RedundantUsingDirective using System.Text; @@ -18,7 +17,6 @@ static partial class Polyfill /// Tries to parse a string into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.int64.tryparse?view=net-11.0#system-int64-tryparse(system-string-system-iformatprovider-system-int64@) - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out long result) => long.TryParse(s, NumberStyles.Integer, provider, out result); @@ -32,7 +30,6 @@ public static bool TryParse(string? s, IFormatProvider? provider, out long resul /// Tries to parse a span of UTF-8 characters into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.int64.tryparse?view=net-11.0#system-int64-tryparse(system-readonlyspan((system-byte))-system-iformatprovider-system-int64@) - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out long result) => long.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); @@ -40,7 +37,6 @@ public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provid /// Tries to parse a span of UTF-8 characters into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.int64.tryparse?view=net-11.0#system-int64-tryparse(system-readonlyspan((system-byte))-system-globalization-numberstyles-system-iformatprovider-system-int64@) - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out long result) => long.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); @@ -48,7 +44,6 @@ public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFo /// Tries to convert a UTF-8 character span containing the string representation of a number to its 64-bit signed integer equivalent. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.int64.tryparse?view=net-11.0#system-int64-tryparse(system-readonlyspan((system-char))-system-globalization-numberstyles-system-iformatprovider-system-int64@) - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out long result) => long.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); @@ -60,7 +55,6 @@ public static bool TryParse(ReadOnlySpan utf8Text, out long result) => /// Converts the span representation of a number in a specified style and culture-specific format to its 32-bit signed integer equivalent. A return value indicates whether the conversion succeeded. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.int64.tryparse?view=net-11.0#system-int64-tryparse(system-readonlyspan((system-char))-system-int64@) - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out long result) => long.TryParse(s.ToString(), out result); @@ -68,7 +62,6 @@ public static bool TryParse(ReadOnlySpan s, out long result) => /// Converts the span representation of a number in a specified style and culture-specific format to its 64-bit signed integer equivalent. A return value indicates whether the conversion succeeded. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.int64.tryparse?view=net-11.0#system-int64-tryparse(system-readonlyspan((system-char))-system-globalization-numberstyles-system-iformatprovider-system-int64@) - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out long result) => long.TryParse(s.ToString(), style, provider, out result); @@ -80,7 +73,6 @@ public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatPro /// Tries to parse a span of characters into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.int64.tryparse?view=net-11.0#system-int64-tryparse(system-readonlyspan((system-char))-system-iformatprovider-system-int64@) - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out long result) => long.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); diff --git a/src/Polyfill/Numbers/SBytePolyfill.cs b/src/Polyfill/Numbers/SBytePolyfill.cs index 8f91b75e2..9ba772561 100644 --- a/src/Polyfill/Numbers/SBytePolyfill.cs +++ b/src/Polyfill/Numbers/SBytePolyfill.cs @@ -4,7 +4,6 @@ namespace Polyfills; using System; using System.Globalization; -using System.Runtime.CompilerServices; // ReSharper disable once RedundantUsingDirective using System.Text; @@ -18,7 +17,6 @@ static partial class Polyfill /// Tries to parse a string into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.sbyte.tryparse?view=net-11.0#system-sbyte-tryparse(system-string-system-iformatprovider-system-sbyte@) - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out sbyte result) => sbyte.TryParse(s, NumberStyles.Integer, provider, out result); @@ -32,7 +30,6 @@ public static bool TryParse(string? s, IFormatProvider? provider, out sbyte resu /// Tries to parse a span of UTF-8 characters into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.sbyte.tryparse?view=net-11.0#system-sbyte-tryparse(system-readonlyspan((system-byte))-system-iformatprovider-system-sbyte@) - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out sbyte result) => sbyte.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); @@ -40,7 +37,6 @@ public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provid /// Tries to parse a span of UTF-8 characters into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.sbyte.tryparse?view=net-11.0#system-sbyte-tryparse(system-readonlyspan((system-byte))-system-globalization-numberstyles-system-iformatprovider-system-sbyte@) - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out sbyte result) => sbyte.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); @@ -48,7 +44,6 @@ public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFo /// Tries to convert a UTF-8 character span containing the string representation of a number to its sbyte equivalent. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.sbyte.tryparse?view=net-11.0#system-sbyte-tryparse(system-readonlyspan((system-char))-system-globalization-numberstyles-system-iformatprovider-system-sbyte@) - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out sbyte result) => sbyte.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); @@ -60,7 +55,6 @@ public static bool TryParse(ReadOnlySpan utf8Text, out sbyte result) => /// Converts the span representation of a number in a specified style and culture-specific format to its sbyte equivalent. A return value indicates whether the conversion succeeded. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.sbyte.tryparse?view=net-11.0#system-sbyte-tryparse(system-readonlyspan((system-char))-system-sbyte@) - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out sbyte result) => sbyte.TryParse(s.ToString(), out result); @@ -68,7 +62,6 @@ public static bool TryParse(ReadOnlySpan s, out sbyte result) => /// Converts the span representation of a number in a specified style and culture-specific format to its sbyte equivalent. A return value indicates whether the conversion succeeded. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.sbyte.tryparse?view=net-11.0#system-sbyte-tryparse(system-readonlyspan((system-char))-system-globalization-numberstyles-system-iformatprovider-system-sbyte@) - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out sbyte result) => sbyte.TryParse(s.ToString(), style, provider, out result); @@ -80,7 +73,6 @@ public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatPro /// Tries to parse a span of characters into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.sbyte.tryparse?view=net-11.0#system-sbyte-tryparse(system-readonlyspan((system-char))-system-iformatprovider-system-sbyte@) - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out sbyte result) => sbyte.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); diff --git a/src/Polyfill/Numbers/UInt16Polyfill.cs b/src/Polyfill/Numbers/UInt16Polyfill.cs index c3f661c5a..e792053bf 100644 --- a/src/Polyfill/Numbers/UInt16Polyfill.cs +++ b/src/Polyfill/Numbers/UInt16Polyfill.cs @@ -4,7 +4,6 @@ namespace Polyfills; using System; using System.Globalization; -using System.Runtime.CompilerServices; // ReSharper disable once RedundantUsingDirective using System.Text; @@ -18,7 +17,6 @@ static partial class Polyfill /// Tries to parse a string into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.uint16.tryparse?view=net-11.0#system-uint16-tryparse(system-string-system-iformatprovider-system-uint16@) - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out ushort result) => ushort.TryParse(s, NumberStyles.Integer, provider, out result); @@ -32,7 +30,6 @@ public static bool TryParse(string? s, IFormatProvider? provider, out ushort res /// Tries to parse a span of UTF-8 characters into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.uint16.tryparse?view=net-11.0#system-uint16-tryparse(system-readonlyspan((system-byte))-system-iformatprovider-system-uint16@) - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out ushort result) => ushort.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); @@ -40,7 +37,6 @@ public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provid /// Tries to parse a span of UTF-8 characters into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.uint16.tryparse?view=net-11.0#system-uint16-tryparse(system-readonlyspan((system-byte))-system-globalization-numberstyles-system-iformatprovider-system-uint16@) - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out ushort result) => ushort.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); @@ -48,7 +44,6 @@ public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFo /// Tries to convert a UTF-8 character span containing the string representation of a number to its ushort equivalent. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.uint16.tryparse?view=net-11.0#system-uint16-tryparse(system-readonlyspan((system-char))-system-globalization-numberstyles-system-iformatprovider-system-uint16@) - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out ushort result) => ushort.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); #endif @@ -59,7 +54,6 @@ public static bool TryParse(ReadOnlySpan utf8Text, out ushort result) => /// Converts the span representation of a number in a specified style and culture-specific format to its ushort equivalent. A return value indicates whether the conversion succeeded. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.uint16.tryparse?view=net-11.0#system-uint16-tryparse(system-readonlyspan((system-char))-system-uint16@) - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out ushort result) => ushort.TryParse(s.ToString(), out result); @@ -67,7 +61,6 @@ public static bool TryParse(ReadOnlySpan s, out ushort result) => /// Converts the span representation of a number in a specified style and culture-specific format to its ushort equivalent. A return value indicates whether the conversion succeeded. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.uint16.tryparse?view=net-11.0#system-uint16-tryparse(system-readonlyspan((system-char))-system-globalization-numberstyles-system-iformatprovider-system-uint16@) - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out ushort result) => ushort.TryParse(s.ToString(), style, provider, out result); @@ -79,7 +72,6 @@ public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatPro /// Tries to parse a span of characters into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.uint16.tryparse?view=net-11.0#system-uint16-tryparse(system-readonlyspan((system-char))-system-iformatprovider-system-uint16@) - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out ushort result) => ushort.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); diff --git a/src/Polyfill/Numbers/UInt32Polyfill.cs b/src/Polyfill/Numbers/UInt32Polyfill.cs index 3dcfbe833..4fcc745cd 100644 --- a/src/Polyfill/Numbers/UInt32Polyfill.cs +++ b/src/Polyfill/Numbers/UInt32Polyfill.cs @@ -4,7 +4,6 @@ namespace Polyfills; using System; using System.Globalization; -using System.Runtime.CompilerServices; // ReSharper disable once RedundantUsingDirective using System.Text; @@ -18,7 +17,6 @@ static partial class Polyfill /// Tries to parse a string into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.uint32.tryparse?view=net-11.0#system-uint32-tryparse(system-string-system-iformatprovider-system-uint32@) - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out uint result) => uint.TryParse(s, NumberStyles.Integer, provider, out result); @@ -32,7 +30,6 @@ public static bool TryParse(string? s, IFormatProvider? provider, out uint resul /// Tries to parse a span of UTF-8 characters into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.uint32.tryparse?view=net-11.0#system-uint32-tryparse(system-readonlyspan((system-byte))-system-iformatprovider-system-uint32@) - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out uint result) => uint.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); @@ -40,7 +37,6 @@ public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provid /// Tries to parse a span of UTF-8 characters into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.uint32.tryparse?view=net-11.0#system-uint32-tryparse(system-readonlyspan((system-byte))-system-globalization-numberstyles-system-iformatprovider-system-uint32@) - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFormatProvider? provider, out uint result) => uint.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); @@ -48,7 +44,6 @@ public static bool TryParse(ReadOnlySpan utf8Text, NumberStyles style, IFo /// Tries to convert a UTF-8 character span containing the string representation of a number to its uint equivalent. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.uint32.tryparse?view=net-11.0#system-uint32-tryparse(system-readonlyspan((system-char))-system-globalization-numberstyles-system-iformatprovider-system-uint32@) - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out uint result) => uint.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); @@ -60,7 +55,6 @@ public static bool TryParse(ReadOnlySpan utf8Text, out uint result) => /// Converts the span representation of a number in a specified style and culture-specific format to its uint equivalent. A return value indicates whether the conversion succeeded. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.uint32.tryparse?view=net-11.0#system-uint32-tryparse(system-readonlyspan((system-char))-system-uint32@) - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out uint result) => uint.TryParse(s.ToString(), out result); @@ -68,7 +62,6 @@ public static bool TryParse(ReadOnlySpan s, out uint result) => /// Converts the span representation of a number in a specified style and culture-specific format to its uint equivalent. A return value indicates whether the conversion succeeded. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.uint32.tryparse?view=net-11.0#system-uint32-tryparse(system-readonlyspan((system-char))-system-globalization-numberstyles-system-iformatprovider-system-uint32@) - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out uint result) => uint.TryParse(s.ToString(), style, provider, out result); @@ -80,7 +73,6 @@ public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatPro /// Tries to parse a span of characters into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.uint32.tryparse?view=net-11.0#system-uint32-tryparse(system-readonlyspan((system-char))-system-iformatprovider-system-uint32@) - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out uint result) => uint.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); diff --git a/src/Polyfill/Numbers/UInt64Polyfill.cs b/src/Polyfill/Numbers/UInt64Polyfill.cs index b6006cc72..ced8b84f3 100644 --- a/src/Polyfill/Numbers/UInt64Polyfill.cs +++ b/src/Polyfill/Numbers/UInt64Polyfill.cs @@ -4,7 +4,6 @@ namespace Polyfills; using System; using System.Globalization; -using System.Runtime.CompilerServices; // ReSharper disable once RedundantUsingDirective using System.Text; @@ -18,7 +17,6 @@ static partial class Polyfill /// Tries to parse a string into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.uint64.tryparse?view=net-11.0#system-uint64-tryparse(system-string-system-iformatprovider-system-uint64@) - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(string? s, IFormatProvider? provider, out ulong result) => ulong.TryParse(s, NumberStyles.Integer, provider, out result); @@ -32,7 +30,6 @@ public static bool TryParse(string? s, IFormatProvider? provider, out ulong resu /// Tries to parse a span of UTF-8 characters into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.uint64.tryparse?view=net-11.0#system-uint64-tryparse(system-readonlyspan((system-byte))-system-iformatprovider-system-uint64@) - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, out ulong result) => ulong.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, provider, out result); @@ -40,7 +37,6 @@ public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provid /// Tries to parse a span of UTF-8 characters into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.uint64.tryparse?view=net-11.0#system-uint64-tryparse(system-readonlyspan((system-byte))-system-globalization-numberstyles-system-iformatprovider-system-uint64@) - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpanutf8Text, NumberStyles style, IFormatProvider? provider, out ulong result) => ulong.TryParse(Encoding.UTF8.GetString(utf8Text), style, provider, out result); @@ -48,7 +44,6 @@ public static bool TryParse(ReadOnlySpanutf8Text, NumberStyles style, IFor /// Tries to convert a UTF-8 character span containing the string representation of a number to its ulong equivalent. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.uint64.tryparse?view=net-11.0#system-uint64-tryparse(system-readonlyspan((system-char))-system-globalization-numberstyles-system-iformatprovider-system-uint64@) - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan utf8Text, out ulong result) => ulong.TryParse(Encoding.UTF8.GetString(utf8Text), NumberStyles.Integer, null, out result); @@ -60,7 +55,6 @@ public static bool TryParse(ReadOnlySpan utf8Text, out ulong result) => /// Converts the span representation of a number in a specified style and culture-specific format to its ulong equivalent. A return value indicates whether the conversion succeeded. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.uint64.tryparse?view=net-11.0#system-uint64-tryparse(system-readonlyspan((system-char))-system-uint64@) - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, out ulong result) => ulong.TryParse(s.ToString(), out result); @@ -68,7 +62,6 @@ public static bool TryParse(ReadOnlySpan s, out ulong result) => /// Converts the span representation of a number in a specified style and culture-specific format to its ulong equivalent. A return value indicates whether the conversion succeeded. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.uint64.tryparse?view=net-11.0#system-uint64-tryparse(system-readonlyspan((system-char))-system-globalization-numberstyles-system-iformatprovider-system-uint64@) - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out ulong result) => ulong.TryParse(s.ToString(), style, provider, out result); @@ -80,7 +73,6 @@ public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatPro /// Tries to parse a span of characters into a value. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.uint64.tryparse?view=net-11.0#system-uint64-tryparse(system-readonlyspan((system-char))-system-iformatprovider-system-uint64@) - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, out ulong result) => ulong.TryParse(s.ToString(), NumberStyles.Integer, provider, out result); diff --git a/src/Polyfill/OperatingSystemPolyfill.cs b/src/Polyfill/OperatingSystemPolyfill.cs index b0f949067..71a34dbf3 100644 --- a/src/Polyfill/OperatingSystemPolyfill.cs +++ b/src/Polyfill/OperatingSystemPolyfill.cs @@ -20,7 +20,6 @@ static bool IsOsVersionAtLeast(int major, int minor = 0, int build = 0, int revi /// Indicates whether the current application is running as WASI. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.operatingsystem.iswasi?view=net-11.0 - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsWasi() => RuntimeInformation.IsOSPlatform(OSPlatform.Create("WASI")); @@ -32,7 +31,6 @@ public static bool IsWasi() => /// Indicates whether the current application is running on Mac Catalyst. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.operatingsystem.ismaccatalyst?view=net-11.0 - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsMacCatalyst() => OperatingSystem.IsMacOS() || OperatingSystem.IsIOS(); @@ -41,7 +39,6 @@ public static bool IsMacCatalyst() => /// Check for the Mac Catalyst version (iOS version as presented in Apple documentation) with a ≤ version comparison. Used to guard APIs that were added in the given Mac Catalyst release. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.operatingsystem.ismaccatalystversionatleast?view=net-11.0 - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsMacCatalystVersionAtLeast(int major, int minor = 0, int build = 0) => IsMacCatalyst() && IsOsVersionAtLeast(major, minor, build); @@ -54,7 +51,6 @@ public static bool IsMacCatalystVersionAtLeast(int major, int minor = 0, int bui /// Checks if the macOS version (returned by libobjc.get_operatingSystemVersion) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified macOS version. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.operatingsystem.ismacosversionatleast?view=net-11.0 - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsMacOSVersionAtLeast(int major, int minor = 0, int build = 0) => OperatingSystemCache.IsMacOSVersionAtLeast(major, minor, build); @@ -63,7 +59,6 @@ public static bool IsMacOSVersionAtLeast(int major, int minor = 0, int build = 0 /// This method can be used to guard APIs that were added in the specified version. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.operatingsystem.isfreebsdversionatleast?view=net-11.0 - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsFreeBSDVersionAtLeast(int major, int minor, int build = 0, int revision = 0) => OperatingSystemCache.IsFreeBSDVersionAtLeast(major, minor, build, revision); @@ -71,7 +66,6 @@ public static bool IsFreeBSDVersionAtLeast(int major, int minor, int build = 0, /// Indicates whether the current application is running on Android. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.operatingsystem.isandroid?view=net-11.0 - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsAndroid() => OperatingSystemCache.IsAndroid(); @@ -79,7 +73,6 @@ public static bool IsAndroid() => /// Checks if the Android version (returned by the Linux command uname) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified version. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.operatingsystem.isandroidversionatleast?view=net-11.0 - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsAndroidVersionAtLeast(int major, int minor = 0, int build = 0, int revision = 0) => OperatingSystemCache.IsAndroidVersionAtLeast(major, minor, build, revision); @@ -87,7 +80,6 @@ public static bool IsAndroidVersionAtLeast(int major, int minor = 0, int build = /// Checks if the Windows version (returned by RtlGetVersion) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified Windows version. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.operatingsystem.iswindowsversionatleast?view=net-11.0 - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsWindowsVersionAtLeast(int major, int minor = 0, int build = 0, int revision = 0) => OperatingSystemCache.IsWindowsVersionAtLeast(major, minor, build, revision); @@ -103,7 +95,6 @@ public static bool IsOSPlatform(string platform) => /// Checks if the operating system version is greater than or equal to the specified platform version. This method can be used to guard APIs that were added in the specified OS version. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.operatingsystem.isosplatformversionatleast?view=net-11.0 - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsOSPlatformVersionAtLeast(string platform, int major, int minor = 0, int build = 0, int revision = 0) => IsOSPlatform(platform) && IsOsVersionAtLeast(major, minor, build, revision); @@ -112,7 +103,6 @@ public static bool IsOSPlatformVersionAtLeast(string platform, int major, int mi /// Indicates whether the current application is running on Windows. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.operatingsystem.iswindows?view=net-11.0 - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsWindows() => RuntimeInformation.IsOSPlatform(OSPlatform.Windows); @@ -120,7 +110,6 @@ public static bool IsWindows() => /// Indicates whether the current application is running on macOS. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.operatingsystem.ismacos?view=net-11.0 - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsMacOS() => RuntimeInformation.IsOSPlatform(OSPlatform.OSX); @@ -128,7 +117,6 @@ public static bool IsMacOS() => /// Indicates whether the current application is running on iOS or MacCatalyst. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.operatingsystem.isios?view=net-11.0 - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsIOS() => RuntimeInformation.IsOSPlatform(OSPlatform.Create("IOS")); @@ -136,7 +124,6 @@ public static bool IsIOS() => /// Indicates whether the current application is running on Linux. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.operatingsystem.islinux?view=net-11.0 - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsLinux() => RuntimeInformation.IsOSPlatform(OSPlatform.Linux); @@ -144,7 +131,6 @@ public static bool IsLinux() => /// Indicates whether the current application is running on FreeBSD. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.operatingsystem.isfreebsd?view=net-11.0 - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsFreeBSD() => RuntimeInformation.OSDescription.ToLower().Contains("freebsd"); @@ -152,7 +138,6 @@ public static bool IsFreeBSD() => /// Checks if the iOS/MacCatalyst version (returned by libobjc.get_operatingSystemVersion) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified iOS version. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.operatingsystem.isiosversionatleast?view=net-11.0 - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsIOSVersionAtLeast(int major, int minor = 0, int build = 0) => IsIOS() && IsOsVersionAtLeast(major, minor, build); @@ -161,7 +146,6 @@ public static bool IsIOSVersionAtLeast(int major, int minor = 0, int build = 0) /// Checks if the tvOS version (returned by libobjc.get_operatingSystemVersion) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified tvOS version. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.operatingsystem.istvosversionatleast?view=net-11.0 - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsTvOSVersionAtLeast(int major, int minor = 0, int build = 0) => IsTvOS() && IsOsVersionAtLeast(major, minor, build); @@ -170,7 +154,6 @@ public static bool IsTvOSVersionAtLeast(int major, int minor = 0, int build = 0) /// Indicates whether the current application is running on tvOS. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.operatingsystem.istvos?view=net-11.0 - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsTvOS() => RuntimeInformation.IsOSPlatform(OSPlatform.Create("TVOS")); @@ -178,7 +161,6 @@ public static bool IsTvOS() => /// Indicates whether the current application is running on watchOS. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.operatingsystem.iswatchos?view=net-11.0 - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsWatchOS() => IsIOS() || RuntimeInformation.OSDescription.ToLower().Contains("watchos"); @@ -187,7 +169,6 @@ public static bool IsWatchOS() => /// Checks if the watchOS version (returned by libobjc.get_operatingSystemVersion) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified watchOS version. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.operatingsystem.iswatchosversionatleast?view=net-11.0 - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsWatchOSVersionAtLeast(int major, int minor = 0, int build = 0) => IsWatchOS() && IsOsVersionAtLeast(major, minor, build); @@ -196,7 +177,6 @@ public static bool IsWatchOSVersionAtLeast(int major, int minor = 0, int build = /// Indicates whether the current application is running as WASM in a browser. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.operatingsystem.isbrowser?view=net-11.0 - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsBrowser() => RuntimeInformation.IsOSPlatform(OSPlatform.Create("BROWSER")); diff --git a/src/Polyfill/PathPolyfill.cs b/src/Polyfill/PathPolyfill.cs index a5e8202a5..f54a21764 100644 --- a/src/Polyfill/PathPolyfill.cs +++ b/src/Polyfill/PathPolyfill.cs @@ -4,7 +4,6 @@ namespace Polyfills; using System; using System.IO; -using System.Runtime.CompilerServices; static partial class Polyfill { @@ -16,7 +15,6 @@ static partial class Polyfill /// Returns the directory information for the specified path represented by a character span. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.io.path.getdirectoryname?view=net-11.0#system-io-path-getdirectoryname(system-readonlyspan((system-char))) - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ReadOnlySpan GetDirectoryName(ReadOnlySpan path) => Path.GetDirectoryName(path.ToString()).AsSpan(); @@ -24,7 +22,6 @@ public static ReadOnlySpan GetDirectoryName(ReadOnlySpan path) => /// Returns the file name and extension of a file path that is represented by a read-only character span. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.io.path.getfilename?view=net-11.0#system-io-path-getfilename(system-readonlyspan((system-char))) - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ReadOnlySpan GetFileName(ReadOnlySpan path) => Path.GetFileName(path.ToString()).AsSpan(); @@ -32,7 +29,6 @@ public static ReadOnlySpan GetFileName(ReadOnlySpan path) => /// Returns the file name without the extension of a file path that is represented by a read-only character span. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.io.path.getfilenamewithoutextension?view=net-11.0#system-io-path-getfilenamewithoutextension(system-readonlyspan((system-char))) - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ReadOnlySpan GetFileNameWithoutExtension(ReadOnlySpan path) => Path.GetFileNameWithoutExtension(path.ToString()).AsSpan(); @@ -40,7 +36,6 @@ public static ReadOnlySpan GetFileNameWithoutExtension(ReadOnlySpan /// Determines whether the path represented by the specified character span includes a file name extension. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.io.path.getfilenamewithoutextension?view=net-11.0#system-io-path-getfilenamewithoutextension(system-readonlyspan((system-char))) - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool HasExtension(ReadOnlySpan path) => Path.HasExtension(path.ToString()); @@ -48,7 +43,6 @@ public static bool HasExtension(ReadOnlySpan path) => /// Returns the extension of the given path. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.io.path.getextension?view=net-11.0#system-io-path-getextension(system-readonlyspan((system-char))) - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ReadOnlySpan GetExtension(ReadOnlySpan path) => Path.GetExtension(path.ToString()).AsSpan(); #endif @@ -58,7 +52,6 @@ public static ReadOnlySpan GetExtension(ReadOnlySpan path) => /// Combines a span of strings into a path. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.io.path.combine?view=net-11.0#system-io-path-combine(system-readonlyspan((system-string))) - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string Combine(scoped ReadOnlySpan paths) => Path.Combine(paths.ToArray()); #endif @@ -68,7 +61,6 @@ public static string Combine(scoped ReadOnlySpan paths) => /// Returns a value that indicates whether the path, specified as a read-only span, ends in a directory separator. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.io.path.endsindirectoryseparator?view=net-11.0#system-io-path-endsindirectoryseparator(system-readonlyspan((system-char))) - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool EndsInDirectorySeparator (ReadOnlySpan path) => EndsInDirectorySeparator(path.ToString()); @@ -76,7 +68,6 @@ public static bool EndsInDirectorySeparator (ReadOnlySpan path) => /// Trims one trailing directory separator beyond the root of the specified path. /// //Link: https://learn.microsoft.com/en-us/dotnet/api/system.io.path.trimendingdirectoryseparator?view=net-11.0#system-io-path-trimendingdirectoryseparator(system-readonlyspan((system-char))) - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ReadOnlySpan TrimEndingDirectorySeparator(ReadOnlySpan path) => TrimEndingDirectorySeparator(path.ToString()).AsSpan(); #endif