I have an F# project that compiles in VS and in Jetbrains Rider.
However, the inspection tool displays errors, for instance for the code:
type DU =
| A of int
function
| A -> () // <- jetbrains inspection complains but Jetbrains compiler compiles - so they are out of sync
Some (I guess the later) F# compiler versions complain with FS0019, my VS version and latest Jetbrains Rider compile this code however, VS does not even warn.
My question is not about the code example above but only:
How can I configure the F# inspection?
Or similar:
Which tool does the inspection?
How can I get inspection and compilation into sync?
Jetbrains notified me that configuration of f# inspection severity is in progress. Its possible to push the urgency here:
https://youtrack.jetbrains.com/issue/RIDER-28183
open remains the question why the code compiles while inspection calls out error.
the code itself was valid only for some versions of f#, that was changed later. so i guess part of the configuration of inspection severity should be which compiler version to use for inspection - VS Code for instance has exactly this feature: for each typescript file one can set the version of the typescript compiler that is used for syntax highlighting and so on.
Related
I have both C++ and Delphi tests in DunitX. I am trying to get it to Build in FinalBuilder. C++ tests builds fine, but Delphi tests has the error:
"Error creating cfg file: C:\Tests.cfg Error expanding variables in Library Path : [Expression Error]: Variable\Object "DUnitX" does not exist! [$(DUnitX.);$(BDSLIB)\Win32\rele]
The FinalBuilder does not have a DunitX action, but has Dunit and NUnit ones. For both C++ and Delphi ones the action is Build. Thoughts on FinalBuilder integration appreciated.
IDE: RAD Berlin 10.1
FinalBuilder: 8
Open the failing project and look into the project options
Delphi Compiler -> Search path for any Target might contain $(DUnitX.) <- notice the dot
Make sure to remove the dot and make sure that you have the DUnitX environment variable set - for additional information see this article: https://www.finalbuilder.com/resources/blogs/postid/702/dunitx-has-a-wizard
If you are using the DUnitX version that ships with Delphi you can just remove the $(DUnitX.) from the search path as the DUnitX sources should be in the BDSLib directory.
However keep in mind that when you create new DUnitX projects via the Wizard it adds that variable to the project (that is probably where it came from originally) which then might again fail when building with FinalBuilder. I don't know how it behaves without that wrong dot if the variable does not exist.
I am interested in the ability to have F# scripting within my app.
Having something like tryfsharp.org would be great, specifically the Intellisense capability. Is any of this available on Github somewhere? How does this work?
Short answer
The code used for the first cut of TryFSharp with F# 2, which includes Intellisense support, is available as a code drop. As an example Rob Pickering built an online editor for Undertone with it. I suspect the code used on the current TryFSharp site which uses F# 3 will appear in time.
TryFSharp uses Silverlight to host the F# compiler in the client's browser (F# is written in F#). It is also possible to call an instance of the F# compiler running on the server from the browser on demand, which is an approach taken by TryFs.Net and Pit.
Longer answer
There are two sides to scripting:
Editing
Execution
F# already supports editing and execution of (.fsx) script files via F# Interactive.
Editing F# Code
There's no shortage of external editors for F# code:
Visual Studio
SharpDevelop
Xamarin Studio
Emacs
Vim
TryFSharp
F# Notebook
The editor support for Xamarin Studio, Emacs and Vim is based on the open source F# Bindings project, which provides code completion.
SharpDevelop uses the open source AvalonEdit and includes syntax highlighting for F#. You can use AvalonEdit in your own projects, for example the open source Refunctor project uses it to provide F# editing inside Reflector.
There are also a couple of new editors for F# on the horizon:
Cloud Sharper - web based F# IDE
Tsumani IDE - embedded editor for Excel, Hadoop, etc.
AvalonEdit is a good place to start for a desktop based embedded editor. Once you've chosen an editor environment then you need to choose between simple syntax highlighting or more advanced integration using F# Bindings. If you suspect people will use an external editor then syntax highlighting may be sufficient.
Bring your own editor is probably the easiest place to start which just leaves execution.
Executing F# Code
Options for executing F# code:
F# CodeDOM from the F# PowerPack
F# Compiler via the F# compiler code drop or invoking fsi.exe
Compiling a snippet with the F# CodeDOM:
open Microsoft.FSharp.Compiler.CodeDom
open System.CodeDom.Compiler
let compile snippet =
use provider = new FSharpCodeProvider()
let options = CompilerParameters(GenerateInMemory=true)
provider.CompileAssemblyFromSource(options, [|snippet|])
let snippet = """
module Snippet
let x = 1
"""
let results = compile snippet
I've used F# to do some quick data-analysis using datastructures from another project. To do so, it needs access to this project; i.e. it needs an assembly reference - but the project is an executable.
I've tried this in F# interactive, and it almost works*; I can #I the appropriate path and #r the executable and a few support dll's - but I can't actually use em. And whatever I do, I can't get the reference into a compiled F# program: VS lets me add a reference just fine, and the appropriate compiler option -r:X:full\path\here.exe is correctly generated by the project, but none of the datastructures are present and the compiler complains of non-existent namespaces; it's as if the reference didn't exist. The application is 64-bit, which may be relevant. 64-bit dll's work fine.
(*) after setting fsi.exe to run in 64-bit mode it thinks it can load it, but actually using it returns FS0193: internal error.
How can I reference a managed 64-bit executable from an F# project?
To others with this same issue: as a workaround, I'm now compiling the executable as Any CPU (which will be executed in 64-bit mode, so behaves the same). This allows FSI and the compiler to reference it. Based on the questions referenced in the comments, this seems to be a known bug that will hopefully be fixed some day.
I have a 3rd party .dll that I have successfully added as a reference in both a VS 2010 C# project and an F# VS 2010 project. I can view the contents in the object browser in both cases, but the F# version won't let me "open" the library. It works fine in the C# project (with the "using" directive), and I can write a program that uses the contents of this particular .dll. I have not had any trouble with other .dlls in F#/VS 2010/.NET 4.0 on Windows 7.
Any ideas as to why this might be happening? Or how I could debug this further?
See what the csc.exe and fsc.exe command-lines have for the library in question (in VS, open the 'Output Window' after a rebuild), to see if they both have the same reference (e.g. -r:Path\Library.dll).
And to be clear, you're saying
open NagLibrary
in F# yields the error message in the title, but
using NagLibrary;
in C# works and opens the namespace?
make sure you reference the path within the script using the double "\" convention
for me this worked
#r "C:\homeware\\blp\\api\\APIv3\\DotnetAPI\\v3.4.5.4\\lib\\Bloomberglp.Blpapi.dll"
open Bloomberglp.Blpapi
I'm trying to use the Seq.generate_using function but unfortunately, I don't seem to be able to find it. I thought it would be living here:
Microsoft.FSharp.Collections.Seq.generate_using
But it doesn't. I am getting the error listed below.
C:\Users\Owner\Documents\Visual Studio
2008\Projects\fsharp1\Program.fs(54,63):
error FS0039: The value, constructor,
namespace or type 'generate_using' is
not defined. A construct with this
name was found in
FSharp.PowerPack.dll, which contains
some modules and types that were
implicitly referenced in some previous
versions of F#. You may need to add an
explicit reference to this DLL in
order to compile this code.
According to the Sept 2008 CTP Release Notes:
The F# library is split into two
components. FSharp.Core.dll: Contains
the core F# libraries, which will be
stabilized and versioned infrequently.
FSharp.PowerPack.dll: Contains
additional useful F# libraries and
tools which will version more
frequently, and allow continued
innovation on top of the core F#
language and libraries.
Some methods in the Seq module were moved into the FSharp.PowerPack assembly, so you can only get those methods by doing the following:
If you're using Visual Studio, open your Solution Explorer, right-click on the project file, choose "Add Reference", and add "FSharp.PowerPack.dll".
If you're using a script file or fsi, then type #r "FSharp.PowerPack";; to load the assembly.
Now you should be able to call Seq.generate_using.
The #r "FSharp.PowerPack";; works for me but the addition of PowerPack to my solution does not. I am trying to use HashSet<>.