public async Task <LineEvaluationResult> HandleAsync(Guid lineId, string text, IReplLogger logger) { string package = text.Substring(CommandPrefix.Length).Trim('"'); var assemblies = (await nugetInstaller.Install(package, logger)).ToArray(); if (assemblies.Any()) { await scriptEvaluator.AddReferences(assemblies); workspaceManager.CreateOrUpdateSubmission(lineId, assemblyReferences: assemblies); } return(LineEvaluationResult.NoOutput); }
public async Task <LineEvaluationResult> HandleAsync(Guid lineId, string input, IReplLogger logger) { string assemblyFile = input.Substring(CommandPrefix.Length).Trim('"'); var assemblies = DotNetAssemblyLocator .GroupDirectoryContentsIntoAssemblies(ReadAssembly(assemblyFile)) .Select(assembly => io.CreateMetadataReferenceWithDocumentation(assembly)); foreach (var assembly in assemblies) { logger.LogOutput("Referencing " + assembly.Display); await scriptEvaluator.AddReferences(assembly); workspaceManager.CreateOrUpdateSubmission(lineId, assemblyReferences: assembly); logger.LogOutput("Assembly successfully referenced"); } return(LineEvaluationResult.NoOutput); }
public async Task <LineEvaluationResult> HandleAsync(Guid lineId, string text, IReplLogger logger) { // bail out if it's not a complete statement, but first try automatic completions var(success, newTree) = await scriptEvaluator.TryCompleteStatementAsync(text); if (!success) { return(LineEvaluationResult.IncompleteInput); } text = (await newTree.GetRootAsync()) .ToFullString(); // track the submission in our workspace. We won't need the // result for script evaluation, but other roslyn APIs like // code completion and syntax highlighting will need it. var submission = workspaceManager.CreateOrUpdateSubmission(lineId, text); var scriptResult = await scriptEvaluator.EvaluateAsync(text); var output = await prettyPrinter.FormatAsync(submission.Document, scriptResult); return(output); }