• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# WorkCoordinatorWorkspace类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中WorkCoordinatorWorkspace的典型用法代码示例。如果您正苦于以下问题:C# WorkCoordinatorWorkspace类的具体用法?C# WorkCoordinatorWorkspace怎么用?C# WorkCoordinatorWorkspace使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



WorkCoordinatorWorkspace类属于命名空间,在下文中一共展示了WorkCoordinatorWorkspace类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: DynamicallyAddAnalyzer

        public async Task DynamicallyAddAnalyzer()
        {
            using (var workspace = new WorkCoordinatorWorkspace(SolutionCrawler))
            {
                // create solution and wait for it to settle
                var solution = GetInitialSolutionInfo(workspace);
                workspace.OnSolutionAdded(solution);
                await WaitWaiterAsync(workspace.ExportProvider);

                // create solution crawler and add new analyzer provider dynamically
                var service = new SolutionCrawlerRegistrationService(
                    SpecializedCollections.EmptyEnumerable<Lazy<IIncrementalAnalyzerProvider, IncrementalAnalyzerProviderMetadata>>(),
                    GetListeners(workspace.ExportProvider));

                service.Register(workspace);

                var provider = new AnalyzerProvider(new Analyzer());
                service.AddAnalyzerProvider(provider, Metadata.Crawler);

                // wait for everything to settle
                await WaitAsync(service, workspace);

                service.Unregister(workspace);

                // check whether everything ran as expected
                Assert.Equal(10, provider.Analyzer.SyntaxDocumentIds.Count);
                Assert.Equal(10, provider.Analyzer.DocumentIds.Count);
            }
        }
开发者ID:otawfik-ms,项目名称:roslyn,代码行数:29,代码来源:WorkCoordinatorTests.cs


示例2: SolutionAdded_Complex

        public void SolutionAdded_Complex()
        {
            using (var workspace = new WorkCoordinatorWorkspace(TestExportProvider.CreateExportProviderWithCSharpAndVisualBasic(), SolutionCrawler))
            {
                var solution = GetInitialSolutionInfo(workspace);

                var worker = ExecuteOperation(workspace, w => w.OnSolutionAdded(solution));
                Assert.Equal(10, worker.SyntaxDocumentIds.Count);
            }
        }
开发者ID:hbarve1,项目名称:roslyn,代码行数:10,代码来源:WorkCoordinatorTests.cs


示例3: SolutionAdded_Complex

        public async Task SolutionAdded_Complex()
        {
            using (var workspace = new WorkCoordinatorWorkspace(SolutionCrawler))
            {
                var solution = GetInitialSolutionInfo(workspace);

                var worker = await ExecuteOperation(workspace, w => w.OnSolutionAdded(solution));
                Assert.Equal(10, worker.SyntaxDocumentIds.Count);
            }
        }
开发者ID:Eyas,项目名称:roslyn,代码行数:10,代码来源:WorkCoordinatorTests.cs


示例4: Solution_Remove

        public void Solution_Remove()
        {
            using (var workspace = new WorkCoordinatorWorkspace(TestExportProvider.CreateExportProviderWithCSharpAndVisualBasic(), SolutionCrawler))
            {
                var solution = GetInitialSolutionInfo(workspace);
                workspace.OnSolutionAdded(solution);
                WaitWaiter(workspace.ExportProvider);

                var worker = ExecuteOperation(workspace, w => w.OnSolutionRemoved());
                Assert.Equal(10, worker.InvalidateDocumentIds.Count);
            }
        }
开发者ID:hbarve1,项目名称:roslyn,代码行数:12,代码来源:WorkCoordinatorTests.cs


示例5: Solution_Remove

        public async Task Solution_Remove()
        {
            using (var workspace = new WorkCoordinatorWorkspace(SolutionCrawler))
            {
                var solution = GetInitialSolutionInfo(workspace);
                workspace.OnSolutionAdded(solution);
                await WaitWaiterAsync(workspace.ExportProvider);

                var worker = await ExecuteOperation(workspace, w => w.OnSolutionRemoved());
                Assert.Equal(10, worker.InvalidateDocumentIds.Count);
            }
        }
