Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 900 Vote(s) - 3.57 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to enable C# 6.0 feature in Visual Studio 2013?

#1
I was going through the latest features introduced in C# 6.0 and just followed an example of auto property initializer,

class NewSample
{
public Guid Id { get; } = Guid.NewGuid();
}

but my IDE did not recognize the syntax.

I am wondering how I could enable C# 6.0 in Visual Studio 2013. The Target framework I am using is 4.5.1.
Reply

#2
Under VS2013 you can install the new compilers into the project as a **nuget package**. That way you don't need VS2015 or an updated build server.

[To see links please register here]


Install-Package Microsoft.Net.Compilers

The package allows you to use/build C# 6.0 code/syntax. Because VS2013 doesn't natively recognize the new C# 6.0 syntax, *it will show errors in the code editor window although it will build fine*.

Using Resharper, you'll get squiggly lines on C# 6 features, but the bulb gives you the option to 'Enable C# 6.0 support for this project' (setting saved to .DotSettings).

As mentioned by @stimpy77: for support in **MVC Razor views** you'll need an extra [package][1] (for those that don't read the comments)

Install-Package Microsoft.CodeDom.Providers.DotNetCompilerPlatform

If you want full C# 6.0 support, you'll need to install VS2015.


[1]:

[To see links please register here]

Reply

#3
### Information for obsoleted prerelease software:

According to [this][2] it's just a install and go for Visual Studio 2013:

> In fact, installing the C# 6.0 compiler from this release involves little more than installing a Visual Studio 2013 extension, which in turn updates the MSBuild target files.

So just get the files from

[To see links please register here]

and you are ready to go.

**You do have to know it is an outdated version of the specs implemented there, since they no longer update the package for Visual Studio 2013**:

> You can also try April's End User Preview, which installs on top of Visual Studio 2013.
(note: this VS 2013 preview is quite out of date, and is no longer updated)

So if you do want to use the latest version, you have to download the [Visual Studio 2015][3].


[1]:

[To see links please register here]

[2]:

[To see links please register here]

[3]:

[To see links please register here]

Reply

#4
It worth mentioning that the **build time will be increased for VS 2015 users after**:

Install-Package Microsoft.Net.Compilers

Those who are using VS 2015 and have to keep this package in their projects **can fix increased build time**.

Edit file `packages\Microsoft.Net.Compilers.1.2.2\build\Microsoft.Net.Compilers.props` and clean it up. The file should look like:

<Project DefaultTargets="Build"
xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
</Project>

Doing so forces a project to be built as it was before adding `Microsoft.Net.Compilers` package
Reply

#5
It seems there's some misunderstanding. So, instead of trying to patch VS2013 here's and answer from a Microsoft guy: [

[To see links please register here]

][1]

So, please, read it and install VS2015.

[1]:

[To see links please register here]

Reply

#6
It is possible to use full C# 6.0 features in Visual Studio 2013 if you have Resharper.
You have to enable Resharper Build and voilá!
In Resharper Options -> Build - enable Resharper Build and in "Use MSBuild.exe version" choose "Latest Installed"

This way Resharper is going to build your C# 6.0 Projects and will also not underline C# 6.0 code as invalid.

I am also using this although I have Visual Studio 2015 because:

1. Unit Tests in Resharper don't work for me with Visual Studio 2015 for some reason
2. VS 2015 uses a lot more memory than VS 2013.

I am putting this here, as I was looking for a solution for this problem for some time now and maybe it will help someone else.
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through