47 lines
1.6 KiB
C#
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 { }
|