Files
Workspace/Godot/Tests/NuGetConsumer/Program.cs
T
cneicy 88ba3cdc48
Validate ShrinkSDK Workspace / unity (push) Failing after 3m18s
feat: add Godot C# compatibility and shared codegen weaving
2026-09-05 02:37:43 +08:00

47 lines
1.6 KiB
C#

#nullable enable
using System;
using System.Linq;
using ShrinkCommand;
using ShrinkEventBus;
using ShrinkNetwork;
using ShrinkSDK.Runtime;
var assembly = typeof(Program).Assembly;
var marker = assembly.GetCustomAttributes(typeof(ShrinkCodeGenWovenAttribute), false)
.Cast<ShrinkCodeGenWovenAttribute>().SingleOrDefault()
?? throw new InvalidOperationException("buildTransitive CodeGen did not run.");
using var binding = EventBus.Attach(new NuGetSubscriber());
EventBus.Post(new NuGetEvent());
if (NuGetSubscriber.Calls != 1 || NuGetStaticSubscriber.Calls != 1)
throw new InvalidOperationException("NuGet EventBus weaving failed.");
if (assembly.GetCustomAttributes(typeof(ShrinkCommandStaticRegistryAttribute), false).Length != 1 ||
assembly.GetCustomAttributes(typeof(ShrinkNetworkMessageRegistryAttribute), false).Length != 1)
throw new InvalidOperationException("NuGet registries are missing.");
Console.WriteLine($"PASS NuGet buildTransitive CodeGen {marker.WeaverVersion}");
public readonly struct NuGetEvent : IShrinkEvent { }
[ShrinkEventSubscriber]
public sealed class NuGetSubscriber
{
public static int Calls;
[ShrinkSubscribe] private void Handle(NuGetEvent value) => Calls++;
}
[ShrinkEventSubscriber]
public static class NuGetStaticSubscriber
{
public static int Calls;
[ShrinkSubscribe] private static void Handle(NuGetEvent value) => Calls++;
}
[ShrinkCommandSubscriber]
public static class NuGetCommands
{
[ShrinkCommand("nuget/smoke")] public static void Smoke() { }
}
[ShrinkNetworkMessage(43001, "nuget/smoke")]
public sealed class NuGetMessage : IShrinkNetworkMessage { }