Merge remote-tracking branch 'origin/main' into issue-11061

This commit is contained in:
Rolf Bjarne Kvinge 2021-05-20 16:22:50 +02:00
Родитель e3c8ac0a6a 1762888e1d
Коммит b4952521d3
44 изменённых файлов: 325 добавлений и 140 удалений

Просмотреть файл

@ -127,8 +127,8 @@ MACCATALYST_NUGET_VERSION_FULL=$(MACCATALYST_NUGET_VERSION_NO_METADATA)+$(NUGET_
# Xcode version should have both a major and a minor version (even if the minor version is 0)
XCODE_VERSION=12.5
XCODE_URL=https://dl.internalx.com/internal-files/xcodes/Xcode_12.5_Release_Candidate.xip
XCODE_DEVELOPER_ROOT=/Applications/Xcode_12.5.0-rc.app/Contents/Developer
XCODE_URL=https://dl.internalx.com/internal-files/xcodes/Xcode_12.5.xip
XCODE_DEVELOPER_ROOT=/Applications/Xcode_12.5.0.app/Contents/Developer
XCODE_PRODUCT_BUILD_VERSION:=$(shell /usr/libexec/PlistBuddy -c 'Print :ProductBuildVersion' $(XCODE_DEVELOPER_ROOT)/../version.plist)
# Mono version embedded in XI/XM (NEEDED_MONO_VERSION/BRANCH) are specified in mk/mono.mk

Просмотреть файл

@ -29,6 +29,12 @@ xamarin_bridge_initialize ()
{
}
void
xamarin_enable_new_refcount ()
{
// Nothing to do here.
}
bool
xamarin_bridge_vm_initialize (int propertyCount, const char **propertyKeys, const char **propertyValues)
{
@ -399,6 +405,14 @@ xamarin_create_system_entry_point_not_found_exception (const char *entrypoint)
return rv;
}
MonoException *
mono_get_exception_out_of_memory ()
{
MonoException *rv = xamarin_bridge_create_exception (XamarinExceptionTypes_System_OutOfMemoryException, NULL);
LOG_CORECLR (stderr, "%s (%p) => %p\n", __func__, entrypoint, rv);
return rv;
}
MonoMethodSignature *
mono_method_signature (MonoMethod* method)
{

Просмотреть файл

@ -471,8 +471,8 @@
OnlyCoreCLR = true,
},
new XDelegate ("MonoObject *", "IntPtr", "xamarin_bridge_get_method_declaring_type",
"MonoObject *", "IntPtr", "gchandle"
new XDelegate ("MonoObject *", "MonoObject *", "xamarin_bridge_get_method_declaring_type",
"MonoObject *", "MonoObject *", "mobj"
) {
WrappedManagedFunction = "GetMethodDeclaringType",
OnlyDynamicUsage = false,

Просмотреть файл

@ -240,7 +240,9 @@
new Export ("void", "mono_profiler_install_gc",
"MonoProfileGCFunc", "callback",
"MonoProfileGCResizeFunc", "heap_resize_callback"
),
) {
XamarinRuntime = RuntimeMode.MonoVM,
},
new Export ("void", "mono_profiler_load",
"const char *", "desc"
@ -408,7 +410,9 @@
"MonoDomain *", "domain",
"const char *", "base_dir",
"const char *", "config_file_name"
),
) {
XamarinRuntime = RuntimeMode.MonoVM,
},
#endregion
@ -486,12 +490,6 @@
#endregion
#region metadata/mono-gc.h
new Export ("int", "mono_gc_max_generation"),
#endregion
#region metadata/mono-hash.h
new Export ("MonoGHashTable *", "mono_g_hash_table_new_type",
@ -530,7 +528,9 @@
XamarinRuntime = RuntimeMode.MonoVM,
},
new Export ("MonoException *", "mono_get_exception_out_of_memory"),
new Export ("MonoException *", "mono_get_exception_out_of_memory") {
HasCoreCLRBridgeFunction = true,
},
#endregion
@ -563,7 +563,9 @@
new Export ("void", "mono_gc_toggleref_add",
"MonoObject *", "object",
"mono_bool", "strong_ref"
),
) {
XamarinRuntime = RuntimeMode.MonoVM,
},
new Export ("void", "mono_gc_toggleref_register_callback",
"MonoToggleRefCallback", "process_toggleref"
@ -603,11 +605,6 @@
HasCoreCLRBridgeFunction = true,
},
new Export ("void", "mono_jit_parse_options",
"int", "argc",
"char**", "argv"
),
new Export ("void", "mono_jit_set_aot_mode",
"MonoAotMode", "mode"
),

Просмотреть файл

@ -458,7 +458,14 @@ xamarin_main (int argc, char *argv[], enum XamarinLaunchMode launch_mode)
snprintf (base_dir, sizeof (base_dir), "%s/" ARCH_SUBDIR, xamarin_get_bundle_path ());
snprintf (config_file_name, sizeof (config_file_name), "%s/%s.config", base_dir, xamarin_executable_name); // xamarin_executable_name should never be NULL for extensions.
#if defined (CORECLR_RUNTIME)
// Need to figure out how to implement the equivalent of mono_domain_set_config for CoreCLR.
// That will need a test case (app extension), which we haven't implemented for CoreCLR yet.
// It's likely to require a completely different implementation, probably a property passed to coreclr_initialize.
xamarin_assertion_message ("Not implemented for CoreCLR: mono_domain_set_config.");
#else
mono_domain_set_config (mono_domain_get (), base_dir, config_file_name);
#endif
rv = xamarin_extension_main (argc, argv);
break;

Просмотреть файл

