Skip to content

Instantly share code, notes, and snippets.

@jacksonh
Last active December 10, 2015 00:18
Show Gist options
  • Select an option

  • Save jacksonh/4349576 to your computer and use it in GitHub Desktop.

Select an option

Save jacksonh/4349576 to your computer and use it in GitHub Desktop.
// invoke this in your appdelegate
#if DEBUG
private void ScanForUnresurrectableMonoTouchTypes ()
{
var found_bad = false;
var intptr_ctor = new Type [] { typeof (IntPtr) };
var types = GetType ().Assembly.GetTypes ();
foreach (var t in types) {
if (!t.IsSubclassOf (typeof (NSObject)))
continue;
if (t.GetConstructor (intptr_ctor) != null)
continue;
var mttype = t.BaseType;
while (mttype.Assembly != typeof (NSObject).Assembly)
mttype = mttype.BaseType;
Console.WriteLine ("Found a type with no intptr ctor: '{0}' inherits from: '{1}'", t, mttype);
found_bad = true;
}
if (found_bad)
throw new Exception ("You have NSObject types without IntPtr ctors.");
}
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment