using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text.Json;
using XFEEDToolBox.Plugin;
var results=Enumerable.Range(0,8).Select(_=>Navigation.RunServiceFixture()).ToArray();
var report=new{sourceLinked=true,gameAccess=false,gameCalls=0,nativeAotBuilt=false,expected=255,results,passed=results.All(value=>value==255)};
var directory=Path.GetFullPath("artifacts/galaxy-service-facts-probe");Directory.CreateDirectory(directory);
File.WriteAllText(Path.Combine(directory,"result.json"),JsonSerializer.Serialize(report,new JsonSerializerOptions{WriteIndented=true}));
Console.WriteLine(JsonSerializer.Serialize(report));if(!report.passed)Environment.ExitCode=1;
namespace XFEEDToolBox.Plugin
{
// A bounded own-allocation memory host, not the game Platform. Production
// Copy/Mask/Source and the own-allocation fixture are linked unchanged.
internal static unsafe class Platform
{
private static readonly Dictionary<nuint,nuint> allocations=[];
internal static nuint Allocate(nuint size)
{var value=(nuint)NativeMemory.AllocZeroed(size);if(value!=0)allocations[value]=size;return value;}
internal static void Free(nuint address){allocations.Remove(address);NativeMemory.Free((void*)address);}
internal static byte[] ReadBytes(nuint address,int length)
{
if(!allocations.Any(pair=>address>=pair.Key&&address-pair.Key<=pair.Value&&(nuint)length<=pair.Value-(address-pair.Key)))throw new InvalidDataException("Outside owned fixture memory");
return new ReadOnlySpan<byte>((void*)address,length).ToArray();
}
internal static void Write<T>(nuint address,T value)where T:unmanaged
{ReadBytes(address,Unsafe.SizeOf<T>());Unsafe.Write((void*)address,value);}
}
internal static unsafe partial class Navigation
{
internal static uint RunServiceFixture()=>GalaxyServiceFactsSelfTest();
static T Read<T>(nuint address)where T:unmanaged=>MemoryMarshal.Read<T>(Platform.ReadBytes(address,Unsafe.SizeOf<T>()));
static nuint Pointer(nuint address)=>Read<nuint>(address);
static void Write<T>(nuint address,T value)where T:unmanaged=>Platform.Write(address,value);
static ulong GalaxyFactHash(ulong address)
{
unchecked{var hash=address*0x40000+~address;hash=((hash>>31)^hash)*0x15;hash=((hash>>11)^hash)*0x41;return(uint)(hash>>22)^(uint)hash;}
}
// Runtime entry declarations only. These guards are never exercised by
// the copy fixture; all game-facing entry conditions remain false.
static bool Enabled()=>false;
static bool inGame=>false;
static nuint image=>0;
static uint owningThread=>0;
static uint GetCurrentThreadId()=>0;
static ulong GetTickCount64()=>0;
static Snapshot Current()=>new();
static nuint RegisteredComponent(nuint registry,uint type)=>0;
internal sealed class Snapshot{internal bool valid=>false;internal ulong entity=>0;internal ulong referenceWorld=>0;}
internal sealed class GalaxyFilterContext{internal nuint expectedImage=>0;internal uint thread=>0;internal ulong tick=>0;internal ulong entity=>0;internal ulong currentSystem=>0;}
}
}
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text.Json;
using XFEEDToolBox.Plugin;
var results=Enumerable.Range(0,8).Select(_=>Navigation.RunServiceFixture()).ToArray();
var report=new{sourceLinked=true,gameAccess=false,gameCalls=0,nativeAotBuilt=false,expected=255,results,passed=results.All(value=>value==255)};
var directory=Path.GetFullPath("artifacts/galaxy-service-facts-probe");Directory.CreateDirectory(directory);
File.WriteAllText(Path.Combine(directory,"result.json"),JsonSerializer.Serialize(report,new JsonSerializerOptions{WriteIndented=true}));
Console.WriteLine(JsonSerializer.Serialize(report));if(!report.passed)Environment.ExitCode=1;
namespace XFEEDToolBox.Plugin
{
// A bounded own-allocation memory host, not the game Platform. Production
// Copy/Mask/Source and the own-allocation fixture are linked unchanged.
internal static unsafe class Platform
{
private static readonly Dictionary<nuint,nuint> allocations=[];
internal static nuint Allocate(nuint size)
{var value=(nuint)NativeMemory.AllocZeroed(size);if(value!=0)allocations[value]=size;return value;}
internal static void Free(nuint address){allocations.Remove(address);NativeMemory.Free((void*)address);}
internal static byte[] ReadBytes(nuint address,int length)
{
if(!allocations.Any(pair=>address>=pair.Key&&address-pair.Key<=pair.Value&&(nuint)length<=pair.Value-(address-pair.Key)))throw new InvalidDataException("Outside owned fixture memory");
return new ReadOnlySpan<byte>((void*)address,length).ToArray();
}
internal static void Write<T>(nuint address,T value)where T:unmanaged
{ReadBytes(address,Unsafe.SizeOf<T>());Unsafe.Write((void*)address,value);}
}
internal static unsafe partial class Navigation
{
internal static uint RunServiceFixture()=>GalaxyServiceFactsSelfTest();
static T Read<T>(nuint address)where T:unmanaged=>MemoryMarshal.Read<T>(Platform.ReadBytes(address,Unsafe.SizeOf<T>()));
static nuint Pointer(nuint address)=>Read<nuint>(address);
static void Write<T>(nuint address,T value)where T:unmanaged=>Platform.Write(address,value);
static ulong GalaxyFactHash(ulong address)
{
unchecked{var hash=address*0x40000+~address;hash=((hash>>31)^hash)*0x15;hash=((hash>>11)^hash)*0x41;return(uint)(hash>>22)^(uint)hash;}
}
// Runtime entry declarations only. These guards are never exercised by
// the copy fixture; all game-facing entry conditions remain false.
static bool Enabled()=>false;
static bool inGame=>false;
static nuint image=>0;
static uint owningThread=>0;
static uint GetCurrentThreadId()=>0;
static ulong GetTickCount64()=>0;
static Snapshot Current()=>new();
static nuint RegisteredComponent(nuint registry,uint type)=>0;
internal sealed class Snapshot{internal bool valid=>false;internal ulong entity=>0;internal ulong referenceWorld=>0;}
internal sealed class GalaxyFilterContext{internal nuint expectedImage=>0;internal uint thread=>0;internal ulong tick=>0;internal ulong entity=>0;internal ulong currentSystem=>0;}
}
}