1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-11 04:52:21 +02:00

Changed Count/MinValue/MaxValue from properties to methods

This commit is contained in:
Brian Fiete 2022-06-23 13:37:15 -07:00
parent d17da427bc
commit 439b34f7c2
2 changed files with 35 additions and 44 deletions

View file

@ -4,11 +4,9 @@ using System.Collections;
namespace System
{
struct Enum
{
public static int Count
{
[Comptime(ConstEval=true)]
get
public static int GetCount()
{
int count = 0;
for (var field in Compiler.OrigCalleeType.GetFields())
@ -18,12 +16,9 @@ namespace System
}
return count;
}
}
public static var MinValue
{
[Comptime(ConstEval=true)]
get
public static var GetMinValue()
{
Compiler.SetReturnType(Compiler.OrigCalleeType);
@ -40,12 +35,9 @@ namespace System
}
return minValue.ValueOrDefault;
}
}
public static var MaxValue
{
[Comptime(ConstEval=true)]
get
public static var GetMaxValue()
{
Compiler.SetReturnType(Compiler.OrigCalleeType);
@ -64,7 +56,6 @@ namespace System
return -1;
return maxValue.ValueOrDefault;
}
}
public static void EnumToString(Type type, String strBuffer, int64 iVal)
{

View file

@ -138,9 +138,9 @@ namespace Tests
eg.Set(66);
Test.Assert(eg == .B);
var ea = EnumA.MaxValue;
var ea = EnumA.GetMaxValue();
Test.Assert(ea == .B);
Test.Assert(EnumA.Count == 2);
Test.Assert(EnumA.GetCount() == 2);
}
}
}