My favorites | Sign in
Project Logo
Project hosting will be READ-ONLY Wednesday at 8am PST due to brief network maintenance.
                
Search
for
Updated Feb 04 (5 days ago) by wildart
Labels: Featured, Phase-Deploy
FSharpBinding  
F# support for Monodevelop

F# support for Monodevelop

F# support provided through addin for Monodevelop (2.0 Alpha). You could find new version of Monodevelop in Mono 2.0 Preview

Source Code

Checkout source code from repository: svn checkout http://wildart.googlecode.com/svn/trunk/FSharpBinding

Compilation

This addin should be compiled in new version of Monodevelop (2.0 Alpha):

Installation

To install F# support for Monodevelop, copy compiled binary MonoDevelop.FSharpBinding.dll to ~/.config/MonoDevelop/addin

Open Monodevelop and go to Edit -> Properties -> Other -> F#. There you could find global setting for F# compiler. You have to setup following options:

Project compilation options

For opened project you could change compilation options, such as:

F# project compilation

Because F# compiler has some annoying issue calculating dependencies by providing order of source files during compilation, please add source files to project in order acceptable for compiler. To change source files order in existing project - edit project file manually.

Update: New version supports file ordering in project. Use right-click menu on project or project file for:

Syntax Highlighting

File FSharpSyntaxMode.xml contains color scheme for F# syntax. Copy this file to ~/.config/MonoDevelop/syntaxstyles to get syntax highlighting in source editor.

Note: Syntax highlighting does not work out-of-box in Mono 2.0 preview release. You need to compile Monodevelop from sources to get it work.


Comment by davnul, Mar 31, 2009

Thanks for you work...

Unfortunately, i'm new to monodevelop and i don't manage to build the FSharpbinding solution with Monodevelop : i get 6 errors about "cannot find metadata file... " concerning MonoDevelop?..dll files

I'm using Monodevelop 1.9.1 (2.0 Alpha) as i'm using Mac OS X.

Comment by joandrade, Apr 09, 2009

Hi! I am having the same problem that davnul. Only I get 6 "cannot find metadata file" for files supposedly on my home directory and 4 for other files. Sorry but I am really new to MonoDevelop? (and Mono/.Net in general). Any help will be appreciated.

Comment by zorglub421, May 08, 2009

for the MonoDevelop?.Projects.Parser error, modify the three files to reflect this change:

using MonoDevelop?.Projects.Parser; -> using MonoDevelop?.Projects.Dom.Parser;

Comment by p.westcott, May 09, 2009

Another newbie to Mono/MonoDevelop??...