开发者ID:Eyas,项目名称:roslyn,代码行数:12,代码来源:WorkCoordinatorTests.cs


示例6: RegisterService

        public void RegisterService()
        {
            using (var workspace = new WorkCoordinatorWorkspace(SolutionCrawler))
            {
                var registrationService = new SolutionCrawlerRegistrationService(
                    SpecializedCollections.EmptyEnumerable<Lazy<IIncrementalAnalyzerProvider, IncrementalAnalyzerProviderMetadata>>(),
                    AggregateAsynchronousOperationListener.EmptyListeners);

                // register and unregister workspace to the service
                registrationService.Register(workspace);
                registrationService.Unregister(workspace);
            }
        }
开发者ID:Eyas,项目名称:roslyn,代码行数:13,代码来源:WorkCoordinatorTests.cs


示例7: RegisterService

        public async Task RegisterService()
        {
            using (var workspace = new WorkCoordinatorWorkspace(SolutionCrawler))
            {
                var registrationService = new SolutionCrawlerRegistrationService(
                    SpecializedCollections.EmptyEnumerable<Lazy<IIncrementalAnalyzerProvider, IncrementalAnalyzerProviderMetadata>>(),
                    AggregateAsynchronousOperationListener.EmptyListeners);

                // register and unregister workspace to the service
                registrationService.Register(workspace);
                registrationService.Unregister(workspace);

                // make sure we wait for all waiter. the test wrongly assumed there won't be
                // any pending async event which is implementation detail when creating workspace
                // and changing options.
                await WaitWaiterAsync(workspace.ExportProvider);
            }
        }
开发者ID:otawfik-ms,项目名称:roslyn,代码行数:18,代码来源:WorkCoordinatorTests.cs


示例8: SolutionAdded_Simple

        public async Task SolutionAdded_Simple()
        {
            using (var workspace = new WorkCoordinatorWorkspace(SolutionCrawler))
            {
                var solutionId = SolutionId.CreateNewId();
                var projectId = ProjectId.CreateNewId();

                var solutionInfo = SolutionInfo.Create(SolutionId.CreateNewId(), VersionStamp.Create(),
                        projects: new[]
                        {
                            ProjectInfo.Create(projectId, VersionStamp.Create(), "P1", "P1", LanguageNames.CSharp,
                                documents: new[]
                                {
                                    DocumentInfo.Create(DocumentId.CreateNewId(projectId), "D1")
                                })
                        });

                var worker = await ExecuteOperation(workspace, w => w.OnSolutionAdded(solutionInfo));
                Assert.Equal(1, worker.SyntaxDocumentIds.Count);
            }
        }
开发者ID:Eyas,项目名称:roslyn,代码行数:21,代码来源:WorkCoordinatorTests.cs


示例9: Project_Add

        public async Task Project_Add()
        {
            using (var workspace = new WorkCoordinatorWorkspace(SolutionCrawler))
            {
                var solution = GetInitialSolutionInfo(workspace);
                workspace.OnSolutionAdded(solution);
                await WaitWaiterAsync(workspace.ExportProvider);

                var projectId = ProjectId.CreateNewId();
                var projectInfo = ProjectInfo.Create(
                    projectId, VersionStamp.Create(), "P3", "P3", LanguageNames.CSharp,
                    documents: new List<DocumentInfo>
                        {
                            DocumentInfo.Create(DocumentId.CreateNewId(projectId), "D1"),
                            DocumentInfo.Create(DocumentId.CreateNewId(projectId), "D2")
                        });

                var worker = await ExecuteOperation(workspace, w => w.OnProjectAdded(projectInfo));
                Assert.Equal(2, worker.SyntaxDocumentIds.Count);
            }
        }
