Changing the F# tools Visual Studio 2010 uses - visual-studio

I rebuilt F# with few syntax additions. I was able to tell VS2010 to use them for F# Interactive and for building, but the code editor still claims I'm making errors (even though the project builds just fine).
Is it even possible to change this? If it is - how?

As far as I know, there is no way to change the IntelliSense service used by F# in Visual Studio. The Visual Studio component isn't a part of the open-source release and it has a reference to strongly-signed FSharp.Compiler.dll. I'm not sure if there is some way to trick .NET to load a different assembly instead (specifying bindingRedirect in app.config requires the same strong name). If you find some way, let me know :-) I'd like to use it with my modified version of F# too.
If you want to get some IntelliSense for your modified F#, you can use the F# MonoDevelop plugin. The plugin is open-source and you can change the F# version used in the Services/FSharpCompiler.fs file (see the source on GitHub).

Related

F# VS2019 Windows Forms

I'm learning F# and I'm just trying to build Animate a pendulum program.
Here's the code:
https://rosettacode.org/wiki/Animate_a_pendulum#F.23
As far as I understand, VS 2019 doesn't support WinForms in F# (maybe, I'm wrong), so I have error messages, trying to copy/paste that code:
What should I do?
Thanks a lot !
If you're looking to use Winforms on .NET core, you'll need to do the following in your project:
Open the project file (double-click on the node in Visual Studio)
Change the Sdk to Microsoft.NET.Sdk.WindowsDesktop
Ensure you have this OutputType: <OutputType>WinExe</OutputType>
Add the following property to the top-level PropertyGroup: <UseWindowsForms>true</UseWindowsForms>
There won't be a visual designer to use, but you should have access to the APIs.
Unfortunately, there is no Winforms designer in Visual Studio 2019 for F# projects of any type, and Winforms can only be easily accessed (as far as I know) in .Net Framework (NOT .NET Core) projects they can be accessed as per #Phillip Carter's answer.
However you can still make Winforms programs easily by manually adding the references to your .NET Framework project, or (more easily) by manually compiling with the F# compiler, fsc.
The Fast Way
The easiest way to do this is simply compile the source code with the F# compiler from a single source file with fsc.exe. The F# compiler will automatically resolve dependencies for things like System.Windows.Forms and a lot of other commonly used namespaces. You can also provide lots of compiler directives for requiring other resources as well.
Example using VSCode, with various extensions:
Another Way
Start a new F# console .NET Framework project (don't pick .NET Core).
Right click on "References" in the Solution Explorer and click "Add Reference..."
Under assemblies, look for "System.Windows.Forms," select it...
And also select "System.Drawing" and then hit OK
Now you have access to both of those namespaces.
Before you run the project in Visual Studio, you should replace
[<STAThread>]
Application.Run( new PendulumForm( Visible=true ) )
with
[<STAThread;EntryPoint>]
let main _ =
Application.Run( new PendulumForm( Visible=true ) )
0
This way you (and VS) know where main actually is. It's not necessary for this small of a program to actually run it, but as your projects get larger VS will complain more about where things are located in your project.

Jump to the definitions in external dependent packages from Visual Studio Code

I'm new to Visual Studio Code (on Mac). We are using it to develop ASP.NET Core MVC applications in C#. When I hit F12 on a symbol, like classes, interfaces or variables, VS Code will jump to the definition of that symbol if the definition exists in the source files, sweet. However nothing will happen if the definition is from an external dependency. If I did this with Visual Studio on Windows, in this situation the default behaviour is jumping to the definition provided by its metadata. Is there a similar way in VS Code to do this, rather than doing nothing in this case? It would be very helpful during development.
The new OmniSharp C# extension for VS Code for >=.NET Core 1.0 now has this feature. If there is no source code available then jump to the definition provided by its metadata. (Since OmniSharp C# extension 1.6.0 for VS Code which I used. But the legacy OmniSharp C# extension for DNX doesn't have this feature)

Using Regionerate on VS2012, or alternative addin

