mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-18 16:10:26 +02:00
Added nameof
This commit is contained in:
parent
dd0d67cca1
commit
7dd2324fcf
13 changed files with 307 additions and 13 deletions
|
@ -1,6 +1,8 @@
|
|||
#pragma warning disable 168
|
||||
|
||||
using System;
|
||||
using System.Interop;
|
||||
using System.Collections;
|
||||
|
||||
namespace Tests
|
||||
{
|
||||
|
@ -24,5 +26,27 @@ namespace Tests
|
|||
inStr.Length > 1 || 2 == 3
|
||||
};
|
||||
}
|
||||
|
||||
static void GetName<T>(String str)
|
||||
{
|
||||
str.Append(nameof(T));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public static void TestNameof()
|
||||
{
|
||||
var point = (x: 3, y: 4);
|
||||
|
||||
Test.Assert(nameof(System) == "System");
|
||||
Test.Assert(nameof(System.Collections) == "Collections");
|
||||
Test.Assert(nameof(point) == "point");
|
||||
Test.Assert(nameof(point.x) == "x");
|
||||
Test.Assert(nameof(Tests.Expressions) == "Expressions");
|
||||
Test.Assert(nameof(c_int) == "c_int");
|
||||
Test.Assert(nameof(List<int>) == "List");
|
||||
Test.Assert(nameof(List<int>.Add) == "Add");
|
||||
Test.Assert(nameof(TestBasics) == "TestBasics");
|
||||
Test.Assert(GetName<String>(.. scope .()) == "T");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue