Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I use F# Interactive to script or interactively debug/test my C# GUI projects?

Tags:

c#

debugging

f#

I have seen a demo of F# and DirectX.

User selects a part of F# code and sends it to F# interactive. It between, the form's thread is working: the form shows dynamic content and responds to clicks.

Can I conclude that for existing C# winforms project I can create a F# project which references it and then launch the F# project in F# interactive to run arbitrary methods of a form ?

EDIT: what are the steps to invoke btShowNextNumber_Click in a running application ?

public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
    }

    int i = 0;

    private void btShowNextNumber_Click(object sender, EventArgs e)
    {
        ++i;
        label1.Text = i.ToString();
    }
}
like image 743
bohdan_trotsenko Avatar asked Dec 04 '22 14:12

bohdan_trotsenko


1 Answers

Sure. In F# interactive, you'd run something like:

#r "MyDllName.dll"
open MyNamespace

// Call the constructor to get a new form, then show it
let form = Form1()
form.Show()

// Call whatever public method you want
form.MyMethodThatIWantToUse()    
like image 100
kvb Avatar answered Dec 07 '22 22:12

kvb