Skip to content

Annotate Storage/Registry reflective surface for AOT (closes #73)#77

Merged
jeremydmiller merged 1 commit into
mainfrom
feature/aot-storage-73
May 13, 2026
Merged

Annotate Storage/Registry reflective surface for AOT (closes #73)#77
jeremydmiller merged 1 commit into
mainfrom
feature/aot-storage-73

Conversation

@jeremydmiller

Copy link
Copy Markdown
Member

Summary

Annotate Polecat's document-store core (DocumentMapping, DocumentProviderRegistry, DocumentProvider, DocumentMappingExpression, DocumentStore.EventStoreExplorer) so AOT smoke tests can run under WarningsAsErrors=IL*. Slice 4 of the AOT pillar (after #67 base config, #74 serializer, #75 ProjectionReplay, #76 LINQ).

The document type T flows in from caller code at the registration boundary (Schema.For<T>()), so trimming sees and preserves T plus its public surface. AOT consumers must swap in a source-generator-backed ISerializer impl and preserve subclass types per the AOT publishing guide.

Applied class-level [UnconditionalSuppressMessage]:

  • Storage/DocumentMapping — IL2026 (Assembly.GetTypes() in AddSubClassHierarchy), IL2070 (PublicProperties discovery for Id / [Index] / [UniqueIndex])
  • Storage/DocumentMappingExpression — IL2026 (Assembly.GetTypes() subclass discovery)
  • Internal/DocumentProviderRegistry — IL2075 (non-public field reflection on DocumentMappingExpression<T>)
  • Internal/DocumentProvider — IL2026/IL3050 (consumer of ISerializer.ToJson)
  • DocumentStore.EventStoreExplorer — IL2026/IL2075/IL3050 (reflective Task<T>.Result extraction + MethodInfo.MakeGenericMethod for RehydrateAtVersionByNameAsync; ISerializer.ToJson)

Warning delta

Polecat.csproj IL warnings on this branch: 422 → 336 (-86).

Independent of #75 (ProjectionReplay) and #76 (LINQ); when all three land together, total will drop substantially further.

Test plan

  • dotnet build src/Polecat/Polecat.csproj -c Debug — no new errors, -86 IL warnings
  • dotnet build src/Polecat.Tests/Polecat.Tests.csproj -c Debug — green
  • CI passes

🤖 Generated with Claude Code

The document-store core reflects against the document Type at multiple
boundaries: DocumentMapping discovers the Id property + index/foreign-key
attributes, DocumentMappingExpression auto-discovers subclass hierarchies
via Assembly.GetTypes(), DocumentProviderRegistry reads non-public
SubClasses/Indexes/ForeignKeys fields off the expression via reflection,
and DocumentProvider serializes documents through ISerializer (RUC/RDC).
DocumentStore.EventStoreExplorer reflects on Task<T>.Result and uses
MethodInfo.MakeGenericMethod for the by-name RehydrateAtVersion overload.

The document type T flows in from caller code at the registration boundary
(Schema.For<T>()), so trimming sees and preserves T. AOT consumers must
swap in a source-generator-backed ISerializer impl and preserve subclass
types per the AOT publishing guide.

Apply class-level [UnconditionalSuppressMessage] with justifications:
- Storage/DocumentMapping: IL2026 (Assembly.GetTypes), IL2070 (PublicProperties)
- Storage/DocumentMappingExpression: IL2026 (Assembly.GetTypes)
- Internal/DocumentProviderRegistry: IL2075 (FieldInfo.GetValue cast)
- Internal/DocumentProvider: IL2026/IL3050 (ISerializer.ToJson)
- DocumentStore.EventStoreExplorer: IL2026/IL2075/IL3050 (RehydrateAtVersionByName
  reflective Task<T>.Result extraction + MakeGenericMethod; ISerializer.ToJson)

422 → 336 warnings (-86) in Polecat.csproj on this branch.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@jeremydmiller jeremydmiller merged commit 572a2f5 into main May 13, 2026
6 checks passed
jeremydmiller added a commit that referenced this pull request May 13, 2026
Two updates to keep the migration-guide accurate as the 2026-wave alphas
roll forward:

- Bump the foundation-pin table to current Polecat 4 alpha versions:
  JasperFx alpha.8 → alpha.11, JasperFx.Events alpha.3 → alpha.4,
  Weasel.* alpha.2 → alpha.3. Note that the alpha line is still rolling
  forward and consumers should pin all five together.

- Rewrite the AOT / codegen posture section to reflect the actual landed
  state: IsAotCompatible=true is set on the Polecat assembly (#67), and
  the reflective surfaces have been progressively annotated through #74
  (serialization), #75 (projection replay), #76 (LINQ extension/provider),
  and #77 (storage / registry / event-store explorer). Link out to the
  cross-stack "Publishing AOT with JasperFx" guide on jasperfx.github.io
  for the end-to-end walkthrough.

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
jeremydmiller added a commit that referenced this pull request May 13, 2026
Fifth slice in Polecat's AOT-pillar (jasperfx#213) cleanup, following the
Serializer (#74), ProjectionReplay (#75), LINQ (#76), and Storage/Registry
(#77) slices that have landed on main.

The patching subsystem reflects on the document's property expressions to
build JSON path strings and feeds the resulting patch values through
ISerializer.ToJson when emitting JSON_MODIFY() SQL. JsonPathHelper also
compiles small Expression.Lambda delegates to evaluate constant sub-
expressions during path resolution. Document types T flow in from
Schema.For<T>() / IDocumentSession.Patch<T>() at the registration boundary
and are preserved per the AOT publishing guide; AOT consumers supply a
source-generator-backed ISerializer impl.

Apply class-level [UnconditionalSuppressMessage] with justifications:

- Patching/PatchExpression<T>: IL2026/IL3050 (ISerializer.ToJson on
  patch values)
- Patching/PatchOperation: IL2026/IL3050 (ISerializer.ToJson when
  building JSON_MODIFY commands)
- Patching/JsonPathHelper: IL3050 (Expression.Lambda for constant
  sub-expression evaluation)

194 → 152 unique IL warnings (-42) in Polecat.csproj.

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@jeremydmiller jeremydmiller deleted the feature/aot-storage-73 branch May 14, 2026 15:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant