I would need some hints with F# interactive usability - f#

Now in VS2013 and F#3.1.1, I noticed that it is a bit cumbersome to send code to F# interactive.
There are separate menus for but no keyboard shortcuts for
sending project output as reference to F# interactive
sending project references to F# interactive
In the editor window, there is no "send whole file" to f# interactive. You have to select it all, right click and send.
It feels very unpolished. Are any faster ways of doing this?
What are your IDE workflows?
As I am righting these questions, i think about maybe using shellplus powershell integration for invoking this...

Just in case it helps: you can right click on any reference in the Solution Explorer and do 'Send reference to interactive' - or you can right click on the References node and send them all to interactive.
You can also do this in your source:
#r #"c:\mycode\myassembly.dll"
...and you can surround that with #if interactive to stop it messing up your compiles.
#if INTERACTIVE
#r #"c:\temp\myassembly.dll"
#endif
Finally you might also want to look at script files (.fsx) - googling for "f# script files" produces some useful references.

For sending references, yes, you have to right-click on the individual reference or the references node and click "Send reference to FSI." Not perfect if you prefer keyboard shortcuts, but much improved from VS 2012 when you had no choice but to type out a full #r statement every time...
For sending code, Alt+Enter is the easiest/most popular shortcut. Highlight the code you want to execute (using either mouse or keyboard), then hit Alt+Enter. To send the entire file, just use select-all (Ctrl+A) to highlight everything.

Related

How to remove the function minimize sidebar in Visual Studio 2019

How can I remove the little sidebar to the left of the code in Visual Studio 2019? I mean the little minus signs that appear next to each function or code block header and, if clicked, minimize that function or code block.
Is there a way to disable these?
The feature is known as "outlining" and enabling/disabling it is language-specific. In all cases, use the "Options" command from the "Tools" menu and then, in the left-hand pane of the displayed pop-up box, open the "Text Editor" node.
For C/C++ files, the option is under the "View" sub-node:
For C# files (and also Basic, F# and Python), it's under "Advanced":
For other languages, it's likely to be in one or other of those places, but I can't guarantee that. In all cases, changes only come into effect on files that are opened after the option is changed.
If you have another specific language for which you can't find this option, just let me know and I'll try to help.

REPL for Delphi IDE?

http://en.wikipedia.org/wiki/REPL Read–eval–print_loop
Is there such a thing for Delphi ?
It would be rather useful to explore DLLs such as Windows APi and sketch their usage, when dealing with border cases scarcely documented.
I tried pascal scripts, such as one in Cnwizards, but it is much less comfortable.
For example it cannot use units like Windows.pas and you had to make some strange stubs of your own for it.
And anyway, those scripts are less easy to use for "try this try that" scenario than Repl.
For Delphi objects most clsoe thing it to pause on breakpoint and use Evaluate/Modify window, but it only works with Delphi objects, not DLLs; it cannot make temporary vars to cache values and such.
It's not really what you're looking for, because Delphi is a statically typed, compiled language, but if you really insist on being able to type some pascal in and see if it does anything, you can try the TJvInterpreter component that comes in the Jedi VCL.
Note that the experience is nothing like using python. You can't just type "uses module" and hit enter, because pascal units must be complete before they can even be interpreted by JvInterpreter, and the JvInterpreter needs you to write a wrapper for every single other unit you want to import. You would go crazy. I'm not seriously advising anybody to try to build a REPL around TJvInterpreter.
The "interactive magic" element of Delphi is called the "designtime environment" and the way we build using "components". We don't even do that bit by writing code much, we do it all visually with our mouse and keyboard. It's called RAD (rapid application development) and is powered by the VCL (visual component library) in Delphi, and (like REPL) is one of the many ways of doing very-rapid development.
The other thing we have that is a lot like a REPL is this button in Delphi:
You click it, after creating a new empty project, and whatever code you added to your new empty project is built and running in less than a second. Close enough to a REPL for me. It's kind of like binary executable instant bliss.
Write one line. Build and run (1 second). Instant.

F# interactive: Reference a project in currently open solution

