diff --git a/.gitmodules b/.gitmodules index 6f170813180e..36e38e32a682 100644 --- a/.gitmodules +++ b/.gitmodules @@ -8,7 +8,7 @@ [submodule "external/mono"] path = external/mono url = ../../mono/mono.git - branch = 2018-10 + branch = 2019-02 [submodule "external/opentk"] path = external/opentk url = ../../mono/opentk.git diff --git a/Make.config b/Make.config index e0ba5e042a59..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=5.20.0.220 -MAX_MONO_VERSION=5.20.99 -MIN_MONO_URL=https://xamjenkinsartifact.azureedge.net/build-package-osx-mono/2018-10/199/d390bb6901fd29051a065323ace54a8920f24f39/MonoFramework-MDK-5.20.0.220.macos10.xamarin.universal.pkg +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/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=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.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 @@ -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)/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) @@ -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/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/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/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/external/guiunit b/external/guiunit index 9f67042498c8..9affe4813987 160000 --- a/external/guiunit +++ b/external/guiunit @@ -1 +1 @@ -Subproject commit 9f67042498c8a3bc28888c7765a93af9b3475329 +Subproject commit 9affe4813987b009022ab7b10e55f81f4a37344c diff --git a/external/mono b/external/mono index bd6801d40222..cf880be66a2d 160000 --- a/external/mono +++ b/external/mono @@ -1 +1 @@ -Subproject commit bd6801d40222b69966b7c17e4f1674214c435962 +Subproject commit cf880be66a2d1cc8ca34e345114a7f420b7b86ea 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 @@ + + + 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 @@ + 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/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]; diff --git a/src/Foundation/NSUrlSessionHandler.cs b/src/Foundation/NSUrlSessionHandler.cs index adb1dcbc9d05..f4ec9127c55b 100644 --- a/src/Foundation/NSUrlSessionHandler.cs +++ b/src/Foundation/NSUrlSessionHandler.cs @@ -38,7 +38,7 @@ using System.Threading.Tasks; using System.Text; -#if UNIFIED +#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 { @@ -124,7 +124,7 @@ public partial class NSUrlSessionHandler : HttpMessageHandler readonly NSUrlSession session; readonly Dictionary inflightRequests; readonly object inflightRequestsLock = new object (); -#if !MONOMAC && !MONOTOUCH_WATCH +#if !MONOMAC && !__WATCHOS__ readonly bool isBackgroundSession = false; NSObject notificationToken; // needed to make sure we do not hang if not using a background session #endif @@ -150,7 +150,7 @@ public NSUrlSessionHandler (NSUrlSessionConfiguration configuration) if (configuration == null) throw new ArgumentNullException (nameof (configuration)); -#if !MONOMAC && !MONOTOUCH_WATCH +#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); @@ -173,7 +173,7 @@ public NSUrlSessionHandler (NSUrlSessionConfiguration configuration) inflightRequests = new Dictionary (); } -#if !MONOMAC && !MONOTOUCH_WATCH +#if !MONOMAC && !__WATCHOS__ void AddNotification () { @@ -210,7 +210,7 @@ void RemoveInflightData (NSUrlSessionTask task, bool cancel = true) data.Dispose (); inflightRequests.Remove (task); } -#if !MONOMAC && !MONOTOUCH_WATCH +#if !MONOMAC && !__WATCHOS__ // do we need to be notified? If we have not inflightData, we do not if (inflightRequests.Count == 0) RemoveNotification (); @@ -225,7 +225,7 @@ void RemoveInflightData (NSUrlSessionTask task, bool cancel = true) protected override void Dispose (bool disposing) { -#if !MONOMAC && !MONOTOUCH_WATCH +#if !MONOMAC && !__WATCHOS__ // remove the notification if present, method checks against null RemoveNotification (); #endif @@ -253,6 +253,189 @@ public bool DisableCaching { } } + 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; @@ -268,7 +451,7 @@ async Task CreateRequest (HttpRequestMessage request) if (request.Content != null) { stream = await request.Content.ReadAsStreamAsync ().ConfigureAwait (false); - headers = headers.Union (request.Content.Headers).ToArray (); + headers = System.Linq.Enumerable.ToArray(headers.Union (request.Content.Headers)); } var nsrequest = new NSMutableUrlRequest { @@ -305,7 +488,7 @@ protected override async Task SendAsync (HttpRequestMessage var tcs = new TaskCompletionSource (); lock (inflightRequestsLock) { -#if !MONOMAC && !MONOTOUCH_WATCH +#if !MONOMAC && !__WATCHOS__ // Add the notification whenever needed AddNotification (); #endif @@ -342,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; @@ -574,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 (); @@ -615,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; @@ -637,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; @@ -786,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; diff --git a/src/Makefile b/src/Makefile index 1ea3099734a4..c3c6faccdb3e 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 @@ -65,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 @@ -182,65 +186,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) $< $@ - -# -# 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 +206,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,10 +228,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 \ $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/32bits/Xamarin.iOS.pdb \ $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/64bits/Xamarin.iOS.dll \ @@ -402,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 $(TOP)/src/Foundation/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 \ @@ -492,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) @@ -505,25 +443,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 @@ -540,8 +459,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 @@ -587,15 +504,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 $< $@ @@ -661,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 @@ -675,16 +584,18 @@ 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_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 \ @@ -764,46 +675,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) $< $@ - -# 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,12 +703,8 @@ 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 \ - $(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 @@ -874,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 @@ -890,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 \ @@ -979,48 +852,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) $< $@ - -# 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,17 +882,13 @@ 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 \ $(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/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} diff --git a/src/ObjCRuntime/Runtime.cs b/src/ObjCRuntime/Runtime.cs index 63edc7def0bd..a2efc5370190 100644 --- a/src/ObjCRuntime/Runtime.cs +++ b/src/ObjCRuntime/Runtime.cs @@ -1093,7 +1093,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)); diff --git a/src/ObjCRuntime/RuntimeOptions.cs b/src/ObjCRuntime/RuntimeOptions.cs index ff13794d1b5a..81bc70ccee15 100644 --- a/src/ObjCRuntime/RuntimeOptions.cs +++ b/src/ObjCRuntime/RuntimeOptions.cs @@ -5,25 +5,14 @@ #if MTOUCH || MMP using Mono.Cecil; using Xamarin.Linker; -#elif SYSTEM_NET_HTTP || (MONOMAC && XAMCORE_2_0) +#else using System.Net.Http; -#endif - -#if XAMCORE_2_0 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 namespace Xamarin.Bundler { -#elif SYSTEM_NET_HTTP -namespace System.Net.Http { #else namespace ObjCRuntime { #endif @@ -33,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 @@ -47,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; } @@ -56,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) { @@ -73,43 +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); - } - } - - 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); - } -#else - return "System.Net.Http." + http_message_handler + ", System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"; -#endif - } - internal void Write (string app_dir) { // note: we always create the file because the simulator won't remove old files @@ -121,7 +68,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 (""); @@ -157,7 +105,7 @@ 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"); } @@ -165,13 +113,13 @@ internal static TypeDefinition GetHttpMessageHandler (Application app, RuntimeOp 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: @@ -201,40 +149,30 @@ internal static RuntimeOptions Read () return options; } } - -#if SYSTEM_NET_HTTP || (MONOMAC && XAMCORE_2_0) -#if MONOMAC - [Preserve] -#endif + + [Preserve] // always present but re-written by the linker 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); + var handler_name = options?.http_message_handler; +#if __WATCHOS__ + if (handler_name != null && 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 != null && 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/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 deleted file mode 100644 index 93c2a74c7cf6..000000000000 --- a/src/OpenGLES/Makefile.include +++ /dev/null @@ -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/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..1537141784a8 --- /dev/null +++ b/src/System.Net.Http/CFNetworkHandler.cs @@ -0,0 +1,393 @@ +// +// 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 +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 + 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; + // 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); + } + 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); + } + } +} diff --git a/src/btouch.cs b/src/btouch.cs index b8af165dcb07..011624ff37b1 100644 --- a/src/btouch.cs +++ b/src/btouch.cs @@ -351,6 +351,7 @@ int Main3 (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": @@ -359,6 +360,7 @@ int Main3 (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": @@ -367,6 +369,7 @@ int Main3 (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": @@ -375,6 +378,7 @@ int Main3 (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": @@ -382,6 +386,7 @@ int Main3 (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": @@ -398,9 +403,11 @@ int Main3 (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; diff --git a/src/generator.cs b/src/generator.cs index 5d4494c88c05..affc2866a055 100644 --- a/src/generator.cs +++ b/src/generator.cs @@ -2596,6 +2596,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++; + // 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); 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/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 \ 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 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/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/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 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/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 deleted file mode 100644 index 257488044237..000000000000 --- a/tests/bcl-test/BCLTests/macOSFull-xammac_net_4_5_System.Data_test.dll.ignore +++ /dev/null @@ -1,63 +0,0 @@ -# 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 - -# #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 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 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 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 + 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 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 6da83d9128d6..79615d865278 100644 --- a/tests/common/Configuration.cs +++ b/tests/common/Configuration.cs @@ -494,7 +494,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/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 + diff --git a/tests/introspection/ApiCtorInitTest.cs b/tests/introspection/ApiCtorInitTest.cs index beffa3c88b88..187cc3d50b66 100644 --- a/tests/introspection/ApiCtorInitTest.cs +++ b/tests/introspection/ApiCtorInitTest.cs @@ -333,11 +333,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": @@ -345,18 +352,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": @@ -388,19 +395,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 @@ -410,12 +417,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": @@ -430,7 +437,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; case "MPSImageReduceUnary": // Not meant to be used, only subclasses @@ -440,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; } 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/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 @@ + 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/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")] diff --git a/tests/linker/ios/link sdk/LinkSdkRegressionTest.cs b/tests/linker/ios/link sdk/LinkSdkRegressionTest.cs index 036aa3c9c052..08ec2e968f35 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__ @@ -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 { @@ -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) 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 2fb4744dcaa5..b0bfb03cb7ab 100644 --- a/tests/mmptest/src/MMPTest.cs +++ b/tests/mmptest/src/MMPTest.cs @@ -214,10 +214,10 @@ 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); + File.SetAttributes (Path.ChangeExtension (assemblyPath, ".pdb"), FileAttributes.ReadOnly); // build project referencing a.dll TI.UnifiedTestConfig test = new TI.UnifiedTestConfig (tmpDir) @@ -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/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/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 @@ + diff --git a/tests/mtouch/MTouch.cs b/tests/mtouch/MTouch.cs index f902c28fb735..36d5eadb7c66 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."); } } @@ -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) { @@ -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:.*"); @@ -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"); @@ -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 ()) { @@ -3647,7 +3648,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 +3658,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 +3677,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 +3687,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'."); } } @@ -4218,7 +4219,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); } @@ -4228,7 +4229,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) { diff --git a/tests/mtouch/MiscTests.cs b/tests/mtouch/MiscTests.cs index 538b88b92b98..d07b6a2104dc 100644 --- a/tests/mtouch/MiscTests.cs +++ b/tests/mtouch/MiscTests.cs @@ -123,7 +123,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_$_", 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", }) }, }; 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 @@ + 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 (); } diff --git a/tools/bcl-test-importer/BCLTestImporter/BCLTestProjectDefinitionWorkaround.cs b/tools/bcl-test-importer/BCLTestImporter/BCLTestProjectDefinitionWorkaround.cs index 93aba2326a95..99a0149a7b94 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"), @@ -250,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 83e92973ea0c..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"), @@ -112,7 +113,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"), @@ -121,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 { @@ -135,7 +141,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 @@ -185,7 +190,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"), @@ -583,7 +588,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 +976,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)); } } 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")}}, 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/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/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/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" 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; diff --git a/tools/linker/CoreHttpMessageHandler.cs b/tools/linker/CoreHttpMessageHandler.cs index 3a930676841f..9b6b86966b89 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,10 +72,10 @@ 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 + // 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); @@ -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 } } diff --git a/tools/linker/CoreMarkStep.cs b/tools/linker/CoreMarkStep.cs index a2868f115d5a..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; @@ -155,15 +156,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) @@ -281,36 +296,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/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/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/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/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", diff --git a/tools/linker/MonoTouch.Tuner/SealerSubStep.cs b/tools/linker/MonoTouch.Tuner/SealerSubStep.cs index 0ac43943203f..51dc844b5233 100644 --- a/tools/linker/MonoTouch.Tuner/SealerSubStep.cs +++ b/tools/linker/MonoTouch.Tuner/SealerSubStep.cs @@ -109,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) 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 79d096c1137f..2730cedf54c3 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,11 +1315,17 @@ 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 (' '); - 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 (' '); + args.Append ("-u ").Append ("_SystemNative_RealPath").Append (' '); // This keeps libmono_system_native_la-pal_io.o symbols + } else { + // add modern libmono-native string libmono_native_name; switch (App.MonoNativeMode) { case MonoNativeMode.Unified: @@ -1332,13 +1342,6 @@ static int Compile () args.Append ("-framework GSS "); } - // 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 (' '); - args.Append ("-u ").Append ("_SystemNative_RealPath").Append (' '); // This keeps libmono_system_native_la-pal_io.o symbols - } - if (profiling.HasValue && profiling.Value) { args.Append (StringUtils.Quote (Path.Combine (libdir, "libmono-profiler-log.a"))).Append (' '); args.Append ("-u _mono_profiler_init_log -lz "); @@ -1350,7 +1353,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++ "); diff --git a/tools/mmp/mmp.csproj b/tools/mmp/mmp.csproj index ff4285113c42..e727cb4a57e4 100644 --- a/tools/mmp/mmp.csproj +++ b/tools/mmp/mmp.csproj @@ -46,148 +46,169 @@ - + 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\Inflater.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\OverrideInformation.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/Target.cs b/tools/mtouch/Target.cs index 19c31abc6444..5f9d5982f2d7 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; @@ -1727,6 +1719,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) { 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; diff --git a/tools/mtouch/mtouch.csproj b/tools/mtouch/mtouch.csproj index 944d885273c6..a92aa5a0fc2f 100644 --- a/tools/mtouch/mtouch.csproj +++ b/tools/mtouch/mtouch.csproj @@ -79,133 +79,154 @@ MonoTouch.Tuner\RemoveCode.cs - + Linker\XApiReader.cs - + Linker\Annotations.cs - + + Linker\Inflater.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\OverrideInformation.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 @@ -214,7 +235,7 @@ MonoTouch.Tuner\ProcessExportedFields.cs - + Mono.Tuner\CecilRocks.cs @@ -380,10 +401,10 @@ external\maccore\BindingImplAttribute.cs - + Linker\AssemblyUtilities.cs - + Linker\TypeNameParser.cs