Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions PolyShim/Net50/IntPtr.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#if (NETCOREAPP && !NET5_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 PolyfillExtensions2
{
extension(IntPtr)
{
// https://learn.microsoft.com/dotnet/api/system.intptr.parse#system-intptr-parse(system-string-system-globalization-numberstyles-system-iformatprovider)
public static IntPtr Parse(string s, NumberStyles style, IFormatProvider? provider) =>
new(IntPtr.Size == 4 ? int.Parse(s, style, provider) : long.Parse(s, style, provider));

// https://learn.microsoft.com/dotnet/api/system.intptr.parse#system-intptr-parse(system-string-system-iformatprovider)
public static IntPtr Parse(string s, IFormatProvider? provider) =>
new(IntPtr.Size == 4 ? int.Parse(s, provider) : long.Parse(s, provider));

// https://learn.microsoft.com/dotnet/api/system.intptr.parse#system-intptr-parse(system-string-system-globalization-numberstyles)
public static IntPtr Parse(string s, NumberStyles style) =>
new(IntPtr.Size == 4 ? int.Parse(s, style) : long.Parse(s, style));

// https://learn.microsoft.com/dotnet/api/system.intptr.parse#system-intptr-parse(system-string)
public static IntPtr Parse(string s) =>
new(IntPtr.Size == 4 ? int.Parse(s) : long.Parse(s));

// https://learn.microsoft.com/dotnet/api/system.intptr.tryparse#system-intptr-tryparse(system-string-system-intptr@)
public static bool TryParse(string? s, out IntPtr result)
{
if (IntPtr.Size == 4)
{
var success = int.TryParse(s, out var intResult);
result = new IntPtr(intResult);
return success;
}
else
{
var success = long.TryParse(s, out var longResult);
result = new IntPtr(longResult);
return success;
}
}
}
}
#endif
51 changes: 51 additions & 0 deletions PolyShim/Net50/UIntPtr.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#if (NETCOREAPP && !NET5_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 PolyfillExtensions3
{
extension(UIntPtr)
{
// https://learn.microsoft.com/dotnet/api/system.uintptr.parse#system-uintptr-parse(system-string-system-globalization-numberstyles-system-iformatprovider)
public static UIntPtr Parse(string s, NumberStyles style, IFormatProvider? provider) =>
new(
UIntPtr.Size == 4 ? uint.Parse(s, style, provider) : ulong.Parse(s, style, provider)
);

// https://learn.microsoft.com/dotnet/api/system.uintptr.parse#system-uintptr-parse(system-string-system-iformatprovider)
public static UIntPtr Parse(string s, IFormatProvider? provider) =>
new(UIntPtr.Size == 4 ? uint.Parse(s, provider) : ulong.Parse(s, provider));

// https://learn.microsoft.com/dotnet/api/system.uintptr.parse#system-uintptr-parse(system-string-system-globalization-numberstyles)
public static UIntPtr Parse(string s, NumberStyles style) =>
new(UIntPtr.Size == 4 ? uint.Parse(s, style) : ulong.Parse(s, style));

// https://learn.microsoft.com/dotnet/api/system.uintptr.parse#system-uintptr-parse(system-string)
public static UIntPtr Parse(string s) =>
new(UIntPtr.Size == 4 ? uint.Parse(s) : ulong.Parse(s));

// https://learn.microsoft.com/dotnet/api/system.uintptr.tryparse#system-uintptr-tryparse(system-string-system-uintptr@)
public static bool TryParse(string? s, out UIntPtr result)
{
if (UIntPtr.Size == 4)
{
var success = uint.TryParse(s, out var intResult);
result = new UIntPtr(intResult);
return success;
}
else
{
var success = ulong.TryParse(s, out var longResult);
result = new UIntPtr(longResult);
return success;
}
}
}
}
#endif
14 changes: 12 additions & 2 deletions PolyShim/Signatures.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Signatures

- **Total:** 320
- **Total:** 330
- **Types:** 71
- **Members:** 249
- **Members:** 259

___

Expand Down Expand Up @@ -169,6 +169,11 @@ ___
- [`bool TryParse(string, IFormatProvider?, out int)`](https://learn.microsoft.com/dotnet/api/system.int32.tryparse#system-int32-tryparse(system-string-system-iformatprovider-system-int32@)) <sup><sub>.NET 7.0</sub></sup>
- `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@)) <sup><sub>.NET 7.0</sub></sup>
- [`bool TryParse(string?, out IntPtr)`](https://learn.microsoft.com/dotnet/api/system.intptr.tryparse#system-intptr-tryparse(system-string-system-intptr@)) <sup><sub>.NET 5.0</sub></sup>
- [`IntPtr Parse(string, IFormatProvider?)`](https://learn.microsoft.com/dotnet/api/system.intptr.parse#system-intptr-parse(system-string-system-iformatprovider)) <sup><sub>.NET 5.0</sub></sup>
- [`IntPtr Parse(string, NumberStyles, IFormatProvider?)`](https://learn.microsoft.com/dotnet/api/system.intptr.parse#system-intptr-parse(system-string-system-globalization-numberstyles-system-iformatprovider)) <sup><sub>.NET 5.0</sub></sup>
- [`IntPtr Parse(string, NumberStyles)`](https://learn.microsoft.com/dotnet/api/system.intptr.parse#system-intptr-parse(system-string-system-globalization-numberstyles)) <sup><sub>.NET 5.0</sub></sup>
- [`IntPtr Parse(string)`](https://learn.microsoft.com/dotnet/api/system.intptr.parse#system-intptr-parse(system-string)) <sup><sub>.NET 5.0</sub></sup>
- `IReadOnlyDictionary<TKey, TValue>`
- [`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)) <sup><sub>.NET Core 2.0</sub></sup>
- [`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)) <sup><sub>.NET Core 2.0</sub></sup>
Expand Down Expand Up @@ -419,6 +424,11 @@ ___
- [`bool TryParse(string, IFormatProvider?, out uint)`](https://learn.microsoft.com/dotnet/api/system.uint32.tryparse#system-uint32-tryparse(system-string-system-iformatprovider-system-uint32@)) <sup><sub>.NET 7.0</sub></sup>
- `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@)) <sup><sub>.NET 7.0</sub></sup>
- [`bool TryParse(string?, out UIntPtr)`](https://learn.microsoft.com/dotnet/api/system.uintptr.tryparse#system-uintptr-tryparse(system-string-system-uintptr@)) <sup><sub>.NET 5.0</sub></sup>
- [`UIntPtr Parse(string, IFormatProvider?)`](https://learn.microsoft.com/dotnet/api/system.uintptr.parse#system-uintptr-parse(system-string-system-iformatprovider)) <sup><sub>.NET 5.0</sub></sup>
- [`UIntPtr Parse(string, NumberStyles, IFormatProvider?)`](https://learn.microsoft.com/dotnet/api/system.uintptr.parse#system-uintptr-parse(system-string-system-globalization-numberstyles-system-iformatprovider)) <sup><sub>.NET 5.0</sub></sup>
- [`UIntPtr Parse(string, NumberStyles)`](https://learn.microsoft.com/dotnet/api/system.uintptr.parse#system-uintptr-parse(system-string-system-globalization-numberstyles)) <sup><sub>.NET 5.0</sub></sup>
- [`UIntPtr Parse(string)`](https://learn.microsoft.com/dotnet/api/system.uintptr.parse#system-uintptr-parse(system-string)) <sup><sub>.NET 5.0</sub></sup>
- `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@)) <sup><sub>.NET 7.0</sub></sup>
- `UnconditionalSuppressMessageAttribute`
Expand Down
Loading