fix: correct the expression rewriter's trimming annotation and the analyzer package assets - #88
Merged
Conversation
…verrides - RequiresUnreferencedCode on VisitBinary, VisitUnary and VisitMethodCall contradicts the ExpressionVisitor members they override, which a consumer's trimmed publish reports as IL2046 three times. The annotation belongs on the rewriter itself, where no base member disagrees with it. - Build the shared rewriter on first use rather than in a static initializer: a static constructor has nowhere to carry the annotation the type now needs, so Reflection.Rewrite states it instead. Every caller already reaches it from a path that says the same thing. Closes #84
- Three analyzer references carried no PrivateAssets, so they were published as dependencies of every packed project rather than staying a build-time concern. - Affects the runtime and platform packages too, not only the generator package. Closes #82
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #88 +/- ##
==========================================
- Coverage 99.48% 99.48% -0.01%
==========================================
Files 246 246
Lines 10411 10410 -1
Branches 1124 1125 +1
==========================================
- Hits 10357 10356 -1
Misses 42 42
Partials 12 12 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
glennawatson
deleted the
fix/trimming-annotations-and-analyzer-assets
branch
September 9, 2026 12:06
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.



What kind of change does this PR introduce?
Two bug fixes.
What is the new behavior?
A trimmed consumer no longer sees IL2046 from the expression rewriter.
RequiresUnreferencedCodesits onExpressionRewriteritself rather than on itsVisitBinary,VisitUnaryandVisitMethodCalloverrides. An override cannot carry an annotation its base member lacks,and
ExpressionVisitorcarries none, so each of the three was reported.nowhere to carry the annotation the type now needs, so
Reflection.Rewritestates it; all three callersalready reach it from a path annotated the same way.
Development-only analyzers are no longer package dependencies.
PrivateAssets="all", matching the five beside them that already had it.What is the current behavior?
Publishing a trimmed application that reaches the expression engine reports IL2046 three times, once per
annotated override.
Every packed project lists three repository-only analyzer packages as dependencies, so consumers inherit
build-time tooling in their dependency graph. The report named the generator package, but
src/Directory.Build.propsapplies to all of them, so the runtime and platform packages leak them too.Closes #84
Closes #82
What might this PR break?
Reflection.Rewriteis public and now carriesRequiresUnreferencedCode. A consumer calling it directlyfrom a trimming-annotated context will see IL2026 where it previously saw nothing - the warning is accurate,
since the method has always used reflection. Callers inside this repository are unaffected: all three already
sit on annotated paths.
Checklist
mainbranchAdditional information
Both fixes were verified against the symptom rather than the source.
The trimming fix was reproduced first: a console app referencing the runtime library, reaching the expression
engine, published with
PublishTrimmed. It reported IL2046 three times before the change and none after. Thetwo IL2026 warnings that remain are the app's own call to
WhenAnyDynamic, which is deliberatelyRequiresUnreferencedCode.The packaging fix was checked by packing
ReactiveUI.Bindingand reading the dependency groups out of thegenerated nuspec, which now list only
ReactiveUI.PrimitivesandSplat.Neither issue was caught by the AOT validation harness, because nothing in it reaches the expression engine.
Closing that gap needs a target that deliberately does, which cannot assert zero warnings the way the current
harness does -
WhenAnyDynamicis annotated by design. Worth deciding separately.