Bug 8329 - Unable to build reactive extensions tests for simulator or device
Summary: Unable to build reactive extensions tests for simulator or device
Status: RESOLVED FIXED
Alias: None
Product: iOS
Classification: Xamarin
Component: General ()
Version: 6.0.x
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2012-11-11 00:33 UTC by Greg Munn
Modified: 2012-11-13 15:09 UTC (History)
5 users (show)

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


Attachments
Rx sample that fails to build for MonoTouch. (1.28 MB, application/zip)
2012-11-11 00:33 UTC, Greg Munn
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Greg Munn 2012-11-11 00:33:07 UTC
Created attachment 2897 [details]
Rx sample that fails to build for MonoTouch.

I've downloaded the source for reactive extensions and hacked away at the projects to get a MonoTouch build.  As monotouch library projects, each project builds fine (except of course windows specific ones).  When I try to build the tests and included them in a test runner project, the compiler fails to compile to native code.

I've attached the code, open the RxTestRunner solution and build all for debug|simulator or device.  All projects build except RxTestRunner which builds but doesn't compile to native code.

/Developer/MonoTouch/usr/bin/mtouch -sdkroot "/Applications/Xcode.app/Contents/Developer" -v --cache "/Users/sgm/Projects/Test/Rx/Rx.NET/Tests.System.Reactive/obj/Debug/mtouch-cache" --nomanifest --nosign -dev "/Users/sgm/Projects/Test/Rx/Rx.NET/Tests.System.Reactive/bin/iPhone/Debug/RxTestRunner.app" -r "/Users/sgm/Projects/Test/Rx/Rx.NET/Microsoft.Reactive.Testing/bin/Debug/Microsoft.Reactive.Testing.dll" -r "/Users/sgm/Projects/Test/Rx/Rx.NET/System.Reactive.Core/bin/Debug/System.Reactive.Core.dll" -r "/Users/sgm/Projects/Test/Rx/Rx.NET/System.Reactive.Experimental/bin/Debug/System.Reactive.Experimental.dll" -r "/Users/sgm/Projects/Test/Rx/Rx.NET/System.Reactive.Interfaces/bin/Debug/System.Reactive.Interfaces.dll" -r "/Users/sgm/Projects/Test/Rx/Rx.NET/System.Reactive.Linq/bin/Debug/System.Reactive.Linq.dll" -r "/Users/sgm/Projects/Test/Rx/Rx.NET/System.Reactive.PlatformServices/bin/Debug/System.Reactive.PlatformServices.dll" -r "/Users/sgm/Projects/Test/Rx/Rx.NET/System.Reactive.Providers/bin/Debug/System.Reactive.Providers.dll" -r "/Developer/MonoTouch/usr/lib/mono/2.1/System.dll" -r "/Developer/MonoTouch/usr/lib/mono/2.1/System.Xml.dll" -r "/Developer/MonoTouch/usr/lib/mono/2.1/System.Core.dll" -r "/Developer/MonoTouch/usr/lib/mono/2.1/monotouch.dll" -r "/Developer/MonoTouch/usr/lib/mono/2.1/MonoTouch.NUnitLite.dll" -debug -profiling -linksdkonly -sdk "6.0" -targetver "3.2" "/Users/sgm/Projects/Test/Rx/Rx.NET/Tests.System.Reactive/bin/iPhone/Debug/RxTestRunner.exe"
MonoTouch version 6.0.6 using framework: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk
error MT0000: Unexpected error - Please file a bug report at http://bugzilla.xamarin.com
System.IndexOutOfRangeException: Array index is out of range.
  at Mono.Cecil.Metadata.Utilities.ReadCompressedInteger (System.Byte[] data, Int32 pos, System.Int32& start) [0x00000] in <filename unknown>:0 
  at Mono.Cecil.Metadata.MetadataHeap.ReadBytesFromStream (UInt32 pos) [0x00000] in <filename unknown>:0 
  at Mono.Cecil.Metadata.BlobHeap.Read (UInt32 index) [0x00000] in <filename unknown>:0 
  at Mono.Cecil.StructureReader.ReadBlob (UInt32 pointer) [0x00000] in <filename unknown>:0 
  at Mono.Cecil.StructureReader.VisitAssemblyNameDefinition (Mono.Cecil.AssemblyNameDefinition name) [0x00000] in <filename unknown>:0 
  at Mono.Cecil.AssemblyNameDefinition.Accept (IReflectionStructureVisitor visitor) [0x00000] in <filename unknown>:0 
  at Mono.Cecil.AssemblyDefinition.Accept (IReflectionStructureVisitor visitor) [0x00000] in <filename unknown>:0 
  at Mono.Cecil.AssemblyFactory.GetAssembly (Mono.Cecil.Binary.ImageReader irv, Boolean manifestOnly) [0x00000] in <filename unknown>:0 
  at Mono.Cecil.AssemblyFactory.GetAssemblyManifest (Mono.Cecil.Binary.ImageReader reader) [0x00000] in <filename unknown>:0 
  at Mono.Cecil.AssemblyFactory.GetAssemblyManifest (System.String file) [0x00000] in <filename unknown>:0 
  at MonoTouch.Tuner.MonoTouchManifestResolver.ReadAssembly (System.String file) [0x00000] in <filename unknown>:0 
  at MonoTouch.Tuner.MonoTouchResolver.AddAssembly (System.String fileName) [0x00000] in <filename unknown>:0 
  at MTouch.Main2 (System.String[] args) [0x00000] in <filename unknown>:0 
  at MTouch.Main (System.String[] args) [0x00000] in <filename unknown>:0
