コード例 #1
0
ファイル: Processor.cs プロジェクト: wk-j/decompiler
        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);
        }
コード例 #2
0
ファイル: SourceLocation.cs プロジェクト: lachbaer/roslyn1612
 protected override string GetDebuggerDisplay()
 {
     return(base.GetDebuggerDisplay() + "\"" + _syntaxTree.ToString().Substring(_span.Start, _span.Length) + "\"");
 }