diff --git a/PolyShim/Net70/Byte.cs b/PolyShim/Net70/Byte.cs new file mode 100644 index 0000000..4869f1e --- /dev/null +++ b/PolyShim/Net70/Byte.cs @@ -0,0 +1,20 @@ +#if (NETCOREAPP && !NET7_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) +#nullable enable +// ReSharper disable RedundantUsingDirective +// ReSharper disable CheckNamespace +// ReSharper disable InconsistentNaming +// ReSharper disable PartialTypeWithSinglePart + +using System; +using System.Globalization; + +internal static partial class PolyfillExtensions +{ + extension(byte) + { + // https://learn.microsoft.com/dotnet/api/system.byte.tryparse#system-byte-tryparse(system-string-system-iformatprovider-system-byte@) + public static bool TryParse(string s, IFormatProvider? provider, out byte result) => + byte.TryParse(s, NumberStyles.Integer, provider, out result); + } +} +#endif diff --git a/PolyShim/Net70/Decimal.cs b/PolyShim/Net70/Decimal.cs new file mode 100644 index 0000000..20144ea --- /dev/null +++ b/PolyShim/Net70/Decimal.cs @@ -0,0 +1,20 @@ +#if (NETCOREAPP && !NET7_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) +#nullable enable +// ReSharper disable RedundantUsingDirective +// ReSharper disable CheckNamespace +// ReSharper disable InconsistentNaming +// ReSharper disable PartialTypeWithSinglePart + +using System; +using System.Globalization; + +internal static partial class PolyfillExtensions +{ + extension(decimal) + { + // https://learn.microsoft.com/dotnet/api/system.decimal.tryparse#system-decimal-tryparse(system-string-system-iformatprovider-system-decimal@) + public static bool TryParse(string s, IFormatProvider? provider, out decimal result) => + decimal.TryParse(s, NumberStyles.Number, provider, out result); + } +} +#endif diff --git a/PolyShim/Net70/Double.cs b/PolyShim/Net70/Double.cs new file mode 100644 index 0000000..8cda669 --- /dev/null +++ b/PolyShim/Net70/Double.cs @@ -0,0 +1,25 @@ +#if (NETCOREAPP && !NET7_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) +#nullable enable +// ReSharper disable RedundantUsingDirective +// ReSharper disable CheckNamespace +// ReSharper disable InconsistentNaming +// ReSharper disable PartialTypeWithSinglePart + +using System; +using System.Globalization; + +internal static partial class PolyfillExtensions +{ + extension(double) + { + // https://learn.microsoft.com/dotnet/api/system.double.tryparse#system-double-tryparse(system-string-system-iformatprovider-system-double@) + public static bool TryParse(string s, IFormatProvider? provider, out double result) => + double.TryParse( + s, + NumberStyles.Float | NumberStyles.AllowThousands, + provider, + out result + ); + } +} +#endif diff --git a/PolyShim/Net70/Int16.cs b/PolyShim/Net70/Int16.cs new file mode 100644 index 0000000..b61920d --- /dev/null +++ b/PolyShim/Net70/Int16.cs @@ -0,0 +1,20 @@ +#if (NETCOREAPP && !NET7_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) +#nullable enable +// ReSharper disable RedundantUsingDirective +// ReSharper disable CheckNamespace +// ReSharper disable InconsistentNaming +// ReSharper disable PartialTypeWithSinglePart + +using System; +using System.Globalization; + +internal static partial class PolyfillExtensions +{ + extension(short) + { + // https://learn.microsoft.com/dotnet/api/system.int16.tryparse#system-int16-tryparse(system-string-system-iformatprovider-system-int16@) + public static bool TryParse(string s, IFormatProvider? provider, out short result) => + short.TryParse(s, NumberStyles.Integer, provider, out result); + } +} +#endif diff --git a/PolyShim/Net70/Int32.cs b/PolyShim/Net70/Int32.cs new file mode 100644 index 0000000..49b5811 --- /dev/null +++ b/PolyShim/Net70/Int32.cs @@ -0,0 +1,20 @@ +#if (NETCOREAPP && !NET7_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) +#nullable enable +// ReSharper disable RedundantUsingDirective +// ReSharper disable CheckNamespace +// ReSharper disable InconsistentNaming +// ReSharper disable PartialTypeWithSinglePart + +using System; +using System.Globalization; + +internal static partial class PolyfillExtensions +{ + extension(int) + { + // https://learn.microsoft.com/dotnet/api/system.int32.tryparse#system-int32-tryparse(system-string-system-iformatprovider-system-int32@) + public static bool TryParse(string s, IFormatProvider? provider, out int result) => + int.TryParse(s, NumberStyles.Integer, provider, out result); + } +} +#endif diff --git a/PolyShim/Net70/Int64.cs b/PolyShim/Net70/Int64.cs new file mode 100644 index 0000000..e89c396 --- /dev/null +++ b/PolyShim/Net70/Int64.cs @@ -0,0 +1,20 @@ +#if (NETCOREAPP && !NET7_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) +#nullable enable +// ReSharper disable RedundantUsingDirective +// ReSharper disable CheckNamespace +// ReSharper disable InconsistentNaming +// ReSharper disable PartialTypeWithSinglePart + +using System; +using System.Globalization; + +internal static partial class PolyfillExtensions +{ + extension(long) + { + // https://learn.microsoft.com/dotnet/api/system.int64.tryparse#system-int64-tryparse(system-string-system-iformatprovider-system-int64@) + public static bool TryParse(string s, IFormatProvider? provider, out long result) => + long.TryParse(s, NumberStyles.Integer, provider, out result); + } +} +#endif diff --git a/PolyShim/Net70/IntPtr.cs b/PolyShim/Net70/IntPtr.cs new file mode 100644 index 0000000..fd0280e --- /dev/null +++ b/PolyShim/Net70/IntPtr.cs @@ -0,0 +1,33 @@ +#if (NETCOREAPP && !NET7_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) +#nullable enable +// ReSharper disable RedundantUsingDirective +// ReSharper disable CheckNamespace +// ReSharper disable InconsistentNaming +// ReSharper disable PartialTypeWithSinglePart + +using System; +using System.Globalization; + +internal static partial class PolyfillExtensions +{ + extension(IntPtr) + { + // https://learn.microsoft.com/dotnet/api/system.intptr.tryparse#system-intptr-tryparse(system-string-system-iformatprovider-system-intptr@) + public static bool TryParse(string s, IFormatProvider? provider, out IntPtr result) + { + if (IntPtr.Size == 4) + { + var success = int.TryParse(s, provider, out var intResult); + result = new IntPtr(intResult); + return success; + } + else + { + var success = long.TryParse(s, provider, out var longResult); + result = new IntPtr(longResult); + return success; + } + } + } +} +#endif diff --git a/PolyShim/Net70/SByte.cs b/PolyShim/Net70/SByte.cs new file mode 100644 index 0000000..9b46bc6 --- /dev/null +++ b/PolyShim/Net70/SByte.cs @@ -0,0 +1,20 @@ +#if (NETCOREAPP && !NET7_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) +#nullable enable +// ReSharper disable RedundantUsingDirective +// ReSharper disable CheckNamespace +// ReSharper disable InconsistentNaming +// ReSharper disable PartialTypeWithSinglePart + +using System; +using System.Globalization; + +internal static partial class PolyfillExtensions +{ + extension(sbyte) + { + // https://learn.microsoft.com/dotnet/api/system.sbyte.tryparse#system-sbyte-tryparse(system-string-system-iformatprovider-system-sbyte@) + public static bool TryParse(string s, IFormatProvider? provider, out sbyte result) => + sbyte.TryParse(s, NumberStyles.Integer, provider, out result); + } +} +#endif diff --git a/PolyShim/Net70/Single.cs b/PolyShim/Net70/Single.cs new file mode 100644 index 0000000..70dfc3d --- /dev/null +++ b/PolyShim/Net70/Single.cs @@ -0,0 +1,25 @@ +#if (NETCOREAPP && !NET7_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) +#nullable enable +// ReSharper disable RedundantUsingDirective +// ReSharper disable CheckNamespace +// ReSharper disable InconsistentNaming +// ReSharper disable PartialTypeWithSinglePart + +using System; +using System.Globalization; + +internal static partial class PolyfillExtensions +{ + extension(float) + { + // https://learn.microsoft.com/dotnet/api/system.single.tryparse#system-single-tryparse(system-string-system-iformatprovider-system-single@) + public static bool TryParse(string s, IFormatProvider? provider, out float result) => + float.TryParse( + s, + NumberStyles.Float | NumberStyles.AllowThousands, + provider, + out result + ); + } +} +#endif diff --git a/PolyShim/Net70/UInt16.cs b/PolyShim/Net70/UInt16.cs new file mode 100644 index 0000000..fd553ec --- /dev/null +++ b/PolyShim/Net70/UInt16.cs @@ -0,0 +1,20 @@ +#if (NETCOREAPP && !NET7_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) +#nullable enable +// ReSharper disable RedundantUsingDirective +// ReSharper disable CheckNamespace +// ReSharper disable InconsistentNaming +// ReSharper disable PartialTypeWithSinglePart + +using System; +using System.Globalization; + +internal static partial class PolyfillExtensions +{ + extension(ushort) + { + // https://learn.microsoft.com/dotnet/api/system.uint16.tryparse#system-uint16-tryparse(system-string-system-iformatprovider-system-uint16@) + public static bool TryParse(string s, IFormatProvider? provider, out ushort result) => + ushort.TryParse(s, NumberStyles.Integer, provider, out result); + } +} +#endif diff --git a/PolyShim/Net70/UInt32.cs b/PolyShim/Net70/UInt32.cs new file mode 100644 index 0000000..a423a72 --- /dev/null +++ b/PolyShim/Net70/UInt32.cs @@ -0,0 +1,20 @@ +#if (NETCOREAPP && !NET7_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) +#nullable enable +// ReSharper disable RedundantUsingDirective +// ReSharper disable CheckNamespace +// ReSharper disable InconsistentNaming +// ReSharper disable PartialTypeWithSinglePart + +using System; +using System.Globalization; + +internal static partial class PolyfillExtensions +{ + extension(uint) + { + // https://learn.microsoft.com/dotnet/api/system.uint32.tryparse#system-uint32-tryparse(system-string-system-iformatprovider-system-uint32@) + public static bool TryParse(string s, IFormatProvider? provider, out uint result) => + uint.TryParse(s, NumberStyles.Integer, provider, out result); + } +} +#endif diff --git a/PolyShim/Net70/UInt64.cs b/PolyShim/Net70/UInt64.cs new file mode 100644 index 0000000..c8e26e6 --- /dev/null +++ b/PolyShim/Net70/UInt64.cs @@ -0,0 +1,20 @@ +#if (NETCOREAPP && !NET7_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) +#nullable enable +// ReSharper disable RedundantUsingDirective +// ReSharper disable CheckNamespace +// ReSharper disable InconsistentNaming +// ReSharper disable PartialTypeWithSinglePart + +using System; +using System.Globalization; + +internal static partial class PolyfillExtensions +{ + extension(ulong) + { + // https://learn.microsoft.com/dotnet/api/system.uint64.tryparse#system-uint64-tryparse(system-string-system-iformatprovider-system-uint64@) + public static bool TryParse(string s, IFormatProvider? provider, out ulong result) => + ulong.TryParse(s, NumberStyles.Integer, provider, out result); + } +} +#endif diff --git a/PolyShim/Net70/UIntPtr.cs b/PolyShim/Net70/UIntPtr.cs new file mode 100644 index 0000000..86259b1 --- /dev/null +++ b/PolyShim/Net70/UIntPtr.cs @@ -0,0 +1,33 @@ +#if (NETCOREAPP && !NET7_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) +#nullable enable +// ReSharper disable RedundantUsingDirective +// ReSharper disable CheckNamespace +// ReSharper disable InconsistentNaming +// ReSharper disable PartialTypeWithSinglePart + +using System; +using System.Globalization; + +internal static partial class PolyfillExtensions +{ + extension(UIntPtr) + { + // https://learn.microsoft.com/dotnet/api/system.uintptr.tryparse#system-uintptr-tryparse(system-string-system-iformatprovider-system-uintptr@) + public static bool TryParse(string s, IFormatProvider? provider, out UIntPtr result) + { + if (IntPtr.Size == 4) + { + var success = uint.TryParse(s, provider, out var intResult); + result = new UIntPtr(intResult); + return success; + } + else + { + var success = ulong.TryParse(s, provider, out var longResult); + result = new UIntPtr(longResult); + return success; + } + } + } +} +#endif diff --git a/PolyShim/Signatures.md b/PolyShim/Signatures.md index 0f26239..0d51a86 100644 --- a/PolyShim/Signatures.md +++ b/PolyShim/Signatures.md @@ -1,8 +1,8 @@ # Signatures -- **Total:** 246 +- **Total:** 259 - **Types:** 62 -- **Members:** 184 +- **Members:** 197 ___ @@ -18,6 +18,8 @@ ___ - [`void ThrowIfNullOrWhiteSpace(string?, string?)`](https://learn.microsoft.com/dotnet/api/system.argumentexception.throwifnullorwhitespace) .NET 7.0 - `ArgumentNullException` - [`void ThrowIfNull(object?, string?)`](https://learn.microsoft.com/dotnet/api/system.argumentnullexception.throwifnull#system-argumentnullexception-throwifnull(system-object-system-string)) .NET 6.0 +- `byte` + - [`bool TryParse(string, IFormatProvider?, out byte)`](https://learn.microsoft.com/dotnet/api/system.byte.tryparse#system-byte-tryparse(system-string-system-iformatprovider-system-byte@)) .NET 7.0 - `CallerArgumentExpressionAttribute` - [**[class]**](https://learn.microsoft.com/dotnet/api/system.runtime.compilerservices.callerargumentexpressionattribute) .NET Core 3.0 - `CancellationTokenSource` @@ -28,6 +30,8 @@ ___ - [`DateTime UnixEpoch`](https://learn.microsoft.com/dotnet/api/system.datetime.unixepoch) .NET Core 2.1 - `DateTimeOffset` - [`DateTimeOffset UnixEpoch`](https://learn.microsoft.com/dotnet/api/system.datetimeoffset.unixepoch) .NET Core 2.1 +- `decimal` + - [`bool TryParse(string, IFormatProvider?, out decimal)`](https://learn.microsoft.com/dotnet/api/system.decimal.tryparse#system-decimal-tryparse(system-string-system-iformatprovider-system-decimal@)) .NET 7.0 - `Dictionary` - [`bool TryAdd(TKey, TValue)`](https://learn.microsoft.com/dotnet/api/system.collections.generic.dictionary-2.tryadd) .NET Core 2.0 - `DictionaryEntry` @@ -38,6 +42,8 @@ ___ - [**[class]**](https://learn.microsoft.com/dotnet/api/system.diagnostics.codeanalysis.doesnotreturnattribute) .NET Core 3.0 - `DoesNotReturnIfAttribute` - [**[class]**](https://learn.microsoft.com/dotnet/api/system.diagnostics.codeanalysis.doesnotreturnifattribute) .NET Core 3.0 +- `double` + - [`bool TryParse(string, IFormatProvider?, out double)`](https://learn.microsoft.com/dotnet/api/system.double.tryparse#system-double-tryparse(system-string-system-iformatprovider-system-double@)) .NET 7.0 - `DynamicallyAccessedMembersAttribute` - [**[class]**](https://learn.microsoft.com/dotnet/api/system.diagnostics.codeanalysis.dynamicallyaccessedmembersattribute) .NET 5.0 - `DynamicallyAccessedMemberTypes` @@ -82,6 +88,8 @@ ___ - [`Task ReadAllTextAsync(string, Encoding, CancellationToken)`](https://learn.microsoft.com/dotnet/api/system.io.file.readalltextasync#system-io-file-readalltextasync(system-string-system-text-encoding-system-threading-cancellationtoken)) .NET Core 2.0 - [`void AppendAllBytes(string, byte[])`](https://learn.microsoft.com/dotnet/api/system.io.file.appendallbytes#system-io-file-appendallbytes(system-string-system-byte())) .NET 9.0 - [`void Move(string, string, bool)`](https://learn.microsoft.com/dotnet/api/system.io.file.move#system-io-file-move(system-string-system-string-system-boolean)) .NET Core 3.0 +- `float` + - [`bool TryParse(string, IFormatProvider?, out float)`](https://learn.microsoft.com/dotnet/api/system.single.tryparse#system-single-tryparse(system-string-system-iformatprovider-system-single@)) .NET 7.0 - `HashCode` - [**[class]**](https://learn.microsoft.com/dotnet/api/system.hashcode) .NET Core 2.1 - `HashSet` @@ -143,6 +151,10 @@ ___ - [`T? MinBy(Func)`](https://learn.microsoft.com/dotnet/api/system.linq.enumerable.minby#system-linq-enumerable-minby-2(system-collections-generic-ienumerable((-0))-system-func((-0-1)))) .NET 6.0 - `Index` - [**[struct]**](https://learn.microsoft.com/dotnet/api/system.index) .NET Core 3.0 +- `int` + - [`bool TryParse(string, IFormatProvider?, out int)`](https://learn.microsoft.com/dotnet/api/system.int32.tryparse#system-int32-tryparse(system-string-system-iformatprovider-system-int32@)) .NET 7.0 +- `IntPtr` + - [`bool TryParse(string, IFormatProvider?, out IntPtr)`](https://learn.microsoft.com/dotnet/api/system.intptr.tryparse#system-intptr-tryparse(system-string-system-iformatprovider-system-intptr@)) .NET 7.0 - `IReadOnlyDictionary` - [`TValue? GetValueOrDefault(TKey, TValue?)`](https://learn.microsoft.com/dotnet/api/system.collections.generic.collectionextensions.getvalueordefault#system-collections-generic-collectionextensions-getvalueordefault-2(system-collections-generic-ireadonlydictionary((-0-1))-0-1)) .NET Core 2.0 - [`TValue? GetValueOrDefault(TKey)`](https://learn.microsoft.com/dotnet/api/system.collections.generic.collectionextensions.getvalueordefault#system-collections-generic-collectionextensions-getvalueordefault-2(system-collections-generic-ireadonlydictionary((-0-1))-0)) .NET Core 2.0 @@ -156,6 +168,8 @@ ___ - [`int EnsureCapacity(int)`](https://learn.microsoft.com/dotnet/api/system.collections.generic.list-1.ensurecapacity) .NET 6.0 - `Lock` - [**[class]**](https://learn.microsoft.com/dotnet/api/system.threading.lock) .NET 9.0 +- `long` + - [`bool TryParse(string, IFormatProvider?, out long)`](https://learn.microsoft.com/dotnet/api/system.int64.tryparse#system-int64-tryparse(system-string-system-iformatprovider-system-int64@)) .NET 7.0 - `MatchCollection` - [`IEnumerable AsEnumerable()`](https://learn.microsoft.com/dotnet/api/system.text.regularexpressions.matchcollection.system-collections-generic-ienumerable-system-text-regularexpressions-match--getenumerator) .NET Core 2.0 - [`IEnumerator GetEnumerator()`](https://learn.microsoft.com/dotnet/api/system.text.regularexpressions.matchcollection.system-collections-generic-ienumerable-system-text-regularexpressions-match--getenumerator) .NET Core 2.0 @@ -227,8 +241,12 @@ ___ - [**[class]**](https://learn.microsoft.com/dotnet/api/system.runtime.compilerservices.runtimehelpers) .NET Core 3.0 - `RuntimeInformation` - [**[class]**](https://learn.microsoft.com/dotnet/api/system.runtime.interopservices.runtimeinformation) .NET Core 1.0 +- `sbyte` + - [`bool TryParse(string, IFormatProvider?, out sbyte)`](https://learn.microsoft.com/dotnet/api/system.sbyte.tryparse#system-sbyte-tryparse(system-string-system-iformatprovider-system-sbyte@)) .NET 7.0 - `SetsRequiredMembersAttribute` - [**[class]**](https://learn.microsoft.com/dotnet/api/system.diagnostics.codeanalysis.setsrequiredmembersattribute) .NET 7.0 +- `short` + - [`bool TryParse(string, IFormatProvider?, out short)`](https://learn.microsoft.com/dotnet/api/system.int16.tryparse#system-int16-tryparse(system-string-system-iformatprovider-system-int16@)) .NET 7.0 - `SkipLocalsInitAttribute` - [**[class]**](https://learn.microsoft.com/dotnet/api/system.runtime.compilerservices.skiplocalsinitattribute) .NET 5.0 - `SortedSet` @@ -324,12 +342,20 @@ ___ - [`bool IsAssignableFrom(Type)`](https://learn.microsoft.com/dotnet/api/system.type.isassignablefrom) .NET Core 2.0 - [`bool IsAssignableTo(Type?)`](https://learn.microsoft.com/dotnet/api/system.type.isassignableto) .NET 5.0 - [`bool IsSubclassOf(Type)`](https://learn.microsoft.com/dotnet/api/system.type.issubclassof) .NET Core 2.0 +- `uint` + - [`bool TryParse(string, IFormatProvider?, out uint)`](https://learn.microsoft.com/dotnet/api/system.uint32.tryparse#system-uint32-tryparse(system-string-system-iformatprovider-system-uint32@)) .NET 7.0 +- `UIntPtr` + - [`bool TryParse(string, IFormatProvider?, out UIntPtr)`](https://learn.microsoft.com/dotnet/api/system.uintptr.tryparse#system-uintptr-tryparse(system-string-system-iformatprovider-system-uintptr@)) .NET 7.0 +- `ulong` + - [`bool TryParse(string, IFormatProvider?, out ulong)`](https://learn.microsoft.com/dotnet/api/system.uint64.tryparse#system-uint64-tryparse(system-string-system-iformatprovider-system-uint64@)) .NET 7.0 - `UnconditionalSuppressMessageAttribute` - [**[class]**](https://learn.microsoft.com/dotnet/api/system.diagnostics.codeanalysis.unconditionalsuppressmessageattribute) .NET 5.0 - `UnsupportedOSPlatformAttribute` - [**[class]**](https://learn.microsoft.com/dotnet/api/system.runtime.versioning.unsupportedosplatformattribute) .NET 5.0 - `UnsupportedOSPlatformGuardAttribute` - [**[class]**](https://learn.microsoft.com/dotnet/api/system.runtime.versioning.unsupportedosplatformguardattribute) .NET 6.0 +- `ushort` + - [`bool TryParse(string, IFormatProvider?, out ushort)`](https://learn.microsoft.com/dotnet/api/system.uint16.tryparse#system-uint16-tryparse(system-string-system-iformatprovider-system-uint16@)) .NET 7.0 - `ValueTuple` - [**[struct]**](https://learn.microsoft.com/dotnet/api/system.valuetuple) .NET Core 2.0 - `ValueTuple`