I have "fixed" references, updated the using statements (as per zorglub421's instructions), but now I'm getting the following error:

.../FSharpBinding/Gui/CodeGenerationPanel??.cs(51,47): error CS0030: Cannot convert type MonoDevelop?.Projects.ConfigurationParameters?' to FSharpBinding.FSharpCompilerParameters' .../FSharpBinding/Gui/CompilerOptionsPanelWidget??.cs(44,72): error CS0030: Cannot convert type MonoDevelop?.Projects.ConfigurationParameters?' to FSharpBinding.FSharpCompilerParameters'

I'm using the 2.0 distribution with Ubuntu 9.04

Any help would be appreciated.

Comment by zorglub421, May 11, 2009

Got the same cast issue than the gentleman right above. I'm using monodevelop 2.1 snapshot of around 2009-05-05, the one used to issue the precompiled .DMG for MAC OSX. Mono is release 2.4. Such a pitty. Would like to learn F# on this platform. I'm a GUI frustrated OCaml'ers :-)

Comment by makotosa...@yahoo.co.jp, May 16, 2009

Line=51, Column=73, Type=Error, Priority=Normal, Description=Cannot convert type `MonoDevelop.Projects.ConfigurationParameters' to `FSharpBinding.FSharpCompilerParameters'(CS0030)?

There seems no copy constructor from `MonoDevelop?.Projects.ConfigurationParameters?' (public ConfigurationParameters? {get; set;}) to `FSharpBinding.FSharpCompilerParameters'.

In the C# source file CompilerOptionsPanelWidget?.cs, the programmar is likely to cast in two steps.

DotNetProject? project -> DotNetProjectConfiguration?

-> FSharpCompilerParameters

As my environment is Fedora 11 development, mono 2.4 (new!, not 2.0), and MonoDevelop? 2.0 (not alpha), there might exists a slight language change of C# for mono (gmcs).

Comment by st...@live.ru, Sep 19, 2009

Line=51, Column=72, Type=Error, Priority=Normal, Description=Cannot convert type `MonoDevelop.Projects.ConfigurationParameters' to `FSharpBinding.FSharpCompilerParameters'(CS0030)??

Comment by st...@live.ru, Sep 19, 2009

Line=44, Column=98, Type=Error, Priority=Normal, Description=Cannot convert type `MonoDevelop.Projects.ConfigurationParameters' to `FSharpBinding.FSharpCompilerParameters'(CS0030)?

Comment by st...@live.ru, Sep 19, 2009

Will tell more please dostpney how to fix it?

Thank you for plugin.

Comment by rsdpisuy, Sep 29, 2009

I have same question as p.westcott. Can you please provide information how can I fix this problem?

Comment by vigalchin, Dec 16, 2009

I am using Monodevelop 2.0. Which file is the FSharpBinding solution?? FSharpBinding.mds? If FSharpBinding.mds is the solution file, then I am getting 10 errors "cannot find metadata" errors as other posters reported. I don't understand the solution advocated by zorglub421 .... please help ...

Regards,

Vasili

Comment by vigalchin, Dec 16, 2009

BTW:

Open FSharpBinding solution in Monodevelop Check and fix references

What does "Check and fix references" mean?

Vasili

Comment by q...@spray.se, Dec 21, 2009

Vasili: The references, for MonoDevelop? namespace, in the project are wrong and needs to be re-added.

Still, the code is out of date for MonoDevelop? 2.2. IDotNetLanguageBinding seems to have changed a lot. I tried to fix it but gave me strange errors at the time, and I'm no expert at C# so I simply gave up, sorry.

Comment by igor.a.mironov, Dec 31, 2009

I've created a patch that allows FSharpBinding revision 26 (current trunk) to compile cleanly against MonoDevelop? 2.0. Don't know how to attach files here so see the patch inline below.

Index: Gui/CodeGenerationPanel.cs
===================================================================
--- Gui/CodeGenerationPanel.cs	(revision 26)
+++ Gui/CodeGenerationPanel.cs	(working copy)
@@ -26,7 +26,7 @@
 using MonoDevelop.Projects.Gui.Dialogs;
 using MonoDevelop.Core;
 using Mono.Addins;
-using MonoDevelop.Projects.Parser;
+using MonoDevelop.Projects.Dom.Parser;
 using MonoDevelop.Ide.Gui;
 
 using Gtk;
Index: Gui/CompilerOptionsPanelWidget.cs
===================================================================
--- Gui/CompilerOptionsPanelWidget.cs	(revision 26)
+++ Gui/CompilerOptionsPanelWidget.cs	(working copy)
@@ -24,7 +24,7 @@
 using MonoDevelop.Core;
 using MonoDevelop.Core.Gui;
 using MonoDevelop.Projects;
-using MonoDevelop.Projects.Parser;
+using MonoDevelop.Projects.Dom.Parser;
 using MonoDevelop.Projects.Text;
 using MonoDevelop.Projects.Gui.Dialogs;
 
Index: Project/FSharpResourceIdBuilder.cs
===================================================================
--- Project/FSharpResourceIdBuilder.cs	(revision 26)
+++ Project/FSharpResourceIdBuilder.cs	(working copy)
@@ -43,7 +43,7 @@
 		public string GetDefaultResourceId (ProjectFile pf)
 		{
 			if (String.IsNullOrEmpty (pf.DependsOn) || !File.Exists (pf.DependsOn))
-				return MSBuildProjectService.GetDefaultResourceId (pf);
+				return MSBuildResourceHandler.Instance.GetDefaultResourceId (pf);
 
 			string ns = null;
 			string classname = null;
@@ -80,7 +80,7 @@
 				}
 
 				if (classname == null)
-					return MSBuildProjectService.GetDefaultResourceId (pf);
+					return MSBuildResourceHandler.Instance.GetDefaultResourceId (pf);
 
 				string culture, extn, only_filename;
 				if (MSBuildProjectService.TrySplitResourceName (pf.RelativePath, out only_filename, out culture, out extn))
Index: Project/FSharpCompilerParameters.cs
===================================================================
--- Project/FSharpCompilerParameters.cs	(revision 26)
+++ Project/FSharpCompilerParameters.cs	(working copy)
@@ -30,7 +30,7 @@
 	/// <summary>
 	/// This class handles project specific compiler parameters
 	/// </summary>
-	public class FSharpCompilerParameters: ICloneable
+	public class FSharpCompilerParameters: ConfigurationParameters, ICloneable
 	{
 		// Configuration parameters
 		
@@ -61,7 +61,7 @@
 		[ItemProperty ("TreatWarningsAsErrors", DefaultValue = false)]
 		bool treatWarningsAsErrors;
 	
-		public object Clone ()
+		public new object Clone ()
 		{
 			return MemberwiseClone ();
 		}
Index: FSharpLanguageBinding.cs
===================================================================
--- FSharpLanguageBinding.cs	(revision 26)
+++ FSharpLanguageBinding.cs	(working copy)
@@ -28,7 +28,7 @@
 using System.Threading;
 
 using MonoDevelop.Projects;
-using MonoDevelop.Projects.Parser;
+using MonoDevelop.Projects.Dom.Parser;
 using MonoDevelop.Projects.CodeGeneration;
 using MonoDevelop.Core;
 
@@ -59,13 +59,13 @@
 			return compilerManager.CanCompile(fileName);
 		}
 		
-		public BuildResult Compile (ProjectFileCollection projectFiles, ProjectReferenceCollection references, DotNetProjectConfiguration configuration, IProgressMonitor monitor)
+		public BuildResult Compile (ProjectItemCollection items, DotNetProjectConfiguration configuration, IProgressMonitor monitor)
 		{
 			Debug.Assert(compilerManager != null);
-			return compilerManager.Compile (projectFiles, references, configuration, monitor);
+			return compilerManager.Compile (items, configuration, monitor);
 		}
 		
-		public ICloneable CreateCompilationParameters (XmlElement projectOptions)
+		public ConfigurationParameters CreateCompilationParameters (XmlElement projectOptions)
 		{
 			FSharpCompilerParameters pars = new FSharpCompilerParameters ();
 			if (projectOptions != null) {
@@ -75,7 +75,12 @@
 			}
 			return pars;
 		}
-		
+
+		public ProjectParameters CreateProjectParameters (XmlElement projectOptions)
+		{
+			return null;
+		}
+
 		public string CommentTag
 		{
 			get { return "//"; }
Index: FSharpBindingCompilerManager.cs
===================================================================
--- FSharpBindingCompilerManager.cs	(revision 26)
+++ FSharpBindingCompilerManager.cs	(working copy)
@@ -53,7 +53,7 @@
         }
         
 
-		public BuildResult Compile (ProjectFileCollection projectFiles, ProjectReferenceCollection references, DotNetProjectConfiguration configuration, IProgressMonitor monitor)
+		public BuildResult Compile (ProjectItemCollection projectItems, DotNetProjectConfiguration configuration, IProgressMonitor monitor)
 		{
 			FSharpCompilerParameters compilerparameters = (FSharpCompilerParameters) configuration.CompilationParameters;
 			if (compilerparameters == null) compilerparameters = new FSharpCompilerParameters ();
@@ -65,6 +65,7 @@
             AddOption(writer, "--fullpaths");
             AddOption(writer, "--utf8output");
                     
+			ProjectReferenceCollection references = null;
 			if (references != null) {
 				foreach (ProjectReference lib in references) {
 					if ((lib.ReferenceType == ReferenceType.Project) &&
@@ -73,17 +74,19 @@
 					foreach (string fileName in lib.GetReferencedFileNames (configuration.Id)) {
 						switch (lib.ReferenceType) {
 						case ReferenceType.Gac:
-							SystemPackage pkg = Runtime.SystemAssemblyService.GetPackageFromFullName (lib.Reference);
-							if (pkg == null) {
+							SystemPackage[] pkgs = Runtime.SystemAssemblyService.GetPackagesFromFullName (lib.Reference);
+							if (pkgs == null || pkgs.GetLength(0) <= 0) {
 								string msg = String.Format (GettextCatalog.GetString ("{0} could not be found or is invalid."), lib.Reference);
 								monitor.ReportWarning (msg);
 								continue;
 							}
-                            else if (pkg.IsInternalPackage) {
+							foreach (SystemPackage pkg in pkgs) {
+                            if (pkg.IsInternalPackage) {
 								AddOption(writer,"-r \"" + fileName + "\"");
 							} 
 							if (pkg.GacRoot != null && !gacRoots.Contains (pkg.GacRoot))
 								gacRoots.Add (pkg.GacRoot);
+							}
 							break;
 						default:
 							AddOption(writer,"-r \"" + fileName + "\"");
@@ -147,6 +150,7 @@
 				AddOption(writer, String.Format("--nowarn {0}", compilerparameters.NoWarnings));
 			}
 			
+			IEnumerable<ProjectFile> projectFiles = projectItems.GetAll<ProjectFile> ();
 			foreach (ProjectFile finfo in projectFiles) {
 				if (finfo.Subtype == Subtype.Directory)
 					continue;
@@ -188,8 +192,10 @@
 			TempFileCollection tf = new TempFileCollection();
 
 			string workingDir = ".";
-			if (projectFiles != null && projectFiles.Count > 0) {
-				workingDir = projectFiles [0].Project.BaseDirectory;
+			if (projectFiles != null) {
+				IEnumerator<ProjectFile> enumerator = projectFiles.GetEnumerator();
+			if (enumerator != null && enumerator.MoveNext()) {
+				workingDir = enumerator.Current.Project.BaseDirectory;
 				if (workingDir == null)
 					// Dummy projects created for single files have no filename
 					// and so no BaseDirectory.
@@ -197,6 +203,7 @@
 					// ProcessStartInfo.WorkingDirectory - not able to handle null
 					workingDir = ".";
 			}
+			}
 
 			LoggingService.LogInfo (compilerName + " " + writer.ToString ());
Comment by igor.a.mironov, Jan 03, 2010

Attached a working patch to defect 2 in the issue tracker.

Comment by makotosa...@yahoo.co.jp, Jan 04, 2010

In monodevelop.i686 0:2.1.0-4.fc12, I still need modifications; for example, pkg (in pkgs) -> pkg2 (?), to avoid conflictions of namespace. I think the brace / indent is misleading. (See the errors in FSharpBindingCompilerManager.cs)

In my convention, not

if () {

something
}

but

if () {

something
}

is the case. (However, it is not fruitful to argue conventions here.)

I still have 10 errors of the followings,

/home/makoto/FSharpBinding/Gui/CodeGenerationPanel?.cs(84,40): error CS0508: FSharpBinding.CodeGenerationPanel?.CreatePanelWidget?()': return type must be Gtk.Widget' to match overridden member `MonoDevelop?.Core.Gui.Dialogs.OptionsPanel?.CreatePanelWidget?()' /home/makoto/MonoDevelop?/main/build/bin/MonoDevelop?.Core.Gui.dll (Location of the symbol related to previous error)

/home/makoto/FSharpBinding/gtk-gui /generated.cs(29,21): error CS0234: The type or namespace name UIManager' does not exist in the namespace Gtk'. Are you missing an assembly reference?

/home/makoto/FSharpBinding/gtk-gui/generated.cs(55,38): error CS0234: The type or namespace name UIManager' does not exist in the namespace Gtk'. Are you missing an assembly reference?

/home/makoto/FSharpBinding/gtk-gui/generated.cs(74,27): error CS0234: The type or namespace name ActionGroup??' does not exist in the namespace Gtk'. Are you missing an assembly reference?

/home/makoto/FSharpBinding/gtk-gui/generated.cs(78,27): error CS0234: The type or namespace name ActionGroup??' does not exist in the namespace Gtk'. Are you missing an assembly reference?

/home/makoto/FSharpBinding/gtk-gui/FSharpBinding.CompilerOptionsPanelWidget?.cs(30,21): error CS0234: The type or namespace name ComboBox??' does not exist in the namespace Gtk'. Are you missing an assembly reference?

/home/makoto/FSharpBinding/gtk-gui/FSharpBinding.CompilerOptionsPanelWidget?.cs(34,21): error CS0234: The type or namespace name ComboBoxEntry??' does not exist in the namespace Gtk'. Are you missing an assembly reference?

/home/makoto/FSharpBinding/Gui/CompilerOptionsPanelWidget?.cs(142,40): error CS0508: FSharpBinding.CompilerOptionsPanel?.CreatePanelWidget?()': return type must be Gtk.Widget' to match overridden member `MonoDevelop?.Core.Gui.Dialogs.OptionsPanel?.CreatePanelWidget?()' /home/makoto/MonoDevelop?/main/build/bin/MonoDevelop?.Core.Gui.dll (Location of the symbol related to previous error)

/home/makoto/FSharpBinding/Gui/GlobalOptionsPanel?.cs(35,40): error CS0508: FSharpBinding.GlobalOptionsPanelPanel?.CreatePanelWidget??()': return type must be Gtk.Widget' to match overridden member `MonoDevelop?.Core.Gui.Dialogs.OptionsPanel?.CreatePanelWidget?()' /home/makoto/MonoDevelop?/main/build/bin/MonoDevelop?.Core.Gui.dll (Location of the symbol related to previous error)

/home/makoto/FSharpBinding/Commands/FSharpBindingNodeExtension.cs(50,30): error CS0505: FSharpBinding.FSharpBindingNodeExtension.BuildNode?(MonoDevelop?.Ide.Gui.Components.ITreeBuilder, object, ref string, ref Gdk.Pixbuf, ref Gdk.Pixbuf)': cannot override because MonoDevelop?.Ide.Gui.Components.NodeBuilder?.BuildNode?(MonoDevelop?.Ide.Gui.Components.ITreeBuilder, object, ref string, ref Gdk.Pixbuf, ref Gdk.Pixbuf)' is not a method /home/makoto/MonoDevelop?/main/build/bin/MonoDevelop?.Ide.dll (Location of the symbol related to previous error)

I will think of it later.

Comment by akrai.iitk, Jan 08, 2010

I successfully compiled the binary and copied the MonoDevelop?.FSharpBinding.dll file to ~/.config/MonoDevelop?/addin . But still on running monodevelop i dont see an option to add F# .....

Can anyone tell me what's happening here??

Comment by scottwferg, Feb 07 (43 hours ago)

Just an FYI, the instructions say deploy to ~/.config/MonoDevelop?/addin/ when you should be deploying to ~/.config/MonoDevelop?/addins/

Comment by igor.a.mironov, Yesterday (32 hours ago)

Hi,

The patch from issue #2 that fixes compilation issues and other problems has been rolled into branch fsharpbinding-v2.0.

The add-in can be built from the command line using standard ./configure; make. It auto-configures during the build for the version of MonoDevelop? that you use. The build also creates the Mono repository, which allows you to install the add-in using MonoDevelop? GUI (Tools -> Add-in Manager -> Repositories… then Install Add-ins) or the command line tool mdutil (see build log for details).

Once you've installed the add-in, don't forget to set F# compiler path (Edit -> Preferences -> Other -> F#).

Cheers!


Sign in to add a comment
Hosted by Google Code