reactiveui / reactiveui/ReactiveUI
[Bug]: ExpressionRewriter overrides trigger IL2046 and IL3051 during Native AOT publishing
Nobody has claimed this yet.
- 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
-
Create a standalone console application:
dotnet new console -n Repro -f net10.0 cd Repro dotnet add package ReactiveUI --version 24.2.0 -
Replace
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=false -
Observe 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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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