mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-18 08:06:04 +02:00
Fixed 'ref' and 'in' this parameter for extension methods
This commit is contained in:
parent
0d15b28bd3
commit
a1cd01cd3d
4 changed files with 43 additions and 1 deletions
|
@ -12,8 +12,21 @@ namespace Tests
|
|||
return 123;
|
||||
}
|
||||
|
||||
public static void AddTo(this ref StructA @this)
|
||||
{
|
||||
@this.mA += 1000;
|
||||
}
|
||||
|
||||
public static void AddTo2(this in StructA @this)
|
||||
{
|
||||
#unwarn
|
||||
(&@this).mA += 1000;
|
||||
}
|
||||
|
||||
class ClassA
|
||||
{
|
||||
public int mA = 10000;
|
||||
|
||||
public static void Test()
|
||||
{
|
||||
Test.Assert("Abc".Remove(1.2f, 2.3f) == 123);
|
||||
|
@ -29,6 +42,11 @@ namespace Tests
|
|||
|
||||
}
|
||||
|
||||
struct StructA
|
||||
{
|
||||
public int mA;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public static void TestBasics()
|
||||
{
|
||||
|
@ -46,6 +64,13 @@ namespace Tests
|
|||
float a = 1.2f;
|
||||
float b = 2.3f;
|
||||
Test.Assert(a.CompareIt(b) < 0);
|
||||
|
||||
StructA sa = .() { mA = 123 };
|
||||
|
||||
sa.AddTo();
|
||||
Test.Assert(sa.mA == 1123);
|
||||
sa.AddTo2();
|
||||
Test.Assert(sa.mA == 2123);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue