private Compilation CompileScript(Microsoft.CodeAnalysis.SyntaxTree tree, OptimizationLevel level) { var references = new MetadataReference[] { MetadataReference.CreateFromFile(typeof(Object).Assembly.Location), MetadataReference.CreateFromFile(typeof(Console).Assembly.Location), MetadataReference.CreateFromFile(typeof(Enumerable).Assembly.Location), }; var all = references.Concat(GetReferences()); var usings = GetUsings(); var options = ScriptOptions.Default .WithImports(usings) .WithReferences(references); var script = CSharpScript.Create(tree.ToString(), options); var com = script.GetCompilation(); if (level == OptimizationLevel.Release) { SetReleaseOptimizationLevel(com); } return(com); }
protected override string GetDebuggerDisplay() { return(base.GetDebuggerDisplay() + "\"" + _syntaxTree.ToString().Substring(_span.Start, _span.Length) + "\""); }