public ProcessingResult Process(string code, ProcessingOptions options) { options = options ?? new ProcessingOptions(); var kind = options.ScriptMode ? SourceCodeKind.Script : SourceCodeKind.Regular; var sourceLanguage = _languages.Single(l => l.Identifier == options.SourceLanguage); var syntaxTree = sourceLanguage.ParseText(code, kind); var stream = new MemoryStream(); var compilation = sourceLanguage .CreateLibraryCompilation("Test", options.OptimizationsEnabled) .AddReferences(_references) .AddSyntaxTrees(syntaxTree); var emitResult = _roslynAbstraction.Emit(compilation, stream); if (!emitResult.Success) { return(new ProcessingResult(null, emitResult.Diagnostics.Select(d => new ProcessingResultDiagnostic(d)))); } stream.Seek(0, SeekOrigin.Begin); var resultWriter = new StringWriter(); var decompiler = _decompilers.Single(d => d.Language == options.TargetLanguage); decompiler.Decompile(stream, resultWriter); return(new ProcessingResult( resultWriter.ToString(), emitResult.Diagnostics.Select(d => new ProcessingResultDiagnostic(d)) )); }