-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/SimonCropp/Polyfill
- Loading branch information
Showing
7 changed files
with
90 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
**API count: 284** | ||
**API count: 285** |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#pragma warning disable | ||
|
||
// ReSharper disable RedundantUsingDirective | ||
// ReSharper disable PartialTypeWithSinglePart | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
using System.Diagnostics.CodeAnalysis; | ||
using System.Globalization; | ||
using System.Text; | ||
using Link = System.ComponentModel.DescriptionAttribute; | ||
|
||
[ExcludeFromCodeCoverage] | ||
[DebuggerNonUserCode] | ||
#if PolyPublic | ||
public | ||
#endif | ||
static partial class GuidPolyfill | ||
{ | ||
/// <summary> | ||
/// Tries to parse a string into a value. | ||
/// </summary> | ||
[Link("https://learn.microsoft.com/en-us/dotnet/api/system.guid.tryparse#system-guid-tryparse(system-string-system-iformatprovider-system-guid@)")] | ||
public static bool TryParse(string? target, IFormatProvider? provider, out Guid result) => | ||
#if !NET7_0_OR_GREATER | ||
Guid.TryParse(target, out result); | ||
#else | ||
Guid.TryParse(target, provider, out result); | ||
#endif | ||
|
||
#if FeatureMemory | ||
/// <summary> | ||
/// Tries to parse a span of UTF-8 characters into a value. | ||
/// </summary> | ||
[Link("https://learn.microsoft.com/en-us/dotnet/api/system.byte.tryparse#system-byte-tryparse(system-readonlyspan((system-byte))-system-iformatprovider-system-byte@)")] | ||
public static bool TryParse(ReadOnlySpan<byte> target, IFormatProvider? provider, out byte result) => | ||
#if !NET8_0_OR_GREATER | ||
byte.TryParse(Encoding.UTF8.GetString(target.ToArray()), NumberStyles.Integer, provider, out result); | ||
#else | ||
byte.TryParse(target, provider, out result); | ||
#endif | ||
|
||
#endif | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
partial class PolyfillTests | ||
{ | ||
[Test] | ||
public void IsAssignableTo() | ||
{ | ||
Assert.True(typeof(List<string>).IsAssignableTo(typeof(IList))); | ||
Assert.False(typeof(List<string>).IsAssignableTo(typeof(string))); | ||
Assert.False(typeof(List<string>).IsAssignableTo(null)); | ||
} | ||
} |