Comment 1 Greg Munn 2012-11-11 00:39:27 UTC
It appears to localized to System.Reactive.Linq in particular. Excluding this from the references of another application builds, whereas adding it in results in the same error as above.
Comment 2 Miguel de Icaza [MSFT] 2012-11-11 09:45:04 UTC
It looks like a bug in our linker code that reads the metadata tables.

Were all of the referenced assemblies built with MonoTouch's compiler?   It is possible that some of those were built with the Microsoft C# compiler.
Comment 3 Greg Munn 2012-11-11 17:22:19 UTC
Yes, they were.  I created new MonoTouch Library projects for each and a new MonoTouch Unit Tests Project.  I added in the units for each project and set defines where necessary.  Prior to having the unit test project, each project was building with no errors with MonoDevelop / MonoTouch (3.0.4.7 / 6.0.6).

The only time I used VS to build was a different copy in a VM, just to verify that their tests passed.

Cheers.
Comment 4 Sebastien Pouliot 2012-11-12 08:21:45 UTC
It's deeper than the linker, it's Cecil code throwing an exception while loading an assembly. 

It could be a Cecil or a compiler bug. I'll investigate.
Comment 5 Sebastien Pouliot 2012-11-12 11:51:32 UTC
MD's assembly browser (also cecil-based) cannot open System.Reactive.Linq either. It shows junk in the references. ILSpy (also based on cecil) does not like it either.

MS peverify reports:

21416 Error(s) Verifying System.Reactive.Linq.dll

I suspect a compiler issue, c.c. Marek
Comment 6 Miguel de Icaza [MSFT] 2012-11-12 13:07:44 UTC
We seem to have a similar bug in Mono:

https://bugzilla.xamarin.com/show_bug.cgi?id=8320
Comment 7 Miguel de Icaza [MSFT] 2012-11-12 13:10:22 UTC
According to Marek, this is fixed in a new Cecil.
Comment 8 Sebastien Pouliot 2012-11-12 13:56:34 UTC
There might be a Cecil workaround to the runtime/compiler issue(s). ILSpy has a newer version (but it only fails differently).

OTOH MonoTouch still uses the old 0.6.9 Cecil (not the new 0.9.5 one) so that workaround won't help in this case. The newer 0.9.x Cecil won't be in use until we switch MT to mono 3.0.
Comment 9 Sebastien Pouliot 2012-11-13 15:09:58 UTC
With the fix for bug #8320 applied to monotouch the build executes fine (without error).

That fix will be in 6.0.8.