Bug 29932 - Binding to const char * fails with [PlainString]
Summary: Binding to const char * fails with [PlainString]
Status: RESOLVED INVALID
Alias: None
Product: iOS
Classification: Xamarin
Component: General ()
Version: master
Hardware: PC Mac OS
: Normal normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2015-05-11 06:46 UTC by erik
Modified: 2015-05-15 05:18 UTC (History)
3 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and 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 Links.

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.

Related Links:
Status:
RESOLVED INVALID

Description erik 2015-05-11 06:46:03 UTC
While trying to implement the Good SDK I run into errors trying to bind the GDHttpRequest. The method uses "const char *" instead of NSString, which according to the documentation should be bound to [PlainString] string. Trying this gives the (not very helpful) error:

2015-05-11 12:41:57.961 MCCForms[8327:959414] *** Assertion failure in -[GDHttpRequest open:withUrl:], /Users/Shared/gd/good/cache/jenkins/master/eng-mac37/workspace/GD_SDK_for_iOS_Release_Dave/dev/gd/dave-ios/msdk/platform/ios/library/GDNETiOS.mm:530

According to the documentation:

- (BOOL) open: (const char * method withUrl: (const char *) url

The Binding:

[Export ("open:withUrl:")]
bool Open ([PlainString] string method, [PlainString] string url);

The implementation:

const string method = "GET";
const string url = "http://google.com";

request.Open (method, url);
Comment 1 Rolf Bjarne Kvinge [MSFT] 2015-05-11 07:00:29 UTC
Can you zip up and attach your binding project (with a test project) we can use to reproduce this?
Comment 2 erik 2015-05-11 07:43:59 UTC
I'd love to, but the difficulty is that the Good (Dynamics) SDK needs to be run on a configured device and connect to a configured Good installation. Only after the app goes through the whole validation, that's when the above code can be run.

The Binding project I used is:

https://github.com/westmonroe/GoodDynamics_XamariniOSBinding
http://blog.westmonroepartners.com/using-good-dynamics-sdk-v1-8-x-with-xamarin-ios/

In that Binding project an IntPtr is used instead of a PlainString. Is there any way to get more debug information on my side? I could request a Good account for this, but it involves quite a bit of work just to get the rest of it working on a machine..
Comment 3 Rolf Bjarne Kvinge [MSFT] 2015-05-12 09:29:09 UTC
Does the binding with IntPtr work?
Comment 4 erik 2015-05-14 20:26:15 UTC
I haven't gotten it to work. I'm unsure how to create the IntPtr for a char * in the first place. What would the IntPtr be created from - a string, or perhaps a byte[]? And how would I create it in such a way it would translate correctly?

I've tried different approaches, but the same (not very helpful) error kept appearing. Perhaps I haven't found the right way to create an IntPtr. All I could tell from the documentation is that I should go for a PlainString.
Comment 5 erik 2015-05-15 05:18:42 UTC
This ticket can be closed, I managed to get it working with the [PlainString] implementation. The assertion error did not come from the Binding, but was an error from the Good SDK (it needs to assert a certain status).

The most useful part of the error doesn't show somehow, which makes debugging it pretty difficult. Either way, it's working now.