开发者ID:Eyas,项目名称:roslyn,代码行数:21,代码来源:WorkCoordinatorTests.cs


示例10: Document_Change

        public async Task Document_Change()
        {
            using (var workspace = new WorkCoordinatorWorkspace(SolutionCrawler))
            {
                var solution = GetInitialSolutionInfo(workspace);
                workspace.OnSolutionAdded(solution);
                await WaitWaiterAsync(workspace.ExportProvider);

                var id = workspace.CurrentSolution.Projects.First().DocumentIds[0];

                var worker = await ExecuteOperation(workspace, w => w.ChangeDocument(id, SourceText.From("//")));

                Assert.Equal(1, worker.SyntaxDocumentIds.Count);
            }
        }
开发者ID:Eyas,项目名称:roslyn,代码行数:15,代码来源:WorkCoordinatorTests.cs


示例11: Document_AdditionalFileChange

        public async Task Document_AdditionalFileChange()
        {
            using (var workspace = new WorkCoordinatorWorkspace(SolutionCrawler))
            {
                var solution = GetInitialSolutionInfo(workspace);
                workspace.OnSolutionAdded(solution);
                await WaitWaiterAsync(workspace.ExportProvider);

                var project = solution.Projects[0];
                var ncfile = DocumentInfo.Create(DocumentId.CreateNewId(project.Id), "D6");

                var worker = await ExecuteOperation(workspace, w => w.OnAdditionalDocumentAdded(ncfile));
                Assert.Equal(5, worker.SyntaxDocumentIds.Count);
                Assert.Equal(5, worker.DocumentIds.Count);

                worker = await ExecuteOperation(workspace, w => w.ChangeAdditionalDocument(ncfile.Id, SourceText.From("//")));

                Assert.Equal(5, worker.SyntaxDocumentIds.Count);
                Assert.Equal(5, worker.DocumentIds.Count);

                worker = await ExecuteOperation(workspace, w => w.OnAdditionalDocumentRemoved(ncfile.Id));

                Assert.Equal(5, worker.SyntaxDocumentIds.Count);
                Assert.Equal(5, worker.DocumentIds.Count);
            }
        }
开发者ID:Eyas,项目名称:roslyn,代码行数:26,代码来源:WorkCoordinatorTests.cs


示例12: Document_Reload

        public async Task Document_Reload()
        {
            using (var workspace = new WorkCoordinatorWorkspace(SolutionCrawler))
            {
                var solution = GetInitialSolutionInfo(workspace);
                workspace.OnSolutionAdded(solution);
                await WaitWaiterAsync(workspace.ExportProvider);

                var id = solution.Projects[0].Documents[0];

                var worker = await ExecuteOperation(workspace, w => w.OnDocumentReloaded(id));
                Assert.Equal(0, worker.SyntaxDocumentIds.Count);
            }
        }
开发者ID:Eyas,项目名称:roslyn,代码行数:14,代码来源:WorkCoordinatorTests.cs


示例13: Document_Reanalyze

        public async Task Document_Reanalyze()
        {
            using (var workspace = new WorkCoordinatorWorkspace(SolutionCrawler))
            {
                var solution = GetInitialSolutionInfo(workspace);
                workspace.OnSolutionAdded(solution);
                await WaitWaiterAsync(workspace.ExportProvider);

                var info = solution.Projects[0].Documents[0];

                var worker = new Analyzer();
                var lazyWorker = new Lazy<IIncrementalAnalyzerProvider, IncrementalAnalyzerProviderMetadata>(() => new AnalyzerProvider(worker), Metadata.Crawler);
                var service = new SolutionCrawlerRegistrationService(new[] { lazyWorker }, GetListeners(workspace.ExportProvider));

                service.Register(workspace);

                // don't rely on background parser to have tree. explicitly do it here.
                await TouchEverything(workspace.CurrentSolution);

                service.Reanalyze(workspace, worker, projectIds: null, documentIds: SpecializedCollections.SingletonEnumerable<DocumentId>(info.Id), highPriority: false);

                await TouchEverything(workspace.CurrentSolution);

                await WaitAsync(service, workspace);

                service.Unregister(workspace);

                Assert.Equal(1, worker.SyntaxDocumentIds.Count);
                Assert.Equal(1, worker.DocumentIds.Count);
            }
        }
开发者ID:Eyas,项目名称:roslyn,代码行数:31,代码来源:WorkCoordinatorTests.cs


示例14: Document_Add

        public async Task Document_Add()
        {
            using (var workspace = new WorkCoordinatorWorkspace(SolutionCrawler))
            {
                var solution = GetInitialSolutionInfo(workspace);
                workspace.OnSolutionAdded(solution);
                await WaitWaiterAsync(workspace.ExportProvider);

                var project = solution.Projects[0];
                var info = DocumentInfo.Create(DocumentId.CreateNewId(project.Id), "D6");

                var worker = await ExecuteOperation(workspace, w => w.OnDocumentAdded(info));
                Assert.Equal(1, worker.SyntaxDocumentIds.Count);
                Assert.Equal(6, worker.DocumentIds.Count);
            }
        }
开发者ID:Eyas,项目名称:roslyn,代码行数:16,代码来源:WorkCoordinatorTests.cs


示例15: Document_Reload

        public void Document_Reload()
        {
            using (var workspace = new WorkCoordinatorWorkspace(TestExportProvider.CreateExportProviderWithCSharpAndVisualBasic(), SolutionCrawler))
            {
                var solution = GetInitialSolutionInfo(workspace);
                workspace.OnSolutionAdded(solution);
                WaitWaiter(workspace.ExportProvider);

                var id = solution.Projects[0].Documents[0];

                var worker = ExecuteOperation(workspace, w => w.OnDocumentReloaded(id));
                Assert.Equal(0, worker.SyntaxDocumentIds.Count);
            }
        }
开发者ID:hbarve1,项目名称:roslyn,代码行数:14,代码来源:WorkCoordinatorTests.cs


示例16: Document_Add

        public void Document_Add()
        {
            using (var workspace = new WorkCoordinatorWorkspace(TestExportProvider.CreateExportProviderWithCSharpAndVisualBasic(), SolutionCrawler))
            {
                var solution = GetInitialSolutionInfo(workspace);
                workspace.OnSolutionAdded(solution);
                WaitWaiter(workspace.ExportProvider);

                var project = solution.Projects[0];
                var info = DocumentInfo.Create(DocumentId.CreateNewId(project.Id), "D6");

                var worker = ExecuteOperation(workspace, w => w.OnDocumentAdded(info));
                Assert.Equal(1, worker.SyntaxDocumentIds.Count);
                Assert.Equal(6, worker.DocumentIds.Count);
            }
        }
开发者ID:hbarve1,项目名称:roslyn,代码行数:16,代码来源:WorkCoordinatorTests.cs


示例17: Project_AnalyzerOptions_Change

        public async Task Project_AnalyzerOptions_Change()
        {
            using (var workspace = new WorkCoordinatorWorkspace(SolutionCrawler))
            {
                var solutionInfo = GetInitialSolutionInfo(workspace);
                workspace.OnSolutionAdded(solutionInfo);
                await WaitWaiterAsync(workspace.ExportProvider);

                var project = workspace.CurrentSolution.Projects.First(p => p.Name == "P1").AddAdditionalDocument("a1", SourceText.From("")).Project;
                var worker = await ExecuteOperation(workspace, w => w.ChangeProject(project.Id, project.Solution));

                Assert.Equal(5, worker.SyntaxDocumentIds.Count);
                Assert.Equal(5, worker.DocumentIds.Count);
            }
        }
开发者ID:Eyas,项目名称:roslyn,代码行数:15,代码来源:WorkCoordinatorTests.cs


