From 80ee9cb4940800c69eade75f96014ad4e8b549f4 Mon Sep 17 00:00:00 2001 From: Joseph Shields Date: Wed, 6 Feb 2019 10:09:47 -0500 Subject: [PATCH 01/96] Bump to mono:2019-02 --- .gitmodules | 2 +- Make.config | 10 +++++----- external/mono | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.gitmodules b/.gitmodules index df7f39cd320e..36e38e32a682 100644 --- a/.gitmodules +++ b/.gitmodules @@ -8,7 +8,7 @@ [submodule "external/mono"] path = external/mono url = ../../mono/mono.git - branch = 2018-08 + branch = 2019-02 [submodule "external/opentk"] path = external/opentk url = ../../mono/opentk.git diff --git a/Make.config b/Make.config index 5c695421506c..5659d437e9bf 100644 --- a/Make.config +++ b/Make.config @@ -47,13 +47,13 @@ XCODE94_URL=http://xamarin-storage/bot-provisioning/xcodes/Xcode_9.4.xip XCODE94_DEVELOPER_ROOT=/Applications/Xcode94.app/Contents/Developer # Minimum Mono version for building XI/XM -MIN_MONO_VERSION=5.18.0.185 -MAX_MONO_VERSION=5.18.99 -MIN_MONO_URL=https://xamjenkinsartifact.azureedge.net/build-package-osx-mono/2018-08/149/ea740d2bc8d58d9c0ee44ef0ba15ccddeafbe227/MonoFramework-MDK-5.18.0.185.macos10.xamarin.universal.pkg +MIN_MONO_VERSION=6.0.0.6 +MAX_MONO_VERSION=6.0.99 +MIN_MONO_URL=https://xamjenkinsartifact.azureedge.net/build-package-osx-mono/2019-02/7/12cadb2b21da7f1ad8f5999fd2c5ec8a127c5795/MonoFramework-MDK-6.0.0.6.macos10.xamarin.universal.pkg # Minimum Mono version for Xamarin.Mac apps using the system mono -MIN_XM_MONO_VERSION=5.18.0.185 -MIN_XM_MONO_URL=https://xamjenkinsartifact.azureedge.net/build-package-osx-mono/2018-08/149/ea740d2bc8d58d9c0ee44ef0ba15ccddeafbe227/MonoFramework-MDK-5.18.0.185.macos10.xamarin.universal.pkg +MIN_XM_MONO_VERSION=6.0.0.6 +MIN_XM_MONO_URL=https://xamjenkinsartifact.azureedge.net/build-package-osx-mono/2019-02/7/12cadb2b21da7f1ad8f5999fd2c5ec8a127c5795/MonoFramework-MDK-6.0.0.6.macos10.xamarin.universal.pkg # Minimum Visual Studio version MIN_VISUAL_STUDIO_URL=https://bosstoragemirror.azureedge.net/vsmac/7a/7aff2dc1f28d711d11d63d79b2a4c49cda217189/VisualStudioForMac-Preview-7.7.0.1470.dmg diff --git a/external/mono b/external/mono index 2359cba40e94..6fe4c149ee6b 160000 --- a/external/mono +++ b/external/mono @@ -1 +1 @@ -Subproject commit 2359cba40e94accdcf5ce526572bce834d53f3aa +Subproject commit 6fe4c149ee6b49922a8bcbe80addb685e5ab75f7 From f796249982a1dd32cd14cf9f7f787041ebcb613c Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Fri, 8 Mar 2019 16:32:42 +0100 Subject: [PATCH 02/96] Bump mono Commit list for mono/mono: * mono/mono@c8906bed284 [corlib] Disable ThreadPoolTest.GetAvailableThreads () on machines with many cores * mono/mono@e21641dab1c [crash] Detect when 0 attached threads, fix hang/double-fault. * mono/mono@8ebb772f86d [2019-02] Bump bockbuild to get GTK fix * mono/mono@db0df0733d2 Ensure that the module cctor is run before the entry point is executed (#13242) (#13299) * mono/mono@1e36288b8e6 [jit] Avoid an assert when gsharedvt enums are boxed. (#13306) * mono/mono@4a0e34d3586 [2019-02] [linker] Fix monotouch tests which need Xamarin.iOS.dll (#13294) * mono/mono@c7e155b4a7f [2019-02] Fix mono conc hashtable lookup endless loop (#13291) * mono/mono@58faa215f47 [2019-02] [interp] mixed mode fixes for delegates (#13259) * mono/mono@43409aab03a [2019-02] Fix Directory.GetLogicalDrives () (#13286) * mono/mono@c3b2368aff0 [mini] Inline Selector.GetHandle for tvOS and watchOS assemblies as well. (#13254) * mono/mono@ce536b347bb [2019-02] [aot] add wrappers to \u0022slim\u0022 mscorlib (i.e. --aot=interp) (#13168) * mono/mono@5c6441aca83 [interp] compute size of generic valuetype correctly (#13226) * mono/mono@6ad7d7987d5 [sdks] Use throttle() instead of lock() * mono/mono@b5a53bf43ab Revert "[sdks] Make sure to run only one build per type per node" * mono/mono@9ec28a5cdfc [ci] Add node name to log of Jenkins pipeline builds * mono/mono@0d60209c63e [2019-02] [System.Net.Http] Move NSUrlSessionHandler from xamarin-macios to mono (#13249) * mono/mono@66a15f77b32 [2019-02] [monodroid] Use CoreFX to implement System.Drawing types that used to be in Mono.Android.dll (#13237) * mono/mono@5fc4dc076d8 [android] Fix inaccurate detection of sendfile() * mono/mono@a342f2e4af4 Bump corefx for type forwarders ported from 2018-10 Xamarin.Android integration * mono/mono@0aac8c4e0ff [2019-02] Fix multiple issues with response file option on Windows. (#13176) * mono/mono@077ca320a8c [aot] use unbox arbitrary trampolines for "slim" mscorlib (#13167) * mono/mono@f438e1b2608 [2019-02] [aot] abort lookup early when a method isn\u0027t available in AOT image (#13178) * mono/mono@60deb21fd85 [ci] Use dl.internalx.com when building on private Jenkins * mono/mono@979cf7978bf [aot] Resolve profile against compiled assembly (#13156) * mono/mono@b4f8e8a698f [System] Bump SocketTest.TestSelect1 socket timeout to 1ms (#13152) * mono/mono@ed72d79edaf Bump API snapshot submodule * mono/mono@39e7d07270d Make `System.dll` internals visible to `Mono.Android`. * mono/mono@5809340a13e [nuget] Add new versions of System.Net.Http * mono/mono@48ce16320f0 [nuget] Add new versions of System.Text.Encoding.CodePages .. * mono/mono@a3f69d7b21c [sdks] Make sure to run only one build per type per node * mono/mono@2ba053262fb use for loop to access item values and avoid InvalidCastException which occurs because VirtualDirectoryMappingCollection enumerator returns key and it's not expected * mono/mono@8f9491c094c [loader] Fix off by 1 (netstandard is a framework facade) * mono/mono@91a7262377e Bump bockbuild for GTK fix * mono/mono@076b66a58a8 Bump ikdasm * mono/mono@5212219db3f [mcs] Remove doc about CAS security * mono/mono@237e312ff74 Pass X509Certificate2 to the certificate validator. (#13036) * mono/mono@4c2b1492641 Remove leading . from script invocation (#13051) * mono/mono@1ce836d47d8 [2019-02] Bump linker submodule to latest master (#13034) * mono/mono@737f6ae708a Set executable bit for all .sh files in repo * mono/mono@0c2b8e9f24c Correct access permissions to include "user execute" for run-msbuild.sh. (#13042) * mono/mono@b9fa0ff8072 [bitcode] round up value type size for slot calculation (#13008) * mono/mono@3ba037bc239 Revert "[Facades] Remove System.Drawing.Primitives from xammac_net_4_5_SUBDIRS" * mono/mono@99dc534da08 [Facades] Remove System.Drawing.Primitives from xammac_net_4_5_SUBDIRS * mono/mono@55c62ea3992 [2019-02] [sdks] Add mac-{mac32,mac64} targets (#12977) * mono/mono@e62516b7aa4 [2019-02] [crash] Add more detailed reporting for exceptions (#13000) * mono/mono@143e2151e6e [System.Net.Http] Improve HttpClientTest to use the retry http listener (#13003) * mono/mono@5c66a3da2f5 [2019-02] [ci] Fix Linux x64 Bitcode job (#13004) * mono/mono@5c6e79ffa78 Mono.Native: Simplify checking for min-version * mono/mono@1f1942c356c [corlib] Fix CustomAttributeDataTest.MethodIncludesDllImportAttributeData() on watch/tv * mono/mono@7c3abd8e0d9 [2019-02] [debugger] Reverting part of https://github.com/mono/mono/pull/12114 (#12960) * mono/mono@f7f0580b047 [2019-02] [ios] add crosswatch64_32 target (#12939) * mono/mono@4da62d45683 [2019-02] Bump cecil submodule (#12942) * mono/mono@d1bab8193bd Update roslyn-binaries submodule to point to latest master revision * mono/mono@f3bdb526f0c Fix issue where togglerefs might be incorrectly pinned. (#12815) * mono/mono@fc80faabb09 [ci] Bump bockbuild to get fontconfig download url fix * mono/mono@1790e8a88f5 [aot] interp flag on AOT images only on mscorlib required (#12891) * mono/mono@765166c97a1 [interp] Fix ldelema (#12929) * mono/mono@14c5f6cc418 [2019-02] [interp] Add method to seq_points table after we finish registering it (#12908) * mono/mono@6ad34f458f0 [arm/bitcode] mark valuetype returns as such when dealing with pinvokes (#12912) * mono/mono@7f5125179dd [ci] Support building the OSX .pkg on private Jenkins * mono/mono@062e05b4f70 Merge pull request #12860 from monojenkins/backport-pr-12856-to-2019-02 * mono/mono@9f6ad1ef7a1 FIxing crash where a generic enum is passed into get_shared_type. Also added automated test to catch this scenario. (#12848) * mono/mono@f218806bf33 [2019-02] [metadata] Fix dynamic delegate (#12812) * mono/mono@e9c6379247f [2019-02] [arm64] encode offset within stack slot for r4 in gsharedvt descriptor (#12887) * mono/mono@77b48ca726c [sre] Handle null values in MarshalAsAttribute CustomAttributeBuilder * mono/mono@1dcd3134125 [runtime] Use temp folders for merp tests (#12870) * mono/mono@6abff04d78e [2019-02] [ios] pass --enable-monotouch to cross compilers so icall defintions are visible to it (#12836) * mono/mono@3101d1c7fbd [Registry] Prevent crash due to background thread facing problems in the file system * mono/mono@35aea5b0efc [tests] Disable flaky block_guard_restore_aligment_on_exit.exe on Windows PRs * mono/mono@034f1d68a35 [2019-02] Add support for async-streams (C# 8.0). (#12832) * mono/mono@fd9b8567d5a [2019-02] [corlib] Remove reflection-based Mono.Native test (#12828) * mono/mono@ea3ee83061c [2019-02] Extend mono-native minimum version magic to CPPFLAGS/CXXFLAGS (#12813) Diff: https://github.com/mono/mono/compare/6fe4c149ee6b49922a8bcbe80addb685e5ab75f7...c8906bed284747c2622ecd0ea324fd4463365794 --- external/mono | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/mono b/external/mono index 6fe4c149ee6b..c8906bed2847 160000 --- a/external/mono +++ b/external/mono @@ -1 +1 @@ -Subproject commit 6fe4c149ee6b49922a8bcbe80addb685e5ab75f7 +Subproject commit c8906bed284747c2622ecd0ea324fd4463365794 From 53146a323051d7d85e345793c24831b52e5652ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Tue, 5 Mar 2019 16:03:55 +0100 Subject: [PATCH 03/96] Bump mono --- Make.config | 8 ++++---- external/mono | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Make.config b/Make.config index 6b207de9542b..068882b3e595 100644 --- a/Make.config +++ b/Make.config @@ -49,13 +49,13 @@ XCODE94_URL=http://xamarin-storage/bot-provisioning/xcodes/Xcode_9.4.xip XCODE94_DEVELOPER_ROOT=/Applications/Xcode94.app/Contents/Developer # Minimum Mono version for building XI/XM -MIN_MONO_VERSION=6.0.0.6 +MIN_MONO_VERSION=6.0.0.63 MAX_MONO_VERSION=6.0.99 -MIN_MONO_URL=https://xamjenkinsartifact.azureedge.net/build-package-osx-mono/2019-02/7/12cadb2b21da7f1ad8f5999fd2c5ec8a127c5795/MonoFramework-MDK-6.0.0.6.macos10.xamarin.universal.pkg +MIN_MONO_URL=https://xamjenkinsartifact.azureedge.net/build-package-osx-mono/2019-02/56/5fc4dc076d8f79218312bfd0e7a6f80e7969f3ad/MonoFramework-MDK-6.0.0.63.macos10.xamarin.universal.pkg # Minimum Mono version for Xamarin.Mac apps using the system mono -MIN_XM_MONO_VERSION=6.0.0.6 -MIN_XM_MONO_URL=https://xamjenkinsartifact.azureedge.net/build-package-osx-mono/2019-02/7/12cadb2b21da7f1ad8f5999fd2c5ec8a127c5795/MonoFramework-MDK-6.0.0.6.macos10.xamarin.universal.pkg +MIN_XM_MONO_VERSION=6.0.0.63 +MIN_XM_MONO_URL=https://xamjenkinsartifact.azureedge.net/build-package-osx-mono/2019-02/56/5fc4dc076d8f79218312bfd0e7a6f80e7969f3ad/MonoFramework-MDK-6.0.0.63.macos10.xamarin.universal.pkg # Minimum Visual Studio version MIN_VISUAL_STUDIO_URL=https://bosstoragemirror.azureedge.net/vsmac/7a/7aff2dc1f28d711d11d63d79b2a4c49cda217189/VisualStudioForMac-Preview-7.7.0.1470.dmg diff --git a/external/mono b/external/mono index c8906bed2847..2f9852486c1a 160000 --- a/external/mono +++ b/external/mono @@ -1 +1 @@ -Subproject commit c8906bed284747c2622ecd0ea324fd4463365794 +Subproject commit 2f9852486c1a28dd1df44a96b5cb9439aedf6c86 From 863ceca54fb9c67e560ccbada98d65f9198ba2d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Fri, 15 Feb 2019 12:00:51 +0100 Subject: [PATCH 04/96] Add config file for libmono-native dllmap The sn tool is used during the build to sign assemblies, but with a twist: It uses the MONO_CFG_DIR environment variable to force a custom machine.config from the 4.5/mono/machine.config directory with custom key mappings. That in turn also changes where the global dllmap file is looked up though and now that certain core parts of the BCL rely on System.Native we need to make sure we have it in place. --- fsharp/Makefile | 2 +- mono/config | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 mono/config diff --git a/fsharp/Makefile b/fsharp/Makefile index 3fb39467c289..6930e8414c92 100644 --- a/fsharp/Makefile +++ b/fsharp/Makefile @@ -184,7 +184,7 @@ $(FSHARP_DIRECTORIES): ### Sign the assemblies. This is done in a temporary directory so that we don't have to re-sign on every install. build/%.dll: $(BIN_DIR)/%.dll | build/monotouch build/xamarinmacmobile build/xamarinmacfull build/xamarinwatchos build/xamarintvos $(Q) $(CP) $< $@ - $(Q_SN) MONO_CFG_DIR="$(TOP)" sn -q -R "$@" "$(PRODUCT_KEY_PATH)" + $(Q_SN) MONO_CFG_DIR="$(TOP)" $(SYSTEM_SN) -q -R "$@" "$(PRODUCT_KEY_PATH)" build.stamp: export TargetFrameworkFallbackSearchPaths=$(IOS_DESTDIR)/Library/Frameworks/Mono.framework/External/xbuild-frameworks build.stamp: export MSBuildExtensionsPathFallbackPathsOverride=$(IOS_DESTDIR)/Library/Frameworks/Mono.framework/External/xbuild diff --git a/mono/config b/mono/config new file mode 100644 index 000000000000..b30597e74031 --- /dev/null +++ b/mono/config @@ -0,0 +1,3 @@ + + + From 6caee47744408a1c577fab89bd34b16926fd8dad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Tue, 5 Mar 2019 22:48:00 +0100 Subject: [PATCH 05/96] Move NSUrlSessionHandler to Mono --- builds/Makefile | 2 +- src/Foundation/NSUrlSessionHandler.cs | 859 -------------------------- src/Makefile | 94 +-- src/ObjCRuntime/RuntimeOptions.cs | 58 -- 4 files changed, 2 insertions(+), 1011 deletions(-) delete mode 100644 src/Foundation/NSUrlSessionHandler.cs diff --git a/builds/Makefile b/builds/Makefile index 8ce7befae306..74c7b134646e 100644 --- a/builds/Makefile +++ b/builds/Makefile @@ -535,7 +535,7 @@ IOS_ASSEMBLIES = I18N.CJK I18N.MidEast I18N.Other I18N.Rare I18N.West I18N Mono. System.Numerics.Vectors System.Reflection.Context \ System.Security \ System.Windows System.Xml.Serialization System.Net \ - Microsoft.CSharp Mono.CSharp + Microsoft.CSharp Mono.CSharp System.Net.Http IOS_REPL_ASSEMBLIES = mscorlib System System.Core System.Xml Mono.CSharp diff --git a/src/Foundation/NSUrlSessionHandler.cs b/src/Foundation/NSUrlSessionHandler.cs deleted file mode 100644 index 84ce76e3280d..000000000000 --- a/src/Foundation/NSUrlSessionHandler.cs +++ /dev/null @@ -1,859 +0,0 @@ -// -// NSUrlSessionHandler.cs: -// -// Authors: -// Paul Betts -// Nick Berardi -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -using System; -using System.Collections.Generic; -using System.Globalization; -using System.IO; -using System.Linq; -using System.Net; -using System.Net.Http; -using System.Net.Http.Headers; -using System.Runtime.InteropServices; -using System.Threading; -using System.Threading.Tasks; -using System.Text; - -#if UNIFIED -using CoreFoundation; -using Foundation; -using Security; -#else -using MonoTouch.CoreFoundation; -using MonoTouch.Foundation; -using MonoTouch.Security; -using System.Globalization; -using nint = System.Int32; -using nuint = System.UInt32; -#endif - -#if !MONOMAC -using UIKit; -#endif - -#if SYSTEM_NET_HTTP -namespace System.Net.Http { -#else -namespace Foundation { -#endif - - // useful extensions for the class in order to set it in a header - static class NSHttpCookieExtensions - { - static void AppendSegment(StringBuilder builder, string name, string value) - { - if (builder.Length > 0) - builder.Append ("; "); - - builder.Append (name); - if (value != null) - builder.Append ("=").Append (value); - } - - // returns the header for a cookie - public static string GetHeaderValue (this NSHttpCookie cookie) - { - var header = new StringBuilder(); - AppendSegment (header, cookie.Name, cookie.Value); - AppendSegment (header, NSHttpCookie.KeyPath.ToString (), cookie.Path.ToString ()); - AppendSegment (header, NSHttpCookie.KeyDomain.ToString (), cookie.Domain.ToString ()); - AppendSegment (header, NSHttpCookie.KeyVersion.ToString (), cookie.Version.ToString ()); - - if (cookie.Comment != null) - AppendSegment (header, NSHttpCookie.KeyComment.ToString (), cookie.Comment.ToString()); - - if (cookie.CommentUrl != null) - AppendSegment (header, NSHttpCookie.KeyCommentUrl.ToString (), cookie.CommentUrl.ToString()); - - if (cookie.Properties.ContainsKey (NSHttpCookie.KeyDiscard)) - AppendSegment (header, NSHttpCookie.KeyDiscard.ToString (), null); - - if (cookie.ExpiresDate != null) { - // Format according to RFC1123; 'r' uses invariant info (DateTimeFormatInfo.InvariantInfo) - var dateStr = ((DateTime) cookie.ExpiresDate).ToUniversalTime ().ToString("r", CultureInfo.InvariantCulture); - AppendSegment (header, NSHttpCookie.KeyExpires.ToString (), dateStr); - } - - if (cookie.Properties.ContainsKey (NSHttpCookie.KeyMaximumAge)) { - var timeStampString = (NSString) cookie.Properties[NSHttpCookie.KeyMaximumAge]; - AppendSegment (header, NSHttpCookie.KeyMaximumAge.ToString (), timeStampString); - } - - if (cookie.IsSecure) - AppendSegment (header, NSHttpCookie.KeySecure.ToString(), null); - - if (cookie.IsHttpOnly) - AppendSegment (header, "httponly", null); // Apple does not show the key for the httponly - - return header.ToString (); - } - } - - public partial class NSUrlSessionHandler : HttpMessageHandler - { - private const string SetCookie = "Set-Cookie"; - readonly Dictionary headerSeparators = new Dictionary { - ["User-Agent"] = " ", - ["Server"] = " " - }; - - readonly NSUrlSession session; - readonly Dictionary inflightRequests; - readonly object inflightRequestsLock = new object (); -#if !MONOMAC && !MONOTOUCH_WATCH - readonly bool isBackgroundSession = false; - NSObject notificationToken; // needed to make sure we do not hang if not using a background session -#endif - - static NSUrlSessionConfiguration CreateConfig () - { - // modifying the configuration does not affect future calls - var config = NSUrlSessionConfiguration.DefaultSessionConfiguration; - // but we want, by default, the timeout from HttpClient to have precedence over the one from NSUrlSession - // Double.MaxValue does not work, so default to 24 hours - config.TimeoutIntervalForRequest = 24 * 60 * 60; - config.TimeoutIntervalForResource = 24 * 60 * 60; - return config; - } - - public NSUrlSessionHandler () : this (CreateConfig ()) - { - } - - [CLSCompliant (false)] - public NSUrlSessionHandler (NSUrlSessionConfiguration configuration) - { - if (configuration == null) - throw new ArgumentNullException (nameof (configuration)); - -#if !MONOMAC && !MONOTOUCH_WATCH - // if the configuration has an identifier, we are dealing with a background session, - // therefore, we do not have to listen to the notifications. - isBackgroundSession = !string.IsNullOrEmpty (configuration.Identifier); -#endif - - AllowAutoRedirect = true; - - // we cannot do a bitmask but we can set the minimum based on ServicePointManager.SecurityProtocol minimum - var sp = ServicePointManager.SecurityProtocol; - if ((sp & SecurityProtocolType.Ssl3) != 0) - configuration.TLSMinimumSupportedProtocol = SslProtocol.Ssl_3_0; - else if ((sp & SecurityProtocolType.Tls) != 0) - configuration.TLSMinimumSupportedProtocol = SslProtocol.Tls_1_0; - else if ((sp & SecurityProtocolType.Tls11) != 0) - configuration.TLSMinimumSupportedProtocol = SslProtocol.Tls_1_1; - else if ((sp & SecurityProtocolType.Tls12) != 0) - configuration.TLSMinimumSupportedProtocol = SslProtocol.Tls_1_2; - - session = NSUrlSession.FromConfiguration (configuration, (INSUrlSessionDelegate) new NSUrlSessionHandlerDelegate (this), null); - inflightRequests = new Dictionary (); - } - -#if !MONOMAC && !MONOTOUCH_WATCH - - void AddNotification () - { - if (!isBackgroundSession && notificationToken == null) - notificationToken = NSNotificationCenter.DefaultCenter.AddObserver (UIApplication.WillResignActiveNotification, BackgroundNotificationCb); - } - - void RemoveNotification () - { - if (notificationToken != null) { - NSNotificationCenter.DefaultCenter.RemoveObserver (notificationToken); - notificationToken = null; - } - } - - void BackgroundNotificationCb (NSNotification obj) - { - // we do not need to call the lock, we call cancel on the source, that will trigger all the needed code to - // clean the resources and such - foreach (var r in inflightRequests.Values) { - r.CompletionSource.TrySetCanceled (); - } - } -#endif - - public long MaxInputInMemory { get; set; } = long.MaxValue; - - void RemoveInflightData (NSUrlSessionTask task, bool cancel = true) - { - lock (inflightRequestsLock) { - inflightRequests.Remove (task); -#if !MONOMAC && !MONOTOUCH_WATCH - // do we need to be notified? If we have not inflightData, we do not - if (inflightRequests.Count == 0) - RemoveNotification (); -#endif - } - - if (cancel) - task?.Cancel (); - - task?.Dispose (); - } - - protected override void Dispose (bool disposing) - { -#if !MONOMAC && !MONOTOUCH_WATCH - // remove the notification if present, method checks against null - RemoveNotification (); -#endif - lock (inflightRequestsLock) { - foreach (var pair in inflightRequests) { - pair.Key?.Cancel (); - pair.Key?.Dispose (); - } - - inflightRequests.Clear (); - } - base.Dispose (disposing); - } - - bool disableCaching; - - public bool DisableCaching { - get { - return disableCaching; - } - set { - EnsureModifiability (); - disableCaching = value; - } - } - - string GetHeaderSeparator (string name) - { - string value; - if (!headerSeparators.TryGetValue (name, out value)) - value = ","; - return value; - } - - async Task CreateRequest (HttpRequestMessage request) - { - var stream = Stream.Null; - var headers = request.Headers as IEnumerable>>; - - if (request.Content != null) { - stream = await request.Content.ReadAsStreamAsync ().ConfigureAwait (false); - headers = headers.Union (request.Content.Headers).ToArray (); - } - - var nsrequest = new NSMutableUrlRequest { - AllowsCellularAccess = true, - CachePolicy = DisableCaching ? NSUrlRequestCachePolicy.ReloadIgnoringCacheData : NSUrlRequestCachePolicy.UseProtocolCachePolicy, - HttpMethod = request.Method.ToString ().ToUpperInvariant (), - Url = NSUrl.FromString (request.RequestUri.AbsoluteUri), - Headers = headers.Aggregate (new NSMutableDictionary (), (acc, x) => { - acc.Add (new NSString (x.Key), new NSString (string.Join (GetHeaderSeparator (x.Key), x.Value))); - return acc; - }) - }; - if (stream != Stream.Null) { - // HttpContent.TryComputeLength is `protected internal` :-( but it's indirectly called by headers - var length = request.Content.Headers.ContentLength; - if (length.HasValue && (length <= MaxInputInMemory)) - nsrequest.Body = NSData.FromStream (stream); - else - nsrequest.BodyStream = new WrappedNSInputStream (stream); - } - return nsrequest; - } - -#if SYSTEM_NET_HTTP || MONOMAC - internal -#endif - protected override async Task SendAsync (HttpRequestMessage request, CancellationToken cancellationToken) - { - Volatile.Write (ref sentRequest, true); - - var nsrequest = await CreateRequest (request).ConfigureAwait(false); - var dataTask = session.CreateDataTask (nsrequest); - - var tcs = new TaskCompletionSource (); - - lock (inflightRequestsLock) { -#if !MONOMAC && !MONOTOUCH_WATCH - // Add the notification whenever needed - AddNotification (); -#endif - inflightRequests.Add (dataTask, new InflightData { - RequestUrl = request.RequestUri.AbsoluteUri, - CompletionSource = tcs, - CancellationToken = cancellationToken, - Stream = new NSUrlSessionDataTaskStream (), - Request = request - }); - } - - if (dataTask.State == NSUrlSessionTaskState.Suspended) - dataTask.Resume (); - - // as per documentation: - // If this token is already in the canceled state, the - // delegate will be run immediately and synchronously. - // Any exception the delegate generates will be - // propagated out of this method call. - // - // The execution of the register ensures that if we - // receive a already cancelled token or it is cancelled - // just before this call, we will cancel the task. - // Other approaches are harder, since querying the state - // of the token does not guarantee that in the next - // execution a threads cancels it. - cancellationToken.Register (() => { - RemoveInflightData (dataTask); - tcs.TrySetCanceled (); - }); - - return await tcs.Task.ConfigureAwait (false); - } - -#if MONOMAC - // Needed since we strip during linking since we're inside a product assembly. - [Preserve (AllMembers = true)] -#endif - partial class NSUrlSessionHandlerDelegate : NSUrlSessionDataDelegate - { - readonly NSUrlSessionHandler sessionHandler; - - public NSUrlSessionHandlerDelegate (NSUrlSessionHandler handler) - { - sessionHandler = handler; - } - - InflightData GetInflightData (NSUrlSessionTask task) - { - var inflight = default (InflightData); - - lock (sessionHandler.inflightRequestsLock) - if (sessionHandler.inflightRequests.TryGetValue (task, out inflight)) { - // ensure that we did not cancel the request, if we did, do cancel the task - if (inflight.CancellationToken.IsCancellationRequested) - task?.Cancel (); - return inflight; - } - - // if we did not manage to get the inflight data, we either got an error or have been canceled, lets cancel the task, that will execute DidCompleteWithError - task?.Cancel (); - return null; - } - - public override void DidReceiveResponse (NSUrlSession session, NSUrlSessionDataTask dataTask, NSUrlResponse response, Action completionHandler) - { - var inflight = GetInflightData (dataTask); - - if (inflight == null) - return; - - try { - var urlResponse = (NSHttpUrlResponse)response; - var status = (int)urlResponse.StatusCode; - - var content = new NSUrlSessionDataTaskStreamContent (inflight.Stream, () => { - if (!inflight.Completed) { - dataTask.Cancel (); - } - - inflight.Disposed = true; - inflight.Stream.TrySetException (new ObjectDisposedException ("The content stream was disposed.")); - - sessionHandler.RemoveInflightData (dataTask); - }, inflight.CancellationToken); - - // NB: The double cast is because of a Xamarin compiler bug - var httpResponse = new HttpResponseMessage ((HttpStatusCode)status) { - Content = content, - RequestMessage = inflight.Request - }; - httpResponse.RequestMessage.RequestUri = new Uri (urlResponse.Url.AbsoluteString); - - foreach (var v in urlResponse.AllHeaderFields) { - // NB: Cocoa trolling us so hard by giving us back dummy dictionary entries - if (v.Key == null || v.Value == null) continue; - // NSUrlSession tries to be smart with cookies, we will not use the raw value but the ones provided by the cookie storage - if (v.Key.ToString () == SetCookie) continue; - - httpResponse.Headers.TryAddWithoutValidation (v.Key.ToString (), v.Value.ToString ()); - httpResponse.Content.Headers.TryAddWithoutValidation (v.Key.ToString (), v.Value.ToString ()); - } - - var cookies = session.Configuration.HttpCookieStorage.CookiesForUrl (response.Url); - for (var index = 0; index < cookies.Length; index++) { - httpResponse.Headers.TryAddWithoutValidation (SetCookie, cookies [index].GetHeaderValue ()); - } - - inflight.Response = httpResponse; - - // We don't want to send the response back to the task just yet. Because we want to mimic .NET behavior - // as much as possible. When the response is sent back in .NET, the content stream is ready to read or the - // request has completed, because of this we want to send back the response in DidReceiveData or DidCompleteWithError - if (dataTask.State == NSUrlSessionTaskState.Suspended) - dataTask.Resume (); - - } catch (Exception ex) { - inflight.CompletionSource.TrySetException (ex); - inflight.Stream.TrySetException (ex); - - sessionHandler.RemoveInflightData (dataTask); - } - - completionHandler (NSUrlSessionResponseDisposition.Allow); - } - - public override void DidReceiveData (NSUrlSession session, NSUrlSessionDataTask dataTask, NSData data) - { - var inflight = GetInflightData (dataTask); - - if (inflight == null) - return; - - inflight.Stream.Add (data); - SetResponse (inflight); - } - - public override void DidCompleteWithError (NSUrlSession session, NSUrlSessionTask task, NSError error) - { - var inflight = GetInflightData (task); - - // this can happen if the HTTP request times out and it is removed as part of the cancellation process - if (inflight != null) { - // set the stream as finished - inflight.Stream.TrySetReceivedAllData (); - - // send the error or send the response back - if (error != null) { - inflight.Errored = true; - - var exc = createExceptionForNSError (error); - inflight.CompletionSource.TrySetException (exc); - inflight.Stream.TrySetException (exc); - } else { - inflight.Completed = true; - SetResponse (inflight); - } - - sessionHandler.RemoveInflightData (task, cancel: false); - } - } - - void SetResponse (InflightData inflight) - { - lock (inflight.Lock) { - if (inflight.ResponseSent) - return; - - if (inflight.CompletionSource.Task.IsCompleted) - return; - - var httpResponse = inflight.Response; - - inflight.ResponseSent = true; - - // EVIL HACK: having TrySetResult inline was blocking the request from completing - Task.Run (() => inflight.CompletionSource.TrySetResult (httpResponse)); - } - } - - public override void WillCacheResponse (NSUrlSession session, NSUrlSessionDataTask dataTask, NSCachedUrlResponse proposedResponse, Action completionHandler) - { - completionHandler (sessionHandler.DisableCaching ? null : proposedResponse); - } - - public override void WillPerformHttpRedirection (NSUrlSession session, NSUrlSessionTask task, NSHttpUrlResponse response, NSUrlRequest newRequest, Action completionHandler) - { - completionHandler (sessionHandler.AllowAutoRedirect ? newRequest : null); - } - - public override void DidReceiveChallenge (NSUrlSession session, NSUrlSessionTask task, NSUrlAuthenticationChallenge challenge, Action completionHandler) - { - var inflight = GetInflightData (task); - - if (inflight == null) - return; - - // case for the basic auth failing up front. As per apple documentation: - // The URL Loading System is designed to handle various aspects of the HTTP protocol for you. As a result, you should not modify the following headers using - // the addValue(_:forHTTPHeaderField:) or setValue(_:forHTTPHeaderField:) methods: - // Authorization - // Connection - // Host - // Proxy-Authenticate - // Proxy-Authorization - // WWW-Authenticate - // but we are hiding such a situation from our users, we can nevertheless know if the header was added and deal with it. The idea is as follows, - // check if we are in the first attempt, if we are (PreviousFailureCount == 0), we check the headers of the request and if we do have the Auth - // header, it means that we do not have the correct credentials, in any other case just do what it is expected. - - if (challenge.PreviousFailureCount == 0) { - var authHeader = inflight.Request?.Headers?.Authorization; - if (!(string.IsNullOrEmpty (authHeader?.Scheme) && string.IsNullOrEmpty (authHeader?.Parameter))) { - completionHandler (NSUrlSessionAuthChallengeDisposition.RejectProtectionSpace, null); - return; - } - } - - if (sessionHandler.Credentials != null && TryGetAuthenticationType (challenge.ProtectionSpace, out string authType)) { - NetworkCredential credentialsToUse = null; - if (authType != RejectProtectionSpaceAuthType) { - var uri = inflight.Request.RequestUri; - credentialsToUse = sessionHandler.Credentials.GetCredential (uri, authType); - } - - if (credentialsToUse != null) { - var credential = new NSUrlCredential (credentialsToUse.UserName, credentialsToUse.Password, NSUrlCredentialPersistence.ForSession); - completionHandler (NSUrlSessionAuthChallengeDisposition.UseCredential, credential); - } else { - // Rejecting the challenge allows the next authentication method in the request to be delivered to - // the DidReceiveChallenge method. Another authentication method may have credentials available. - completionHandler (NSUrlSessionAuthChallengeDisposition.RejectProtectionSpace, null); - } - } else { - completionHandler (NSUrlSessionAuthChallengeDisposition.PerformDefaultHandling, challenge.ProposedCredential); - } - } - - static readonly string RejectProtectionSpaceAuthType = "reject"; - - static bool TryGetAuthenticationType (NSUrlProtectionSpace protectionSpace, out string authenticationType) - { - if (protectionSpace.AuthenticationMethod == NSUrlProtectionSpace.AuthenticationMethodNTLM) { - authenticationType = "NTLM"; - } else if (protectionSpace.AuthenticationMethod == NSUrlProtectionSpace.AuthenticationMethodHTTPBasic) { - authenticationType = "basic"; - } else if (protectionSpace.AuthenticationMethod == NSUrlProtectionSpace.AuthenticationMethodNegotiate || - protectionSpace.AuthenticationMethod == NSUrlProtectionSpace.AuthenticationMethodHTMLForm || - protectionSpace.AuthenticationMethod == NSUrlProtectionSpace.AuthenticationMethodHTTPDigest) { - // Want to reject this authentication type to allow the next authentication method in the request to - // be used. - authenticationType = RejectProtectionSpaceAuthType; - } else { - // ServerTrust, ClientCertificate or Default. - authenticationType = null; - return false; - } - return true; - } - } - -#if MONOMAC - // Needed since we strip during linking since we're inside a product assembly. - [Preserve (AllMembers = true)] -#endif - class InflightData - { - public readonly object Lock = new object (); - public string RequestUrl { get; set; } - - public TaskCompletionSource CompletionSource { get; set; } - public CancellationToken CancellationToken { get; set; } - public NSUrlSessionDataTaskStream Stream { get; set; } - public HttpRequestMessage Request { get; set; } - public HttpResponseMessage Response { get; set; } - - public bool ResponseSent { get; set; } - public bool Errored { get; set; } - public bool Disposed { get; set; } - public bool Completed { get; set; } - public bool Done { get { return Errored || Disposed || Completed || CancellationToken.IsCancellationRequested; } } - } - -#if MONOMAC - // Needed since we strip during linking since we're inside a product assembly. - [Preserve (AllMembers = true)] -#endif - class NSUrlSessionDataTaskStreamContent : StreamContent - { - Action disposed; - - public NSUrlSessionDataTaskStreamContent (NSUrlSessionDataTaskStream source, Action onDisposed, CancellationToken token) : base (source, token) - { - disposed = onDisposed; - } - - protected override void Dispose (bool disposing) - { - var action = Interlocked.Exchange (ref disposed, null); - action?.Invoke (); - - base.Dispose (disposing); - } - } - -#if MONOMAC - // Needed since we strip during linking since we're inside a product assembly. - [Preserve (AllMembers = true)] -#endif - class NSUrlSessionDataTaskStream : Stream - { - readonly Queue data; - readonly object dataLock = new object (); - - long position; - long length; - - bool receivedAllData; - Exception exc; - - NSData current; - Stream currentStream; - - public NSUrlSessionDataTaskStream () - { - data = new Queue (); - } - - public void Add (NSData d) - { - lock (dataLock) { - data.Enqueue (d); - length += (int)d.Length; - } - } - - public void TrySetReceivedAllData () - { - receivedAllData = true; - } - - public void TrySetException (Exception e) - { - exc = e; - TrySetReceivedAllData (); - } - - void ThrowIfNeeded (CancellationToken cancellationToken) - { - if (exc != null) - throw exc; - - cancellationToken.ThrowIfCancellationRequested (); - } - - public override int Read (byte [] buffer, int offset, int count) - { - return ReadAsync (buffer, offset, count).Result; - } - - public override async Task ReadAsync (byte [] buffer, int offset, int count, CancellationToken cancellationToken) - { - // try to throw on enter - ThrowIfNeeded (cancellationToken); - - while (current == null) { - lock (dataLock) { - if (data.Count == 0 && receivedAllData && position == length) - return 0; - - if (data.Count > 0 && current == null) { - current = data.Peek (); - currentStream = current.AsStream (); - break; - } - } - - await Task.Delay (50).ConfigureAwait (false); - } - - // try to throw again before read - ThrowIfNeeded (cancellationToken); - - var d = currentStream; - var bufferCount = Math.Min (count, (int)(d.Length - d.Position)); - var bytesRead = await d.ReadAsync (buffer, offset, bufferCount, cancellationToken).ConfigureAwait (false); - - // add the bytes read from the pointer to the position - position += bytesRead; - - // remove the current primary reference if the current position has reached the end of the bytes - if (d.Position == d.Length) { - lock (dataLock) { - // this is the same object, it was done to make the cleanup - data.Dequeue (); - currentStream?.Dispose (); - // We cannot use current?.Dispose. The reason is the following one: - // In the DidReceiveResponse, if iOS realizes that a buffer can be reused, - // because the data is the same, it will do so. Such a situation does happen - // between requests, that is, request A and request B will get the same NSData - // (buffer) in the delegate. In this case, we cannot dispose the NSData because - // it might be that a different request received it and it is present in - // its NSUrlSessionDataTaskStream stream. We can only trust the gc to do the job - // which is better than copying the data over. - current = null; - currentStream = null; - } - } - - return bytesRead; - } - - public override bool CanRead => true; - - public override bool CanSeek => false; - - public override bool CanWrite => false; - - public override bool CanTimeout => false; - - public override long Length => length; - - public override void SetLength (long value) - { - throw new InvalidOperationException (); - } - - public override long Position { - get { return position; } - set { throw new InvalidOperationException (); } - } - - public override long Seek (long offset, SeekOrigin origin) - { - throw new InvalidOperationException (); - } - - public override void Flush () - { - throw new InvalidOperationException (); - } - - public override void Write (byte [] buffer, int offset, int count) - { - throw new InvalidOperationException (); - } - } - -#if MONOMAC - // Needed since we strip during linking since we're inside a product assembly. - [Preserve (AllMembers = true)] -#endif - class WrappedNSInputStream : NSInputStream - { - NSStreamStatus status; - CFRunLoopSource source; - readonly Stream stream; - bool notifying; - - public WrappedNSInputStream (Stream inputStream) - { - status = NSStreamStatus.NotOpen; - stream = inputStream; - source = new CFRunLoopSource (Handle); - } - - public override NSStreamStatus Status => status; - - public override void Open () - { - status = NSStreamStatus.Open; - Notify (CFStreamEventType.OpenCompleted); - } - - public override void Close () - { - status = NSStreamStatus.Closed; - } - - public override nint Read (IntPtr buffer, nuint len) - { - var sourceBytes = new byte [len]; - var read = stream.Read (sourceBytes, 0, (int)len); - Marshal.Copy (sourceBytes, 0, buffer, (int)len); - - if (notifying) - return read; - - notifying = true; - if (stream.CanSeek && stream.Position == stream.Length) { - Notify (CFStreamEventType.EndEncountered); - status = NSStreamStatus.AtEnd; - } - notifying = false; - - return read; - } - - public override bool HasBytesAvailable () - { - return true; - } - - protected override bool GetBuffer (out IntPtr buffer, out nuint len) - { - // Just call the base implemention (which will return false) - return base.GetBuffer (out buffer, out len); - } - - // NSInvalidArgumentException Reason: *** -propertyForKey: only defined for abstract class. Define -[System_Net_Http_NSUrlSessionHandler_WrappedNSInputStream propertyForKey:]! - protected override NSObject GetProperty (NSString key) - { - return null; - } - - protected override bool SetProperty (NSObject property, NSString key) - { - return false; - } - - protected override bool SetCFClientFlags (CFStreamEventType inFlags, IntPtr inCallback, IntPtr inContextPtr) - { - // Just call the base implementation, which knows how to handle everything. - return base.SetCFClientFlags (inFlags, inCallback, inContextPtr); - } - - public override void Schedule (NSRunLoop aRunLoop, string mode) - { - var cfRunLoop = aRunLoop.GetCFRunLoop (); - var nsMode = new NSString (mode); - - cfRunLoop.AddSource (source, nsMode); - - if (notifying) - return; - - notifying = true; - Notify (CFStreamEventType.HasBytesAvailable); - notifying = false; - } - - public override void Unschedule (NSRunLoop aRunLoop, string mode) - { - var cfRunLoop = aRunLoop.GetCFRunLoop (); - var nsMode = new NSString (mode); - - cfRunLoop.RemoveSource (source, nsMode); - } - - protected override void Dispose (bool disposing) - { - stream?.Dispose (); - } - } - } -} diff --git a/src/Makefile b/src/Makefile index bd66bb7471c2..afa153904a1c 100644 --- a/src/Makefile +++ b/src/Makefile @@ -203,44 +203,6 @@ $(MONO_PATH)/mcs/class/lib/monotouch/reference_Facades/netstandard.dll: $(IOS_BU $(IOS_BUILD_DIR)/%/Facades/netstandard.dll: $(MONO_PATH)/mcs/class/lib/monotouch/%_Facades/netstandard.dll | $(IOS_BUILD_DIR)/compat/Facades $(IOS_BUILD_DIR)/reference/Facades $(Q) $(CP) $< $@ -# -# System.Net.Http is special -# -# System.Net.Http has a 2-step build process: -# -# 1. We build it like all the other BCL assemblies (part of the -# regular BCL build), since there are other BCL assemblies (Facades) -# that reference System.Net.Http.dll -# 2. Then we build it a second time in src/, where we add additional -# source code (public types) and a reference to Xamarin.iOS.dll. -# -# This means we need to install the correct System.Net.Http.dll from here -# (builds/Makefile does not install the BCL version of System.Net.Http.dll) -# - -IOS_EXTRA_SYSTEM_NET_HTTP_FILES = \ - $(abspath $(MONO_PATH)/mcs/class/System.Net.Http/CFContentStream.cs) \ - $(abspath $(MONO_PATH)/mcs/class/System.Net.Http/CFNetworkHandler.cs) \ - $(abspath $(MONO_PATH)/mcs/class/System.Net.Http/HttpClientEx.cs) \ - $(abspath $(TOP)/src/Foundation/NSUrlSessionHandler.cs) \ - $(abspath $(TOP)/src/ObjCRuntime/RuntimeOptions.cs) \ - -# build (into custom LIBRARY_SUBDIR) -$(MONO_PATH)/mcs/class/lib/monotouch/reference/System.Net.Http%dll $(MONO_PATH)/mcs/class/lib/monotouch/reference/System.Net.Http%pdb: $(IOS_EXTRA_SYSTEM_NET_HTTP_FILES) $(MONO_PATH)/mcs/class/lib/monotouch/System.Net.Http.dll $(IOS_BUILD_DIR)/reference/Xamarin.iOS.dll - $(call Q_PROF_CSC,ios/unified) $(MAKE) $(if $(V),,-s) -C $(MONO_PATH)/mcs/class/System.Net.Http PROFILE=monotouch LIBRARY_SUBDIR=reference MONOTOUCH_MCS_FLAGS=$(IOS_CSC_FLAGS) EXTRA_LIB_MCS_FLAGS="-r:$(abspath $(IOS_BUILD_DIR)/reference/Xamarin.iOS.dll) $(IOS_EXTRA_SYSTEM_NET_HTTP_FILES) -D:XAMCORE_2_0 -D:XAMARIN_MODERN -D:SYSTEM_NET_HTTP -D:UNIFIED -D:__UNIFIED__" - @# If the make we executed didn't result in building the dll/pdb (because make determined it wasn't necessary to rebuild), - @# then this make can end up confused and in an infinite loop. So touch the output files, to make sure they look rebuilt to make. - $(Q) touch $(basename $@).dll $(basename $@).pdb - -# sign dll (one target for both compat+reference) -$(IOS_BUILD_DIR)/%/System.Net.Http.dll: $(MONO_PATH)/mcs/class/lib/monotouch/%/System.Net.Http.dll | $(IOS_BUILD_DIR)/compat $(IOS_BUILD_DIR)/reference - $(Q) $(CP) $< $@ - $(call Q_PROF_SN,ios/$@) MONO_CFG_DIR=$(TOP) $(SYSTEM_SN) -q -R $@ $(PRODUCT_KEY_PATH) - -# (one target for both compat+reference) -$(IOS_BUILD_DIR)/%/System.Net.Http.pdb: $(MONO_PATH)/mcs/class/lib/monotouch/%/System.Net.Http.pdb | $(IOS_BUILD_DIR)/compat $(IOS_BUILD_DIR)/reference - $(Q) $(CP) $< $@ - clean-local:: rm -rf build rm -f $(IOS_TARGETS) generated_sources *.mdb *.pdb @@ -261,8 +223,6 @@ IOS_TARGETS_DIRS += \ IOS_TARGETS += \ $(PROJECT_DIR)/xamios.csproj \ $(PROJECT_DIR)/MonoTouch.NUnitLite.csproj \ - $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/mono/2.1/System.Net.Http.dll \ - $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/mono/2.1/System.Net.Http.pdb \ $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/mono/2.1/monotouch.dll \ $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/mono/2.1/monotouch.dll.mdb \ $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/mono/2.1/OpenTK.dll \ @@ -285,8 +245,6 @@ IOS_TARGETS += \ $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/mono/Xamarin.iOS/OpenTK-1.0.dll \ $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/mono/Xamarin.iOS/OpenTK-1.0.pdb \ $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/mono/Xamarin.iOS/OpenTK-1.0.dll.config \ - $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/mono/Xamarin.iOS/System.Net.Http.dll \ - $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/mono/Xamarin.iOS/System.Net.Http.pdb \ $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/mono/Xamarin.iOS/Facades/System.Drawing.Primitives.dll \ $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/mono/Xamarin.iOS/Facades/netstandard.dll \ $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/32bits/Xamarin.iOS.dll \ @@ -404,7 +362,7 @@ MAC_CFNETWORK_SOURCES = \ MAC_MODERNHTTP_SOURCES = \ $(abspath $(MONO_PATH)/mcs/class/System.Net.Http/HttpClientEx.cs) \ - $(abspath $(TOP)/src/Foundation/NSUrlSessionHandler.cs) \ + $(abspath $(MONO_PATH)/mcs/class/System.Net.Http/NSUrlSessionHandler.cs) \ $(abspath $(MONO_PATH)/mcs/class/System.Net.Http/CFContentStream.cs) \ $(abspath $(MONO_PATH)/mcs/class/System.Net.Http/CFNetworkHandler.cs) \ @@ -782,28 +740,6 @@ $(MONO_PATH)/mcs/class/lib/monotouch_watch/reference_Facades/netstandard.dll: $( $(WATCH_BUILD_DIR)/%/Facades/netstandard.dll: $(MONO_PATH)/mcs/class/lib/monotouch_watch/%_Facades/netstandard.dll | $(WATCH_BUILD_DIR)/reference/Facades $(Q) $(CP) $< $@ -# System.Net.Http.dll is special. See comment in src/Makefile - -WATCH_EXTRA_SYSTEM_NET_HTTP_FILES = \ - $(abspath $(MONO_PATH)/mcs/class/System.Net.Http/HttpClientEx.cs) \ - $(abspath $(TOP)/src/Foundation/NSUrlSessionHandler.cs) \ - $(abspath $(TOP)/src/ObjCRuntime/RuntimeOptions.cs) \ - -# build (into custom LIBRARY_SUBDIR) -$(MONO_PATH)/mcs/class/lib/monotouch_watch/reference/System.Net.Http%dll $(MONO_PATH)/mcs/class/lib/monotouch_watch/reference/System.Net.Http%pdb: $(WATCH_EXTRA_SYSTEM_NET_HTTP_FILES) $(MONO_PATH)/mcs/class/lib/monotouch_watch/System.Net.Http.dll $(WATCH_BUILD_DIR)/reference/Xamarin.WatchOS.dll - $(call Q_PROF_CSC,watch) $(MAKE) $(if $(V),,-s) -C $(MONO_PATH)/mcs/class/System.Net.Http PROFILE=monotouch_watch LIBRARY_SUBDIR=reference MONOTOUCH_MCS_FLAGS=$(IOS_CSC_FLAGS) EXTRA_LIB_MCS_FLAGS="-r:$(abspath $(WATCH_BUILD_DIR)/reference/Xamarin.WatchOS.dll) $(WATCH_EXTRA_SYSTEM_NET_HTTP_FILES) -D:XAMCORE_2_0 -D:XAMCORE_3_0 -D:XAMARIN_MODERN -D:SYSTEM_NET_HTTP -D:UNIFIED -D:__UNIFIED__" - @# If the make we executed didn't result in building the dll/pdb (because make determined it wasn't necessary to rebuild), - @# then this make can end up confused and in an infinite loop. So touch the output files, to make sure they look rebuilt to make. - $(Q) touch $(basename $@).dll $(basename $@).pdb - -# sign dll -$(WATCH_BUILD_DIR)/reference/System.Net.Http.dll: $(MONO_PATH)/mcs/class/lib/monotouch_watch/reference/System.Net.Http.dll | $(WATCH_BUILD_DIR)/reference - $(Q) $(CP) $< $@ - $(call Q_PROF_SN,watch) MONO_CFG_DIR=$(TOP) $(SYSTEM_SN) -q -R $@ $(PRODUCT_KEY_PATH) - -$(WATCH_BUILD_DIR)/reference/System.Net.Http.pdb: $(MONO_PATH)/mcs/class/lib/monotouch_watch/reference/System.Net.Http.pdb | $(WATCH_BUILD_DIR)/reference - $(Q) $(CP) $< $@ - $(PROJECT_DIR)/xamwatch.csproj: xamwatch.tmpl.csproj Makefile $(wildcard $(TOP)/*.sources) @sed -e 's**$(foreach file,$(WATCHOS_SOURCES),)*' -e 's**$(foreach file,$(WATCHOS_APIS),)*' $< | xmllint --format - > $@ @@ -832,8 +768,6 @@ WATCH_TARGETS += \ $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/mono/Xamarin.WatchOS/Xamarin.WatchOS.pdb \ $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/32bits/Xamarin.WatchOS.dll \ $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/32bits/Xamarin.WatchOS.pdb \ - $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/mono/Xamarin.WatchOS/System.Net.Http.dll \ - $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/mono/Xamarin.WatchOS/System.Net.Http.pdb \ $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/mono/Xamarin.WatchOS/MonoTouch.NUnitLite.dll \ $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/mono/Xamarin.WatchOS/MonoTouch.NUnitLite.pdb \ $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/mono/Xamarin.WatchOS/Facades/System.Drawing.Primitives.dll \ @@ -997,30 +931,6 @@ $(MONO_PATH)/mcs/class/lib/monotouch_tv/reference_Facades/netstandard.dll: $(TVO $(TVOS_BUILD_DIR)/%/Facades/netstandard.dll: $(MONO_PATH)/mcs/class/lib/monotouch_tv/%_Facades/netstandard.dll | $(TVOS_BUILD_DIR)/reference/Facades $(Q) $(CP) $< $@ -# System.Net.Http.dll is special. See comment in src/Makefile - -TVOS_EXTRA_SYSTEM_NET_HTTP_FILES = \ - $(abspath $(MONO_PATH)/mcs/class/System.Net.Http/CFContentStream.cs) \ - $(abspath $(MONO_PATH)/mcs/class/System.Net.Http/CFNetworkHandler.cs) \ - $(abspath $(MONO_PATH)/mcs/class/System.Net.Http/HttpClientEx.cs) \ - $(abspath $(TOP)/src/Foundation/NSUrlSessionHandler.cs) \ - $(abspath $(TOP)/src/ObjCRuntime/RuntimeOptions.cs) \ - -# build (into custom LIBRARY_SUBDIR) -$(MONO_PATH)/mcs/class/lib/monotouch_tv/reference/System.Net.Http%dll $(MONO_PATH)/mcs/class/lib/monotouch_tv/reference/System.Net.Http%pdb: $(TVOS_EXTRA_SYSTEM_NET_HTTP_FILES) $(MONO_PATH)/mcs/class/lib/monotouch_tv/System.Net.Http.dll $(TVOS_BUILD_DIR)/reference/Xamarin.TVOS.dll - $(call Q_PROF_CSC,tvos) $(MAKE) $(if $(V),,-s) -C $(MONO_PATH)/mcs/class/System.Net.Http PROFILE=monotouch_tv LIBRARY_SUBDIR=reference MONOTOUCH_MCS_FLAGS=$(IOS_CSC_FLAGS) EXTRA_LIB_MCS_FLAGS="-r:$(abspath $(TVOS_BUILD_DIR)/reference/Xamarin.TVOS.dll) $(TVOS_EXTRA_SYSTEM_NET_HTTP_FILES) -D:XAMCORE_2_0 -D:XAMCORE_3_0 -D:XAMARIN_MODERN -D:SYSTEM_NET_HTTP -D:UNIFIED -D:__UNIFIED__" - @# If the make we executed didn't result in building the dll/pdb (because make determined it wasn't necessary to rebuild), - @# then this make can end up confused and in an infinite loop. So touch the output files, to make sure they look rebuilt to make. - $(Q) touch $(basename $@).dll $(basename $@).pdb - -# sign dll -$(TVOS_BUILD_DIR)/reference/System.Net.Http.dll: $(MONO_PATH)/mcs/class/lib/monotouch_tv/reference/System.Net.Http.dll | $(TVOS_BUILD_DIR)/reference - $(Q) $(CP) $< $@ - $(call Q_PROF_SN,tvos) MONO_CFG_DIR=$(TOP) $(SYSTEM_SN) -q -R $@ $(PRODUCT_KEY_PATH) - -$(TVOS_BUILD_DIR)/reference/System.Net.Http.pdb: $(MONO_PATH)/mcs/class/lib/monotouch_tv/reference/System.Net.Http.pdb | $(TVOS_BUILD_DIR)/reference - $(Q) $(CP) $< $@ - $(PROJECT_DIR)/xamtvos.csproj: xamtvos.tmpl.csproj Makefile $(wildcard $(TOP)/*.sources) @sed -e 's**$(foreach file,$(TVOS_SOURCES),)*' -e 's**$(foreach file,$(TVOS_APIS),)*' $< | xmllint --format - > $@ @@ -1051,8 +961,6 @@ TVOS_TARGETS += \ $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/mono/Xamarin.TVOS/Xamarin.TVOS.pdb \ $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/64bits/Xamarin.TVOS.dll \ $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/64bits/Xamarin.TVOS.pdb \ - $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/mono/Xamarin.TVOS/System.Net.Http.dll \ - $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/mono/Xamarin.TVOS/System.Net.Http.pdb \ $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/mono/Xamarin.TVOS/OpenTK-1.0.dll \ $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/mono/Xamarin.TVOS/OpenTK-1.0.pdb \ $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/mono/Xamarin.TVOS/OpenTK-1.0.dll.config \ diff --git a/src/ObjCRuntime/RuntimeOptions.cs b/src/ObjCRuntime/RuntimeOptions.cs index ff13794d1b5a..b63cc24d7cfc 100644 --- a/src/ObjCRuntime/RuntimeOptions.cs +++ b/src/ObjCRuntime/RuntimeOptions.cs @@ -5,8 +5,6 @@ #if MTOUCH || MMP using Mono.Cecil; using Xamarin.Linker; -#elif SYSTEM_NET_HTTP || (MONOMAC && XAMCORE_2_0) -using System.Net.Http; #endif #if XAMCORE_2_0 @@ -22,8 +20,6 @@ #if MMP || MMP_TEST || MTOUCH namespace Xamarin.Bundler { -#elif SYSTEM_NET_HTTP -namespace System.Net.Http { #else namespace ObjCRuntime { #endif @@ -181,60 +177,6 @@ internal static TypeDefinition GetHttpMessageHandler (Application app, RuntimeOp throw new InvalidOperationException (string.Format ("Cannot load HttpMessageHandler `{0}`.", handler)); return type; } -#else - - internal static RuntimeOptions Read () - { - // for iOS NSBundle.ResourcePath returns the path to the root of the app bundle - // for macOS apps NSBundle.ResourcePath returns foo.app/Contents/Resources - // for macOS frameworks NSBundle.ResourcePath returns foo.app/Versions/Current/Resources - Class bundle_finder = new Class (typeof (NSObject.NSObject_Disposer)); - var resource_dir = NSBundle.FromClass (bundle_finder).ResourcePath; - var plist_path = GetFileName (resource_dir); - - if (!File.Exists (plist_path)) - return null; - - using (var plist = NSDictionary.FromFile (plist_path)) { - var options = new RuntimeOptions (); - options.http_message_handler = (NSString) plist ["HttpMessageHandler"]; - return options; - } - } - -#if SYSTEM_NET_HTTP || (MONOMAC && XAMCORE_2_0) -#if MONOMAC - [Preserve] -#endif - internal static HttpMessageHandler GetHttpMessageHandler () - { - var options = RuntimeOptions.Read (); - if (options == null) { -#if MONOTOUCH_WATCH - return new NSUrlSessionHandler (); -#else - return new HttpClientHandler (); -#endif - } - - // all types will be present as this is executed only when the linker is not enabled - var handler_name = options.http_message_handler; - var t = Type.GetType (handler_name, false); - - HttpMessageHandler handler = null; - if (t != null) - handler = Activator.CreateInstance (t) as HttpMessageHandler; - if (handler != null) - return handler; -#if MONOTOUCH_WATCH - Console.WriteLine ("{0} is not a valid HttpMessageHandler, defaulting to NSUrlSessionHandler", handler_name); - return new NSUrlSessionHandler (); -#else - Console.WriteLine ("{0} is not a valid HttpMessageHandler, defaulting to System.Net.Http.HttpClientHandler", handler_name); - return new HttpClientHandler (); -#endif - } -#endif #endif // Use either Create() or Read(). From 8274161551ec9ab758dacca5b1495adda995f54e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Fri, 15 Feb 2019 15:10:34 +0100 Subject: [PATCH 06/96] Update mmp/mtouch projects to add new linker files and adapt to new logic --- tools/linker/CoreMarkStep.cs | 25 ++++++------------------- tools/linker/MobileMarkStep.cs | 6 +++--- tools/mmp/mmp.csproj | 15 +++++++++++++++ tools/mtouch/mtouch.csproj | 15 +++++++++++++++ 4 files changed, 39 insertions(+), 22 deletions(-) diff --git a/tools/linker/CoreMarkStep.cs b/tools/linker/CoreMarkStep.cs index a2868f115d5a..c19c858f0867 100644 --- a/tools/linker/CoreMarkStep.cs +++ b/tools/linker/CoreMarkStep.cs @@ -281,36 +281,23 @@ protected override MethodDefinition MarkMethod (MethodReference reference) return method; } - protected override void MarkInterfaceImplementation (TypeDefinition type, InterfaceImplementation iface) + protected override bool ShouldMarkInterfaceImplementation (TypeDefinition type, InterfaceImplementation iface, TypeDefinition resolvedInterfaceType) { if (RegisterProtocols) { // If we're registering protocols, we can remove interfaces that represent protocols. // The linker will automatically mark interfaces a class implements, but we have to // override the linker behavior for interfaces that represent protocols for those // interfaces to be removed. - var mark = false; - var interfaceType = iface.InterfaceType.Resolve (); - var isProtocol = type.IsNSObject (LinkContext) && interfaceType.HasCustomAttribute (LinkContext, Namespaces.Foundation, "ProtocolAttribute"); + var isProtocol = type.IsNSObject (LinkContext) && resolvedInterfaceType.HasCustomAttribute (LinkContext, Namespaces.Foundation, "ProtocolAttribute"); - if (IgnoreScope (type.Scope)) { - // We're not linking the current assembly, which means the interface should be marked. - mark = true; - } else if (!isProtocol) { - // We only skip interfaces that represent protocols. - mark = true; - } - - if (!mark) { - if (isProtocol) - LinkContext.StoreProtocolMethods (interfaceType); - - return; + // We're not linking the current assembly, which means the interface should be marked. + if (isProtocol && !IgnoreScope (type.Scope)) { + LinkContext.StoreProtocolMethods (resolvedInterfaceType); } } - - base.MarkInterfaceImplementation (type, iface); + return base.ShouldMarkInterfaceImplementation (type, iface, resolvedInterfaceType); } } } diff --git a/tools/linker/MobileMarkStep.cs b/tools/linker/MobileMarkStep.cs index 3d45ced502ad..dae784e46f8a 100644 --- a/tools/linker/MobileMarkStep.cs +++ b/tools/linker/MobileMarkStep.cs @@ -114,13 +114,13 @@ protected override TypeDefinition MarkType (TypeReference reference) return type; } - protected override void MarkMethods (TypeDefinition type) + protected override bool MarkMethods (TypeDefinition type) { // type can be null if we're not linking the assembly where the type reside, // e.g. --linkskip=System, in such case GetType returns null and an NRE can occur if (type == null) - return; - base.MarkMethods (type); + return false; + return base.MarkMethods (type); } protected void MarkConstructors (TypeDefinition type) diff --git a/tools/mmp/mmp.csproj b/tools/mmp/mmp.csproj index ff4285113c42..f243bc880098 100644 --- a/tools/mmp/mmp.csproj +++ b/tools/mmp/mmp.csproj @@ -129,6 +129,21 @@ Linker\TypePreserve.cs + + + Linker\KnownMembers.cs + + + Linker\BCL.cs + + + Linker\MethodDefinitionExtensions.cs + + + Linker\TypeDefinitionExtensions.cs + + + Linker\MethodBodyScanner.cs Linker\AssemblyUtilities.cs diff --git a/tools/mtouch/mtouch.csproj b/tools/mtouch/mtouch.csproj index 944d885273c6..77f2a8276d58 100644 --- a/tools/mtouch/mtouch.csproj +++ b/tools/mtouch/mtouch.csproj @@ -103,6 +103,21 @@ Linker\TypeReferenceExtensions.cs + + Linker\KnownMembers.cs + + + Linker\BCL.cs + + + Linker\MethodDefinitionExtensions.cs + + + Linker\TypeDefinitionExtensions.cs + + + Linker\MethodBodyScanner.cs + Linker\AssemblyResolver.cs From 60812c0ba644fbb18a3cc04b1aeffd299b1aa02f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Fri, 8 Mar 2019 14:33:15 +0100 Subject: [PATCH 07/96] Use LangVersion=latest in mscorlib test csproj Some tests require ref structs now which needs latest C#. --- tests/bcl-test/mscorlib/mscorlib-mac.csproj.template | 1 + tests/bcl-test/mscorlib/mscorlib-split.csproj.template | 1 + tests/bcl-test/mscorlib/mscorlib.csproj.template | 1 + 3 files changed, 3 insertions(+) diff --git a/tests/bcl-test/mscorlib/mscorlib-mac.csproj.template b/tests/bcl-test/mscorlib/mscorlib-mac.csproj.template index e440082f8f29..9cf199abdbf4 100644 --- a/tests/bcl-test/mscorlib/mscorlib-mac.csproj.template +++ b/tests/bcl-test/mscorlib/mscorlib-mac.csproj.template @@ -3,6 +3,7 @@ Debug AnyCPU + latest {34CB1751-E445-4E32-BFA7-03E6831C11EE} {A3F8F2AB-B479-4A4A-A458-A89E7DC349F1};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} Exe diff --git a/tests/bcl-test/mscorlib/mscorlib-split.csproj.template b/tests/bcl-test/mscorlib/mscorlib-split.csproj.template index cbc19680793d..0705d8035515 100644 --- a/tests/bcl-test/mscorlib/mscorlib-split.csproj.template +++ b/tests/bcl-test/mscorlib/mscorlib-split.csproj.template @@ -4,6 +4,7 @@ Debug 10.0.0 2.0 + latest {6f47c092-2f85-43d6-#SPLIT##SPLIT##SPLIT##SPLIT#-e687426f6bf3} {FEACFBD2-3405-455C-9665-78FE426C6842};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} Library diff --git a/tests/bcl-test/mscorlib/mscorlib.csproj.template b/tests/bcl-test/mscorlib/mscorlib.csproj.template index 6a0216eaf29d..004f0bdaca56 100644 --- a/tests/bcl-test/mscorlib/mscorlib.csproj.template +++ b/tests/bcl-test/mscorlib/mscorlib.csproj.template @@ -5,6 +5,7 @@ iPhoneSimulator 10.0.0 2.0 + latest {34CB1751-E445-4E32-BFA7-03E6831C11EE} {FEACFBD2-3405-455C-9665-78FE426C6842};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} Exe From 3c156f7c49e3736a3b26450913ddee0654f04ce5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Wed, 13 Mar 2019 17:25:58 +0100 Subject: [PATCH 08/96] Move System.Drawing types to Mono --- Make.config | 10 +- opentk/Makefile.include | 2 +- opentk/opentk.csproj | 19 +--- src/Makefile | 104 +----------------- src/OpenGLES/Makefile-1.0.include | 4 +- src/OpenGLES/Makefile.include | 6 - src/OpenTK.dll.sources | 4 +- .../ColorKnownColorTypeForwarders.cs | 2 + .../PointSizeRectangleTypeForwarders.cs | 6 + src/opentk.csproj | 13 +-- src/system-drawing.sources | 11 +- 11 files changed, 29 insertions(+), 152 deletions(-) create mode 100644 src/System.Drawing/ColorKnownColorTypeForwarders.cs create mode 100644 src/System.Drawing/PointSizeRectangleTypeForwarders.cs diff --git a/Make.config b/Make.config index 068882b3e595..7fd9a02f5f82 100644 --- a/Make.config +++ b/Make.config @@ -186,11 +186,11 @@ DEVICE_BIN_PATH=$(XCODE_DEVELOPER_ROOT)/Toolchains/XcodeDefault.xctoolchain/usr/ DEVICE_CC=$(IOS_CC) DEVICE_CXX=$(IOS_CXX) -IOS_CSC=$(SYSTEM_CSC) -nostdlib -noconfig -r:$(MONOTOUCH_MONO_PATH)/System.dll -r:$(MONOTOUCH_MONO_PATH)/System.Core.dll -r:$(MONOTOUCH_MONO_PATH)/System.Xml.dll -r:$(MONOTOUCH_MONO_PATH)/mscorlib.dll -r:$(MONOTOUCH_MONO_PATH)/System.Net.Http.dll -deterministic +IOS_CSC=$(SYSTEM_CSC) -nostdlib -noconfig -r:$(MONOTOUCH_MONO_PATH)/System.dll -r:$(MONOTOUCH_MONO_PATH)/System.Core.dll -r:$(MONOTOUCH_MONO_PATH)/System.Xml.dll -r:$(MONOTOUCH_MONO_PATH)/mscorlib.dll -r:$(MONOTOUCH_MONO_PATH)/System.Net.Http.dll -r:$(MONOTOUCH_MONO_PATH)/Facades/System.Drawing.Common.dll -deterministic IOS_MCS=$(SYSTEM_MCS) -nostdlib -r:mscorlib.dll -lib:$(MONOTOUCH_MONO_PATH) -TV_CSC=$(SYSTEM_CSC) -nostdlib -noconfig -r:$(MONOTOUCH_TV_MONO_PATH)/System.dll -r:$(MONOTOUCH_TV_MONO_PATH)/System.Core.dll -r:$(MONOTOUCH_TV_MONO_PATH)/System.Xml.dll -r:$(MONOTOUCH_TV_MONO_PATH)/mscorlib.dll -deterministic -WATCH_CSC=$(SYSTEM_CSC) -nostdlib -noconfig -r:$(WATCH_BCL_DIR)/System.dll -r:$(WATCH_BCL_DIR)/System.Core.dll -r:$(WATCH_BCL_DIR)/System.Xml.dll -r:$(WATCH_BCL_DIR)/mscorlib.dll -deterministic +TV_CSC=$(SYSTEM_CSC) -nostdlib -noconfig -r:$(MONOTOUCH_TV_MONO_PATH)/System.dll -r:$(MONOTOUCH_TV_MONO_PATH)/System.Core.dll -r:$(MONOTOUCH_TV_MONO_PATH)/System.Xml.dll -r:$(MONOTOUCH_TV_MONO_PATH)/mscorlib.dll -r:$(MONOTOUCH_TV_MONO_PATH)/Facades/System.Drawing.Common.dll -deterministic +WATCH_CSC=$(SYSTEM_CSC) -nostdlib -noconfig -r:$(WATCH_BCL_DIR)/System.dll -r:$(WATCH_BCL_DIR)/System.Core.dll -r:$(WATCH_BCL_DIR)/System.Xml.dll -r:$(WATCH_BCL_DIR)/mscorlib.dll -r:$(WATCH_BCL_DIR)/Facades/System.Drawing.Common.dll -deterministic DEVICE_OBJC_CFLAGS=$(OBJC_CFLAGS) $(BITCODE_CFLAGS) @@ -285,10 +285,10 @@ MAC_FRAMEWORK_VERSIONED_DIR = $(MAC_FRAMEWORK_DIR)/Versions/$(MAC_PACKAGE_VERSIO MAC_FRAMEWORK_CURRENT_DIR = $(MAC_FRAMEWORK_DIR)/Versions/$(MAC_INSTALL_VERSION) MOBILE_BCL_DIR = $(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/lib/mono/Xamarin.Mac -MAC_mobile_CSC = $(SYSTEM_CSC) -nostdlib -noconfig -r:$(MOBILE_BCL_DIR)/System.dll -r:$(MOBILE_BCL_DIR)/System.Core.dll -r:$(MOBILE_BCL_DIR)/System.Xml.dll -r:$(MOBILE_BCL_DIR)/mscorlib.dll -r:$(MOBILE_BCL_DIR)/System.Net.Http.dll -deterministic +MAC_mobile_CSC = $(SYSTEM_CSC) -nostdlib -noconfig -r:$(MOBILE_BCL_DIR)/System.dll -r:$(MOBILE_BCL_DIR)/System.Core.dll -r:$(MOBILE_BCL_DIR)/System.Xml.dll -r:$(MOBILE_BCL_DIR)/mscorlib.dll -r:$(MOBILE_BCL_DIR)/System.Net.Http.dll -r:$(MOBILE_BCL_DIR)/Facades/System.Drawing.Common.dll -deterministic FULL_BCL_DIR = $(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/lib/mono/4.5 -MAC_full_CSC = $(SYSTEM_CSC) -nostdlib -noconfig -r:$(FULL_BCL_DIR)/System.dll -r:$(FULL_BCL_DIR)/System.Core.dll -r:$(FULL_BCL_DIR)/System.Xml.dll -r:$(FULL_BCL_DIR)/mscorlib.dll -r:$(FULL_BCL_DIR)/System.Net.Http.dll -deterministic +MAC_full_CSC = $(SYSTEM_CSC) -nostdlib -noconfig -r:$(FULL_BCL_DIR)/System.dll -r:$(FULL_BCL_DIR)/System.Core.dll -r:$(FULL_BCL_DIR)/System.Xml.dll -r:$(FULL_BCL_DIR)/mscorlib.dll -r:$(FULL_BCL_DIR)/System.Net.Http.dll -r:$(FULL_BCL_DIR)/Facades/System.Drawing.Common.dll -deterministic MAC_PACKAGE_FILENAME=$(MAC_PACKAGE_NAME_LOWER)-$(MAC_PACKAGE_VERSION).pkg MAC_PACKAGE_DMG_FILENAME=$(MAC_PACKAGE_NAME_LOWER)-$(MAC_PACKAGE_VERSION).dmg diff --git a/opentk/Makefile.include b/opentk/Makefile.include index fe20e1885470..fe4714da1ea8 100644 --- a/opentk/Makefile.include +++ b/opentk/Makefile.include @@ -36,7 +36,7 @@ $(MAC_BUILD_DIR)/full-32/OpenTK.dll: $(MAC_OPENTK_SOURCES) $(MAC_BUILD_DIR)/full $(call Q_PROF_CSC,mac/$(VARIANT)) $(MAC_full_CSC) \ -nologo -out:$@ -target:library -debug:full -define:OPENTK_DLL -unsafe -nowarn:3021,612,618,1635 \ $(MAC_BOOTSTRAP_DEFINES),COREBUILD \ - -r:System.Drawing.dll $(XAMMAC) \ + $(XAMMAC) \ -publicsign -keyfile:$(PRODUCT_KEY_PATH) \ $(MAC_OPENTK_FULL_SOURCES) diff --git a/opentk/opentk.csproj b/opentk/opentk.csproj index c42cdc6bae0f..cf9bbcf040d3 100644 --- a/opentk/opentk.csproj +++ b/opentk/opentk.csproj @@ -107,23 +107,8 @@ OpenGL\WindowState.cs - - System.Drawing\Color.cs - - - System.Drawing\ColorConverter.cs - - - System.Drawing\KnownColor.cs - - - System.Drawing\KnownColors.cs - - - System.Drawing\SystemColors.cs - - - System.Drawing\Locale.cs + + System.Drawing\ColorKnownColorTypeForwarders.cs diff --git a/src/Makefile b/src/Makefile index afa153904a1c..6fdde16a9f9f 100644 --- a/src/Makefile +++ b/src/Makefile @@ -182,27 +182,6 @@ $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/mono/2.1/Facades/% : $(MACIOS_BINARIES_PAT $(IOS_BUILD_DIR)/compat/%: $(MACIOS_BINARIES_PATH)/% | $(IOS_BUILD_DIR)/compat $(Q) $(CP) $< $@ -$(IOS_BUILD_DIR)/compat/Facades/System.Drawing.Primitives.dll : $(MACIOS_BINARIES_PATH)/Facades/System.Drawing.Primitives.dll | $(IOS_BUILD_DIR)/compat/Facades - $(Q) $(CP) $< $@ - -# -# Assemblies which require special handling as they have dependency on Xamarin.iOS.dll -# hence we cannot built it as part of Mono BCL -# -$(MONO_PATH)/mcs/class/lib/monotouch/reference_Facades/System.Drawing.Primitives.dll: $(IOS_BUILD_DIR)/reference/Xamarin.iOS.dll - $(call Q_PROF_CSC,ios/unified) $(MAKE) $(if $(V),,-s) -C $(MONO_PATH)/mcs/class/Facades/System.Drawing.Primitives PROFILE=monotouch LIBRARY_SUBDIR=reference_Facades EXTERNAL_FACADE_DRAWING_REFERENCE="$(abspath $(IOS_BUILD_DIR)/reference/Xamarin.iOS.dll)" - @touch $@ - -$(IOS_BUILD_DIR)/%/Facades/System.Drawing.Primitives.dll: $(MONO_PATH)/mcs/class/lib/monotouch/%_Facades/System.Drawing.Primitives.dll | $(IOS_BUILD_DIR)/compat/Facades $(IOS_BUILD_DIR)/reference/Facades - $(Q) $(CP) $< $@ - -$(MONO_PATH)/mcs/class/lib/monotouch/reference_Facades/netstandard.dll: $(IOS_BUILD_DIR)/reference/Xamarin.iOS.dll $(IOS_BUILD_DIR)/reference/OpenTK-1.0.dll - $(call Q_PROF_CSC,ios/unified) $(MAKE) $(if $(V),,-s) -C $(MONO_PATH)/mcs/class/Facades/netstandard PROFILE=monotouch LIBRARY_SUBDIR=reference_Facades EXTERNAL_FACADE_DRAWING_REFERENCE="$(abspath $(IOS_BUILD_DIR)/reference/Xamarin.iOS.dll),$(abspath $(IOS_BUILD_DIR)/reference/OpenTK-1.0.dll)" - @touch $@ - -$(IOS_BUILD_DIR)/%/Facades/netstandard.dll: $(MONO_PATH)/mcs/class/lib/monotouch/%_Facades/netstandard.dll | $(IOS_BUILD_DIR)/compat/Facades $(IOS_BUILD_DIR)/reference/Facades - $(Q) $(CP) $< $@ - clean-local:: rm -rf build rm -f $(IOS_TARGETS) generated_sources *.mdb *.pdb @@ -245,8 +224,6 @@ IOS_TARGETS += \ $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/mono/Xamarin.iOS/OpenTK-1.0.dll \ $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/mono/Xamarin.iOS/OpenTK-1.0.pdb \ $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/mono/Xamarin.iOS/OpenTK-1.0.dll.config \ - $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/mono/Xamarin.iOS/Facades/System.Drawing.Primitives.dll \ - $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/mono/Xamarin.iOS/Facades/netstandard.dll \ $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/32bits/Xamarin.iOS.dll \ $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/32bits/Xamarin.iOS.pdb \ $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/64bits/Xamarin.iOS.dll \ @@ -463,25 +440,6 @@ $(MAC_BUILD_DIR)/%-reference/Xamarin.Mac.pdb: $(MAC_BUILD_DIR)/%-64/Xamarin.Mac. @mkdir -p $(@D) $(Q) $(CP) $^ $@ -# System.Drawing.Primitives.dll is special - - -$(MONO_PATH)/mcs/class/lib/xammac/reference_Facades/System.Drawing.Primitives.dll: $(MAC_BUILD_DIR)/mobile-reference/Xamarin.Mac.dll - $(call Q_PROF_CSC,xammac) $(MAKE) $(if $(V),,-s) -C $(MONO_PATH)/mcs/class/Facades/System.Drawing.Primitives PROFILE=xammac LIBRARY_SUBDIR=reference_Facades EXTERNAL_FACADE_DRAWING_REFERENCE="$(abspath $(MAC_BUILD_DIR)/mobile-reference/Xamarin.Mac.dll)" - @touch $@ - -$(MAC_BUILD_DIR)/mobile/Facades/System.Drawing.Primitives.dll: $(MONO_PATH)/mcs/class/lib/xammac/reference_Facades/System.Drawing.Primitives.dll $(MAC_BUILD_DIR)/mobile/Facades - $(Q) $(CP) $< $@ - -# netstandard.dll is special - -$(MONO_PATH)/mcs/class/lib/xammac/reference_Facades/netstandard.dll: $(MAC_BUILD_DIR)/mobile-reference/Xamarin.Mac.dll $(MAC_BUILD_DIR)/mobile-reference/OpenTK.dll - $(call Q_PROF_CSC,xammac) $(MAKE) $(if $(V),,-s) -C $(MONO_PATH)/mcs/class/Facades/netstandard PROFILE=xammac LIBRARY_SUBDIR=reference_Facades EXTERNAL_FACADE_DRAWING_REFERENCE="$(abspath $(MAC_BUILD_DIR)/mobile-reference/Xamarin.Mac.dll),$(abspath $(MAC_BUILD_DIR)/mobile-reference/OpenTK.dll)" - @touch $@ - -$(MAC_BUILD_DIR)/mobile/Facades/netstandard.dll: $(MONO_PATH)/mcs/class/lib/xammac/reference_Facades/netstandard.dll $(MAC_BUILD_DIR)/mobile/Facades - $(Q) $(CP) $< $@ - $(MAC_BUILD_DIR)/compat/XamMac.CFNetwork.dll: $(MACIOS_BINARIES_PATH)/XamMac.CFNetwork.dll | $(MAC_BUILD_DIR)/compat $(Q) $(CP) $< $@ $(Q) $(CP) $<.mdb $@.mdb @@ -498,8 +456,6 @@ MAC_VARIANTS_TARGETS = \ $(MAC_BUILD_DIR)/full-64/Xamarin.Mac.dll \ $(MAC_BUILD_DIR)/mobile-reference/Xamarin.Mac.dll \ $(MAC_BUILD_DIR)/full-reference/Xamarin.Mac.dll \ - $(MAC_BUILD_DIR)/mobile/Facades/System.Drawing.Primitives.dll \ - $(MAC_BUILD_DIR)/mobile/Facades/netstandard.dll \ $(MAC_BUILD_DIR)/compat/XamMac.CFNetwork.dll INSTALL_TARGETS+=install-mac @@ -545,15 +501,7 @@ MAC_TARGETS += \ $(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/lib/mono/Xamarin.Mac/Xamarin.Mac.pdb \ $(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/lib/mono/4.5/Xamarin.Mac.dll \ $(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/lib/mono/4.5/Xamarin.Mac.pdb \ - $(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/lib/pkgconfig/xammac.pc \ - $(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/lib/mono/Xamarin.Mac/Facades/System.Drawing.Primitives.dll \ - $(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/lib/mono/Xamarin.Mac/Facades/netstandard.dll - -$(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/lib/mono/Xamarin.Mac/Facades/System.Drawing.Primitives.dll: $(MAC_BUILD_DIR)/mobile/Facades/System.Drawing.Primitives.dll | $(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/lib/mono/Xamarin.Mac/Facades - $(Q) install -m 0755 $< $@ - -$(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/lib/mono/Xamarin.Mac/Facades/netstandard.dll: $(MAC_BUILD_DIR)/mobile/Facades/netstandard.dll | $(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/lib/mono/Xamarin.Mac/Facades - $(Q) install -m 0755 $< $@ + $(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/lib/pkgconfig/xammac.pc $(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/lib/mono/XamMac.dll: $(MAC_BUILD_DIR)/compat/XamMac.dll | $(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/lib/mono $(Q) install -m 0755 $< $@ @@ -633,10 +581,8 @@ WATCHOS_EXTRA_CORE_SOURCES = \ $(IOS_OPENTK_1_0_CORE_SOURCES) \ AudioToolbox/AudioBuffers.cs \ AudioToolbox/AudioType.cs \ - $(SHARED_SYSTEM_DRAWING_SOURCES) \ - $(MONO_PATH)/mcs/class/System.Drawing/System.Drawing/Color.cs \ - $(MONO_PATH)/mcs/class/System.Drawing/System.Drawing/KnownColor.cs \ - $(MONO_PATH)/mcs/class/System.Drawing/System.Drawing/KnownColors.cs + $(SHARED_SYSTEM_DRAWING_SOURCES) \ + System.Drawing/ColorKnownColorTypeForwarders.cs WATCHOS_CORE_SOURCES += \ $(WATCHOS_EXTRA_CORE_SOURCES) \ @@ -722,24 +668,6 @@ $(WATCH_BUILD_DIR)/reference/MonoTouch.NUnitLite%dll $(WATCH_BUILD_DIR)/referenc -deterministic \ $(WATCHOS_TOUCHUNIT_SOURCES) -# System.Drawing.Primitives.dll is special - -$(MONO_PATH)/mcs/class/lib/monotouch_watch/reference_Facades/System.Drawing.Primitives.dll: $(WATCH_BUILD_DIR)/reference/Xamarin.WatchOS.dll - $(call Q_PROF_CSC,watch) $(MAKE) $(if $(V),,-s) -C $(MONO_PATH)/mcs/class/Facades/System.Drawing.Primitives PROFILE=monotouch_watch LIBRARY_SUBDIR=reference_Facades EXTERNAL_FACADE_DRAWING_REFERENCE="$(abspath $(WATCH_BUILD_DIR)/reference/Xamarin.WatchOS.dll)" - @touch $@ - -$(WATCH_BUILD_DIR)/%/Facades/System.Drawing.Primitives.dll: $(MONO_PATH)/mcs/class/lib/monotouch_watch/%_Facades/System.Drawing.Primitives.dll | $(WATCH_BUILD_DIR)/reference/Facades - $(Q) $(CP) $< $@ - -# netstandard.dll is special - -$(MONO_PATH)/mcs/class/lib/monotouch_watch/reference_Facades/netstandard.dll: $(WATCH_BUILD_DIR)/reference/Xamarin.WatchOS.dll - $(call Q_PROF_CSC,watch) $(MAKE) $(if $(V),,-s) -C $(MONO_PATH)/mcs/class/Facades/netstandard PROFILE=monotouch_watch LIBRARY_SUBDIR=reference_Facades EXTERNAL_FACADE_DRAWING_REFERENCE="$(abspath $(WATCH_BUILD_DIR)/reference/Xamarin.WatchOS.dll)" - @touch $@ - -$(WATCH_BUILD_DIR)/%/Facades/netstandard.dll: $(MONO_PATH)/mcs/class/lib/monotouch_watch/%_Facades/netstandard.dll | $(WATCH_BUILD_DIR)/reference/Facades - $(Q) $(CP) $< $@ - $(PROJECT_DIR)/xamwatch.csproj: xamwatch.tmpl.csproj Makefile $(wildcard $(TOP)/*.sources) @sed -e 's**$(foreach file,$(WATCHOS_SOURCES),)*' -e 's**$(foreach file,$(WATCHOS_APIS),)*' $< | xmllint --format - > $@ @@ -769,9 +697,7 @@ WATCH_TARGETS += \ $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/32bits/Xamarin.WatchOS.dll \ $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/32bits/Xamarin.WatchOS.pdb \ $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/mono/Xamarin.WatchOS/MonoTouch.NUnitLite.dll \ - $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/mono/Xamarin.WatchOS/MonoTouch.NUnitLite.pdb \ - $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/mono/Xamarin.WatchOS/Facades/System.Drawing.Primitives.dll \ - $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/mono/Xamarin.WatchOS/Facades/netstandard.dll \ + $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/mono/Xamarin.WatchOS/MonoTouch.NUnitLite.pdb # reference assemblies, this is just for compilation with XS $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/mono/Xamarin.WatchOS/%.dll: $(WATCH_BUILD_DIR)/reference/%.dll | $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/mono/Xamarin.WatchOS @@ -913,24 +839,6 @@ $(TVOS_BUILD_DIR)/reference/MonoTouch.Dialog-1.dll: $(MACIOS_BINARIES_PATH)/Mono $(TVOS_BUILD_DIR)/reference/MonoTouch.Dialog-1.pdb: $(MACIOS_BINARIES_PATH)/MonoTouch.Dialog-Unified/tvos/MonoTouch.Dialog-1.pdb | $(TVOS_BUILD_DIR)/reference $(Q) $(CP) $< $@ -# System.Drawing.Primitives.dll is special - -$(MONO_PATH)/mcs/class/lib/monotouch_tv/reference_Facades/System.Drawing.Primitives.dll: $(TVOS_BUILD_DIR)/reference/Xamarin.TVOS.dll - $(call Q_PROF_CSC,tvos) $(MAKE) $(if $(V),,-s) -C $(MONO_PATH)/mcs/class/Facades/System.Drawing.Primitives PROFILE=monotouch_tv LIBRARY_SUBDIR=reference_Facades EXTERNAL_FACADE_DRAWING_REFERENCE="$(abspath $(TVOS_BUILD_DIR)/reference/Xamarin.TVOS.dll)" - @touch $@ - -$(TVOS_BUILD_DIR)/%/Facades/System.Drawing.Primitives.dll: $(MONO_PATH)/mcs/class/lib/monotouch_tv/%_Facades/System.Drawing.Primitives.dll | $(TVOS_BUILD_DIR)/reference/Facades - $(Q) $(CP) $< $@ - -# netstandard.dll is special - -$(MONO_PATH)/mcs/class/lib/monotouch_tv/reference_Facades/netstandard.dll: $(TVOS_BUILD_DIR)/reference/Xamarin.TVOS.dll $(TVOS_BUILD_DIR)/reference/OpenTK-1.0.dll - $(call Q_PROF_CSC,tvos) $(MAKE) $(if $(V),,-s) -C $(MONO_PATH)/mcs/class/Facades/netstandard PROFILE=monotouch_tv LIBRARY_SUBDIR=reference_Facades EXTERNAL_FACADE_DRAWING_REFERENCE="$(abspath $(TVOS_BUILD_DIR)/reference/Xamarin.TVOS.dll),$(abspath $(TVOS_BUILD_DIR)/reference/OpenTK-1.0.dll)" - @touch $@ - -$(TVOS_BUILD_DIR)/%/Facades/netstandard.dll: $(MONO_PATH)/mcs/class/lib/monotouch_tv/%_Facades/netstandard.dll | $(TVOS_BUILD_DIR)/reference/Facades - $(Q) $(CP) $< $@ - $(PROJECT_DIR)/xamtvos.csproj: xamtvos.tmpl.csproj Makefile $(wildcard $(TOP)/*.sources) @sed -e 's**$(foreach file,$(TVOS_SOURCES),)*' -e 's**$(foreach file,$(TVOS_APIS),)*' $< | xmllint --format - > $@ @@ -967,9 +875,7 @@ TVOS_TARGETS += \ $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/mono/Xamarin.TVOS/MonoTouch.Dialog-1.dll \ $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/mono/Xamarin.TVOS/MonoTouch.Dialog-1.pdb \ $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/mono/Xamarin.TVOS/MonoTouch.NUnitLite.dll \ - $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/mono/Xamarin.TVOS/MonoTouch.NUnitLite.pdb \ - $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/mono/Xamarin.TVOS/Facades/System.Drawing.Primitives.dll \ - $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/mono/Xamarin.TVOS/Facades/netstandard.dll \ + $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/mono/Xamarin.TVOS/MonoTouch.NUnitLite.pdb # reference assemblies, this is just for compilation with XS $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/mono/Xamarin.TVOS/%.dll: $(TVOS_BUILD_DIR)/reference/%.dll | $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/mono/Xamarin.TVOS diff --git a/src/OpenGLES/Makefile-1.0.include b/src/OpenGLES/Makefile-1.0.include index 12bb2c8e6bde..7f6a64b0c8ff 100644 --- a/src/OpenGLES/Makefile-1.0.include +++ b/src/OpenGLES/Makefile-1.0.include @@ -34,12 +34,12 @@ OPENTK_1_0_CSC_FLAGS = -warn:0 -unsafe -target:library -noconfig -publicsign -de # Xamarin.iOS $(IOS_BUILD_DIR)/reference/OpenTK-1.0%dll $(IOS_BUILD_DIR)/reference/OpenTK-1.0%pdb: $(IOS_BUILD_DIR)/reference/Xamarin.iOS.dll $(OPENTK_1_0_DEPENDENCIES) $(IOS_BUILD_DIR)/reference/OpenTK-1.0.dll.config - $(call Q_PROF_CSC,ios/unified) $(IOS_CSC) -nologo -r:$(MONOTOUCH_MONO_PATH)/System.dll -r:$(MONOTOUCH_MONO_PATH)/System.Xml.dll $(OPENTK_1_0_CSC_FLAGS) -out:$(basename $@).dll -r:$< -D:XAMCORE_2_0 + $(call Q_PROF_CSC,ios/unified) $(IOS_CSC) -nologo -r:$(MONOTOUCH_MONO_PATH)/System.dll -r:$(MONOTOUCH_MONO_PATH)/System.Xml.dll -r:$(MONOTOUCH_MONO_PATH)/Facades/System.Drawing.Common.dll $(OPENTK_1_0_CSC_FLAGS) -out:$(basename $@).dll -r:$< -D:XAMCORE_2_0 # Xamarin.TVOS $(TVOS_BUILD_DIR)/reference/OpenTK-1.0%dll $(TVOS_BUILD_DIR)/reference/OpenTK-1.0%pdb: $(TVOS_BUILD_DIR)/reference/Xamarin.TVOS.dll $(OPENTK_1_0_DEPENDENCIES) $(TVOS_BUILD_DIR)/reference/OpenTK-1.0.dll.config - $(call Q_PROF_CSC,tvos) $(SYSTEM_CSC) -nologo $(OPENTK_1_0_CSC_FLAGS) -r:$(TVOS_LIBDIR)/System.dll -r:$(TVOS_LIBDIR)/System.Xml.dll -out:$(basename $@).dll -r:$< -D:XAMCORE_2_0 -D:XAMCORE_3_0 -D:TVOS + $(call Q_PROF_CSC,tvos) $(SYSTEM_CSC) -nologo $(OPENTK_1_0_CSC_FLAGS) -r:$(TVOS_LIBDIR)/System.dll -r:$(TVOS_LIBDIR)/System.Xml.dll -r:$(TVOS_LIBDIR)/Facades/System.Drawing.Common.dll -out:$(basename $@).dll -r:$< -D:XAMCORE_2_0 -D:XAMCORE_3_0 -D:TVOS # common targets diff --git a/src/OpenGLES/Makefile.include b/src/OpenGLES/Makefile.include index 93c2a74c7cf6..e69de29bb2d1 100644 --- a/src/OpenGLES/Makefile.include +++ b/src/OpenGLES/Makefile.include @@ -1,6 +0,0 @@ -$(IOS_BUILD_DIR)/compat/OpenTK.dll: Makefile OpenGLES/Makefile.include $(shell cat OpenTK.dll.sources) $(IOS_BUILD_DIR)/compat/monotouch.dll | $(IOS_BUILD_DIR)/compat - $(Q_CSC) $(IOS_CSC) -nologo -warn:0 -unsafe -target:library -debug:portable -optimize -publicsign -define:MONOTOUCH -define:IPHONE -d:MINIMAL -out:$@ @./$(@F).sources -r:$(IOS_BUILD_DIR)/compat/monotouch.dll -r:$(MONOTOUCH_MONO_PATH)/System.dll -keyfile:$(PRODUCT_KEY_PATH) - $(Q) touch $@ - -$(IOS_BUILD_DIR)/compat/OpenTK.pdb: $(IOS_BUILD_DIR)/compat/OpenTK.dll - @touch $@ diff --git a/src/OpenTK.dll.sources b/src/OpenTK.dll.sources index 54ff33953a6a..5f7d803b3133 100644 --- a/src/OpenTK.dll.sources +++ b/src/OpenTK.dll.sources @@ -1,6 +1,4 @@ -../external/mono/mcs/class/System.Drawing/System.Drawing/Color.cs -../external/mono/mcs/class/System.Drawing/System.Drawing/KnownColor.cs -../external/mono/mcs/class/System.Drawing/System.Drawing/KnownColors.cs +System.Drawing/ColorKnownColorTypeForwarders.cs OpenGLES/OpenTK/Audio/AudioContext.cs OpenGLES/OpenTK/Audio/AudioContextException.cs OpenGLES/OpenTK/Audio/AudioDeviceEnumerator.cs diff --git a/src/System.Drawing/ColorKnownColorTypeForwarders.cs b/src/System.Drawing/ColorKnownColorTypeForwarders.cs new file mode 100644 index 000000000000..a715fe2ea587 --- /dev/null +++ b/src/System.Drawing/ColorKnownColorTypeForwarders.cs @@ -0,0 +1,2 @@ +[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Drawing.Color))] +[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Drawing.KnownColor))] diff --git a/src/System.Drawing/PointSizeRectangleTypeForwarders.cs b/src/System.Drawing/PointSizeRectangleTypeForwarders.cs new file mode 100644 index 000000000000..a7632f04a518 --- /dev/null +++ b/src/System.Drawing/PointSizeRectangleTypeForwarders.cs @@ -0,0 +1,6 @@ +[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Drawing.Point))] +[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Drawing.PointF))] +[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Drawing.Rectangle))] +[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Drawing.RectangleF))] +[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Drawing.Size))] +[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Drawing.SizeF))] diff --git a/src/opentk.csproj b/src/opentk.csproj index 075195e675ef..0be562e39c3c 100644 --- a/src/opentk.csproj +++ b/src/opentk.csproj @@ -234,17 +234,8 @@ OpenGLES\OpenTK\Graphics\ES30.iPhone\Helper.cs - - System.Drawing\Color.cs - - - System.Drawing\KnownColor.cs - - - System.Drawing\KnownColors.cs - - - System.Drawing\Locale.cs + + System.Drawing\ColorKnownColorTypeForwarders.cs diff --git a/src/system-drawing.sources b/src/system-drawing.sources index f95f861c26e4..e5cfaf6f97bd 100644 --- a/src/system-drawing.sources +++ b/src/system-drawing.sources @@ -1,11 +1,6 @@ -SHARED_SYSTEM_DRAWING_SOURCES = \ - $(MONO_PATH)/mcs/build/common/Locale.cs \ - $(MONO_PATH)/mcs/class/System.Drawing/System.Drawing/Point.cs \ - $(MONO_PATH)/mcs/class/System.Drawing/System.Drawing/PointF.cs \ - $(MONO_PATH)/mcs/class/System.Drawing/System.Drawing/Rectangle.cs \ - $(MONO_PATH)/mcs/class/System.Drawing/System.Drawing/RectangleF.cs \ - $(MONO_PATH)/mcs/class/System.Drawing/System.Drawing/Size.cs \ - $(MONO_PATH)/mcs/class/System.Drawing/System.Drawing/SizeF.cs \ +SHARED_SYSTEM_DRAWING_SOURCES = System.Drawing/PointSizeRectangleTypeForwarders.cs + + IOS_SYSTEM_DRAWING_SOURCES = \ $(TOP)/sysdrawing-coregraphics/System.Drawing/Brush.cs \ From 8ad5199d5362bcbcba9041937633a33c320dd265 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Fri, 8 Mar 2019 13:27:44 +0100 Subject: [PATCH 09/96] Don't use internal MethodBase.FullName anymore It was removed in Mono when moving to the corefx implementation. Replaced it with the original implementation (though we probably shouldn't rely on internals...) --- src/ObjCRuntime/Runtime.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ObjCRuntime/Runtime.cs b/src/ObjCRuntime/Runtime.cs index 12c3f6308d5d..b3272b5cf9db 100644 --- a/src/ObjCRuntime/Runtime.cs +++ b/src/ObjCRuntime/Runtime.cs @@ -1102,7 +1102,7 @@ internal enum MissingCtorResolution { if (method != IntPtr.Zero) { var mi = ObjectWrapper.Convert (method) as MethodBase; if (mi != null) - msg += $"\tMethod: {mi.FullName}\n"; + msg += $"\tMethod: {String.Format("{0}.{1}", mi.DeclaringType.FullName, mi.FormatNameAndSig(false))}\n"; } throw ErrorHelper.CreateError (8027, string.Format (msg, ptr.ToString ("x"), new Class (klass).Name, type.FullName)); From fb38e7689fdde46fc4644b3a1128e26b8283a3bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Wed, 13 Mar 2019 19:00:06 +0100 Subject: [PATCH 10/96] Workaround GuiUnit csproj issue --- external/guiunit | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/guiunit b/external/guiunit index 9f67042498c8..9affe4813987 160000 --- a/external/guiunit +++ b/external/guiunit @@ -1 +1 @@ -Subproject commit 9f67042498c8a3bc28888c7765a93af9b3475329 +Subproject commit 9affe4813987b009022ab7b10e55f81f4a37344c From 8c96fb26009232a6d52d754b682806a1d7e00e4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Wed, 13 Mar 2019 19:54:04 +0100 Subject: [PATCH 11/96] Fix missing file in System-mac.csproj.template --- tests/bcl-test/System/System-mac.csproj.template | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/bcl-test/System/System-mac.csproj.template b/tests/bcl-test/System/System-mac.csproj.template index e46560fc3675..90a00ddc2cf7 100644 --- a/tests/bcl-test/System/System-mac.csproj.template +++ b/tests/bcl-test/System/System-mac.csproj.template @@ -85,6 +85,9 @@ test-helpers\SocketResponder.cs + + test-helpers\PathHelpers.cs + From 7f15726ae9ae1a11ff0f421a0d26cd021d3baa0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Wed, 13 Mar 2019 19:55:26 +0100 Subject: [PATCH 12/96] Remove obsolete src/OpenGLES/Makefile.include --- src/Makefile | 1 - src/OpenGLES/Makefile.include | 0 2 files changed, 1 deletion(-) delete mode 100644 src/OpenGLES/Makefile.include diff --git a/src/Makefile b/src/Makefile index 6fdde16a9f9f..2b0320e14c30 100644 --- a/src/Makefile +++ b/src/Makefile @@ -37,7 +37,6 @@ MAC_GENERATOR_WARNASERROR=$(GENERATOR_WARNASERROR) # IOS_WARNINGS_THAT_YOU_SHOULD_FIX=108 -include ./OpenGLES/Makefile.include include ./OpenGLES/Makefile-1.0.include include ./Makefile.generator diff --git a/src/OpenGLES/Makefile.include b/src/OpenGLES/Makefile.include deleted file mode 100644 index e69de29bb2d1..000000000000 From f4802b0587516132519e88ba904d6fe3a583c689 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Wed, 13 Mar 2019 21:06:45 +0100 Subject: [PATCH 13/96] Add back some code to RuntimeOptions.cs that was still needed --- src/ObjCRuntime/RuntimeOptions.cs | 56 +++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/src/ObjCRuntime/RuntimeOptions.cs b/src/ObjCRuntime/RuntimeOptions.cs index b63cc24d7cfc..eefc7e55d636 100644 --- a/src/ObjCRuntime/RuntimeOptions.cs +++ b/src/ObjCRuntime/RuntimeOptions.cs @@ -5,6 +5,8 @@ #if MTOUCH || MMP using Mono.Cecil; using Xamarin.Linker; +#elif (MONOMAC && XAMCORE_2_0) +using System.Net.Http; #endif #if XAMCORE_2_0 @@ -177,6 +179,60 @@ internal static TypeDefinition GetHttpMessageHandler (Application app, RuntimeOp throw new InvalidOperationException (string.Format ("Cannot load HttpMessageHandler `{0}`.", handler)); return type; } +#else + + internal static RuntimeOptions Read () + { + // for iOS NSBundle.ResourcePath returns the path to the root of the app bundle + // for macOS apps NSBundle.ResourcePath returns foo.app/Contents/Resources + // for macOS frameworks NSBundle.ResourcePath returns foo.app/Versions/Current/Resources + Class bundle_finder = new Class (typeof (NSObject.NSObject_Disposer)); + var resource_dir = NSBundle.FromClass (bundle_finder).ResourcePath; + var plist_path = GetFileName (resource_dir); + + if (!File.Exists (plist_path)) + return null; + + using (var plist = NSDictionary.FromFile (plist_path)) { + var options = new RuntimeOptions (); + options.http_message_handler = (NSString) plist ["HttpMessageHandler"]; + return options; + } + } + +#if (MONOMAC && XAMCORE_2_0) +#if MONOMAC + [Preserve] +#endif + internal static HttpMessageHandler GetHttpMessageHandler () + { + RuntimeOptions options = RuntimeOptions.Read (); + if (options == null) { +#if MONOTOUCH_WATCH + return new NSUrlSessionHandler (); +#else + return new HttpClientHandler (); +#endif + } + + // all types will be present as this is executed only when the linker is not enabled + var handler_name = options.http_message_handler; + var t = Type.GetType (handler_name, false); + + HttpMessageHandler handler = null; + if (t != null) + handler = Activator.CreateInstance (t) as HttpMessageHandler; + if (handler != null) + return handler; +#if MONOTOUCH_WATCH + Console.WriteLine ("{0} is not a valid HttpMessageHandler, defaulting to NSUrlSessionHandler", handler_name); + return new NSUrlSessionHandler (); +#else + Console.WriteLine ("{0} is not a valid HttpMessageHandler, defaulting to System.Net.Http.HttpClientHandler", handler_name); + return new HttpClientHandler (); +#endif + } +#endif #endif // Use either Create() or Read(). From 13c2ef376869e9087d9229424b85d10b6de12f62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Wed, 13 Mar 2019 21:09:02 +0100 Subject: [PATCH 14/96] Revert var change --- src/ObjCRuntime/RuntimeOptions.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ObjCRuntime/RuntimeOptions.cs b/src/ObjCRuntime/RuntimeOptions.cs index eefc7e55d636..c5bedb43ac82 100644 --- a/src/ObjCRuntime/RuntimeOptions.cs +++ b/src/ObjCRuntime/RuntimeOptions.cs @@ -206,7 +206,7 @@ internal static RuntimeOptions Read () #endif internal static HttpMessageHandler GetHttpMessageHandler () { - RuntimeOptions options = RuntimeOptions.Read (); + var options = RuntimeOptions.Read (); if (options == null) { #if MONOTOUCH_WATCH return new NSUrlSessionHandler (); From 6e3b0f2298069ffd16a397d7b3808f238718046c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Thu, 14 Mar 2019 13:43:09 +0100 Subject: [PATCH 15/96] Fix InterfaceTest.Bug10866 The linker got smarter with https://github.com/mono/linker/pull/394 so we now remove B.Bar() since it's not used. --- tests/linker/ios/link all/InterfacesTest.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/linker/ios/link all/InterfacesTest.cs b/tests/linker/ios/link all/InterfacesTest.cs index 37490a73c262..22514c86926b 100644 --- a/tests/linker/ios/link all/InterfacesTest.cs +++ b/tests/linker/ios/link all/InterfacesTest.cs @@ -90,10 +90,9 @@ public void Bug10866 () // I::Bar is used in F so everyone implementing I needs Bar Assert.NotNull (type_i.GetMethod ("Bar", BindingFlags.Instance | BindingFlags.Public), "I::Bar"); - // Foo and Bar are never used on B - so Foo can be removed + // Foo and Bar are never used on B - so they can be removed Assert.Null (type_b.GetMethod ("Foo", BindingFlags.Instance | BindingFlags.Public), "B::Foo"); - // but Bar cannot since B implements I - Assert.NotNull (type_b.GetMethod ("Bar", BindingFlags.Instance | BindingFlags.Public), "B::Bar"); + Assert.Null (type_b.GetMethod ("Bar", BindingFlags.Instance | BindingFlags.Public), "B::Bar"); } [DllImport ("/usr/lib/system/libsystem_dnssd.dylib")] From a5ad6055777b1c2f00bad4ba9294fa8632e5b577 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Thu, 14 Mar 2019 15:22:46 +0100 Subject: [PATCH 16/96] Remove a public symbol from MiscTests.PublicSymbols that was renamed It now has a monoeg_ prefix which is already ignored --- tests/mtouch/MiscTests.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/mtouch/MiscTests.cs b/tests/mtouch/MiscTests.cs index cdd4f450082e..a491a285c29a 100644 --- a/tests/mtouch/MiscTests.cs +++ b/tests/mtouch/MiscTests.cs @@ -122,7 +122,6 @@ public void PublicSymbols (Profile profile) "_gateway_from_rtm", "_sgen_", "_arm_patch", - "_g_printv", // These two aren't public in a way we care about "l_OBJC_LABEL_PROTOCOL_$_", "l_OBJC_PROTOCOL_$_", From ca50ae504c8d5c7a5edcbe37f762196abf6591ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Thu, 14 Mar 2019 15:49:25 +0100 Subject: [PATCH 17/96] Add System.Drawing.Common.dll to Xamarin.Mac-Full-FrameworkList.xml.in --- msbuild/Xamarin.Mac.Tasks/Xamarin.Mac-Full-FrameworkList.xml.in | 1 + 1 file changed, 1 insertion(+) diff --git a/msbuild/Xamarin.Mac.Tasks/Xamarin.Mac-Full-FrameworkList.xml.in b/msbuild/Xamarin.Mac.Tasks/Xamarin.Mac-Full-FrameworkList.xml.in index 0997db009a1e..637235388683 100644 --- a/msbuild/Xamarin.Mac.Tasks/Xamarin.Mac-Full-FrameworkList.xml.in +++ b/msbuild/Xamarin.Mac.Tasks/Xamarin.Mac-Full-FrameworkList.xml.in @@ -78,6 +78,7 @@ + From d9404ed1157569812013224370a4ef21810b531f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Fri, 15 Mar 2019 16:42:31 +0100 Subject: [PATCH 18/96] Bump mono --- external/mono | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/mono b/external/mono index 2f9852486c1a..44016c09a72a 160000 --- a/external/mono +++ b/external/mono @@ -1 +1 @@ -Subproject commit 2f9852486c1a28dd1df44a96b5cb9439aedf6c86 +Subproject commit 44016c09a72a61eb1bcb3d753265f95aca40d053 From 2b30e0755ebddd98b0e3d19d980c236f7deab30d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Fri, 15 Mar 2019 16:42:57 +0100 Subject: [PATCH 19/96] REVERTME: Add workaround for missing System.Drawing.Common reference --- tests/monotouch-test/monotouch-test.csproj | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/monotouch-test/monotouch-test.csproj b/tests/monotouch-test/monotouch-test.csproj index e1e84e54b12b..dbb1c53ac971 100644 --- a/tests/monotouch-test/monotouch-test.csproj +++ b/tests/monotouch-test/monotouch-test.csproj @@ -156,6 +156,7 @@ + From 24a0dd20eca0dbe30cd1efdc45e598c392aed883 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Sat, 16 Mar 2019 01:40:52 +0100 Subject: [PATCH 20/96] Bump mono pkg --- Make.config | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Make.config b/Make.config index 7fd9a02f5f82..2820926a2d98 100644 --- a/Make.config +++ b/Make.config @@ -49,13 +49,13 @@ XCODE94_URL=http://xamarin-storage/bot-provisioning/xcodes/Xcode_9.4.xip XCODE94_DEVELOPER_ROOT=/Applications/Xcode94.app/Contents/Developer # Minimum Mono version for building XI/XM -MIN_MONO_VERSION=6.0.0.63 +MIN_MONO_VERSION=6.0.0.92 MAX_MONO_VERSION=6.0.99 -MIN_MONO_URL=https://xamjenkinsartifact.azureedge.net/build-package-osx-mono/2019-02/56/5fc4dc076d8f79218312bfd0e7a6f80e7969f3ad/MonoFramework-MDK-6.0.0.63.macos10.xamarin.universal.pkg +MIN_MONO_URL=https://xamjenkinsartifact.azureedge.net/build-package-osx-mono/2019-02/84/38252d7877266332572645f486c4815531941482/MonoFramework-MDK-6.0.0.92.macos10.xamarin.universal.pkg # Minimum Mono version for Xamarin.Mac apps using the system mono -MIN_XM_MONO_VERSION=6.0.0.63 -MIN_XM_MONO_URL=https://xamjenkinsartifact.azureedge.net/build-package-osx-mono/2019-02/56/5fc4dc076d8f79218312bfd0e7a6f80e7969f3ad/MonoFramework-MDK-6.0.0.63.macos10.xamarin.universal.pkg +MIN_XM_MONO_VERSION=6.0.0.92 +MIN_XM_MONO_URL=https://xamjenkinsartifact.azureedge.net/build-package-osx-mono/2019-02/84/38252d7877266332572645f486c4815531941482/MonoFramework-MDK-6.0.0.92.macos10.xamarin.universal.pkg # Minimum Visual Studio version MIN_VISUAL_STUDIO_URL=https://bosstoragemirror.azureedge.net/vsmac/7a/7aff2dc1f28d711d11d63d79b2a4c49cda217189/VisualStudioForMac-Preview-7.7.0.1470.dmg From 15c5f811784bf4bef059a468912f8062453b1976 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Sat, 16 Mar 2019 01:30:40 +0100 Subject: [PATCH 21/96] Remove unnecessary Makefile targets that seem to conflict in "make package" They are actually built by another Makefile and the existing ones didn't even work. --- src/NativeTypes/.gitignore | 2 -- src/NativeTypes/Makefile | 11 +++-------- 2 files changed, 3 insertions(+), 10 deletions(-) delete mode 100644 src/NativeTypes/.gitignore diff --git a/src/NativeTypes/.gitignore b/src/NativeTypes/.gitignore deleted file mode 100644 index 6b69f09a63f0..000000000000 --- a/src/NativeTypes/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -Drawing.cs -Primitives.cs diff --git a/src/NativeTypes/Makefile b/src/NativeTypes/Makefile index f0192c7098f0..4c4786a684c0 100644 --- a/src/NativeTypes/Makefile +++ b/src/NativeTypes/Makefile @@ -1,17 +1,12 @@ -TT = "/Applications/Visual Studio.app/Contents/MacOS/lib/monodevelop/AddIns/MonoDevelop.TextTemplating/TextTransform.exe" - .PHONY: all test clean -all: Primitives.cs Drawing.cs test.exe - -%.cs: %.tt - mono $(TT) $< -o $@ +all: test.exe -test.exe: Primitives.cs Drawing.cs test.cs +test.exe: ../build/common/NativeTypes/Primitives.cs ../build/common/NativeTypes/Drawing.cs test.cs mcs -unsafe -debug -out:$@ $+ -r:System.Drawing -define:XAMCORE_2_0 test: test.exe mono --debug $< clean: - rm -f test.exe{,.mdb} Primitives.cs Drawing.cs + rm -f test.exe{,.mdb} From c2bd7011e2803c90a8f08cf2cd545f9bfd9f962a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Sat, 16 Mar 2019 02:47:32 +0100 Subject: [PATCH 22/96] Fix processing of tools/common/StringUtils.cs in XamarinSourcesPathMangler.cs --- .../XamarinSourcesPathManglerTest.cs | 10 ++++++++ .../XamarinSourcesPathMangler.cs | 25 ++++++++++++------- 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/tools/install-source/InstallSourcesTests/XamarinSourcesPathManglerTest.cs b/tools/install-source/InstallSourcesTests/XamarinSourcesPathManglerTest.cs index 392a3d3699c3..999b0bb6e141 100644 --- a/tools/install-source/InstallSourcesTests/XamarinSourcesPathManglerTest.cs +++ b/tools/install-source/InstallSourcesTests/XamarinSourcesPathManglerTest.cs @@ -86,6 +86,16 @@ public void TestGetSourcePathNativeTypes (string path, string expectedPath) Assert.AreEqual (result, expectedPath); } + [TestCase ("/Users/test/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/Xamarin.iOS/tools/common/StringUtils.cs", + "/Users/test/xamarin-macios/tools/common/StringUtils.cs")] + public void TestGetSourcePathToolsCommon (string path, string expectedPath) + { + var result = mangler.GetSourcePath (path); + var toolsPath = System.IO.Path.GetFullPath (System.IO.Path.Combine (xamarinSourcePath, "..", "tools")); + Assert.IsTrue (result.StartsWith (toolsPath, StringComparison.InvariantCulture), "Path does not start with the XamarinPath '{0}'", toolsPath); + Assert.AreEqual (result, expectedPath); + } + [TestCase ("/Users/test/xamarin-macios/src/build/ios/native/AVFoundation/AVMutableMetadataItem.g.cs", "/Users/test/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/Xamarin.iOS/AVFoundation/AVMutableMetadataItem.g.cs")] [TestCase ("/Users/test/xamarin-macios/src/AVFoundation/AVCaptureDeviceInput.cs", "/Users/test/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/Xamarin.iOS/AVFoundation/AVCaptureDeviceInput.cs")] [TestCase ("/Users/test/xamarin-macios/src/NativeTypes/NMath.cs", "/Users/test/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/Xamarin.iOS/NativeTypes/NMath.cs")] diff --git a/tools/install-source/XamarinSourcesPathMangler.cs b/tools/install-source/XamarinSourcesPathMangler.cs index bd595c4c6ae5..1a22491245c5 100644 --- a/tools/install-source/XamarinSourcesPathMangler.cs +++ b/tools/install-source/XamarinSourcesPathMangler.cs @@ -10,7 +10,8 @@ public class XamarinSourcesPathMangler : IPathMangler { static string GeneratedExtension = ".g.cs"; static string NativeTypeSubpath = "NativeTypes"; - static string CommonSourceSubpath = "/build/common/"; + static string CommonBuildSourceSubpath = "/build/common/"; + static string CommonToolsSourceSubpath = "/tools/common/"; static string RuntimeSubpath = "generated.cs"; /// @@ -54,7 +55,7 @@ static bool IsGeneratedPath (string path) /// Path. public static bool IsManualSource (string path) { - return path.EndsWith (".cs", StringComparison.CurrentCulture) && !path.Contains (CommonSourceSubpath) && !path.Contains (NativeTypeSubpath); + return path.EndsWith (".cs", StringComparison.CurrentCulture) && !path.Contains (CommonBuildSourceSubpath) && !path.Contains (CommonToolsSourceSubpath) && !path.Contains (NativeTypeSubpath); } /// @@ -92,18 +93,24 @@ static bool IsRunrime (string path) string GetSourcePathForNativeType (string path) { string src = ""; - var pos = path.IndexOf (CommonSourceSubpath, StringComparison.InvariantCulture); + var pos = path.IndexOf (CommonBuildSourceSubpath, StringComparison.InvariantCulture); if (pos >= 0) { - src = path.Remove (0, pos + CommonSourceSubpath.Length); + src = path.Remove (0, pos + CommonBuildSourceSubpath.Length); src = Path.Combine (XamarinSourcePath, "build", "common", src); } else { - pos = path.IndexOf (NativeTypeSubpath, StringComparison.InvariantCulture); + pos = path.IndexOf (CommonToolsSourceSubpath, StringComparison.InvariantCulture); if (pos >= 0) { - src = path.Remove (0, pos); - src = Path.Combine (XamarinSourcePath, src); + src = path.Remove (0, pos + CommonToolsSourceSubpath.Length); + src = Path.GetFullPath (Path.Combine (XamarinSourcePath, "..", "tools", "common", src)); } else { - Console.WriteLine ($"Ignoring path {path}"); - return ""; + pos = path.IndexOf (NativeTypeSubpath, StringComparison.InvariantCulture); + if (pos >= 0) { + src = path.Remove (0, pos); + src = Path.Combine (XamarinSourcePath, src); + } else { + Console.WriteLine ($"Ignoring path {path}"); + return ""; + } } } return src; From c73ced0014a353cb41bcca535358e65e16e77e75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Sat, 16 Mar 2019 02:49:11 +0100 Subject: [PATCH 23/96] Bump mono --- external/mono | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/mono b/external/mono index 44016c09a72a..e11eac0f08f5 160000 --- a/external/mono +++ b/external/mono @@ -1 +1 @@ -Subproject commit 44016c09a72a61eb1bcb3d753265f95aca40d053 +Subproject commit e11eac0f08f585ea218dbfea3b3a635e5b15e07e From 1c99284d076a3d1aa192e64a6d8ac41439bf2a29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Mon, 18 Mar 2019 11:57:21 +0100 Subject: [PATCH 24/96] REVERTME: Add workaround for missing System.Drawing.Common reference --- tests/introspection/iOS/introspection-ios.csproj | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/introspection/iOS/introspection-ios.csproj b/tests/introspection/iOS/introspection-ios.csproj index c0e48c59fc88..7231a24d561a 100644 --- a/tests/introspection/iOS/introspection-ios.csproj +++ b/tests/introspection/iOS/introspection-ios.csproj @@ -143,6 +143,7 @@ + From 6b7578306c25d74321b1b92965a3a9bcb8f6e41b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Mon, 18 Mar 2019 19:24:28 +0100 Subject: [PATCH 25/96] Fix MTouch.MT2018_b and MTouch.MT2018_c tests mscorlib.dll now has InternalsVisibleTo to System.Net.Http.dll which causes > Friend access was granted to `System.Net.Http, PublicKeyToken=b03f5f7f11d50a3a', but the output assembly is named `System.Net.Http, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'. Switch to System.Xml.dll instead for these tests. --- tests/mtouch/MTouch.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/mtouch/MTouch.cs b/tests/mtouch/MTouch.cs index 45d24c1c638a..a569402942bb 100644 --- a/tests/mtouch/MTouch.cs +++ b/tests/mtouch/MTouch.cs @@ -3647,7 +3647,7 @@ public void MT2018_b () // this will *not* show the MT2018 error (in fact I don't know if it's possible // to run into MT2018 at all). var tmpA = mtouch.CreateTemporaryDirectory (); - var dllA = CompileTestAppCode ("library", tmpA, "public class X {}", appName: "System.Net.Http"); + var dllA = CompileTestAppCode ("library", tmpA, "public class X {}", appName: "System.Xml"); var dllB = Path.Combine (Configuration.SdkRootXI, "lib", "mono", "Xamarin.iOS", Path.GetFileName (dllA)); @@ -3657,12 +3657,12 @@ public void MT2018_b () // Without the linker we'll just copy the references, and not actually run into problems if we copy one that doesn't work mtouch.Linker = MTouchLinker.DontLink; mtouch.AssertExecute (MTouchAction.BuildSim, "build"); - mtouch.AssertWarningPattern (109, "The assembly 'System.Net.Http.dll' was loaded from a different path than the provided path .provided path: .*/Library/Frameworks/Xamarin.iOS.framework/Versions/Current/lib/mono/Xamarin.iOS/System.Net.Http.dll, actual path: .*CreateTemporaryDirectory.*/System.Net.Http.dll.."); + mtouch.AssertWarningPattern (109, "The assembly 'System.Xml.dll' was loaded from a different path than the provided path .provided path: .*/Library/Frameworks/Xamarin.iOS.framework/Versions/Current/lib/mono/Xamarin.iOS/System.Xml.dll, actual path: .*CreateTemporaryDirectory.*/System.Xml.dll.."); // With the linker, we'll find out that we've loaded the right one. mtouch.Linker = MTouchLinker.LinkSdk; mtouch.AssertExecute (MTouchAction.BuildSim, "build"); - mtouch.AssertWarningPattern (109, "The assembly 'System.Net.Http.dll' was loaded from a different path than the provided path .provided path: .*/Library/Frameworks/Xamarin.iOS.framework/Versions/Current/lib/mono/Xamarin.iOS/System.Net.Http.dll, actual path: .*CreateTemporaryDirectory.*/System.Net.Http.dll.."); + mtouch.AssertWarningPattern (109, "The assembly 'System.Xml.dll' was loaded from a different path than the provided path .provided path: .*/Library/Frameworks/Xamarin.iOS.framework/Versions/Current/lib/mono/Xamarin.iOS/System.Xml.dll, actual path: .*CreateTemporaryDirectory.*/System.Xml.dll.."); } } @@ -3676,7 +3676,7 @@ public void MT2018_c () // this will *not* show the MT2018 error (in fact I don't know if it's possible // to run into MT2018 at all). var tmpA = mtouch.CreateTemporaryDirectory (); - var dllA = CompileTestAppCode ("library", tmpA, "public class X {}", appName: "System.Net.Http"); + var dllA = CompileTestAppCode ("library", tmpA, "public class X {}", appName: "System.Xml"); var dllB = Path.Combine (Configuration.SdkRootXI, "lib", "mono", "Xamarin.iOS", Path.GetFileName (dllA)); @@ -3686,12 +3686,12 @@ public void MT2018_c () // Without the linker we'll just copy the references, and not actually run into problems if we copy one that doesn't work mtouch.Linker = MTouchLinker.DontLink; mtouch.AssertExecute (MTouchAction.BuildSim, "build"); - mtouch.AssertWarningPattern (109, "The assembly 'System.Net.Http.dll' was loaded from a different path than the provided path .provided path: .*CreateTemporaryDirectory.*/System.Net.Http.dll, actual path: .*/Library/Frameworks/Xamarin.iOS.framework/Versions/.*/lib/mono/Xamarin.iOS/System.Net.Http.dll.."); + mtouch.AssertWarningPattern (109, "The assembly 'System.Xml.dll' was loaded from a different path than the provided path .provided path: .*CreateTemporaryDirectory.*/System.Xml.dll, actual path: .*/Library/Frameworks/Xamarin.iOS.framework/Versions/.*/lib/mono/Xamarin.iOS/System.Xml.dll.."); // With the linker, we'll find out that the loaded reference doesn't work. mtouch.Linker = MTouchLinker.LinkSdk; mtouch.AssertExecuteFailure (MTouchAction.BuildSim, "build"); - mtouch.AssertError (2101, "Can't resolve the reference 'X', referenced from the method 'System.Void C::Main()' in 'System.Net.Http, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'."); + mtouch.AssertError (2101, "Can't resolve the reference 'X', referenced from the method 'System.Void C::Main()' in 'System.Xml, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'."); } } From 7a0d44fcb5ceb0829cf1bff06b28f037677d03af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Tue, 19 Mar 2019 00:01:10 +0100 Subject: [PATCH 26/96] Bump mono --- external/mono | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/mono b/external/mono index e11eac0f08f5..ca284bcc8c74 160000 --- a/external/mono +++ b/external/mono @@ -1 +1 @@ -Subproject commit e11eac0f08f585ea218dbfea3b3a635e5b15e07e +Subproject commit ca284bcc8c743de30bc7015ba312bd4ed01053ef From f1035a66d29f9c5f1115defecdfac5a72635525e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Tue, 19 Mar 2019 16:18:25 +0100 Subject: [PATCH 27/96] Bump mono --- external/mono | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/mono b/external/mono index ca284bcc8c74..f7b2cd32aeca 160000 --- a/external/mono +++ b/external/mono @@ -1 +1 @@ -Subproject commit ca284bcc8c743de30bc7015ba312bd4ed01053ef +Subproject commit f7b2cd32aecaa2603d32875cecc23a0d99bd04ed From 5c4be7378fe4934080031fd9be3a8d54211907c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Wed, 20 Mar 2019 01:25:49 +0100 Subject: [PATCH 28/96] Bump mono --- external/mono | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/mono b/external/mono index f7b2cd32aeca..8067ad9ac2d4 160000 --- a/external/mono +++ b/external/mono @@ -1 +1 @@ -Subproject commit f7b2cd32aecaa2603d32875cecc23a0d99bd04ed +Subproject commit 8067ad9ac2d4dd9de898c5c9361672ec48c738af From 39c61cca889540ed20358f0cd4dc73e42116b69f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Wed, 20 Mar 2019 01:32:48 +0100 Subject: [PATCH 29/96] REVERTME: Add workaround for missing System.Drawing.Common reference --- tests/xammac_tests/xammac_tests.csproj | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/xammac_tests/xammac_tests.csproj b/tests/xammac_tests/xammac_tests.csproj index e8ce769f5672..bfdb67740a26 100644 --- a/tests/xammac_tests/xammac_tests.csproj +++ b/tests/xammac_tests/xammac_tests.csproj @@ -60,6 +60,7 @@ + From b8412cf7319f871a8509e972acf7271d2d5c346d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Wed, 20 Mar 2019 12:12:41 +0100 Subject: [PATCH 30/96] Bump mono --- external/mono | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/mono b/external/mono index 8067ad9ac2d4..a3dba5dc89e0 160000 --- a/external/mono +++ b/external/mono @@ -1 +1 @@ -Subproject commit 8067ad9ac2d4dd9de898c5c9361672ec48c738af +Subproject commit a3dba5dc89e0b1bfd83294efce35c3797665b5a3 From c0e85ae6f11539829c1860cb94753b592e7431c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Wed, 20 Mar 2019 12:13:35 +0100 Subject: [PATCH 31/96] SdkTest.cs: remove known LLVM failures that no longer occur and fix oparglist name oparglist was renamed to arglist in https://github.com/mono/mono/commit/d5547b1929afa91944ba941d66a93767ca534a97 --- tests/mtouch/SdkTest.cs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/tests/mtouch/SdkTest.cs b/tests/mtouch/SdkTest.cs index 429724ebf1bd..b875fb333cd4 100644 --- a/tests/mtouch/SdkTest.cs +++ b/tests/mtouch/SdkTest.cs @@ -229,9 +229,6 @@ static string [] GetWatchOSAssemblies () } static Dictionary> known_llvm_failures = new Dictionary> { - { "System.Security.dll", new Tuple (0, new string [] { - "LLVM failed for 'SignedCms.GetContent': non-finally/catch/fault clause.", - }) }, { "System.Data.dll", new Tuple (0, new string [] { "LLVM failed for 'XmlDataDocument.HasPointers': non-finally/catch/fault clause.", "LLVM failed for 'XmlDataDocument.OnFoliated': non-finally/catch/fault clause.", @@ -310,8 +307,8 @@ static string [] GetWatchOSAssemblies () "LLVM failed for 'EnterTryCatchFinallyInstruction.Run': non-finally/catch/fault clause.", }) }, { "mscorlib.dll", new Tuple (0, new string [] { - "LLVM failed for 'Console.Write': opcode oparglist", - "LLVM failed for 'Console.WriteLine': opcode oparglist", + "LLVM failed for 'Console.Write': opcode arglist", + "LLVM failed for 'Console.WriteLine': opcode arglist", }) }, }; From dcc213974cad99e8a226de31adfb886bd5f69d73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Fri, 22 Mar 2019 10:32:01 +0100 Subject: [PATCH 32/96] Bump mono --- external/mono | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/mono b/external/mono index a3dba5dc89e0..537f49f25c1c 160000 --- a/external/mono +++ b/external/mono @@ -1 +1 @@ -Subproject commit a3dba5dc89e0b1bfd83294efce35c3797665b5a3 +Subproject commit 537f49f25c1cc17bdea6d394cf65833bb043fb0b From 9b039e0f9d670fac8fd213f91187374c89d57259 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Fri, 22 Mar 2019 11:19:35 +0100 Subject: [PATCH 33/96] Fix linker paths --- Xamarin.Mac.sln | 2 +- tools/mmp/mmp.csproj | 106 ++++++++++++++++++------------------- tools/mtouch/mtouch.csproj | 102 +++++++++++++++++------------------ 3 files changed, 105 insertions(+), 105 deletions(-) diff --git a/Xamarin.Mac.sln b/Xamarin.Mac.sln index 127328a640ea..83a464422948 100644 --- a/Xamarin.Mac.sln +++ b/Xamarin.Mac.sln @@ -9,7 +9,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mono.Cecil.Mdb", "external\ EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mono.Cecil", "external\mono\external\cecil\Mono.Cecil.csproj", "{D68133BD-1E63-496E-9EDE-4FBDBF77B486}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mono.Linker", "external\mono\external\linker\linker\Mono.Linker.csproj", "{DD28E2B1-057B-4B4D-A04D-B2EBD9E76E46}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mono.Linker", "external\mono\external\linker\src\linker\Mono.Linker.csproj", "{DD28E2B1-057B-4B4D-A04D-B2EBD9E76E46}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "libxammac", "runtime\libxammac.csproj", "{8A5B637C-E4FF-4145-B887-9347020100F4}" EndProject diff --git a/tools/mmp/mmp.csproj b/tools/mmp/mmp.csproj index f243bc880098..5f11bca4dec8 100644 --- a/tools/mmp/mmp.csproj +++ b/tools/mmp/mmp.csproj @@ -46,163 +46,163 @@ - + Mono.Tuner\ApplyPreserveAttributeBase.cs - + Mono.Tuner\CecilRocks.cs - + Mono.Tuner\CustomizeActions.cs - + Mono.Tuner\Dispatcher.cs - + Mono.Tuner\Extensions.cs - + Mono.Tuner\PreserveCrypto.cs - + Mono.Tuner\PreserveSoapHttpClients.cs - + Mono.Tuner\RemoveAttributesBase.cs - + Mono.Tuner\RemoveResources.cs - + Mono.Tuner\RemoveSecurity.cs - + Mono.Tuner\TunerAnnotations.cs - + Linker\Annotations.cs - + Linker\AssemblyAction.cs - + Linker\AssemblyResolver.cs - + Linker\I18nAssemblies.cs - + Linker\IXApiVisitor.cs - + Linker\ILogger.cs - + Linker\ConsoleLogger.cs - + Linker\LinkContext.cs - + Linker\LoadException.cs - + Linker\MarkException.cs - + Linker\MethodAction.cs - + Linker\Pipeline.cs - + Linker\Linker\MethodReferenceExtensions.cs - + Linker\Linker\MarkingHelpers.cs - + Linker\Linker\Tracer.cs - + Linker\Linker\TypeReferenceExtensions.cs - + Linker\TypePreserve.cs - + Linker\KnownMembers.cs - + Linker\BCL.cs - + Linker\MethodDefinitionExtensions.cs - + Linker\TypeDefinitionExtensions.cs - + Linker\MethodBodyScanner.cs - + Linker\AssemblyUtilities.cs - + Linker\TypeNameParser.cs - + Linker\XApiReader.cs - + Linker.Steps\BaseStep.cs - + Linker.Steps\BlacklistStep.cs - + Linker.Steps\CleanStep.cs - + Linker.Steps\IStep.cs - + Linker.Steps\LoadI18nAssemblies.cs - + Linker.Steps\LoadReferencesStep.cs - + Linker.Steps\MarkStep.cs - + Linker.Steps\OutputStep.cs - + Linker.Steps\PreserveDependencyLookupStep.cs - + Linker.Steps\RegenerateGuidStep.cs - + Linker.Steps\ResolveFromAssemblyStep.cs - + Linker.Steps\ResolveFromXApiStep.cs - + Linker.Steps\ResolveFromXmlStep.cs - + Linker.Steps\ResolveStep.cs - + Linker.Steps\SweepStep.cs - + Linker.Steps\TypeMapStep.cs - + Mono.Tuner\Profile.cs diff --git a/tools/mtouch/mtouch.csproj b/tools/mtouch/mtouch.csproj index 77f2a8276d58..4ca1a9de3a0c 100644 --- a/tools/mtouch/mtouch.csproj +++ b/tools/mtouch/mtouch.csproj @@ -79,148 +79,148 @@ MonoTouch.Tuner\RemoveCode.cs - + Linker\XApiReader.cs - + Linker\Annotations.cs - + Linker\LinkContext.cs - + Linker\Pipeline.cs - + Linker\MethodReferenceExtensions.cs - + Linker\Linker\MarkingHelpers.cs - + Linker\Linker\Tracer.cs - + Linker\TypeReferenceExtensions.cs - + Linker\KnownMembers.cs - + Linker\BCL.cs - + Linker\MethodDefinitionExtensions.cs - + Linker\TypeDefinitionExtensions.cs - + Linker\MethodBodyScanner.cs - + Linker\AssemblyResolver.cs - + Linker\IXApiVisitor.cs - + Linker\ILogger.cs - + Linker\ConsoleLogger.cs - + Linker\I18nAssemblies.cs - + Linker\AssemblyAction.cs - + Linker\TypePreserve.cs - + Linker\LoadException.cs - + Linker\MarkException.cs - + Linker\MethodAction.cs - + Linker.Steps\BaseStep.cs - + Linker.Steps\BlacklistStep.cs - + Linker.Steps\CleanStep.cs - + Linker.Steps\IStep.cs - + Linker.Steps\LoadI18nAssemblies.cs - + Linker.Steps\LoadReferencesStep.cs - + Linker.Steps\MarkStep.cs - + Linker.Steps\OutputStep.cs - + Linker.Steps\PreserveDependencyLookupStep.cs - + Linker.Steps\ResolveFromAssemblyStep.cs - + Linker.Steps\ResolveFromXApiStep.cs - + Linker.Steps\ResolveFromXmlStep.cs - + Linker.Steps\ResolveStep.cs - + Linker.Steps\SweepStep.cs - + Linker.Steps\TypeMapStep.cs - + Mono.Tuner\ApplyPreserveAttributeBase.cs - + Mono.Tuner\RemoveAttributesBase.cs - + Mono.Tuner\PreserveSoapHttpClients.cs - + Mono.Tuner\Profile.cs - + Mono.Tuner\CustomizeActions.cs - + Mono.Tuner\RemoveResources.cs - + Mono.Tuner\RemoveSecurity.cs - + Mono.Tuner\Extensions.cs - + Mono.Tuner\FixModuleFlags.cs - + Mono.Tuner\Dispatcher.cs @@ -229,7 +229,7 @@ MonoTouch.Tuner\ProcessExportedFields.cs - + Mono.Tuner\CecilRocks.cs @@ -395,10 +395,10 @@ external\maccore\BindingImplAttribute.cs - + Linker\AssemblyUtilities.cs - + Linker\TypeNameParser.cs From a4702c465cd267ee7386c261140800a068d7e99c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Fri, 22 Mar 2019 12:20:07 +0100 Subject: [PATCH 34/96] Update pdb files in install-source tool --- tools/install-source/Makefile | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/tools/install-source/Makefile b/tools/install-source/Makefile index 507d29ed54a0..28cad31f25c3 100644 --- a/tools/install-source/Makefile +++ b/tools/install-source/Makefile @@ -37,7 +37,6 @@ IOS_ASSEMBLIES = \ $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/mono/Xamarin.iOS/Mono.Data.Sqlite.pdb \ $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/mono/Xamarin.iOS/Mono.Data.Tds.pdb \ $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/mono/Xamarin.iOS/Mono.Security.pdb \ - $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/mono/Xamarin.iOS/Mono.Simd.pdb \ $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/mono/Xamarin.iOS/System.ComponentModel.Composition.pdb \ $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/mono/Xamarin.iOS/System.ComponentModel.DataAnnotations.pdb \ $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/mono/Xamarin.iOS/System.Core.pdb \ @@ -78,22 +77,31 @@ MAC_ASSEMBLIES = \ $(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/lib/mono/4.5/Mono.CompilerServices.SymbolWriter.pdb \ $(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/lib/mono/4.5/Mono.Data.Sqlite.pdb \ $(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/lib/mono/4.5/Mono.Data.Tds.pdb \ + $(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/lib/mono/4.5/Mono.Messaging.pdb \ + $(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/lib/mono/4.5/Mono.Posix.pdb \ $(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/lib/mono/4.5/Mono.Security.pdb \ $(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/lib/mono/4.5/System.ComponentModel.Composition.pdb \ $(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/lib/mono/4.5/System.ComponentModel.DataAnnotations.pdb \ + $(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/lib/mono/4.5/System.Configuration.Install.pdb \ + $(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/lib/mono/4.5/System.Configuration.pdb \ $(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/lib/mono/4.5/System.Core.pdb \ + $(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/lib/mono/4.5/System.Data.Linq.pdb \ $(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/lib/mono/4.5/System.Data.Services.Client.pdb \ $(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/lib/mono/4.5/System.Data.pdb \ + $(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/lib/mono/4.5/System.EnterpriseServices.pdb \ $(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/lib/mono/4.5/System.IO.Compression.FileSystem.pdb \ $(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/lib/mono/4.5/System.IO.Compression.pdb \ + $(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/lib/mono/4.5/System.IdentityModel.Selectors.pdb \ $(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/lib/mono/4.5/System.IdentityModel.pdb \ $(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/lib/mono/4.5/System.Json.pdb \ + $(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/lib/mono/4.5/System.Messaging.pdb \ $(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/lib/mono/4.5/System.Net.Http.WinHttpHandler.pdb \ $(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/lib/mono/4.5/System.Net.Http.pdb \ $(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/lib/mono/4.5/System.Net.pdb \ $(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/lib/mono/4.5/System.Numerics.Vectors.pdb \ $(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/lib/mono/4.5/System.Numerics.pdb \ $(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/lib/mono/4.5/System.Reflection.Context.pdb \ + $(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/lib/mono/4.5/System.Runtime.Serialization.Formatters.Soap.pdb \ $(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/lib/mono/4.5/System.Runtime.Serialization.pdb \ $(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/lib/mono/4.5/System.Security.pdb \ $(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/lib/mono/4.5/System.ServiceModel.Internals.pdb \ @@ -107,19 +115,6 @@ MAC_ASSEMBLIES = \ $(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/lib/mono/4.5/mscorlib.pdb \ $(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/lib/mono/4.5/Xamarin.Mac.pdb -IOS_MDB_FILES = \ - $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/64bits/Xamarin.iOS.dll \ - $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/32bits/Xamarin.iOS.dll - -MAC_MDB_FILES = \ - $(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/lib/x86_64/mobile/Xamarin.Mac.pdb \ - $(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/lib/i386/mobile/Xamarin.Mac.pdb \ - $(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/lib/reference/full/Xamarin.Mac.pdb \ - $(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/lib/x86_64/full/Xamarin.Mac.pdb \ - $(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/lib/i386/full/Xamarin.Mac.pdb \ - $(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/lib/mono/XamMac.CFNetwork.dll.mdb \ - $(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/lib/mono/Xamarin.Mac/Xamarin.Mac.pdb \ - $(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/lib/mono/4.5/Xamarin.Mac.pdb install-source-ios: install-source.exe @echo "Installing source files for Xamarin.iOS" From d473217ace0c8c2d42d4c659ed0d122d462e9f4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Fri, 22 Mar 2019 12:58:52 +0100 Subject: [PATCH 35/96] Fix LinkSdkRegressionTest The internal runtime type was renamed: MonoModule -> RuntimeModule, MonoAssembly -> RuntimeAssembly Also linker got smarter and removed unecessary types for WebKit_NSProxy. --- tests/linker/ios/link sdk/LinkSdkRegressionTest.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/linker/ios/link sdk/LinkSdkRegressionTest.cs b/tests/linker/ios/link sdk/LinkSdkRegressionTest.cs index 036aa3c9c052..debb956272a7 100644 --- a/tests/linker/ios/link sdk/LinkSdkRegressionTest.cs +++ b/tests/linker/ios/link sdk/LinkSdkRegressionTest.cs @@ -77,7 +77,7 @@ public class LinkSdkRegressionTest { public void MonoAssembly_LinkedOut () { Assembly a = Assembly.GetExecutingAssembly (); - Assert.That (a.GetType ().Name, Is.EqualTo ("MonoAssembly"), "MonoAssembly"); + Assert.That (a.GetType ().Name, Is.EqualTo ("RuntimeAssembly"), "RuntimeAssembly"); } [Test] @@ -173,7 +173,7 @@ public void Bug865_CanOpenUrl () public void Bug928_MonoModule_LinkedOut () { Module m = Assembly.GetExecutingAssembly ().ManifestModule; - Assert.That (m.GetType ().Name, Is.EqualTo ("MonoModule"), "MonoModule"); + Assert.That (m.GetType ().Name, Is.EqualTo ("RuntimeModule"), "RuntimeModule"); } #if !__TVOS__ && !__WATCHOS__ @@ -1070,6 +1070,7 @@ public void AppleTls_Default () Assert.Null (GetTypeHelper (fqn), "Should be included"); } +#if !__WATCHOS__ && !__TVOS__ // WebKit isn't available in tvOS or watchOS [Test] // https://bugzilla.xamarin.com/show_bug.cgi?id=59247 public void WebKit_NSProxy () @@ -1080,6 +1081,7 @@ public void WebKit_NSProxy () var fqn = typeof (NSObject).AssemblyQualifiedName.Replace ("Foundation.NSObject", "Foundation.NSProxy"); Assert.NotNull (GetTypeHelper (fqn), fqn); } +#endif // !__WATCHOS__ && !__TVOS__ // Fools linker not to keep the type by using it in test check static Type GetTypeHelper (string name) From 048d170918bcc2d042586fa0d3193004c4ebc8ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Fri, 22 Mar 2019 20:14:50 +0100 Subject: [PATCH 36/96] Bump mono --- external/mono | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/mono b/external/mono index 537f49f25c1c..55a50dbdeba7 160000 --- a/external/mono +++ b/external/mono @@ -1 +1 @@ -Subproject commit 537f49f25c1cc17bdea6d394cf65833bb043fb0b +Subproject commit 55a50dbdeba782a7a38fef72130b9e0ad8b0f423 From f67ca65e95583a35ca2e1f06aa676699804f2ce0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Mon, 25 Mar 2019 16:13:11 +0100 Subject: [PATCH 37/96] mmp: Add -lc++ to clang arguments We need to link with C++ now since Mono requires it on Desktop now. --- tools/mmp/driver.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/mmp/driver.cs b/tools/mmp/driver.cs index 9cd1ddd7c093..2800e13b50d2 100644 --- a/tools/mmp/driver.cs +++ b/tools/mmp/driver.cs @@ -1348,7 +1348,7 @@ static int Compile () args.Append (" -framework Quartz "); } - args.Append ("-liconv -x objective-c++ "); + args.Append ("-liconv -lc++ -x objective-c++ "); if (XcodeVersion.Major >= 10) { // Xcode 10 doesn't ship with libstdc++ args.Append ("-stdlib=libc++ "); From 032145f99bd901169b7b511fbdb71fae17cd109f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Mon, 25 Mar 2019 16:01:09 +0100 Subject: [PATCH 38/96] mmp: Require mono-native even for Classic mode Many BCL APIs call into it now. --- tools/mmp/Application.cs | 4 +--- tools/mmp/driver.cs | 40 ++++++++++++++++++++++------------------ 2 files changed, 23 insertions(+), 21 deletions(-) diff --git a/tools/mmp/Application.cs b/tools/mmp/Application.cs index 02936c8e82d3..38be6c85f135 100644 --- a/tools/mmp/Application.cs +++ b/tools/mmp/Application.cs @@ -25,9 +25,7 @@ void SelectRegistrar () void SelectMonoNative () { - if (Driver.IsClassic) - MonoNativeMode = MonoNativeMode.None; - else if (DeploymentTarget >= new Version (10, 12)) + if (DeploymentTarget >= new Version (10, 12)) MonoNativeMode = MonoNativeMode.Unified; else MonoNativeMode = MonoNativeMode.Compat; diff --git a/tools/mmp/driver.cs b/tools/mmp/driver.cs index 2800e13b50d2..7c78caba5eb1 100644 --- a/tools/mmp/driver.cs +++ b/tools/mmp/driver.cs @@ -875,17 +875,21 @@ static void Pack (IList unprocessed) static void CopyMonoNative () { string name; - switch (App.MonoNativeMode) { - case MonoNativeMode.None: - return; - case MonoNativeMode.Unified: - name = "libmono-native-unified"; - break; - case MonoNativeMode.Compat: - name = "libmono-native-compat"; - break; - default: - throw ErrorHelper.CreateError (99, $"Internal error: Invalid mono native type: '{App.MonoNativeMode}'. Please file a bug report with a test case (https://github.com/xamarin/xamarin-macios/issues/new)."); + if (File.Exists (Path.Combine (MonoDirectory, "lib", "libmono-system-native.dylib"))) { + // legacy libmono-system-native.a needs to be included if it exists in the mono in question + name = "libmono-system-native"; + } else { + // use modern libmono-native + switch (App.MonoNativeMode) { + case MonoNativeMode.Unified: + name = "libmono-native-unified"; + break; + case MonoNativeMode.Compat: + name = "libmono-native-compat"; + break; + default: + throw ErrorHelper.CreateError (99, $"Internal error: Invalid mono native type: '{App.MonoNativeMode}'. Please file a bug report with a test case (https://github.com/xamarin/xamarin-macios/issues/new)."); + } } var src = Path.Combine (MonoDirectory, "lib", name + ".dylib"); @@ -1311,16 +1315,16 @@ static int Compile () string libmono = Path.Combine (libdir, "libmonosgen-2.0.a"); if (!File.Exists (libmono)) - throw new MonoMacException (5202, true, "Mono.framework MDK is missing. Please install the MDK for your Mono.framework version from http://mono-project.com/Downloads"); + throw new MonoMacException (5202, true, "Mono.framework MDK is missing. Please install the MDK for your Mono.framework version from https://www.mono-project.com/download/"); args.Append (StringUtils.Quote (libmono)).Append (' '); - // libmono-system-native.a needs to be included if it exists in the mono in question - string libmonoNative = Path.Combine (libdir, "libmono-system-native.a"); - if (File.Exists (libmonoNative)) - args.Append (StringUtils.Quote (libmonoNative)).Append (' '); - - if (App.MonoNativeMode != MonoNativeMode.None) { + string libmonoSystemNative = Path.Combine (libdir, "libmono-system-native.a"); + if (File.Exists (libmonoSystemNative)) { + // legacy libmono-system-native.a needs to be included if it exists in the mono in question + args.Append (StringUtils.Quote (libmonoSystemNative)).Append (' '); + } else { + // add modern libmono-native string libmono_native_name; switch (App.MonoNativeMode) { case MonoNativeMode.Unified: From 1079592cd1e151b915d880aad336a3dd71915e6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Mon, 25 Mar 2019 19:56:27 +0100 Subject: [PATCH 39/96] tests: Default to using csc instead of mcs --- tests/common/BundlerTool.cs | 6 +++--- tests/common/Configuration.cs | 2 +- tests/mmptest/src/AssemblyReferencesTests.cs | 4 ++-- tests/mmptest/src/MMPTest.cs | 2 +- tests/mmptest/src/MmpTool.cs | 2 +- tests/mmptest/src/TargetFrameworkDetectionTests.cs | 2 +- tests/mtouch/MTouch.cs | 6 +++--- tests/mtouch/MTouchTool.cs | 4 ++-- 8 files changed, 14 insertions(+), 14 deletions(-) diff --git a/tests/common/BundlerTool.cs b/tests/common/BundlerTool.cs index 65fba9979882..b646e0011a20 100644 --- a/tests/common/BundlerTool.cs +++ b/tests/common/BundlerTool.cs @@ -331,9 +331,9 @@ public void AssertExecuteFailure (string message = null) Assert.AreEqual (1, Execute (), message); } - public abstract void CreateTemporaryApp (Profile profile, string appName = "testApp", string code = null, string extraArg = "", string extraCode = null, string usings = null, bool use_csc = false); + public abstract void CreateTemporaryApp (Profile profile, string appName = "testApp", string code = null, string extraArg = "", string extraCode = null, string usings = null, bool use_csc = true); - public static string CompileTestAppExecutable (string targetDirectory, string code = null, string extraArg = "", Profile profile = Profile.iOS, string appName = "testApp", string extraCode = null, string usings = null, bool use_csc = false) + public static string CompileTestAppExecutable (string targetDirectory, string code = null, string extraArg = "", Profile profile = Profile.iOS, string appName = "testApp", string extraCode = null, string usings = null, bool use_csc = true) { if (code == null) code = "public class TestApp { static void Main () { System.Console.WriteLine (typeof (ObjCRuntime.Runtime).ToString ()); } }"; @@ -350,7 +350,7 @@ public static string CompileTestAppLibrary (string targetDirectory, string code, return CompileTestAppCode ("library", targetDirectory, code, extraArg, profile, appName); } - public static string CompileTestAppCode (string target, string targetDirectory, string code, string extraArg = "", Profile profile = Profile.iOS, string appName = "testApp", bool use_csc = false) + public static string CompileTestAppCode (string target, string targetDirectory, string code, string extraArg = "", Profile profile = Profile.iOS, string appName = "testApp", bool use_csc = true) { var ext = target == "exe" ? "exe" : "dll"; var cs = Path.Combine (targetDirectory, "testApp.cs"); diff --git a/tests/common/Configuration.cs b/tests/common/Configuration.cs index 96f0ea49a941..9bec19a64932 100644 --- a/tests/common/Configuration.cs +++ b/tests/common/Configuration.cs @@ -492,7 +492,7 @@ public static string GetSdkPath (Profile profile, bool is_device) } } - public static string GetCompiler (Profile profile, StringBuilder args, bool use_csc = false) + public static string GetCompiler (Profile profile, StringBuilder args, bool use_csc = true) { args.Append (" -lib:").Append (Path.GetDirectoryName (GetBaseLibrary (profile))).Append (' '); if (use_csc) { diff --git a/tests/mmptest/src/AssemblyReferencesTests.cs b/tests/mmptest/src/AssemblyReferencesTests.cs index 4886901115b4..5fbb213eb37e 100644 --- a/tests/mmptest/src/AssemblyReferencesTests.cs +++ b/tests/mmptest/src/AssemblyReferencesTests.cs @@ -45,13 +45,13 @@ public void AllowsUnresolvableReferences () sb.Clear (); sb.AppendFormat ("-target:library -out:{0}/b.dll {0}/b.cs", tmpDir); File.WriteAllText (Path.Combine (tmpDir, "b.cs"), "public class B { }"); - TI.RunAndAssert ("/Library/Frameworks/Mono.framework/Commands/mcs", sb, "b"); + TI.RunAndAssert ("/Library/Frameworks/Mono.framework/Commands/csc", sb, "b"); // build a.dll sb.Clear (); sb.AppendFormat ("-target:library -out:{0}/a.dll {0}/a.cs -r:{0}/b.dll", tmpDir); File.WriteAllText (Path.Combine (tmpDir, "a.cs"), "public class A { public A () { System.Console.WriteLine (typeof (B)); }}"); - TI.RunAndAssert ("/Library/Frameworks/Mono.framework/Commands/mcs", sb, "a"); + TI.RunAndAssert ("/Library/Frameworks/Mono.framework/Commands/csc", sb, "a"); File.Delete (Path.Combine (tmpDir, "b.dll")); diff --git a/tests/mmptest/src/MMPTest.cs b/tests/mmptest/src/MMPTest.cs index 342ae98c75c5..37ee07a1ee99 100644 --- a/tests/mmptest/src/MMPTest.cs +++ b/tests/mmptest/src/MMPTest.cs @@ -214,7 +214,7 @@ public void Dontlink_Allow_ReadonlyAssembly () string assemblyPath = string.Format ("{0}/b.dll", tmpDir); sb.AppendFormat ("-target:library -debug -out:{0} {1}/b.cs", assemblyPath, tmpDir); File.WriteAllText (Path.Combine (tmpDir, "b.cs"), "public class B { }"); - TI.RunAndAssert ("/Library/Frameworks/Mono.framework/Commands/mcs", sb, "b"); + TI.RunAndAssert ("/Library/Frameworks/Mono.framework/Commands/csc", sb, "b"); File.SetAttributes (assemblyPath, FileAttributes.ReadOnly); File.SetAttributes (assemblyPath + ".mdb", FileAttributes.ReadOnly); diff --git a/tests/mmptest/src/MmpTool.cs b/tests/mmptest/src/MmpTool.cs index fb6cf232afec..1c61adfdbf03 100644 --- a/tests/mmptest/src/MmpTool.cs +++ b/tests/mmptest/src/MmpTool.cs @@ -50,7 +50,7 @@ protected override void BuildArguments (StringBuilder sb) } } - public override void CreateTemporaryApp (Profile profile, string appName = "testApp", string code = null, string extraArg = "", string extraCode = null, string usings = null, bool use_csc = false) + public override void CreateTemporaryApp (Profile profile, string appName = "testApp", string code = null, string extraArg = "", string extraCode = null, string usings = null, bool use_csc = true) { if (RootAssembly == null) { OutputPath = CreateTemporaryDirectory (); diff --git a/tests/mmptest/src/TargetFrameworkDetectionTests.cs b/tests/mmptest/src/TargetFrameworkDetectionTests.cs index 9fa9e22beebf..7556cb79194b 100644 --- a/tests/mmptest/src/TargetFrameworkDetectionTests.cs +++ b/tests/mmptest/src/TargetFrameworkDetectionTests.cs @@ -16,7 +16,7 @@ string CreateTestExe (string tmpDir) { string path = Path.Combine (tmpDir, "b.exe"); File.WriteAllText (Path.Combine (tmpDir, "b.cs"), "public static class EntryPoint { public static void Main () {} }"); - TI.RunAndAssert ("/Library/Frameworks/Mono.framework/Commands/mcs", string.Format ("-out:{0} {1}/b.cs", path, tmpDir), "CreateTestExe"); + TI.RunAndAssert ("/Library/Frameworks/Mono.framework/Commands/csc", string.Format ("-out:{0} {1}/b.cs", path, tmpDir), "CreateTestExe"); return path; } diff --git a/tests/mtouch/MTouch.cs b/tests/mtouch/MTouch.cs index 5e0b59932760..e4880db654f7 100644 --- a/tests/mtouch/MTouch.cs +++ b/tests/mtouch/MTouch.cs @@ -1961,7 +1961,7 @@ public static string GetBaseLibrary (Profile profile) return Configuration.GetBaseLibrary (profile); } - public static string GetCompiler (Profile profile, StringBuilder args, bool use_csc = false) + public static string GetCompiler (Profile profile, StringBuilder args, bool use_csc = true) { args.Append (" -lib:").Append (Path.GetDirectoryName (GetBaseLibrary (profile))).Append (' '); if (use_csc) { @@ -4216,7 +4216,7 @@ public void DummyTest () {} ExecutionHelper.Execute ("mono", $"{StringUtils.Quote (Path.Combine (Configuration.RootPath, "tests", "xharness", "xharness.exe"))} --run {StringUtils.Quote (csprojpath)} --target ios-simulator-64 --sdkroot {Configuration.xcode_root} --logdirectory {StringUtils.Quote (Path.Combine (tmpdir, "log.txt"))} --configuration {configuration}", environmentVariables: environment_variables); } - public static string CompileTestAppExecutable (string targetDirectory, string code = null, string extraArg = "", Profile profile = Profile.iOS, string appName = "testApp", string extraCode = null, string usings = null, bool use_csc = false) + public static string CompileTestAppExecutable (string targetDirectory, string code = null, string extraArg = "", Profile profile = Profile.iOS, string appName = "testApp", string extraCode = null, string usings = null, bool use_csc = true) { return BundlerTool.CompileTestAppExecutable (targetDirectory, code, extraArg, profile, appName, extraCode, usings, use_csc); } @@ -4226,7 +4226,7 @@ public static string CompileTestAppLibrary (string targetDirectory, string code, return BundlerTool.CompileTestAppLibrary (targetDirectory, code, extraArg, profile, appName); } - public static string CompileTestAppCode (string target, string targetDirectory, string code, string extraArg = "", Profile profile = Profile.iOS, string appName = "testApp", bool use_csc = false) + public static string CompileTestAppCode (string target, string targetDirectory, string code, string extraArg = "", Profile profile = Profile.iOS, string appName = "testApp", bool use_csc = true) { return BundlerTool.CompileTestAppCode (target, targetDirectory, code, extraArg, profile, appName, use_csc); } diff --git a/tests/mtouch/MTouchTool.cs b/tests/mtouch/MTouchTool.cs index a0120cd8acd8..e61639b7defe 100644 --- a/tests/mtouch/MTouchTool.cs +++ b/tests/mtouch/MTouchTool.cs @@ -455,13 +455,13 @@ public string CreateTemporarySatelliteAssembly (string culture = "en-AU") return MTouch.CompileTestAppLibrary (asm_dir, "class X {}", appName: Path.GetFileNameWithoutExtension (asm_name)); } - public override void CreateTemporaryApp (Profile profile, string appName = "testApp", string code = null, string extraArg = "", string extraCode = null, string usings = null, bool use_csc = false) + public override void CreateTemporaryApp (Profile profile, string appName = "testApp", string code = null, string extraArg = "", string extraCode = null, string usings = null, bool use_csc = true) { Profile = profile; CreateTemporaryApp (appName: appName, code: code, extraArg: extraArg, extraCode: extraCode, usings: usings, use_csc: use_csc); } - public void CreateTemporaryApp (bool hasPlist = false, string appName = "testApp", string code = null, string extraArg = "", string extraCode = null, string usings = null, bool use_csc = false) + public void CreateTemporaryApp (bool hasPlist = false, string appName = "testApp", string code = null, string extraArg = "", string extraCode = null, string usings = null, bool use_csc = true) { string testDir; if (RootAssembly == null) { From 40a58811bb1a9322e5277cd6bf5dd64605319b33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Mon, 25 Mar 2019 20:20:10 +0100 Subject: [PATCH 40/96] Fix TestAllLoad() mtouch test --- tests/mtouch/MTouch.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/mtouch/MTouch.cs b/tests/mtouch/MTouch.cs index e4880db654f7..d282fc83bded 100644 --- a/tests/mtouch/MTouch.cs +++ b/tests/mtouch/MTouch.cs @@ -3113,6 +3113,10 @@ public void TestAllLoad () using (var mtouch = new MTouchTool ()) { mtouch.CreateTemporaryApp (); mtouch.GccFlags = "-all_load"; + // the test app doesn't depend on any BCL assembly that would cause mtouch to + // pull in GSS, but -all_load will cause all members of libmono-native to be + // loaded so we need to manually add GSS.framework or we'd get undefined symobls + mtouch.GccFlags += " -framework GSS"; mtouch.Abi = "armv7,arm64"; mtouch.TargetVer = "10.3"; // otherwise 32-bit builds aren't possible mtouch.AssertExecute (MTouchAction.BuildDev, "build"); From 1cb9c5b0684f544f68b799de66233d0416300420 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Tue, 26 Mar 2019 12:41:48 +0100 Subject: [PATCH 41/96] Fix MT1015() mtouch test Mono started using System.IO.File from CoreFX and it has a different behavior for File.Copy() when the target is a directory: It just puts the file into the directory instead of raising an exception. In order to fix the MT1015 test we just check ourselves whether the target is a directory. --- tools/mtouch/Target.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/mtouch/Target.cs b/tools/mtouch/Target.cs index 63cc84805515..300d7343b0d0 100644 --- a/tools/mtouch/Target.cs +++ b/tools/mtouch/Target.cs @@ -1727,6 +1727,8 @@ public void Symlink () else if (Is64Build) launcher.Append ("64"); launcher.Append ("-sgen"); + if (Directory.Exists (targetExecutable)) + throw new ArgumentException ($"{targetExecutable} is a directory."); File.Copy (launcher.ToString (), targetExecutable); File.SetLastWriteTime (targetExecutable, DateTime.Now); } catch (MonoTouchException) { From f7864d5bfc00e3d7c522edbcc8255ebf5c4e8efd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Wed, 27 Mar 2019 01:28:56 +0100 Subject: [PATCH 42/96] Fix introspection tests due to new reflection ctor.ToString() format Mono is now using reflection code from corefx and the string includes namespace now. --- tests/introspection/ApiCtorInitTest.cs | 29 ++++++++++++++++---------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/tests/introspection/ApiCtorInitTest.cs b/tests/introspection/ApiCtorInitTest.cs index e759044ef648..2407db1b242c 100644 --- a/tests/introspection/ApiCtorInitTest.cs +++ b/tests/introspection/ApiCtorInitTest.cs @@ -331,11 +331,18 @@ public void DesignatedInitializer () protected virtual bool Match (ConstructorInfo ctor, Type type) { +#if XAMCORE_2_0 + string foundation_namespace = "Foundation"; +#elif MONOMAC + string foundation_namespace = "MonoMac.Foundation"; +#else + string foundation_namespace = "MonoTouch.Foundation"; +#endif switch (type.Name) { case "MKTileOverlayRenderer": // NSInvalidArgumentEception Expected a MKTileOverlay // looks like Apple has not yet added a DI for this type, but it should be `initWithTileOverlay:` - if (ctor.ToString () == "Void .ctor(IMKOverlay)") + if (ctor.ToString () == $"Void .ctor(MapKit.IMKOverlay)") return true; break; case "MPSMatrixMultiplication": @@ -343,18 +350,18 @@ protected virtual bool Match (ConstructorInfo ctor, Type type) case "MPSImageHistogram": // Could not initialize an instance of the type 'MetalPerformanceShaders.MPSImageHistogram': the native 'initWithDevice:' method returned nil. // make sense: there's a `initWithDevice:histogramInfo:` DI - if (ctor.ToString () == "Void .ctor(IMTLDevice)") + if (ctor.ToString () == $"Void .ctor(Metal.IMTLDevice)") return true; break; case "NSDataDetector": // -[NSDataDetector initWithPattern:options:error:]: Not valid for NSDataDetector - if (ctor.ToString () == "Void .ctor(NSString, NSRegularExpressionOptions, NSError&)") + if (ctor.ToString () == $"Void .ctor({foundation_namespace}.NSString, {foundation_namespace}.NSRegularExpressionOptions, {foundation_namespace}.NSError ByRef)") return true; break; case "SKStoreProductViewController": case "SKCloudServiceSetupViewController": // SKStoreProductViewController and SKCloudServiceSetupViewController are OS View Controllers which can't be customized. Therefore they shouldn't re-expose initWithNibName:bundle: - if (ctor.ToString () == "Void .ctor(String, NSBundle)") + if (ctor.ToString () == $"Void .ctor(System.String, {foundation_namespace}.NSBundle)") return true; break; case "MKCompassButton": @@ -386,19 +393,19 @@ protected virtual bool Match (ConstructorInfo ctor, Type type) // This ctor was introduced in 10,13 but all of the above objects are deprecated in 10,12 // so it does not make much sense to expose this ctor in all the deprecated subclasses #if XAMCORE_2_0 - if (ctor.ToString () == "Void .ctor(CGRect, NSString, NSDictionary)") + if (ctor.ToString () == $"Void .ctor(CoreGraphics.CGRect, {foundation_namespace}.NSString, {foundation_namespace}.NSDictionary)") #else - if (ctor.ToString () == "Void .ctor(RectangleF, NSString, NSDictionary)") + if (ctor.ToString () == $"Void .ctor(System.Drawing.RectangleF, {foundation_namespace}.NSString, {foundation_namespace}.NSDictionary)") #endif return true; break; case "VNTargetedImageRequest": // Explicitly disabled - if (ctor.ToString () == "Void .ctor(VNRequestCompletionHandler)") + if (ctor.ToString () == $"Void .ctor(Vision.VNRequestCompletionHandler)") return true; break; case "PKPaymentRequestShippingContactUpdate": // a more precise designated initializer is provided - if (ctor.ToString () == "Void .ctor(PKPaymentSummaryItem[])") + if (ctor.ToString () == $"Void .ctor(PassKit.PKPaymentSummaryItem[])") return true; break; case "NSApplication": // Does not make sense, also it crashes @@ -408,12 +415,12 @@ protected virtual bool Match (ConstructorInfo ctor, Type type) case "NSCustomImageRep": // exception raised case "NSEPSImageRep": // exception raised case "NSPdfImageRep": // exception raised - if (ctor.ToString () == "Void .ctor()") + if (ctor.ToString () == $"Void .ctor()") return true; break; case "AUPannerView": // Do not make sense without the AudioUnit case "AUGenericView": // Do not make sense without the AudioUnit - if (ctor.ToString () == "Void .ctor(CGRect)") + if (ctor.ToString () == $"Void .ctor(CoreGraphics.CGRect)") return true; break; case "MDLNoiseTexture": @@ -428,7 +435,7 @@ protected virtual bool Match (ConstructorInfo ctor, Type type) case "INUIAddVoiceShortcutViewController": // Doesn't make sense without INVoiceShortcut and there is no other way to set this unless you use the other only .ctor case "INUIEditVoiceShortcutViewController": // Doesn't make sense without INVoiceShortcut and there is no other way to set this unless you use the other only .ctor case "ILClassificationUIExtensionViewController": // Meant to be an extension - if (ctor.ToString () == "Void .ctor(String, NSBundle)") + if (ctor.ToString () == $"Void .ctor(System.String, {foundation_namespace}.NSBundle)") return true; break; } From 618fa41c1be9d4e4a04c3b45ce8fdf6c7c2b3a11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Wed, 27 Mar 2019 01:34:38 +0100 Subject: [PATCH 43/96] Bump mono --- external/mono | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/mono b/external/mono index 55a50dbdeba7..faddbcae96a3 160000 --- a/external/mono +++ b/external/mono @@ -1 +1 @@ -Subproject commit 55a50dbdeba782a7a38fef72130b9e0ad8b0f423 +Subproject commit faddbcae96a307dc3af929419982f4d550660597 From bcae65f998be2215075f133312259a950d0574d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Wed, 27 Mar 2019 11:14:11 +0100 Subject: [PATCH 44/96] MTouch: Always add GSS framework when mono-native is used According to Rolf it's fine to always add since the native linker will figure out if it's really needed and so customers don't need to do anything when using -all_load. --- tests/mtouch/MTouch.cs | 4 ---- tools/common/DerivedLinkContext.cs | 4 ---- tools/linker/MonoTouch.Tuner/ListExportedSymbols.cs | 6 +----- tools/mtouch/Target.cs | 12 ++---------- 4 files changed, 3 insertions(+), 23 deletions(-) diff --git a/tests/mtouch/MTouch.cs b/tests/mtouch/MTouch.cs index d282fc83bded..e4880db654f7 100644 --- a/tests/mtouch/MTouch.cs +++ b/tests/mtouch/MTouch.cs @@ -3113,10 +3113,6 @@ public void TestAllLoad () using (var mtouch = new MTouchTool ()) { mtouch.CreateTemporaryApp (); mtouch.GccFlags = "-all_load"; - // the test app doesn't depend on any BCL assembly that would cause mtouch to - // pull in GSS, but -all_load will cause all members of libmono-native to be - // loaded so we need to manually add GSS.framework or we'd get undefined symobls - mtouch.GccFlags += " -framework GSS"; mtouch.Abi = "armv7,arm64"; mtouch.TargetVer = "10.3"; // otherwise 32-bit builds aren't possible mtouch.AssertExecute (MTouchAction.BuildDev, "build"); diff --git a/tools/common/DerivedLinkContext.cs b/tools/common/DerivedLinkContext.cs index ca937f7c7ca5..9bfe319dbcc0 100644 --- a/tools/common/DerivedLinkContext.cs +++ b/tools/common/DerivedLinkContext.cs @@ -81,10 +81,6 @@ public bool RequireMonoNative { get; set; } - public bool RequireGss { - get; set; - } - public DerivedLinkContext (Pipeline pipeline, AssemblyResolver resolver) : base (pipeline, resolver) { diff --git a/tools/linker/MonoTouch.Tuner/ListExportedSymbols.cs b/tools/linker/MonoTouch.Tuner/ListExportedSymbols.cs index 4de7ed2a008a..ad93f186349c 100644 --- a/tools/linker/MonoTouch.Tuner/ListExportedSymbols.cs +++ b/tools/linker/MonoTouch.Tuner/ListExportedSymbols.cs @@ -117,12 +117,8 @@ void ProcessMethod (MethodDefinition method) DerivedLinkContext.RequiredSymbols.AddFunction (pinfo.EntryPoint).AddMember (method); break; case "System.Native": - case "System.Security.Cryptography.Native.Apple": - DerivedLinkContext.RequireMonoNative = true; - DerivedLinkContext.RequiredSymbols.AddFunction (pinfo.EntryPoint).AddMember (method); - break; case "System.Net.Security.Native": - DerivedLinkContext.RequireGss = true; + case "System.Security.Cryptography.Native.Apple": DerivedLinkContext.RequireMonoNative = true; DerivedLinkContext.RequiredSymbols.AddFunction (pinfo.EntryPoint).AddMember (method); break; diff --git a/tools/mtouch/Target.cs b/tools/mtouch/Target.cs index 300d7343b0d0..be8d6ae5b2f2 100644 --- a/tools/mtouch/Target.cs +++ b/tools/mtouch/Target.cs @@ -1589,7 +1589,6 @@ public NativeLinkTask NativeLink (BuildTasks build_tasks, Abi abi, string output public class MonoNativeInfo { public bool RequireMonoNative { get; set; } - public bool RequireGss { get; set; } public void Load (string filename) { @@ -1606,9 +1605,6 @@ public void Load (string filename) case "RequireMonoNative": RequireMonoNative = value; break; - case "RequireGss": - RequireGss = value; - break; default: throw ErrorHelper.CreateError (99, $"Internal error: invalid type string while loading cached Mono.Native info: {typestr}. Please file a bug report with a test case (https://github.com/xamarin/xamarin-macios/issues/new)."); } @@ -1620,7 +1616,6 @@ public void Save (string filename) { using (var writer = new StreamWriter (filename)) { writer.WriteLine ("RequireMonoNative={0}", RequireMonoNative); - writer.WriteLine ("RequireGss={0}", RequireGss); } } } @@ -1639,7 +1634,6 @@ public MonoNativeInfo MonoNative mono_native_info.Load (cache_location); } else { mono_native_info.RequireMonoNative = LinkContext?.RequireMonoNative ?? true; - mono_native_info.RequireGss = LinkContext?.RequireGss ?? true; mono_native_info.Save (cache_location); } @@ -1666,10 +1660,8 @@ void HandleMonoNative (Application app, CompilerFlags compiler_flags) compiler_flags.AddLinkWith (libnative); switch (app.Platform) { case ApplePlatform.iOS: - if (MonoNative.RequireGss) { - Driver.Log (3, "Adding GSS framework reference."); - compiler_flags.AddFramework ("GSS"); - } + Driver.Log (3, "Adding GSS framework reference."); + compiler_flags.AddFramework ("GSS"); break; } break; From b1b557a1b90f7fe1a13ff97b7031c4e691b544f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Wed, 27 Mar 2019 13:33:23 +0100 Subject: [PATCH 45/96] Reenable a few BCLTests --- ...otouch_System.Web.Services_test.dll.ignore | 5 -- ...ac_net_4_5_System.Security_test.dll.ignore | 5 -- ...xammac_net_4_5_System.Data_test.dll.ignore | 51 ------------------- ...-xammac_net_4_5_System.Xml_test.dll.ignore | 14 ----- 4 files changed, 75 deletions(-) delete mode 100644 tests/bcl-test/BCLTests/common-monotouch_System.Web.Services_test.dll.ignore delete mode 100644 tests/bcl-test/BCLTests/macOS-xammac_net_4_5_System.Security_test.dll.ignore delete mode 100644 tests/bcl-test/BCLTests/macOSFull-xammac_net_4_5_System.Xml_test.dll.ignore diff --git a/tests/bcl-test/BCLTests/common-monotouch_System.Web.Services_test.dll.ignore b/tests/bcl-test/BCLTests/common-monotouch_System.Web.Services_test.dll.ignore deleted file mode 100644 index 71cbd566e31a..000000000000 --- a/tests/bcl-test/BCLTests/common-monotouch_System.Web.Services_test.dll.ignore +++ /dev/null @@ -1,5 +0,0 @@ -# System.IO.DirectoryNotFoundException: SystemWebServicesTests.app/Test/System.Web.Services.Description/test.wsdl -MonoTests.System.Web.Services.Description.ServiceDescriptionTest.ExtensibleAttributes -MonoTests.System.Web.Services.Description.ServiceDescriptionTest.Extensions -MonoTests.System.Web.Services.Description.ServiceDescriptionTest.Namespaces -MonoTests.System.Web.Services.Description.ServiceDescriptionTest.ReadAndRetrievalUrl \ No newline at end of file diff --git a/tests/bcl-test/BCLTests/macOS-xammac_net_4_5_System.Security_test.dll.ignore b/tests/bcl-test/BCLTests/macOS-xammac_net_4_5_System.Security_test.dll.ignore deleted file mode 100644 index 6f3463ed7aef..000000000000 --- a/tests/bcl-test/BCLTests/macOS-xammac_net_4_5_System.Security_test.dll.ignore +++ /dev/null @@ -1,5 +0,0 @@ -# System.IO.DirectoryNotFoundException : Could not find a part of the path -MonoTests.System.Security.Cryptography.Xml.EncryptedXmlTest.Sample3 -MonoTests.System.Security.Cryptography.Xml.EncryptedXmlTest.Sample2 -MonoTests.System.Security.Cryptography.Xml.EncryptedXmlTest.Sample1 -MonoTests.System.Security.Cryptography.Pkcs.SignedCmsTest.CheckSignatureDetachedSignedCms \ No newline at end of file diff --git a/tests/bcl-test/BCLTests/macOSFull-xammac_net_4_5_System.Data_test.dll.ignore b/tests/bcl-test/BCLTests/macOSFull-xammac_net_4_5_System.Data_test.dll.ignore index 257488044237..755c2ea783b5 100644 --- a/tests/bcl-test/BCLTests/macOSFull-xammac_net_4_5_System.Data_test.dll.ignore +++ b/tests/bcl-test/BCLTests/macOSFull-xammac_net_4_5_System.Data_test.dll.ignore @@ -1,54 +1,3 @@ -# System.IO.DirectoryNotFoundException : Could not find a part of the path -Monotests_Mono.Data.SqlExpressions.DateComparisonTest.TestDateComparisonRight -MonoTests.System.Data.XmlDataReaderTest.XmlLoadTest -Monotests_Mono.Data.SqlExpressions.DateComparisonTest.TestDateComparisonRigh -MonoTests.System.Data.XmlDataReaderTest.XmlLoadTest -MonoTests.System.Data.Xml.XmlDataDocumentTest.Test6 -MonoTests.System.Data.Xml.XmlDataDocumentTest.Test5 -MonoTests.System.Data.Xml.XmlDataDocumentTest.Test4 -MonoTests.System.Data.Xml.XmlDataDocumentTest.Test3 -MonoTests.System.Data.Xml.XmlDataDocumentTest.Test2 -MonoTests.System.Data.Xml.XmlDataDocumentTest.Test1 -MonoTests.System.Data.Xml.XmlDataDocumentTest.Navigator -MonoTests.System.Data.Xml.XmlDataDocumentTest.GetRowFromElement -MonoTests.System.Data.Xml.XmlDataDocumentTest.GetElementFromRow -MonoTests.System.Data.Xml.XmlDataDocumentTest.EditingXmlTree -MonoTests.System.Data.Xml.XmlDataDocumentTest.EditingDataSet -MonoTests.System.Data.Xml.XmlDataDocumentTest.CreateElement3 -MonoTests.System.Data.Xml.XmlDataDocumentTest.CreateElement2 -MonoTests.System.Data.Xml.XmlDataDocumentTest.CreateElement1 -MonoTests.System.Data.Xml.XmlDataDocumentTest.CloneNode -MonoTests.System.Data.DataTableTest.WriteXmlSchema -MonoTests.System.Data.DataTableReadXmlSchemaTest.TestSampleFileXPath -MonoTests.System.Data.DataTableReadXmlSchemaTest.TestSampleFileSimpleTables -MonoTests.System.Data.DataTableReadXmlSchemaTest.TestSampleFileComplexTables3 -MonoTests.System.Data.DataTableReadXmlSchemaTest.ReadConstraints -MonoTests.System.Data.DataSetTypedDataSetTest.TypedDataSet -MonoTests.System.Data.DataSetTest2.ReadXmlSchema_TableOrder -MonoTests.System.Data.DataSetTest2.ReadXmlSchema_Nested -MonoTests.System.Data.DataSetTest2.Merge_ConstraintsFromReadXmlSchema -MonoTests.System.Data.DataSetTest.WriteXmlSchema -MonoTests.System.Data.DataSetTest.ReadXmlSchema -MonoTests.System.Data.DataSetTest.ReadWriteXmlDiffGram -MonoTests.System.Data.DataSetTest.ReadWriteXml -MonoTests.System.Data.DataSetTest.CloneCopy2 -MonoTests.System.Data.DataSetReadXmlTest.DataSetExtendedPropertiesTest -MonoTests.System.Data.DataSetReadXmlSchemaTest.TestSampleFileXPath -MonoTests.System.Data.DataSetReadXmlSchemaTest.TestSampleFileSimpleTables -MonoTests.System.Data.DataSetReadXmlSchemaTest.TestSampleFileNoTables -MonoTests.System.Data.DataSetReadXmlSchemaTest.TestSampleFileComplexTables3 -MonoTests.System.Data.DataSetReadXmlSchemaTest.TestSampleFileComplexTables -MonoTests.System.Data.DataSetReadXmlSchemaTest.TestMoreThanOneRepeatableColumns -MonoTests.System.Data.DataSetReadXmlSchemaTest.TestAnnotatedRelation2 -MonoTests.System.Data.DataSetReadXmlSchemaTest.TestAnnotatedRelation1 -MonoTests.System.Data.DataSetReadXmlSchemaTest.RepeatableSimpleElement -MonoTests.System.Data.DataSetReadXmlSchemaTest.ReadConstraints -MonoTests.System.Data.DataSetReadXmlSchemaTest.ReadAnnotatedRelations_MultipleColumns -MonoTests.System.Data.DataRelationTest.RelationFromSchema -MonoTests.System.Data.DataTableTest.ReadXmlSchema -MonoTests.System.Data.BinarySerializationTest.Test_With_Null_Values2 -MonoTests.System.Data.BinarySerializationTest.DataTableSerializationTest2 - # System.NullReferenceException : Object reference not set to an instance of an object MonoTests.System.Data.Common.DbProviderFactoriesConfigurationHandlerTest.PopulateTest diff --git a/tests/bcl-test/BCLTests/macOSFull-xammac_net_4_5_System.Xml_test.dll.ignore b/tests/bcl-test/BCLTests/macOSFull-xammac_net_4_5_System.Xml_test.dll.ignore deleted file mode 100644 index cf89ae5be222..000000000000 --- a/tests/bcl-test/BCLTests/macOSFull-xammac_net_4_5_System.Xml_test.dll.ignore +++ /dev/null @@ -1,14 +0,0 @@ -# System.IO.DirectoryNotFoundException : Could not find a part of the path -MonoTests.System.Xml.Serialization.XmlSchemaImporterTests.ImportWildcardElementAsClass -MonoTests.System.XmlSerialization.XmlCodeExporterTests.DuplicateIdentifiers - -# Expected string length 566 but was 562. Strings differ at index 66. -# Expected: "...piler.GeneratedCodeAttribute("nunit-lite-console", "0.0.0...." -# But was: "...piler.GeneratedCodeAttribute("SystemXmlTests", "0.0.0.0")]..." -MonoTests.System.XmlSerialization.XmlCodeExporterTests.ExportTypeMapping_ArrayClass -MonoTests.System.XmlSerialization.XmlCodeExporterTests.ExportTypeMapping_ArrayContainer -MonoTests.System.XmlSerialization.XmlCodeExporterTests.ExportTypeMapping_CDataContainer -MonoTests.System.XmlSerialization.XmlCodeExporterTests.ExportTypeMapping_ClassArrayContainer -MonoTests.System.XmlSerialization.XmlCodeExporterTests.ExportTypeMapping_ItemChoiceType -MonoTests.System.XmlSerialization.XmlCodeExporterTests.ExportTypeMapping_SimpleClassWithXmlAttributes -MonoTests.System.XmlSerialization.XmlCodeExporterTests.ExportTypeMapping_ZeroFlagEnum \ No newline at end of file From d9ea3f6928a45f1459c3c0703787d58f83bb25c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Wed, 27 Mar 2019 23:57:39 +0100 Subject: [PATCH 46/96] Bump mono --- external/mono | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/mono b/external/mono index faddbcae96a3..bff188abc469 160000 --- a/external/mono +++ b/external/mono @@ -1 +1 @@ -Subproject commit faddbcae96a307dc3af929419982f4d550660597 +Subproject commit bff188abc469852c82b6e4e02c184373b8ff1a31 From d91769a5a381130662683c4937f6ad18d0c7ba61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Thu, 28 Mar 2019 00:16:53 +0100 Subject: [PATCH 47/96] Fix two mmp/mtouch tests after the mcs->csc default change --- tests/mmptest/src/MMPTest.cs | 2 +- tests/mtouch/MTouch.cs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/mmptest/src/MMPTest.cs b/tests/mmptest/src/MMPTest.cs index 37ee07a1ee99..6691b57b7220 100644 --- a/tests/mmptest/src/MMPTest.cs +++ b/tests/mmptest/src/MMPTest.cs @@ -217,7 +217,7 @@ public void Dontlink_Allow_ReadonlyAssembly () TI.RunAndAssert ("/Library/Frameworks/Mono.framework/Commands/csc", sb, "b"); File.SetAttributes (assemblyPath, FileAttributes.ReadOnly); - File.SetAttributes (assemblyPath + ".mdb", FileAttributes.ReadOnly); + File.SetAttributes (Path.ChangeExtension (assemblyPath, ".pdb"), FileAttributes.ReadOnly); // build project referencing a.dll TI.UnifiedTestConfig test = new TI.UnifiedTestConfig (tmpDir) diff --git a/tests/mtouch/MTouch.cs b/tests/mtouch/MTouch.cs index e4880db654f7..4b2f059b4b7a 100644 --- a/tests/mtouch/MTouch.cs +++ b/tests/mtouch/MTouch.cs @@ -3514,7 +3514,7 @@ public void OnlyDebugFileChange (MTouchLinker linker_options) // Create a sample exe var code = "public class TestApp { static void Main () { System.Console.WriteLine (typeof (ObjCRuntime.Runtime).ToString ()); } }"; - var exe = MTouch.CompileTestAppExecutable (tmp, code, "/debug:full"); + var exe = MTouch.CompileTestAppExecutable (tmp, code, "/debug:full", use_csc: false); mtouch.AppPath = mtouch.CreateTemporaryDirectory (); mtouch.RootAssembly = exe; @@ -3531,12 +3531,12 @@ public void OnlyDebugFileChange (MTouchLinker linker_options) System.Threading.Thread.Sleep (1000); // HFS does not have sub-second timestamp resolution, so make sure the timestamps actually change... // Recompile the exe, adding only whitespace. This will only change the debug files - MTouch.CompileTestAppExecutable (tmp, "\n\n" + code + "\n\n", "/debug:full"); + MTouch.CompileTestAppExecutable (tmp, "\n\n" + code + "\n\n", "/debug:full", use_csc: false); // Rebuild the app mtouch.AssertExecute (MTouchAction.BuildSim); - // The mdb files should be updated, but the exe should not. + // The pdb files should be updated, but the exe should not. Assert.AreEqual (exeStamp, File.GetLastWriteTimeUtc (exePath), "exe no change"); Assert.IsTrue (File.Exists (mdbPath), "mdb existence"); Assert.AreNotEqual (mdbStamp, File.GetLastWriteTimeUtc (mdbPath), "mdb changed"); From e63eeafe62ec46cda5b2299df6eb21d1ec589677 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Thu, 28 Mar 2019 11:05:14 +0100 Subject: [PATCH 48/96] Fix Generator to include a reference to System.Drawing.Common --- src/btouch.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/btouch.cs b/src/btouch.cs index 7248ea969e62..776037f26e17 100644 --- a/src/btouch.cs +++ b/src/btouch.cs @@ -339,6 +339,7 @@ static int Main2 (string [] args) if (string.IsNullOrEmpty (baselibdll)) baselibdll = Path.Combine (GetSDKRoot (), "lib/mono/2.1/monotouch.dll"); Path.Combine (GetSDKRoot (), "bin/smcs"); + references.Add ("Facades/System.Drawing.Common"); ReferenceFixer.FixSDKReferences (GetSDKRoot (), "lib/mono/2.1/", references); break; case "xamarin.ios": @@ -347,6 +348,7 @@ static int Main2 (string [] args) nostdlib = true; if (string.IsNullOrEmpty (baselibdll)) baselibdll = Path.Combine (GetSDKRoot (), "lib/mono/Xamarin.iOS/Xamarin.iOS.dll"); + references.Add ("Facades/System.Drawing.Common"); ReferenceFixer.FixSDKReferences (GetSDKRoot (), "lib/mono/Xamarin.iOS", references); break; case "xamarin.tvos": @@ -355,6 +357,7 @@ static int Main2 (string [] args) nostdlib = true; if (string.IsNullOrEmpty (baselibdll)) baselibdll = Path.Combine (GetSDKRoot (), "lib/mono/Xamarin.TVOS/Xamarin.TVOS.dll"); + references.Add ("Facades/System.Drawing.Common"); ReferenceFixer.FixSDKReferences (GetSDKRoot (), "lib/mono/Xamarin.TVOS", references); break; case "xamarin.watchos": @@ -363,6 +366,7 @@ static int Main2 (string [] args) nostdlib = true; if (string.IsNullOrEmpty (baselibdll)) baselibdll = Path.Combine (GetSDKRoot (), "lib/mono/Xamarin.WatchOS/Xamarin.WatchOS.dll"); + references.Add ("Facades/System.Drawing.Common"); ReferenceFixer.FixSDKReferences (GetSDKRoot (), "lib/mono/Xamarin.WatchOS", references); break; case "xammac": @@ -370,6 +374,7 @@ static int Main2 (string [] args) Unified = false; if (string.IsNullOrEmpty (baselibdll)) baselibdll = Path.Combine (GetSDKRoot (), "lib", "mono", "XamMac.dll"); + references.Add ("Facades/System.Drawing.Common"); ReferenceFixer.FixSDKReferences ("/Library/Frameworks/Mono.framework/Versions/Current/lib/mono/4.5", references); break; case "xamarin.mac": @@ -386,9 +391,11 @@ static int Main2 (string [] args) } if (target_framework == TargetFramework.Xamarin_Mac_2_0_Mobile) { skipSystemDrawing = true; + references.Add ("Facades/System.Drawing.Common"); ReferenceFixer.FixSDKReferences (GetSDKRoot (), "lib/mono/Xamarin.Mac", references); } else if (target_framework == TargetFramework.Xamarin_Mac_4_5_Full) { skipSystemDrawing = true; + references.Add ("Facades/System.Drawing.Common"); ReferenceFixer.FixSDKReferences (GetSDKRoot (), "lib/mono/4.5", references); } else if (target_framework == TargetFramework.Xamarin_Mac_4_5_System) { skipSystemDrawing = false; From 56bb4f95054850a753da969b5bafcfa7615088c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Thu, 28 Mar 2019 11:16:47 +0100 Subject: [PATCH 49/96] Reenable more BCLTests --- .../macOS-xammac_net_4_5_Mono.CSharp_test.dll.ignore | 2 -- ...OSFull-xammac_net_4_5_System.Data_test.dll.ignore | 12 ------------ 2 files changed, 14 deletions(-) delete mode 100644 tests/bcl-test/BCLTests/macOS-xammac_net_4_5_Mono.CSharp_test.dll.ignore delete mode 100644 tests/bcl-test/BCLTests/macOSFull-xammac_net_4_5_System.Data_test.dll.ignore diff --git a/tests/bcl-test/BCLTests/macOS-xammac_net_4_5_Mono.CSharp_test.dll.ignore b/tests/bcl-test/BCLTests/macOS-xammac_net_4_5_Mono.CSharp_test.dll.ignore deleted file mode 100644 index eb9bb96dc83c..000000000000 --- a/tests/bcl-test/BCLTests/macOS-xammac_net_4_5_Mono.CSharp_test.dll.ignore +++ /dev/null @@ -1,2 +0,0 @@ -# Internal compiler error: Internal compiler error: Internal compiler error: Internal compiler error: The predefined type `Microsoft.CSharp.RuntimeBinder.Binder' is not defined or imported -MonoTests.EvaluatorTest.ExpressionsTest.DynamicStatement \ No newline at end of file diff --git a/tests/bcl-test/BCLTests/macOSFull-xammac_net_4_5_System.Data_test.dll.ignore b/tests/bcl-test/BCLTests/macOSFull-xammac_net_4_5_System.Data_test.dll.ignore deleted file mode 100644 index 755c2ea783b5..000000000000 --- a/tests/bcl-test/BCLTests/macOSFull-xammac_net_4_5_System.Data_test.dll.ignore +++ /dev/null @@ -1,12 +0,0 @@ -# System.NullReferenceException : Object reference not set to an instance of an object -MonoTests.System.Data.Common.DbProviderFactoriesConfigurationHandlerTest.PopulateTest - -# #A1 -$ Expected: not null -# But was: null -MonoTests.System.Data.Common.DbProviderFactoriesConfigurationHandlerTest.GetConfigTest - -# getconfig returns null -# Expected: not null -# But was: null -MonoTests.System.Configuration.ConnectionStringsSectionTest.GetConfigTest \ No newline at end of file From 99b41bb828c842a038b67aacec46cf1759c43e6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Thu, 28 Mar 2019 15:14:32 +0100 Subject: [PATCH 50/96] Bump mono --- external/mono | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/mono b/external/mono index bff188abc469..5c781f2eab75 160000 --- a/external/mono +++ b/external/mono @@ -1 +1 @@ -Subproject commit bff188abc469852c82b6e4e02c184373b8ff1a31 +Subproject commit 5c781f2eab75df1f7fbfd4ea7e631e0a66136606 From f9218d17b3db88640e18d035659a9c36f61e1482 Mon Sep 17 00:00:00 2001 From: Sebastien Pouliot Date: Thu, 28 Mar 2019 14:43:38 -0500 Subject: [PATCH 51/96] [generator] Preserve the `Handler` fields inside generated trampolines code This is caused by a new optimization by the linker which makes it possible to remove some `.cctor` if it's fields are not preserved. In earlier versions the linker would actually mark the fields because of the `.cctor` (whenever a type is used). While this is the correct fix we'll also need (in progress) to allow disabling this optimization for existing _linker safe_ code (in part because other, similar pattern might exists in 3rd party code). Fix failures such as ``` [FAIL] RegistrarTest.BlockReturnTest : ObjCRuntime.RuntimeException : Invalid DelegateProxyAttribute for the return value for the method MonoTouchFixtures.ObjCRuntime.RegistrarTest+BlockReturnTestClass.MethodReturningBlock: DelegateType (ObjCRuntime.Trampolines+SDRegistrarTestBlock) specifies a type without a 'Handler' field. Please file a bug at https://github.com/xamarin/xamarin-macios/issues/new. ``` --- src/generator.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/generator.cs b/src/generator.cs index 53c97ab7149f..926096c95b40 100644 --- a/src/generator.cs +++ b/src/generator.cs @@ -2562,6 +2562,7 @@ void GenerateTrampolinesForQueue (TrampolineInfo [] queue) print (""); print ("//\n// This class bridges native block invocations that call into C#\n//"); print ("static internal class {0} {{", ti.StaticName); indent++; + print ("[Preserve (Conditional=true)]"); print ("static internal readonly {0} Handler = {1};", ti.DelegateName, ti.TrampolineName); print (""); print ("[MonoPInvokeCallback (typeof ({0}))]", ti.DelegateName); From baaac9c594e544655d40c21eb6eb335dadb08dab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Fri, 29 Mar 2019 22:14:14 +0100 Subject: [PATCH 52/96] Bump mono --- external/mono | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/mono b/external/mono index 5c781f2eab75..4e3ef48ff033 160000 --- a/external/mono +++ b/external/mono @@ -1 +1 @@ -Subproject commit 5c781f2eab75df1f7fbfd4ea7e631e0a66136606 +Subproject commit 4e3ef48ff03349c46551fb0ad43016a92296cf99 From 6197899ebd51dfc64574074850d6c343fc6a7232 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Sat, 30 Mar 2019 00:28:34 +0100 Subject: [PATCH 53/96] Move HTTP types from System.Net.Http.dll to Xamarin.*.dll --- src/Foundation/NSUrlSessionHandler.cs | 1079 +++++++++++++++++++++++ src/Makefile | 42 +- src/ObjCRuntime/RuntimeOptions.cs | 28 +- src/System.Net.Http/CFContentStream.cs | 156 ++++ src/System.Net.Http/CFNetworkHandler.cs | 389 ++++++++ 5 files changed, 1667 insertions(+), 27 deletions(-) create mode 100644 src/Foundation/NSUrlSessionHandler.cs create mode 100644 src/System.Net.Http/CFContentStream.cs create mode 100644 src/System.Net.Http/CFNetworkHandler.cs diff --git a/src/Foundation/NSUrlSessionHandler.cs b/src/Foundation/NSUrlSessionHandler.cs new file mode 100644 index 000000000000..a445435dc781 --- /dev/null +++ b/src/Foundation/NSUrlSessionHandler.cs @@ -0,0 +1,1079 @@ +// +// NSUrlSessionHandler.cs: +// +// Authors: +// Paul Betts +// Nick Berardi +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using System; +using System.Collections.Generic; +using System.Globalization; +using System.IO; +using System.Linq; +using System.Net; +using System.Net.Http; +using System.Net.Http.Headers; +using System.Runtime.InteropServices; +using System.Threading; +using System.Threading.Tasks; +using System.Text; + +#if XAMCORE_2_0 || SYSTEM_NET_HTTP +using CoreFoundation; +using Foundation; +using Security; +#else +using MonoTouch.CoreFoundation; +using MonoTouch.Foundation; +using MonoTouch.Security; +using System.Globalization; +using nint = System.Int32; +using nuint = System.UInt32; +#endif + +#if !MONOMAC +using UIKit; +#endif + +#if SYSTEM_NET_HTTP +namespace System.Net.Http { +#else +namespace Foundation { +#endif + + // useful extensions for the class in order to set it in a header + static class NSHttpCookieExtensions + { + static void AppendSegment(StringBuilder builder, string name, string value) + { + if (builder.Length > 0) + builder.Append ("; "); + + builder.Append (name); + if (value != null) + builder.Append ("=").Append (value); + } + + // returns the header for a cookie + public static string GetHeaderValue (this NSHttpCookie cookie) + { + var header = new StringBuilder(); + AppendSegment (header, cookie.Name, cookie.Value); + AppendSegment (header, NSHttpCookie.KeyPath.ToString (), cookie.Path.ToString ()); + AppendSegment (header, NSHttpCookie.KeyDomain.ToString (), cookie.Domain.ToString ()); + AppendSegment (header, NSHttpCookie.KeyVersion.ToString (), cookie.Version.ToString ()); + + if (cookie.Comment != null) + AppendSegment (header, NSHttpCookie.KeyComment.ToString (), cookie.Comment.ToString()); + + if (cookie.CommentUrl != null) + AppendSegment (header, NSHttpCookie.KeyCommentUrl.ToString (), cookie.CommentUrl.ToString()); + + if (cookie.Properties.ContainsKey (NSHttpCookie.KeyDiscard)) + AppendSegment (header, NSHttpCookie.KeyDiscard.ToString (), null); + + if (cookie.ExpiresDate != null) { + // Format according to RFC1123; 'r' uses invariant info (DateTimeFormatInfo.InvariantInfo) + var dateStr = ((DateTime) cookie.ExpiresDate).ToUniversalTime ().ToString("r", CultureInfo.InvariantCulture); + AppendSegment (header, NSHttpCookie.KeyExpires.ToString (), dateStr); + } + + if (cookie.Properties.ContainsKey (NSHttpCookie.KeyMaximumAge)) { + var timeStampString = (NSString) cookie.Properties[NSHttpCookie.KeyMaximumAge]; + AppendSegment (header, NSHttpCookie.KeyMaximumAge.ToString (), timeStampString); + } + + if (cookie.IsSecure) + AppendSegment (header, NSHttpCookie.KeySecure.ToString(), null); + + if (cookie.IsHttpOnly) + AppendSegment (header, "httponly", null); // Apple does not show the key for the httponly + + return header.ToString (); + } + } + + public partial class NSUrlSessionHandler : HttpMessageHandler + { + private const string SetCookie = "Set-Cookie"; + readonly Dictionary headerSeparators = new Dictionary { + ["User-Agent"] = " ", + ["Server"] = " " + }; + + readonly NSUrlSession session; + readonly Dictionary inflightRequests; + readonly object inflightRequestsLock = new object (); +#if !MONOMAC && !__WATCHOS__ + readonly bool isBackgroundSession = false; + NSObject notificationToken; // needed to make sure we do not hang if not using a background session +#endif + + static NSUrlSessionConfiguration CreateConfig () + { + // modifying the configuration does not affect future calls + var config = NSUrlSessionConfiguration.DefaultSessionConfiguration; + // but we want, by default, the timeout from HttpClient to have precedence over the one from NSUrlSession + // Double.MaxValue does not work, so default to 24 hours + config.TimeoutIntervalForRequest = 24 * 60 * 60; + config.TimeoutIntervalForResource = 24 * 60 * 60; + return config; + } + + public NSUrlSessionHandler () : this (CreateConfig ()) + { + } + + [CLSCompliant (false)] + public NSUrlSessionHandler (NSUrlSessionConfiguration configuration) + { + if (configuration == null) + throw new ArgumentNullException (nameof (configuration)); + +#if !MONOMAC && !__WATCHOS__ + // if the configuration has an identifier, we are dealing with a background session, + // therefore, we do not have to listen to the notifications. + isBackgroundSession = !string.IsNullOrEmpty (configuration.Identifier); +#endif + + AllowAutoRedirect = true; + + // we cannot do a bitmask but we can set the minimum based on ServicePointManager.SecurityProtocol minimum + var sp = ServicePointManager.SecurityProtocol; + if ((sp & SecurityProtocolType.Ssl3) != 0) + configuration.TLSMinimumSupportedProtocol = SslProtocol.Ssl_3_0; + else if ((sp & SecurityProtocolType.Tls) != 0) + configuration.TLSMinimumSupportedProtocol = SslProtocol.Tls_1_0; + else if ((sp & SecurityProtocolType.Tls11) != 0) + configuration.TLSMinimumSupportedProtocol = SslProtocol.Tls_1_1; + else if ((sp & SecurityProtocolType.Tls12) != 0) + configuration.TLSMinimumSupportedProtocol = SslProtocol.Tls_1_2; + + session = NSUrlSession.FromConfiguration (configuration, (INSUrlSessionDelegate) new NSUrlSessionHandlerDelegate (this), null); + inflightRequests = new Dictionary (); + } + +#if !MONOMAC && !__WATCHOS__ + + void AddNotification () + { + if (!isBackgroundSession && notificationToken == null) + notificationToken = NSNotificationCenter.DefaultCenter.AddObserver (UIApplication.WillResignActiveNotification, BackgroundNotificationCb); + } + + void RemoveNotification () + { + if (notificationToken != null) { + NSNotificationCenter.DefaultCenter.RemoveObserver (notificationToken); + notificationToken = null; + } + } + + void BackgroundNotificationCb (NSNotification obj) + { + // we do not need to call the lock, we call cancel on the source, that will trigger all the needed code to + // clean the resources and such + foreach (var r in inflightRequests.Values) { + r.CompletionSource.TrySetCanceled (); + } + } +#endif + + public long MaxInputInMemory { get; set; } = long.MaxValue; + + void RemoveInflightData (NSUrlSessionTask task, bool cancel = true) + { + lock (inflightRequestsLock) { + if (inflightRequests.TryGetValue (task, out var data)) { + if (cancel) + data.CancellationTokenSource.Cancel (); + data.Dispose (); + inflightRequests.Remove (task); + } +#if !MONOMAC && !__WATCHOS__ + // do we need to be notified? If we have not inflightData, we do not + if (inflightRequests.Count == 0) + RemoveNotification (); +#endif + } + + if (cancel) + task?.Cancel (); + + task?.Dispose (); + } + + protected override void Dispose (bool disposing) + { +#if !MONOMAC && !__WATCHOS__ + // remove the notification if present, method checks against null + RemoveNotification (); +#endif + lock (inflightRequestsLock) { + foreach (var pair in inflightRequests) { + pair.Key?.Cancel (); + pair.Key?.Dispose (); + pair.Value?.Dispose (); + } + + inflightRequests.Clear (); + } + base.Dispose (disposing); + } + + bool disableCaching; + + public bool DisableCaching { + get { + return disableCaching; + } + set { + EnsureModifiability (); + disableCaching = value; + } + } + + bool allowAutoRedirect; + + public bool AllowAutoRedirect { + get { + return allowAutoRedirect; + } + set { + EnsureModifiability (); + allowAutoRedirect = value; + } + } + + ICredentials credentials; + + public ICredentials Credentials { + get { + return credentials; + } + set { + EnsureModifiability (); + credentials = value; + } + } + + bool sentRequest; + + internal void EnsureModifiability () + { + if (sentRequest) + throw new InvalidOperationException ( + "This instance has already started one or more requests. " + + "Properties can only be modified before sending the first request."); + } + + // almost identical to ModernHttpClient version but it uses the constants from monotouch.dll | Xamarin.[iOS|WatchOS|TVOS].dll + static Exception createExceptionForNSError(NSError error) + { + // var webExceptionStatus = WebExceptionStatus.UnknownError; + + var innerException = new NSErrorException(error); + + // errors that exists in both share the same error code, so we can use a single switch/case + // this also ease watchOS integration as if does not expose CFNetwork but (I would not be + // surprised if it)could return some of it's error codes +#if __WATCHOS__ + if (error.Domain == NSError.NSUrlErrorDomain) { +#else + if ((error.Domain == NSError.NSUrlErrorDomain) || (error.Domain == NSError.CFNetworkErrorDomain)) { +#endif + // Parse the enum into a web exception status or exception. Some + // of these values don't necessarily translate completely to + // what WebExceptionStatus supports, so made some best guesses + // here. For your reading pleasure, compare these: + // + // Apple docs: https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Miscellaneous/Foundation_Constants/index.html#//apple_ref/doc/constant_group/URL_Loading_System_Error_Codes + // .NET docs: http://msdn.microsoft.com/en-us/library/system.net.webexceptionstatus(v=vs.110).aspx + switch ((NSUrlError) (long) error.Code) { + case NSUrlError.Cancelled: + case NSUrlError.UserCancelledAuthentication: +#if !__WATCHOS__ + case (NSUrlError) NSNetServicesStatus.CancelledError: +#endif + // No more processing is required so just return. + return new OperationCanceledException(error.LocalizedDescription, innerException); +// case NSUrlError.BadURL: +// case NSUrlError.UnsupportedURL: +// case NSUrlError.CannotConnectToHost: +// case NSUrlError.ResourceUnavailable: +// case NSUrlError.NotConnectedToInternet: +// case NSUrlError.UserAuthenticationRequired: +// case NSUrlError.InternationalRoamingOff: +// case NSUrlError.CallIsActive: +// case NSUrlError.DataNotAllowed: +// #if !__WATCHOS__ +// case (NSUrlError) CFNetworkErrors.Socks5BadCredentials: +// case (NSUrlError) CFNetworkErrors.Socks5UnsupportedNegotiationMethod: +// case (NSUrlError) CFNetworkErrors.Socks5NoAcceptableMethod: +// case (NSUrlError) CFNetworkErrors.HttpAuthenticationTypeUnsupported: +// case (NSUrlError) CFNetworkErrors.HttpBadCredentials: +// case (NSUrlError) CFNetworkErrors.HttpBadURL: +// #endif +// webExceptionStatus = WebExceptionStatus.ConnectFailure; +// break; +// case NSUrlError.TimedOut: +// #if !__WATCHOS__ +// case (NSUrlError) CFNetworkErrors.NetServiceTimeout: +// #endif +// webExceptionStatus = WebExceptionStatus.Timeout; +// break; +// case NSUrlError.CannotFindHost: +// case NSUrlError.DNSLookupFailed: +// #if !__WATCHOS__ +// case (NSUrlError) CFNetworkErrors.HostNotFound: +// case (NSUrlError) CFNetworkErrors.NetServiceDnsServiceFailure: +// #endif +// webExceptionStatus = WebExceptionStatus.NameResolutionFailure; +// break; +// case NSUrlError.DataLengthExceedsMaximum: +// webExceptionStatus = WebExceptionStatus.MessageLengthLimitExceeded; +// break; +// case NSUrlError.NetworkConnectionLost: +// #if !__WATCHOS__ +// case (NSUrlError) CFNetworkErrors.HttpConnectionLost: +// #endif +// webExceptionStatus = WebExceptionStatus.ConnectionClosed; +// break; +// case NSUrlError.HTTPTooManyRedirects: +// case NSUrlError.RedirectToNonExistentLocation: +// #if !__WATCHOS__ +// case (NSUrlError) CFNetworkErrors.HttpRedirectionLoopDetected: +// #endif +// webExceptionStatus = WebExceptionStatus.ProtocolError; +// break; +// case NSUrlError.RequestBodyStreamExhausted: +// #if !__WATCHOS__ +// case (NSUrlError) CFNetworkErrors.SocksUnknownClientVersion: +// case (NSUrlError) CFNetworkErrors.SocksUnsupportedServerVersion: +// case (NSUrlError) CFNetworkErrors.HttpParseFailure: +// #endif +// webExceptionStatus = WebExceptionStatus.SendFailure; +// break; +// case NSUrlError.BadServerResponse: +// case NSUrlError.ZeroByteResource: +// case NSUrlError.CannotDecodeRawData: +// case NSUrlError.CannotDecodeContentData: +// case NSUrlError.CannotParseResponse: +// case NSUrlError.FileDoesNotExist: +// case NSUrlError.FileIsDirectory: +// case NSUrlError.NoPermissionsToReadFile: +// case NSUrlError.CannotLoadFromNetwork: +// case NSUrlError.CannotCreateFile: +// case NSUrlError.CannotOpenFile: +// case NSUrlError.CannotCloseFile: +// case NSUrlError.CannotWriteToFile: +// case NSUrlError.CannotRemoveFile: +// case NSUrlError.CannotMoveFile: +// case NSUrlError.DownloadDecodingFailedMidStream: +// case NSUrlError.DownloadDecodingFailedToComplete: +// #if !__WATCHOS__ +// case (NSUrlError) CFNetworkErrors.Socks4RequestFailed: +// case (NSUrlError) CFNetworkErrors.Socks4IdentdFailed: +// case (NSUrlError) CFNetworkErrors.Socks4IdConflict: +// case (NSUrlError) CFNetworkErrors.Socks4UnknownStatusCode: +// case (NSUrlError) CFNetworkErrors.Socks5BadState: +// case (NSUrlError) CFNetworkErrors.Socks5BadResponseAddr: +// case (NSUrlError) CFNetworkErrors.CannotParseCookieFile: +// case (NSUrlError) CFNetworkErrors.NetServiceUnknown: +// case (NSUrlError) CFNetworkErrors.NetServiceCollision: +// case (NSUrlError) CFNetworkErrors.NetServiceNotFound: +// case (NSUrlError) CFNetworkErrors.NetServiceInProgress: +// case (NSUrlError) CFNetworkErrors.NetServiceBadArgument: +// case (NSUrlError) CFNetworkErrors.NetServiceInvalid: +// #endif +// webExceptionStatus = WebExceptionStatus.ReceiveFailure; +// break; +// case NSUrlError.SecureConnectionFailed: +// webExceptionStatus = WebExceptionStatus.SecureChannelFailure; +// break; +// case NSUrlError.ServerCertificateHasBadDate: +// case NSUrlError.ServerCertificateHasUnknownRoot: +// case NSUrlError.ServerCertificateNotYetValid: +// case NSUrlError.ServerCertificateUntrusted: +// case NSUrlError.ClientCertificateRejected: +// case NSUrlError.ClientCertificateRequired: +// webExceptionStatus = WebExceptionStatus.TrustFailure; +// break; +// #if !__WATCHOS__ +// case (NSUrlError) CFNetworkErrors.HttpProxyConnectionFailure: +// case (NSUrlError) CFNetworkErrors.HttpBadProxyCredentials: +// case (NSUrlError) CFNetworkErrors.PacFileError: +// case (NSUrlError) CFNetworkErrors.PacFileAuth: +// case (NSUrlError) CFNetworkErrors.HttpsProxyConnectionFailure: +// case (NSUrlError) CFNetworkErrors.HttpsProxyFailureUnexpectedResponseToConnectMethod: +// webExceptionStatus = WebExceptionStatus.RequestProhibitedByProxy; +// break; +// #endif + } + } + + // Always create a WebException so that it can be handled by the client. + return new WebException(error.LocalizedDescription, innerException); //, webExceptionStatus, response: null); + } + + string GetHeaderSeparator (string name) + { + string value; + if (!headerSeparators.TryGetValue (name, out value)) + value = ","; + return value; + } + + async Task CreateRequest (HttpRequestMessage request) + { + var stream = Stream.Null; + var headers = request.Headers as IEnumerable>>; + + if (request.Content != null) { + stream = await request.Content.ReadAsStreamAsync ().ConfigureAwait (false); + headers = System.Linq.Enumerable.ToArray(headers.Union (request.Content.Headers)); + } + + var nsrequest = new NSMutableUrlRequest { + AllowsCellularAccess = true, + CachePolicy = DisableCaching ? NSUrlRequestCachePolicy.ReloadIgnoringCacheData : NSUrlRequestCachePolicy.UseProtocolCachePolicy, + HttpMethod = request.Method.ToString ().ToUpperInvariant (), + Url = NSUrl.FromString (request.RequestUri.AbsoluteUri), + Headers = headers.Aggregate (new NSMutableDictionary (), (acc, x) => { + acc.Add (new NSString (x.Key), new NSString (string.Join (GetHeaderSeparator (x.Key), x.Value))); + return acc; + }) + }; + if (stream != Stream.Null) { + // HttpContent.TryComputeLength is `protected internal` :-( but it's indirectly called by headers + var length = request.Content.Headers.ContentLength; + if (length.HasValue && (length <= MaxInputInMemory)) + nsrequest.Body = NSData.FromStream (stream); + else + nsrequest.BodyStream = new WrappedNSInputStream (stream); + } + return nsrequest; + } + +#if SYSTEM_NET_HTTP || MONOMAC + internal +#endif + protected override async Task SendAsync (HttpRequestMessage request, CancellationToken cancellationToken) + { + Volatile.Write (ref sentRequest, true); + + var nsrequest = await CreateRequest (request).ConfigureAwait(false); + var dataTask = session.CreateDataTask (nsrequest); + + var tcs = new TaskCompletionSource (); + + lock (inflightRequestsLock) { +#if !MONOMAC && !__WATCHOS__ + // Add the notification whenever needed + AddNotification (); +#endif + inflightRequests.Add (dataTask, new InflightData { + RequestUrl = request.RequestUri.AbsoluteUri, + CompletionSource = tcs, + CancellationToken = cancellationToken, + CancellationTokenSource = new CancellationTokenSource (), + Stream = new NSUrlSessionDataTaskStream (), + Request = request + }); + } + + if (dataTask.State == NSUrlSessionTaskState.Suspended) + dataTask.Resume (); + + // as per documentation: + // If this token is already in the canceled state, the + // delegate will be run immediately and synchronously. + // Any exception the delegate generates will be + // propagated out of this method call. + // + // The execution of the register ensures that if we + // receive a already cancelled token or it is cancelled + // just before this call, we will cancel the task. + // Other approaches are harder, since querying the state + // of the token does not guarantee that in the next + // execution a threads cancels it. + cancellationToken.Register (() => { + RemoveInflightData (dataTask); + tcs.TrySetCanceled (); + }); + + return await tcs.Task.ConfigureAwait (false); + } + +#if MONOMAC + // Needed since we strip during linking since we're inside a product assembly. + [Preserve (AllMembers = true)] +#endif + partial class NSUrlSessionHandlerDelegate : NSUrlSessionDataDelegate + { + readonly NSUrlSessionHandler sessionHandler; + + public NSUrlSessionHandlerDelegate (NSUrlSessionHandler handler) + { + sessionHandler = handler; + } + + InflightData GetInflightData (NSUrlSessionTask task) + { + var inflight = default (InflightData); + + lock (sessionHandler.inflightRequestsLock) + if (sessionHandler.inflightRequests.TryGetValue (task, out inflight)) { + // ensure that we did not cancel the request, if we did, do cancel the task + if (inflight.CancellationToken.IsCancellationRequested) + task?.Cancel (); + return inflight; + } + + // if we did not manage to get the inflight data, we either got an error or have been canceled, lets cancel the task, that will execute DidCompleteWithError + task?.Cancel (); + return null; + } + + public override void DidReceiveResponse (NSUrlSession session, NSUrlSessionDataTask dataTask, NSUrlResponse response, Action completionHandler) + { + var inflight = GetInflightData (dataTask); + + if (inflight == null) + return; + + try { + var urlResponse = (NSHttpUrlResponse)response; + var status = (int)urlResponse.StatusCode; + + var content = new NSUrlSessionDataTaskStreamContent (inflight.Stream, () => { + if (!inflight.Completed) { + dataTask.Cancel (); + } + + inflight.Disposed = true; + inflight.Stream.TrySetException (new ObjectDisposedException ("The content stream was disposed.")); + + sessionHandler.RemoveInflightData (dataTask); + }, inflight.CancellationTokenSource.Token); + + // NB: The double cast is because of a Xamarin compiler bug + var httpResponse = new HttpResponseMessage ((HttpStatusCode)status) { + Content = content, + RequestMessage = inflight.Request + }; + httpResponse.RequestMessage.RequestUri = new Uri (urlResponse.Url.AbsoluteString); + + foreach (var v in urlResponse.AllHeaderFields) { + // NB: Cocoa trolling us so hard by giving us back dummy dictionary entries + if (v.Key == null || v.Value == null) continue; + // NSUrlSession tries to be smart with cookies, we will not use the raw value but the ones provided by the cookie storage + if (v.Key.ToString () == SetCookie) continue; + + httpResponse.Headers.TryAddWithoutValidation (v.Key.ToString (), v.Value.ToString ()); + httpResponse.Content.Headers.TryAddWithoutValidation (v.Key.ToString (), v.Value.ToString ()); + } + + var cookies = session.Configuration.HttpCookieStorage.CookiesForUrl (response.Url); + for (var index = 0; index < cookies.Length; index++) { + httpResponse.Headers.TryAddWithoutValidation (SetCookie, cookies [index].GetHeaderValue ()); + } + + inflight.Response = httpResponse; + + // We don't want to send the response back to the task just yet. Because we want to mimic .NET behavior + // as much as possible. When the response is sent back in .NET, the content stream is ready to read or the + // request has completed, because of this we want to send back the response in DidReceiveData or DidCompleteWithError + if (dataTask.State == NSUrlSessionTaskState.Suspended) + dataTask.Resume (); + + } catch (Exception ex) { + inflight.CompletionSource.TrySetException (ex); + inflight.Stream.TrySetException (ex); + + sessionHandler.RemoveInflightData (dataTask); + } + + completionHandler (NSUrlSessionResponseDisposition.Allow); + } + + public override void DidReceiveData (NSUrlSession session, NSUrlSessionDataTask dataTask, NSData data) + { + var inflight = GetInflightData (dataTask); + + if (inflight == null) + return; + + inflight.Stream.Add (data); + SetResponse (inflight); + } + + public override void DidCompleteWithError (NSUrlSession session, NSUrlSessionTask task, NSError error) + { + var inflight = GetInflightData (task); + + // this can happen if the HTTP request times out and it is removed as part of the cancellation process + if (inflight != null) { + // set the stream as finished + inflight.Stream.TrySetReceivedAllData (); + + // send the error or send the response back + if (error != null) { + // got an error, cancel the stream operatios before we do anything + inflight.CancellationTokenSource.Cancel (); + inflight.Errored = true; + + var exc = createExceptionForNSError (error); + inflight.CompletionSource.TrySetException (exc); + inflight.Stream.TrySetException (exc); + } else { + inflight.Completed = true; + SetResponse (inflight); + } + + sessionHandler.RemoveInflightData (task, cancel: false); + } + } + + void SetResponse (InflightData inflight) + { + lock (inflight.Lock) { + if (inflight.ResponseSent) + return; + + if (inflight.CancellationTokenSource.Token.IsCancellationRequested) + return; + + if (inflight.CompletionSource.Task.IsCompleted) + return; + + var httpResponse = inflight.Response; + + inflight.ResponseSent = true; + + // EVIL HACK: having TrySetResult inline was blocking the request from completing + Task.Run (() => inflight.CompletionSource.TrySetResult (httpResponse)); + } + } + + public override void WillCacheResponse (NSUrlSession session, NSUrlSessionDataTask dataTask, NSCachedUrlResponse proposedResponse, Action completionHandler) + { + completionHandler (sessionHandler.DisableCaching ? null : proposedResponse); + } + + public override void WillPerformHttpRedirection (NSUrlSession session, NSUrlSessionTask task, NSHttpUrlResponse response, NSUrlRequest newRequest, Action completionHandler) + { + completionHandler (sessionHandler.AllowAutoRedirect ? newRequest : null); + } + + public override void DidReceiveChallenge (NSUrlSession session, NSUrlSessionTask task, NSUrlAuthenticationChallenge challenge, Action completionHandler) + { + var inflight = GetInflightData (task); + + if (inflight == null) + return; + + // case for the basic auth failing up front. As per apple documentation: + // The URL Loading System is designed to handle various aspects of the HTTP protocol for you. As a result, you should not modify the following headers using + // the addValue(_:forHTTPHeaderField:) or setValue(_:forHTTPHeaderField:) methods: + // Authorization + // Connection + // Host + // Proxy-Authenticate + // Proxy-Authorization + // WWW-Authenticate + // but we are hiding such a situation from our users, we can nevertheless know if the header was added and deal with it. The idea is as follows, + // check if we are in the first attempt, if we are (PreviousFailureCount == 0), we check the headers of the request and if we do have the Auth + // header, it means that we do not have the correct credentials, in any other case just do what it is expected. + + if (challenge.PreviousFailureCount == 0) { + var authHeader = inflight.Request?.Headers?.Authorization; + if (!(string.IsNullOrEmpty (authHeader?.Scheme) && string.IsNullOrEmpty (authHeader?.Parameter))) { + completionHandler (NSUrlSessionAuthChallengeDisposition.RejectProtectionSpace, null); + return; + } + } + + if (sessionHandler.Credentials != null && TryGetAuthenticationType (challenge.ProtectionSpace, out string authType)) { + NetworkCredential credentialsToUse = null; + if (authType != RejectProtectionSpaceAuthType) { + var uri = inflight.Request.RequestUri; + credentialsToUse = sessionHandler.Credentials.GetCredential (uri, authType); + } + + if (credentialsToUse != null) { + var credential = new NSUrlCredential (credentialsToUse.UserName, credentialsToUse.Password, NSUrlCredentialPersistence.ForSession); + completionHandler (NSUrlSessionAuthChallengeDisposition.UseCredential, credential); + } else { + // Rejecting the challenge allows the next authentication method in the request to be delivered to + // the DidReceiveChallenge method. Another authentication method may have credentials available. + completionHandler (NSUrlSessionAuthChallengeDisposition.RejectProtectionSpace, null); + } + } else { + completionHandler (NSUrlSessionAuthChallengeDisposition.PerformDefaultHandling, challenge.ProposedCredential); + } + } + + static readonly string RejectProtectionSpaceAuthType = "reject"; + + static bool TryGetAuthenticationType (NSUrlProtectionSpace protectionSpace, out string authenticationType) + { + if (protectionSpace.AuthenticationMethod == NSUrlProtectionSpace.AuthenticationMethodNTLM) { + authenticationType = "NTLM"; + } else if (protectionSpace.AuthenticationMethod == NSUrlProtectionSpace.AuthenticationMethodHTTPBasic) { + authenticationType = "basic"; + } else if (protectionSpace.AuthenticationMethod == NSUrlProtectionSpace.AuthenticationMethodNegotiate || + protectionSpace.AuthenticationMethod == NSUrlProtectionSpace.AuthenticationMethodHTMLForm || + protectionSpace.AuthenticationMethod == NSUrlProtectionSpace.AuthenticationMethodHTTPDigest) { + // Want to reject this authentication type to allow the next authentication method in the request to + // be used. + authenticationType = RejectProtectionSpaceAuthType; + } else { + // ServerTrust, ClientCertificate or Default. + authenticationType = null; + return false; + } + return true; + } + } + +#if MONOMAC + // Needed since we strip during linking since we're inside a product assembly. + [Preserve (AllMembers = true)] +#endif + class InflightData : IDisposable + { + public readonly object Lock = new object (); + public string RequestUrl { get; set; } + + public TaskCompletionSource CompletionSource { get; set; } + public CancellationToken CancellationToken { get; set; } + public CancellationTokenSource CancellationTokenSource { get; set; } + public NSUrlSessionDataTaskStream Stream { get; set; } + public HttpRequestMessage Request { get; set; } + public HttpResponseMessage Response { get; set; } + + public bool ResponseSent { get; set; } + public bool Errored { get; set; } + public bool Disposed { get; set; } + public bool Completed { get; set; } + public bool Done { get { return Errored || Disposed || Completed || CancellationToken.IsCancellationRequested; } } + + public void Dispose() + { + Dispose (true); + GC.SuppressFinalize(this); + } + + // The bulk of the clean-up code is implemented in Dispose(bool) + protected virtual void Dispose (bool disposing) + { + if (disposing) { + if (CancellationTokenSource != null) { + CancellationTokenSource.Dispose (); + CancellationTokenSource = null; + } + } + } + + } + +#if MONOMAC + // Needed since we strip during linking since we're inside a product assembly. + [Preserve (AllMembers = true)] +#endif + class NSUrlSessionDataTaskStreamContent : StreamContent + { + Action disposed; + + public NSUrlSessionDataTaskStreamContent (NSUrlSessionDataTaskStream source, Action onDisposed, CancellationToken token) : base (source, token) + { + disposed = onDisposed; + } + + protected override void Dispose (bool disposing) + { + var action = Interlocked.Exchange (ref disposed, null); + action?.Invoke (); + + base.Dispose (disposing); + } + } + +#if MONOMAC + // Needed since we strip during linking since we're inside a product assembly. + [Preserve (AllMembers = true)] +#endif + class NSUrlSessionDataTaskStream : Stream + { + readonly Queue data; + readonly object dataLock = new object (); + + long position; + long length; + + bool receivedAllData; + Exception exc; + + NSData current; + Stream currentStream; + + public NSUrlSessionDataTaskStream () + { + data = new Queue (); + } + + public void Add (NSData d) + { + lock (dataLock) { + data.Enqueue (d); + length += (int)d.Length; + } + } + + public void TrySetReceivedAllData () + { + receivedAllData = true; + } + + public void TrySetException (Exception e) + { + exc = e; + TrySetReceivedAllData (); + } + + void ThrowIfNeeded (CancellationToken cancellationToken) + { + if (exc != null) + throw exc; + + cancellationToken.ThrowIfCancellationRequested (); + } + + public override int Read (byte [] buffer, int offset, int count) + { + return ReadAsync (buffer, offset, count).Result; + } + + public override async Task ReadAsync (byte [] buffer, int offset, int count, CancellationToken cancellationToken) + { + // try to throw on enter + ThrowIfNeeded (cancellationToken); + + while (current == null) { + lock (dataLock) { + if (data.Count == 0 && receivedAllData && position == length) + return 0; + + if (data.Count > 0 && current == null) { + current = data.Peek (); + currentStream = current.AsStream (); + break; + } + } + + try { + await Task.Delay (50, cancellationToken).ConfigureAwait (false); + } catch (TaskCanceledException ex) { + // add a nicer exception for the user to catch, add the cancelation exception + // to have a decent stack + throw new TimeoutException ("The request timed out.", ex); + } + } + + // try to throw again before read + ThrowIfNeeded (cancellationToken); + + var d = currentStream; + var bufferCount = Math.Min (count, (int)(d.Length - d.Position)); + var bytesRead = await d.ReadAsync (buffer, offset, bufferCount, cancellationToken).ConfigureAwait (false); + + // add the bytes read from the pointer to the position + position += bytesRead; + + // remove the current primary reference if the current position has reached the end of the bytes + if (d.Position == d.Length) { + lock (dataLock) { + // this is the same object, it was done to make the cleanup + data.Dequeue (); + currentStream?.Dispose (); + // We cannot use current?.Dispose. The reason is the following one: + // In the DidReceiveResponse, if iOS realizes that a buffer can be reused, + // because the data is the same, it will do so. Such a situation does happen + // between requests, that is, request A and request B will get the same NSData + // (buffer) in the delegate. In this case, we cannot dispose the NSData because + // it might be that a different request received it and it is present in + // its NSUrlSessionDataTaskStream stream. We can only trust the gc to do the job + // which is better than copying the data over. + current = null; + currentStream = null; + } + } + + return bytesRead; + } + + public override bool CanRead => true; + + public override bool CanSeek => false; + + public override bool CanWrite => false; + + public override bool CanTimeout => false; + + public override long Length => length; + + public override void SetLength (long value) + { + throw new InvalidOperationException (); + } + + public override long Position { + get { return position; } + set { throw new InvalidOperationException (); } + } + + public override long Seek (long offset, SeekOrigin origin) + { + throw new InvalidOperationException (); + } + + public override void Flush () + { + throw new InvalidOperationException (); + } + + public override void Write (byte [] buffer, int offset, int count) + { + throw new InvalidOperationException (); + } + } + +#if MONOMAC + // Needed since we strip during linking since we're inside a product assembly. + [Preserve (AllMembers = true)] +#endif + class WrappedNSInputStream : NSInputStream + { + NSStreamStatus status; + CFRunLoopSource source; + readonly Stream stream; + bool notifying; + + public WrappedNSInputStream (Stream inputStream) + { + status = NSStreamStatus.NotOpen; + stream = inputStream; + source = new CFRunLoopSource (Handle); + } + + public override NSStreamStatus Status => status; + + public override void Open () + { + status = NSStreamStatus.Open; + Notify (CFStreamEventType.OpenCompleted); + } + + public override void Close () + { + status = NSStreamStatus.Closed; + } + + public override nint Read (IntPtr buffer, nuint len) + { + var sourceBytes = new byte [len]; + var read = stream.Read (sourceBytes, 0, (int)len); + Marshal.Copy (sourceBytes, 0, buffer, (int)len); + + if (notifying) + return read; + + notifying = true; + if (stream.CanSeek && stream.Position == stream.Length) { + Notify (CFStreamEventType.EndEncountered); + status = NSStreamStatus.AtEnd; + } + notifying = false; + + return read; + } + + public override bool HasBytesAvailable () + { + return true; + } + + protected override bool GetBuffer (out IntPtr buffer, out nuint len) + { + // Just call the base implemention (which will return false) + return base.GetBuffer (out buffer, out len); + } + + // NSInvalidArgumentException Reason: *** -propertyForKey: only defined for abstract class. Define -[System_Net_Http_NSUrlSessionHandler_WrappedNSInputStream propertyForKey:]! + protected override NSObject GetProperty (NSString key) + { + return null; + } + + protected override bool SetProperty (NSObject property, NSString key) + { + return false; + } + + protected override bool SetCFClientFlags (CFStreamEventType inFlags, IntPtr inCallback, IntPtr inContextPtr) + { + // Just call the base implementation, which knows how to handle everything. + return base.SetCFClientFlags (inFlags, inCallback, inContextPtr); + } + + public override void Schedule (NSRunLoop aRunLoop, string mode) + { + var cfRunLoop = aRunLoop.GetCFRunLoop (); + var nsMode = new NSString (mode); + + cfRunLoop.AddSource (source, nsMode); + + if (notifying) + return; + + notifying = true; + Notify (CFStreamEventType.HasBytesAvailable); + notifying = false; + } + + public override void Unschedule (NSRunLoop aRunLoop, string mode) + { + var cfRunLoop = aRunLoop.GetCFRunLoop (); + var nsMode = new NSString (mode); + + cfRunLoop.RemoveSource (source, nsMode); + } + + protected override void Dispose (bool disposing) + { + stream?.Dispose (); + } + } + } +} diff --git a/src/Makefile b/src/Makefile index 2b0320e14c30..d6474fff857c 100644 --- a/src/Makefile +++ b/src/Makefile @@ -64,12 +64,17 @@ IOS_EXTRA_SOURCES = \ Compat.iOS.cs \ $(SHARED_SYSTEM_DRAWING_SOURCES) \ +IOS_HTTP_SOURCES = \ + Foundation/NSUrlSessionHandler.cs \ + System.Net.Http/CFContentStream.cs \ + System.Net.Http/CFNetworkHandler.cs \ + IOS_CORE_SOURCES += $(IOS_EXTRA_SOURCES) -IOS_SOURCES += $(IOS_EXTRA_SOURCES) +IOS_SOURCES += $(IOS_EXTRA_SOURCES) $(IOS_HTTP_SOURCES) IOS_GENERATOR_FLAGS = -inline-selectors -d:IOS -process-enums -warnaserror:$(IOS_GENERATOR_WARNASERROR) IOS_GENERATOR_native_FLAGS = -d:XAMCORE_2_0 -d:__UNIFIED__ -IOS_DEFINES = -define:IPHONE -define:IOS -define:MONOTOUCH -d:NET_2_0 -d:__IOS__ $(APPLETLS_DEFINES) +IOS_DEFINES = -define:IPHONE -define:IOS -define:MONOTOUCH -d:NET_2_0 -d:__IOS__ $(APPLETLS_DEFINES) -d:SYSTEM_NET_HTTP IOS_native_DEFINES = -d:XAMCORE_2_0 -d:__UNIFIED__ IOS_LIBDIR = $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/mono/2.1 IOS_BMONO = MONO_PATH=$(IOS_LIBDIR) $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/bin/btouch-mono @@ -336,11 +341,10 @@ MAC_CFNETWORK_SOURCES = \ CFNetwork/WebResponseStream.cs \ CFNetwork/WorkerThread.cs -MAC_MODERNHTTP_SOURCES = \ - $(abspath $(MONO_PATH)/mcs/class/System.Net.Http/HttpClientEx.cs) \ - $(abspath $(MONO_PATH)/mcs/class/System.Net.Http/NSUrlSessionHandler.cs) \ - $(abspath $(MONO_PATH)/mcs/class/System.Net.Http/CFContentStream.cs) \ - $(abspath $(MONO_PATH)/mcs/class/System.Net.Http/CFNetworkHandler.cs) \ +MAC_HTTP_SOURCES = \ + Foundation/NSUrlSessionHandler.cs \ + System.Net.Http/CFContentStream.cs \ + System.Net.Http/CFNetworkHandler.cs \ $(MAC_BUILD_DIR)/Constants.cs: Constants.mac.cs.in Makefile $(TOP)/Make.config.inc | $(MAC_BUILD_DIR) $(Q) sed \ @@ -426,10 +430,10 @@ $(MAC_BUILD_DIR)/$(1)/$(2:.dll=.pdb): $(MAC_BUILD_DIR)/$(1)/$(2) endef -$(eval $(call MAC_TARGETS_template,mobile-32,Xamarin.Mac.dll,mobile,$(MAC_CFNETWORK_SOURCES) $(MAC_MODERNHTTP_SOURCES) $(SHARED_SYSTEM_DRAWING_SOURCES) $(APPLETLS_DEFINES) -D:XAMARIN_MODERN -D:UNIFIED -D:__UNIFIED__,mobile-32,32)) -$(eval $(call MAC_TARGETS_template,mobile-64,Xamarin.Mac.dll,mobile,$(MAC_CFNETWORK_SOURCES) $(MAC_MODERNHTTP_SOURCES) $(SHARED_SYSTEM_DRAWING_SOURCES) $(APPLETLS_DEFINES) -D:XAMARIN_MODERN -D:UNIFIED -D:__UNIFIED__,mobile-64,64)) -$(eval $(call MAC_TARGETS_template,full-32,Xamarin.Mac.dll,full,$(MAC_CFNETWORK_SOURCES) $(MAC_MODERNHTTP_SOURCES) -D:XAMARIN_MODERN -D:UNIFIED -D:__UNIFIED__,full-32,32)) -$(eval $(call MAC_TARGETS_template,full-64,Xamarin.Mac.dll,full,$(MAC_CFNETWORK_SOURCES) $(MAC_MODERNHTTP_SOURCES) -D:XAMARIN_MODERN -D:UNIFIED -D:__UNIFIED__,full-64,64)) +$(eval $(call MAC_TARGETS_template,mobile-32,Xamarin.Mac.dll,mobile,$(MAC_CFNETWORK_SOURCES) $(MAC_HTTP_SOURCES) $(SHARED_SYSTEM_DRAWING_SOURCES) $(APPLETLS_DEFINES) -D:XAMARIN_MODERN -D:UNIFIED -D:__UNIFIED__,mobile-32,32)) +$(eval $(call MAC_TARGETS_template,mobile-64,Xamarin.Mac.dll,mobile,$(MAC_CFNETWORK_SOURCES) $(MAC_HTTP_SOURCES) $(SHARED_SYSTEM_DRAWING_SOURCES) $(APPLETLS_DEFINES) -D:XAMARIN_MODERN -D:UNIFIED -D:__UNIFIED__,mobile-64,64)) +$(eval $(call MAC_TARGETS_template,full-32,Xamarin.Mac.dll,full,$(MAC_CFNETWORK_SOURCES) $(MAC_HTTP_SOURCES) -D:XAMARIN_MODERN -D:UNIFIED -D:__UNIFIED__,full-32,32)) +$(eval $(call MAC_TARGETS_template,full-64,Xamarin.Mac.dll,full,$(MAC_CFNETWORK_SOURCES) $(MAC_HTTP_SOURCES) -D:XAMARIN_MODERN -D:UNIFIED -D:__UNIFIED__,full-64,64)) $(MAC_BUILD_DIR)/%-reference/Xamarin.Mac.dll: $(MAC_BUILD_DIR)/%-64/Xamarin.Mac.dll @mkdir -p $(@D) @@ -566,7 +570,7 @@ all-mac: $(MAC_TARGETS) # Xamarin.WatchOS # -WATCH_DEFINES = -define:IPHONE -define:MONOTOUCH -d:NET_2_0 -d:WATCH -d:XAMCORE_2_0 -d:XAMCORE_3_0 -d:__WATCHOS__ -d:__UNIFIED__ +WATCH_DEFINES = -define:IPHONE -define:MONOTOUCH -d:NET_2_0 -d:WATCH -d:XAMCORE_2_0 -d:XAMCORE_3_0 -d:__WATCHOS__ -d:__UNIFIED__ -d:SYSTEM_NET_HTTP WATCH_LIBDIR = $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/mono/Xamarin.WatchOS WATCH_BMONO = MONO_PATH=$(WATCH_LIBDIR)/repl $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/bin/bwatch-mono WATCH_GENERATOR=$(BUILD_DIR)/common/bgen.exe @@ -581,13 +585,17 @@ WATCHOS_EXTRA_CORE_SOURCES = \ AudioToolbox/AudioBuffers.cs \ AudioToolbox/AudioType.cs \ $(SHARED_SYSTEM_DRAWING_SOURCES) \ - System.Drawing/ColorKnownColorTypeForwarders.cs + System.Drawing/ColorKnownColorTypeForwarders.cs \ + +WATCHOS_HTTP_SOURCES = \ + Foundation/NSUrlSessionHandler.cs \ WATCHOS_CORE_SOURCES += \ $(WATCHOS_EXTRA_CORE_SOURCES) \ WATCHOS_SOURCES += \ $(WATCHOS_EXTRA_CORE_SOURCES) \ + $(WATCHOS_HTTP_SOURCES) \ $(WATCH_BUILD_DIR)/Constants.cs: $(TOP)/src/Constants.watch.cs.in Makefile $(TOP)/Make.config.inc | $(WATCH_BUILD_DIR) $(call Q_PROF_GEN,watch) sed \ @@ -733,7 +741,7 @@ endif # Xamarin.TVOS # -TVOS_DEFINES = -define:IPHONE -define:MONOTOUCH -d:NET_2_0 -d:TVOS -d:XAMCORE_2_0 -d:XAMCORE_3_0 -d:__TVOS__ $(APPLETLS_DEFINES) -d:__UNIFIED__ +TVOS_DEFINES = -define:IPHONE -define:MONOTOUCH -d:NET_2_0 -d:TVOS -d:XAMCORE_2_0 -d:XAMCORE_3_0 -d:__TVOS__ $(APPLETLS_DEFINES) -d:__UNIFIED__ -d:SYSTEM_NET_HTTP TVOS_LIBDIR = $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/mono/Xamarin.TVOS TVOS_BMONO = MONO_PATH=$(TVOS_LIBDIR)/repl $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/bin/btv-mono TVOS_GENERATOR=$(BUILD_DIR)/common/bgen.exe @@ -749,8 +757,14 @@ TVOS_EXTRA_CORE_SOURCES = \ TVOS_CORE_SOURCES += \ $(TVOS_EXTRA_CORE_SOURCES) \ +TVOS_HTTP_SOURCES = \ + Foundation/NSUrlSessionHandler.cs \ + System.Net.Http/CFContentStream.cs \ + System.Net.Http/CFNetworkHandler.cs \ + TVOS_SOURCES += \ $(TVOS_EXTRA_CORE_SOURCES) \ + $(TVOS_HTTP_SOURCES) \ $(TVOS_BUILD_DIR)/Constants.cs: $(TOP)/src/Constants.tvos.cs.in Makefile $(TOP)/Make.config.inc | $(TVOS_BUILD_DIR) $(call Q_PROF_GEN,tvos) sed \ diff --git a/src/ObjCRuntime/RuntimeOptions.cs b/src/ObjCRuntime/RuntimeOptions.cs index c5bedb43ac82..73866f6a57a4 100644 --- a/src/ObjCRuntime/RuntimeOptions.cs +++ b/src/ObjCRuntime/RuntimeOptions.cs @@ -5,11 +5,11 @@ #if MTOUCH || MMP using Mono.Cecil; using Xamarin.Linker; -#elif (MONOMAC && XAMCORE_2_0) +#elif (MONOMAC || SYSTEM_NET_HTTP) using System.Net.Http; #endif -#if XAMCORE_2_0 +#if XAMCORE_2_0 || SYSTEM_NET_HTTP using Foundation; using ObjCRuntime; #elif MONOMAC && !MMP @@ -103,8 +103,12 @@ string GenerateMessageHandlerValue () default: throw ErrorHelper.CreateError (2010, "Unknown HttpMessageHandler `{0}`. Valid values are HttpClientHandler (default), CFNetworkHandler or NSUrlSessionHandler", http_message_handler); } +#elif __WATCHOS__ + return "System.Net.Http." + http_message_handler + ", Xamarin.WatchOS, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065"; +#elif __TVOS__ + return "System.Net.Http." + http_message_handler + ", Xamarin.TVOS, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065"; #else - return "System.Net.Http." + http_message_handler + ", System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"; + return "System.Net.Http." + http_message_handler + ", Xamarin.iOS, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065"; #endif } @@ -155,21 +159,21 @@ internal static TypeDefinition GetHttpMessageHandler (Application app, RuntimeOp case HttpClientHandlerValue: if (app.Platform == Utils.ApplePlatform.WatchOS) { ErrorHelper.Warning (2015, "Invalid HttpMessageHandler `{0}` for watchOS. The only valid value is NSUrlSessionHandler.", handler); - type = httpModule.GetType ("System.Net.Http", "NSUrlSessionHandler"); + type = platformModule.GetType ("System.Net.Http", "NSUrlSessionHandler"); } else { - type = httpModule.GetType ("System.Net.Http", "HttpClientHandler"); + type = platformModule.GetType ("System.Net.Http", "HttpClientHandler"); } break; case CFNetworkHandlerValue: if (app.Platform == Utils.ApplePlatform.WatchOS) { ErrorHelper.Warning (2015, "Invalid HttpMessageHandler `{0}` for watchOS. The only valid value is NSUrlSessionHandler.", handler); - type = httpModule.GetType ("System.Net.Http", "NSUrlSessionHandler"); + type = platformModule.GetType ("System.Net.Http", "NSUrlSessionHandler"); } else { - type = httpModule.GetType ("System.Net.Http", "CFNetworkHandler"); + type = platformModule.GetType ("System.Net.Http", "CFNetworkHandler"); } break; case NSUrlSessionHandlerValue: - type = httpModule.GetType ("System.Net.Http", "NSUrlSessionHandler"); + type = platformModule.GetType ("System.Net.Http", "NSUrlSessionHandler"); break; #endif default: @@ -200,15 +204,13 @@ internal static RuntimeOptions Read () } } -#if (MONOMAC && XAMCORE_2_0) -#if MONOMAC +#if (MONOMAC || SYSTEM_NET_HTTP) [Preserve] -#endif internal static HttpMessageHandler GetHttpMessageHandler () { var options = RuntimeOptions.Read (); if (options == null) { -#if MONOTOUCH_WATCH +#if __WATCHOS__ return new NSUrlSessionHandler (); #else return new HttpClientHandler (); @@ -224,7 +226,7 @@ internal static HttpMessageHandler GetHttpMessageHandler () handler = Activator.CreateInstance (t) as HttpMessageHandler; if (handler != null) return handler; -#if MONOTOUCH_WATCH +#if __WATCHOS__ Console.WriteLine ("{0} is not a valid HttpMessageHandler, defaulting to NSUrlSessionHandler", handler_name); return new NSUrlSessionHandler (); #else diff --git a/src/System.Net.Http/CFContentStream.cs b/src/System.Net.Http/CFContentStream.cs new file mode 100644 index 000000000000..42f0142ed564 --- /dev/null +++ b/src/System.Net.Http/CFContentStream.cs @@ -0,0 +1,156 @@ +// +// CFContentStream.cs +// +// Authors: +// Marek Safar +// +// Copyright (C) 2013 Xamarin Inc (http://www.xamarin.com) +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using System.Threading; +using System.Threading.Tasks; +using System.IO; +using System.Net; +using System.Runtime.ExceptionServices; + +#if XAMCORE_4_0 +using CFNetwork; +using CoreFoundation; +#elif XAMCORE_2_0 || SYSTEM_NET_HTTP +using CoreServices; +using CoreFoundation; +#else +using MonoTouch.CoreServices; +using MonoTouch.CoreFoundation; +#endif + +namespace System.Net.Http +{ + class BufferData + { + public byte[] Buffer; + public int Length; + } + + class CFContentStream : HttpContent + { + readonly CFHTTPStream http_stream; + BufferData data; + Mutex data_mutex; + AutoResetEvent data_event; + AutoResetEvent data_read_event; + ExceptionDispatchInfo http_exception; + + // The requirements are: + // * We must read at least one byte from the stream every time + // we get a HasBytesAvailable event. + // * SerializeToStreamAsync is executed on a separate thread, + // so reads must somehow be synchronized with that thread. + // + // Current implementation: + // * We read data in ReadStreamData (on the same thread + // we got the HasBytesAvailable event, i.e. inside the + // HasBytesAvailable event handler). + // * Data is stored in a class-level buffer. + // * SerializeToStreamAsync blocks while waiting for + // data from ReadStreamData. + // * ReadStreamData will only read more data once SerializeToStreamAsync + // has consumed any existing data. This means we'll be + // blocking in the HasBytesAvailable event handler until + // any previously read data has been processed (this prevents + // any unbound memory growth). + + public CFContentStream (CFHTTPStream stream) + { + this.http_stream = stream; + this.http_stream.ErrorEvent += HandleErrorEvent; + data = new BufferData () { + Buffer = new byte [4096], + }; + data_event = new AutoResetEvent (false); + data_read_event = new AutoResetEvent (true); + data_mutex = new Mutex (); + } + + void HandleErrorEvent (object sender, CFStream.StreamEventArgs e) + { + var gotMutex = data_mutex.WaitOne (); + if (gotMutex) { + var stream = (CFHTTPStream)sender; + if (e.EventType == CFStreamEventType.ErrorOccurred) + Volatile.Write (ref http_exception, ExceptionDispatchInfo.Capture (stream.GetError ())); + data_mutex.ReleaseMutex (); + } + } + + public void ReadStreamData () + { + data_read_event.WaitOne (); // make sure there's no pending data. + + data_mutex.WaitOne (); + data.Length = (int) http_stream.Read (data.Buffer, 0, data.Buffer.Length); + data_mutex.ReleaseMutex (); + + data_event.Set (); + } + + public void Close () + { + data_read_event.WaitOne (); // make sure there's no pending data + + data_mutex.WaitOne (); + data = null; + this.http_stream.ErrorEvent -= HandleErrorEvent; + data_mutex.ReleaseMutex (); + + data_event.Set (); + } + + protected internal override async Task SerializeToStreamAsync (Stream stream, TransportContext context) + { + while (data_event.WaitOne ()) { + data_mutex.WaitOne (); + if (http_exception != null) { + http_exception.Throw (); + data_mutex.ReleaseMutex (); + break; + } + if (data == null || data.Length <= 0) { + data_mutex.ReleaseMutex (); + data_read_event.Set (); + break; + } + + await stream.WriteAsync (data.Buffer, 0, data.Length).ConfigureAwait (false); + data_mutex.ReleaseMutex (); + + data_read_event.Set (); + } + } + + protected internal override bool TryComputeLength (out long length) + { + length = 0; + return false; + } + } +} diff --git a/src/System.Net.Http/CFNetworkHandler.cs b/src/System.Net.Http/CFNetworkHandler.cs new file mode 100644 index 000000000000..d87fa2a5fcc3 --- /dev/null +++ b/src/System.Net.Http/CFNetworkHandler.cs @@ -0,0 +1,389 @@ +// +// CFNetworkHandler.cs +// +// Authors: +// Marek Safar +// +// Copyright (C) 2013 Xamarin Inc (http://www.xamarin.com) +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using System.Threading; +using System.Net.Http.Headers; +using System.Threading.Tasks; +using System.IO; +using System.Collections.Generic; +using System.Net; + +#if XAMCORE_4_0 +using CFNetwork; +using CoreFoundation; +using CF=CoreFoundation; +#elif XAMCORE_2_0 || SYSTEM_NET_HTTP +using CoreServices; +using CoreFoundation; +using CF=CoreFoundation; +#else +using MonoTouch.CoreServices; +using MonoTouch.CoreFoundation; +using CF=MonoTouch.CoreFoundation; +#endif + +namespace System.Net.Http +{ + public class CFNetworkHandler : HttpMessageHandler + { + class StreamBucket + { + public TaskCompletionSource Response; + public HttpRequestMessage Request; + public CancellationTokenRegistration CancellationTokenRegistration; + public CFContentStream ContentStream; + public bool StreamCanBeDisposed; + + public void Close () + { + CancellationTokenRegistration.Dispose (); + if (ContentStream != null) { + // The Close method of the CFContentStream blocks as you can see: + // public void Close () + // { + // data_read_event.WaitOne (); // make sure there's no pending data + // + // data_mutex.WaitOne (); + // data = null; + // this.http_stream.ErrorEvent -= HandleErrorEvent; + // data_mutex.ReleaseMutex (); + // + // data_event.Set (); + // } + // This means. that when we want to ignore the data of the content, which happens + // in the first request of a redirect, if we want to close, ignoring the content + // we will have a deadlock. + // Dispose will clean all the data, without waiting for the read, which by design in the + // CFContentStream, blocks the thread. This happens ONLY after the first request that gets + // a redirect status code. All other cases should call close. + if (StreamCanBeDisposed) + ContentStream.Dispose (); + else + ContentStream.Close (); + } + } + } + + bool allowAutoRedirect; + bool sentRequest; + bool useSystemProxy; + CookieContainer cookies; + + Dictionary streamBuckets; + + public CFNetworkHandler () + { + allowAutoRedirect = true; + streamBuckets = new Dictionary (); + } + + void EnsureModifiability () + { + if (sentRequest) + throw new InvalidOperationException ( + "This instance has already started one or more requests. " + + "Properties can only be modified before sending the first request."); + } + + public bool AllowAutoRedirect { + get { + return allowAutoRedirect; + } + set { + EnsureModifiability (); + allowAutoRedirect = value; + } + } + + public CookieContainer CookieContainer { + get { + return cookies ?? (cookies = new CookieContainer ()); + } + set { + EnsureModifiability (); + cookies = value; + } + } + + public bool UseSystemProxy { + get { + return useSystemProxy; + } + set { + EnsureModifiability (); + useSystemProxy = value; + } + } + + // TODO: Add more properties + + protected override void Dispose (bool disposing) + { + // TODO: CloseStream remaining stream buckets if there are any + + base.Dispose (disposing); + } + + CFHTTPMessage CreateWebRequestAsync (HttpRequestMessage request) + { + var req = CFHTTPMessage.CreateRequest (request.RequestUri, request.Method.Method, request.Version); + + // TODO: +/* + if (wr.ProtocolVersion == HttpVersion.Version10) { + wr.KeepAlive = request.Headers.ConnectionKeepAlive; + } else { + wr.KeepAlive = request.Headers.ConnectionClose != true; + } + + if (useDefaultCredentials) { + wr.UseDefaultCredentials = true; + } else { + wr.Credentials = credentials; + } + + if (useProxy) { + wr.Proxy = proxy; + } +*/ + if (cookies != null) { + string cookieHeader = cookies.GetCookieHeader (request.RequestUri); + if (cookieHeader != "") + req.SetHeaderFieldValue ("Cookie", cookieHeader); + } + + foreach (var header in request.Headers) { + foreach (var value in header.Value) { + req.SetHeaderFieldValue (header.Key, value); + } + } + + if (request.Content != null) { + foreach (var header in request.Content.Headers) { + foreach (var value in header.Value) { + req.SetHeaderFieldValue (header.Key, value); + } + } + } + + return req; + } + + protected internal override async Task SendAsync (HttpRequestMessage request, CancellationToken cancellationToken) + { + return await SendAsync (request, cancellationToken, true).ConfigureAwait (false); + } + + internal async Task SendAsync (HttpRequestMessage request, CancellationToken cancellationToken, bool isFirstRequest) + { + sentRequest = true; + + CFHTTPStream stream; + using (var message = CreateWebRequestAsync (request)) + { + if (request.Content != null) { + var data = await request.Content.ReadAsByteArrayAsync ().ConfigureAwait (false); + message.SetBody (data); + } + + stream = CFHTTPStream.CreateForHTTPRequest (message); + } + + if (useSystemProxy) { + var proxies = CF.CFNetwork.GetSystemProxySettings (); + if (proxies.HTTPEnable) { + stream.SetProxy (proxies); + } + } + + if (!isFirstRequest && allowAutoRedirect) + stream.ShouldAutoredirect = allowAutoRedirect; + stream.HasBytesAvailableEvent += HandleHasBytesAvailableEvent; + stream.ErrorEvent += HandleErrorEvent; + stream.ClosedEvent += HandleClosedEvent; + + var response = new TaskCompletionSource (); + + if (cancellationToken.IsCancellationRequested) { + response.SetCanceled (); + return await response.Task; + } + + var bucket = new StreamBucket () { + Request = request, + Response = response, + }; + + streamBuckets.Add (stream.Handle, bucket); + + // + // Always schedule stream events handling on main-loop. Due to ConfigureAwait (false) we may end up + // on any thread-pool thread which may not have run-loop running + // +#if XAMCORE_2_0 || SYSTEM_NET_HTTP + stream.EnableEvents (CF.CFRunLoop.Main, CF.CFRunLoop.ModeCommon); +#else + stream.EnableEvents (CF.CFRunLoop.Main, CF.CFRunLoop.CFRunLoopCommonModes); +#endif + + stream.Open (); + + bucket.CancellationTokenRegistration = cancellationToken.Register (() => { + StreamBucket bucket2; + if (!streamBuckets.TryGetValue (stream.Handle, out bucket2)) + return; + + bucket2.Response.TrySetCanceled (); + CloseStream (stream); + }); + + if (isFirstRequest) { + var initialRequest = await response.Task; + var status = initialRequest.StatusCode; + if (IsRedirect (status) && allowAutoRedirect) { + bucket.StreamCanBeDisposed = true; + // remove headers in a redirect for Authentication. + request.Headers.Authorization = null; + return await SendAsync (request, cancellationToken, false).ConfigureAwait (false); + } + return initialRequest; + } + return await response.Task; + } + + // Decide if we redirect or not, similar to what is done in the managed handler + // https://github.com/mono/mono/blob/eca15996c7163f331c9f2cd0a17b63e8f92b1d55/mcs/class/referencesource/System/net/System/Net/HttpWebRequest.cs#L5681 + static bool IsRedirect (HttpStatusCode status) + { + return status == HttpStatusCode.Ambiguous || // 300 + status == HttpStatusCode.Moved || // 301 + status == HttpStatusCode.Redirect || // 302 + status == HttpStatusCode.RedirectMethod || // 303 + status == HttpStatusCode.RedirectKeepVerb; // 307 + } + + void HandleErrorEvent (object sender, CFStream.StreamEventArgs e) + { + var stream = (CFHTTPStream)sender; + + StreamBucket bucket; + if (!streamBuckets.TryGetValue (stream.Handle, out bucket)) + return; + + bucket.Response.TrySetException (stream.GetError ()); + CloseStream (stream); + } + + void HandleClosedEvent (object sender, CFStream.StreamEventArgs e) + { + var stream = (CFHTTPStream)sender; + // might not have been called (e.g. no data) but initialize critical data + HandleHasBytesAvailableEvent (sender, e); + CloseStream (stream); + } + + void CloseStream (CFHTTPStream stream) + { + lock (streamBuckets) { + if (streamBuckets.TryGetValue (stream.Handle, out var bucket)) { + bucket.Close (); + streamBuckets.Remove (stream.Handle); + } + } + stream.Close (); + } + + void HandleHasBytesAvailableEvent (object sender, CFStream.StreamEventArgs e) + { + var stream = (CFHTTPStream) sender; + + StreamBucket bucket; + if (!streamBuckets.TryGetValue (stream.Handle, out bucket)) + return; + + if (bucket.Response.Task.IsCompleted) { + bucket.ContentStream.ReadStreamData (); + return; + } + + var header = stream.GetResponseHeader (); + + // Is this possible? + if (!header.IsHeaderComplete) + throw new NotImplementedException (); + + bucket.ContentStream = new CFContentStream (stream); + + var response_msg = new HttpResponseMessage (header.ResponseStatusCode); + response_msg.RequestMessage = bucket.Request; + response_msg.ReasonPhrase = header.ResponseStatusLine; + response_msg.Content = bucket.ContentStream; + + var fields = header.GetAllHeaderFields (); + if (fields != null) { + foreach (var entry in fields) { + if (entry.Key == null) + continue; + + var key = entry.Key.ToString (); + var value = entry.Value == null ? string.Empty : entry.Value.ToString (); + HttpHeaders item_headers; + if (HttpHeaders.GetKnownHeaderKind (key) == Headers.HttpHeaderKind.Content) { + item_headers = response_msg.Content.Headers; + } else { + item_headers = response_msg.Headers; + + if (cookies != null && (key == "Set-Cookie" || key == "Set-Cookie2")) + AddCookie (value, bucket.Request.RequestUri, key); + } + + item_headers.TryAddWithoutValidation (key, value); + } + } + + // cancellation (CancellationTokenRegistration) can happen in parallel + if (!bucket.Response.Task.IsCanceled) { + bucket.Response.TrySetResult (response_msg); + + bucket.ContentStream.ReadStreamData (); + } + } + + void AddCookie (string value, Uri uri, string header) + { + CookieCollection cookies1 = null; + try { + cookies1 = cookies.CookieCutter (uri, header, value, false); + } catch { + } + + if (cookies1 != null && cookies1.Count != 0) + cookies.Add (cookies1); + } + } +} From 9ebebf9f42856e191dcac6e41f538ebd20d35efc Mon Sep 17 00:00:00 2001 From: Sebastien Pouliot Date: Mon, 1 Apr 2019 09:35:14 -0500 Subject: [PATCH 54/96] [linker] Teach linker to accept old (before optimization) bindings (#5823) Existing binding binaries won't have the `[Preserve]` attribute on the `Handler` field and, with the new optimization, would not work properly. This tweak make sure that older, already linker-safe, bindings will remain this way (safe) in this (and future) versions of both iOS and macOS SDK. --- tests/linker/CommonLinkAllTest.cs | 48 ++++++++++++++++++++++++++++++- tools/linker/CoreMarkStep.cs | 16 ++++++++++- 2 files changed, 62 insertions(+), 2 deletions(-) diff --git a/tests/linker/CommonLinkAllTest.cs b/tests/linker/CommonLinkAllTest.cs index 0a63f8b16ce6..265953f67ac6 100644 --- a/tests/linker/CommonLinkAllTest.cs +++ b/tests/linker/CommonLinkAllTest.cs @@ -1,10 +1,39 @@ using System; using System.ComponentModel; +using System.Reflection; using NUnit.Framework; using Foundation; +namespace ObjCRuntime { + public class Trampolines { + + internal delegate void DInnerBlock (IntPtr block, int magic_number); + + internal class NIDInnerBlock { } + + static internal class SDInnerBlock { + // not preserved by attributes + static internal readonly DInnerBlock Handler = Invoke; + + [MonoPInvokeCallback (typeof (DInnerBlock))] + static internal void Invoke (IntPtr block, int magic_number) + { + } + } + + static internal class SDInnerBlock_Misnamed { + // not preserved by attributes + static internal readonly DInnerBlock MisHandler = Invoke; + + [MonoPInvokeCallback (typeof (DInnerBlock))] + static internal void Invoke (IntPtr block, int magic_number) + { + } + } + } +} namespace LinkAll { public class CustomConverter : TypeConverter { @@ -24,6 +53,23 @@ class TypeDescriptorTest { [Preserve (AllMembers = true)] public class CommonLinkAllTest { + [Test] + public void BindingsAndBeforeInitField () + { + ObjCRuntime.Trampolines.SDInnerBlock.Invoke (IntPtr.Zero, 0); + var fields = typeof (ObjCRuntime.Trampolines.SDInnerBlock).GetFields (BindingFlags.NonPublic | BindingFlags.Static); + Assert.That (fields.Length, Is.EqualTo (1), "one"); + Assert.That (fields [0].Name, Is.EqualTo ("Handler"), "Name"); + } + + [Test] + public void BindingsAndBeforeInitField_2 () + { + ObjCRuntime.Trampolines.SDInnerBlock_Misnamed.Invoke (IntPtr.Zero, 0); + var fields = typeof (ObjCRuntime.Trampolines.SDInnerBlock_Misnamed).GetFields (BindingFlags.NonPublic | BindingFlags.Static); + Assert.That (fields.Length, Is.EqualTo (0), "zero"); + } + [Test] public void TypeConverter_BuiltIn () { @@ -50,4 +96,4 @@ public void ConstantsVersion_4859 () Assert.True (Version.TryParse (ObjCRuntime.Constants.Version, out var _), "Version"); } } -} \ No newline at end of file +} diff --git a/tools/linker/CoreMarkStep.cs b/tools/linker/CoreMarkStep.cs index c19c858f0867..bc14a780b26c 100644 --- a/tools/linker/CoreMarkStep.cs +++ b/tools/linker/CoreMarkStep.cs @@ -155,15 +155,29 @@ protected override TypeDefinition MarkType (TypeReference reference) { try { var td = base.MarkType (reference); + if (td == null) + return null; // We're removing the Protocol attribute, which points to its wrapper type. // But we need the wrapper type if the protocol interface is marked, so manually mark it. - if (td != null && td.IsInterface) { + if (td.IsInterface) { var proto = LinkContext.StaticRegistrar.GetProtocolAttribute (td); if (proto?.WrapperType != null) MarkType (proto.WrapperType); } + // older generated bindings did not preserve the `Handler` field and + // newer (mono 2019-02) linker can optimize them (enabled by default) + // so we make sure our old bindings remains linker-safe + if (td.IsAbstract && td.IsSealed && td.IsNested && td.HasFields) { + var dt = td.DeclaringType; + if (dt.Is ("ObjCRuntime", "Trampolines")) { + var f = td.Fields [0]; + if (f.IsInitOnly && td.Fields.Count == 1 && f.Name == "Handler") + MarkField (f); + } + } + return td; } catch (Exception e) { // we need a way to know where (not just what) went wrong (e.g. debugging symbols being incorrect) From c708fbaefd54dfea01c4d2d2bdfa4ecfa3d7cfda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Mon, 1 Apr 2019 17:21:18 +0200 Subject: [PATCH 55/96] Bump mono --- external/mono | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/mono b/external/mono index 4e3ef48ff033..7827aff41ca9 160000 --- a/external/mono +++ b/external/mono @@ -1 +1 @@ -Subproject commit 4e3ef48ff03349c46551fb0ad43016a92296cf99 +Subproject commit 7827aff41ca9f8e37b5297e7859e9a8520ff0487 From 7b1f3bbd99eb160e4d147f563b3fb53ce418442c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Mon, 1 Apr 2019 20:56:08 +0200 Subject: [PATCH 56/96] Fix Xamarin.WatchOS.dll build --- Make.config | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Make.config b/Make.config index 2820926a2d98..55d7cc2c6f3b 100644 --- a/Make.config +++ b/Make.config @@ -189,8 +189,8 @@ DEVICE_CXX=$(IOS_CXX) IOS_CSC=$(SYSTEM_CSC) -nostdlib -noconfig -r:$(MONOTOUCH_MONO_PATH)/System.dll -r:$(MONOTOUCH_MONO_PATH)/System.Core.dll -r:$(MONOTOUCH_MONO_PATH)/System.Xml.dll -r:$(MONOTOUCH_MONO_PATH)/mscorlib.dll -r:$(MONOTOUCH_MONO_PATH)/System.Net.Http.dll -r:$(MONOTOUCH_MONO_PATH)/Facades/System.Drawing.Common.dll -deterministic IOS_MCS=$(SYSTEM_MCS) -nostdlib -r:mscorlib.dll -lib:$(MONOTOUCH_MONO_PATH) -TV_CSC=$(SYSTEM_CSC) -nostdlib -noconfig -r:$(MONOTOUCH_TV_MONO_PATH)/System.dll -r:$(MONOTOUCH_TV_MONO_PATH)/System.Core.dll -r:$(MONOTOUCH_TV_MONO_PATH)/System.Xml.dll -r:$(MONOTOUCH_TV_MONO_PATH)/mscorlib.dll -r:$(MONOTOUCH_TV_MONO_PATH)/Facades/System.Drawing.Common.dll -deterministic -WATCH_CSC=$(SYSTEM_CSC) -nostdlib -noconfig -r:$(WATCH_BCL_DIR)/System.dll -r:$(WATCH_BCL_DIR)/System.Core.dll -r:$(WATCH_BCL_DIR)/System.Xml.dll -r:$(WATCH_BCL_DIR)/mscorlib.dll -r:$(WATCH_BCL_DIR)/Facades/System.Drawing.Common.dll -deterministic +TV_CSC=$(SYSTEM_CSC) -nostdlib -noconfig -r:$(MONOTOUCH_TV_MONO_PATH)/System.dll -r:$(MONOTOUCH_TV_MONO_PATH)/System.Core.dll -r:$(MONOTOUCH_TV_MONO_PATH)/System.Xml.dll -r:$(MONOTOUCH_TV_MONO_PATH)/mscorlib.dll -r:$(MONOTOUCH_TV_MONO_PATH)/System.Net.Http.dll -r:$(MONOTOUCH_TV_MONO_PATH)/Facades/System.Drawing.Common.dll -deterministic +WATCH_CSC=$(SYSTEM_CSC) -nostdlib -noconfig -r:$(WATCH_BCL_DIR)/System.dll -r:$(WATCH_BCL_DIR)/System.Core.dll -r:$(WATCH_BCL_DIR)/System.Xml.dll -r:$(WATCH_BCL_DIR)/mscorlib.dll -r:$(WATCH_BCL_DIR)/System.Net.Http.dll -r:$(WATCH_BCL_DIR)/Facades/System.Drawing.Common.dll -deterministic DEVICE_OBJC_CFLAGS=$(OBJC_CFLAGS) $(BITCODE_CFLAGS) From a9f8d7b37975f01cc52cea56fd1c5ca3a4216343 Mon Sep 17 00:00:00 2001 From: Sebastien Pouliot Date: Mon, 1 Apr 2019 21:21:56 -0500 Subject: [PATCH 57/96] [mtouch][mmp] Add control over the the linker new `BeforeFieldInit` optimization (#5820) Add an mtouch/mmp optimization flag to control this new optimization since 3rd party code (in particular binaries) might depend on this side effect. --- docs/website/optimizations.md | 20 ++++++++++++++++++++ tests/mmptest/src/MMPTest.cs | 2 +- tests/mtouch/MTouch.cs | 5 +++-- tools/common/Optimizations.cs | 11 +++++++++++ tools/mtouch/Tuning.cs | 2 ++ 5 files changed, 37 insertions(+), 3 deletions(-) diff --git a/docs/website/optimizations.md b/docs/website/optimizations.md index ffd1ea2f7762..8808be9bdc15 100644 --- a/docs/website/optimizations.md +++ b/docs/website/optimizations.md @@ -717,3 +717,23 @@ unless the interpreter is used. The default behavior can be overridden by passing `--optimize=[+|-]seal-and-devirtualize` to `mtouch`. + +## Static constructors for BeforeFieldInit removal + +This optimization requires the linker to be enabled and is applied globally +on all code inside the application. + +This optimization allows the linker not to mark every `.cctor` when a type +is preserved, e.g. whenever the class/static constructor `.cctor` is only +used for field initialization and those fields are not marked themselves +then it is possible to remove the `.cctor`. + +This optimization is enabled, by default, on both Xamarin.iOS and +Xamarin.Mac. However it represent a change from older versions of the linker. +It is possible that some existing code depend on this side effect (i.e. +those `.cctor` not being removed). In such case the optimization can be +disabled until the correct linker annotations (e.g. +`[Preserve (Conditional=true)]`) are added. + +The default behavior can be overridden by passing +`--optimize=[+|-]cctor-beforefieldinit` to `mtouch` or `mmp`. diff --git a/tests/mmptest/src/MMPTest.cs b/tests/mmptest/src/MMPTest.cs index 6691b57b7220..b8d77f43da8e 100644 --- a/tests/mmptest/src/MMPTest.cs +++ b/tests/mmptest/src/MMPTest.cs @@ -646,7 +646,7 @@ public void MM0132 (string opt) "Full", }; var rv = TI.TestUnifiedExecutable (test, shouldFail: false); - rv.Messages.AssertWarning (132, $"Unknown optimization: '{opt}'. Valid optimizations are: remove-uithread-checks, dead-code-elimination, inline-isdirectbinding, inline-intptr-size, blockliteral-setupblock, register-protocols, inline-dynamic-registration-supported, static-block-to-delegate-lookup, trim-architectures, inline-is-arm64-calling-convention."); + rv.Messages.AssertWarning (132, $"Unknown optimization: '{opt}'. Valid optimizations are: remove-uithread-checks, dead-code-elimination, inline-isdirectbinding, inline-intptr-size, blockliteral-setupblock, register-protocols, inline-dynamic-registration-supported, static-block-to-delegate-lookup, trim-architectures, inline-is-arm64-calling-convention, cctor-beforefieldinit."); rv.Messages.AssertErrorCount (0); }); } diff --git a/tests/mtouch/MTouch.cs b/tests/mtouch/MTouch.cs index 4b2f059b4b7a..a104e2cf0ac8 100644 --- a/tests/mtouch/MTouch.cs +++ b/tests/mtouch/MTouch.cs @@ -1752,7 +1752,7 @@ public void MT0132 () mtouch.Linker = MTouchLinker.LinkSdk; mtouch.Optimize = new string [] { "foo" }; mtouch.AssertExecute (MTouchAction.BuildSim, "build"); - mtouch.AssertWarning (132, "Unknown optimization: 'foo'. Valid optimizations are: remove-uithread-checks, dead-code-elimination, inline-isdirectbinding, inline-intptr-size, inline-runtime-arch, blockliteral-setupblock, register-protocols, inline-dynamic-registration-supported, static-block-to-delegate-lookup, remove-dynamic-registrar, remove-unsupported-il-for-bitcode, inline-is-arm64-calling-convention, seal-and-devirtualize."); + mtouch.AssertWarning (132, "Unknown optimization: 'foo'. Valid optimizations are: remove-uithread-checks, dead-code-elimination, inline-isdirectbinding, inline-intptr-size, inline-runtime-arch, blockliteral-setupblock, register-protocols, inline-dynamic-registration-supported, static-block-to-delegate-lookup, remove-dynamic-registrar, remove-unsupported-il-for-bitcode, inline-is-arm64-calling-convention, seal-and-devirtualize, cctor-beforefieldinit."); } } @@ -3564,7 +3564,8 @@ public void MT2003 () mtouch.AssertWarning (2003, "Option '--optimize=static-block-to-delegate-lookup' will be ignored since the static registrar is not enabled"); mtouch.AssertWarning (2003, "Option '--optimize=inline-is-arm64-calling-convention' will be ignored since linking is disabled"); mtouch.AssertWarning (2003, "Option '--optimize=seal-and-devirtualize' will be ignored since linking is disabled"); - mtouch.AssertWarningCount (12); + mtouch.AssertWarning (2003, "Option '--optimize=cctor-beforefieldinit' will be ignored since linking is disabled"); + mtouch.AssertWarningCount (13); } using (var mtouch = new MTouchTool ()) { diff --git a/tools/common/Optimizations.cs b/tools/common/Optimizations.cs index 285defd53fc8..8ed3f2323cd4 100644 --- a/tools/common/Optimizations.cs +++ b/tools/common/Optimizations.cs @@ -40,6 +40,7 @@ public class Optimizations #else "", // dummy value to make indices match up between XM and XI #endif + "cctor-beforefieldinit", }; enum Opt @@ -58,6 +59,7 @@ enum Opt RemoveUnsupportedILForBitcode, InlineIsARM64CallingConvention, SealAndDevirtualize, + StaticConstructorBeforeFieldInit, } bool? all; @@ -131,6 +133,11 @@ public bool? SealAndDevirtualize { } #endif + public bool? StaticConstructorBeforeFieldInit { + get { return values [(int) Opt.StaticConstructorBeforeFieldInit]; } + set { values [(int) Opt.StaticConstructorBeforeFieldInit] = value; } + } + public Optimizations () { values = new bool? [opt_names.Length]; @@ -283,6 +290,10 @@ public void Initialize (Application app) if (!InlineIsARM64CallingConvention.HasValue) InlineIsARM64CallingConvention = true; + // by default we try to eliminate any .cctor we can + if (!StaticConstructorBeforeFieldInit.HasValue) + StaticConstructorBeforeFieldInit = true; + if (Driver.Verbosity > 3) Driver.Log (4, "Enabled optimizations: {0}", string.Join (", ", values.Select ((v, idx) => v == true ? opt_names [idx] : string.Empty).Where ((v) => !string.IsNullOrEmpty (v)))); } diff --git a/tools/mtouch/Tuning.cs b/tools/mtouch/Tuning.cs index 536c5ec8957f..edd05ca37b8e 100644 --- a/tools/mtouch/Tuning.cs +++ b/tools/mtouch/Tuning.cs @@ -136,6 +136,8 @@ static MonoTouchLinkContext CreateLinkContext (LinkerOptions options, Pipeline p context.Target = options.Target; context.ExcludedFeatures = new [] { "remoting", "com", "sre" }; context.SymbolWriterProvider = new CustomSymbolWriterProvider (); + if (options.Application.Optimizations.StaticConstructorBeforeFieldInit == false) + context.DisabledOptimizations |= CodeOptimizations.BeforeFieldInit; options.LinkContext = context; return context; From 56d87eebba40539cdb6bcfc8c2abb3d6bea01f40 Mon Sep 17 00:00:00 2001 From: Sebastien Pouliot Date: Mon, 1 Apr 2019 21:23:56 -0500 Subject: [PATCH 58/96] [linker] Adjust HttpClientHandler selection with the new (non BCL) location of the handlers --- src/ObjCRuntime/RuntimeOptions.cs | 47 +++++++------------- tests/introspection/ApiFrameworkTest.cs | 10 +++++ tools/linker/CoreHttpMessageHandler.cs | 58 ++++++------------------- 3 files changed, 39 insertions(+), 76 deletions(-) diff --git a/src/ObjCRuntime/RuntimeOptions.cs b/src/ObjCRuntime/RuntimeOptions.cs index 73866f6a57a4..97bb16901b2d 100644 --- a/src/ObjCRuntime/RuntimeOptions.cs +++ b/src/ObjCRuntime/RuntimeOptions.cs @@ -5,19 +5,10 @@ #if MTOUCH || MMP using Mono.Cecil; using Xamarin.Linker; -#elif (MONOMAC || SYSTEM_NET_HTTP) +#else using System.Net.Http; -#endif - -#if XAMCORE_2_0 || SYSTEM_NET_HTTP using Foundation; using ObjCRuntime; -#elif MONOMAC && !MMP -using MonoMac.Foundation; -using MonoMac.ObjCRuntime; -#elif !MTOUCH && !MMP && !MMP_TEST -using MonoTouch.Foundation; -using MonoTouch.ObjCRuntime; #endif #if MMP || MMP_TEST || MTOUCH @@ -204,37 +195,29 @@ internal static RuntimeOptions Read () } } -#if (MONOMAC || SYSTEM_NET_HTTP) - [Preserve] + [Preserve] // always present but re-written by the linker internal static HttpMessageHandler GetHttpMessageHandler () { var options = RuntimeOptions.Read (); - if (options == null) { -#if __WATCHOS__ - return new NSUrlSessionHandler (); -#else - return new HttpClientHandler (); -#endif - } - // all types will be present as this is executed only when the linker is not enabled - var handler_name = options.http_message_handler; - var t = Type.GetType (handler_name, false); - - HttpMessageHandler handler = null; - if (t != null) - handler = Activator.CreateInstance (t) as HttpMessageHandler; - if (handler != null) - return handler; + var handler_name = options?.http_message_handler; #if __WATCHOS__ - Console.WriteLine ("{0} is not a valid HttpMessageHandler, defaulting to NSUrlSessionHandler", handler_name); + if (handler_name != NSUrlSessionHandlerValue) + Console.WriteLine ($"{handler_name} is not a valid HttpMessageHandler, defaulting to NSUrlSessionHandler"); return new NSUrlSessionHandler (); #else - Console.WriteLine ("{0} is not a valid HttpMessageHandler, defaulting to System.Net.Http.HttpClientHandler", handler_name); - return new HttpClientHandler (); + switch (handler_name) { + case CFNetworkHandlerValue: + return new CFNetworkHandler (); + case NSUrlSessionHandlerValue: + return new NSUrlSessionHandler (); + default: + if (handler_name != HttpClientHandlerValue) + Console.WriteLine ($"{handler_name} is not a valid HttpMessageHandler, defaulting to System.Net.Http.HttpClientHandler"); + return new HttpClientHandler (); + } #endif } -#endif #endif // Use either Create() or Read(). diff --git a/tests/introspection/ApiFrameworkTest.cs b/tests/introspection/ApiFrameworkTest.cs index cd1655d3621f..902c8920eb7d 100644 --- a/tests/introspection/ApiFrameworkTest.cs +++ b/tests/introspection/ApiFrameworkTest.cs @@ -121,6 +121,16 @@ public void NativeFrameworks () Console.WriteLine ($"Namespace candidate '{ns}'"); if (frameworks.TryGetValue (ns, out var f)) continue; + // skip System.Net.Http handlers (since we moved them out of the BCL) + switch (ns) { + case "System.Net.Http": + switch (t.Name) { + case "CFNetworkHandler": + case "NSUrlSessionHandler": + continue; + } + break; + } // Either Skip method or Frameworks.cs needs to be updated ReportError ("Unknown framework '{0}'", ns); } diff --git a/tools/linker/CoreHttpMessageHandler.cs b/tools/linker/CoreHttpMessageHandler.cs index 3a930676841f..a6e0e5053733 100644 --- a/tools/linker/CoreHttpMessageHandler.cs +++ b/tools/linker/CoreHttpMessageHandler.cs @@ -37,6 +37,16 @@ public override SubStepTargets Targets { protected override string Name { get; } = "Default HttpMessageHandler setter"; protected override int ErrorCode { get; } = 2040; + Application App { + get { +#if MONOMAC + return Driver.App; +#else + return Options.Application; +#endif + } + } + public override bool IsActiveFor (AssemblyDefinition assembly) { switch (assembly.Name.Name) { @@ -44,7 +54,9 @@ public override bool IsActiveFor (AssemblyDefinition assembly) case "Xamarin.Mac": return context.Annotations.GetAction (assembly) == AssemblyAction.Link; #else - case "System.Net.Http": + case "Xamarin.iOS": + case "Xamarin.TVOS": + case "Xamarin.WatchOS": return context.Annotations.GetAction (assembly) == AssemblyAction.Link; #endif default: @@ -52,7 +64,6 @@ public override bool IsActiveFor (AssemblyDefinition assembly) } } -#if MONOMAC protected override void Process (TypeDefinition type) { if (!type.Is ("ObjCRuntime", "RuntimeOptions")) @@ -61,7 +72,7 @@ protected override void Process (TypeDefinition type) MethodDefinition method = type.Methods.First (x => x.Name == "GetHttpMessageHandler" && !x.HasParameters); AssemblyDefinition systemNetHTTPAssembly = context.GetAssemblies ().First (x => x.Name.Name == "System.Net.Http"); - TypeDefinition handler = RuntimeOptions.GetHttpMessageHandler (Driver.App, Options.RuntimeOptions, systemNetHTTPAssembly.MainModule, type.Module); + TypeDefinition handler = RuntimeOptions.GetHttpMessageHandler (App, Options.RuntimeOptions, systemNetHTTPAssembly.MainModule, type.Module); MethodReference handler_ctor = handler.Methods.First (x => x.IsConstructor && !x.HasParameters && !x.IsStatic); // HttpClientHandler is defined not in Xamarin.Mac.dll so we need to import @@ -74,46 +85,5 @@ protected override void Process (TypeDefinition type) il.Emit (OpCodes.Ret); method.Body = body; } -#else - protected override void Process (TypeDefinition type) - { - if (!type.Is ("System.Net.Http", "HttpClient")) - return; - - MethodDefinition default_ctor = null; - MethodDefinition full_ctor = null; - foreach (var m in type.Methods) { - if (m.IsStatic || !m.IsConstructor) - continue; - if (!m.HasParameters) { - default_ctor = m; - } else if (m.Parameters.Count == 2) { - full_ctor = m; - } - } - - if (default_ctor == null || full_ctor == null) - throw new Exception ("Could not set the default HttpMessageHandler"); - - var handler = RuntimeOptions.GetHttpMessageHandler (Options.Application, Options.RuntimeOptions, type.Module); - - MethodDefinition handler_ctor = null; - foreach (var m in handler.Methods) { - if (m.IsStatic || !m.IsConstructor || m.HasParameters) - continue; - handler_ctor = m; - break; - } - // re-write default ctor - var body = new MethodBody (default_ctor); - var il = body.GetILProcessor (); - il.Emit (OpCodes.Ldarg_0); - il.Emit (OpCodes.Newobj, handler_ctor); - il.Emit (OpCodes.Ldc_I4_1); - il.Emit (OpCodes.Call, full_ctor); - il.Emit (OpCodes.Ret); - default_ctor.Body = body; - } -#endif } } From 9f2a775b8d89226dee2152aa5831e480b9b22b5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Tue, 2 Apr 2019 13:13:42 +0200 Subject: [PATCH 59/96] Bump mono --- external/mono | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/mono b/external/mono index 7827aff41ca9..a1fc070eb5e2 160000 --- a/external/mono +++ b/external/mono @@ -1 +1 @@ -Subproject commit 7827aff41ca9f8e37b5297e7859e9a8520ff0487 +Subproject commit a1fc070eb5e290a93c454816d4c69c630862df17 From 02176dc5dea5506121f906c834fb0c4617938ae0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Tue, 2 Apr 2019 16:30:50 +0200 Subject: [PATCH 60/96] HttpClientHandler is still in System.Net.Http.dll and use short string for http handler in runtime-options.plist --- src/ObjCRuntime/RuntimeOptions.cs | 33 ++++---------------------- tools/linker/CoreHttpMessageHandler.cs | 2 +- 2 files changed, 6 insertions(+), 29 deletions(-) diff --git a/src/ObjCRuntime/RuntimeOptions.cs b/src/ObjCRuntime/RuntimeOptions.cs index 97bb16901b2d..aac1906fd8b8 100644 --- a/src/ObjCRuntime/RuntimeOptions.cs +++ b/src/ObjCRuntime/RuntimeOptions.cs @@ -79,30 +79,6 @@ static string ParseTlsProvider (string value) } } - string GenerateMessageHandlerValue () - { -#if MONOMAC - // Unlike iOS, XM has this each in different namespaces... - switch (http_message_handler) - { - case HttpClientHandlerValue: - return "System.Net.Http.HttpClientHandler, System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"; - case CFNetworkHandlerValue: - return "System.Net.Http.CFNetworkHandler, Xamarin.Mac, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065"; - case NSUrlSessionHandlerValue: - return "Foundation.NSUrlSessionHandler, Xamarin.Mac, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065"; - default: - throw ErrorHelper.CreateError (2010, "Unknown HttpMessageHandler `{0}`. Valid values are HttpClientHandler (default), CFNetworkHandler or NSUrlSessionHandler", http_message_handler); - } -#elif __WATCHOS__ - return "System.Net.Http." + http_message_handler + ", Xamarin.WatchOS, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065"; -#elif __TVOS__ - return "System.Net.Http." + http_message_handler + ", Xamarin.TVOS, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065"; -#else - return "System.Net.Http." + http_message_handler + ", Xamarin.iOS, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065"; -#endif - } - internal void Write (string app_dir) { // note: we always create the file because the simulator won't remove old files @@ -114,7 +90,8 @@ internal void Write (string app_dir) content.AppendLine (""); content.AppendLine ("HttpMessageHandler"); content.Append (""); - content.AppendLine (GenerateMessageHandlerValue ()); + content.Append (http_message_handler); + content.AppendLine (""); content.AppendLine (""); content.AppendLine (""); @@ -152,7 +129,7 @@ internal static TypeDefinition GetHttpMessageHandler (Application app, RuntimeOp ErrorHelper.Warning (2015, "Invalid HttpMessageHandler `{0}` for watchOS. The only valid value is NSUrlSessionHandler.", handler); type = platformModule.GetType ("System.Net.Http", "NSUrlSessionHandler"); } else { - type = platformModule.GetType ("System.Net.Http", "HttpClientHandler"); + type = httpModule.GetType ("System.Net.Http", "HttpClientHandler"); } break; case CFNetworkHandlerValue: @@ -202,7 +179,7 @@ internal static HttpMessageHandler GetHttpMessageHandler () // all types will be present as this is executed only when the linker is not enabled var handler_name = options?.http_message_handler; #if __WATCHOS__ - if (handler_name != NSUrlSessionHandlerValue) + if (handler_name != null && handler_name != NSUrlSessionHandlerValue) Console.WriteLine ($"{handler_name} is not a valid HttpMessageHandler, defaulting to NSUrlSessionHandler"); return new NSUrlSessionHandler (); #else @@ -212,7 +189,7 @@ internal static HttpMessageHandler GetHttpMessageHandler () case NSUrlSessionHandlerValue: return new NSUrlSessionHandler (); default: - if (handler_name != HttpClientHandlerValue) + if (handler_name != null && handler_name != HttpClientHandlerValue) Console.WriteLine ($"{handler_name} is not a valid HttpMessageHandler, defaulting to System.Net.Http.HttpClientHandler"); return new HttpClientHandler (); } diff --git a/tools/linker/CoreHttpMessageHandler.cs b/tools/linker/CoreHttpMessageHandler.cs index a6e0e5053733..9b6b86966b89 100644 --- a/tools/linker/CoreHttpMessageHandler.cs +++ b/tools/linker/CoreHttpMessageHandler.cs @@ -75,7 +75,7 @@ protected override void Process (TypeDefinition type) TypeDefinition handler = RuntimeOptions.GetHttpMessageHandler (App, Options.RuntimeOptions, systemNetHTTPAssembly.MainModule, type.Module); MethodReference handler_ctor = handler.Methods.First (x => x.IsConstructor && !x.HasParameters && !x.IsStatic); - // HttpClientHandler is defined not in Xamarin.Mac.dll so we need to import + // HttpClientHandler is defined in System.Net.Http.dll so we need to import if (handler.Name.Contains ("HttpClientHandler")) handler_ctor = type.Module.ImportReference (handler_ctor); From be5b255d2def22dad4ceb74dfe7e08537aa40d5b Mon Sep 17 00:00:00 2001 From: Sebastien Pouliot Date: Tue, 2 Apr 2019 15:11:43 -0500 Subject: [PATCH 61/96] [foundation] Preserve inner types for NSUrlSessionHandler since they are processed a bit differently (for NSObject subclasses) inside the platform assemblies --- src/Foundation/NSUrlSessionHandler.cs | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/src/Foundation/NSUrlSessionHandler.cs b/src/Foundation/NSUrlSessionHandler.cs index a445435dc781..f4ec9127c55b 100644 --- a/src/Foundation/NSUrlSessionHandler.cs +++ b/src/Foundation/NSUrlSessionHandler.cs @@ -38,7 +38,7 @@ using System.Threading.Tasks; using System.Text; -#if XAMCORE_2_0 || SYSTEM_NET_HTTP +#if XAMCORE_2_0 using CoreFoundation; using Foundation; using Security; @@ -55,7 +55,7 @@ using UIKit; #endif -#if SYSTEM_NET_HTTP +#if !MONOMAC namespace System.Net.Http { #else namespace Foundation { @@ -525,10 +525,8 @@ protected override async Task SendAsync (HttpRequestMessage return await tcs.Task.ConfigureAwait (false); } -#if MONOMAC // Needed since we strip during linking since we're inside a product assembly. [Preserve (AllMembers = true)] -#endif partial class NSUrlSessionHandlerDelegate : NSUrlSessionDataDelegate { readonly NSUrlSessionHandler sessionHandler; @@ -757,10 +755,8 @@ static bool TryGetAuthenticationType (NSUrlProtectionSpace protectionSpace, out } } -#if MONOMAC // Needed since we strip during linking since we're inside a product assembly. [Preserve (AllMembers = true)] -#endif class InflightData : IDisposable { public readonly object Lock = new object (); @@ -798,10 +794,8 @@ protected virtual void Dispose (bool disposing) } -#if MONOMAC // Needed since we strip during linking since we're inside a product assembly. [Preserve (AllMembers = true)] -#endif class NSUrlSessionDataTaskStreamContent : StreamContent { Action disposed; @@ -820,10 +814,8 @@ protected override void Dispose (bool disposing) } } -#if MONOMAC // Needed since we strip during linking since we're inside a product assembly. [Preserve (AllMembers = true)] -#endif class NSUrlSessionDataTaskStream : Stream { readonly Queue data; @@ -969,10 +961,8 @@ public override void Write (byte [] buffer, int offset, int count) } } -#if MONOMAC // Needed since we strip during linking since we're inside a product assembly. [Preserve (AllMembers = true)] -#endif class WrappedNSInputStream : NSInputStream { NSStreamStatus status; From b3ab9e5edce002fca1eb92147db741d561586048 Mon Sep 17 00:00:00 2001 From: Sebastien Pouliot Date: Tue, 2 Apr 2019 17:44:59 -0500 Subject: [PATCH 62/96] [generator] Comment previous [Preserve] change on Handler since fields can't be conditionally preserved (known linker limitation) --- src/generator.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/generator.cs b/src/generator.cs index 926096c95b40..9210b609773e 100644 --- a/src/generator.cs +++ b/src/generator.cs @@ -2562,7 +2562,9 @@ void GenerateTrampolinesForQueue (TrampolineInfo [] queue) print (""); print ("//\n// This class bridges native block invocations that call into C#\n//"); print ("static internal class {0} {{", ti.StaticName); indent++; - print ("[Preserve (Conditional=true)]"); + // it can't be conditional without fixing https://github.com/mono/linker/issues/516 + // but we have a workaround in place because we can't fix old, binary bindings so... + // print ("[Preserve (Conditional=true)]"); print ("static internal readonly {0} Handler = {1};", ti.DelegateName, ti.TrampolineName); print (""); print ("[MonoPInvokeCallback (typeof ({0}))]", ti.DelegateName); From 7c73d70b4fbeb62c24c7b694eaba8bb2496fbe76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Wed, 3 Apr 2019 17:41:38 +0200 Subject: [PATCH 63/96] [linker] Don't remove RuntimeCompatibilityAttribute from assembly It's needed at runtime since it changes exception handling behavior. The "link sdk" Linker_RuntimeWrappedException() test relies on it, but this never showed up there since "link sdk" doesn't link the main assembly. --- tests/linker/ios/link sdk/LinkSdkRegressionTest.cs | 2 +- tools/linker/MonoTouch.Tuner/RemoveAttributes.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/linker/ios/link sdk/LinkSdkRegressionTest.cs b/tests/linker/ios/link sdk/LinkSdkRegressionTest.cs index debb956272a7..08ec2e968f35 100644 --- a/tests/linker/ios/link sdk/LinkSdkRegressionTest.cs +++ b/tests/linker/ios/link sdk/LinkSdkRegressionTest.cs @@ -386,7 +386,7 @@ public void Bug2000_NSPersistentStoreCoordinator () } [Test] - // http://lists.ximian.com/pipermail/monotouch/2011-December/006976.html + // http://lists.dot.net/pipermail/monotouch/2011-December/006976.html public void Linker_RuntimeWrappedException () { try { diff --git a/tools/linker/MonoTouch.Tuner/RemoveAttributes.cs b/tools/linker/MonoTouch.Tuner/RemoveAttributes.cs index 6dca636ebb2f..caddc8bd2ab7 100644 --- a/tools/linker/MonoTouch.Tuner/RemoveAttributes.cs +++ b/tools/linker/MonoTouch.Tuner/RemoveAttributes.cs @@ -71,7 +71,7 @@ public class RemoveAttributes : CoreRemoveAttributes { "System.Runtime.CompilerServices.DecimalConstantAttribute", "System.Runtime.CompilerServices.DefaultDependencyAttribute", //"System.Runtime.CompilerServices.ExtensionAttribute", used at runtime by LINQ, see bug #3028 - "System.Runtime.CompilerServices.RuntimeCompatibilityAttribute", + //"System.Runtime.CompilerServices.RuntimeCompatibilityAttribute", used at runtime by runtime wrapped exception handling "System.Runtime.CompilerServices.StringFreezingAttribute", "System.Runtime.ConstrainedExecution.PrePrepareMethodAttribute", "System.Runtime.ConstrainedExecution.ReliabilityContractAttribute", From cc58acdcd3542405df77a6333db87f2192fa9095 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Wed, 3 Apr 2019 23:52:02 +0200 Subject: [PATCH 64/96] Bump mono Commit list for mono/mono: * mono/mono@6717c3422a9 [2019-02] Bump linker to latest master (#13818) * mono/mono@6d2f1506903 Add regression test * mono/mono@fe613fb0677 Add reflected class to event methods Diff: https://github.com/mono/mono/compare/a1fc070eb5e290a93c454816d4c69c630862df17...6717c3422a9b55f9d0165cd972c0bebf88fc3a67 --- external/mono | 2 +- tools/linker/CoreMarkStep.cs | 3 ++- tools/linker/MarkNSObjects.cs | 4 ++-- tools/linker/MonoTouch.Tuner/SealerSubStep.cs | 3 ++- tools/mmp/mmp.csproj | 6 ++++++ tools/mtouch/mtouch.csproj | 6 ++++++ 6 files changed, 19 insertions(+), 5 deletions(-) diff --git a/external/mono b/external/mono index a1fc070eb5e2..6717c3422a9b 160000 --- a/external/mono +++ b/external/mono @@ -1 +1 @@ -Subproject commit a1fc070eb5e290a93c454816d4c69c630862df17 +Subproject commit 6717c3422a9b55f9d0165cd972c0bebf88fc3a67 diff --git a/tools/linker/CoreMarkStep.cs b/tools/linker/CoreMarkStep.cs index bc14a780b26c..ff8d29a4ef11 100644 --- a/tools/linker/CoreMarkStep.cs +++ b/tools/linker/CoreMarkStep.cs @@ -67,7 +67,8 @@ void ProcessDispose (MethodDefinition bd, MethodDefinition cd) return; // every subclass-Dispose should be calling base-Dispose - foreach (MethodDefinition od in overrides) { + foreach (var overrideInfo in overrides) { + var od = overrideInfo.Override; // we do not need to process unmarked code (it won't be part of the final binary) if (!Annotations.IsMarked (od)) continue; diff --git a/tools/linker/MarkNSObjects.cs b/tools/linker/MarkNSObjects.cs index ff05bb6cc7a7..eca84e849ff2 100644 --- a/tools/linker/MarkNSObjects.cs +++ b/tools/linker/MarkNSObjects.cs @@ -101,8 +101,8 @@ bool IsOverridenInUserCode (MethodDefinition method) if (overrides == null || overrides.Count == 0) return false; - foreach (MethodDefinition @override in overrides) - if (!IsProductMethod (@override)) + foreach (var @override in overrides) + if (!IsProductMethod (@override.Override)) return true; return false; diff --git a/tools/linker/MonoTouch.Tuner/SealerSubStep.cs b/tools/linker/MonoTouch.Tuner/SealerSubStep.cs index 0ac43943203f..b62ceb413f4f 100644 --- a/tools/linker/MonoTouch.Tuner/SealerSubStep.cs +++ b/tools/linker/MonoTouch.Tuner/SealerSubStep.cs @@ -1,6 +1,7 @@ // Copyright 2016 Xamarin Inc. All rights reserved. using System; +using System.Linq; using System.Collections.Generic; using Mono.Cecil; using Mono.Linker; @@ -84,7 +85,7 @@ protected override void Process (TypeDefinition type) // sanity (disable IsSealed == true above) //if (type.IsSealed) // Console.WriteLine (); - if (AreMarked (overrides)) + if (AreMarked (overrides.Select (x => x.Override).ToList ())) continue; } diff --git a/tools/mmp/mmp.csproj b/tools/mmp/mmp.csproj index 5f11bca4dec8..e727cb4a57e4 100644 --- a/tools/mmp/mmp.csproj +++ b/tools/mmp/mmp.csproj @@ -82,6 +82,9 @@ Linker\Annotations.cs + + Linker\Inflater.cs + Linker\AssemblyAction.cs @@ -145,6 +148,9 @@ Linker\MethodBodyScanner.cs + + Linker\OverrideInformation.cs + Linker\AssemblyUtilities.cs diff --git a/tools/mtouch/mtouch.csproj b/tools/mtouch/mtouch.csproj index 4ca1a9de3a0c..a92aa5a0fc2f 100644 --- a/tools/mtouch/mtouch.csproj +++ b/tools/mtouch/mtouch.csproj @@ -85,6 +85,9 @@ Linker\Annotations.cs + + Linker\Inflater.cs + Linker\LinkContext.cs @@ -118,6 +121,9 @@ Linker\MethodBodyScanner.cs + + Linker\OverrideInformation.cs + Linker\AssemblyResolver.cs From b0da1994d858b46f9762e3e7b1688963cf2e2e54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Thu, 4 Apr 2019 14:35:45 +0200 Subject: [PATCH 65/96] Bump mono Commit list for mono/mono: * mono/mono@9eb2dbf4cc3 [corlib] Disable EncodingTest.AllEncodingsAreSerializable() on XM4.5 too * mono/mono@3a935218137 [MacSDK] Bump bockbuild for fix to #13804 Diff: https://github.com/mono/mono/compare/6717c3422a9b55f9d0165cd972c0bebf88fc3a67...9eb2dbf4cc35c7422a14d48639e036332f5443c1 --- external/mono | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/mono b/external/mono index 6717c3422a9b..9eb2dbf4cc35 160000 --- a/external/mono +++ b/external/mono @@ -1 +1 @@ -Subproject commit 6717c3422a9b55f9d0165cd972c0bebf88fc3a67 +Subproject commit 9eb2dbf4cc35c7422a14d48639e036332f5443c1 From 349b73e3901e9991279863831f54eaac7db846cb Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Fri, 5 Apr 2019 12:32:43 +0200 Subject: [PATCH 66/96] Allow for current VS stable. (#5835) --- Make.config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Make.config b/Make.config index e78f4009319b..4b0660558b85 100644 --- a/Make.config +++ b/Make.config @@ -60,7 +60,7 @@ MIN_XM_MONO_URL=https://xamjenkinsartifact.azureedge.net/build-package-osx-mono/ # Minimum Visual Studio version MIN_VISUAL_STUDIO_URL=https://bosstoragemirror.azureedge.net/vsmac/7a/7aff2dc1f28d711d11d63d79b2a4c49cda217189/VisualStudioForMac-Preview-7.7.0.1470.dmg MIN_VISUAL_STUDIO_VERSION=7.7.0.1470 -MAX_VISUAL_STUDIO_VERSION=7.8.99 +MAX_VISUAL_STUDIO_VERSION=8.0.99 # Minimum CMake version MIN_CMAKE_URL=https://cmake.org/files/v3.6/cmake-3.6.2-Darwin-x86_64.dmg From c055db4ddcbd48b2140fa0ab37a6c63135fd05dd Mon Sep 17 00:00:00 2001 From: Sebastien Pouliot Date: Fri, 5 Apr 2019 14:00:51 -0500 Subject: [PATCH 67/96] [objcruntime] Fix options for watchOS default HTTP handler and remove (now) unused TLS options --- src/ObjCRuntime/RuntimeOptions.cs | 24 +----------------------- 1 file changed, 1 insertion(+), 23 deletions(-) diff --git a/src/ObjCRuntime/RuntimeOptions.cs b/src/ObjCRuntime/RuntimeOptions.cs index aac1906fd8b8..81bc70ccee15 100644 --- a/src/ObjCRuntime/RuntimeOptions.cs +++ b/src/ObjCRuntime/RuntimeOptions.cs @@ -22,10 +22,6 @@ class RuntimeOptions const string CFNetworkHandlerValue = "CFNetworkHandler"; const string NSUrlSessionHandlerValue = "NSUrlSessionHandler"; - const string DefaultTlsProviderValue = "default"; - const string LegacyTlsProviderValue = "legacy"; - const string AppleTlsProviderValue = "appletls"; - string http_message_handler; #if MTOUCH || MMP @@ -36,7 +32,6 @@ internal static RuntimeOptions Create (Application app, string http_message_hand { var options = new RuntimeOptions (); options.http_message_handler = ParseHttpMessageHandler (app, http_message_handler); - ParseTlsProvider (tls_provider); return options; } @@ -45,7 +40,7 @@ static string ParseHttpMessageHandler (Application app, string value) switch (value) { // default case null: - return HttpClientHandlerValue; + return (app.Platform == Utils.ApplePlatform.WatchOS) ? NSUrlSessionHandlerValue : HttpClientHandlerValue; case CFNetworkHandlerValue: case HttpClientHandlerValue: if (app.Platform == Utils.ApplePlatform.WatchOS) { @@ -62,23 +57,6 @@ static string ParseHttpMessageHandler (Application app, string value) } } - static string ParseTlsProvider (string value) - { - switch (value) { - // default - case null: - return DefaultTlsProviderValue; - case DefaultTlsProviderValue: - case AppleTlsProviderValue: - return value; - case LegacyTlsProviderValue: - ErrorHelper.Warning (2016, "Invalid TlsProvider `{0}` option. The only valid value `{1}` will be used.", value, AppleTlsProviderValue); - return AppleTlsProviderValue; - default: - throw ErrorHelper.CreateError (2011, "Unknown TlsProvider `{0}`. Valid values are default or appletls", value); - } - } - internal void Write (string app_dir) { // note: we always create the file because the simulator won't remove old files From d66375d27558e6898a4ba9e472d89f59e4a96db8 Mon Sep 17 00:00:00 2001 From: Sebastien Pouliot Date: Fri, 5 Apr 2019 14:01:44 -0500 Subject: [PATCH 68/96] [linker] Remove new memory allocations (List) in the sealer --- tools/linker/MonoTouch.Tuner/SealerSubStep.cs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tools/linker/MonoTouch.Tuner/SealerSubStep.cs b/tools/linker/MonoTouch.Tuner/SealerSubStep.cs index b62ceb413f4f..51dc844b5233 100644 --- a/tools/linker/MonoTouch.Tuner/SealerSubStep.cs +++ b/tools/linker/MonoTouch.Tuner/SealerSubStep.cs @@ -1,7 +1,6 @@ // Copyright 2016 Xamarin Inc. All rights reserved. using System; -using System.Linq; using System.Collections.Generic; using Mono.Cecil; using Mono.Linker; @@ -85,7 +84,7 @@ protected override void Process (TypeDefinition type) // sanity (disable IsSealed == true above) //if (type.IsSealed) // Console.WriteLine (); - if (AreMarked (overrides.Select (x => x.Override).ToList ())) + if (AreMarked (overrides)) continue; } @@ -110,6 +109,17 @@ protected override void Process (TypeDefinition type) } } + bool AreMarked (List list) + { + if (list == null) + return false; + foreach (var m in list) { + if (Annotations.IsMarked (m.Override)) + return true; + } + return false; + } + bool AreMarked (List list) { if (list == null) From f5f389282546cb041ba92b0fda8f66f33abfa490 Mon Sep 17 00:00:00 2001 From: Sebastien Pouliot Date: Fri, 5 Apr 2019 14:17:36 -0500 Subject: [PATCH 69/96] [tests][intro] Fix post xcode10.2 merge (since reflection string output changed) --- tests/introspection/ApiCtorInitTest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/introspection/ApiCtorInitTest.cs b/tests/introspection/ApiCtorInitTest.cs index 088ea14d3100..187cc3d50b66 100644 --- a/tests/introspection/ApiCtorInitTest.cs +++ b/tests/introspection/ApiCtorInitTest.cs @@ -447,7 +447,7 @@ protected virtual bool Match (ConstructorInfo ctor, Type type) case "MPSNNReduceBinary": // Not meant to be used, only subclasses case "MPSNNReduceUnary": // Not meant to be used, only subclasses var cstr = ctor.ToString (); - if (cstr == "Void .ctor(IMTLDevice)" || cstr == "Void .ctor(NSCoder, IMTLDevice)") + if (cstr == "Void .ctor(Metal.IMTLDevice)" || cstr == $"Void .ctor({foundation_namespace}.NSCoder, Metal.IMTLDevice)") return true; break; } From 89c653919d2560f500a43b4ceca3cb0fdf71d17e Mon Sep 17 00:00:00 2001 From: Sebastien Pouliot Date: Fri, 5 Apr 2019 15:51:05 -0500 Subject: [PATCH 70/96] [cfnetwork] Merge latest version of the source code It seems the latest fixes (in mono/master) happened after the `2019-02` branch was created, so the latest fixes (in mono `2018-*`) were not applied to the code that was moved but, thankfully, the we had tests to cover it. --- src/System.Net.Http/CFNetworkHandler.cs | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/src/System.Net.Http/CFNetworkHandler.cs b/src/System.Net.Http/CFNetworkHandler.cs index d87fa2a5fcc3..1bb00dfc73fd 100644 --- a/src/System.Net.Http/CFNetworkHandler.cs +++ b/src/System.Net.Http/CFNetworkHandler.cs @@ -37,7 +37,7 @@ using CFNetwork; using CoreFoundation; using CF=CoreFoundation; -#elif XAMCORE_2_0 || SYSTEM_NET_HTTP +#elif XAMCORE_2_0 using CoreServices; using CoreFoundation; using CF=CoreFoundation; @@ -245,7 +245,7 @@ internal async Task SendAsync (HttpRequestMessage request, // Always schedule stream events handling on main-loop. Due to ConfigureAwait (false) we may end up // on any thread-pool thread which may not have run-loop running // -#if XAMCORE_2_0 || SYSTEM_NET_HTTP +#if XAMCORE_2_0 stream.EnableEvents (CF.CFRunLoop.Main, CF.CFRunLoop.ModeCommon); #else stream.EnableEvents (CF.CFRunLoop.Main, CF.CFRunLoop.CFRunLoopCommonModes); @@ -309,12 +309,12 @@ void HandleClosedEvent (object sender, CFStream.StreamEventArgs e) void CloseStream (CFHTTPStream stream) { - lock (streamBuckets) { - if (streamBuckets.TryGetValue (stream.Handle, out var bucket)) { - bucket.Close (); - streamBuckets.Remove (stream.Handle); - } + StreamBucket bucket; + if (streamBuckets.TryGetValue (stream.Handle, out bucket)) { + bucket.Close (); + streamBuckets.Remove (stream.Handle); } + stream.Close (); } @@ -366,12 +366,9 @@ void HandleHasBytesAvailableEvent (object sender, CFStream.StreamEventArgs e) } } - // cancellation (CancellationTokenRegistration) can happen in parallel - if (!bucket.Response.Task.IsCanceled) { - bucket.Response.TrySetResult (response_msg); + bucket.Response.TrySetResult (response_msg); - bucket.ContentStream.ReadStreamData (); - } + bucket.ContentStream.ReadStreamData (); } void AddCookie (string value, Uri uri, string header) From bd1560dafd88fab8a2c4ede2a629ec1959e7a898 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Mon, 8 Apr 2019 11:41:40 +0200 Subject: [PATCH 71/96] Bump Mono .pkg version --- Make.config | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Make.config b/Make.config index c984a80f7c45..9030e3a38a20 100644 --- a/Make.config +++ b/Make.config @@ -49,13 +49,13 @@ XCODE94_URL=http://xamarin-storage/bot-provisioning/xcodes/Xcode_9.4.xip XCODE94_DEVELOPER_ROOT=/Applications/Xcode94.app/Contents/Developer # Minimum Mono version for building XI/XM -MIN_MONO_VERSION=6.0.0.92 +MIN_MONO_VERSION=6.0.0.148 MAX_MONO_VERSION=6.0.99 -MIN_MONO_URL=https://xamjenkinsartifact.azureedge.net/build-package-osx-mono/2019-02/84/38252d7877266332572645f486c4815531941482/MonoFramework-MDK-6.0.0.92.macos10.xamarin.universal.pkg +MIN_MONO_URL=https://xamjenkinsartifact.azureedge.net/build-package-osx-mono/2019-02/138/c4d0fae9e53190b67338037983536bef42d682c9/MonoFramework-MDK-6.0.0.148.macos10.xamarin.universal.pkg # Minimum Mono version for Xamarin.Mac apps using the system mono -MIN_XM_MONO_VERSION=6.0.0.92 -MIN_XM_MONO_URL=https://xamjenkinsartifact.azureedge.net/build-package-osx-mono/2019-02/84/38252d7877266332572645f486c4815531941482/MonoFramework-MDK-6.0.0.92.macos10.xamarin.universal.pkg +MIN_XM_MONO_VERSION=6.0.0.148 +MIN_XM_MONO_URL=https://xamjenkinsartifact.azureedge.net/build-package-osx-mono/2019-02/138/c4d0fae9e53190b67338037983536bef42d682c9/MonoFramework-MDK-6.0.0.148.macos10.xamarin.universal.pkg # Minimum Visual Studio version MIN_VISUAL_STUDIO_URL=https://bosstoragemirror.azureedge.net/vsmac/7a/7aff2dc1f28d711d11d63d79b2a4c49cda217189/VisualStudioForMac-Preview-7.7.0.1470.dmg From 006e24b174c6d2a1e7f75bc98dc2e6370d5f4b7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Mon, 8 Apr 2019 11:55:05 +0200 Subject: [PATCH 72/96] Bump mono Commit list for mono/mono: * mono/mono@c4d0fae9e53 [corlib] Fix exception 'replacement' in IsolatedStorageFile.MoveFile() * mono/mono@e728be305d7 [mono-dl] Don't do thread state transitions in mono_dl_fallback_register * mono/mono@c61202dd212 [2019-02] [merp] Fix image size reported (#13882) * mono/mono@7ecc5388d8b Add temporary workaround for internal StreamContent constructor. Diff: https://github.com/mono/mono/compare/9eb2dbf4cc35c7422a14d48639e036332f5443c1...c4d0fae9e53190b67338037983536bef42d682c9 --- external/mono | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/mono b/external/mono index 9eb2dbf4cc35..c4d0fae9e531 160000 --- a/external/mono +++ b/external/mono @@ -1 +1 @@ -Subproject commit 9eb2dbf4cc35c7422a14d48639e036332f5443c1 +Subproject commit c4d0fae9e53190b67338037983536bef42d682c9 From 3a398ee5dd934c4201416f6df59412151e8b07a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Tue, 9 Apr 2019 12:11:07 +0200 Subject: [PATCH 73/96] [System.Net.Http] Set LEGACY_HTTPCLIENT for test project Otherwise a bunch of tests that assume the new behavior fail. --- tests/bcl-test/System.Net.Http/System.Net.Http.csproj.template | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/bcl-test/System.Net.Http/System.Net.Http.csproj.template b/tests/bcl-test/System.Net.Http/System.Net.Http.csproj.template index a00ad02d482d..200fb5eebc97 100644 --- a/tests/bcl-test/System.Net.Http/System.Net.Http.csproj.template +++ b/tests/bcl-test/System.Net.Http/System.Net.Http.csproj.template @@ -14,7 +14,7 @@ 67,168,169,219,414,612,618,649,672 Xamarin.iOS obj\$(Platform)\$(Configuration)-unified - XAMCORE_2_0 + XAMCORE_2_0;LEGACY_HTTPCLIENT True From 1944b7cf4d03fcbe27ab8bca8ea2821ffa3eec4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Tue, 9 Apr 2019 17:28:58 +0200 Subject: [PATCH 74/96] Bump mono Commit list for mono/mono: * mono/mono@cd08c69f0a2 Fix reading of undefined NativeType values in old Cecil * mono/mono@af5b50b1348 [debugger-agent] Ignore thread_end event if thread is detached (#13938) * mono/mono@6c59f0e1241 [System.Net.Http] Use LEGACY_HTTPCLIENT on xammac_net_4_5 * mono/mono@e5985e541cc [2019-02] [merp] Restore non-assertion behavior in debugger-engine.c (#13879) * mono/mono@b2b2089145d [System.Data] Remove unnecessary file from xunit tests (#13935) * mono/mono@b1eb3d59cdf [AOT] remove confusing llcopts flag (#13910) * mono/mono@6b981362ecb Bump bockbuild to get GTK fix (#13912) Diff: https://github.com/mono/mono/compare/c4d0fae9e53190b67338037983536bef42d682c9...cd08c69f0a23569bf9abb58e3f1c06416874c99f --- external/mono | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/mono b/external/mono index c4d0fae9e531..cd08c69f0a23 160000 --- a/external/mono +++ b/external/mono @@ -1 +1 @@ -Subproject commit c4d0fae9e53190b67338037983536bef42d682c9 +Subproject commit cd08c69f0a23569bf9abb58e3f1c06416874c99f From 07e454bb40fb1691557893d9f2f36282923715fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Tue, 9 Apr 2019 17:47:50 +0200 Subject: [PATCH 75/96] Bump Mono .pkg version --- Make.config | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Make.config b/Make.config index 9030e3a38a20..42d8f1118590 100644 --- a/Make.config +++ b/Make.config @@ -49,13 +49,13 @@ XCODE94_URL=http://xamarin-storage/bot-provisioning/xcodes/Xcode_9.4.xip XCODE94_DEVELOPER_ROOT=/Applications/Xcode94.app/Contents/Developer # Minimum Mono version for building XI/XM -MIN_MONO_VERSION=6.0.0.148 +MIN_MONO_VERSION=6.0.0.155 MAX_MONO_VERSION=6.0.99 -MIN_MONO_URL=https://xamjenkinsartifact.azureedge.net/build-package-osx-mono/2019-02/138/c4d0fae9e53190b67338037983536bef42d682c9/MonoFramework-MDK-6.0.0.148.macos10.xamarin.universal.pkg +MIN_MONO_URL=https://xamjenkinsartifact.azureedge.net/build-package-osx-mono/2019-02/145/cd08c69f0a23569bf9abb58e3f1c06416874c99f/MonoFramework-MDK-6.0.0.155.macos10.xamarin.universal.pkg # Minimum Mono version for Xamarin.Mac apps using the system mono -MIN_XM_MONO_VERSION=6.0.0.148 -MIN_XM_MONO_URL=https://xamjenkinsartifact.azureedge.net/build-package-osx-mono/2019-02/138/c4d0fae9e53190b67338037983536bef42d682c9/MonoFramework-MDK-6.0.0.148.macos10.xamarin.universal.pkg +MIN_XM_MONO_VERSION=6.0.0.155 +MIN_XM_MONO_URL=https://xamjenkinsartifact.azureedge.net/build-package-osx-mono/2019-02/145/cd08c69f0a23569bf9abb58e3f1c06416874c99f/MonoFramework-MDK-6.0.0.155.macos10.xamarin.universal.pkg # Minimum Visual Studio version MIN_VISUAL_STUDIO_URL=https://bosstoragemirror.azureedge.net/vsmac/7a/7aff2dc1f28d711d11d63d79b2a4c49cda217189/VisualStudioForMac-Preview-7.7.0.1470.dmg From d9376421fef4f2c4164ab7943a71af83076ec4a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Tue, 9 Apr 2019 21:07:30 +0200 Subject: [PATCH 76/96] Revert "[XHarness] Ignore monotouch_Microsoft.CSharp_xunit-test.dll until issue 5868 is fixed. (#5869)" This reverts commit dc697dd5ef4cbb216b2ed9f87453aadbda6f44c4. The mono issue was fixed. --- .../bcl-test-importer/BCLTestImporter/BCLTestProjectGenerator.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/tools/bcl-test-importer/BCLTestImporter/BCLTestProjectGenerator.cs b/tools/bcl-test-importer/BCLTestImporter/BCLTestProjectGenerator.cs index 83e92973ea0c..a1e8bcd06ef5 100644 --- a/tools/bcl-test-importer/BCLTestImporter/BCLTestProjectGenerator.cs +++ b/tools/bcl-test-importer/BCLTestImporter/BCLTestProjectGenerator.cs @@ -135,7 +135,6 @@ public enum WatchAppType { "monotouch_Mono.CodeContracts_test.dll", // not supported by xamarin "monotouch_Novell.Directory.Ldap_test.dll", // not supported by xamarin "monotouch_Mono.Profiler.Log_xunit-test.dll", // special tests that need an extra app to connect as a profiler - "monotouch_Microsoft.CSharp_xunit-test.dll", // mono-cil-strip fails due to an exception from cecil, issue https://github.com/xamarin/xamarin-macios/issues/5868 }; // list of assemblies that are going to be ignored, any project with an assemblies that is ignored will From 47963d14e1226eeee9cc7f8e62b1c85f92572617 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Wed, 10 Apr 2019 20:53:47 +0200 Subject: [PATCH 77/96] Bump mono New commits in mono/mono: * mono/mono@766b3204c31 [corlib] Disable a ParameterInfoTest test on MONOTOUCH * mono/mono@c920e2002cd [corlib] Fix NSLogWriter.Write to take into account the index and count parameters. * mono/mono@578b9269c32 [corlib] Simplify newline checking in NSLogWriter. * mono/mono@31df40e9b7b [corlib] Make NSLogWriter thread-safe. * mono/mono@5a1c1281511 [configure] Add failsafe for missing submodules (#13957) * mono/mono@0b6dbfa3496 [System.Net.Http] Make some tests specific to HttpClientHandler Diff: https://github.com/mono/mono/compare/cd08c69f0a23569bf9abb58e3f1c06416874c99f..766b3204c3107be76e339aa714dad5df1c919138 --- external/mono | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/mono b/external/mono index cd08c69f0a23..766b3204c310 160000 --- a/external/mono +++ b/external/mono @@ -1 +1 @@ -Subproject commit cd08c69f0a23569bf9abb58e3f1c06416874c99f +Subproject commit 766b3204c3107be76e339aa714dad5df1c919138 From 83f7f7cbe70c8018b3d5b0074d6e52304cfb9602 Mon Sep 17 00:00:00 2001 From: Sebastien Pouliot Date: Wed, 10 Apr 2019 16:21:48 -0400 Subject: [PATCH 78/96] [cfnetwork] Add missing locks inn CFNetworkHandler Previous commit missed part of the fix from https://github.com/mono/mono/commit/d9508b8086f14ffde27c9886ba01b572c38cd3e1 Sadly this does not solve the hangs/time out while testing it --- src/System.Net.Http/CFNetworkHandler.cs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/System.Net.Http/CFNetworkHandler.cs b/src/System.Net.Http/CFNetworkHandler.cs index 1bb00dfc73fd..dfbd3e51df04 100644 --- a/src/System.Net.Http/CFNetworkHandler.cs +++ b/src/System.Net.Http/CFNetworkHandler.cs @@ -309,12 +309,12 @@ void HandleClosedEvent (object sender, CFStream.StreamEventArgs e) void CloseStream (CFHTTPStream stream) { - StreamBucket bucket; - if (streamBuckets.TryGetValue (stream.Handle, out bucket)) { - bucket.Close (); - streamBuckets.Remove (stream.Handle); + lock (streamBuckets) { + if (streamBuckets.TryGetValue (stream.Handle, out var bucket)) { + bucket.Close (); + streamBuckets.Remove (stream.Handle); + } } - stream.Close (); } @@ -366,9 +366,12 @@ void HandleHasBytesAvailableEvent (object sender, CFStream.StreamEventArgs e) } } - bucket.Response.TrySetResult (response_msg); + // cancellation (CancellationTokenRegistration) can happen in parallel + if (!bucket.Response.Task.IsCanceled) { + bucket.Response.TrySetResult (response_msg); - bucket.ContentStream.ReadStreamData (); + bucket.ContentStream.ReadStreamData (); + } } void AddCookie (string value, Uri uri, string header) From 915b3f425e37eac67060569d9a4680e50f8e8870 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Thu, 11 Apr 2019 20:31:28 +0200 Subject: [PATCH 79/96] Bump mono New commits in mono/mono: * mono/mono@bfbc3b73669 Bump corefx to get System.Linq.Expressions test fix * mono/mono@44792fcb6d4 [nuget] Bump to nuget 5.0.0 * mono/mono@4d6d75648de delete redundant try/catch from test * mono/mono@0771040bd1f Fix NRE when combobox was disposed and Text setted * mono/mono@556b1c4828a Fix local variable assign * mono/mono@32a7cc87920 Fix Stackoverflow when SplitContainer`s SplitterDistance setted in SplitterMoved event subscription * mono/mono@014b86cdba8 [SWF] Method OnClosed should pass FormClosedEventArgs type, instead of EventArgs. * mono/mono@ff2865a0787 [2019-02] [profiler] Add duration=NUM parameter to AOT profiler (#13688) (#13967) Diff: https://github.com/mono/mono/compare/766b3204c3107be76e339aa714dad5df1c919138..bfbc3b73669cb063f8bd176db35928d326e08e46 --- external/mono | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/mono b/external/mono index 766b3204c310..bfbc3b73669c 160000 --- a/external/mono +++ b/external/mono @@ -1 +1 @@ -Subproject commit 766b3204c3107be76e339aa714dad5df1c919138 +Subproject commit bfbc3b73669cb063f8bd176db35928d326e08e46 From 1cdf2ac3a83bfae1a80a81db5b259559930825bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Thu, 11 Apr 2019 20:31:48 +0200 Subject: [PATCH 80/96] Revert "[XHarness] Update ignore for some failing tests. (#5887)" This reverts commit a3ad78c937caeae9341f8d73e2191b0047f2403d. It was fixed in mono 2019-02. --- ...on-monotouch_System.Core_xunit-test.dll.ignore | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/tests/bcl-test/BCLTests/common-monotouch_System.Core_xunit-test.dll.ignore b/tests/bcl-test/BCLTests/common-monotouch_System.Core_xunit-test.dll.ignore index 744993145905..1220f8aea5cf 100644 --- a/tests/bcl-test/BCLTests/common-monotouch_System.Core_xunit-test.dll.ignore +++ b/tests/bcl-test/BCLTests/common-monotouch_System.Core_xunit-test.dll.ignore @@ -467,18 +467,3 @@ System.Dynamic.Tests.SetIndexBinderTests.IndexErrorIsNotBindingError System.Dynamic.Tests.SetIndexBinderTests.ListIndexing System.Dynamic.Tests.GetIndexBinderTests.IndexErrorIsNotBindingError System.Dynamic.Tests.GetIndexBinderTests.ListIndexing - -# DEVICE FAILURES + RELEASE CONFIG - -#System.InvalidOperationException : Sequence contains no matching element -System.Linq.Expressions.Tests.ExpressionDebuggerTypeProxyTests.VerifyDebugView -System.Linq.Expressions.Tests.ExpressionDebuggerTypeProxyTests.ThrowOnNullToCtor -System.Dynamic.Tests.ExpandoObjectProxyTests.ViewTypeThrowsOnNull -System.Dynamic.Tests.ExpandoObjectProxyTests.ValueCollectionCorrectlyViewed -System.Dynamic.Tests.ExpandoObjectProxyTests.ItemsAreRootHidden -System.Dynamic.Tests.ExpandoObjectProxyTests.KeyCollectionCorrectlyViewed -System.Dynamic.Tests.BindingRestrictionsProxyTests.MergedRestrictionsExpressions -System.Dynamic.Tests.BindingRestrictionsProxyTests.ThrowOnNullToCtor -System.Dynamic.Tests.BindingRestrictionsProxyTests.MergedRestrictionsProperties -System.Dynamic.Tests.BindingRestrictionsProxyTests.EmptyRestiction -System.Dynamic.Tests.BindingRestrictionsProxyTests.CustomRestriction From 51d66ea5cc27af1191b9bf37303c581c1cc93a52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Fri, 12 Apr 2019 16:36:53 +0200 Subject: [PATCH 81/96] Bump mono New commits in mono/mono: * mono/mono@b85fdbdb10e [corlib] Disable FileTest.SymLinkStats() on TVOS * mono/mono@170a35d5fd8 Remove TypedReference.MakeTypedReference readonly restriction * mono/mono@a1accb6f3ea [w32error] Add ENONET error case * mono/mono@b31a8fac421 [jit] Make dlmalloc use mono_valloc so it picks up the MAP_JIT flag on osx. * mono/mono@bcea757791c [utils] stub mono_setmmapjit on Win32 and Wasm * mono/mono@0a47789f152 Do not use MAP_JIT by default, instead make this something that is toggled by Xamarin.Mac which needs it Diff: https://github.com/mono/mono/compare/bfbc3b73669cb063f8bd176db35928d326e08e46..b85fdbdb10e18fcf3483dc409e9a10ac5b1e36ca --- external/mono | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/mono b/external/mono index bfbc3b73669c..b85fdbdb10e1 160000 --- a/external/mono +++ b/external/mono @@ -1 +1 @@ -Subproject commit bfbc3b73669cb063f8bd176db35928d326e08e46 +Subproject commit b85fdbdb10e18fcf3483dc409e9a10ac5b1e36ca From 505a957accae49ee049733d7139846901f62cfb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Fri, 12 Apr 2019 17:43:18 +0200 Subject: [PATCH 82/96] [bcl-tests] Add Microsoft.CSharp reference to Mono.CSharp_test.dll on XM It's needed for the C# "dynamic" feature. --- .../BCLTestImporter/BCLTestProjectDefinitionWorkaround.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/bcl-test-importer/BCLTestImporter/BCLTestProjectDefinitionWorkaround.cs b/tools/bcl-test-importer/BCLTestImporter/BCLTestProjectDefinitionWorkaround.cs index 93aba2326a95..98466cdf9ae7 100644 --- a/tools/bcl-test-importer/BCLTestImporter/BCLTestProjectDefinitionWorkaround.cs +++ b/tools/bcl-test-importer/BCLTestImporter/BCLTestProjectDefinitionWorkaround.cs @@ -15,6 +15,7 @@ public partial struct BCLTestProjectDefinition {"MonoCSharpTests", new List<(string assembly, string hint)> { (assembly:"mscorlib", hint:"{MONO_ROOT}mcs/class/lib/xammac_net_4_5/mscorlib.dll"), (assembly:"Mono.CSharp", hint:"{MONO_ROOT}mcs/class/lib/xammac_net_4_5/Mono.CSharp.dll"), + (assembly:"Microsoft.CSharp", hint:"{MONO_ROOT}mcs/class/lib/xammac_net_4_5/Microsoft.CSharp.dll"), (assembly:"nunitlite", hint:"{MONO_ROOT}mcs/class/lib/xammac_net_4_5/nunitlite.dll"), (assembly:"System.Core", hint:"{MONO_ROOT}mcs/class/lib/xammac_net_4_5/System.Core.dll"), (assembly:"xammac_net_4_5_Mono.CSharp_test.dll", hint:"{MONO_ROOT}mcs/class/lib/xammac_net_4_5/tests/xammac_net_4_5_Mono.CSharp_test.dll"), From 2278512abafe68a808c84c7575a6bdb053cc8081 Mon Sep 17 00:00:00 2001 From: Chris Hamons Date: Fri, 12 Apr 2019 18:06:28 +0200 Subject: [PATCH 83/96] [launcher] Pass --use-map-jit to mono on XM app startup - Related: https://github.com/mono/mono/pull/13446 - Patch by Miguel --- runtime/launcher.m | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/runtime/launcher.m b/runtime/launcher.m index 521d96961915..c1f30b284b9a 100644 --- a/runtime/launcher.m +++ b/runtime/launcher.m @@ -605,7 +605,7 @@ int xamarin_main (int argc, char **argv, enum XamarinLaunchMode launch_mode) @autoreleasepool { int env_argc = 0; char **env_argv = get_mono_env_options (&env_argc); - int new_argc = env_argc + 2 /* --debug executable */ + argc ; + int new_argc = env_argc + 3 /* --use-map-jit --debug executable */ + argc ; if (xamarin_mac_hybrid_aot) new_argc += 1; if (xamarin_mac_modern) @@ -615,6 +615,8 @@ int xamarin_main (int argc, char **argv, enum XamarinLaunchMode launch_mode) const char **ptr = (const char **) new_argv; // binary *ptr++ = argv [0]; + *ptr++ = "--use-map-jit"; + // inject MONO_ENV_OPTIONS for (int i = 0; i < env_argc; i++) *ptr++ = env_argv [i]; From db657ee58be5a7a0d09c4eef91a0a628671b1e96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Mon, 15 Apr 2019 11:36:52 +0200 Subject: [PATCH 84/96] Bump mono New commits in mono/mono: * mono/mono@d75c142a464 Bump corefx to get unit test fix Diff: https://github.com/mono/mono/compare/b85fdbdb10e18fcf3483dc409e9a10ac5b1e36ca..d75c142a4646af45f680cd90cafe05843d1d5945 --- external/mono | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/mono b/external/mono index b85fdbdb10e1..d75c142a4646 160000 --- a/external/mono +++ b/external/mono @@ -1 +1 @@ -Subproject commit b85fdbdb10e18fcf3483dc409e9a10ac5b1e36ca +Subproject commit d75c142a4646af45f680cd90cafe05843d1d5945 From 8308ec9c6752c081b6f57e86f26816d2a0ff4969 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Mon, 15 Apr 2019 15:05:13 +0200 Subject: [PATCH 85/96] Bump Mono .pkg version --- Make.config | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Make.config b/Make.config index 42d8f1118590..145e78e93d7a 100644 --- a/Make.config +++ b/Make.config @@ -49,13 +49,13 @@ XCODE94_URL=http://xamarin-storage/bot-provisioning/xcodes/Xcode_9.4.xip XCODE94_DEVELOPER_ROOT=/Applications/Xcode94.app/Contents/Developer # Minimum Mono version for building XI/XM -MIN_MONO_VERSION=6.0.0.155 +MIN_MONO_VERSION=6.0.0.176 MAX_MONO_VERSION=6.0.99 -MIN_MONO_URL=https://xamjenkinsartifact.azureedge.net/build-package-osx-mono/2019-02/145/cd08c69f0a23569bf9abb58e3f1c06416874c99f/MonoFramework-MDK-6.0.0.155.macos10.xamarin.universal.pkg +MIN_MONO_URL=https://xamjenkinsartifact.azureedge.net/build-package-osx-mono/2019-02/161/d75c142a4646af45f680cd90cafe05843d1d5945/MonoFramework-MDK-6.0.0.176.macos10.xamarin.universal.pkg # Minimum Mono version for Xamarin.Mac apps using the system mono -MIN_XM_MONO_VERSION=6.0.0.155 -MIN_XM_MONO_URL=https://xamjenkinsartifact.azureedge.net/build-package-osx-mono/2019-02/145/cd08c69f0a23569bf9abb58e3f1c06416874c99f/MonoFramework-MDK-6.0.0.155.macos10.xamarin.universal.pkg +MIN_XM_MONO_VERSION=6.0.0.176 +MIN_XM_MONO_URL=https://xamjenkinsartifact.azureedge.net/build-package-osx-mono/2019-02/161/d75c142a4646af45f680cd90cafe05843d1d5945/MonoFramework-MDK-6.0.0.176.macos10.xamarin.universal.pkg # Minimum Visual Studio version MIN_VISUAL_STUDIO_URL=https://bosstoragemirror.azureedge.net/vsmac/7a/7aff2dc1f28d711d11d63d79b2a4c49cda217189/VisualStudioForMac-Preview-7.7.0.1470.dmg From c734cf2def6868ab0336ccb6786bb1b3fb3b1f16 Mon Sep 17 00:00:00 2001 From: Manuel de la Pena Date: Tue, 16 Apr 2019 12:14:17 +0200 Subject: [PATCH 86/96] [CFNetwork] Ensure we do not block on redirects. (#5900) The changes in mono are changing threading. This means that the code is getting deadlock in the ReadStreamData. This happens because we were not removing the handlers from the first requests events. Initially, before we had to take care about the auth headers, this was needed to init certain internal state for the HttpContent that was sexposed to the user. With the fix of the CVE, the first request, in case of a redirect, is garbage and is ignored. The second request is the one returned to the user and contains all the required info. Removing the event handlers, ensure that HandleClose is not called and therefore ReadStream is never called. --- src/System.Net.Http/CFNetworkHandler.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/System.Net.Http/CFNetworkHandler.cs b/src/System.Net.Http/CFNetworkHandler.cs index dfbd3e51df04..1537141784a8 100644 --- a/src/System.Net.Http/CFNetworkHandler.cs +++ b/src/System.Net.Http/CFNetworkHandler.cs @@ -267,6 +267,10 @@ internal async Task SendAsync (HttpRequestMessage request, var status = initialRequest.StatusCode; if (IsRedirect (status) && allowAutoRedirect) { bucket.StreamCanBeDisposed = true; + // we do not care about the first stream cbs + stream.HasBytesAvailableEvent -= HandleHasBytesAvailableEvent; + stream.ErrorEvent -= HandleErrorEvent; + stream.ClosedEvent -= HandleClosedEvent; // remove headers in a redirect for Authentication. request.Headers.Authorization = null; return await SendAsync (request, cancellationToken, false).ConfigureAwait (false); From 9bd927bb7fe3eb1b14721745c500ff8b4aecd109 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Tue, 16 Apr 2019 17:59:23 +0200 Subject: [PATCH 87/96] Workaround https://github.com/xamarin/xamarin-macios/issues/5760 in generator csproj --- src/generator.csproj | 1 + tests/generator/generator-tests.csproj | 1 + 2 files changed, 2 insertions(+) diff --git a/src/generator.csproj b/src/generator.csproj index d0d8c80b7c2f..b11d92be2a08 100644 --- a/src/generator.csproj +++ b/src/generator.csproj @@ -23,6 +23,7 @@ True + diff --git a/tests/generator/generator-tests.csproj b/tests/generator/generator-tests.csproj index 68d8f49a7d90..e62799c4e682 100644 --- a/tests/generator/generator-tests.csproj +++ b/tests/generator/generator-tests.csproj @@ -26,6 +26,7 @@ 4 + From d405c37692dc20385381ce5273b5557b2f729505 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Wed, 17 Apr 2019 11:29:11 +0200 Subject: [PATCH 88/96] Bump mono New commits in mono/mono: * mono/mono@158b6137fae [corefx] Use fallbacks when link() fails * mono/mono@5a9fb2376d9 [MacSDK] Bump F# to 4.5 (#10919) * mono/mono@eb478b5163c [gsharedvt] Fix sizeof opcode (#13831) * mono/mono@d67de36ffbb [2019-02] [arm] align stack pointer in throw trampoline (#14083) * mono/mono@d3ece1d29f8 [2019-02] [aot] change method table generation so that it works for larger assemblies on ARM (#14052) * mono/mono@d76895f97fc [WinForms] Fix displayed image in TreeNode when ImageIndex set to -2 When ImageIndex in TreeNode set to -2 must not displayed any image Diff: https://github.com/mono/mono/compare/d75c142a4646af45f680cd90cafe05843d1d5945..158b6137fae610d3efb8741e2375eb57959101a4 --- external/mono | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/mono b/external/mono index d75c142a4646..158b6137fae6 160000 --- a/external/mono +++ b/external/mono @@ -1 +1 @@ -Subproject commit d75c142a4646af45f680cd90cafe05843d1d5945 +Subproject commit 158b6137fae610d3efb8741e2375eb57959101a4 From dbbc95444785d2611eee0e7af30fa56d9cf8a245 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Wed, 17 Apr 2019 11:30:41 +0200 Subject: [PATCH 89/96] Reenable tests that were fixed --- .../BCLTests/common-monotouch_System_test.dll.ignore | 7 ------- 1 file changed, 7 deletions(-) delete mode 100644 tests/bcl-test/BCLTests/common-monotouch_System_test.dll.ignore diff --git a/tests/bcl-test/BCLTests/common-monotouch_System_test.dll.ignore b/tests/bcl-test/BCLTests/common-monotouch_System_test.dll.ignore deleted file mode 100644 index 7319b8fdea2c..000000000000 --- a/tests/bcl-test/BCLTests/common-monotouch_System_test.dll.ignore +++ /dev/null @@ -1,7 +0,0 @@ -# FAIL ON DEVICE - -# ProcessTest.Start1_FileName_NotFound : #C6 -# Expected: 2 -# But was: 13 -# revert it once we have https://github.com/mono/mono/pull/13693 -MonoTests.System.Diagnostics.ProcessTest.Start1_FileName_NotFound From b1dc78525dac4cea250049f729b88dc58276054e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Wed, 17 Apr 2019 12:18:29 +0200 Subject: [PATCH 90/96] bcl-test-importer: Append .Unsafe to System.Runtime.CompilerServices test suite It's actually an important distinction. --- .../BCLTestImporter/BCLTestProjectDefinitionWorkaround.cs | 2 +- .../BCLTestImporter/BCLTestProjectGenerator.cs | 2 +- .../bcl-test-importer/BCLTestImporter/RegisterTypeGenerator.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/bcl-test-importer/BCLTestImporter/BCLTestProjectDefinitionWorkaround.cs b/tools/bcl-test-importer/BCLTestImporter/BCLTestProjectDefinitionWorkaround.cs index 98466cdf9ae7..99a0149a7b94 100644 --- a/tools/bcl-test-importer/BCLTestImporter/BCLTestProjectDefinitionWorkaround.cs +++ b/tools/bcl-test-importer/BCLTestImporter/BCLTestProjectDefinitionWorkaround.cs @@ -251,7 +251,7 @@ public partial struct BCLTestProjectDefinition (assembly:"Microsoft.CSharp", hint:"{MONO_ROOT}mcs/class/lib/xammac_net_4_5/Microsoft.CSharp.dll"), (assembly:"xammac_net_4_5_System.Numerics_xunit-test.dll", hint:"{MONO_ROOT}mcs/class/lib/xammac_net_4_5/tests/xammac_net_4_5_System.Numerics_xunit-test.dll"), }}, - {"SystemRuntimeCompilerServicesXunit", new List<(string assembly, string hint)> { + {"SystemRuntimeCompilerServicesUnsafeXunit", new List<(string assembly, string hint)> { (assembly:"mscorlib", hint:"{MONO_ROOT}mcs/class/lib/xammac_net_4_5/mscorlib.dll"), (assembly:"xunit.core", hint:""), (assembly:"xunit.abstractions", hint:""), diff --git a/tools/bcl-test-importer/BCLTestImporter/BCLTestProjectGenerator.cs b/tools/bcl-test-importer/BCLTestImporter/BCLTestProjectGenerator.cs index a1e8bcd06ef5..e77ffff01454 100644 --- a/tools/bcl-test-importer/BCLTestImporter/BCLTestProjectGenerator.cs +++ b/tools/bcl-test-importer/BCLTestImporter/BCLTestProjectGenerator.cs @@ -184,7 +184,7 @@ public enum WatchAppType { (name:"SystemDataXunit", assemblies: new [] {"xammac_net_4_5_System.Data_xunit-test.dll"}, group: "Mac OS X BCL tests group 3"), (name:"SystemJsonXunit", assemblies: new [] {"xammac_net_4_5_System.Json_xunit-test.dll"}, group: "Mac OS X BCL tests group 3"), (name:"SystemNumericsXunit", assemblies: new [] {"xammac_net_4_5_System.Numerics_xunit-test.dll"}, group: "Mac OS X BCL tests group 3"), - (name:"SystemRuntimeCompilerServicesXunit", assemblies: new [] {"xammac_net_4_5_System.Runtime.CompilerServices.Unsafe_xunit-test.dll"}, group: "Mac OS X BCL tests group 3"), + (name:"SystemRuntimeCompilerServicesUnsafeXunit", assemblies: new [] {"xammac_net_4_5_System.Runtime.CompilerServices.Unsafe_xunit-test.dll"}, group: "Mac OS X BCL tests group 3"), (name:"SystemSecurityXunit", assemblies: new [] {"xammac_net_4_5_System.Security_xunit-test.dll"}, group: "Mac OS X BCL tests group 3"), (name:"SystemXmlLinqXunit", assemblies: new [] {"xammac_net_4_5_System.Xml.Linq_xunit-test.dll"}, group: "Mac OS X BCL tests group 3"), (name:"SystemXunit", assemblies: new [] {"xammac_net_4_5_System_xunit-test.dll"}, group: "Mac OS X BCL tests group 3"), diff --git a/tools/bcl-test-importer/BCLTestImporter/RegisterTypeGenerator.cs b/tools/bcl-test-importer/BCLTestImporter/RegisterTypeGenerator.cs index fb7078b01f34..a1748e428aff 100644 --- a/tools/bcl-test-importer/BCLTestImporter/RegisterTypeGenerator.cs +++ b/tools/bcl-test-importer/BCLTestImporter/RegisterTypeGenerator.cs @@ -43,7 +43,7 @@ public static class RegisterTypeGenerator { {"SystemDataXunit", new [] {("System.Data.SqlClient.Tests", "xammac_net_4_5_System.Data_xunit-test.dll", "System.Data.SqlClient.Tests.CloneTests")}}, {"SystemJsonXunit", new [] {("System.Json.Tests", "xammac_net_4_5_System.Json_xunit-test.dll", "System.Json.Tests.JsonArrayTests")}}, {"SystemNumericsXunit", new [] {("System.Numerics.Tests", "xammac_net_4_5_System.Numerics_xunit-test.dll", "System.Numerics.Tests.GenericVectorTests")}}, - {"SystemRuntimeCompilerServicesXunit", new [] {("System.Runtime.CompilerServices", "xammac_net_4_5_System.Runtime.CompilerServices.Unsafe_xunit-test.dll", "System.Runtime.CompilerServices.UnsafeTests")}}, + {"SystemRuntimeCompilerServicesUnsafeXunit", new [] {("System.Runtime.CompilerServices", "xammac_net_4_5_System.Runtime.CompilerServices.Unsafe_xunit-test.dll", "System.Runtime.CompilerServices.UnsafeTests")}}, {"SystemXmlLinqXunit", new [] {("Microsoft.Test.ModuleCore", "xammac_net_4_5_System.Xml.Linq_xunit-test.dll", "Microsoft.Test.ModuleCore.LtmContext")}}, {"SystemServiceModelTests", new [] {("MonoTests.System.ServiceModel", "xammac_net_4_5_System.ServiceModel_test.dll", "MonoTests.System.ServiceModel.Bug36080")}}, {"SystemSecurityXunit", new [] {("System.Security.Cryptography.Pkcs.Tests", "xammac_net_4_5_System.Security_xunit-test.dll", "System.Security.Cryptography.Pkcs.Tests.CryptographicAttributeObjectCollectionTests")}}, From 65153f4985a01904c8eebadc6c11a4b58986a32b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Wed, 17 Apr 2019 12:20:27 +0200 Subject: [PATCH 91/96] Add System.Runtime.CompilerServices.Unsafe xunit test to iOS --- .../BCLTestImporter/BCLTestProjectGenerator.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/bcl-test-importer/BCLTestImporter/BCLTestProjectGenerator.cs b/tools/bcl-test-importer/BCLTestImporter/BCLTestProjectGenerator.cs index e77ffff01454..cc3841b9cae9 100644 --- a/tools/bcl-test-importer/BCLTestImporter/BCLTestProjectGenerator.cs +++ b/tools/bcl-test-importer/BCLTestImporter/BCLTestProjectGenerator.cs @@ -112,7 +112,8 @@ public enum WatchAppType { (name:"SystemComponentModelCompositionXunit", assemblies: new [] {"monotouch_System.ComponentModel.Composition_xunit-test.dll"}, group: "BCL tests group 3"), (name:"SystemRuntimeSerializationXunit", assemblies: new [] {"monotouch_System.Runtime.Serialization_xunit-test.dll"}, group: "BCL tests group 3"), (name:"SystemXmlXunit", assemblies: new [] {"monotouch_System.Xml_xunit-test.dll"}, group: "BCL tests group 3"), - + (name:"SystemRuntimeCompilerServicesUnsafeXunit", assemblies: new [] {"monotouch_System.Runtime.CompilerServices.Unsafe_xunit-test.dll"}, group: "BCL tests group 3"), + // BCL tests group 4 (name:"SystemNumericsXunit", assemblies: new [] {"monotouch_System.Numerics_xunit-test.dll"}, group: "BCL tests group 4"), (name:"SystemCoreXunit", assemblies: new [] {"monotouch_System.Core_xunit-test.dll"}, group: "BCL tests group 4"), From fc7008d2261ed960f3a38a5abbbf4da6e413365b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Wed, 17 Apr 2019 14:32:27 +0200 Subject: [PATCH 92/96] bcl-test-importer: Select first type that ends with Test/Tests We need to avoid selecting some unrelated type that could conflict between assemblies like FileCleanupTestBase. --- .../BCLTestImporter/BCLTestProjectDefinition.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/bcl-test-importer/BCLTestImporter/BCLTestProjectDefinition.cs b/tools/bcl-test-importer/BCLTestImporter/BCLTestProjectDefinition.cs index 6742bfba6c20..3daeea832170 100644 --- a/tools/bcl-test-importer/BCLTestImporter/BCLTestProjectDefinition.cs +++ b/tools/bcl-test-importer/BCLTestImporter/BCLTestProjectDefinition.cs @@ -97,12 +97,12 @@ public bool Validate () if (!types.Any ()) { continue; } - dict[Path.GetFileName (path)] = types.First (t => !t.IsGenericType && t.FullName.Contains ("Test")); + dict[Path.GetFileName (path)] = types.First (t => !t.IsGenericType && (t.FullName.EndsWith ("Test") || t.FullName.EndsWith ("Tests"))); } catch (ReflectionTypeLoadException e) { // ReflectionTypeLoadException // we did get an exception, possible reason, the type comes from an assebly not loaded, but // nevertheless we can do something about it, get all the not null types in the exception // and use one of them - var types = e.Types.Where (t => t != null).Where (t => !t.IsGenericType && t.FullName.Contains ("Test")); + var types = e.Types.Where (t => t != null).Where (t => !t.IsGenericType && (t.FullName.EndsWith ("Test") || t.FullName.EndsWith ("Tests"))); if (types.Any()) { dict[Path.GetFileName (path)] = types.First (); } From 3ebafb9725b0439c22b8a1ae7214edb1efbd012b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Wed, 17 Apr 2019 14:33:50 +0200 Subject: [PATCH 93/96] bcl-test-importer: Correctly process watch/tv assemblies The missing test assemblies validator wasn't matching them since it looked for monotouch_, instead of monotouch_watch_ --- .../BCLTestImporter/BCLTestProjectGenerator.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/bcl-test-importer/BCLTestImporter/BCLTestProjectGenerator.cs b/tools/bcl-test-importer/BCLTestImporter/BCLTestProjectGenerator.cs index cc3841b9cae9..20cd93139ed9 100644 --- a/tools/bcl-test-importer/BCLTestImporter/BCLTestProjectGenerator.cs +++ b/tools/bcl-test-importer/BCLTestImporter/BCLTestProjectGenerator.cs @@ -583,7 +583,7 @@ bool IsIgnored (string a, Platform platform) using (var file = new StreamWriter (projectPath, false)) { // false is do not append await file.WriteAsync (generatedProject); } - var typesPerAssembly = projectDefinition.GetTypeForAssemblies (GetReleaseDownload (Platform.iOS), platform, true); + var typesPerAssembly = projectDefinition.GetTypeForAssemblies (GetReleaseDownload (platform), platform, true); var registerCode = await RegisterTypeGenerator.GenerateCodeAsync (typesPerAssembly, projectDefinition.IsXUnit, RegisterTypesTemplatePath); @@ -971,21 +971,21 @@ public void CleanOutput () public bool AllTestAssembliesAreRan (out Dictionary> missingAssemblies, bool wasDownloaded) { missingAssemblies = new Dictionary> (); - foreach (var platform in new [] {Platform.iOS, Platform.TvOS}) { + foreach (var platform in new [] {Platform.iOS, Platform.TvOS, Platform.WatchOS}) { var testDir = wasDownloaded ? BCLTestAssemblyDefinition.GetTestDirectoryFromDownloadsPath (GetReleaseDownload (platform), platform) : BCLTestAssemblyDefinition.GetTestDirectoryFromMonoPath (MonoRootPath, platform); var missingAssembliesPlatform = Directory.GetFiles (testDir, NUnitPattern).Select (Path.GetFileName).Union ( Directory.GetFiles (testDir, xUnitPattern).Select (Path.GetFileName)).ToList (); foreach (var assembly in CommonIgnoredAssemblies) { - missingAssembliesPlatform.Remove (assembly); + missingAssembliesPlatform.Remove (new BCLTestAssemblyDefinition (assembly).GetName (platform)); } // loop over the mono root path and grab all the assemblies, then intersect the found ones with the added // and ignored ones. foreach (var projectDefinition in commoniOSTestProjects) { foreach (var testAssembly in projectDefinition.assemblies) { - missingAssembliesPlatform.Remove (testAssembly); + missingAssembliesPlatform.Remove (new BCLTestAssemblyDefinition (testAssembly).GetName (platform)); } } From 8ed5e3926a0d8fd6a8ca1573956e916e587d903e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Wed, 17 Apr 2019 14:34:12 +0200 Subject: [PATCH 94/96] bcl-test-importer: Add three more unit test assemblies --- ...notouch_System.Net.Http.UnitTests_xunit-test.dll.ignore | 4 ++++ .../BCLTestImporter/BCLTestProjectGenerator.cs | 7 ++++++- 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 tests/bcl-test/BCLTests/common-monotouch_System.Net.Http.UnitTests_xunit-test.dll.ignore diff --git a/tests/bcl-test/BCLTests/common-monotouch_System.Net.Http.UnitTests_xunit-test.dll.ignore b/tests/bcl-test/BCLTests/common-monotouch_System.Net.Http.UnitTests_xunit-test.dll.ignore new file mode 100644 index 000000000000..6fb9b68dc35b --- /dev/null +++ b/tests/bcl-test/BCLTests/common-monotouch_System.Net.Http.UnitTests_xunit-test.dll.ignore @@ -0,0 +1,4 @@ +## Uses RemoteExecutor +System.Net.Http.Tests.HttpEnvironmentProxyTest.HttpProxy_CredentialParsing_Basic +System.Net.Http.Tests.HttpEnvironmentProxyTest.HttpProxy_Exceptions_Match +System.Net.Http.Tests.HttpEnvironmentProxyTest.HttpProxy_EnvironmentProxy_Loaded diff --git a/tools/bcl-test-importer/BCLTestImporter/BCLTestProjectGenerator.cs b/tools/bcl-test-importer/BCLTestImporter/BCLTestProjectGenerator.cs index 20cd93139ed9..0c15f77b0040 100644 --- a/tools/bcl-test-importer/BCLTestImporter/BCLTestProjectGenerator.cs +++ b/tools/bcl-test-importer/BCLTestImporter/BCLTestProjectGenerator.cs @@ -92,7 +92,8 @@ public enum WatchAppType { (name:"MonoCSharpTests", assemblies: new [] {"monotouch_Mono.CSharp_test.dll"}, group: "BCL tests group 1"), (name:"SystemSecurityTests", assemblies: new [] {"monotouch_System.Security_test.dll"}, group: "BCL tests group 1"), (name:"MonoDataSqliteTests", assemblies: new [] {"monotouch_Mono.Data.Sqlite_test.dll"}, group: "BCL tests group 1"), - + (name:"MonoRuntimeTests", assemblies: new [] {"monotouch_Mono.Runtime.Tests_test.dll"}, group: "BCL tests group 1"), + // BCL tests group 2 (name:"SystemTests", assemblies: new[] {"monotouch_System_test.dll"}, group: "BCL tests group 2"), (name:"SystemDataTests", assemblies: new [] {"monotouch_System.Data_test.dll"}, group: "BCL tests group 2"), @@ -122,6 +123,10 @@ public enum WatchAppType { // BCL tests group 5 (name:"CorlibXunit", assemblies: new [] {"monotouch_corlib_xunit-test.dll"}, group: "BCL tests group 5"), + + // BCL tests group 6 + (name:"SystemNetHttpUnitTestsXunit", assemblies: new [] {"monotouch_System.Net.Http.UnitTests_xunit-test.dll"}, group: "BCL tests group 6"), + (name:"SystemNetHttpFunctionalTestsXunit", assemblies: new [] {"monotouch_System.Net.Http.FunctionalTests_xunit-test.dll"}, group: "BCL tests group 6"), }; static readonly List CommonIgnoredAssemblies = new List { From 946e0174b0710b24554f1aa9e3fd43d0b93e2637 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Wed, 17 Apr 2019 15:23:29 +0200 Subject: [PATCH 95/96] Bump mono New commits in mono/mono: * mono/mono@cf880be66a2 [Mono.Runtime.Tests] Exclude simd tests Diff: https://github.com/mono/mono/compare/158b6137fae610d3efb8741e2375eb57959101a4..cf880be66a2d1cc8ca34e345114a7f420b7b86ea --- external/mono | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/mono b/external/mono index 158b6137fae6..cf880be66a2d 160000 --- a/external/mono +++ b/external/mono @@ -1 +1 @@ -Subproject commit 158b6137fae610d3efb8741e2375eb57959101a4 +Subproject commit cf880be66a2d1cc8ca34e345114a7f420b7b86ea From 9882746e377a586c00c06e32aa6303543c8bbe6e Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Thu, 25 Apr 2019 09:05:48 +0200 Subject: [PATCH 96/96] [tests] Fix race condition in the MT5211 mtouch test. We build for both armv7 and arm64, and the failure we're looking for can happen with either architecture. The order in which the architectures are built is random, and mtouch will fail once the first error occurs, which means that we can't assert that the failure comes from the arm64 build, since the armv7 build might have been executed first (and triggered the error). So just don't assert that the expected error message contains the architecture, which makes the assert valid for both armv7 and armv64. --- tests/mtouch/MTouch.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/mtouch/MTouch.cs b/tests/mtouch/MTouch.cs index 427ae3bcd4ac..36d5eadb7c66 100644 --- a/tests/mtouch/MTouch.cs +++ b/tests/mtouch/MTouch.cs @@ -2998,7 +2998,7 @@ static void Main () mtouch.AssertExecuteFailure (MTouchAction.BuildDev, "build"); - mtouch.AssertOutputPattern ("Undefined symbols for architecture arm64:"); + mtouch.AssertOutputPattern ("Undefined symbols for architecture"); mtouch.AssertOutputPattern (".*_OBJC_METACLASS_._Inexistent., referenced from:.*"); mtouch.AssertOutputPattern (".*_OBJC_METACLASS_._Test_Subexistent in registrar.o.*"); mtouch.AssertOutputPattern (".*_OBJC_CLASS_._Inexistent., referenced from:.*");