Repository navigation
test: keep runtime reflection confined to the JIT-only fallback - #73
Merged
Merged
Conversation
Blind-Striker
added this pull request to stack #69
October 23, 2026 13:33
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
This was referenced Oct 23, 2026
Blind-Striker
force-pushed
the
aot/reflection-free-test
branch
from
October 23, 2026 15:22
3fe4790 to
36ebc5f
Compare
Blind-Striker
force-pushed
the
aot/reflection-free-test
branch
from
October 23, 2026 20:24
36ebc5f to
06694d4
Compare
This was referenced Oct 23, 2026
ReflectionFreeAssemblyTests decodes the IL of LocalStack.Client and LocalStack.Client.Extensions (net10.0/net11.0) and fails when a runtime reflection API (member lookup, FieldInfo/PropertyInfo access, Invoke, Activator.CreateInstance, Type.GetType(string), Assembly.GetType, Reflection.Emit, Expression.Compile) is called outside a method marked [RequiresUnreferencedCode], i.e. outside the fallback that trimmed and Native AOT apps remove. It also requires that the fallback's allowed calls are found, so an empty scan cannot pass. Checked red: a trim-safe typeof(Session).GetConstructors() added to the Session constructor fails the test with "LocalStack.Client.Session..ctor -> System.Type.GetConstructors".
Blind-Striker
force-pushed
the
aot/reflection-free-test
branch
from
October 23, 2026 21:13
06694d4 to
b5fa969
Compare
Blind-Striker
marked this pull request as ready for review
October 23, 2026 21:55
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.
Stack (review bottom-up, merge as one stack): #62 base, #66 the #63 fix, #67 Native AOT test lane, #68 static-factory generic path, #70 slim generator, #71 public docs, #72 internal docs and 3.0.0, #73 reflection-free test, #74 package consumer in CI, #75 convention clean-up, #76 service catalog refresh.
Goal of the stack: 3.0.0, where existing consumers upgrade without code changes, both packages support Native AOT on net10.0/net11.0, and the libraries use no runtime reflection for types the compiler can see (a JIT-only fallback covers the rest).
This PR
ReflectionFreeAssemblyTests(Libraries_Should_Call_Runtime_Reflection_Only_From_RequiresUnreferencedCode_Methods) decodes the IL ofLocalStack.ClientandLocalStack.Client.Extensions(net10.0/net11.0). It fails if a runtime-reflection API (member lookup, Field/PropertyInfo access,Invoke,Activator.CreateInstance,Type.GetType(string),Assembly.GetType, Emit,Expression.Compile) is called outside a[RequiresUnreferencedCode]method, that is, outside the fallback that trimmed and AOT apps remove. It also requires the fallback's own calls to be found, so an empty scan cannot pass.Verification
Green on net10/net11 (Extensions 63). Red check: adding a trim-safe
typeof(Session).GetConstructors()to theSessionconstructor made it fail withLocalStack.Client.Session..ctor -> System.Type.GetConstructors.