Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Roslyn features/patterns branch (C# 7) - How to enable the experimental language features

Tags:

c#

roslyn

c#-7.0

I want to experiment with the potential C# 7 future language features.

I have a virtual machine into which I have downloaded the Roslyn codebase (features/patterns branch) and built as described on Roslyn's github here: Building and Testing on Windows.

I can successfully fire up a new experimental instance of Visual Studio (set VisualStudioSetup as the startup project and run).

When I try out the new language features (pattern matching and local functions) I get an error in the editor as a squiggly and also error when I build:

Pattern matching error squiggly

Local function error squiggly

Error CS8058 Feature 'local functions' is experimental and unsupported; use '/features:localFunctions' to enable.

Error CS8058 Feature 'pattern matching' is experimental and unsupported; use '/features:patterns' to enable.

Where do I put these options?

I tried adding it to the command line arguments, but I get an error.

Roslyn Args

Roslyn Args Error

like image 979
Edward Avatar asked Jan 29 '16 01:01

Edward


2 Answers

This is bug 7812 that I haven't fixed yet. Sorry.

Internally, the compiler team mostly just tests things through unit tests or the command line compiler; if we really need to test the IDE we just delete the check that's passing in the feature flag.

like image 53
Jason Malinowski Avatar answered Sep 28 '22 04:09

Jason Malinowski


Sorry, I haven't done R&D with the said code you have downloaded.

But in Visual Studio '15' preview (announced on 30 March 2016) I have fixed this very easily. It might help other people.

I was getting the error

Error CS8058 Feature 'local functions' is experimental and unsupported; use '/features:localFunctions' to enable.

To fix this select your project name and right click >> Properties Window >> Build and then add the below two options in "Conditional Compilation symbols" text box __DEMO__,__DEMO_EXPERIMENTAL__

enter image description here

click on save button to Save it. Now build your application and your build will be succeeded.

Even though at my end if I add any one of the __DEMO__ & __DEMO_EXPERIMENTAL__ then it is working fine.

like image 31
Banketeshvar Narayan Avatar answered Sep 28 '22 03:09

Banketeshvar Narayan