Наследование: KernelCommand
Пример #1
0
        public async Task <bool> BuildAsync(string mode = "Release")
        {
            bool result = false;

            try
            {
                _logger.WriteInfo(new LogMessage("Inizio compilazione"), LogCategories);
                CompileProject compile = new CompileProject();
                IDictionary <string, string>       buildOption    = compile.BuildOption(_binFolder, CompilationType.Release);
                IDictionary <string, TargetResult> compilerResult = await compile.ExecuteAsync(_projectFilePath, buildOption, _builderLogger);

                // Il risultato di compilazione si trova qui:
                if (compilerResult["Build"].Items.FirstOrDefault() != null)
                {
                    _logger.WriteInfo(new LogMessage("Compilazione avvenuta con successo"), LogCategories);
                    result = true;
                    return(result);
                }
                _logger.WriteInfo(new LogMessage("Errore di compilazione, verificare il log di compilazione"), LogCategories);
            }
            catch (Exception ex)
            {
                _logger.WriteError(ex, LogCategories);
                throw ex;
            }
            return(result);
        }
Пример #2
0
        public static IEnumerable <object[]> Events()
        {
            foreach (var @event in events().Select(e =>
            {
                e.Command.Properties["id"] = "command-id";
                return(e);
            }))
            {
                yield return(new object[] { @event });
            }

            IEnumerable <KernelEvent> events()
            {
                var compileProject = new CompileProject("123");

                yield return(new AssemblyProduced(compileProject, new Base64EncodedAssembly("01020304")));

                var submitCode = new SubmitCode("123");

                yield return(new CodeSubmissionReceived(
                                 submitCode));

                yield return(new CommandFailed(
                                 "Oooops!",
                                 submitCode));

                yield return(new CommandFailed(
                                 new InvalidOperationException("Oooops!"),
                                 submitCode,
                                 "oops"));

                yield return(new CommandSucceeded(submitCode));

                yield return(new CompleteCodeSubmissionReceived(submitCode));

                var requestCompletion = new RequestCompletions("Console.Wri", new LinePosition(0, 11));

                yield return(new CompletionsProduced(
                                 new[]
                {
                    new CompletionItem(
                        "WriteLine",
                        "Method",
                        "WriteLine",
                        "WriteLine",
                        "WriteLine",
                        "Writes the line")
                },
                                 requestCompletion));

                yield return(new DiagnosticLogEntryProduced("oops!", submitCode));

                yield return(new DiagnosticsProduced(
                                 new[]
                {
                    new Diagnostic(
                        new LinePositionSpan(
                            new LinePosition(1, 2),
                            new LinePosition(3, 4)),
                        DiagnosticSeverity.Error,
                        "code",
                        "message")
                },
                                 submitCode));

                yield return(new DisplayedValueProduced(
                                 new HtmlString("<b>hi!</b>"),
                                 new SubmitCode("b(\"hi!\")", "csharp", SubmissionType.Run),
                                 new[]
                {
                    new FormattedValue("text/html", "<b>hi!</b>"),
                }));

                yield return(new DisplayedValueUpdated(
                                 new HtmlString("<b>hi!</b>"),
                                 "the-value-id",
                                 new SubmitCode("b(\"hi!\")", "csharp", SubmissionType.Run),
                                 new[]
                {
                    new FormattedValue("text/html", "<b>hi!</b>"),
                }));

                var openDocument = new OpenDocument("path");

                yield return(new DocumentOpened(openDocument, "path", null, "file contents"));

                yield return(new ErrorProduced("oops!", submitCode));

                yield return(new IncompleteCodeSubmissionReceived(submitCode));

                var requestHoverTextCommand = new RequestHoverText("document-contents", new LinePosition(1, 2));

                yield return(new HoverTextProduced(
                                 requestHoverTextCommand,
                                 new[] { new FormattedValue("text/markdown", "markdown") },
                                 new LinePositionSpan(new LinePosition(1, 2), new LinePosition(3, 4))));

                yield return(new KernelInfoProduced(
                                 new KernelInfo("javascript", "javascript")
                {
                    Aliases = new[] { "js" },
                    DestinationUri = new Uri("kernel://vscode/javascript"),
                    SupportedDirectives = new[]
                    {
                        new DirectiveInfo("#r")
                    },
                    SupportedKernelCommands = new[]
                    {
                        new KernelCommandInfo(nameof(SubmitCode))
                    }
                },
                                 new RequestKernelInfo()));

                yield return(new KernelReady());

                yield return(new PackageAdded(
                                 new ResolvedPackageReference(
                                     packageName: "ThePackage",
                                     packageVersion: "1.2.3",
                                     assemblyPaths: new[] { "/path/to/a.dll" },
                                     packageRoot: "/the/package/root",
                                     probingPaths: new[] { "/probing/path/1", "/probing/path/2" }),
                                 new SubmitCode("#r \"nuget:ThePackage,1.2.3\"")));

                yield return(new ReturnValueProduced(
                                 new HtmlString("<b>hi!</b>"),
                                 new SubmitCode("b(\"hi!\")", "csharp", SubmissionType.Run),
                                 new[]
                {
                    new FormattedValue("text/html", "<b>hi!</b>"),
                }));

                yield return(new SignatureHelpProduced(
                                 new RequestSignatureHelp("sig-help-contents", new LinePosition(1, 2)),
                                 new[]
                {
                    new SignatureInformation("label",
                                             new FormattedValue("text/html", "sig-help-result"),
                                             new[]
                    {
                        new ParameterInformation("param1", new FormattedValue("text/html", "param1")),
                        new ParameterInformation("param2", new FormattedValue("text/html", "param2"))
                    })
                },
                                 0,
                                 1));

                yield return(new StandardErrorValueProduced(
                                 submitCode,
                                 new[]
                {
                    new FormattedValue("text/plain", "oops!"),
                }));

                yield return(new StandardOutputValueProduced(
                                 new SubmitCode("Console.Write(123);", "csharp", SubmissionType.Run),
                                 new[]
                {
                    new FormattedValue("text/plain", "123"),
                }));

                yield return(new WorkingDirectoryChanged(
                                 "some/different/directory",
                                 new ChangeWorkingDirectory("some/different/directory")));

                yield return(new KernelExtensionLoaded(new SubmitCode(@"#r ""nuget:package"" ")));

                yield return(new ValueInfosProduced(new[] { new KernelValueInfo("a", typeof(string)), new KernelValueInfo("b", typeof(string)), new KernelValueInfo("c", typeof(string)) }, new RequestValueInfos("csharp")));

                yield return(new ValueProduced("raw value", "a", new FormattedValue(HtmlFormatter.MimeType, "<span>formatted value</span>"), new RequestValue("a", "csharp", HtmlFormatter.MimeType)));

                yield return(new CommandCancelled(new Cancel(), new SubmitCode("var value = 1;", "csharp")));

                yield return(new InputProduced("user input", new GetInput(targetKernelName: "vscode")));
            }
        }
Пример #3
0
 public AssemblyProduced(CompileProject command, Base64EncodedAssembly assembly)
     : base(command)
 {
     Assembly = assembly ?? throw new ArgumentNullException(nameof(assembly));
 }