mono/monomac — pull request #86 by aarononeal (2012-11-21 19:36:32+00:00)
Title: Add IsWrapper handling to aid debugging and avoid recursion crash

When a type wraps a native class the IsWrapper property is set on the RegisterAttribute. This informs the runtime that the managed implementation wraps a native class that was already registered with Objective-C as opposed to being a managed class that would be a new registration.

This patch updates the registration logic in Class.cs to check the attribute before registering a new type and to avoid registering if the native class for a wrapped type is not found. This is important because without this check the registration will proceed and calling methods on the type will result in recursion and an eventual crash as the wrapper attempts to invoke Objective-C which turns around and invokes the same method on the wrapper again. This patch avoids that situation and makes it obvious to the caller that the issue is that the native class was not found, probably due to a linker error when setting up the wrapper.