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
19 changes: 19 additions & 0 deletions PolyShim.Tests/Net60/CharTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System;
using FluentAssertions;
using Xunit;

namespace PolyShim.Tests.Net60;

public class CharTests
{
[Fact]
public void IsAscii_Test()
{
// Act & assert
char.IsAscii('A').Should().BeTrue();
char.IsAscii('z').Should().BeTrue();
char.IsAscii('\x7f').Should().BeTrue();
char.IsAscii('\x80').Should().BeFalse();
char.IsAscii('é').Should().BeFalse();
}
}
118 changes: 118 additions & 0 deletions PolyShim.Tests/Net70/CharTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
using System;
using FluentAssertions;
using Xunit;

namespace PolyShim.Tests.Net70;

public class CharTests
{
[Fact]
public void IsBetween_Test()
{
// Act & assert
char.IsBetween('c', 'a', 'z').Should().BeTrue();
char.IsBetween('a', 'a', 'z').Should().BeTrue();
char.IsBetween('z', 'a', 'z').Should().BeTrue();
char.IsBetween('A', 'a', 'z').Should().BeFalse();
char.IsBetween('1', 'a', 'z').Should().BeFalse();
}

[Fact]
public void IsAsciiDigit_Test()
{
// Act & assert
char.IsAsciiDigit('0').Should().BeTrue();
char.IsAsciiDigit('5').Should().BeTrue();
char.IsAsciiDigit('9').Should().BeTrue();
char.IsAsciiDigit('a').Should().BeFalse();
char.IsAsciiDigit('A').Should().BeFalse();
}

[Fact]
public void IsAsciiHexDigit_Test()
{
// Act & assert
char.IsAsciiHexDigit('0').Should().BeTrue();
char.IsAsciiHexDigit('9').Should().BeTrue();
char.IsAsciiHexDigit('a').Should().BeTrue();
char.IsAsciiHexDigit('f').Should().BeTrue();
char.IsAsciiHexDigit('A').Should().BeTrue();
char.IsAsciiHexDigit('F').Should().BeTrue();
char.IsAsciiHexDigit('g').Should().BeFalse();
char.IsAsciiHexDigit('G').Should().BeFalse();
char.IsAsciiHexDigit('z').Should().BeFalse();
}

[Fact]
public void IsAsciiHexDigitLower_Test()
{
// Act & assert
char.IsAsciiHexDigitLower('0').Should().BeTrue();
char.IsAsciiHexDigitLower('9').Should().BeTrue();
char.IsAsciiHexDigitLower('a').Should().BeTrue();
char.IsAsciiHexDigitLower('f').Should().BeTrue();
char.IsAsciiHexDigitLower('A').Should().BeFalse();
char.IsAsciiHexDigitLower('F').Should().BeFalse();
char.IsAsciiHexDigitLower('g').Should().BeFalse();
char.IsAsciiHexDigitLower('z').Should().BeFalse();
}

[Fact]
public void IsAsciiHexDigitUpper_Test()
{
// Act & assert
char.IsAsciiHexDigitUpper('0').Should().BeTrue();
char.IsAsciiHexDigitUpper('9').Should().BeTrue();
char.IsAsciiHexDigitUpper('A').Should().BeTrue();
char.IsAsciiHexDigitUpper('F').Should().BeTrue();
char.IsAsciiHexDigitUpper('a').Should().BeFalse();
char.IsAsciiHexDigitUpper('f').Should().BeFalse();
char.IsAsciiHexDigitUpper('G').Should().BeFalse();
char.IsAsciiHexDigitUpper('Z').Should().BeFalse();
}

[Fact]
public void IsAsciiLetter_Test()
{
// Act & assert
char.IsAsciiLetter('a').Should().BeTrue();
char.IsAsciiLetter('z').Should().BeTrue();
char.IsAsciiLetter('A').Should().BeTrue();
char.IsAsciiLetter('Z').Should().BeTrue();
char.IsAsciiLetter('0').Should().BeFalse();
char.IsAsciiLetter('!').Should().BeFalse();
}

[Fact]
public void IsAsciiLetterLower_Test()
{
// Act & assert
char.IsAsciiLetterLower('a').Should().BeTrue();
char.IsAsciiLetterLower('z').Should().BeTrue();
char.IsAsciiLetterLower('A').Should().BeFalse();
char.IsAsciiLetterLower('Z').Should().BeFalse();
char.IsAsciiLetterLower('0').Should().BeFalse();
}

[Fact]
public void IsAsciiLetterUpper_Test()
{
// Act & assert
char.IsAsciiLetterUpper('A').Should().BeTrue();
char.IsAsciiLetterUpper('Z').Should().BeTrue();
char.IsAsciiLetterUpper('a').Should().BeFalse();
char.IsAsciiLetterUpper('z').Should().BeFalse();
char.IsAsciiLetterUpper('0').Should().BeFalse();
}

[Fact]
public void IsAsciiLetterOrDigit_Test()
{
// Act & assert
char.IsAsciiLetterOrDigit('a').Should().BeTrue();
char.IsAsciiLetterOrDigit('Z').Should().BeTrue();
char.IsAsciiLetterOrDigit('5').Should().BeTrue();
char.IsAsciiLetterOrDigit('!').Should().BeFalse();
char.IsAsciiLetterOrDigit(' ').Should().BeFalse();
}
}
19 changes: 19 additions & 0 deletions PolyShim/Net60/Char.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#if (NETCOREAPP && !NET6_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD)
#nullable enable
#pragma warning disable CS0436

using System;
using System.Diagnostics.CodeAnalysis;

