Support more than one .NET language within a project
I would like to use C# or VB.NET along side F# within the same project without being forced to place that code in it's own project. The language of each code file would be determined by it's file extension as it is now. They all compile to IL, so it shouldn't be a problem to link them all together into one DLL.
For backwards compatibility with existing .csproj, .vbproj and .fsproj files, there would probably need to be a new project format -- something like .netproj that would support multiple language code files.
If C# code files and VB.NET code files can coexist in the same solution, that will be very handy. Users do not need to create a new solution in either C# or VB to finish their tasks. That could reduce the code complexity.
Benjamin Holland commented
Jonas N commented
I would love this, especially to mix C# and F#. F# is perfect for some math-intensive scenarios, but unwieldy in others. I don't really understand why it hasn't become a feature already since, as you say, it all compiles to IL anyway, and the mixed code would reside within the same root namespace, etc.
This is a wonderful idea i want the same thing
Would that it be possible
I want this too. I want to use C++/CLI, C#, and F# in one project (not in multiple projects in one solution).
Luis Francisco Ramirez Daza Gonzalez commented
"ONE ASP.NET" ??????
So why don't we have a "ONE LANGUAGES"
Please at least do it for C# + VB
I think if you now have Roslyn it couldn't be so hard to do it.
1- I have some T4 templates that want to use in my project, but some of them generate code in C# only and others generate code in VB.NET only, so I neeed to moce each T4 to a separated project and copile de DLL and then IL Merge it back or traslate C#->VB or viceversa.
2- In ASP.NET we want to use VB.NET as the code behind language, but use C# for the Razor pages (because I think Razor was claerly designed with C# in mind as the deault language and using VB.NET in razor is more clumsy.
If this also supported partial class definitions across languages, then I would use it for those times when I just want to use VB.NET's XML Literals within a couple methods of a class that's in a C# project.
Michael Siroen commented
A different setup you could use is making multiple assemblies and stitch them together with ILMerge ( http://research.microsoft.com/en-us/people/mbarnett/ILMerge.aspx ).
Although you still have multiple 'working projects', the resulting assembly is just one DLL.
And it would be really nice if C++/CLI (safe or pure mode) could also be included. In that last scenario, it might be acceptable that not all C++ project options (properties) would be available.
Stephan Tolksdorf commented
If supporting multiple languages within one project is too difficult, please consider improving the Visual Studio support for .netmodules and/or for merging multiple DLLs into one.
I think this would be a valuable addition to VS. As a developer that started with VS 6.0 and had to combine a lot of code written in Fortran with Visual C, this would allow us to move forward and now migrate those Console applications with .NET web apps without having to invest months or years in rewriting legacy code. In VS 6.0 there was no issue, we could just put ant CPP or.f code in the project and VS would compile it.
Mark H commented
Should be noted that you would need to enforce a strict compile order for such feature - as F# requires files to be compiled in a specific order.
I mentioned this idea to a friend who is a Microsoft MVP in Client Application Development. He told me that MSBuild does support doing this. That's even more reason to support it within Visual Studio for all projects.
Andrew Teebay commented
I've always thought this would be a godd idea, especially when getting examples of the internet. Often these are only in C# or VB and not both. Having to translate them is not that hard but why should I have to. It would seem to me that everything is in place to allow either in teh same project (and can infact be done in WebSite projects) so why not allow it in any project?
Simon Jones commented
You can already have multiple projects in a solution, each project in a different language.
Are you asking to mix languages within in one Project?