mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-21 09:27:59 +02:00
Reflection field value fixes and tests
This commit is contained in:
parent
d4c78c0799
commit
d864a912c5
3 changed files with 41 additions and 1 deletions
|
@ -1,6 +1,7 @@
|
|||
#pragma warning disable 168
|
||||
|
||||
using System;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Tests
|
||||
{
|
||||
|
@ -124,6 +125,13 @@ namespace Tests
|
|||
}
|
||||
}
|
||||
|
||||
[Reflect, AlwaysInclude(AssumeInstantiated=true, IncludeAllMethods=true)]
|
||||
struct StructB
|
||||
{
|
||||
public int mA;
|
||||
public String mB;
|
||||
}
|
||||
|
||||
class ClassA2 : ClassA
|
||||
{
|
||||
public override int GetA(int32 a)
|
||||
|
@ -470,5 +478,31 @@ namespace Tests
|
|||
methodIdx++;
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
static void TestStructB()
|
||||
{
|
||||
StructB sb;
|
||||
sb.mA = 25;
|
||||
sb.mB = "Struct B";
|
||||
|
||||
let type = sb.GetType() as TypeInstance;
|
||||
let fields = type.GetFields();
|
||||
int fieldIdx = 0;
|
||||
for (let field in fields)
|
||||
{
|
||||
let refP = field.GetValue(sb);
|
||||
switch (fieldIdx)
|
||||
{
|
||||
case 0:
|
||||
Test.Assert(refP.Value.Get<int>() == 25);
|
||||
case 1:
|
||||
Test.Assert(refP.Value.Get<String>() === "Struct B");
|
||||
case 2:
|
||||
Test.FatalError();
|
||||
}
|
||||
fieldIdx++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue