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 for Bug 60707 on
Developer Community or GitHub if you have new
information to add and do not yet see a matching new report.
If the latest results still closely match this report, you can use the
In special cases on GitHub you might also want the comments:
GitHub Markdown with public comments
var a = new CIQRCodeDescriptor (new NSData (), 0, 0, CIQRCodeErrorCorrectionLevel.Q);
This C# API throws: `Could not initialize an instance of the type 'CoreImage.CIQRCodeDescriptor': the native 'initWithPayload:symbolVersion:maskPattern:errorCorrectionLevel:' method returned nil.`
The same code in native not only doesn't throw but also tells the user the exact problem and solution.
CIQRCodeDescriptor * desc = [[CIQRCodeDescriptor alloc] initWithPayload:[[NSData alloc] init] symbolVersion:0 maskPattern:0 errorCorrectionLevel:CIQRCodeErrorCorrectionLevelQ];
let code = CIQRCodeDescriptor (payload: Data (), symbolVersion: 0, maskPattern: 0, errorCorrectionLevel: .levelQ)
In the logs we get: `[api] -[CIQRCodeDescriptor isValid] CIQRCodeDescriptor: symbolVersion must be in the range of [1,40]`
This is nowhere to be found when using the managed API and I'm wondering if it's just a case where we can't do anything about it, have to use the API and add a validation check to our code or if we can somehow leverage the native behavior and report that automatically to our users.
Could be that we do not support os_log and friends? I might be wrong :) I think @Rolf mentioned something about it last year but could not find it :)
cc @Rolf :D
Apple API are inconsistent. Some `init*` method can return an `out NSError` argument, that would contain such information (and we bind them as such).
However most of `init*` returns `nil` without any extra information. Some will assert, which crash the app (much worse). Some will throw an ObjC exception (tricky). Finally a few will log something - and that should remain the case when called from C#.
In some cases it's possible to add the same validation in managed code (and throw a more accurate exception). However if the validation is not documented then it's risky to be over protective (and disallow acceptable data) in addition to adding extra code into the application.
We could add a more elaborate message (or an URL, the existing message is already long) that describe the issue and suggest looking into the logs for, possible, extra information.
The native method prints the message to stderr, which should show up in the Application Output in the IDE (I tested this by closing stderr in an Xcode project ("close (2);"), and the message went away).