feat: trim/AOT annotations (RequiresUnreferencedCode/RequiresDynamicCode)#6
Merged
Merged
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 ourMakeGenericMethodwhile still using Scrutor's scan would gain nothing. So the truthful move (while staying a Scrutor extension) is to declare the requirement.AsHttpClientoverloads now carry[RequiresUnreferencedCode]+[RequiresDynamicCode](net8.0+) → trim/AOT consumers get a warning at the call site instead of silent breakage.EnableTrimAnalyzer/EnableAotAnalyzeron the net8.0 build to self-validate. OnlyIL3050(MakeGenericMethod) surfaced — suppressed at that one site with justification (theApplyoverride can't carryRequires*; the public entry points already warn callers).NET8_0_OR_GREATER(attrs/analyzers absent on netstandard2.0, where trim/AOT isn't a concern).0 warnings both TFMs; 7/7 specs pass.