Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3rd party binding generator #690

Merged

Conversation

TimLariviere
Copy link
Member

@TimLariviere TimLariviere commented Mar 9, 2020

Closes #441, #659 and #664

Glossary:

As explained by #441 (comment), the idea is to write a mapping file with references to other mapping files.
This allows anyone to write their own mapping file to generate bindings for 3rd party libs (like SyncFusion) with the inherited properties/events from Xamarin.Forms.
It's this last part that isn't currently possible.

Writing the following mapping file

{
  "assemblies": [
    "path/to/Xamarin.Forms.Core.dll",
    "path/to/SyncFusion.dll"
  ],

  // This is the new field. It is optional and can contain one or more mapping files
  "baseMappingFiles": [
    "path/to/Xamarin.Forms.Core.json" // Found in the Fabulous.XamarinForms repository
  ],

  "outputNamespace": "Fabulous.XamarinForms.SyncFusion",
  "types": [
    {
      "type": "Syncfusion.Buttons.XForms.SfButton",
      "properties": [
        {
          "source": "IsCheckable"
        },
        {
          "source": "ShowIcon"
        }
      ]
    },
    (...)
  ]
} 

And passing it to Fabulous.XamarinForms.Generator, will result in the matching F# binding code with all the same declared parameters of the inherited button control + the new declared parameters.

View.SfButton(
    text = "SyncFusion button", // Comes from Xamarin.Forms
    showIcon = true // Comes from SyncFusion
)

cc @xperiandri

@TimLariviere
Copy link
Member Author

TimLariviere commented Mar 9, 2020

Currently, it's only a first draft.
I managed to generate this F# binding code from this mapping file.
The TestButton control is declared here

It's only missing the correct open statements to be compilable. But should be working once added manually.
open statements are automatically generated now.

@TimLariviere
Copy link
Member Author

TimLariviere commented Mar 20, 2020

Managed to successfully move OxyPlot, SkiaSharp and VideoManager under automatically generated bindings

@TimLariviere
Copy link
Member Author

Implemented #659 and #664 for FFImageLoading

@TimLariviere TimLariviere marked this pull request as ready for review March 21, 2020 20:55
@TimLariviere TimLariviere changed the title [WIP] 3rd party binding generator 3rd party binding generator Mar 21, 2020
@TimLariviere TimLariviere requested a review from SergejDK March 21, 2020 20:56
@TimLariviere
Copy link
Member Author

This PR should be ok now.

@SergejDK Could you please review it and let me know what you think?
Thanks.

Copy link
Collaborator

@SergejDK SergejDK left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All in all it looks very good and it seems to work for so much as I could test it :)
Thanks for this feature!

@SergejDK
Copy link
Collaborator

@TimLariviere
About #664 should we check the ViewUpdaters.fs, too? I mean we use the defaultValue there and maybe we should use ClearProperty in this file. What dou you think?

@TimLariviere
Copy link
Member Author

About #664 should we check the ViewUpdaters.fs, too? I mean we use the defaultValue there and maybe we should use ClearProperty in this file. What dou you think?

Yes! You're completely right. Forgot to check this file.
Will do.

@TimLariviere TimLariviere merged commit 536e7c4 into fabulous-dev:master Mar 23, 2020
@TimLariviere TimLariviere deleted the third-party-bindings-generator branch March 23, 2020 07:59
@TimLariviere TimLariviere mentioned this pull request Apr 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants