I suggest we ...

Support mixed F# and C# projects in order to extend F# usage

Support mixing F# and C# source files in the same project in order to support a gradual move to F# for new users/organisations and to support cases where tooling is oriented at C# (F# not supported)

For instance I could use this feature to slowly move a C# project to F# one class at the time. Another example would be to use C# tooling to generate web infrastructure like ASP.NET 5 controllers (because F# does not currently have templates for this) and then call directly into F# from those.

P.S. Other languages that F# compares to like Scala already supported mixed projects

121 votes
Sign in
Sign in with: Facebook Google
Signed in as (Sign out)
You have left! (?) (thinking…)
zjv shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →


Sign in
Sign in with: Facebook Google
Signed in as (Sign out)
  • Anonymous commented  ·   ·  Flag as inappropriate

    This would be great for us and our use case! We have a major calculation engine in C# where the core functionality would be much better represented in F# but where the more user oriented layers would perhaps be better represented in C#.

  • Gauthier Segay commented  ·   ·  Flag as inappropriate

    Charles Roddie, this would work with "islands" of C# files compiled together and knowing about previous compiled islands, 1.cs can't know about 4.cs in your case.

  • Charles Roddie commented  ·   ·  Flag as inappropriate

    How is this compatible with file order requirements?

    1.cs, 2.fs, 3.fs, 4.cs

    Presumably the fs files can refer to previous cs files, and the cs files can refer to each other. Then 2.fs can refer to 1.cs which can refer to 4.cs which can refer to 3.fs. So 2.fs can effectively refer to 3.fs and the whole linear order of F# is broken, isn't it?

  • mmc commented  ·   ·  Flag as inappropriate

    Another valuable usecase for this would be to F# projects that needs to be consumed from other .NET languages like C#. A mixed F# project could have all the private logic as F# files but the main exposed interfaces as C#.

  • Gauthier Segay commented  ·   ·  Flag as inappropriate

    I think kotlin has such support with java too.

    I'd see this idea coming to fruition first in scripting:

    #load @"path/to/file.csx"

    where it is easy to figure out the topoligical graph of script files to include, compile in separate assemblies and link.

    If this is made, then work on same feature in project system would be great.

    I think that would also give few kicks to Jetbrains to finally start implementing F# support and more importantly, this would restore some trust in having the whole of MS people working on .NET focused on making best platform with highest level of interop among all the languages, having them invest major engineering efforts which benefits all the languages (current and future) to have easy embedding of all IL compilers in a meta compiler.

    F# file ordering is also a major aspect making this seem viable.

  • Anonymous commented  ·   ·  Flag as inappropriate

    Nemerle's support for mixed C# and Nemerle source files was a very appealing feature when I first found it. Although the Nemerle compiler was built as something like a fork of the C# compiler. I would be much more inclined to use F# if I didn't have to 100% commit to it. As functional as C# is getting, it would be nice at times to leave the C behind.

F# Language

Feedback and Knowledge Base