summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2026-03-16 23:45:18 +0800
committerruki <[email protected]>2026-03-16 23:45:18 +0800
commitde6664486ef54cf7d3b50b45074539fb413e583c (patch)
tree6dd33b520e2317dbe93946287814f63a9c6af657
parentbf997637e98558b7289e8f9b3d05b08d102bb8af (diff)
format csharp codes
-rw-r--r--tests/projects/csharp/console_with_runtime_json/src/Program.cs4
-rw-r--r--tests/projects/csharp/exe_with_library/src/lib/Greeter.cs7
-rw-r--r--tests/projects/csharp/multiple_library/src/libalpha/Alpha.cs7
-rw-r--r--tests/projects/csharp/multiple_library/src/libbeta/Beta.cs7
-rw-r--r--xmake/repository/templates/csharp/console/src/Program.cs9
-rw-r--r--xmake/repository/templates/csharp/console/xmake.lua7
-rw-r--r--xmake/repository/templates/csharp/shared/src/foo.cs7
-rw-r--r--xmake/repository/templates/csharp/shared/src/main.cs7
-rw-r--r--xmake/repository/templates/csharp/shared/xmake.lua10
-rw-r--r--xmake/repository/templates/csharp/static/src/foo.cs7
-rw-r--r--xmake/repository/templates/csharp/static/src/main.cs7
-rw-r--r--xmake/repository/templates/csharp/static/xmake.lua10
12 files changed, 71 insertions, 18 deletions
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}