当前位置: 首页>>代码示例>>C#>>正文


C# Workspace.GetOpenDocumentIds方法代码示例

本文整理汇总了C#中Workspace.GetOpenDocumentIds方法的典型用法代码示例。如果您正苦于以下问题:C# Workspace.GetOpenDocumentIds方法的具体用法?C# Workspace.GetOpenDocumentIds怎么用?C# Workspace.GetOpenDocumentIds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Workspace的用法示例。


在下文中一共展示了Workspace.GetOpenDocumentIds方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Register

        public async void Register(Workspace workspace)
        {
            try
            {
                var workerBackOffTimeSpanInMS = workspace.Options.GetOption(InternalSolutionCrawlerOptions.PreviewBackOffTimeSpanInMS);

                var analyzer = _provider.CreateIncrementalAnalyzer(workspace);
                var source = s_cancellationTokens.GetValue(workspace, _ => new CancellationTokenSource());

                var solution = workspace.CurrentSolution;
                foreach (var documentId in workspace.GetOpenDocumentIds())
                {
                    var document = solution.GetDocument(documentId);
                    if (document == null)
                    {
                        continue;
                    }

                    // delay analyzing
                    await Task.Delay(workerBackOffTimeSpanInMS).ConfigureAwait(false);

                    // do actual analysis
                    await analyzer.AnalyzeSyntaxAsync(document, source.Token).ConfigureAwait(false);
                    await analyzer.AnalyzeDocumentAsync(document, bodyOpt: null, cancellationToken: source.Token).ConfigureAwait(false);

                    // don't call project one.
                }
            }
            catch (OperationCanceledException)
            {
                // do nothing
            }
        }
开发者ID:SoumikMukherjeeDOTNET,项目名称:roslyn,代码行数:33,代码来源:PreviewSolutionCrawlerRegistrationService.cs

示例2: ReadOnlyDocumentTracker

        public ReadOnlyDocumentTracker(IEditAndContinueWorkspaceService encService, Action<DocumentId, SessionReadOnlyReason, ProjectReadOnlyReason> onReadOnlyDocumentEditAttempt)
            : base(assertIsForeground: true)
        {
            Debug.Assert(encService.DebuggingSession != null);

            _encService = encService;
            _readOnlyRegions = new Dictionary<DocumentId, IReadOnlyRegion>();
            _workspace = encService.DebuggingSession.InitialSolution.Workspace;
            _onReadOnlyDocumentEditAttempt = onReadOnlyDocumentEditAttempt;

            _workspace.DocumentClosed += OnDocumentClosed;
            _workspace.DocumentOpened += OnDocumentOpened;

            foreach (var documentId in _workspace.GetOpenDocumentIds())
            {
                TrackDocument(documentId);
            }
        }
开发者ID:GloryChou,项目名称:roslyn,代码行数:18,代码来源:ReadOnlyDocumentTracker.cs

示例3: SynchronizeWithBuildAsync

        public override async Task SynchronizeWithBuildAsync(Workspace workspace, ImmutableDictionary<ProjectId, ImmutableArray<DiagnosticData>> map)
        {
            if (!PreferBuildErrors(workspace))
            {
                // prefer live errors over build errors
                return;
            }

            var solution = workspace.CurrentSolution;
            foreach (var projectEntry in map)
            {
                var project = solution.GetProject(projectEntry.Key);
                if (project == null)
                {
                    continue;
                }

                // REVIEW: is build diagnostic contains suppressed diagnostics?
                var stateSets = _stateManager.CreateBuildOnlyProjectStateSet(project);
                var result = await CreateProjectAnalysisDataAsync(project, stateSets, projectEntry.Value).ConfigureAwait(false);

                foreach (var stateSet in stateSets)
                {
                    var state = stateSet.GetProjectState(project.Id);
                    await state.SaveAsync(project, result.GetResult(stateSet.Analyzer)).ConfigureAwait(false);
                }

                // REVIEW: this won't handle active files. might need to tweak it later.
                RaiseProjectDiagnosticsIfNeeded(project, stateSets, result.OldResult, result.Result);
            }

            if (PreferLiveErrorsOnOpenedFiles(workspace))
            {
                // enqueue re-analysis of open documents.
                this.Owner.Reanalyze(workspace, documentIds: workspace.GetOpenDocumentIds(), highPriority: true);
            }
        }
开发者ID:Eyas,项目名称:roslyn,代码行数:37,代码来源:DiagnosticIncrementalAnalyzer_BuildSynchronization.cs

示例4: ClearVersionMap

            private void ClearVersionMap(Workspace workspace, DocumentId documentId)
            {
                if (workspace.GetOpenDocumentIds(documentId.ProjectId).Any())
                {
                    return;
                }

                var versionMap = GetVersionMapFromBranch(workspace, workspace.PrimaryBranchId);

                using (this.gate.DisposableWrite())
                {
                    versionMap.Remove(documentId.ProjectId);
                }
            }
开发者ID:jerriclynsjohn,项目名称:roslyn,代码行数:14,代码来源:SemanticModelWorkspaceServiceFactory.cs


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