@ -419,4 +419,64 @@ xamarin_mono_object_retain (MonoObject *mobj)
#endif // DOTNET
/*
* ToggleRef support
*/
// #define DEBUG_TOGGLEREF 1
static void
gc_register_toggleref (MonoObject *obj, id self, bool isCustomType)
{
// COOP: This is an icall, at entry we're in unsafe mode. Managed memory is accessed, so we stay in unsafe mode.
MONO_ASSERT_GC_UNSAFE;
#ifdef DEBUG_TOGGLEREF
id handle = xamarin_get_nsobject_handle (obj);
PRINT ("**Registering object %p handle %p RC %d flags: %i isCustomType: %i",
obj,
handle,
(int) (handle ? [handle retainCount] : 0),
xamarin_get_nsobject_flags (obj),
isCustomType
);
#endif
mono_gc_toggleref_add (obj, TRUE);
// Make sure the GCHandle we have is a weak one for custom types.
if (isCustomType) {
MONO_ENTER_GC_SAFE;
xamarin_switch_gchandle (self, true);
MONO_EXIT_GC_SAFE;
}
}
static MonoToggleRefStatus
gc_toggleref_callback (MonoObject *object)
{
// COOP: this is a callback called by the GC, so I assume the mode here doesn't matter
MonoToggleRefStatus res;
uint8_t flags = xamarin_get_nsobject_flags (object);
res = xamarin_gc_toggleref_callback (flags, NULL, xamarin_get_nsobject_handle, object);
return res;
}
static void
gc_event_callback (MonoProfiler *prof, MonoGCEvent event, int generation)
{
// COOP: this is a callback called by the GC, I believe the mode here doesn't matter.
xamarin_gc_event (event);
}
void
xamarin_enable_new_refcount ()
{
mono_gc_toggleref_register_callback (gc_toggleref_callback);
xamarin_add_internal_call ("Foundation.NSObject::RegisterToggleRef", (const void *) gc_register_toggleref);
mono_profiler_install_gc (gc_event_callback, NULL);
}
#endif // !CORECLR_RUNTIME

Просмотреть файл

