I am building a project system for Visual Studio MVC web projects with controllers written in F#. It comes along pretty cool. I can build and run the apps, but I have a problem with FSharp Language Service.
In the editor it shows the syntax colorization and diagnostic as it should. With one problem - it does not pick up project references. Even though during build it picks them up and successfully builds the project, on the screen it shows the objects/namespaces from the referenced assemblies/projects as unresolved.
If somebody out here has some knowledge about integrating with F# Language service - please help me make it work
In response to Tomas:
The code for F# controllers is in the project file and as I already mentioned I can compile and run it. Originally we kept the F# code in a separate project and desire to get rid of this extra complexity is what prompted this project. It is not a ASP.MVC though it is Bistro MVC.
Edit
BistroMVC now solves this problem in the latest version of the Bistro Designer which is based on the F# project extender
Do you keep your F# source code as part of the Web Project? I'm not sure if this is even possible for ASP.NET MVC, but it was possible in ASP.NET WebForms. With WebForms projects, it didn't work very well (because F# wasn't aware of the project context). I believe it was possible to overcome this with a hacky #if like this:
#if EDITING
#r "Your.Referenced.Library.dll"
#endif
This would serve only as a hint to the editor... However it is much better idea (if it is possible) to write F# controllers in a separate F# project. In that case you shouldn't have any issues (at least I hope so!)
Can you describe what you're doing in more detail? Is this a "flavoring", or a new project system? Are other aspects of the 'project environment' picked up? For example, if you have F# code with
#if DEBUG
let x = 3
#else
let x = 4
#endif
does the coloring change when you change the VS solution from Debug to Release?
(Offhand I am unsure if it will be possible to fully integrate the F# language service into a user-defined project system; if you want more of a discussion, you can email fsbugs#microsoft.com and I'll respond there.)
Related
I am using rider but some reasons I can't see any option to create web-related projects with F#.
I even installed the Girafe template but I still don't see anything in the project creation panel.
is there anything I can do to projec templates with F# in Rider?
Unfortunately Rider does not support these web templates. I mean we have disabled them intentionally in the Rider's source code ~ 2 years ago:
// HACK: Do not show F# web templates
if (info.GroupIdentity.StartsWith("Microsoft.Web") && info.GetTagValue(LanguageGroupProvider.LanguageTag) == "F#") continue;
In 2019.2 (the next release) we will enable them because for know all known issues with F# and web were fixed. We just forgot to enable templates.
I can suggest to use dotnet command line for now. Sorry for inconvenience.
This issue is exactly as described in the title.
I have a portable F# class library. I have created an ASP.NET Core Web Application (both .NET Framework and .NET Core), from which I have tried to add a reference to my F# class library.
Trying to add the reference gives a message:
The following projects are not supported as references:
Project type is unsupported by current project and can not (sic) be referenced.
This is extremely disappointing, as the .NET Core is now in General Availability.
Are there any workarounds while this bug gets addressed?
I have a project, which I started with Beta8 bits of .net core and since then I have an F# library, which I use from an asp.net core C# app. (btw here is an RC2 based minimal sample for referencing the F# lib from a net core based console app)
Here is how I did it:
Currently (according to my knowledge) there is no template in VS to create a coreCLR based F# library (the PLC templates under F# are all Full framework based, but that you still cannot reference from asp.net core even if it runs on full framework), so you have to do this with the command line. This is done by:
dotnet new --lang F#
This creates you a hello world coreCLR F# app. You can turn the app into a class library by modifying project.json file.
If you have a VS solution and you click to “Add” -> “Existing project” you can select the project.json file. This way you add it to your solution (and btw. an xproj file will be also created).
So at this point you will have the coreCLR based F# project in your solution. I believe by right clicking the asp.net core project and go to “Add” -> “Reference” -> Projects->Solutions and selecting the F# library you can already reference it. If this does not work, you can do it manually: just list the F# project under the “dependencies” in the project.json of the asp.net core application.
If your asp.net core app runs on full framework still need to do these steps. It actually doesn't really matter.
Now the bad part:
In the RTM (released on Monday) the “dotnet new” command creates an uncompliable F# app, because of some dependency issues. This is tracked here (the title says "on macOS", but it's the same on Windows) and as soon as it’s solved this should be fine (or if you did not yet install RTM and you have RC2 you are also good).
Intellisense and debugging across F# and C# does not work (I posted it here)
Although .NET Core has officially been released, the vast majority of the nuget packages in the ASP.NET Core Web Application are in prerelease. Moreover, although the entity framework identity model has been cleaned up, my attempt to change the key columns for users and roles from strings to ints generated an obscure error when I tried to implement Entity Framework migrations. I know I can do it for a .NET Web Application, even though the process is clunky in places. So for now I have gone back to using a .NET Framework Web Application. I'm looking forward to seeing a fully mature version of ASP.NET Core Web Applications. It's not ready, but it looks very promising.
In the Build 2011 keynote and demos, they were always talking about C++, C#, Visual Basic and JavaScript. Can't I build Metro style Apps with F#? Or is it safe to say that if it works with C#, then it works with F# as well?
Or is it eligible to say if it works with C# then it works with F# as well?
Yes, that's how it is supposed to work. In addition to javascript and C/C++, any CLS compliant language that runs on top of the CLR will have access to the WinRT API.
Unfortunately in the VS 2011 Express edition you don't get tooling support but I guess this will be added progressively or to other editions:
Don talks about this a little around 7:40 into his talk.
http://channel9.msdn.com/Events/BUILD/BUILD2011/SAC-904T
I had the same question and created a blog post: Create a Metro App in F# (NOT)
There are a few issues:
You cannot reference ordinary .NET dll’s (even in C#). They have to
be have recompiled with a “reference” to the WinRT. Because of this
you cannot reference the F# dll. I think this will be solved when F#
3.0 get released (source: Understanding F# slide from Don Syme at
build).
The ability from F# to create Metro apps. This has to be
built by the F# team. This is an open question. This is the all-F#
approach (In WPF it is today possible but not recommended).
Tool support for creation Metro front-end projects. This will be not the case for the
F# 3.0 release. (source: Understanding F# slide from Don Syme at
build).
Using Visual Studio 11 Developer Preview (Full, not Express), I was able to reference and run F# code from a C# Metro style application with the following caveats:
You will get a build warning saying that the project can't be referenced, even though Visual Studio will still allow you to add it.
You must remove all references to all DLL's in the F# project, including FSharp.Core.
By following these steps it is possible to run F# code from a C# Metro style application, but it is nearly impossible to write any useful code in F# without references to the core language libraries. Let's hope they update the libraries to be WinRT compatible soon.
The question has been answered here:
Windows 8 and F#
Although you cannot create and design Metro apps directly in F#, you can still create so called Portable library in F# with all Models and ViewModels and use it in another Metro projects. It's not ideal, but it works.
I ported my stock chart library for .NET3.5-4.0 to Portable library,it works quite well on Metro with C# Metro application and some my Metro UI bridge.
I'm convinced that I can use F# to make Metro application in many parts.
I've always used VS for .NET development, but am just wondering about the alternatives around now. I'm especially interested in use for ASP.NET MVC development. I'm not bothered about any of the visual design aspects of vs, but of course love intellisense and the debugging features.
So, for anyone who has tried SharpDevelop when doing ASP.NET MVC:
How did you get on?
What are the main disadvantages and pain points?
Thanks
By the looks of it, SharpDevelop won't have any problems compiling the project and editing the source...you just won't get any tooling support. From what I've read, that includes aspx files.
Having said that, there does seem to be some movement around an ASP.NET plug-in editor for SharpDevelop here.
Source: http://community.sharpdevelop.net/forums/t/7872.aspx
As an aside, it might to nice to update this question with your experiences if you go down that route... (:
I have used SharpDevelop to create an ASP.Net WebForms project - didn't have too many issues with it. The lack of a visual designer is certainly annoying, but it forces you to think about the source directly, which is a good thing...
I haven't done anything with MVC yet - though from the sounds of things the only thing that's stopping SD at the moment is the tooling. The core developers might have no plans for that, but it's an open source project, so there's nothing stopping an independent effort.
I've gone a very limited amount of work (bug investigation) with the SD code - it seems to me that once you understand their classes it's not bad code... Their failing as a project has been (as it is with most open source efforts) that everyone wants to code, so the documentation gets ignored. No-one likes writing documentation, but clear documentation might have led to far greater participation...
It's a great project, but their decision to ignore the web is madness.
As Kieron said, you'll be able to compile and you'll lack tooling. Unfortunately, #Develop's forum says that they don't plan to directly support it:
ASP.NET support is not planned for SharpDevelop.
The lack of tooling and knowing that it's not coming anytime soon would be the major pain point for me.
I'd like to create an application using ASP.NET MVC, that should run under mono 2.4 (compiling will be done on a Windows box). Has anyone getting luck with this? Here is what I've already tried:
ASP.NET MVC on mono without any persistence model support, and using nhaml as the view engine
S#aml architecture, which is a quite good framework imho, but it depends too much on stuff, that are not working good under mono (like windsor)
The first part worked fine, I didn't encounter any major problems. But I couldn't get the second part working. It seems it's dependency on Castle.Windsor breaks the whole mono support (but there might be other parts too).
Therefore I decided to create an alternative framework, that borrows some of the ideas of s#arp-architecture, but designed to be working under mono (and if I'm able to do this I'll release it for the community of course). The controller and view part is working fine (not much magic here though, they have been always working), but I have some questions before I start job on the persistence part:
What NHibernate versions are working under mono? I've heard 1.2 is working fine. Does 2.0.1/2.1 beta work under mono?
Does Fluent.NHibernate and NHibernate.Linq work under mono? (for the latter it seems it needs some dependcies that aren't avaialable in mono)
Are there any good alternatives for persistence support to NHibernate under mono?
Alternative questions:
Are there any frameworks that have mono+persistence+asp.net mvc support already or am I the first one to think about this?
If you have already done this: what are your opinions on stability/usability?
Thanks for the answers
EDIT: Updated the framework to support ASP.NET MVC 2: http://shaml.sztupy.hu/
I am using mono 2.4 to run a asp.net mvc app + windows service.
Compatibility is very good. There are some bugs and differences than with windows but once you learn what they are it gets easier (there can be pain at the start!)
I am using NHibernate (2.1) FluentNhibernate, StructureMap, NBehave, Moq and open id lib and they all just seem to work as expected.
As for stability, since I have ironed out the major bugs in my code I haven't had any problems.
Usability, well it is a completely different platform so you need to come to it with an open mind and be prepared to leave behind the windows way.. the good news is that once you do that things get easier. Apache is a lot nicer than IIS and configuring and managing a linux box is just easier than windows.
I am pretty glad I choose mono.. sorry this is starting to sound like a PR drive - but I am just really happy with it!!
Okay. I started on a new project that incorporates the best from S#arp Architecture with stuff, that work on mono. Instead of T4Toolkit it uses a ruby script to do the generation job, just as with rails or merb.
To use install the shaml gem from github:
gem install shaml
Then create a new application:
shaml generate app AppName
And create resources:
shaml generate resource NewRes "name:string;date:DateTime"
S#aml Architecture project homepage: http://shaml.sztupy.hu/
GitHub project: http://github.com/sztupy/shaml/tree/master