diff options
| author | JassJam <[email protected]> | 2026-02-23 12:28:50 +0000 |
|---|---|---|
| committer | ruki <[email protected]> | 2026-03-14 00:08:40 +0800 |
| commit | 9946d1814f4af9ef67e5accd9404e0fc69290f6f (patch) | |
| tree | f669ea003ab4947aabb7732696aefa4e62f5793c /tests/projects/csharp/console_with_runtime_json | |
| parent | 95fa1f158a4044b9851ce6c0f4ff21f3427ce83e (diff) | |
feat: add initial test files
Diffstat (limited to 'tests/projects/csharp/console_with_runtime_json')
6 files changed, 61 insertions, 0 deletions
diff --git a/tests/projects/csharp/console_with_runtime_json/.gitignore b/tests/projects/csharp/console_with_runtime_json/.gitignore new file mode 100644 index 000000000..53e577525 --- /dev/null +++ b/tests/projects/csharp/console_with_runtime_json/.gitignore @@ -0,0 +1,7 @@ +.xmake/ +build/ +bin/ +obj/ +vsxmake*/ +.vs/ + diff --git a/tests/projects/csharp/console_with_runtime_json/src/Program.cs b/tests/projects/csharp/console_with_runtime_json/src/Program.cs new file mode 100644 index 000000000..2c9b0783b --- /dev/null +++ b/tests/projects/csharp/console_with_runtime_json/src/Program.cs @@ -0,0 +1,17 @@ +using System.Text.Json; + +var runtimeFile = Path.Combine(AppContext.BaseDirectory, "runtime.json"); +if (!File.Exists(runtimeFile)) +{ + Console.WriteLine("runtime.json missing"); + return; +} + +var json = File.ReadAllText(runtimeFile); +using var doc = JsonDocument.Parse(json); +var runtime = doc.RootElement.TryGetProperty("runtime", out var value) + ? value.GetString() + : "unknown"; + +Console.WriteLine($"runtime={runtime}"); + diff --git a/tests/projects/csharp/console_with_runtime_json/src/app.csproj b/tests/projects/csharp/console_with_runtime_json/src/app.csproj new file mode 100644 index 000000000..4e754bb15 --- /dev/null +++ b/tests/projects/csharp/console_with_runtime_json/src/app.csproj @@ -0,0 +1,14 @@ +<Project Sdk="Microsoft.NET.Sdk"> + <PropertyGroup> + <OutputType>Exe</OutputType> + <TargetFramework>net8.0</TargetFramework> + <ImplicitUsings>enable</ImplicitUsings> + <Nullable>enable</Nullable> + </PropertyGroup> + <ItemGroup> + <None Include="runtime.json"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </None> + </ItemGroup> +</Project> + diff --git a/tests/projects/csharp/console_with_runtime_json/src/runtime.json b/tests/projects/csharp/console_with_runtime_json/src/runtime.json new file mode 100644 index 000000000..15bec810d --- /dev/null +++ b/tests/projects/csharp/console_with_runtime_json/src/runtime.json @@ -0,0 +1,7 @@ +{ + "runtime": "xmake", + "featureFlags": { + "sample": true + } +} + diff --git a/tests/projects/csharp/console_with_runtime_json/test.lua b/tests/projects/csharp/console_with_runtime_json/test.lua new file mode 100644 index 000000000..5ab8adc69 --- /dev/null +++ b/tests/projects/csharp/console_with_runtime_json/test.lua @@ -0,0 +1,10 @@ +import("lib.detect.find_tool") + +function test_build(t) + local dotnet = find_tool("dotnet") + if dotnet then + t:build() + else + return t:skip("dotnet not found") + end +end diff --git a/tests/projects/csharp/console_with_runtime_json/xmake.lua b/tests/projects/csharp/console_with_runtime_json/xmake.lua new file mode 100644 index 000000000..8d8539b26 --- /dev/null +++ b/tests/projects/csharp/console_with_runtime_json/xmake.lua @@ -0,0 +1,6 @@ +add_rules("mode.debug", "mode.release") + +target("app") + set_kind("binary") + add_rules("csharp") + add_files("src/Program.cs", "src/app.csproj") |
