Skip to content

feat: trim/AOT annotations (RequiresUnreferencedCode/RequiresDynamicCode)#6

Merged
ChrisonSimtian merged 1 commit into
mainfrom
feat/trim-aot-annotations
Jul 24, 2026
Merged

feat: trim/AOT annotations (RequiresUnreferencedCode/RequiresDynamicCode)#6
ChrisonSimtian merged 1 commit into
mainfrom
feat/trim-aot-annotations

Conversation

@ChrisonSimtian

Copy link
Copy Markdown
Collaborator

Final modernization workstream — the AOT axis, done honestly per the design fork.

Why annotations, not a source-gen rewrite: Scrutor's .Scan() is runtime assembly reflection and fundamentally isn't trim/AOT-safe. Removing our MakeGenericMethod while still using Scrutor's scan would gain nothing. So the truthful move (while staying a Scrutor extension) is to declare the requirement.

  • Public AsHttpClient overloads now carry [RequiresUnreferencedCode] + [RequiresDynamicCode] (net8.0+) → trim/AOT consumers get a warning at the call site instead of silent breakage.
  • Enabled EnableTrimAnalyzer/EnableAotAnalyzer on the net8.0 build to self-validate. Only IL3050 (MakeGenericMethod) surfaced — suppressed at that one site with justification (the Apply override can't carry Requires*; the public entry points already warn callers).
  • Guarded by NET8_0_OR_GREATER (attrs/analyzers absent on netstandard2.0, where trim/AOT isn't a concern).
  • PublicApiGenerator baseline updated to include the attributes.

0 warnings both TFMs; 7/7 specs pass.

…uiresDynamicCode])

Honest trim/AOT signal rather than a source-gen rewrite: the real blocker is
Scrutor's runtime assembly scan (fundamentally not trim/AOT-safe), so removing our
own reflection would gain nothing while staying a Scrutor extension. Instead, the
public AsHttpClient entry points now carry [RequiresUnreferencedCode] +
[RequiresDynamicCode] (net8.0+), so consumers building trimmed/AOT get accurate
warnings at the call site instead of silent breakage.

- Enable EnableTrimAnalyzer + EnableAotAnalyzer on the net8.0 target to self-validate
  the annotations. Only IL3050 (MakeGenericMethod) surfaced; suppressed at that site
  with [UnconditionalSuppressMessage] + justification (the override can't carry
  Requires*; the public entry points already warn callers).
- Attributes/usings guarded by NET8_0_OR_GREATER (the attrs + analyzers don't exist
  on netstandard2.0, where trimming/AOT isn't a concern).
- Public API baseline updated to include the new attributes.

Build clean (0 warnings both TFMs); all 7 specs pass.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@ChrisonSimtian ChrisonSimtian added the feature New feature label Jul 24, 2026
@ChrisonSimtian
ChrisonSimtian merged commit 2dd1f8d into main Jul 24, 2026
1 check passed
@ChrisonSimtian
ChrisonSimtian deleted the feat/trim-aot-annotations branch July 24, 2026 03:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant