Bug 43838 - System.Linq build problem on Alpha channel Xamarin Android
Summary: System.Linq build problem on Alpha channel Xamarin Android
Status: VERIFIED DUPLICATE of bug 44402
Alias: None
Product: Compilers
Classification: Mono
Component: C# (show other bugs)
Version: 4.6.0 (C8)
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: ---
Assignee: Marek Safar
URL:
Depends on:
Blocks:
 
Reported: 2016-08-29 17:48 UTC by ulrike_axen
Modified: 2016-09-16 20:38 UTC (History)
5 users (show)

See Also:
Tags: XATriaged BZRC8B4_C7SR1S1
Is this bug a regression?: Yes
Last known good build: Cycle 7 SR 1


Attachments
Test Project: please make sure that the MathNet dll is referenced in order to duplicate the issue. (32.16 KB, application/zip)
2016-08-29 17:48 UTC, ulrike_axen
Details
Complete build output (23.71 KB, text/plain)
2016-08-29 17:50 UTC, ulrike_axen
Details
test project that ensures MathNet reference is included (35.67 KB, application/zip)
2016-08-31 20:30 UTC, ulrike_axen
Details

Description ulrike_axen 2016-08-29 17:48:30 UTC
Created attachment 17242 [details]
Test Project: please make sure that the MathNet dll is referenced in order to duplicate the issue.

I will upload a very simple test project that demonstrates the build problem. When MathNet numerics is referenced, there is a System.Linq compile error. This error does not occur on the stable channel, with the same code.

	MainActivity.cs(28,31): error CS1929: Type `System.Array' does not contain a member `OfType' and the best extension method overload `System.Linq.Enumerable.OfType<TestLinq.MyTestEnum>(this System.Collections.IEnumerable)' requires an instance of type `System.Collections.IEnumerable'


Here is my Xamarin info:
=== Xamarin Studio Enterprise ===

Version 6.1 (build 5365)
Installation UUID: 0ca42116-8f54-4ad6-bd25-aa90f20c571f
Runtime:
	Mono 4.6.0 (mono-4.6.0-branch/23c6a4d) (64-bit)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 406000165

=== NuGet ===

Version: 3.4.3.0

=== Xamarin.Profiler ===

Version: 0.20.0.0
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

=== Xamarin.Android ===

Version: 6.2.0.47 (Xamarin Enterprise)
Android SDK: /Users/axenu/Library/Developer/Xamarin/android-sdk-mac_x86
	Supported Android versions:
		2.3    (API level 10)
		4.0.3  (API level 15)
		4.3    (API level 18)
		4.4    (API level 19)
		4.4.87 (API level 20)
		5.0    (API level 21)
		5.1    (API level 22)
		6.0    (API level 23)

SDK Tools Version: 25.1.1
SDK Platform Tools Version: 23.1
SDK Build Tools Version: 23.0.3

Java SDK: /usr
java version "1.8.0_74"
Java(TM) SE Runtime Environment (build 1.8.0_74-b02)
Java HotSpot(TM) 64-Bit Server VM (build 25.74-b02, mixed mode)

Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

=== Xamarin Android Player ===

Not Installed

=== Apple Developer Tools ===

Xcode 8.0 (11228.2)
Build 8S193k

=== Xamarin.iOS ===

Version: 9.99.4.23 (Xamarin Enterprise)
Hash: f63ecd7
Branch: cycle8
Build date: 2016-08-23 14:45:42-0400

=== Xamarin.Mac ===

Version: 2.10.0.68 (Xamarin Enterprise)

=== Build Information ===

Release ID: 601005365
Git revision: 4fb2e8b3f2042f3be28b370d01f1c8057e993e51
Build date: 2016-08-23 08:54:41-04
Xamarin addins: 60c0f9d8f0eb210499e1f8c6daf4972c10f4663f
Build lane: monodevelop-lion-cycle8

=== Operating System ===

Mac OS X 10.11.6
Darwin ulrikes-mbp-2.ms.starkey.com 15.6.0 Darwin Kernel Version 15.6.0
    Thu Jun 23 18:25:34 PDT 2016
    root:xnu-3248.60.10~1/RELEASE_X86_64 x86_64
Comment 1 ulrike_axen 2016-08-29 17:50:44 UTC
Created attachment 17243 [details]
Complete build output
Comment 2 ulrike_axen 2016-08-29 18:01:33 UTC
We have the same code and reference to MathNet in our Xamarin iOS project, and do not encounter the build error.

Please provide a fix or workaround, we are trying to finish some Android Nougat work.
Comment 3 Marek Habersack 2016-08-29 21:56:28 UTC
I've tested this with Xamarin.Android/monodroid from master as well as from the cycle8 branch and in both situations the build works just fine - in both Debug and Release (with linking) configurations.

Please update your Xamarin.Android to the latest Alpha as soon as it is published or to the next release, whichever comes first.
Comment 4 ulrike_axen 2016-08-29 22:01:20 UTC
OK, just checking, did you make sure to restore the MathNet package, and make sure that there is a reference to the Math Net dll. I had to reference it manually (the package restore didn't work, probably because I don't use it in this sample), and the build only breaks with that reference included.
Comment 5 ulrike_axen 2016-08-30 13:19:12 UTC
@Marek: I have tried this on the latest alpha, and the issue is present. Please check to make sure that the project references MathNet, thanks! Or, if you want to supply me with the latest package that you think it's fixed on, please do and I can give it a try.
Comment 6 Marek Habersack 2016-08-30 17:20:26 UTC
I restored MathNet (just removing it and adding it back again makes it automatically referenced) and tested with both master and cycle8 tip of branch builds. Note that those builds are newer than the latest alpha release. The latest builds can be found here:

https://jenkins.mono-project.com/view/Xamarin.Android/job/xamarin-android-builds-cycle8/
https://jenkins.mono-project.com/view/Xamarin.Android/job/xamarin-android-builds-master/

Note that they are strictly pre-release builds! Hope it helps :)
Comment 7 ulrike_axen 2016-08-31 20:21:57 UTC
I just tested using the latest Tamarin-Android package at the link you provided, and I get the exact same results. If I remove the reference to MathNet, it builds. If the reference to MathNet is there, it does not. I am building in "Debug" configuration, so the linker is not removing it. I'll submit a new test project where I actually reference a MathNet class, so the reference is not removed even by the linker
Comment 8 ulrike_axen 2016-08-31 20:30:22 UTC
Created attachment 17282 [details]
test project that ensures MathNet reference is included


// remove this line and the MathNet reference, and you will not see the System.Array build error two lines below this one
			Matrix x = new DenseMatrix(3, 3);
Comment 9 ulrike_axen 2016-08-31 20:34:38 UTC
To show you which version of Xamarin.Android I installed:

=== Xamarin Studio Enterprise ===

Version 6.1 (build 5365)
Installation UUID: 0ca42116-8f54-4ad6-bd25-aa90f20c571f
Runtime:
	Mono 4.6.0 (mono-4.6.0-branch/23c6a4d) (64-bit)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 406000165

=== NuGet ===

Version: 3.4.3.0

=== Xamarin.Profiler ===

Version: 0.20.0.0
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

=== Xamarin.Android ===

Version: 7.0.0.5 (Xamarin Enterprise)
Android SDK: /Users/axenu/Library/Developer/Xamarin/android-sdk-mac_x86
	Supported Android versions:
		2.3    (API level 10)
		4.0.3  (API level 15)
		4.3    (API level 18)
		4.4    (API level 19)
		4.4.87 (API level 20)
		5.0    (API level 21)
		5.1    (API level 22)
		6.0    (API level 23)

SDK Tools Version: 25.1.1
SDK Platform Tools Version: 23.1
SDK Build Tools Version: 23.0.3

Java SDK: /usr
java version "1.8.0_74"
Java(TM) SE Runtime Environment (build 1.8.0_74-b02)
Java HotSpot(TM) 64-Bit Server VM (build 25.74-b02, mixed mode)

Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

=== Xamarin Android Player ===

Not Installed

=== Apple Developer Tools ===

Xcode 8.0 (11228.2)
Build 8S193k

=== Xamarin.iOS ===

Version: 9.99.4.23 (Xamarin Enterprise)
Hash: f63ecd7
Branch: cycle8
Build date: 2016-08-23 14:45:42-0400

=== Xamarin.Mac ===

Version: 2.10.0.68 (Xamarin Enterprise)

=== Build Information ===

Release ID: 601005365
Git revision: 4fb2e8b3f2042f3be28b370d01f1c8057e993e51
Build date: 2016-08-23 08:54:41-04
Xamarin addins: 60c0f9d8f0eb210499e1f8c6daf4972c10f4663f
Build lane: monodevelop-lion-cycle8

=== Operating System ===

Mac OS X 10.11.6
Darwin ulrikes-mbp-2.ms.starkey.com 15.6.0 Darwin Kernel Version 15.6.0
    Thu Jun 23 18:25:34 PDT 2016
    root:xnu-3248.60.10~1/RELEASE_X86_64 x86_64
Comment 10 Brendan Zagaeski (Xamarin Support) 2016-09-13 13:50:06 UTC
Thanks for the updated test case.  I was able to confirm the reported error message from Comment 1 with that test case.


## Regression status for the test case from Comment 8: regression in Cycle 8 compared to Cycle 7

BAD:  Xamarin.Android 7.0.99-62 (master/a5091c653b7780df70078c1604577edcff69040f)
BAD:  Xamarin.Android 7.0.0.15  (Cycle 8 Beta 4)
GOOD: Xamarin.Android 6.1.2.21  (Cycle 7 SR 1)
Comment 11 Claus Elmann 2016-09-14 21:05:23 UTC
I get an error in stable release, in Xamarin Studio, but Visual Studio still works? 


 protected override void OnAppearing()
        {
            base.OnAppearing();

            var list = (from p in Enum.GetValues(typeof(Util.Sprog)).Cast<Util.Sprog>()
                        select new UIViewItem()
                        {
                            ID = (long)p + "",
                            SSort = p.ToString(),
                            Line1Spans = new List<Span>(new[] {
                                     new Span {Text = string.Format("{0}  ", p.ToString()) , FontSize = App.FontSizeLine1},
                                     new Span {Text = ((long)p == Settings.SprogID ? FontAwesome.FACheck : ""), FontFamily = App.FontawsomeName, FontSize = App.FontSizeLine1 * 1.5, ForegroundColor = Xamarin.Forms.Color.Green
                        },
                                 }),
                        }).OrderBy(s => s.SSort).ToList();
            listView.ItemsSource = list;
        }

/Users/cel/Projects/DefaultCollection/_git/PigTechMobile/Mobile.Portable/Pages/Select/Sprog.cs(70,70): Error CS1929: Type `System.Array' does not contain a member `Cast' and the best extension method overload `System.Linq.Queryable.Cast<Mobile.Portable.Util.Sprog>(this System.Linq.IQueryable)' requires an instance of type `System.Linq.IQueryable' (CS1929) (Mobile.Portable)
Comment 12 Brendan Zagaeski (Xamarin Support) 2016-09-15 02:32:42 UTC
## Note to the Xamarin team

Bug 44323 appears to be very closely related if not a duplicate.  It seems the underlying problem might in fact be a Mono compiler bug, and just by coincidence (?) the older version of Xamarin.Android does not trigger that bug.

Regression status for _Mono_:

### On Mac using Mono

GOOD: Xamarin.Android 7.0.0.18 + Mono 4.4.2 (mono-4.4.0-branch-c7sr1/f72fe45)
BAD:  Xamarin.Android 7.0.0.18 + Mono 4.6.0 (mono-4.6.0-branch/746756c)

### On Windows using .NET

GOOD: Xamarin.Android 7.0.0.18 (0e59c36) (from XamarinVS 4.2.0.680 (c4382f5))
Comment 13 ulrike_axen 2016-09-16 13:43:12 UTC
Looks like this bug made it to the stable channel :(. Can't build our app on stable now. The problem code is in code that we consume from another team, so a workaround is not a good option.
Comment 14 Claus Elmann 2016-09-16 15:09:09 UTC
I just UN installed mono and installed previos version
Comment 15 Marek Habersack 2016-09-16 19:25:25 UTC
I managed to reproduce it with the current stable releases of XS, XA and Mono using the test case provided in comment 8, but it isn't reproducible with the current master builds of any of the above. I think Brendan might right in comment 12 about this being an mcs bug.
Comment 16 Brendan Zagaeski (Xamarin Support) 2016-09-16 20:08:04 UTC
Excellent.  I bet this has been fixed in the "current master builds" by the fix for Bug 44402 (Bug 44323 is now resolved as a duplicate of that bug):

https://github.com/mono/mono/commit/8d0eee7575928145f1e3d5b1e8e346cc22ab6ec9

I will check the behavior of Mono before and after that commit to verify.
Comment 17 Brendan Zagaeski (Xamarin Support) 2016-09-16 20:38:03 UTC
## Verification status: verified fixed / duplicate of Bug 44402

GOOD: Xamarin.Android 7.0.0.18 + Mono 4.6.0 (mono-4.6.0-branch/8d0eee7)
BAD:  Xamarin.Android 7.0.0.18 + Mono 4.6.0 (mono-4.6.0-branch/ebeb4e1)

(Note: ebeb4e1 is exactly 1 commit before 8d0eee7575928145f1e3d5b1e8e346cc22ab6ec9 on the mono/mono-4.6.0-branch branch.)

*** This bug has been marked as a duplicate of bug 44402 ***

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