This test contains code that requires the dynamic registrar unless the code is
optimized, and it's only optimized if the assembly is linked, which only
happens if linking all assemblies.
So disable the test if dynamic registrar is removed (which happens when all
optimizations are enabled) and the assembly isn't linked.
Fixes https://github.com/xamarin/xamarin-macios/issues/4566.
* [runtime] Don't throw exceptions when checking if a token reference exists (and not finding any). Fixes#3830.
It's not necessarily bad to not be able to find a token reference for a class:
in particular not if we're just checking if a token reference exists. In this
case, don't throw any exceptions, so that the fall-back code path (if no token
references were found) can execute properly.
This scenario occurs when all the following are true:
* The runtime runs into a native object that is exposed in managed as a protocol.
* The native type's managed type does not implement the protocol.
* The dynamic registrar is being used.
Fixes https://github.com/xamarin/xamarin-macios/issues/3830.
* [runtime] Don't lock while calling selectors that can up calling managed code. Fixes#3943.
Instead of locking the framework peer lock while we call release on dying
object, we just lock and then immediately unlock again before calling release.
This enforces an execution order that still strong enough to not run into race
conditions, while at the same time not running into deadlocks.
Fixes https://github.com/xamarin/xamarin-macios/issues/3943.