Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
Mono organizations on
GitHub to continue tracking issues. Bugzilla will remain
available for reference in read-only mode. We will continue to work
on open Bugzilla bugs, copy them to the new locations
as needed for follow-up, and add the new items under Related
Our sincere thanks to everyone who has contributed on this bug
tracker over the years. Thanks also for your understanding as we
make these adjustments and improvements for the future.
Please create a new report on
Developer Community or GitHub with
your current version information, steps to reproduce, and relevant error
messages or log files if you are hitting an issue that looks similar to
this resolved bug and you do not yet see a matching new report.
`Class.ThrowOnInitFailure` does not throw the expected exception in cases where `NSObject(NSObjectFlag)` is used.
ref: bug #13707
It's bug #14307 (not 13707) and it's also the cause of confusion in bug #15973.
The issue is that `Class.ThrowOnInitFailure` actually checks after `alloc` not after `init*`. So if `alloc` succeed (the Handle is non-nil) and `init*` fails (Handle becomes nil) then the condition remains unreported.
Can be duplicated with UrlTest.cs, InitWith
Unfortunately we don't have any good place to detect 'init*' failures as opposed to 'alloc' failures. The only thing we could do would be to detect setting the Handle property to IntPtr.Zero (which is technically yet another breaking change).
Let me try it and see if it even works with our own code...
Yup, I did not see any "good place" either when I filed this :-( and modifying the Handle property looks pretty risky IMO.
Maybe we could have the generated .ctors call a new InitializeHandle method (instead of setting the Handle directly).
This method would check if:
1. alloc succeeded (replacing the previous check) by ensuring `this.Handle` is not 0x0;
2. init* succeeded, by chekcing the `handle` parameter (not 0x0) before setting the Handle property.
That should be safe since existing bindings (and non generated code) would continue to use the same, unmodified, code.
FIxed (like you suggested, with an InitializeHandle method).
This fix is planned to be released with Xamarin.iOS 7.0.6, which should hit the beta channel before December 23rd.
This is technically a breaking change (see bug #17089), so maybe we should live this fix for later (XI 8.0 for instance)?
This was shipped with 7.0.6, so we'll just leave it in now.