1

As I learn that I can compile C#6.0 code to run on lower .NET framework,

Post-Answered Note: I realized that the post above only shows that C#6.0 can compile on .NET 4.0. For lower .NET, here is the answer from Mr. Jason Malinowski, who works on the Roslyn project:

"I can't think of a reason why it wouldn't work, but I'm not sure how much that has been tested"

I learn how to code in C#6.0 in Visual Studio 2013 and I read some posts regarding the topic:

And also watching a video:

What I basically understand from them are:

  • You can have C#6.0 feature enabled in VS2013 by using Roslyn Compiler
  • You could use Microsoft.Net.Compilers NuGet package to use Roslyn compiler, but with the cost that the VS2013 itself won't "understand" some codes since the VS2013's internal "live" compiler is not the same as Roslyn.
  • There was once upon a time where such is supported. https://github.com/dotnet/roslyn but the latest version for this is April's End.

(Side question: Anything wrong with my understanding?)

Now my questions are:

  1. As of now, is the a way to workaround with Microsoft.Net.Compilers NuGet package and VS2013 internal "live" compiler such that it can "understand" C#6.0?
  2. "There was once upon a time where such is supported" how can I get this project. As I download the project from github and tried to open it with VS2013, I got the following error:

    enter image description here

    Can we still use the April's End version well in VS2013 that it will understand what it tries to compile?

  3. Any other workaround for this? I would be happy as long as I can code with C#6, using VS2013, and compile it to lower .NET framework.

Thanks!

Note: Unfortunately, using Visual Studio 2015 is not an option for me...

Community
  • 1
  • 1
Ian
  • 30,182
  • 19
  • 69
  • 107
  • Why is VS 2015 not an option? They have a free edition (VS 2015 Community) that's equivalent to VS 2015 Professional. – Tim Jan 25 '16 at 04:15
  • @Tim it is just team's decision to use the current VS (2013) available in the office... Other than that actually VS2015 community is okay... – Ian Jan 25 '16 at 04:17
  • @Tim, Community version does not contain Team server features, where Professional does – Fabio Jan 25 '16 at 05:02
  • @Fabio - What Team server features are you referring to? Do you mean TFS? If so, which specific features of TFS? I have Community 2015 and it integrates with TFS just fine. – Tim Jan 25 '16 at 05:47
  • @Tim, sorry I was referring to this: [Compare Visual Studio 2015 Offerings](https://www.visualstudio.com/products/compare-visual-studio-2015-products-vs). It seems free only for limited amount of users – Fabio Jan 25 '16 at 06:20
  • @Fabio - yes, that is correct. A maximum of 5 users is the limit. I should have mentioned that, thanks. – Tim Jan 25 '16 at 06:23

1 Answers1

2

To summarize the compatibilities and incompatibilities:

  • C# 6.0 (the language) can be used to compile applications that run .NET 4.0; i.e. it does not require .NET 4.5 or higher.
  • There is no supported way to make Visual Studio 2013 understand C# 6.0 code in the IDE. We did release, as you observe, previews of pre-6.0 things that ran on Visual Studio 2013. Those were just intended to be previews while we finished all the work of making Visual Studio 2015.
  • You can install the NuGet package to make the build use C# 6.0 under Visual Studio 2013, but the IDE will still not understand C# 6.0 features and Intellisense and friends will be broken.
  • To build the Roslyn source code as-is (and of this writing), you need Visual Studio 2015 with Update 1, or equivalent tools for Mac/Linux.
Jason Malinowski
  • 18,148
  • 1
  • 38
  • 55
  • Thanks for the answer! I really appreciate it. Aince you might be the most capable person on this matter, may I just clarify with you a couple more things? (1) You specifically mention, "C# 6.0 can compile application that run **.NET 4.0**; i.e. there is nothing in **.NET 4.5 or higher** that is needed to use C# 6.0'. One is .NET 4.0, another is .NET 4.5, does that mean that there is something in .NET 4.0 (but not in .NET4.5+) which is required to use C#6.0? (2) Can C#6.0 be compiled for app run in framework lower than .NET 4.0? – Ian Jan 26 '16 at 01:45
  • For (1) I fixed my wording to be clearer. For (2), I actually don't know. I can't think of a reason why it wouldn't work, but I'm not sure how much *that* has been tested. – Jason Malinowski Jan 26 '16 at 06:03
  • Thanks for the clarification. It helps me a lot. (though I am still pretty sad that I cannot use C#6.0 and VS2013 together as fully :() – Ian Jan 26 '16 at 06:11
  • When we did the preview of Roslyn atop Visual Studio 2013, there were a bunch of caveats and hacks in place. For example, some lesser known features wouldn't work entirely, and things like the debugger were using the old engine that wouldn't know about new C# 6.0 features. The reason we only fully support it for VS2013 is because we had to rewrite or update a bunch of other stuff too. – Jason Malinowski Jan 26 '16 at 17:30
  • "The reason we only fully support it for **VS2013**" Do you mean **VS2015**? – Ian Jan 27 '16 at 01:31
  • Uh yes, typing is hard. – Jason Malinowski Jan 27 '16 at 07:01