Using C# 6 features with CodeDomProvider (Roslyn)

Update: March 2018 Word of caution, NuGet version 1.0.6 … 1.0.8 will not copy the /roslyn folder to the build output directory on non-web projects. Best stick with 1.0.5 https://github.com/aspnet/RoslynCodeDomProvider/issues/38 Run-time compilation using C#6 features requires a new compiler, as @thomas-levesque mentioned. This compiler can be installed by using the nuget package Microsoft.CodeDom.Providers.DotNetCompilerPlatform. For desktop … Read more

Microsoft Roslyn vs. CodeDom

Disclaimer: I work for Microsoft on the Roslyn team. CodeDom is a precursor to Roslyn, but is only marginally related. Essentially, CodeDom is a simple and (somewhat) langage agnostic way to generate code that was added in .NET 1.0 to support designers (a la WinForms). Because CodeDom was an attempt at providing a unified model … Read more

Delegate caching behavior changes in Roslyn

Yes. The most important part is that the method containing lambda implementation is now an instance method. You can see a delegate as a middleman receiving an instance call through Invoke and dispatching that call according to the calling convention of the implementing method. Note that there are platform ABI requirements that specify how arguments … Read more

Is nameof() evaluated at compile-time?

Yes. nameof() is evaluated at compile-time. Looking at the latest version of the specs: The nameof expression is a constant. In all cases, nameof(…) is evaluated at compile-time to produce a string. Its argument is not evaluated at runtime, and is considered unreachable code (however it does not emit an “unreachable code” warning). From nameof … Read more

Finding all references to a method with Roslyn

You’re probably looking for the SymbolFinder class and specifically the FindAllReferences method. It sounds like you’re having some trouble getting familiar with Roslyn. I’ve got a series of blog posts to help people get introduced to Roslyn called Learn Roslyn Now. As @SLaks mentions you’re going to need access to the semantic model which I … Read more

C# 6.0 Features Not Working with Visual Studio 2015

This works in MVC 5 (tested 5.2.3), you just need to add the roslyn code dom Nuget package CodeDOM Providers for .NET Compiler… Replacement CodeDOM providers that use the new .NET Compiler Platform (“Roslyn”) compiler as a service APIs. This provides support for new language features in systems using CodeDOM (e.g. ASP.NET runtime compilation) as … Read more

Could not find a part of the path … bin\roslyn\csc.exe

TL; DR run this in the Package Manager Console: Update-Package Microsoft.CodeDom.Providers.DotNetCompilerPlatform -r More information This problem is not related to Visual Studio itself, so answers suggesting adding build steps to copy files over are rather a workaround. Same with adding compiler binaries manually to the project. The Roslyn compiler comes from a NuGet package and … Read more