I would like to use the F# interactive console with the projects in the currently open solution in Visual Studio 2010. Is there a quick and easy way to add a reference in the F# interactive console to reference projects in the currently open solution?
I've got lines like this at the top of my .fs file:
#if INTERACTIVE
#r #"C:\path\to\some.dll"
#I #"C:\Users\bford\path\to\a\project\in\this\solution\bin\Debug"
#r "Project.name"
#endif
Alt-Enter now drops me into fsi with all the required stuff loaded
If it's a project you reference often, you can add an 'always' reference to the FSI command line, under Tools->Options->F# Tools->F# interactive options.
Add a -r switch like:
-r "C:\Users\yaddayadda\MyDll.dll"
I don't think there is any direct way to reference a project in the solution. The best way I can think of is to add a FSX file somewhere to your project with the #r directive:
#r #"bin\Debug\YourProject.dll"
Then you can at least reference the compiled DLL file simply by hitting Alt+Enter in Visual Studio. As far as I know, you cannot reference the project - you can only reference an assembly.
Currently, F# Interactive is really disconnected from the project system in Visual Studio. I suppose that closer integration would be quite useful (but probably difficult to provide).
Now in Visual Studio 2013 you can add a reference to the F# interactive window by right clicking on the referenced dll and clicking "Send to F# interactive".
I would think it should be straightforward to reference the current project, obtain the list of references it contains, and then optionally generate a list of #r (and possibly #i) statements for the interactive session being created, referencing the dll of the project itself as well.
For example: "fsi /i:pathOfLib1 /r:lib1 /i:pathOfLib2 /r:lib2 ...."
PS: base on the MSDN article it doesn't appear that library names can include their path prefixes hence the separate into /i and /i : http://msdn.microsoft.com/en-us/library/dd233172%28v=vs.100%29.aspx
It would be good if the Visual Studio F# Interactive Options menu allowed for the stipulation of a startup script that the invocation could pass to FSI via the "--use:" directive. Such a script could then be passed solution metadata that allows for the environments to be more integrated such as loading latest project outputs.

F# compiler order of source files

As I understand it, when using F#, you have to manually list the source files in dependency order for the compiler's benefit (if there is any way around that, please let me know!)
Listing them on the command line from left to right obviously isn't going to scale. Is there a way to at least make it accept the list of files in a text file, one per line, preferably with the ability to put in blank lines and comments? I've checked the compiler options, and I don't see anything that looks promising.
About the Visual Studio 2008 integration, you can move up/down source files with a right click and choosing Move Up, Move Down or use the shortcut Alt+Up Arrow, Alt+Down Arrow after having selected the file.
No, but the typical way to compile F# (at least on Windows; dunno about Mono) is via MSBuild; the .fsproj project file puts each file as a separate <Compile> item on a separate line. What build tools are you using?

How to detect if file in IDE is being edited using Open Tools API

I made a small IDE plug-in using Open Tools API that accesses ClearCase. It has menu items "Check In", "Check Out", etc. It works OK but I want it to check out a read-only file automatically if I start typing in IDE editor or if I attempt to save the file. Do you think this is possible?
I tried a few things but gave up eventually. IOTAEditorServices.KeyboardServices has AddKeyboardBinding method which looked promising. Using it I added a notifier with binding type btPartial (and later tried btComplete) and the plug-in started detecting some shortcut key presses but not all keyboard events, far from it... Any ideas would be much appreciated!
I think a "cleaner" way is to hook up a IOTAEditorNotifier to each editor and have your IOTAEditor.Modified method called by the IDE whenever the contents of the editor is modified, whether by keyboard, mouse or programmatically from another plugin.
Here's an example which registers an IOTAIDENotifier to be notified of files being opened in the IDE so it can register its IOTAEditorNotifier instances.
I must be possible somehow: we use SourceConexion (http://www.epocalipse.com/scx.htm) here, which auto checks-out the file before you edit the source or change the form.
JVCS has IDE integration support, it is open source, maybe they have implemented this too:
http://jedivcs.sourceforge.net/

Resources