コード例 #1
0
        /// <summary>
        ///     Compile and run <paramref name="buildingTask"/> to completion
        /// </summary>
        /// <param name="buildingTask">description of building operation</param>
        private async Task RunToCompletion(IServiceScope scope, BuildingTask buildingTask)
        {
            var compiler         = scope.ServiceProvider.GetRequiredService <ICompiler>();
            var runner           = scope.ServiceProvider.GetRequiredService <IRunner>();
            var editorHubContext = scope.ServiceProvider.GetRequiredService <IHubContext <LiveEditorHub> >();

            var projectName    = buildingTask.ProjectName;
            var buildingResult = default(BuildingResult);

            using var sw = new StringWriter();
            try {
                Console.SetOut(sw);
                Console.SetError(sw);

                var assemblyBytes = await compiler.CompileAsync(buildingTask);

                buildingResult = await runner.ExecuteAsync(assemblyBytes, Array.Empty <string>());

                buildingResult.ResultMessage = sw.ToString();
            } catch (Exception ex) when(ex is InvalidOperationException || ex is ArgumentNullException)
            {
                buildingResult = new BuildingResult {
                    ResultMessage = ex.Message
                };
            } finally {
                await editorHubContext
                .Clients
                .Group(projectName)
                .SendAsync(nameof(LiveEditorHub.ProjectCompiled), projectName, buildingResult);
            }
        }
コード例 #2
0
        public ValueTask QueueAsync(BuildingTask buildingTask)
        {
            if (buildingTask is null)
            {
                throw new ArgumentNullException(nameof(buildingTask));
            }

            _buildingTasks.Enqueue(buildingTask);
            _signal.Release();

            return(new ValueTask());
        }
コード例 #3
0
        /// <summary>
        ///     Debug the <paramref name="buildingTask"/> to first/next breakpoint
        /// </summary>
        /// <param name="buildingTask">description of building operation</param>
        private async Task RunDebug(IServiceScope scope, BuildingTask buildingTask)
        {
            var debuggingSession = await _debuggingSessions.GetOrAddSession(buildingTask);

            var editorHubContext = scope.ServiceProvider.GetRequiredService <IHubContext <LiveEditorHub> >();

            var buildingResult = await debuggingSession.DebugAsync(buildingTask);

            await editorHubContext
            .Clients
            .Group(buildingTask.ProjectName)
            .SendAsync(nameof(LiveEditorHub.StepOver), buildingResult);
        }