You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Generated instance hooks emit IL2075 during Native AOT publishing #7430
Native AOT publishing emits IL2075 warnings from generated instance hooks. The generated code calls GetMethod on an instance's GetType() without preserving the reflected method requirements. Users need hook methods retained reliably under trimming and actionable publish diagnostics.
Reproduction
At commit 411189a, run dotnet publish tests/TUnit.TestProject -c Release -f net10.0 -p:Aot=true --use-current-runtime.
The generated HookMetadataGenerator output for GenericHooks.Setup and Bugs._1603.GrandParentTests.SetupBase emits IL2075: Object.GetType() does not satisfy the PublicMethods and NonPublicMethods requirements of Type.GetMethod(String, BindingFlags).
Expected and actual
Generated instance hooks should retain required methods without IL2075 warnings. Publishing succeeds but reports these warnings across multiple generated hook methods. Please correct the generated reflection flow or its preservation annotations.
Environment
.NET SDK 10.0.403, Native AOT compiler 10.0.14, macOS arm64. Observed while validating #7424; the hook generator is unchanged by that PR.
Audited against main d87516cb9c: HookMetadataGenerator.GenerateReflectionBasedInvocation still emits instance.GetType() followed by GetMethod (lines 791–792). The reported reflection flow remains; no closing PR was found. Keep open for the AOT preservation fix and publish validation.
Reproduced the generated-hook IL2075 warnings while validating #7476 at e167fcf with SDK 10.0.403 / macOS arm64: dotnet publish tests/TUnit.TestProject -c Release -p:Aot=true --use-current-runtime -f net10.0. Publishing succeeds; GenericHooks and Bugs._2935.GenericTests<T> generated instance hook bodies still warn about GetType() followed by GetMethod(String, BindingFlags). Targeted Native AOT tests pass. This remains separate from the row-scope cleanup change.
Reproduced while validating #7224 on main 515f198 plus its inference fix, with SDK 10.0.403 on macOS arm64: dotnet publish tests/TUnit.TestProject -c Release -p:Aot=true --use-current-runtime -f net10.0 reports IL2075 in generated instance hooks, including GenericHooks.Before and After. No reflection inference warnings appeared.
Activity
thomhurst commentedon Nov 3, 2026
Audited against main
d87516cb9c:HookMetadataGenerator.GenerateReflectionBasedInvocationstill emitsinstance.GetType()followed byGetMethod(lines 791–792). The reported reflection flow remains; no closing PR was found. Keep open for the AOT preservation fix and publish validation.thomhurst commentedon Nov 3, 2026
Reproduced the generated-hook IL2075 warnings while validating #7476 at e167fcf with SDK 10.0.403 / macOS arm64:
dotnet publish tests/TUnit.TestProject -c Release -p:Aot=true --use-current-runtime -f net10.0. Publishing succeeds;GenericHooksandBugs._2935.GenericTests<T>generated instance hook bodies still warn aboutGetType()followed byGetMethod(String, BindingFlags). Targeted Native AOT tests pass. This remains separate from the row-scope cleanup change.thomhurst commentedon Nov 4, 2026
Reproduced while validating #7224 on main 515f198 plus its inference fix, with SDK 10.0.403 on macOS arm64:
dotnet publish tests/TUnit.TestProject -c Release -p:Aot=true --use-current-runtime -f net10.0reports IL2075 in generated instance hooks, including GenericHooks.Before and After. No reflection inference warnings appeared.