-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: generate code off internal methods
- Loading branch information
Showing
13 changed files
with
118 additions
and
465 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
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,19 +1,10 @@ | ||
namespace Tuxedo; | ||
|
||
/// <summary> | ||
/// Boolean refinements | ||
/// </summary> | ||
public static class BoolRefinements | ||
internal static class BoolRefinements | ||
{ | ||
/// <summary> | ||
/// Enforces that a boolean value is true | ||
/// </summary> | ||
[Refinement("The boolean value must be 'True', instead found '{value}'")] | ||
public static bool True(bool value) => value; | ||
internal static bool True(bool value) => value; | ||
|
||
/// <summary> | ||
/// Enforces that a boolean value is false | ||
/// </summary> | ||
[Refinement("The boolean value must be 'False', instead found '{value}'")] | ||
public static bool False(bool value) => !value; | ||
internal static bool False(bool value) => !value; | ||
} |
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,91 +1,46 @@ | ||
namespace Tuxedo; | ||
|
||
/// <summary> | ||
/// Refinements for <see cref="char"/> | ||
/// </summary> | ||
public static class CharRefinements | ||
internal static class CharRefinements | ||
{ | ||
/// <summary> | ||
/// Enforces that a character is a digit | ||
/// </summary> | ||
[Refinement("The character must be a letter, instead found '{value}'")] | ||
public static bool Letter(char value) => char.IsLetter(value); | ||
internal static bool Letter(char value) => char.IsLetter(value); | ||
|
||
/// <summary> | ||
/// Enforces that a character is a digit | ||
/// </summary> | ||
[Refinement("The character must be a digit, instead found '{value}'")] | ||
public static bool Digit(char value) => char.IsDigit(value); | ||
internal static bool Digit(char value) => char.IsDigit(value); | ||
|
||
/// <summary> | ||
/// Enforces that a character is lower case | ||
/// </summary> | ||
[Refinement("The character must be lower case, instead found '{value}'")] | ||
public static bool Lower(char value) => char.IsLower(value); | ||
internal static bool Lower(char value) => char.IsLower(value); | ||
|
||
/// <summary> | ||
/// Enforces that a character is upper case | ||
/// </summary> | ||
[Refinement("The character must be upper case, instead found '{value}'")] | ||
public static bool Upper(char value) => char.IsUpper(value); | ||
internal static bool Upper(char value) => char.IsUpper(value); | ||
|
||
/// <summary> | ||
/// Enforces that a character is a symbol | ||
/// </summary> | ||
[Refinement("The character must be a symbol, instead found '{value}'")] | ||
public static bool Symbol(char value) => char.IsSymbol(value); | ||
internal static bool Symbol(char value) => char.IsSymbol(value); | ||
|
||
/// <summary> | ||
/// Enforces that a character is a punctuation | ||
/// </summary> | ||
[Refinement("The character must be a punctuation, instead found '{value}'")] | ||
public static bool Punctuation(char value) => char.IsPunctuation(value); | ||
internal static bool Punctuation(char value) => char.IsPunctuation(value); | ||
|
||
/// <summary> | ||
/// Enforces that a character is a separator | ||
/// </summary> | ||
[Refinement("The character must be a separator, instead found '{value}'")] | ||
public static bool Separator(char value) => char.IsSeparator(value); | ||
internal static bool Separator(char value) => char.IsSeparator(value); | ||
|
||
/// <summary> | ||
/// Enforces that a character is a control | ||
/// </summary> | ||
[Refinement("The character must be a control, instead found '{value}'")] | ||
public static bool Control(char value) => char.IsControl(value); | ||
internal static bool Control(char value) => char.IsControl(value); | ||
|
||
/// <summary> | ||
/// Enforces that a character is a whitespace | ||
/// </summary> | ||
[Refinement("The character must be a whitespace, instead found '{value}'")] | ||
public static bool Whitespace(char value) => char.IsWhiteSpace(value); | ||
internal static bool Whitespace(char value) => char.IsWhiteSpace(value); | ||
|
||
/// <summary> | ||
/// Enforces that a character is a surrogate | ||
/// </summary> | ||
[Refinement("The character must be a surrogate, instead found '{value}'")] | ||
public static bool Surrogate(char value) => char.IsSurrogate(value); | ||
internal static bool Surrogate(char value) => char.IsSurrogate(value); | ||
|
||
/// <summary> | ||
/// Enforces that a character is a high surrogate | ||
/// </summary> | ||
[Refinement("The character must be a high surrogate, instead found '{value}'")] | ||
public static bool HighSurrogate(char value) => char.IsHighSurrogate(value); | ||
internal static bool HighSurrogate(char value) => char.IsHighSurrogate(value); | ||
|
||
/// <summary> | ||
/// Enforces that a character is a low surrogate | ||
/// </summary> | ||
[Refinement("The character must be a low surrogate, instead found '{value}'")] | ||
public static bool LowSurrogate(char value) => char.IsLowSurrogate(value); | ||
internal static bool LowSurrogate(char value) => char.IsLowSurrogate(value); | ||
|
||
/// <summary> | ||
/// Enforces that a character is a valid ASCII character | ||
/// </summary> | ||
[Refinement("The character must be a valid ASCII character, instead found '{value}'")] | ||
public static bool Ascii(char value) => value < 128; | ||
internal static bool Ascii(char value) => value < 128; | ||
|
||
/// <summary> | ||
/// Enforces that a character is a valid-extended ASCII character | ||
/// </summary> | ||
[Refinement("The character must be a valid extended ASCII character, instead found '{value}'")] | ||
public static bool ExtendedAscii(char value) => value < 256; | ||
internal static bool ExtendedAscii(char value) => value < 256; | ||
} |
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 |
---|---|---|
@@ -1,55 +1,28 @@ | ||
namespace Tuxedo; | ||
|
||
/// <summary> | ||
/// Refinements to ensure that a numeric value is even | ||
/// </summary> | ||
public static class EvenRefinements | ||
internal static class EvenRefinements | ||
{ | ||
/// <summary> | ||
/// Enforces that a numeric value is even | ||
/// </summary> | ||
[Refinement("Number must be an even number, but found {value}")] | ||
public static bool Even(sbyte value) => value % 2 == 0; | ||
internal static bool Even(sbyte value) => value % 2 == 0; | ||
|
||
/// <summary> | ||
/// Enforces that a numeric value is even | ||
/// </summary> | ||
[Refinement("Number must be an even number, but found {value}")] | ||
public static bool Even(short value) => value % 2 == 0; | ||
internal static bool Even(short value) => value % 2 == 0; | ||
|
||
/// <summary> | ||
/// Enforces that a numeric value is even | ||
/// </summary> | ||
[Refinement("Number must be an even number, but found {value}")] | ||
public static bool Even(int value) => value % 2 == 0; | ||
internal static bool Even(int value) => value % 2 == 0; | ||
|
||
/// <summary> | ||
/// Enforces that a numeric value is even | ||
/// </summary> | ||
[Refinement("Number must be an even number, but found {value}")] | ||
public static bool Even(long value) => value % 2 == 0; | ||
internal static bool Even(long value) => value % 2 == 0; | ||
|
||
/// <summary> | ||
/// Enforces that a numeric value is even | ||
/// </summary> | ||
[Refinement("Number must be an even number, but found {value}")] | ||
public static bool Even(byte value) => value % 2 == 0; | ||
internal static bool Even(byte value) => value % 2 == 0; | ||
|
||
/// <summary> | ||
/// Enforces that a numeric value is even | ||
/// </summary> | ||
[Refinement("Number must be an even number, but found {value}")] | ||
public static bool Even(ushort value) => value % 2 == 0; | ||
internal static bool Even(ushort value) => value % 2 == 0; | ||
|
||
/// <summary> | ||
/// Enforces that a numeric value is even | ||
/// </summary> | ||
[Refinement("Number must be an even number, but found {value}")] | ||
public static bool Even(uint value) => value % 2 == 0; | ||
internal static bool Even(uint value) => value % 2 == 0; | ||
|
||
/// <summary> | ||
/// Enforces that a numeric value is even | ||
/// </summary> | ||
[Refinement("Number must be an even number, but found {value}")] | ||
public static bool Even(ulong value) => value % 2 == 0; | ||
internal static bool Even(ulong value) => value % 2 == 0; | ||
} |
Oops, something went wrong.