示例18: Document_Change

        public void Document_Change()
        {
            using (var workspace = new WorkCoordinatorWorkspace(TestExportProvider.CreateExportProviderWithCSharpAndVisualBasic(), SolutionCrawler))
            {
                var solution = GetInitialSolutionInfo(workspace);
                workspace.OnSolutionAdded(solution);
                WaitWaiter(workspace.ExportProvider);

                var id = workspace.CurrentSolution.Projects.First().DocumentIds[0];

                var worker = ExecuteOperation(workspace, w => w.ChangeDocument(id, SourceText.From("//")));

                Assert.Equal(1, worker.SyntaxDocumentIds.Count);
            }
        }
开发者ID:hbarve1,项目名称:roslyn,代码行数:15,代码来源:WorkCoordinatorTests.cs


示例19: ProgressReporterTest

        public async Task ProgressReporterTest()
        {
            var solution = GetInitialSolutionInfoWithP2P();

            using (var workspace = new WorkCoordinatorWorkspace(SolutionCrawler))
            {
                await WaitWaiterAsync(workspace.ExportProvider);

                var service = workspace.Services.GetService<ISolutionCrawlerService>();
                var reporter = service.GetProgressReporter(workspace);
                Assert.False(reporter.InProgress);

                // set up events
                bool started = false;
                reporter.Started += (o, a) => { started = true; };

                bool stopped = false;
                reporter.Stopped += (o, a) => { stopped = true; };

                var registrationService = workspace.Services.GetService<ISolutionCrawlerRegistrationService>();
                registrationService.Register(workspace);

                // first mutation
                workspace.OnSolutionAdded(solution);

                await WaitAsync((SolutionCrawlerRegistrationService)registrationService, workspace);

                Assert.True(started);
                Assert.True(stopped);

                // reset
                started = false;
                stopped = false;

                // second mutation
                workspace.OnDocumentAdded(DocumentInfo.Create(DocumentId.CreateNewId(solution.Projects[0].Id), "D6"));

                await WaitAsync((SolutionCrawlerRegistrationService)registrationService, workspace);

                Assert.True(started);
                Assert.True(stopped);

                registrationService.Unregister(workspace);
            }
        }
开发者ID:Eyas,项目名称:roslyn,代码行数:45,代码来源:WorkCoordinatorTests.cs


示例20: Document_Cancellation_MultipleTimes

        public async Task Document_Cancellation_MultipleTimes()
        {
            using (var workspace = new WorkCoordinatorWorkspace(SolutionCrawler))
            {
                var solution = GetInitialSolutionInfo(workspace);
                workspace.OnSolutionAdded(solution);
                await WaitWaiterAsync(workspace.ExportProvider);

                var id = workspace.CurrentSolution.Projects.First().DocumentIds[0];

                var analyzer = new Analyzer(waitForCancellation: true);
                var lazyWorker = new Lazy<IIncrementalAnalyzerProvider, IncrementalAnalyzerProviderMetadata>(() => new AnalyzerProvider(analyzer), Metadata.Crawler);
                var service = new SolutionCrawlerRegistrationService(new[] { lazyWorker }, GetListeners(workspace.ExportProvider));

                service.Register(workspace);

                workspace.ChangeDocument(id, SourceText.From("//"));
                analyzer.RunningEvent.Wait();
                analyzer.RunningEvent.Reset();

                workspace.ChangeDocument(id, SourceText.From("// "));
                analyzer.RunningEvent.Wait();

                workspace.ChangeDocument(id, SourceText.From("//  "));
                await WaitAsync(service, workspace);

                service.Unregister(workspace);

                Assert.Equal(1, analyzer.SyntaxDocumentIds.Count);
                Assert.Equal(5, analyzer.DocumentIds.Count);
            }
        }
开发者ID:Eyas,项目名称:roslyn,代码行数:32,代码来源:WorkCoordinatorTests.cs



注:本文中的WorkCoordinatorWorkspace类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# WorkItem类代码示例发布时间:2022-05-24
下一篇:
C# WorkContext类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap