summaryrefslogtreecommitdiff
path: root/tests/projects/csharp/console_with_runtime_json/src/Program.cs
blob: fd836a339c7773f3c52967dd27dede20ad16766c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
using System.Text.Json;

var runtimeFile = Path.Combine(Directory.GetCurrentDirectory(), "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}");