Assume CultRecordRef<T> formattable for MessagePack's source generator consumers
The package ships MessagePackAssumedFormattable(typeof(CultRecordRef<>)) as an MSBuild AssemblyAttribute in buildTransitive, so generated resolvers defer the ref to CultDocumentResolver. Geometry imports the targets and drops its three per-member [MessagePackFormatter] workarounds. GeneratorConsumer is the generator-on twin of ConsumerBuild. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
b7a68884c6
commit
5c55f9cb15
9 changed files with 162 additions and 3 deletions
|
|
@ -11,5 +11,6 @@
|
|||
<PackageReference Include="System.Text.Json" Version="9.0.10" />
|
||||
<PackageReference Include="MessagePackAnalyzer" Version="3.1.7" PrivateAssets="all" />
|
||||
<InternalsVisibleTo Include="GameCult.Caching.Tests" />
|
||||
<None Include="buildTransitive\GameCult.Caching.MessagePack.targets" Pack="true" PackagePath="buildTransitive\" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -59,6 +59,13 @@ await cache.PullAllBackingStoresAsync();
|
|||
- The raw CultNet document lane should treat these payload bytes as already
|
||||
blessed, not decode and re-encode them for sport.
|
||||
|
||||
## MessagePack source generator
|
||||
|
||||
NuGet consumers get `[assembly: MessagePackAssumedFormattable(typeof(CultRecordRef<>))]` from the package, so a
|
||||
`CultRecordRef<T>` member or dictionary key compiles with MessagePack's source generator on and is formatted by
|
||||
CultLib's resolver; no per-member `[MessagePackFormatter]` is needed. Unity and `ProjectReference` consumers that turn the generator
|
||||
on write that line themselves (or import `buildTransitive/GameCult.Caching.MessagePack.targets`).
|
||||
|
||||
## CultMath Value Shapes
|
||||
|
||||
Every public CultMath value type has one MessagePack shape (`CultMathResolver`,
|
||||
|
|
|
|||
|
|
@ -0,0 +1,9 @@
|
|||
<Project>
|
||||
<!-- MessagePack's source generator invents a formatter for CultRecordRef<T> instead of asking the resolver chain (MessagePack-CSharp#2133); assuming it formattable leaves the ref to CultDocumentResolver. -->
|
||||
<ItemGroup>
|
||||
<AssemblyAttribute Include="MessagePack.MessagePackAssumedFormattableAttribute">
|
||||
<_Parameter1>typeof(global::GameCult.Caching.CultRecordRef<>)</_Parameter1>
|
||||
<_Parameter1_IsLiteral>true</_Parameter1_IsLiteral>
|
||||
</AssemblyAttribute>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
@ -161,7 +161,6 @@ namespace GameCult.Geometry
|
|||
public string RequestId { get; set; } = string.Empty;
|
||||
|
||||
[Key(1)]
|
||||
[MessagePackFormatter(typeof(CultRecordRefFormatter<CultGeometryDomainDocument>))]
|
||||
public CultRecordRef<CultGeometryDomainDocument> DomainKey { get; set; }
|
||||
|
||||
[Key(2)]
|
||||
|
|
@ -236,7 +235,6 @@ namespace GameCult.Geometry
|
|||
public string CutId { get; set; } = string.Empty;
|
||||
|
||||
[Key(1)]
|
||||
[MessagePackFormatter(typeof(CultRecordRefFormatter<CultGeometryBuildRequest>))]
|
||||
public CultRecordRef<CultGeometryBuildRequest> RequestKey { get; set; }
|
||||
|
||||
[Key(2)]
|
||||
|
|
@ -325,7 +323,6 @@ namespace GameCult.Geometry
|
|||
public string ChunkId { get; set; } = string.Empty;
|
||||
|
||||
[Key(1)]
|
||||
[MessagePackFormatter(typeof(CultRecordRefFormatter<CultGeometrySelectedCutManifest>))]
|
||||
public CultRecordRef<CultGeometrySelectedCutManifest> CutKey { get; set; }
|
||||
|
||||
[Key(2)]
|
||||
|
|
|
|||
|
|
@ -15,6 +15,8 @@
|
|||
<PackageReference Include="System.Text.Json" Version="9.0.10" />
|
||||
</ItemGroup>
|
||||
|
||||
<Import Project="..\GameCult.Caching.MessagePack\buildTransitive\GameCult.Caching.MessagePack.targets" />
|
||||
|
||||
<ItemGroup>
|
||||
<None Include="README.md" Pack="true" PackagePath="\" />
|
||||
<None Include="ISOSURFACE-PROVENANCE.md" Pack="true" PackagePath="\" />
|
||||
|
|
|
|||
Loading…
Reference in a new issue