Can somebody show an example how to use Akka.Net Testkit with F# API?
Both Akka.Net and F# are quite new to me so I don't know if it is even feasible or reasonable to write unit tests this way (F# API and Testkit).
To be more specific, quite simply I don't know how to get access to Sys with F# API. This is what I got:
module SocketTests
open Xunit
open Akka.TestKit
open Akka.TestKit.Internal
open Akka.TestKit.Xunit2
open Akka.FSharp
type SocketTests() =
inherit Akka.TestKit.Xunit2.TestKit()
[<Fact>]
let Socket_should_change_to_connected_state_when_receiving_Connect() =
Ok, now I would need to get reference to Sys for spawning something and for the life of me I can't figure it out. :-(
Any help would be much appreciated
Related
I need help running this python code in a windows flutter app
import win32com.client
outlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI")
msg = outlook.OpenSharedItem(r"C:\test_msg.msg")
using the win32 package, as I can't understand how to use it... I'm quite sure it's doable since this is available in the package and seems to be what is needed...
The most easiest way is to automate Outlook for that like the Python code does. Be aware, the code mentioned make sense only for Windows machines. The COM technology doesn't exists on other platforms.
Also you can find the MSG file format described in depth in MSDN. So, you may search for existing parsers over the internet or create your own.
I notice that each time I open F# Interactive (FSI) from within Visual Studio to tryout something REPL-style, I always find myself executing a few commands first, often specific for any given project:
open System;;
#r #"r:\projects\currentprjLibs.dll";;
#r #"r:\external\unquote.dll";;
#time;;
This is just an example, but I find myself asking: can this be automated? Now, I could have an fsx script for each project and do a "send to interactive", but this is still quite a bit of work (and #r or #time won't work there). Besides, I have to do it again on each FSI Reset.
Does anybody know of a simpler way? Should I roll my own (I never created a serious add-in for Visual Studio, but maybe now is a good time). Other suggestions?
PS: the solution here is not what I am after, as it applies to every instance of FSI and it doesn't do opens. The 2nd solution there is to add #if INTERACTIVE, but this adds clutter, is difficult to write with relative paths, and Ctrl-A plus Ctrl+Shift+Enter will choke on any namespace, which then also needs to be in #if !INTERACTIVE, adding more clutter.
How do I use COM libraries from an F# script? Is it even possible? How do I reference the required COM libraries in an .fsx file?
More specifically, I'd like to use InstallShield Automation from a build script. Despite all my efforts, I could only get it to work with a regular compiled project.
Edit: I already tried the COM type provider project. However, it doesn't seem to find any types in the particular COM library I'm interested in. If it's a bug or intended behavior, I don't know.
I think possibly maybe the COM type provider might help you out:
One advantage of this method is that you can author and deploy F#
scripts without having to pre-generate the interop assemblies. Another
advantage is that you can easily explore all the COM components
installed on your machine via intellisense.
And yes I did just google it, which OP also might have done before asked here.
Using Python in command line you can write help(function) to see docstring.
Is there something similar in Fsharp for fsi?
Do you have any tips and tricks for working in fsi anyway?
What is even possible to find out without using IDE? Just from interactive session.
EDIT:
This question is actually addressed to Python guys who know Fsharp as well. I guess MS guys relying on their VS might find my question pretty strange :)
So far it seems that my question has simple answer: NO.
EXAMPLE:
Lets say you are logged to remote computer via console. I dont know whether this is typical or even possible scenario. For some reason I started fsi and now what? Am I lost or do I have some chances to get some help from fsi directly
DISCLAMER:
I know Scott Wlaschins fsharpforfunandprofit.com pretty well. But his example is dedicated to C# users. Pythonists have different workflow.
If you are used to interactive python, and you like the approach, you may have a look at this F# engine for iPython Notebook:
https://github.com/fsprojects/IfSharp
Yes.
Simple introspection can be done by typeof <_> or typedefof<_>.
For example:
typeof<System.Console>;;
In fsi you can use TAB completation, but apperantly just from command line. It is not working in my Xamarin.
Neat trick is to run:
fsi --use:yourfile.fsx
which run your file and let you test it interactively.
For more info you can use in command line fsi.exe --help.
I would like to add an F# REPL to my application for live debugging purposes. I am looking at the source code for fsi.exe (F# Interactive) and there is a ton of stuff going on that looks like it pokes around with F# compiler internals. I cannot get this same code to compile in the context of our application because of this.
Is there a nice simple example of implementing an F# REPL somewhere? I would have hoped for this to be fairly easy.
The short answer is that F# (unfortunatelly) doesn't currently provide any API for hosting F# Interactive in your applications. There are a lot of people asking for this - see for example this SO question.
There are essentially two things you could do about that:
You can modify the open-source release and compile fsi.exe as some DLL library that would provide the API you need. This isn't simple task - F# Interactive is tightly bound with the compiler (it compiles code you enter on the fly), but it should be doable to encapsulate the types implementing REPL into some type you could call (But you cannot just take some file out of it - you need to compile entire F# to get this working).
You can run fsi.exe as a separate process as Visual Studio does and send commands to it using standard input/output. You can get some more flexibility by loading your library when fsi.exe starts. The library could use .NET Remoting to connect back to your application and expose some data.
Unfortunatelly, these two options are probably the only things you can do at the moment.
EDIT I was thinking that I already answered this question somewhere (perhaps in email), but couldn't
find it! Thanks to Mauricio who found the exact duplicate (even with my duplicate answer... Doh!)
I've written a series of blog posts about using the open source F# interactive executable inside and WPF application.
The code base is available on github - https://github.com/oriches/Simple.Wpf.FSharp.Repl
The series of blog posts are:
http://awkwardcoder.blogspot.co.uk/2013/12/simple-f-repl-in-wpf-part-1.html
http://awkwardcoder.blogspot.co.uk/2013/12/simple-f-repl-in-wpf-part-2.html
http://awkwardcoder.blogspot.co.uk/2013/12/simple-f-repl-in-wpf-part-3.html
The final post is to follow soon.