Will Roslyn be part of the .NET framework?
Which version and when?
It is actually available at GitHub but it is fairly big and I'm not able to load it in Visual Studio 2013 on Windows 7 without errors.
No, Roslyn is not included in the .Net Framework. Note that, even in .Net Framework 4.6 you'll still find the legacy csc.exe and vbc.exe compilers which we ship for compatibility reasons. They don't support the latest language features and, at release, you'll see that we've changed their banner text to make it clear that these are not the latest versions.
To get the Roslyn-based C# and VB command-line compilers, you have two options:
Install Visual Studio 2015 RC. or
Install the MSBuild_tools installer package.
You'll find the Roslyn-based command-line compilers at %ProgramFiles(x86)%\MSBuild\14.0\bin
Does Roslyn will be part of the .net framework? Which version and
when?
Roslyn will be officaly shipping with Visual Studio 2015 RTM, which is currently in RC (which you can download and try). It is no longer available for VS2013. Generally, there is also a nice web hosted roslyn compiler called TryRoslyn if you want to try it out.
Related
As I learn that I can compile C#6.0 code to run on lower .NET framework,
Does C# 6.0 work for .NET 4.0?
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:
Using Roslyn compiler with Visual Studio 2013
How to enable C# 6.0 feature in Visual Studio 2013?
How can I add C# 6.0 to Visual Studio 2013?
And also watching a video:
https://www.youtube.com/watch?v=tTdhlJFzCRA
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:
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?
"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:
Can we still use the April's End version well in VS2013 that it will understand what it tries to compile?
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...
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.
I have a funny situation where the C# project targets version of .NET framework depending on Visual Studio version rather than depending on selected .NET target version in Application tab of project's properties.
I had VS2013 premium, update 4, installed and the given project targets .NET 3.5.
Afterwards I've installed VS2015 Enterprise edition and opened solution with the given project with VS2015. Resharper suggested use of nameof() operator (which is .NET 6.0 feature) and this compiled, but when I open given solution in VS2013 it doesn't compile anymore.
Here's the screenshot of Application tab for the given project:
Here's the code snippet from the project when I open it in VS2015:
Which compiles successfully.
And here's the code snippet from the project when I open it in VS20103:
Which doesn't compile.
Any clues about this?
UPDATE:
To rephrase my question. Why does the given project (that targets .NET 3.5) compile at all in VS2015 even though I've used .NET 6.0 feature (nameof() operator)?
This is normal behaviour. If you try to compile something .NET 4.0 specific in VS 2005, you will get the same result. Using a certain VS version you can only develop using up to a certain .NET version.
If I remember correctly:
VS 2005 - .NET 2.0
VS 2008 - .NET 3.5
VS 2010 - .NET 4.0
VS 2013 - .NET 4.5
Update:
The .NET version is indeed not relevant in this case, as the nameof operator is a feature of the Roslyn compiler. Nothing more, nothing less. The VS 2013 definitely uses a different one (at least a compiler which does not cover up with C# 6), therefore it does not compile.
I have developed a program in visual studio 2012, my targeting framework was 4.5 and now i want it to be open in vs 2008.
I tried to edit cs file in notepad and edited it, but could not compile.
Is there any workaround?
Any help will be highly appreciated.
Visual Studio 2008 doesn't support the .NET 4.5 Framework. The maximum it supports is 3.5.
Similarly, the maximum VS 2010 supports is .NET 4.0.
You can try changing the target framework to 3.5 before opening it in VS2008, but if you're using anything from the newer frameworks, it won't compile.
Additionally, here's a Wikipedia article with the supported framework (and other information) for each Visual Studio release.
From ScottGu's blog: http://weblogs.asp.net/scottgu/archive/2009/08/27/multi-targeting-support-vs-2010-and-net-4-series.aspx
There isn't any way to target .NET 4 from VS08 and use new features.
Having said that, .NET4 is upwards comaptible with .NET 3.5 - so
applications you build targeting .NET 3.5 with VS08 should work fine
on top of .NET 4.
So in simple words you just can not!
Are you actually using features from the 4.5 framework? There's no IDE-supported way to do this, as other answerers have pointed out. What you can do is this:
Create a new project in Visual Studio 2008.
Add your files to it.
Go through and remove any references to .NET 4.5 and ensure it builds cleanly under .NET 2.0 or whatever VS2008-compatible framework you're targeting.
Rinse and repeat until you get a clean build.
Depending on what you're actually using in code, this may entail a lot of work or very little.
I'm using VS 2005 Standard SP1, with .Net 3.5 SP1 installed on XP.
The client machines only have .Net 2.0.50727 installed (also on XP).
How can I tell the compiler to reject any classes or methods that are not available in .Net 2?
In Visual Studio 2005 this is not possible because it simply doesn't know about .Net 3.5. Visual Studio 2008 is the first version which understands .Net 3.5.
The best way to make sure you don't use any classes defined in 3.5 is to do the following
Don't reference any DLL's from 3.5 (System.Core,System.Xml.Linq,etc ...)
Run the FxCop rule which spots for 3.5 violations in 2.0 projects. This was initially added to Visual Studio 2008 but I don't see a reason you couldn't use it in a 2005 project if you installed the latest FxCop
Here is a link to a blog article about the FxCop rule I was talking about.
http://blogs.msdn.com/kcwalina/archive/2007/10/02/Multi_2D00_TargetingAndFxCop.aspx
The article does talk about running it against VS2008. But I don't immediately see a reason it couldn't be used in VS2005. But I don't have an install handy to test it on.
I downloaded and installed the .net framework 4.0, but I didn't install VS 2010, because VS 2010 require the high-performance computer hardware. I have no but I expect to taste the C# 4.0 feature.
you need the .net 4.0 compiler, which at the moment is only available with vs2010.
This thread might answer your question
Where I can download compiler for C# 4.0 without Visual Studio 2010?
The .NET framework client profile includes the compiler (csc.exe). For example, on my machine, it's at:
c:\Windows\Microsoft.NET\Framework64\v4.0.20506\csc.exe
The 32-bit version is at:
c:\Windows\Microsoft.NET\Framework\v4.0.20506\csc.exe
If you're familiar with the command-line compiler syntax, most applications can be written just using it, notepad and referencing the appropriate assemblies. It won't be a terribly pleasant experience though.