Bolero (F# Blazor) Debugging - f#

Does someone know how to debug a Bolero project? In particular, is it possible (and how) to debug the client project using and IDE (VS or VS code) or directly in the browser (source mappings)?

Currently there is no ability to debug Bolero (Client side) in the browser that I'm aware of. I recommend using a console trace to watch your model and updates: example. Additionally I've been adding heavy logging for my Bolero project, I find that's often easier with functional code anyways.
You may be able to use the Blazor debugging techniques though I suspect the mappings won't translate back to F#.

Related

VS Code setup to mimic VS debugging

I am involved in an ASP.NET MVC application that uses React/Redux. Using VS I can bring up the solution set the default project and with F5 debug the application. The default application just so happens to be a web application so in debugging VS starts IISExpress and I can set breakpoints in the C# code.
I would like to setup VS Code to debug the client side code. For example there are a number of React components defined using .tsx. I would like to set a break point in the .tsx code without having to resort to using the Chrome debugging tools and find the corresponding js code. Is this possible? What do I have to do to launch.json (and possibly other steps) to allow debugging this app with VS Code?
Thank you.
I think this is what you need : https://github.com/Microsoft/vscode-chrome-debug
it allows you to add breakpoints to javascript , and then debug directly from chrome without running external debugging tools.

How to securely embed the F# compiler in a asp.net web app

I am developing a asp.net web app enabling users to submit F# code, which should be dynamically compiled and executed on the server. I was thinking of either hosting the F# compiler in the web app using the approach shown here:
https://fsharp.github.io/FSharp.Compiler.Service/compiler.html
Or use F# interactive: http://fsharp.github.io/FSharp.Compiler.Service/interactive.html
The idea would be to dynamically compile the F# code and then load it as an assembly in c# or have F# interactive interpret the code. However, my main concern is security and how to stop the end user from executing arbitrary code. Is there an easy way to restrict this? Thanks!
This is an old question and things have considerably changed since it was asked. Now the Fable team have managed to run the F# compiler inside of a web-worker, removing the need to execute code on the server-side. This side-steps all of the security concerns around executing untrusted code.
You can try out the REPL here.
You can view the source-code here.

Debugging Grails Applications

In ruy on rails in order to debug the application you could just call, "debugger", and
it will start a debugger in the console. How is this approach possible in Grails? Especially in a .gsp file? I am using a simple text editor for my development, Sublime.
Thanks
Debugging java is simply not possible in Sublime.You can use another debugger like JDebugTools or a full-featured IDE like Eclipse or Netbeans (but that breaks the whole point to have a lightweight IDE like Sublime, which is great for Java, if not for debugging purpose)
There exists a command-line debugging tool, jdb which can be used for very simple debugging purposes, and may be integrated as a build tool for Sublime (I don't think the result will be good though)
Debugging for Grails is done with the --debug switch as for recent versions, you can then attach a debugger to the session. GSP debugging, like JSP, needs a specific tooling as to be aware of compilation means, and you'd better switch to IntelliJ Idea or [GGTS (Groovy/Grails Tool Suite)](http://spring.io/tools/ggts) which provide both strong debugging capabilities

IOS: AOT ahead of time, what is it?

I have read an article from Xamarin, and came across a particular computer science word : Ahead of Time.
According to some google search result, this AOT does not allow for code generation during run time.
Does it mean, it does not support dynamic stuff?
I know this question may stupid and I have 0 knowledge in IOS, hopefully can get some answer from here. thanks
First, what is the definition of dynamic? For the general public, dynamic code mean the application can change functionality at run-time. For the iOS platform, the binaries are signed to prevent malware. And Apple don't like apps that can load functionality at run-time.
An ahead-of-time (AOT) compiler has nothing to do with dynamic code per se. It's has to do with intermediate language that are just-in-time compilation (JIT). The biggest example of intermediate language is Java bytecode; compile once, run anywhere. When a Java application is executing, the compiled code is JIT to native machine code. AOT compiler is just doing it ahead of time, to save time.
For the iOS platform, Xcode compiles Objective-C to a native binary for the device.
Another way of looking at this is with an example...
In .Net, you can use the Reflection.Emit namespace to generate and compile code at runtime.
Eg you could create an "IDE" with a textbox that accepts C#. When you click a button that C# could be compiled by the .Net framework into a custom library that's loaded dynamically or a fully-fledged executable which is launched as a new process.
This is insanely powerful when combined with the rest of the System.Reflection namespace. You can examine objects at runtime and compile custom code based on any criteria you like.
That said... The problems usually outweigh the benefits in most cases. Mainly, it's a massive security issue, especially when running on a consumer device.
It would be possible to create an app that wouldn't have anything close to malicious code, get it audited by apple, then have the app download code from your webserver, compile it, and execute it. This new code wouldn't be audited...
There really is no good reason to be doing this in a consumer app.

How do I implement an F# Read Eval Print Loop (REPL)?

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.

Resources