reactiveui / reactiveui/ReactiveUI

[Bug]: ExpressionRewriter overrides trigger IL2046 and IL3051 during Native AOT publishing

Open
#4,455 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
C#
Stars
8.5k
Forks
1.2k
Avg merge
4d 2h
Merged PRs (30d)
6

Description

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:

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

    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:

    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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the ExpressionRewriter overrides VisitBinary, VisitUnary, and VisitMethodCall, then compare their annotations with the corresponding ExpressionVisitor methods. Reproduce the issue using the provided Program.cs example and Native AOT publish command. Done means the reproduction no longer reports IL2046 or IL3051 for these overrides.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
build-system
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.