I tend to use Regionerate quite extensively for reorganizing my code files. My only problem is I can't get it registered with VS2012. I've abandoned VS2010 fully in favour of VS2012 and it's galling to have to flip back just to run a macro to reorganize code files. I've never tried writing a VS addin before so I'm not at all familiar with the object model or how to register - seems the old addins are more complicated to install than the VS2010 extensions! I've also looked through the WIX setup XML and tried replicating the registry keys to no avail.
Does anyone know how to either register Regionerate with VS2012, or is there an alternative (free and which is maintained!) extension that provides the same functionality?
Two things needed for registration:
It looks like VS2012 doesn't read from the HKLM...\11.0\AutomationOptions key at runtime, only at first run. The corresponding key at HKCU...\11.0_Config\AutomationOptions needs to be set as well.
A new .AddIn file needs to be created with a Version of 11.0
If you do that, Regionerate will appear, but will hang Studio when you try to use it. The Regionerate code has a bad version check ("not equal" instead of "less than") that will get stuck in code that doesn't work for VS2010/2012. Unchecking "Automatically collapse regions" in Regionerate settings might be enough to avoid the bad code.
I made a new version that fixes the version check and has the correct install pieces for VS2012. You can download the installer and changed source files here:
https://skydrive.live.com/redir?resid=2FEB8D1988F04D77!565
This is what you need to do to make VS2012 compatible Regionerate (0.8.0.1) by Frank Racis work with Visual Studio 2013.
Modify this file: C:\Program Files (x86)\Regionerate\Regionerate.VS2012.AddIn
Change version from 11 to 12: <Version>12.0</Version>
Add the following string value in your registry:
Location: HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\12.0_Config\AutomationOptions\LookInFolders
Name: C:\Program Files (x86)\Regionerate\
CodeMaid is a free and actively developed alternative. It has nearly all the features of Regionerate, plus some new stuff. One thing I really like is setting it to organize and clean unsaved files every time I build.

Importing WinSCP source files into Microsoft Visual Studio 2008?

I am pretty new to programming. I would like to download an open source project and build it in my Microsoft Visual Studio 2008. In fact, I tried to import and build the application WinSCP:
https://sourceforge.net/projects/winscp/
But I didn’t work. Please can somebody help me and tell me which files do I have to download (from sourceforge) and how to import these into Microsoft Visual Studio in order to build the application. Thank you a lot. David
WinSCP seems to be written in Borland C++ Builder or whatever it's called today. It's not a standard C++ program and wouldn't compile in any other compiler because it uses special features only present in BCB. (It uses Delphi-style components, VCL and thus the __property keyword.)
Unfortunately, a lot of Open Source projects have very poor support for Microsoft's development tools. One project that comes to mind as being not too big and having workable MSVC project files is FreeType2, but that's a library and not an application, which probably makes it not very interesting for toying around with.
In support forum of winscp, they say, that you can't compile this project in Visual Studio.
Winscp appears to be a CPP project using a makefile instead of a sln file. VS uses SLN and *proj files to control builds and such. A good way to start would be to open VS, create a new console project (and solution) and go through some tutorials online.
If you really want to just see how a large project works in VS, grab something like IronRuby or IronPython or even something like the Witty twitter client.
In the general case, it is not possible to pour the C++ sources of a program into Visual Studio and expect it to work. C++ programming environments are far too different between operating systems for that. If you have a open-source program which builds and runs fine on Linux (for example), it may need several weeks (or months) or programming effort to make it run on Windows.

Using Saxon .NET XSLT processor does not work with intellisense in Visual Studio

I am using the open source Saxon XSLT processor for .NET to execute some 2.0 transforms.
I reference the saxon9api.dll as I would any other dll, and can compile code against this. However Visual Studio does not show any intellisense making the IDE as useful as notepad.
The saxon9api.dll is using the IKVM Java for .NET platform, and I wonder if this is the causing VS a problem. Reflector can inspect the DLL without issue, but I suspect VS is not happy for some reason.
Any ideas?
EDIT:
Surprised that no one else has encountered this behaviour seeing as Microsoft recommends (link is now dead) the use of Saxon in the absense of built in functionality in the framework.
I think I will reword the question to be about assemblies running under IKVM not showing intellisense although I will need to find another IKVM based project to prove that this is the case first...
To make compiling, running and intellisense work in Visual Studio, you need to do the following:
Reference saxon9api.dll, as you already did
Reference IKVM.OpenJDK.Core.dll
Reference IKVM.Runtime.dll (not sure this is needed, but I always include it)
If you are also referencing vjslib, you may run into issues, because it uses a lot of the same namespaces and classnames, leading to ambiguities that can cause Visual Studio's intellisense to get into problems. Perhaps other libraries exist that show the same namespace clashes. In that case, try this on a fresh project first and add the references one by one, starting with Saxon's dependencies first.
After you do this, at least in Visual Studio 2010, 2012 and 2013, you will find that the context-sensitive help is working (image is of VS 2012 with R#):
Note: since this post is old, it may have only applied to Visual Studio 2008 at the time, I have not tested that as I am not using it anyore.

Resources