#if !POLYSHIM_INCLUDE_COVERAGE
[ExcludeFromCodeCoverage]
#endif
internal static class MemberPolyfills_Net60_Char
{
extension(char)
{
// https://learn.microsoft.com/dotnet/api/system.char.isascii
public static bool IsAscii(char c) => (uint)c <= '\x7f';
}
}
#endif
49 changes: 49 additions & 0 deletions PolyShim/Net70/Char.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#if (NETCOREAPP && !NET7_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD)
#nullable enable
#pragma warning disable CS0436

using System;
using System.Diagnostics.CodeAnalysis;

#if !POLYSHIM_INCLUDE_COVERAGE
[ExcludeFromCodeCoverage]
#endif
internal static class MemberPolyfills_Net70_Char
{
extension(char)
{
// https://learn.microsoft.com/dotnet/api/system.char.isbetween
public static bool IsBetween(char c, char minInclusive, char maxInclusive) =>
(uint)(c - minInclusive) <= (uint)(maxInclusive - minInclusive);

// https://learn.microsoft.com/dotnet/api/system.char.isasciidigit
public static bool IsAsciiDigit(char c) => char.IsBetween(c, '0', '9');

// https://learn.microsoft.com/dotnet/api/system.char.isasciihexdigit
public static bool IsAsciiHexDigit(char c) =>
char.IsAsciiHexDigitUpper(c) || char.IsAsciiHexDigitLower(c);

// https://learn.microsoft.com/dotnet/api/system.char.isasciihexdigitlower
public static bool IsAsciiHexDigitLower(char c) =>
char.IsBetween(c, 'a', 'f') || char.IsAsciiDigit(c);

// https://learn.microsoft.com/dotnet/api/system.char.isasciihexdigitupper
public static bool IsAsciiHexDigitUpper(char c) =>
char.IsBetween(c, 'A', 'F') || char.IsAsciiDigit(c);

// https://learn.microsoft.com/dotnet/api/system.char.isasciiletter
public static bool IsAsciiLetter(char c) =>
char.IsAsciiLetterUpper(c) || char.IsAsciiLetterLower(c);

// https://learn.microsoft.com/dotnet/api/system.char.isasciiletterlower
public static bool IsAsciiLetterLower(char c) => char.IsBetween(c, 'a', 'z');

// https://learn.microsoft.com/dotnet/api/system.char.isasciiletterupper
public static bool IsAsciiLetterUpper(char c) => char.IsBetween(c, 'A', 'Z');

// https://learn.microsoft.com/dotnet/api/system.char.isasciiletterordigit
public static bool IsAsciiLetterOrDigit(char c) =>
char.IsAsciiLetter(c) || char.IsAsciiDigit(c);
}
}
#endif
15 changes: 13 additions & 2 deletions Signatures.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Signatures

- **Total:** 531
- **Total:** 541
- **Types:** 113
- **Members:** 418
- **Members:** 428

___

Expand Down Expand Up @@ -58,6 +58,17 @@ ___
- [**[class]**](https://learn.microsoft.com/dotnet/api/system.runtime.compilerservices.callermembernameattribute) <sup><sub>.NET Core 1.0</sub></sup>
- `CancellationTokenSource`
- [`Task CancelAsync()`](https://learn.microsoft.com/dotnet/api/system.threading.cancellationtokensource.cancelasync) <sup><sub>.NET 8.0</sub></sup>
- `char`
- [`static bool IsAscii(char)`](https://learn.microsoft.com/dotnet/api/system.char.isascii) <sup><sub>.NET 6.0</sub></sup>
- [`static bool IsAsciiDigit(char)`](https://learn.microsoft.com/dotnet/api/system.char.isasciidigit) <sup><sub>.NET 7.0</sub></sup>
- [`static bool IsAsciiHexDigit(char)`](https://learn.microsoft.com/dotnet/api/system.char.isasciihexdigit) <sup><sub>.NET 7.0</sub></sup>
- [`static bool IsAsciiHexDigitLower(char)`](https://learn.microsoft.com/dotnet/api/system.char.isasciihexdigitlower) <sup><sub>.NET 7.0</sub></sup>
- [`static bool IsAsciiHexDigitUpper(char)`](https://learn.microsoft.com/dotnet/api/system.char.isasciihexdigitupper) <sup><sub>.NET 7.0</sub></sup>
- [`static bool IsAsciiLetter(char)`](https://learn.microsoft.com/dotnet/api/system.char.isasciiletter) <sup><sub>.NET 7.0</sub></sup>
- [`static bool IsAsciiLetterLower(char)`](https://learn.microsoft.com/dotnet/api/system.char.isasciiletterlower) <sup><sub>.NET 7.0</sub></sup>
- [`static bool IsAsciiLetterOrDigit(char)`](https://learn.microsoft.com/dotnet/api/system.char.isasciiletterordigit) <sup><sub>.NET 7.0</sub></sup>
- [`static bool IsAsciiLetterUpper(char)`](https://learn.microsoft.com/dotnet/api/system.char.isasciiletterupper) <sup><sub>.NET 7.0</sub></sup>
- [`static bool IsBetween(char, char, char)`](https://learn.microsoft.com/dotnet/api/system.char.isbetween) <sup><sub>.NET 7.0</sub></sup>
- `CompilerFeatureRequiredAttribute`
- [**[class]**](https://learn.microsoft.com/dotnet/api/system.runtime.compilerservices.compilerfeaturerequiredattribute) <sup><sub>.NET 7.0</sub></sup>
- `ConditionalWeakTable<TKey, TValue>`
Expand Down
Loading