Bug 37631 - System.Runtime.InteropServices.ComTypes.FILETIME missing in PCLs
Summary: System.Runtime.InteropServices.ComTypes.FILETIME missing in PCLs
Status: RESOLVED ANSWERED
Alias: None
Product: iOS
Classification: Xamarin
Component: BCL Class Libraries ()
Version: XI 9.4 (iOS 9.2)
Hardware: PC Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2016-01-12 20:40 UTC by Frank A. Krueger
Modified: 2016-10-04 12:16 UTC (History)
6 users (show)

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


Attachments
Repro project (21.01 KB, application/zip)
2016-01-12 20:40 UTC, Frank A. Krueger
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 ANSWERED

Description Frank A. Krueger 2016-01-12 20:40:03 UTC
Created attachment 14560 [details]
Repro project

I have a PCL that references System.Runtime.InteropServices.ComTypes.FILETIME

When mtouch tries to link, it fails with:

/Users/fak/Dropbox/Projects/Upsight/Upsight.iOS/Upsight.fsproj (Build) ->
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/iOS/Xamarin.iOS.Common.targets (_CompileToNative target) ->

	MTOUCH: error MT2002: Failed to resolve "System.Runtime.InteropServices.ComTypes.FILETIME" reference from "System.Runtime.InteropServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"

	 2 Warning(s)
	 1 Error(s)


Microsoft says this structure is available in PCLs: https://msdn.microsoft.com/en-us/library/system.runtime.interopservices.comtypes.filetime(v=vs.110).aspx

Repro:

1. Create a PCL that uses FILENAME
2. Reference that PCL with an iOS app

I have attached a project that does this. But you will have to build the PCL in Visual Studio due to this bug.



=== Xamarin Studio ===

Version 5.10.1 (build 6)
Installation UUID: e51e2705-c52a-4ae8-aa07-c481d6ab8a7a
Runtime:
	Mono 4.2.1 (explicit/6dd2d0d)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 402010102

=== Xamarin.Profiler ===

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

=== Apple Developer Tools ===

Xcode 7.2 (9548)
Build 7C68

=== Xamarin.iOS ===

Version: 9.4.0.0 (Enterprise Edition)
Hash: 7322991
Branch: master
Build date: 2015-12-08 16:20:29-0500

=== Xamarin.Android ===

Version: 6.0.0.34 (Enterprise Edition)
Android SDK: /Users/fak/Library/Developer/Xamarin/android-sdk-mac_x86
	Supported Android versions:
		2.3   (API level 10)
		4.0.3 (API level 15)
		4.4   (API level 19)
		5.0   (API level 21)
		6.0   (API level 23)

SDK Tools Version: 24.4.1
SDK Platform Tools Version: 23.1
SDK Build Tools Version: 23.0.2

Java SDK: /usr
java version "1.7.0_51"
Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode)

=== Xamarin Android Player ===

Version: 0.6.5
Location: /Applications/Xamarin Android Player.app

=== Xamarin.Mac ===

Version: 2.4.0.109 (Enterprise Edition)

=== Xamarin Inspector ===

Version: 0.3.2.3
Hash: 1b526e6
Branch: master
Build date: Tue Nov 17 20:54:30 UTC 2015

=== Build Information ===

Release ID: 510010006
Git revision: 0b60eecdb531933734519c13257d16a780274aab
Build date: 2015-12-04 20:28:20-05
Xamarin addins: 9876fd7c9837977178411ec7375b4352c0a0d6af
Build lane: monodevelop-lion-cycle6-baseline

=== Operating System ===

Mac OS X 10.11.2
Darwin lepton.local 15.2.0 Darwin Kernel Version 15.2.0
    Fri Nov 13 19:56:56 PST 2015
    root:xnu-3248.20.55~2/RELEASE_X86_64 x86_64
Comment 1 Rodrigo Kumpera 2016-01-14 23:22:40 UTC
Marcos / Alexander,

Could one of you work on this bug?
Comment 2 Marek Safar 2016-01-15 08:33:06 UTC
I get different error when using your repro project

Archive2/FiletimeLib/FiletimeLib.csproj (Build) ->
/Library/Frameworks/Mono.framework/Versions/4.2.1/lib/mono/4.5/Microsoft.CSharp.targets (CoreCompile target) ->

	MyClass.cs(11,57): error CS1070: The type `System.Runtime.InteropServices.ComTypes.FILETIME' has been forwarded to an assembly that is not referenced. Consider adding a reference to assembly `System.Runtime.InteropServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'

When something is supported in PCL it does not mean it's supported by XI as every profile has different subset and XI generally does not support Com types even if they are simple structs.
Comment 3 Alexander Köplinger [MSFT] 2016-01-16 12:23:35 UTC
I was able to make the FiletimeLib compile by switching to Profile111 which has a System.Runtime.InteropServices.dll contract (contrary to Profile259 where the struct is defined in mscorlib.dll). But of course even with that the actual app fails to compile since the forwarded type isn't there, see also Sebastien's comment in https://bugzilla.xamarin.com/show_bug.cgi?id=37632#c1.

I do wonder though whether we should add stubs that throw PlatformNotSupportedException so that the app/lib at least compiles when using the PCL? Do we have API diffs between Xamarin.iOS and the PCLs to see what is there and what isn't?
Comment 4 Andrew Arnott 2016-04-02 20:23:12 UTC
> XI generally does not support Com types even if they are simple structs.

Despite the namespace, this isn't a COM type. This type is the managed equivalent of a Win32 function struct for enumerating files. 

> When something is supported in PCL it does not mean
> it's supported by XI as every profile has different subset

True. But as XI and XA claim to fulfill the contracts in Profile259 and Profile111, it seems an error on Xamarin's side whenever there is actually a hole in supporting that full profile. As this FILETIME struct is available in those profiles, XA and XI should support them.

This is showing up as blocking use of the latest version of PCLCrypto due to its dependency on PInvoke.Kernel32:
https://github.com/AArnott/pinvoke/issues/232

Please consider reactivating and fixing by filling in the hole in the API support. We can't fix this in PInvoke without a breaking change. But Xamarin could without one.
Comment 5 Andrew Arnott 2016-04-02 20:33:47 UTC
Alternatively, you might improve your linker to not care about the missing type since the app doesn't actually need it. It just happens to be referenced from a library that my app references, but doesn't use that part of the library.
Comment 6 Alexander Köplinger [MSFT] 2016-10-04 12:16:31 UTC
FYI the missing typeforward was added in https://github.com/mono/mono/commit/276c31d5ed602824d2284433c9460694ed5fdda0#diff-fee27e2cd00f3fd0a43aa0e5e0bccf2dR95 recently.