[Bug]: ExpressionRewriter overrides trigger IL2046 and IL3051 during Native AOT publishing
Author: HMBSbigeCreated Sep 8, 2026Updated Sep 8, 2026
Labelsbug
Describe the bug
Publishing an application that uses ToProperty with Native AOT produces IL2046 and IL3051 warnings for ExpressionRewriter.VisitBinary, VisitUnary, and VisitMethodCall.
These overrides declare RequiresUnreferencedCode and RequiresDynamicCode, while the corresponding base methods in ExpressionVisitor do not.
Step to reproduce
Create a standalone console application:
dotnet new console -n Repro -f net10.0 cd Repro dotnet add package ReactiveUI --version 24.2.0Replace
Program.cswith:using ReactiveUI; using ReactiveUI.Primitives; namespace Repro; internal static class Program { private static void Main() { using var vm = new ViewModel(); Console.WriteLine(vm.IsBusy); } } public sealed class ViewModel : ReactiveObject, IDisposable { private readonly ObservableAsPropertyHelper<bool> _isBusy; public ReactiveCommand<RxVoid, RxVoid> RunCommand { get; } public bool IsBusy => _isBusy.Value; public ViewModel() { RunCommand = ReactiveCommand.Create(static () => { }); _isBusy = RunCommand.IsExecuting.ToProperty(this, static x => x.IsBusy); } public void Dispose() { _isBusy.Dispose(); RunCommand.Dispose(); } }Publish with Native AOT enabled:
dotnet publish -c Release -r win-x64 -p:PublishAot=true -p:TrimmerSingleWarn=false -p:IlcSingleWarn=falseObserve IL2046 and IL3051 warnings for each of the three
ExpressionRewriteroverrides.
Reproduction repository
No response
Expected behavior
Trim-safe and Native AOT-compatible usage paths should not produce trimming or AOT warnings.
Screenshots ️
No response
IDE
No response
Operating system
No response
Version
No response
Device
No response
ReactiveUI Version
No response
Source: reactiveui/ReactiveUI