I have a litle but stupid problem. I started working with MS Roslyn, and I am trying to do the Walkthrough, but directly at the beginning an error occurred...
error CS0117: 'Roslyn.Compilers.CSharp.SyntaxTree' does not contain a definition for 'ParseCompilationUnit'
I do not understand why it occurred... maybe one of you had the same problem.
My Sourceode:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Roslyn.Compilers;
using Roslyn.Compilers.CSharp;
using Roslyn.Services;
using Roslyn.Services.CSharp;
namespace gettingstarted2
{
class Program
{
static void Main(string[] args)
{
SyntaxTree tree = SyntaxTree.ParseCompilationUnit(
@"using System;
using System.Collections;
using System.Linq;
using System.Text;
namespace HelloWorld
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine(""Hello, World!"");
}
}
}");
var root = (CompilationUnitSyntax)tree.GetRoot();
}
}
}
NET Compiler Platform (Roslyn) Analyzers inspect your C# or Visual Basic code for style, quality, maintainability, design, and other issues. This inspection or analysis happens during design time in all open files. Analyzers are divided into the following groups: Code style analyzers are built into Visual Studio.
NET compiler platform (Roslyn) package versions are supported for different versions of Visual Studio.
One advantage that Roslyn has is when your application needs a scripting interface. With Roslyn, you can directly compile the script as C# source code with same programming possibilities as the source of the application and directly use it. do you mean after compiling, the script is converted to C# source code?
Roslyn, the . NET Compiler Platform, empowers the C# compiler on . NET Core and allows developers to leverage the rich code analysis APIs to perform code generation, analysis and compilation.
What is the date mentioned in the walkthrough you were following? The method was renamed from ParseCompilationUnit
to ParseText
for the September CTP. If you a previous CTP installed, it's possible that the walkthrough wasn't updated properly when you installed the latest CTP.
I would recommend uninstalling and reinstalling the CTP or using repair.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With