Use runtime-neutral command port defaults

This commit is contained in:
Meta Vens 2026-06-21 12:55:16 +01:00
commit 567e8cff81
2 changed files with 22 additions and 3 deletions

View file

@ -6799,6 +6799,8 @@ static void RequireTypedEveCommandBodies(string root)
"namespace Aetheria.State",
"namespace GameCult.Aetheria.State.Verse",
"global::Aetheria.State.AetheriaCommandPort",
"public const string DefaultRuntimeId = \"aetheria-command-client\"",
"string.IsNullOrWhiteSpace(runtimeId) ? DefaultRuntimeId : runtimeId",
"public static class AetheriaRuntimeCommandSubmitter",
"TrySubmitEveCommand(",
"TrySubmitDaemonCommand(",
@ -6888,6 +6890,21 @@ static void RequireTypedEveCommandBodies(string root)
string.Join(", ", unityNamedRuntimeHits));
}
var forbiddenSharedCommandRuntimeIds = new[]
{
"string runtimeId = \"unity-input-provider\"",
"? \"unity-input-provider\" : runtimeId"
};
var sharedCommandRuntimeIdHits = forbiddenSharedCommandRuntimeIds
.Where(symbol => runtimeCommandPort.Contains(symbol, StringComparison.Ordinal))
.ToArray();
if (sharedCommandRuntimeIdHits.Length > 0)
{
throw new InvalidOperationException(
"Shared command runtime still uses Unity-specific fallback runtime ids: " +
string.Join(", ", sharedCommandRuntimeIdHits));
}
var forbiddenUnitySubmitterSymbols = new[]
{
"AetheriaRuntimeCommandSubmitter.TrySubmitEveCommand(",

View file

@ -145,6 +145,8 @@ namespace GameCult.Aetheria.State.Verse
{
public sealed class AetheriaRuntimeCommandPort : IDisposable
{
public const string DefaultRuntimeId = "aetheria-command-client";
private readonly global::Aetheria.State.AetheriaCommandPort _port;
private AetheriaRuntimeCommandPort(global::Aetheria.State.AetheriaCommandPort port)
@ -156,11 +158,11 @@ namespace GameCult.Aetheria.State.Verse
public static async Task<AetheriaRuntimeCommandPort> OpenAsync(
string stateFilePath,
string runtimeId = "unity-input-provider")
string runtimeId = DefaultRuntimeId)
{
var port = await global::Aetheria.State.AetheriaCommandPort.OpenAsync(
stateFilePath,
string.IsNullOrWhiteSpace(runtimeId) ? "unity-input-provider" : runtimeId)
string.IsNullOrWhiteSpace(runtimeId) ? DefaultRuntimeId : runtimeId)
.ConfigureAwait(false);
return new AetheriaRuntimeCommandPort(port);
}
@ -242,7 +244,7 @@ namespace GameCult.Aetheria.State.Verse
private static AetheriaRuntimeCommandPort GetOrOpen(string stateFilePath, string runtimeId)
{
var fullPath = Path.GetFullPath(stateFilePath ?? "");
var key = $"{fullPath}|{(string.IsNullOrWhiteSpace(runtimeId) ? "unity-input-provider" : runtimeId)}";
var key = $"{fullPath}|{(string.IsNullOrWhiteSpace(runtimeId) ? AetheriaRuntimeCommandPort.DefaultRuntimeId : runtimeId)}";
lock (Sync)
{
if (Ports.TryGetValue(key, out var existing))