RynthCore/tools/HookResolver.Core/Resolution/ManifestBuilder.cs
Cursor Agent 4ddbb52eb2
feat: port aelrynth 2026.9.27.2 snapshot onto GitHub history
Overlay upstream/main (9b5e276) onto BlankenshipG main without rewriting
history. Keep origin-only Decal/plugin/docs trees. Re-apply aelrynth.com
and sibling-fork URL fixes that aelrynth git still has as tombohar links.

Co-authored-by: BlankenshipG <BlankenshipG@users.noreply.github.com>
2026-10-04 15:43:50 +00:00

46 lines
1.4 KiB
C#

using System;
using System.Collections.Generic;
using System.IO;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using RynthCore.HookManifest.Schema;
using Manifest = RynthCore.HookManifest.Schema.HookManifest;
namespace RynthCore.HookResolver.Core.Resolution;
public static class ManifestBuilder
{
public const string GeneratorName = "RynthCore.HookResolver 0.1.0";
public static Manifest Compose(
ManifestInput input,
IEnumerable<HookManifestEntry> entries,
IReadOnlyDictionary<string, string>? labels = null)
{
var dict = new Dictionary<string, HookManifestEntry>();
foreach (var e in entries)
dict[e.SymbolId] = e;
return new Manifest
{
Generator = GeneratorName,
GeneratedAtUtc = DateTime.UtcNow,
Input = input,
Labels = labels ?? new Dictionary<string, string>(),
Symbols = dict
};
}
public static async Task WriteAsync(Manifest manifest, string path, CancellationToken ct = default)
{
string? dir = Path.GetDirectoryName(path);
if (!string.IsNullOrEmpty(dir))
Directory.CreateDirectory(dir);
byte[] bytes = JsonSerializer.SerializeToUtf8Bytes(
manifest, HookManifestJsonContext.Default.HookManifest);
await File.WriteAllBytesAsync(path, bytes, ct).ConfigureAwait(false);
}
}