using System.Reflection; using AcDream.Core.Physics; using AcDream.Headless.Configuration; namespace AcDream.Headless.Hosting; /// /// Rejects process-global physics probes whose mutable capture cursors and /// last-hit fields cannot be attributed safely when several Runtime roots /// share one process. Ordinary diagnostics remain session-labelled through /// . /// internal static class HeadlessStaticStateAudit { internal static void ValidateProcessIsolation() { var enabled = new List(); foreach (PropertyInfo property in typeof(PhysicsDiagnostics) .GetProperties(BindingFlags.Public | BindingFlags.Static) .OrderBy(static property => property.Name, StringComparer.Ordinal)) { if (property.PropertyType != typeof(bool) || property.GetMethod is null || (!property.Name.StartsWith( "Probe", StringComparison.Ordinal) && !property.Name.StartsWith( "Dump", StringComparison.Ordinal))) { continue; } if (property.GetValue(null) is true) enabled.Add(property.Name); } if (PhysicsDiagnostics.CollisionShadowSampleEvery > 0) enabled.Add(nameof(PhysicsDiagnostics.CollisionShadowSampleEvery)); if (PhysicsResolveCapture.IsEnabled) enabled.Add(nameof(PhysicsResolveCapture)); if (enabled.Count != 0) { throw new HeadlessConfigurationException( "Multi-session headless mode cannot use process-global " + "physics probes. Disable: " + string.Join(", ", enabled)); } } }