Esempio n. 1
0
        static async Task <Tuple <CodeActionEditorExtension, Projects.Solution> > GatherFixesNoDispose <T> (string input, Action <ResultsEditorExtension, TaskCompletionSource <T> > callback, params int[] caretLocations)
        {
            await Ide.Composition.CompositionManager.InitializeAsync();

            TestWorkbenchWindow tww     = new TestWorkbenchWindow();
            TestViewContent     content = new TestViewContent();

            tww.ViewContent       = content;
            content.ContentName   = "/a.cs";
            content.Data.MimeType = "text/x-csharp";

            var doc = new Ide.Gui.Document(tww);

            var text = input;

            content.Text = text;

            var project = Projects.Services.ProjectService.CreateProject("C#");

            project.Name     = "test";
            project.FileName = "test.csproj";
            project.Files.Add(new ProjectFile(content.ContentName, BuildAction.Compile));
            var solution = new Projects.Solution();

            solution.AddConfiguration("", true);
            solution.DefaultSolutionFolder.AddItem(project);
            content.Project = project;
            doc.SetProject(project);

            using (var monitor = new ProgressMonitor())
                await TypeSystemService.Load(solution, monitor);

            var resultsExt = new ResultsEditorExtension();

            resultsExt.Initialize(doc.Editor, doc);
            content.Contents.Add(resultsExt);

            var compExt = new CodeActionEditorExtension();

            compExt.Initialize(doc.Editor, doc);
            content.Contents.Add(compExt);

            var tcs = new TaskCompletionSource <T> ();

            var cts = new CancellationTokenSource();

            cts.CancelAfter(60 * 1000);
            cts.Token.Register(() => tcs.TrySetCanceled());

            resultsExt.TasksUpdated += delegate {
                callback(resultsExt, tcs);
            };

            await doc.UpdateParseDocument();

            await Task.Run(() => tcs.Task);

            return(Tuple.Create(compExt, solution));
        }
        static void AssertExpectedDiagnostic(ExpectedDiagnostic expected, ResultsEditorExtension ext, int i)
        {
            var actual = ext.QuickTasks [i];

            Assert.AreEqual(expected.Location, actual.Location);
            Assert.AreEqual(expected.Severity, actual.Severity);
            Assert.AreEqual(expected.Description, actual.Description);
        }
Esempio n. 3
0
            public ResultsUpdater(ResultsEditorExtension ext, IReadOnlyList <Result> results, object resultsId)
            {
                if (ext == null)
                {
                    throw new ArgumentNullException("ext");
                }
                if (results == null)
                {
                    throw new ArgumentNullException("results");
                }
                this.ext = ext;
                id       = resultsId;

                if (resultsId != null)
                {
                    ext.markers.TryGetValue(id, out oldMarkers);
                }

                builder = ImmutableArray <QuickTask> .Empty.ToBuilder();

                this.results = results;
                newMarkers   = ext.GetCachedList();
                Debug.Assert(newMarkers != null);
            }