-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b450737
commit 9080109
Showing
41 changed files
with
881 additions
and
3,481 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
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
23 changes: 23 additions & 0 deletions
23
src/Spanned/Compat/System/Diagnostics/CodeAnalysis/StringSyntaxAttribute.cs
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,23 @@ | ||
namespace System.Diagnostics.CodeAnalysis; | ||
|
||
[AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = false, Inherited = false)] | ||
internal sealed class StringSyntaxAttribute : Attribute | ||
{ | ||
public StringSyntaxAttribute(string syntax) | ||
{ | ||
Syntax = syntax; | ||
Arguments = Array.Empty<object?>(); | ||
} | ||
|
||
public StringSyntaxAttribute(string syntax, params object?[] arguments) | ||
{ | ||
Syntax = syntax; | ||
Arguments = arguments; | ||
} | ||
|
||
public string Syntax { get; } | ||
|
||
public object?[] Arguments { get; } | ||
|
||
public const string CompositeFormat = nameof(CompositeFormat); | ||
} |
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,25 @@ | ||
namespace System.Numerics; | ||
|
||
internal readonly struct ByteNumber : INumber<byte> | ||
{ | ||
public byte MinValue | ||
{ | ||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
get => byte.MinValue; | ||
} | ||
|
||
public byte MaxValue | ||
{ | ||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
get => byte.MaxValue; | ||
} | ||
|
||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
public byte Add(byte left, byte right) => (byte)(left + right); | ||
|
||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
public byte AddChecked(byte left, byte right) => checked((byte)(left + right)); | ||
|
||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
public bool IsNegative(byte value) => false; | ||
} |
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,25 @@ | ||
namespace System.Numerics; | ||
|
||
internal readonly struct DecimalNumber : INumber<decimal> | ||
{ | ||
public decimal MinValue | ||
{ | ||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
get => decimal.MinValue; | ||
} | ||
|
||
public decimal MaxValue | ||
{ | ||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
get => decimal.MaxValue; | ||
} | ||
|
||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
public decimal Add(decimal left, decimal right) => left + right; | ||
|
||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
public decimal AddChecked(decimal left, decimal right) => left + right; | ||
|
||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
public bool IsNegative(decimal value) => value < 0m; | ||
} |
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,25 @@ | ||
namespace System.Numerics; | ||
|
||
internal readonly struct DoubleNumber : INumber<double> | ||
{ | ||
public double MinValue | ||
{ | ||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
get => double.MinValue; | ||
} | ||
|
||
public double MaxValue | ||
{ | ||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
get => double.MaxValue; | ||
} | ||
|
||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
public double Add(double left, double right) => left + right; | ||
|
||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
public double AddChecked(double left, double right) => left + right; | ||
|
||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
public bool IsNegative(double value) => value < 0d; | ||
} |
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,14 @@ | ||
namespace System.Numerics; | ||
|
||
internal interface INumber<T> where T : struct | ||
{ | ||
T MinValue { get; } | ||
|
||
T MaxValue { get; } | ||
|
||
bool IsNegative(T value); | ||
|
||
T Add(T left, T right); | ||
|
||
T AddChecked(T left, T right); | ||
} |
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,25 @@ | ||
namespace System.Numerics; | ||
|
||
internal readonly struct Int16Number : INumber<short> | ||
{ | ||
public short MinValue | ||
{ | ||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
get => short.MinValue; | ||
} | ||
|
||
public short MaxValue | ||
{ | ||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
get => short.MaxValue; | ||
} | ||
|
||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
public short Add(short left, short right) => (short)(left + right); | ||
|
||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
public short AddChecked(short left, short right) => checked((short)(left + right)); | ||
|
||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
public bool IsNegative(short value) => value < (short)0; | ||
} |
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,25 @@ | ||
namespace System.Numerics; | ||
|
||
internal readonly struct Int32Number : INumber<int> | ||
{ | ||
public int MinValue | ||
{ | ||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
get => int.MinValue; | ||
} | ||
|
||
public int MaxValue | ||
{ | ||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
get => int.MaxValue; | ||
} | ||
|
||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
public int Add(int left, int right) => left + right; | ||
|
||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
public int AddChecked(int left, int right) => checked(left + right); | ||
|
||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
public bool IsNegative(int value) => value < 0; | ||
} |
Oops, something went wrong.