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

Inline anonymous type declarations

This commit is contained in:
Brian Fiete 2025-01-02 11:42:33 -08:00
parent f609062c2a
commit 958fc30310
20 changed files with 600 additions and 48 deletions

View file

@ -0,0 +1,44 @@
using System;
namespace Tests;
class Anonymous
{
struct StructA
{
public [Union] struct { public int mX, mY; } mVals;
[CRepr, SkipCall] struct { public int mA, mB; } GetVals()
{
decltype(GetVals()) retVals;
retVals.mA = 1;
retVals.mB = 2;
return retVals;
}
}
struct StructB
{
[Union]
public using struct
{
public int mX;
public int mY;
} mCoords;
}
[Test]
public static void TestBasics()
{
StructA sa = default;
sa.mVals.mX = 123;
Test.Assert(sa.mVals.mY == 123);
var val = sa.[Friend]GetVals();
Test.Assert(val.mA == 0);
Test.Assert(val.mB == 0);
StructB sb = default;
sb.mX = 345;
Test.Assert(sb.mY == 345);
}
}