Producing Better Bindings RRS feed

All replies

  • User239 posted

    protected override Assembly Assembly { get { return typeof (CCAccelAmplitude).Assembly; } }

    where to put this code?

    Wednesday, March 20, 2013 6:17 AM
  • User1004 posted

    The binding-test folder you added to the cocos2d bindings puzzled me up to now. I now know what it is about. But still, the project is incomplete there. Where do I find ApiBaseTest.cs, ApiCtorInitText.cs, ... should I get them from https://github.com/mono/maccore/tree/master/tests/bindings or is this part of an assembly somewhere ?

    Wednesday, March 20, 2013 8:36 AM
  • User1004 posted

    @simon: in all of your test classes... https://github.com/mono/monotouch-bindings/blob/master/cocos2d/binding-test/BindingCtorTest.cs

    Wednesday, March 20, 2013 8:38 AM
  • User2589 posted

    @StephaneDelcroix for the cocos2d tests you need to clone the maccore as a sibling to the monotouch-bindings directory. That should make the test project build as-is, otherwise (e.g. a new project) you need to copy the files into your solution.

    The files are not part of an assembly - mostly because the same binary would not be usable for both Xamarin.Mac (which we use nunit for testing) and Xamarin.iOS (which uses Touch.Unit/NUnitLite).

    Wednesday, March 20, 2013 12:40 PM
  • User1004 posted

    thanks @poupou, at this time of the day, I had that figured. Your stuff is awesome and able to catch 100's of issues

    There's one or two that'll have to ask you about, but lemme send a pull request first

    Wednesday, March 20, 2013 12:42 PM
  • User1004 posted

    you're not testing the constructors' selector but the default one, right ?

    Wednesday, March 20, 2013 1:12 PM
  • User2589 posted

    @StephaneDelcroix ApiCtorInitTest tests are executed on instances created from the default constructor. Mostly because it's not possible to guess the required parameters for other .ctor. The next blog post will be about constructors.

    OTOH other tests exists for every exported selectors to ensure that they exists (respond) and that their managed/native signature match. More details coming in future blog posts (but you have all the sources until then :-).

    Wednesday, March 20, 2013 1:25 PM
  • User197 posted

    pretty cool guide! Exactly what I was looking for.

    Question :

    • Can I submit a binding (free) in the component store who I am not the author of this objc component ?
    • What happens if the component is out of date after few months ?

    thanks in advance.

    Wednesday, March 20, 2013 4:52 PM
  • User2589 posted

    @vbellet, Thanks :)

    You better email components@xamarin.com for question specific to the component store that are not covered in the submitter terms.

    My best guess would be: (a) depend on the original component license and (b) binding projects includes the static library (so it does not matter to the store itself). Of course your component review rating might go down if you don't keep updating your bindings.

    Wednesday, March 20, 2013 5:33 PM
  • User1004 posted

    @poupou: this https://github.com/mono/maccore/pull/47 detect some signature mismatches for constructors

    Wednesday, March 20, 2013 7:41 PM
  • User197 posted

    Just to give back the support answer (nat lol :)) about who can submit a binding :

    Everybody can submit a binding as long as the license to the original objective-c library allows you to.

    As far as I know almost all objc component are under the MIT license, so let's get some binding done!

    Wednesday, March 20, 2013 9:06 PM
  • User986 posted

    This is an awesome blog post series, thanks for writing down these details!

    Thursday, March 21, 2013 12:31 AM
  • User1004 posted

    A default (no parameters) public constructor is added to (non-static) types unless you define one with less visibility (e.g. private).

    and unless there's another constructor with parameter

    Thursday, March 21, 2013 8:25 AM
  • User1004 posted

    [TestFixture] public class BindingCtorTest : ApiCtorInitTest { public BindingCtorTest () { // fictional example where binding won't work without // some specific initialization code MyLibrary.SharedConfiguration.Server = ""; } }

    Aren't you supposed to do that in [SetUp] ?

    Thursday, March 21, 2013 8:31 AM
  • User1004 posted

    For example, the fixture implementation to test Cocos2d did not require any overrides

    well, actually: https://github.com/StephaneDelcroix/monotouch-bindings/blob/cocos2d/cocos2d/binding-test/BindingCtorTest.cs

    (and I'm now done with the comments for the second post)

    Thursday, March 21, 2013 8:58 AM
  • User2589 posted

    Aren't you supposed to do that in [SetUp] ?

    @StephaneDelcroix that would execute before each test while the constructor will be called once.

    Now there's a [TestFixtureSetUp] but I never found it very useful - but it's symmetric with using [TestFixtureTearDown] (and a finalizer would not be reliable, timing-wise to replace the later).

    Friday, March 22, 2013 8:22 PM
  • User1004 posted

    Yes, that's the point. Re-initializing your configuration for every test. Anyway, in this case, that's nitpicking as there's one [Test] per [TestFixture] :)

    Friday, March 22, 2013 8:25 PM
  • User2589 posted

    My example might not be a very good one :-) but I wanted to show it's possible to initialize a library once (not per test) since it's not uncommon for native library (like the mono runtime itself) not to allow re-initialization.

    Friday, March 22, 2013 8:53 PM
  • User2672 posted

    Pardon my ignorance but why do we have to bother with having to create a "binding"/wrapper when products like RemObject's Oxygene “Nougat” can simply add a reference to the library and start using it?

    Nougat is .Net, granted it's Pascal but that doesn't bother me. But the ability to import a library and use it is very enticing, versus creating an error prone binding, having to wait for someone else to create a binding for me or porting the code myself.

    To quote marc hoffman, whom I have a great deal of respect for. I've been using his RemObject SDK and DataAbstract products for years in both Delphi and in .Net:

    Here’s the amount of legwork i had to do before i could work with the GameKit APIs, just like every other Cocoa developer would: i added a reference to GameKit to my project. Done. That’s it. No begging someone to translate header files, or waiting for someone to create a crappy abstraction wrapper class. Add a reference, and use the APIs as Apple intended them — that’s the way development should be.

    Just curious why the same couldn't be down with MonoTouch.

    Saturday, March 23, 2013 1:40 PM
  • User2589 posted

    @JeremyBrown There's not much details about Nougat and I don't like to speculate. There's just too many ways to achieve any goal - some easier than others, all with (at least some) drawbacks.

    and use the APIs as Apple intended them

    Honestly I'd rather not. I much prefer to have complexity (bindings) and ugliness (how an ObjC API looks in .NET) restricted to few than exposed to all. So it boils down to the time spend creating bindings versus the time using them - across every users.

    Since the later is generally much larger than the former I think it's worth the time to curate the API bindings, to bring them to match the language and test them to ensure the later group experience is the best.

    Monday, March 25, 2013 1:54 PM
  • User1004 posted

    If you want a test for completeness : http://blog.reblochon.org/2013/03/producing-better-bindings-completeness.html

    Thursday, March 28, 2013 3:32 PM
  • User2589 posted

    @StephaneDelcroix That's awesome! There are some ObjC runtime API to query methods (e.g. class_copyMethodList) so maybe it could be done without an outside step.

    I have not really looked into this one - mostly because it would (for iOS and OSX bindings) list Apple private selectors. We (Xamarin) do not want to bind any of them since it would be too easy to get application refused in the appstores. OTOH for library bindings that's a great addition!

    Also about fields... the blog series was written a while ago. Since then we made some changes to bindings wrt fields so it might be possible (I need to review that fixture) to be more precise if some (non-NSString) fields cannot be found in the native library. Feel free to beat me into reviewing this :-) I'm not likely yo have time to look into this before Evolve.

    Thursday, March 28, 2013 3:51 PM
  • User7297 posted

    Can you please tell me how to get MD5 key/sha1 key for Google Map API1 in Windows XP Operating system. I got some steps on this link but can any one tell me this same steps for windows xp.


    Saturday, March 30, 2013 1:32 PM
  • User350 posted

    A great set of articles - thanks Sebastien.

    I'm struggling, however to see how to set up a test project for my binding. Can someone give me some pointers please? Or is there a sample I can use?

    Tuesday, October 22, 2013 7:01 PM
  • User350 posted

    Ah - found the cocos2d binding project and tests...

    Tuesday, October 22, 2013 7:06 PM
  • User2589 posted

    @JamesLavery thanks!

    It's fairly simple but a real life example makes it even easier. Have a look at the Cocos2d binding solution (from github).

    Tuesday, October 22, 2013 7:07 PM
  • User350 posted

    Hi Sebastien, Thanks - that's exactly what I'm doing! I realised that was what I should be doing approximately 30 seconds after my post...

    Tuesday, October 22, 2013 7:25 PM