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

Improve usability from C# #52

Closed
1 of 2 tasks
kMutagene opened this issue Sep 15, 2020 · 1 comment
Closed
1 of 2 tasks

Improve usability from C# #52

kMutagene opened this issue Sep 15, 2020 · 1 comment
Assignees

Comments

@kMutagene
Copy link
Member

kMutagene commented Sep 15, 2020

Description

There were already reports regarding problems using Plotly.NET from C#, e.g. #29 .

Problems regarding the translation of F# options into C# have been fixed, however there are 2 main issues left:

  • Extension methods defined in the ChartExtensions module do not works as intended. This can be fixed using the [<System.Runtime.CompilerServices.Extension>] atttribute for those methods, making it possible to call the methods on chart instances in C#, e.g

    myChart |> Chart.Show

    will in C# be

    myChart.Show()

    The extension method must have the Chart as first parameter though, so overloads for all fitting methods are necessary. Additionally, using static ChartExtensions already works.

    implemented via members of GenericChart via c1ed1be

  • Generic types are easier to use in F#. Consider the following F# example:

    Chart.Point(data,Color="#ffffff")

    In this case, Color is not typed in the Chart.Point function, and is infered as generic 'a1. This is not the case in C#, where you must annotate it (the second string annotation). :

    var chart = Chart.Point<double, double, string, string>(data, Color: "#ffffff");
    
    //This is what you should be able to do:
    var chart = Chart.Point<double, double, string>(data, Color: "#ffffff");

    I see no solution for that other than adding type annotations to the respective parameters extensively.

However, when these issues are taken care of, from my limited usage of C# it seems like we can reach comfortable usage in that language with these features added.

@kMutagene
Copy link
Member Author

turns out i was wrong with the second part of my comment above and you can ignore unset generics as the example in the readme shows

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant