INNER CODE UNIT · C#

ExpandPath

axmolengine/axmol · tools/bindings-generator/src/BatchGeneration.cs:246

    private static string ExpandPath(string value, string repositoryRoot) =>
        Regex.Replace(value.Trim('"'), @"%\([^)]+\)s", repositoryRoot).Replace('\\', '/');

    private static string RequiredString(JsonElement root, string name)
    {
        if (!root.TryGetProperty(name, out var value) || value.ValueKind != JsonValueKind.String ||
            string.IsNullOrWhiteSpace(value.GetString()))
            throw new InvalidDataException($"'{name}' must be a non-empty string.");
        return value.GetString()!;
    }

    private static string? OptionalString(JsonElement root, string name)
    {
        if (!root.TryGetProperty(name, out var value) || value.ValueKind == JsonValueKind.Null)
            return null;
        if (value.ValueKind != JsonValueKind.String)
            throw new InvalidDataException($"'{name}' must be a string or null.");
        return value.GetString();

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…