Bug 14692 - Operation LessThanOrEqual not defined for System.Decimal and System.Decimal
Summary: Operation LessThanOrEqual not defined for System.Decimal and System.Decimal
Status: CONFIRMED
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll (show other bugs)
Version: XI 10.10 (d15-2)
Hardware: All All
: Normal normal
Target Milestone: Future Cycle (TBD)
Assignee: Sebastien Pouliot
URL:
Depends on:
Blocks:
 
Reported: 2013-09-12 14:36 UTC by Eric Maupin
Modified: 2017-04-24 03:47 UTC (History)
3 users (show)

See Also:
Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
.exe of the repro app from csc (7.50 KB, application/x-msdownload)
2013-09-20 11:03 UTC, Eric Maupin
Details

Description Eric Maupin 2013-09-12 14:36:04 UTC
System.InvalidOperationException: Operation LessThanOrEqual not defined for System.Decimal and System.Decimal

Xamarin.iOS 6.4.5

Given:

[Register("AppDelegate")]
public partial class AppDelegate : UIApplicationDelegate {
	UIWindow window;
	public override bool FinishedLaunching(UIApplication app, NSDictionary options) {
		window = new UIWindow(UIScreen.MainScreen.Bounds);
		window.RootViewController = new UIViewController();
		window.MakeKeyAndVisible();

		Launch();

		return true;
	}

	async void Launch() {
		await Task.Run (() => {
			IQueryable<decimal> query = new[] { 5m, 6m, 7m }.AsQueryable();
			query = query.Where (i => i <= 5);
			foreach (decimal i in query)
				i.ToString();
		});
	}
}

(The async stuff has no bearing on the test, it's purely to avoid the app from closing while debugging in FinishedLaunching).
Comment 1 Sebastien Pouliot 2013-09-12 16:10:03 UTC
Does this only happen on device ?

If so does with work if you disable linking ?

Expression uses reflection and Decimal operators are more likely to be removed (not used much inside the BCL) while other value-type operators are quasi-unremovable.
Comment 2 Eric Maupin 2013-09-12 16:18:53 UTC
(In reply to comment #1)
> If so does with work if you disable linking ?

It does, so it's just being linked out.
Comment 3 Sebastien Pouliot 2013-09-20 09:29:07 UTC
Eric, are you sure your code was identical to the above ?

I cannot duplicate this, not with 7.0, neither with 6.4.x, both with sim and devices (w/linking).
Comment 4 Sebastien Pouliot 2013-09-20 09:54:48 UTC
and what's your mono version ? or maybe you're using csc ?

IL_0075: ldtoken method bool [mscorlib]System.Decimal::op_LessThanOrEqual(valuetype [mscorlib]System.Decimal, valuetype [mscorlib]System.Decimal)

mcs is generating IL that makes the linker "mark" the required code.

OTOH maybe csc does something different. If you're using `csc` can you attach the .exe for the above ? 

take it from the bin/iPhone/Debug/yourapp.app/*.exe -or- attach the .app (debug version or the IL won't be available).
Comment 5 Eric Maupin 2013-09-20 11:03:22 UTC
Created attachment 4941 [details]
.exe of the repro app from csc
Comment 6 Eric Maupin 2013-09-20 11:04:08 UTC
(In reply to comment #1)
> Does this only happen on device ?

I only tried it on device, it may or may not happen on simulator.

(In reply to comment #3)
> Eric, are you sure your code was identical to the above ?

Yes, I created a new project to see if I could narrow down the issue in to a small repro and copied the code over to here when I had. There may be some spacing differences for brevity but that's all.

> and what's your mono version ? or maybe you're using csc ?
I was using VS, so it was CSC. I just retested with XI 7.0, still present.

> If you're using `csc` can you attach the .exe for the above ? 
Done above.
Comment 7 Sebastien Pouliot 2013-09-20 11:25:39 UTC
IL_0076: call class [System.Core]System.Linq.Expressions.BinaryExpression [System.Core]System.Linq.Expressions.Expression::LessThanOrEqual(class [System.Core]System.Linq.Expressions.Expression, class [System.Core]System.Linq.Expressions.Expression)

ok, so that happens only with `csc`.

note: that means `mcs` produced binaries are likely to perform better in that case (no reflection).
Comment 8 Vincent Dondain [MSFT] 2017-04-24 03:47:25 UTC
Hi,

This is still happening with csc (not with msc though), linker on SDK only mode.

Environment: https://gist.github.com/VincentDondain/85760a74410a98beddfab14fdf2d31de

Build output: https://gist.github.com/VincentDondain/5fa721fd4ea87154ec880efaf8cfae76

Exception: https://gist.github.com/VincentDondain/0021f23f19cb968b4ac9ef30ff6a3ba4

Note You need to log in before you can comment on or make changes to this bug.