public DiagnosticIncrementalAnalyzer(
            DiagnosticAnalyzerService owner,
            int correlationId,
            Workspace workspace,
            HostAnalyzerManager hostAnalyzerManager,
            AbstractHostDiagnosticUpdateSource hostDiagnosticUpdateSource)
            : base(owner, workspace, hostAnalyzerManager, hostDiagnosticUpdateSource)
        {
            _correlationId = correlationId;

            _stateManager = new StateManager(hostAnalyzerManager);
            _stateManager.ProjectAnalyzerReferenceChanged += OnProjectAnalyzerReferenceChanged;

            _executor = new Executor(this);
            _compilationManager = new CompilationManager(this);
        }
        public DiagnosticIncrementalAnalyzer(
            DiagnosticAnalyzerService owner,
            int correlationId,
            Workspace workspace,
            HostAnalyzerManager hostAnalyzerManager,
            AbstractHostDiagnosticUpdateSource hostDiagnosticUpdateSource)
            : base(owner, workspace, hostAnalyzerManager, hostDiagnosticUpdateSource)
        {
            _correlationId = correlationId;

            _stateManager = new StateManager(hostAnalyzerManager);
            _stateManager.ProjectAnalyzerReferenceChanged += OnProjectAnalyzerReferenceChanged;

            _executor           = new Executor(this);
            _compilationManager = new CompilationManager(this);
        }
        public void Test_Case_A()
        {
            var context = AppendContext(new ProjectContext(UseCases.A));

            context.RefreshContents();

            CompilationManager.Workspace.OpenProjectAsync(context.ProjectPath).Wait();

            EvaluateRoslynWorkspaceDiagnostics(context, CompilationManager.Workspace.Diagnostics.ToArray());

            CompilationManager.EvaluateCompilation += Private_OnEvaluateCompilation;

            CompilationManager.CompileAllProjects();

            CompilationManager.EvaluateCompilation -= Private_OnEvaluateCompilation;
        }
        private async void CompileShaderCommand_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            TabInfo tabData = EditorTabControl.SelectedItem as TabInfo;
            bool    needToShowSavingDialog = Convert.ToBoolean(e.Parameter);

            if (tabData.CompiledFilePath == string.Empty || tabData.CompiledFilePath == null || needToShowSavingDialog == true)
            {
                string dialogResult = FileManager.GetSelectedPathOfCompiledFile();
                if (dialogResult == ConfigManager.DialogCanceledMessage)
                {
                    return;
                }

                tabData.CompiledFilePath = dialogResult;
            }

            int compilerExitCode = await CompilationManager.CompileShaderAsync(tabData);

            CompilationProgressBlock.Text = (compilerExitCode == 0)
                                ? CompilationManager.BuildSucceededMessage : CompilationManager.BuildFailedMessage;
        }
Exemple #5
0
        public DiagnosticIncrementalAnalyzer(
            DiagnosticAnalyzerService owner,
            int correlationId,
            Workspace workspace,
            HostAnalyzerManager hostAnalyzerManager,
            AbstractHostDiagnosticUpdateSource hostDiagnosticUpdateSource)
        {
            Contract.ThrowIfNull(owner);

            Owner                      = owner;
            Workspace                  = workspace;
            HostAnalyzerManager        = hostAnalyzerManager;
            HostDiagnosticUpdateSource = hostDiagnosticUpdateSource;
            DiagnosticLogAggregator    = new DiagnosticLogAggregator(owner);

            _correlationId = correlationId;

            _stateManager = new StateManager(hostAnalyzerManager);
            _stateManager.ProjectAnalyzerReferenceChanged += OnProjectAnalyzerReferenceChanged;

            _executor           = new Executor(this);
            _compilationManager = new CompilationManager(this);
        }
        public void Test_Case_Obviously_Malformed()
        {
            // TODO: TBD: we are satisfied that the reasons we were here pursuing Roslyn Compilation Services has been completed.
            // TODO: TBD: what we can stand to do more of next is to work on better arrangement, action, and assertion.
            // TODO: TBD: but for now we will commit and put it to some use, then apply whatever else we learn on the other side of that.
            var context = AppendContext(
                new ProjectContext("namespace Foo { public class Bar { public Bar() }".ToRange())
                );

            context.RefreshContents();

            var projectPath = context.ProjectPath.AssertNotNull().AssertFileExists();

            CompilationManager.Workspace.OpenProjectAsync(projectPath).Wait();

            EvaluateRoslynWorkspaceDiagnostics(context, CompilationManager.Workspace.Diagnostics.ToArray());

            CompilationManager.EvaluateCompilation += Private_OnEvaluateCompilation;

            CompilationManager.CompileAllProjects();

            CompilationManager.EvaluateCompilation -= Private_OnEvaluateCompilation;
        }
Exemple #7
0
        public async Task Invoke(IDictionary <string, object> environment)
        {
            var    sw    = new Stopwatch();
            var    req   = new RazorRequest(environment);
            ITrace trace = Tracer.ForRequest(req);

            using (trace.StartTrace())
            {
                trace.WriteLine("Received {0} {1}", req.Method, req.Path);

                if (!IsUnder(VirtualRoot, req.Path))
                {
                    // Not for us!
                    await NextApp(environment);

                    return;
                }

                // Step 1. Route the request to a file
                RouteResult routed = await Router.Route(req, trace);

                if (!routed.Success)
                {
                    // Also not for us!
                    await NextApp(environment);

                    return;
                }
                trace.WriteLine("Router: '{0}' ==> '{1}'::'{2}'", req.Path, routed.File.Name, routed.PathInfo);

                // Step 2. Use the compilation manager to get the file's compiled type
                sw.Start();
                CompilationResult compiled = await CompilationManager.Compile(routed.File, trace);

                sw.Stop();
                if (!compiled.Success)
                {
                    trace.WriteLine("Compiler: '{0}' FAILED", routed.File.Name);
                    throw new CompilationFailedException(compiled.Messages, compiled.GeneratedCode);
                }
                if (compiled.SatisfiedFromCache)
                {
                    trace.WriteLine("Retrieved compiled code from cache in {0}ms", sw.ElapsedMilliseconds);
                }
                else
                {
                    trace.WriteLine("Compiled '{0}' in {1}ms", routed.File.Name, sw.ElapsedMilliseconds);
                }
                sw.Reset();

                // Step 3. Construct an instance using the PageActivator
                Type             type      = compiled.GetCompiledType();
                ActivationResult activated = Activator.ActivatePage(type, trace);
                if (!activated.Success)
                {
                    trace.WriteLine("Activator: '{0}' FAILED", type.FullName);
                    throw new ActivationFailedException(type);
                }
                trace.WriteLine("Activator: '{0}' SUCCESS", type.FullName);

                // Step 4. Execute the activated instance!
                await Executor.Execute(activated.Page, environment, trace);
            }
        }