#4455·ReactiveUI

[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

  1. Create a standalone console application:

    bash
    dotnet new console -n Repro -f net10.0
    cd Repro
    dotnet add package ReactiveUI --version 24.2.0
  2. Replace Program.cs with:

    csharp
    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();
        }
    }
  3. Publish with Native AOT enabled:

    bash
    dotnet publish -c Release -r win-x64 -p:PublishAot=true -p:TrimmerSingleWarn=false -p:IlcSingleWarn=false
  4. Observe IL2046 and IL3051 warnings for each of the three ExpressionRewriter overrides.

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