@ -796,51 +796,24 @@ xamarin_type_get_full_name (MonoType *type, GCHandle *exception_gchandle)
* ToggleRef support
*/
// #define DEBUG_TOGGLEREF 1
#if !defined (CORECLR_RUNTIME)
static void
gc_register_toggleref (MonoObject *obj, id self, bool isCustomType)
{
// COOP: This is an icall, at entry we're in unsafe mode. Managed memory is accessed, so we stay in unsafe mode.
MONO_ASSERT_GC_UNSAFE;
#ifdef DEBUG_TOGGLEREF
id handle = xamarin_get_nsobject_handle (obj);
PRINT ("**Registering object %p handle %p RC %d flags: %i isCustomType: %i",
obj,
handle,
(int) (handle ? [handle retainCount] : 0),
xamarin_get_nsobject_flags (obj),
isCustomType
);
#endif
mono_gc_toggleref_add (obj, TRUE);
// Make sure the GCHandle we have is a weak one for custom types.
if (isCustomType) {
MONO_ENTER_GC_SAFE;
xamarin_switch_gchandle (self, true);
MONO_EXIT_GC_SAFE;
}
}
static MonoToggleRefStatus
gc_toggleref_callback (MonoObject *object)
MonoToggleRefStatus
xamarin_gc_toggleref_callback (uint8_t flags, id handle, xamarin_get_handle_func get_handle, MonoObject *info)
{
// COOP: this is a callback called by the GC, so I assume the mode here doesn't matter
id handle = NULL;
MonoToggleRefStatus res;
uint8_t flags = xamarin_get_nsobject_flags (object);
bool disposed = (flags & NSObjectFlagsDisposed) == NSObjectFlagsDisposed;
bool has_managed_ref = (flags & NSObjectFlagsHasManagedRef) == NSObjectFlagsHasManagedRef;
if (disposed || !has_managed_ref) {
res = MONO_TOGGLE_REF_DROP; /* Already disposed, we don't need the managed object around */
} else {
handle = xamarin_get_nsobject_handle (object);
if (handle == NULL)
handle = get_handle (info);
if (handle == NULL) { /* This shouldn't really happen */
return MONO_TOGGLE_REF_DROP;
res = MONO_TOGGLE_REF_DROP;
} else {
if ([handle retainCount] == 1)
res = MONO_TOGGLE_REF_WEAK;
@ -861,21 +834,17 @@ gc_toggleref_callback (MonoObject *object)
rv = "UNKNOWN";
}
const char *cn = NULL;
if (handle == NULL) {
cn = object_getClassName (xamarin_get_nsobject_handle (object));
} else {
cn = object_getClassName (handle);
}
if (handle == NULL)
handle = get_handle (info);
cn = object_getClassName (handle);
PRINT ("\tinspecting %p handle:%p %s flags: %i RC %d -> %s\n", object, handle, cn, (int) flags, (int) (handle ? [handle retainCount] : 0), rv);
#endif
return res;
}
#endif
#if !defined (CORECLR_RUNTIME)
static void
gc_event_callback (MonoProfiler *prof, MonoGCEvent event, int generation)
void
xamarin_gc_event (MonoGCEvent event)
{
// COOP: this is a callback called by the GC, I believe the mode here doesn't matter.
switch (event) {
@ -892,16 +861,6 @@ gc_event_callback (MonoProfiler *prof, MonoGCEvent event, int generation)
}
}
static void
gc_enable_new_refcount (void)
{
mono_gc_toggleref_register_callback (gc_toggleref_callback);
xamarin_add_internal_call ("Foundation.NSObject::RegisterToggleRef", (const void *) gc_register_toggleref);
mono_profiler_install_gc (gc_event_callback, NULL);
}
#endif // !CORECLR_RUNTIME
#if !defined (CORECLR_RUNTIME)
struct _MonoProfiler {
int dummy;
@ -1309,9 +1268,7 @@ xamarin_initialize ()
pthread_mutex_init (&framework_peer_release_lock, &attr);
pthread_mutexattr_destroy (&attr);
#if !defined (CORECLR_RUNTIME)
gc_enable_new_refcount ();
#endif
xamarin_enable_new_refcount ();
MONO_EXIT_GC_UNSAFE;
}

Просмотреть файл

@ -80,6 +80,7 @@ enum XamarinExceptionTypes : int {
XamarinExceptionTypes_System_Exception,
XamarinExceptionTypes_System_InvalidCastException,
XamarinExceptionTypes_System_EntryPointNotFoundException,
XamarinExceptionTypes_System_OutOfMemoryException,
};
extern bool mono_use_llvm; // this is defined inside mono

Просмотреть файл

@ -214,6 +214,7 @@ MonoMethod * xamarin_bridge_get_mono_method (MonoReflectionMethod *method);
void xamarin_bridge_free_mono_signature (MonoMethodSignature **signature);
bool xamarin_register_monoassembly (MonoAssembly *assembly, GCHandle *exception_gchandle);
void xamarin_install_nsautoreleasepool_hooks ();
void xamarin_enable_new_refcount ();
MonoObject * xamarin_new_nsobject (id self, MonoClass *klass, GCHandle *exception_gchandle);
bool xamarin_has_managed_ref (id self);
@ -286,6 +287,10 @@ MonoObject * xamarin_gchandle_get_target (GCHandle handle);
void xamarin_gchandle_free (GCHandle handle);
MonoObject * xamarin_gchandle_unwrap (GCHandle handle); // Will get the target and free the GCHandle
typedef id (*xamarin_get_handle_func) (MonoObject *info);
MonoToggleRefStatus xamarin_gc_toggleref_callback (uint8_t flags, id handle, xamarin_get_handle_func get_handle, MonoObject *info);
void xamarin_gc_event (MonoGCEvent event);
/*
* In MonoVM MonoObjects are tracked in memory/the stack directly by the GC, but that doesn't
* work for CoreCLR, so we make it ref-counted. All code must use the functions below to retain/release

22
src/AdSupport/ASCompat.cs Normal file
Просмотреть файл

@ -0,0 +1,22 @@
#if !XAMCORE_4_0
using System;
using System.Runtime.Versioning;
namespace AdSupport {
public partial class ASIdentifierManager {
#if MONOMAC
#if NET
[UnsupportedOSPlatform ("macos")]
#endif
[Obsolete ("Empty stub. This member was retroactively marked as unavailable for macOS.")]
public virtual void ClearAdvertisingIdentifier ()
{
}
#endif
}
}
#endif

Просмотреть файл

@ -3,5 +3,8 @@
<type fullname="ObjCRuntime.Runtime">
<method signature="System.Boolean get_IsCoreCLR()" body="stub" value="false" />
</type>
<type fullname="UIKit.UIButton">
<method signature="System.Void VerifyIsUIButton()" body="stub" feature="System.Diagnostics.Debugger.IsSupported" featurevalue="false" />
</type>
</assembly>
</linker>

Просмотреть файл

@ -3,5 +3,8 @@
<type fullname="ObjCRuntime.Runtime">
<method signature="System.Boolean get_IsCoreCLR()" body="stub" value="false" />
</type>
<type fullname="UIKit.UIButton">
<method signature="System.Void VerifyIsUIButton()" body="stub" feature="System.Diagnostics.Debugger.IsSupported" featurevalue="false" />
</type>
</assembly>
</linker>

Просмотреть файл

@ -140,7 +140,7 @@ IOS_CORE_DEFINES=-define:COREBUILD $(IOS_DEFINES)
$(IOS_BUILD_DIR)/Constants.cs: Constants.iOS.cs.in Makefile $(TOP)/Make.config.inc | $(IOS_BUILD_DIR)
$(call Q_PROF_GEN,ios) sed \
-e "s/@VERSION@/$(IOS_PACKAGE_VERSION_MAJOR).$(IOS_PACKAGE_VERSION_MINOR).$(IOS_PACKAGE_VERSION_REV)/g" \
-e 's/@REVISION@/$(IOS_COMMIT_DISTANCE) ($(CURRENT_BRANCH_SED_ESCAPED): $(shell git log -1 --pretty=%h)/g' \
-e 's/@REVISION@/$(IOS_COMMIT_DISTANCE) ($(CURRENT_BRANCH_SED_ESCAPED): $(shell git log -1 --pretty=%h))/g' \
-e "s/@IOS_SDK_VERSION@/$(IOS_SDK_VERSION)/g" \
$< > $@
@ -479,7 +479,7 @@ MAC_HTTP_SOURCES = \
$(MAC_BUILD_DIR)/Constants.cs: Constants.mac.cs.in Makefile $(TOP)/Make.config.inc | $(MAC_BUILD_DIR)
$(Q) sed \
-e "s/@VERSION@/$(MAC_PACKAGE_VERSION_MAJOR).$(MAC_PACKAGE_VERSION_MINOR).$(MAC_PACKAGE_VERSION_REV)/g" \
-e 's/@REVISION@/$(MAC_COMMIT_DISTANCE) ($(CURRENT_BRANCH_SED_ESCAPED): $(shell git log -1 --pretty=%h)/g' \
-e 's/@REVISION@/$(MAC_COMMIT_DISTANCE) ($(CURRENT_BRANCH_SED_ESCAPED): $(shell git log -1 --pretty=%h))/g' \
-e "s/@OSX_SDK_VERSION@/$(OSX_SDK_VERSION)/g" \
-e "s/@MIN_XM_MONO_VERSION@/$(MIN_XM_MONO_VERSION)/g" \
$< > $@
@ -769,7 +769,7 @@ WATCHOS_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 \
-e "s/@VERSION@/$(IOS_PACKAGE_VERSION_MAJOR).$(IOS_PACKAGE_VERSION_MINOR).$(IOS_PACKAGE_VERSION_REV)/g" \
-e 's/@REVISION@/$(IOS_COMMIT_DISTANCE) ($(CURRENT_BRANCH_SED_ESCAPED): $(shell git log -1 --pretty=%h)/g' \
-e 's/@REVISION@/$(IOS_COMMIT_DISTANCE) ($(CURRENT_BRANCH_SED_ESCAPED): $(shell git log -1 --pretty=%h))/g' \
-e "s/@WATCH_SDK_VERSION@/$(WATCH_SDK_VERSION)/g" \
$< > $@
@ -1058,7 +1058,7 @@ TVOS_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 \
-e "s/@VERSION@/$(IOS_PACKAGE_VERSION_MAJOR).$(IOS_PACKAGE_VERSION_MINOR).$(IOS_PACKAGE_VERSION_REV)/g" \
-e 's/@REVISION@/$(IOS_COMMIT_DISTANCE) ($(CURRENT_BRANCH_SED_ESCAPED): $(shell git log -1 --pretty=%h)/g' \
-e 's/@REVISION@/$(IOS_COMMIT_DISTANCE) ($(CURRENT_BRANCH_SED_ESCAPED): $(shell git log -1 --pretty=%h))/g' \
-e "s/@TVOS_SDK_VERSION@/$(TVOS_SDK_VERSION)/g" \
$< > $@
@ -1268,7 +1268,7 @@ MACCATALYST_SOURCES += \
$(MACCATALYST_BUILD_DIR)/Constants.cs: $(TOP)/src/Constants.maccatalyst.cs.in Makefile $(TOP)/Make.config.inc | $(MACCATALYST_BUILD_DIR)
$(call Q_PROF_GEN,maccatalyst) sed \
-e "s/@VERSION@/$(IOS_PACKAGE_VERSION_MAJOR).$(IOS_PACKAGE_VERSION_MINOR).$(IOS_PACKAGE_VERSION_REV)/g" \
-e 's/@REVISION@/$(IOS_COMMIT_DISTANCE) ($(CURRENT_BRANCH_SED_ESCAPED): $(shell git log -1 --pretty=%h)/g' \
-e 's/@REVISION@/$(IOS_COMMIT_DISTANCE) ($(CURRENT_BRANCH_SED_ESCAPED): $(shell git log -1 --pretty=%h))/g' \
-e "s/@MACCATALYST_SDK_VERSION@/$(MACCATALYST_SDK_VERSION)/g" \
$< > $@

Просмотреть файл

@ -42,6 +42,7 @@ namespace ObjCRuntime {
System_Exception,
System_InvalidCastException,
System_EntryPointNotFoundException,
System_OutOfMemoryException,
}
// This struct must be kept in sync with the _MonoObject struct in coreclr-bridge.h
@ -89,6 +90,9 @@ namespace ObjCRuntime {
case ExceptionType.System_EntryPointNotFoundException:
rv = new System.EntryPointNotFoundException (str0);
break;
case ExceptionType.System_OutOfMemoryException:
rv = new System.OutOfMemoryException ();
break;
default:
throw new ArgumentOutOfRangeException (nameof (type));
}
@ -337,10 +341,10 @@ namespace ObjCRuntime {
return (byte) obj.FlagsInternal;
}
static IntPtr GetMethodDeclaringType (MonoObjectPtr mobj)
static unsafe MonoObject* GetMethodDeclaringType (MonoObject *mobj)
{
var method = (MethodBase) GetMonoObjectTarget (mobj);
return GetMonoObject (method.DeclaringType);
return (MonoObject *) GetMonoObject (method.DeclaringType);
}
static IntPtr ObjectGetType (MonoObjectPtr mobj)

Просмотреть файл

@ -32,6 +32,7 @@ namespace AdSupport {
NSUuid AdvertisingIdentifier { get; }
[NoTV][NoiOS]
[NoMac] // unclear when that was changed (xcode 12 GM allowed it)
[Export ("clearAdvertisingIdentifier")]
void ClearAdvertisingIdentifier ();
}

Просмотреть файл

@ -64,6 +64,11 @@ ADDRESSBOOKUI_SOURCES = \
AddressBookUI/ABUnknownPersonViewController.cs \
AddressBookUI/DisplayedPropertiesCollection.cs \
# AdSupport
ADSUPPORT_SOURCES = \
AdSupport/ASCompat.cs \
# AppKit
APPKIT_CORE_SOURCES = \

Просмотреть файл

@ -108,6 +108,7 @@ test.config: Makefile $(TOP)/Make.config $(TOP)/mk/mono.mk
@echo "WATCH_SDK_VERSION=$(WATCH_SDK_VERSION)" >> $@
@echo "OSX_SDK_VERSION=$(OSX_SDK_VERSION)" >> $@
@echo "DOTNET6_BCL_DIR=$(DOTNET6_BCL_DIR)" >> $@
@echo "ENABLE_DOTNET=$(ENABLE_DOTNET)" >> $@
test-system.config: Makefile $(TOP)/Make.config $(TOP)/mk/mono.mk
@rm -f $@

Просмотреть файл

@ -26,6 +26,9 @@ namespace XamarinTests.ObjCRuntime {
}
[Test]
#if NET
[Ignore ("Ignored on CoreCLR for now due to missing support for marshalling exceptions")]
#endif
public void IntPtrCtor ()
{
IntPtr ptr = IntPtr.Zero;

Просмотреть файл

@ -42,6 +42,7 @@ namespace Xamarin.Tests
public static bool include_dotnet_watchos;
public static bool include_maccatalyst;
public static bool include_device;
public static bool include_dotnet;
static Version xcode_version;
public static Version XcodeVersion {
@ -270,6 +271,7 @@ namespace Xamarin.Tests
include_dotnet_watchos = !string.IsNullOrEmpty (GetVariable ("INCLUDE_DOTNET_WATCH", ""));
include_maccatalyst = !string.IsNullOrEmpty (GetVariable ("INCLUDE_MACCATALYST", ""));
include_device = !string.IsNullOrEmpty (GetVariable ("INCLUDE_DEVICE", ""));
include_dotnet = !string.IsNullOrEmpty (GetVariable ("ENABLE_DOTNET", ""));
DotNet6BclDir = GetVariable ("DOTNET6_BCL_DIR", null);
XcodeVersionString = GetXcodeVersion (xcode_root);
@ -294,6 +296,7 @@ namespace Xamarin.Tests
Console.WriteLine (" INCLUDE_TVOS={0}", include_tvos);
Console.WriteLine (" INCLUDE_WATCHOS={0}", include_watchos);
Console.WriteLine (" INCLUDE_MACCATALYST={0}", include_maccatalyst);
Console.WriteLine (" ENABLE_DOTNET={0}", include_dotnet);
}
public static string RootPath {
@ -700,6 +703,13 @@ namespace Xamarin.Tests
Assert.Ignore ("This build does not include device support.");
}
public static void AssertDotNetAvailable ()
{
if (include_dotnet)
return;
Assert.Ignore (".NET tests not enabled");
}
public static string CloneTestDirectory (string directory)
{
// Copy the test projects to a temporary directory so that we can run the tests from there without affecting the working directory.

Просмотреть файл

@ -1025,18 +1025,16 @@ namespace LinkSdk {
#endif
#if !__WATCHOS__
static Type type_uibutton = typeof (UIButton);
[Test]
#if NET
[Ignore ("Not implemented yet: https://github.com/xamarin/xamarin-macios/issues/9612")]
#endif
public void UIButtonSubclass ()
{
// ensure the linker keeps the .ctor(UIButtonType) around
using (var b = new UIButton (UIButtonType.Custom)) {
// https://trello.com/c/Nf2B8mIM/484-remove-debug-code-in-the-linker
var m = type_uibutton.GetMethod ("VerifyIsUIButton", BindingFlags.Instance | BindingFlags.NonPublic);
var m = b.GetType ().GetMethod ("VerifyIsUIButton", BindingFlags.Instance | BindingFlags.NonPublic);
#if NET
CheckILLinkStubbedMethod (m);
#else // NET
#if DEBUG
// kept in debug builds
Assert.NotNull (m, "VerifyIsUIButton");
@ -1044,11 +1042,30 @@ namespace LinkSdk {
// removed from release builds
Assert.Null (m, "VerifyIsUIButton");
#endif
#endif // NET
}
}
#endif // !__WATCHOS__
#if NET
static void CheckILLinkStubbedMethod (MethodInfo m)
{
// ILLink does not remove the method, but it can "stub" (empty) it
Assert.NotNull (m, "Method not found (null");
var mb = m.GetMethodBody ();
Assert.NotNull (m, "GetMethodBody");
var il = mb.GetILAsByteArray ();
#if DEBUG
// means some stuff in addition to the `ret` instruction
Assert.That (il.Length, Is.GreaterThan (1), "il > 1");
#else
// empty means a `ret` instruction (and that's true even if IL is stripped)
Assert.That (il.Length, Is.EqualTo (1), "il == 1");
#endif
}
#endif
[Test]
public void MonoRuntime34671 ()
{

Просмотреть файл

@ -85,6 +85,9 @@ namespace MonoTouchFixtures.ObjCRuntime {
// Simulator/desktop only (except for watchOS, where it works everywhere)
[Test]
#if NET
[Ignore ("Ignored on CoreCLR for now due to missing support for marshalling exceptions")]
#endif
public void ObjCException ()
{
#if !__WATCHOS__ && !__MACOS__
@ -131,6 +134,9 @@ namespace MonoTouchFixtures.ObjCRuntime {
// Simulator/desktop only test (except for watchOS, where it works everywhere)
[Test]
#if NET
[Ignore ("Ignored on CoreCLR for now due to missing support for marshalling exceptions")]
#endif
public void ManagedExceptionPassthrough ()
{
Exception thrownException = null;

Просмотреть файл

@ -433,6 +433,9 @@ namespace MonoTouchFixtures.ObjCRuntime {
}
[Test]
#if NET
[Ignore ("Ignored on CoreCLR for now due to missing support for marshalling exceptions")]
#endif
public void TestGeneric ()
{
var g1 = new GenericTestClass<string> ();
@ -1240,6 +1243,9 @@ namespace MonoTouchFixtures.ObjCRuntime {
}
[Test]
#if NET
[Ignore ("Ignored on CoreCLR for now due to missing support for marshalling exceptions")]
#endif
public void TestConstrainedGenericType ()
{
IntPtr value;
@ -2148,7 +2154,11 @@ namespace MonoTouchFixtures.ObjCRuntime {
[Test]
public void CustomUserTypeWithDynamicallyLoadedAssembly ()
{
#if NET
var customTypeAssemblyPath = global::System.IO.Path.Combine (global::Xamarin.Tests.Configuration.RootPath, "tests", "test-libraries", "custom-type-assembly", ".libs", "dotnet", "macos", "custom-type-assembly.dll");
#else
var customTypeAssemblyPath = global::System.IO.Path.Combine (global::Xamarin.Tests.Configuration.RootPath, "tests", "test-libraries", "custom-type-assembly", ".libs", "macos", "custom-type-assembly.dll");
#endif
Assert.That (customTypeAssemblyPath, Does.Exist, "existence");
var size = 10;

Просмотреть файл

@ -579,6 +579,9 @@ namespace MonoTouchFixtures.ObjCRuntime {
}
[Test]
#if NET
[Ignore ("Ignored on CoreCLR for now due to missing support for marshalling exceptions")]
#endif
public void MX8029 ()
{
var handle = Messaging.IntPtr_objc_msgSend (Messaging.IntPtr_objc_msgSend (Class.GetHandle (typeof (Dummy)), Selector.GetHandle ("alloc")), Selector.GetHandle ("init"));
@ -613,6 +616,9 @@ namespace MonoTouchFixtures.ObjCRuntime {
#if DYNAMIC_REGISTRAR
[Test]
#if NET
[Ignore ("Ignored on CoreCLR for now due to missing support for marshalling exceptions")]
#endif
public void MX8029_b ()
{
try {
@ -634,6 +640,9 @@ Additional information:
}
[Test]
#if NET
[Ignore ("Ignored on CoreCLR for now due to missing support for marshalling exceptions")]
#endif
public void MX8033 ()
{
try {

Просмотреть файл

@ -137,6 +137,9 @@ namespace MonoTouchFixtures.Security {
}
[Test]
#if NET
[Ignore ("Fails on ARM64 due to: https://github.com/xamarin/xamarin-macios/issues/11498)")]
#endif
public void SslSupportedCiphers ()
{
TestRuntime.AssertSystemVersion (PlatformName.MacOSX, 10, 8, throwIfOtherPlatform: false);

Просмотреть файл

@ -51,6 +51,8 @@ namespace Xamarin.iOS.Tasks {
[TestCase ("MyXamarinFormsApp")]
public void CompareBuilds (string project, int expectedErrorCount = 0)
{
Configuration.AssertDotNetAvailable ();
tfi = "Xamarin.iOS";
switch (project) {
case "MyMetalGame":

Просмотреть файл

@ -3,12 +3,24 @@ TOP=../../..
include $(TOP)/Make.config
.libs/macos/custom-type-assembly.dll: custom-type-assembly.cs Makefile | .libs/macos
$(MAC_mobile_CSC) $< -out:$@ -r:$(TOP)/_mac-build/Library/Frameworks/Xamarin.Mac.framework/Versions/Current/lib/mono/Xamarin.Mac/Xamarin.Mac.dll -target:library
$(Q_CSC) $(MAC_mobile_CSC) $< -out:$@ -r:$(TOP)/_mac-build/Library/Frameworks/Xamarin.Mac.framework/Versions/Current/lib/mono/Xamarin.Mac/Xamarin.Mac.dll -target:library
.libs/macos:
.libs/dotnet/macos/custom-type-assembly.dll: custom-type-assembly.cs Makefile | .libs/dotnet/macos
$(Q_CSC) $(DOTNET6_CSC) $< -out:$@ -r:$(TOP)/_build/Microsoft.macOS.Ref/ref/net6.0/Xamarin.Mac.dll -target:library -r:$(DOTNET6_BCL_DIR)/System.Runtime.dll /nologo
.libs/macos .libs/dotnet/macos:
$(Q) mkdir -p $@
ifdef INCLUDE_XAMARIN_LEGACY
TARGETS += \
.libs/macos/custom-type-assembly.dll \
endif
ifdef ENABLE_DOTNET
TARGETS += \
.libs/dotnet/macos/custom-type-assembly.dll \
endif
build-assembly: $(TARGETS)

Просмотреть файл

@ -132,6 +132,7 @@ namespace Xharness {
public string MONO_IOS_SDK_DESTDIR { get; }
public string MONO_MAC_SDK_DESTDIR { get; }
public bool ENABLE_XAMARIN { get; }
public bool ENABLE_DOTNET { get; }
// Run
@ -203,6 +204,7 @@ namespace Xharness {
MONO_IOS_SDK_DESTDIR = config ["MONO_IOS_SDK_DESTDIR"];
MONO_MAC_SDK_DESTDIR = config ["MONO_MAC_SDK_DESTDIR"];
ENABLE_XAMARIN = config.ContainsKey ("ENABLE_XAMARIN") && !string.IsNullOrEmpty (config ["ENABLE_XAMARIN"]);
ENABLE_DOTNET = config.ContainsKey ("ENABLE_DOTNET") && !string.IsNullOrEmpty (config ["ENABLE_DOTNET"]);
if (string.IsNullOrEmpty (SdkRoot))
SdkRoot = config ["XCODE_DEVELOPER_ROOT"] ?? configuration.SdkRoot;

Просмотреть файл

@ -43,6 +43,7 @@ namespace Xharness {
string MONO_IOS_SDK_DESTDIR { get; }
string MONO_MAC_SDK_DESTDIR { get; }
bool ENABLE_XAMARIN { get; }
bool ENABLE_DOTNET { get; }
string XcodeRoot { get; }
string LogDirectory { get; }
double Timeout { get; }

Просмотреть файл

@ -1,4 +1,4 @@
using System;
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;

Просмотреть файл

@ -327,6 +327,11 @@ namespace Xharness.Jenkins {
MainLog.WriteLine ("The macOS build is disabled, so any macOS tests will be disabled as well.");
jenkins.IncludeMac = false;
}
if (!Harness.ENABLE_DOTNET) {
MainLog.WriteLine ("The .NET build is disabled, so any .NET tests will be disabled as well.");
jenkins.IncludeDotNet = false;
}
}
}
}

Просмотреть файл

@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.DotNet.XHarness.Common.Execution;
using Microsoft.DotNet.XHarness.Common.Logging;
@ -14,6 +15,7 @@ namespace Xharness.Jenkins.TestTasks {
public bool SpecifyPlatform { get; set; } = true;
public bool SpecifyConfiguration { get; set; } = true;
public List<string> Constants { get; } = new List<string> ();
public BuildTool (IProcessManager processManager)
{

Просмотреть файл

@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.DotNet.XHarness.Common.Execution;
using Microsoft.DotNet.XHarness.Common.Logging;
@ -33,6 +34,10 @@ namespace Xharness.Jenkins.TestTasks {
set => buildToolTask.SpecifyConfiguration = value;
}
public List<string> Constants {
get => buildToolTask.Constants;
}
public override TestProject TestProject {
get => base.TestProject;
set {

Просмотреть файл

@ -32,6 +32,8 @@ namespace Xharness.Jenkins.TestTasks {
if (Platform == TestPlatform.MacCatalyst)
args.Add ("/r");
args.Add (projectFile);
if (Constants.Count > 0)
args.Add($"/p:DefineConstants=\"{string.Join(";", Constants)}\"");
return args;
}

Просмотреть файл

@ -1,3 +1,4 @@
## macOS only (deprecated in 10.13) without any catalyst annotations (headers or web docs)
!missing-field! ACAccountTypeIdentifierLinkedIn not bound
!missing-field! ACLinkedInAppIdKey not bound
!missing-field! ACLinkedInPermissionsKey not bound

Просмотреть файл

@ -0,0 +1,3 @@
## weird case, it was available on macOS (xcode12 GM) but later removed so it's not in iOS, tvOS or macOS
## there's no annotation specific for Catalyst but it does not make sense to have it
!missing-selector! ASIdentifierManager::clearAdvertisingIdentifier not bound

Просмотреть файл

@ -1 +0,0 @@
!missing-selector! ASIdentifierManager::clearAdvertisingIdentifier not bound

Просмотреть файл

@ -1,3 +1,4 @@
## macOS only (added in 10.15) without any catalyst annotations (headers or web docs)
!missing-protocol! ASWebAuthenticationSessionWebBrowserSessionHandling not bound
!missing-selector! +ASWebAuthenticationSessionWebBrowserSessionManager::sharedManager not bound
!missing-selector! ASWebAuthenticationSessionWebBrowserSessionManager::sessionHandler not bound

Просмотреть файл

@ -11,6 +11,7 @@ steps:
- checkout: self # https://docs.microsoft.com/en-us/azure/devops/pipelines/yaml-schema?view=azure-devops&tabs=schema#checkout
clean: true # Executes: git clean -ffdx && git reset --hard HEAD
submodules: false
persistCredentials: true
- pwsh: |
Import-Module $Env:SYSTEM_DEFAULTWORKINGDIRECTORY/tools/devops/automation/scripts/GitHub.psm1
@ -155,6 +156,15 @@ steps:
continueOnError: true
workingDirectory: $(Build.SourcesDirectory)\tools\devops
- powershell: |
git config user.email "valco@microsoft.com"
git config user.name "vs-mobiletools-engineering-service2"
git checkout -b Localization origin/Localization
git merge origin/main
git push origin Localization
displayName: "Sync Localization branch with main"
condition: and(succeeded(), in(variables['build.reason'], 'Schedule', 'Manual'), eq(variables.isMain, 'True'))
- task: OneLocBuild@2
condition: and(succeeded(), eq(variables.isMain, 'True'))
continueOnError: true

Просмотреть файл

@ -3,10 +3,6 @@ parameters:
type: boolean
default: true
- name: apiGeneratorDiffBuilt
type: boolean
default: true
steps:
- checkout: self
@ -32,32 +28,28 @@ steps:
archiveFilePatterns: '$(System.DefaultWorkingDirectory)/Reports/apidiff-stable/apidiff-stable.zip'
destinationFolder: '$(System.DefaultWorkingDirectory)/apidiff-stable'
- ${{ if eq(parameters.apiGeneratorDiffBuilt, true) }}:
- task: DownloadPipelineArtifact@2
displayName: 'Download API & Generator comparison'
inputs:
patterns: 'apicomparison/apicomparison.zip'
allowFailedBuilds: true
path: $(System.DefaultWorkingDirectory)/Reports
- task: DownloadPipelineArtifact@2
displayName: 'Download API & Generator comparison'
condition: and(succeeded(), contains(variables.API_GENERATOR_DIFF_BUILT, 'True'))
inputs:
patterns: 'apicomparison/apicomparison.zip'
allowFailedBuilds: true
path: $(System.DefaultWorkingDirectory)/Reports
- task: ExtractFiles@1
displayName: 'Extract API & Generator comparison'
inputs:
archiveFilePatterns: '$(System.DefaultWorkingDirectory)/Reports/apicomparison/apicomparison.zip'
destinationFolder: '$(System.DefaultWorkingDirectory)/apicomparison'
- task: ExtractFiles@1
displayName: 'Extract API & Generator comparison'
condition: and(succeeded(), contains(variables.API_GENERATOR_DIFF_BUILT, 'True'))
inputs:
archiveFilePatterns: '$(System.DefaultWorkingDirectory)/Reports/apicomparison/apicomparison.zip'
destinationFolder: '$(System.DefaultWorkingDirectory)/apicomparison'
- powershell: |
Write-Host "##vso[task.setvariable variable=STABLE_APIDDIFF_PATH]$Env:SYSTEM_DEFAULTWORKINGDIRECTORY\apidiff-stable"
if ($Env:apiGeneratorDiffBuilt -eq "True") {
if ($Env:API_GENERATOR_DIFF_BUILT -eq "True") {
Write-Host "##vso[task.setvariable variable=STABLE_APID_GENERATOR_DIFF_PATH]$Env:SYSTEM_DEFAULTWORKINGDIRECTORY\apicomparison"
}
displayName: Publish apidiff paths
name: apidiff # not to be confused with the displayName, this is used to later use the name of the step to access the output variables from an other job
env:
${{ if eq(parameters.apiGeneratorDiffBuilt, true) }}:
apiGeneratorDiffBuilt: 'True'
${{ if ne(parameters.apiGeneratorDiffBuilt, true) }}:
apiGeneratorDiffBuilt: 'False'
# download the artifacts.json, which will use to find the URI of the built pkg to later be given to the user
- task: DownloadPipelineArtifact@2

Просмотреть файл

@ -29,10 +29,6 @@ parameters:
type: boolean
default: true
- name: apiGeneratorDiffBuilt
type: string
default: true
steps:
- checkout: self
@ -41,7 +37,6 @@ steps:
- template: download-artifacts.yml
parameters:
runTests: ${{ parameters.runTests }}
apiGeneratorDiffBuilt: ${{ contains(parameters.apiGeneratorDiffBuilt, 'True') }}
- ${{ if eq(parameters.runTests, true) }}:
- pwsh: |

Просмотреть файл

@ -135,6 +135,9 @@ jobs:
dependsOn: build # can start as soon as the tests are done
condition: and(succeededOrFailed() , contains (dependencies.build.outputs['runTests.TESTS_RAN'], 'True')) # only run when we did run the tests
variables:
API_GENERATOR_DIFF_BUILT: $[ dependencies.build.outputs['apiGeneratorDiff.API_GENERATOR_BUILT'] ]
pool:
vmImage: 'windows-latest'
workspace:
@ -144,7 +147,6 @@ jobs:
parameters:
devicePrefix: sim
runTests: ${{ parameters.runTests }}
apiGeneratorDiffBuilt: $[ dependencies.build.outputs['apiGeneratorDiff.API_GENERATOR_BUILT'] ]
- job: upload_vsts_tests
displayName: 'Upload xml to vsts'
@ -179,6 +181,7 @@ jobs:
TESTS_JOBSTATUS: $[ dependencies.build.outputs['runTests.TESTS_JOBSTATUS'] ]
APIDIFF_MESSAGE: $[ dependencies.build.outputs['apidiff.APIDIFF_MESSAGE'] ]
APIDIFF_BUILT: $[ dependencies.build.outputs['apidiff.APIDIFF_BUILT'] ]
API_GENERATOR_DIFF_BUILT: $[ dependencies.build.outputs['apiGeneratorDiff.API_GENERATOR_BUILT'] ]
PR_ID: $[ dependencies.configure.outputs['labels.pr-number'] ]
pool:
vmImage: 'windows-latest'
@ -190,5 +193,4 @@ jobs:
statusContext: "Build"
runTests: ${{ parameters.runTests }}
vsdropsPrefix: ${{ parameters.vsdropsPrefix }}
apiGeneratorDiffBuilt: $[ dependencies.build.outputs['apiGeneratorDiff.API_GENERATOR_BUILT'] ]
devicePrefix: sim

Просмотреть файл

@ -10,10 +10,6 @@ parameters:
type: boolean
default: true
- name: apiGeneratorDiffBuilt
type: string
default: true
steps:
- checkout: self
@ -22,7 +18,6 @@ steps:
- template: download-artifacts.yml
parameters:
runTests: ${{ parameters.runTests }}
apiGeneratorDiffBuilt: ${{ contains(parameters.apiGeneratorDiffBuilt, 'True') }}
# Upload full report to vsdrops using the the build numer and id as uuids.
- ${{ if eq(parameters.runTests, true) }}:
@ -47,13 +42,13 @@ steps:
detailedLog: true
usePat: true
- ${{ if contains(parameters.apiGeneratorDiffBuilt, 'True') }}:
- task: ms-vscs-artifact.build-tasks.artifactDropTask-1.artifactDropTask@0
displayName: 'Publish API & Generator comparisonn to Artifact Services Drop'
inputs:
dropServiceURI: 'https://devdiv.artifacts.visualstudio.com/DefaultCollection'
dropMetadataContainerName: 'DropMetadata-APIGeneratorDiff'
buildNumber: 'xamarin-macios/device-tests/$(Build.BuildNumber)/$(Build.BuildId)/APIGeneratorDiff'
sourcePath: $(STABLE_APID_GENERATOR_DIFF_PATH)
detailedLog: true
usePat: true
- task: ms-vscs-artifact.build-tasks.artifactDropTask-1.artifactDropTask@0
displayName: 'Publish API & Generator comparisonn to Artifact Services Drop'
condition: and(succeeded(), contains(variables.API_GENERATOR_DIFF_BUILT, 'True'))
inputs:
dropServiceURI: 'https://devdiv.artifacts.visualstudio.com/DefaultCollection'
dropMetadataContainerName: 'DropMetadata-APIGeneratorDiff'
buildNumber: 'xamarin-macios/device-tests/$(Build.BuildNumber)/$(Build.BuildId)/APIGeneratorDiff'
sourcePath: $(STABLE_APID_GENERATOR_DIFF_PATH)
detailedLog: true
usePat: true

Просмотреть файл

@ -19,9 +19,10 @@ steps:
path: $(Build.SourcesDirectory)/build-configuration
- pwsh: |
$configFile = Join-Path $(Build.SourcesDirectory) build-configuration
$configFile = Join-Path $(Build.SourcesDirectory) "build-configuration" "configuration.json"
$config = Get-Content $configFile | ConvertFrom-Json
# export variables to be present in the othe steps
Write-Host "##vso[task.setvariable variable=BuildReason;isOutput=true]$($config.BuildReason)"
Write-Host "##vso[task.setvariable variable=BuildSourceBranchName;isOutput=true]$($config.BuildSourceBranchName)"
Write-Host "##vso[task.setvariable variable=BuildSourceBranch;isOutput=true]$($config.BuildSourceBranch)"
Write-Host "##vso[task.setvariable variable=BuildId;isOutput=true]$($config.BuildId)"
@ -31,6 +32,26 @@ steps:
timeoutInMinutes: 1
- pwsh: |
Write-Host "Work in progress"
git config user.email "valco@microsoft.com"
git config user.name "vs-mobiletools-engineering-service2"
$branchName = "$Env:OriginalSourceBranch/$Env:OriginalCommit/$Env:OriginalBuildId"
if (Env:OriginalBuildReason -eq "PullRequest") {
$branchName = "pr/$branchName"
} else {
$branchName = "ci/$branchName"
}
Write-Host "New branch name: $branchName"
$htmlRepo = Join-Path $(Build.SourcesDirectory) "macios.ci"
cd $htmlRepo
git checkout -b $branchName
displayName: 'Create remote branch'
timeoutInMinutes: 1
env:
OriginalBuildReason: $(configuration.BuildReason)
OriginalSourceBranch: $(configuration.BuildSourceBranchName)
OriginalBuildId: $(configuration.BuildId)
OriginalCommit: $(configuration.Commit)

Просмотреть файл

@ -103,9 +103,6 @@ Xamarin.Mac.registrar.full.arm64.m: $(TOP)/src/build/mac/full-64/Xamarin.Mac.d
$(GENERATE_PART_REGISTRAR) --arch=arm64 --target-framework Xamarin.Mac,Version=v4.5,Profile=Full -a:$(FULL_BCL_DIR)/mscorlib.dll
$(Q) touch Xamarin.Mac.registrar.full.arm64.m Xamarin.Mac.registrar.full.arm64.h
%.coreclr.x86_64.a: export EXTRA_DEFINES=-DCORECLR_RUNTIME
%.coreclr.arm64.a: export EXTRA_DEFINES=-DCORECLR_RUNTIME
%.x86_64.a: %.x86_64.m
$(Q_CC) $(MAC_CC) -DDEBUG -g -gdwarf-2 -x objective-c++ -std=c++14 -o $@ -c -arch x86_64 $< -Wall -Wno-unguarded-availability-new -I$(TOP)/runtime -mmacosx-version-min=$(MIN_OSX_SDK_VERSION) -fobjc-runtime=macosx $(EXTRA_DEFINES)