From 6fcc2a7704cfb1341fc7d6e3d12c4efbb1fbd899 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sun, 13 Sep 2026 21:09:16 +0200 Subject: [PATCH] Stop MessagePack's source generator flowing to consumers A direct MessagePackAnalyzer reference with PrivateAssets="all" in Caching.MessagePack and Networking keeps MessagePack 3's generator out of consumer builds, where it emitted a reference to a nonexistent GeneratedMessagePackResolver formatter for Dictionary, float> (CS0426). CultLib composes StandardResolver itself and never registers a generated resolver. tests/GameCult.Caching.ConsumerBuild is RefKeyedDictionaryCompilesInAConsumer: its build is the test. On 825b4f7 it failed with CS0426; now it builds and obj has no MessagePack.SourceGenerator output. Co-Authored-By: Claude Opus 5 --- CultLib.sln | 15 +++++++++++++++ .../GameCult.Caching.MessagePack.csproj | 1 + .../GameCult.Networking.csproj | 1 + .../GameCult.Caching.ConsumerBuild.csproj | 16 ++++++++++++++++ tests/GameCult.Caching.ConsumerBuild/Program.cs | 14 ++++++++++++++ 5 files changed, 47 insertions(+) create mode 100644 tests/GameCult.Caching.ConsumerBuild/GameCult.Caching.ConsumerBuild.csproj create mode 100644 tests/GameCult.Caching.ConsumerBuild/Program.cs diff --git a/CultLib.sln b/CultLib.sln index 2b50a153..c60890ca 100644 --- a/CultLib.sln +++ b/CultLib.sln @@ -51,6 +51,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CultMath", "packages\cultma EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CultMath.Tests", "packages\cultmath\tests\CultMath.Tests\CultMath.Tests.csproj", "{FEF9DA88-2177-4FD0-885D-7096ACFA8A9D}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GameCult.Caching.ConsumerBuild", "tests\GameCult.Caching.ConsumerBuild\GameCult.Caching.ConsumerBuild.csproj", "{D3138F3C-9531-4906-A5D3-74BD857D0685}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -289,6 +291,18 @@ Global {FEF9DA88-2177-4FD0-885D-7096ACFA8A9D}.Release|x64.Build.0 = Release|Any CPU {FEF9DA88-2177-4FD0-885D-7096ACFA8A9D}.Release|x86.ActiveCfg = Release|Any CPU {FEF9DA88-2177-4FD0-885D-7096ACFA8A9D}.Release|x86.Build.0 = Release|Any CPU + {D3138F3C-9531-4906-A5D3-74BD857D0685}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D3138F3C-9531-4906-A5D3-74BD857D0685}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D3138F3C-9531-4906-A5D3-74BD857D0685}.Debug|x64.ActiveCfg = Debug|Any CPU + {D3138F3C-9531-4906-A5D3-74BD857D0685}.Debug|x64.Build.0 = Debug|Any CPU + {D3138F3C-9531-4906-A5D3-74BD857D0685}.Debug|x86.ActiveCfg = Debug|Any CPU + {D3138F3C-9531-4906-A5D3-74BD857D0685}.Debug|x86.Build.0 = Debug|Any CPU + {D3138F3C-9531-4906-A5D3-74BD857D0685}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D3138F3C-9531-4906-A5D3-74BD857D0685}.Release|Any CPU.Build.0 = Release|Any CPU + {D3138F3C-9531-4906-A5D3-74BD857D0685}.Release|x64.ActiveCfg = Release|Any CPU + {D3138F3C-9531-4906-A5D3-74BD857D0685}.Release|x64.Build.0 = Release|Any CPU + {D3138F3C-9531-4906-A5D3-74BD857D0685}.Release|x86.ActiveCfg = Release|Any CPU + {D3138F3C-9531-4906-A5D3-74BD857D0685}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -314,5 +328,6 @@ Global {B48EAE30-152F-01E3-6E31-82B350494D3C} = {809F86A1-1C4C-B159-0CD4-DF9D33D876CE} {54D543F7-8EB7-4A11-977E-22D3EE2D8C3F} = {B48EAE30-152F-01E3-6E31-82B350494D3C} {FEF9DA88-2177-4FD0-885D-7096ACFA8A9D} = {B48EAE30-152F-01E3-6E31-82B350494D3C} + {D3138F3C-9531-4906-A5D3-74BD857D0685} = {39D316AB-ABB5-49A2-8E83-CAF4C75B48F4} EndGlobalSection EndGlobal diff --git a/src/GameCult.Caching.MessagePack/GameCult.Caching.MessagePack.csproj b/src/GameCult.Caching.MessagePack/GameCult.Caching.MessagePack.csproj index 24e7a48e..b089c776 100644 --- a/src/GameCult.Caching.MessagePack/GameCult.Caching.MessagePack.csproj +++ b/src/GameCult.Caching.MessagePack/GameCult.Caching.MessagePack.csproj @@ -10,5 +10,6 @@ + diff --git a/src/GameCult.Networking/GameCult.Networking.csproj b/src/GameCult.Networking/GameCult.Networking.csproj index f275484f..951cc1cc 100644 --- a/src/GameCult.Networking/GameCult.Networking.csproj +++ b/src/GameCult.Networking/GameCult.Networking.csproj @@ -11,6 +11,7 @@ OutputItemType="Analyzer" ReferenceOutputAssembly="false" /> + diff --git a/tests/GameCult.Caching.ConsumerBuild/GameCult.Caching.ConsumerBuild.csproj b/tests/GameCult.Caching.ConsumerBuild/GameCult.Caching.ConsumerBuild.csproj new file mode 100644 index 00000000..a05b8113 --- /dev/null +++ b/tests/GameCult.Caching.ConsumerBuild/GameCult.Caching.ConsumerBuild.csproj @@ -0,0 +1,16 @@ + + + Exe + net10.0 + enable + false + true + + + + + + + diff --git a/tests/GameCult.Caching.ConsumerBuild/Program.cs b/tests/GameCult.Caching.ConsumerBuild/Program.cs new file mode 100644 index 00000000..b0f15973 --- /dev/null +++ b/tests/GameCult.Caching.ConsumerBuild/Program.cs @@ -0,0 +1,14 @@ +using System.Collections.Generic; +using GameCult.Caching; +using MessagePack; + +// RefKeyedDictionaryCompilesInAConsumer: this project building is the test. +System.Console.WriteLine(new ConsumerFaction().Standing.Count); + +[CultDocument("tests.consumer_faction", "tests.consumer_faction.v1")] +[MessagePackObject] +public sealed class ConsumerFaction +{ + [Key(0)] [CultName] public string Name { get; set; } = string.Empty; + [Key(1)] public Dictionary, float> Standing { get; set; } = new(); +}