From 9946d1814f4af9ef67e5accd9404e0fc69290f6f Mon Sep 17 00:00:00 2001 From: JassJam <0139ne@gmail.com> Date: Mon, 23 Feb 2026 12:28:50 +0000 Subject: feat: add initial test files --- tests/projects/csharp/multiple_library/src/libalpha/Alpha.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 tests/projects/csharp/multiple_library/src/libalpha/Alpha.cs (limited to 'tests/projects/csharp/multiple_library/src/libalpha/Alpha.cs') diff --git a/tests/projects/csharp/multiple_library/src/libalpha/Alpha.cs b/tests/projects/csharp/multiple_library/src/libalpha/Alpha.cs new file mode 100644 index 000000000..f203d9c9e --- /dev/null +++ b/tests/projects/csharp/multiple_library/src/libalpha/Alpha.cs @@ -0,0 +1,10 @@ +namespace LibAlpha; + +public static class Alpha +{ + public static string Message() + { + return "alpha"; + } +} + -- cgit v1.3.1 From de6664486ef54cf7d3b50b45074539fb413e583c Mon Sep 17 00:00:00 2001 From: ruki Date: Mon, 16 Mar 2026 23:45:18 +0800 Subject: format csharp codes --- tests/projects/csharp/console_with_runtime_json/src/Program.cs | 4 +--- tests/projects/csharp/exe_with_library/src/lib/Greeter.cs | 7 ++----- tests/projects/csharp/multiple_library/src/libalpha/Alpha.cs | 7 ++----- tests/projects/csharp/multiple_library/src/libbeta/Beta.cs | 7 ++----- xmake/repository/templates/csharp/console/src/Program.cs | 9 +++++++++ xmake/repository/templates/csharp/console/xmake.lua | 7 +++++++ xmake/repository/templates/csharp/shared/src/foo.cs | 7 +++++++ xmake/repository/templates/csharp/shared/src/main.cs | 7 +++++++ xmake/repository/templates/csharp/shared/xmake.lua | 10 ++++++++++ xmake/repository/templates/csharp/static/src/foo.cs | 7 +++++++ xmake/repository/templates/csharp/static/src/main.cs | 7 +++++++ xmake/repository/templates/csharp/static/xmake.lua | 10 ++++++++++ 12 files changed, 71 insertions(+), 18 deletions(-) create mode 100644 xmake/repository/templates/csharp/console/src/Program.cs create mode 100644 xmake/repository/templates/csharp/console/xmake.lua create mode 100644 xmake/repository/templates/csharp/shared/src/foo.cs create mode 100644 xmake/repository/templates/csharp/shared/src/main.cs create mode 100644 xmake/repository/templates/csharp/shared/xmake.lua create mode 100644 xmake/repository/templates/csharp/static/src/foo.cs create mode 100644 xmake/repository/templates/csharp/static/src/main.cs create mode 100644 xmake/repository/templates/csharp/static/xmake.lua (limited to 'tests/projects/csharp/multiple_library/src/libalpha/Alpha.cs') diff --git a/tests/projects/csharp/console_with_runtime_json/src/Program.cs b/tests/projects/csharp/console_with_runtime_json/src/Program.cs index 2c9b0783b..690faf873 100644 --- a/tests/projects/csharp/console_with_runtime_json/src/Program.cs +++ b/tests/projects/csharp/console_with_runtime_json/src/Program.cs @@ -1,8 +1,7 @@ using System.Text.Json; var runtimeFile = Path.Combine(AppContext.BaseDirectory, "runtime.json"); -if (!File.Exists(runtimeFile)) -{ +if (!File.Exists(runtimeFile)) { Console.WriteLine("runtime.json missing"); return; } @@ -14,4 +13,3 @@ var runtime = doc.RootElement.TryGetProperty("runtime", out var value) : "unknown"; Console.WriteLine($"runtime={runtime}"); - diff --git a/tests/projects/csharp/exe_with_library/src/lib/Greeter.cs b/tests/projects/csharp/exe_with_library/src/lib/Greeter.cs index 546dd4b6f..cf895138a 100644 --- a/tests/projects/csharp/exe_with_library/src/lib/Greeter.cs +++ b/tests/projects/csharp/exe_with_library/src/lib/Greeter.cs @@ -1,10 +1,7 @@ namespace MyLib; -public static class Greeter -{ - public static string Greet(string name) - { +public static class Greeter { + public static string Greet(string name) { return $"hello {name}!"; } } - diff --git a/tests/projects/csharp/multiple_library/src/libalpha/Alpha.cs b/tests/projects/csharp/multiple_library/src/libalpha/Alpha.cs index f203d9c9e..a10ed6d73 100644 --- a/tests/projects/csharp/multiple_library/src/libalpha/Alpha.cs +++ b/tests/projects/csharp/multiple_library/src/libalpha/Alpha.cs @@ -1,10 +1,7 @@ namespace LibAlpha; -public static class Alpha -{ - public static string Message() - { +public static class Alpha { + public static string Message() { return "alpha"; } } - diff --git a/tests/projects/csharp/multiple_library/src/libbeta/Beta.cs b/tests/projects/csharp/multiple_library/src/libbeta/Beta.cs index 5e431039f..c96944dc5 100644 --- a/tests/projects/csharp/multiple_library/src/libbeta/Beta.cs +++ b/tests/projects/csharp/multiple_library/src/libbeta/Beta.cs @@ -2,11 +2,8 @@ using LibAlpha; namespace LibBeta; -public static class Beta -{ - public static string Message() - { +public static class Beta { + public static string Message() { return Alpha.Message() + "+beta"; } } - diff --git a/xmake/repository/templates/csharp/console/src/Program.cs b/xmake/repository/templates/csharp/console/src/Program.cs new file mode 100644 index 000000000..5f75209cb --- /dev/null +++ b/xmake/repository/templates/csharp/console/src/Program.cs @@ -0,0 +1,9 @@ +using System; + +namespace ${TARGET_NAME}; + +class Program { + static void Main(string[] args) { + Console.WriteLine("Hello, xmake!"); + } +} diff --git a/xmake/repository/templates/csharp/console/xmake.lua b/xmake/repository/templates/csharp/console/xmake.lua new file mode 100644 index 000000000..d19ce0fcd --- /dev/null +++ b/xmake/repository/templates/csharp/console/xmake.lua @@ -0,0 +1,7 @@ +add_rules("mode.debug", "mode.release") + +target("${TARGET_NAME}") + set_kind("binary") + add_files("src/*.cs") + +${FAQ} diff --git a/xmake/repository/templates/csharp/shared/src/foo.cs b/xmake/repository/templates/csharp/shared/src/foo.cs new file mode 100644 index 000000000..bba30d999 --- /dev/null +++ b/xmake/repository/templates/csharp/shared/src/foo.cs @@ -0,0 +1,7 @@ +namespace Foo; + +public class Foo { + public static int Add(int a, int b) { + return a + b; + } +} diff --git a/xmake/repository/templates/csharp/shared/src/main.cs b/xmake/repository/templates/csharp/shared/src/main.cs new file mode 100644 index 000000000..c2e4eb2fd --- /dev/null +++ b/xmake/repository/templates/csharp/shared/src/main.cs @@ -0,0 +1,7 @@ +using System; + +class Program { + static void Main(string[] args) { + Console.WriteLine("add(1, 2) = {0}", Foo.Foo.Add(1, 2)); + } +} diff --git a/xmake/repository/templates/csharp/shared/xmake.lua b/xmake/repository/templates/csharp/shared/xmake.lua new file mode 100644 index 000000000..256ed0f65 --- /dev/null +++ b/xmake/repository/templates/csharp/shared/xmake.lua @@ -0,0 +1,10 @@ +target("foo") + set_kind("shared") + add_files("src/foo.cs") + +target("${TARGET_NAME}_demo") + set_kind("binary") + add_deps("foo") + add_files("src/main.cs") + +${FAQ} diff --git a/xmake/repository/templates/csharp/static/src/foo.cs b/xmake/repository/templates/csharp/static/src/foo.cs new file mode 100644 index 000000000..bba30d999 --- /dev/null +++ b/xmake/repository/templates/csharp/static/src/foo.cs @@ -0,0 +1,7 @@ +namespace Foo; + +public class Foo { + public static int Add(int a, int b) { + return a + b; + } +} diff --git a/xmake/repository/templates/csharp/static/src/main.cs b/xmake/repository/templates/csharp/static/src/main.cs new file mode 100644 index 000000000..c2e4eb2fd --- /dev/null +++ b/xmake/repository/templates/csharp/static/src/main.cs @@ -0,0 +1,7 @@ +using System; + +class Program { + static void Main(string[] args) { + Console.WriteLine("add(1, 2) = {0}", Foo.Foo.Add(1, 2)); + } +} diff --git a/xmake/repository/templates/csharp/static/xmake.lua b/xmake/repository/templates/csharp/static/xmake.lua new file mode 100644 index 000000000..51bce92a0 --- /dev/null +++ b/xmake/repository/templates/csharp/static/xmake.lua @@ -0,0 +1,10 @@ +target("foo") + set_kind("static") + add_files("src/foo.cs") + +target("${TARGET_NAME}_demo") + set_kind("binary") + add_deps("foo") + add_files("src/main.cs") + +${FAQ} -- cgit v1.3.1