Exemplo n.º 1
0
        private static async Task Main()
        {
            WriteLine("Creating sandbox from C# script:");
            WriteLine();
            WriteLine(SampleScript.HelloWorld);
            WriteLine();

            var playground = PlaygroundWorkspace.FromSource(SourceCodeKind.Script, SampleScript.HelloWorld, 26);

            using (var analyser = new Analyser(playground))
            {
                await Tokenize(analyser);

                WriteLine();

                await Diagnostics(analyser);

                WriteLine();

                (var line, var column) = PositionConverter.PositionToRowColumn(playground.EditingFile.EditorPosition.Value, playground.EditingFile.RawContents);

                WriteLine($"Intellisense at {playground.EditingFile.EditorPosition} (line {line}, column {column}): ");

                using (UseColor(ConsoleColor.Cyan))
                {
                    await Autocomplete(analyser);
                }
                WriteLine();

                WriteLine($"Compiling and executing...");
                WriteLine(new string('-', 50));
                WriteLine();

                using (UseColor(ConsoleColor.Cyan))
                {
                    await analyser.CompileAndRunScript();
                }

                WriteLine();
                WriteLine(new string('-', 50));
            }

            WriteLine();

            WriteLine($"Press {nameof(ConsoleKey.Enter)} to exit");
            UntilEnterPressed();
        }