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


C# Document.IsOpen方法代码示例

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


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

示例1: AnalyzeSyntaxAsync

            public async Task AnalyzeSyntaxAsync(Document document, CancellationToken cancellationToken)
            {
                // if closed file diagnostic is off and document is not opened, then don't do anything
                if (!_workspace.Options.GetOption(ServiceFeatureOnOffOptions.ClosedFileDiagnostic, document.Project.Language) && !document.IsOpen())
                {
                    return;
                }

                var tree = await document.GetSyntaxTreeAsync(cancellationToken).ConfigureAwait(false);
                var diagnostics = tree.GetDiagnostics(cancellationToken);

                Contract.Requires(document.Project.Solution.Workspace == _workspace);

                var diagnosticData = diagnostics == null ? ImmutableArray<DiagnosticData>.Empty : diagnostics.Select(d => DiagnosticData.Create(document, d)).ToImmutableArrayOrEmpty();
                _service.RaiseDiagnosticsUpdated(new DiagnosticsUpdatedArgs(ValueTuple.Create(this, document.Id), _workspace, document.Project.Solution, document.Project.Id, document.Id, diagnosticData));
            }
开发者ID:elemk0vv,项目名称:roslyn-1,代码行数:16,代码来源:MiscellaneousDiagnosticAnalyzerService.cs

示例2: DocumentResetAsync

            public Task DocumentResetAsync(Document document, CancellationToken cancellationToken)
            {
                // no closed file diagnostic and file is not opened, remove any existing diagnostics
                if (!_workspace.Options.GetOption(ServiceFeatureOnOffOptions.ClosedFileDiagnostic, document.Project.Language) && !document.IsOpen())
                {
                    RaiseEmptyDiagnosticUpdated(document.Id);
                }

                return SpecializedTasks.EmptyTask;
            }
开发者ID:elemk0vv,项目名称:roslyn-1,代码行数:10,代码来源:MiscellaneousDiagnosticAnalyzerService.cs

示例3: AnalyzeDocumentAsync

            public async Task AnalyzeDocumentAsync(Document document, SyntaxNode bodyOpt, CancellationToken cancellationToken)
            {
                try
                {
                    // do nothing if this document is not currently open.
                    // to prevent perf from getting too poor for large projects, only examine open documents.
                    if (!document.IsOpen())
                    {
                        return;
                    }

                    // Only analyzing C# for now
                    if (document.Project.Language != LanguageNames.CSharp)
                    {
                        return;
                    }

                    List<CompilationErrorDetails> errorDetails = await _errorDetailDiscoverer.GetCompilationErrorDetails(document, bodyOpt, cancellationToken).ConfigureAwait(false);

                    var errorsToReport = _errorDetailCache.GetErrorsToReportAndRecordErrors(document.Id, errorDetails);
                    if (errorsToReport != null)
                    {
                        using (var hashProvider = new SHA256CryptoServiceProvider())
                        {
                            foreach (CompilationErrorDetails errorDetail in errorsToReport)
                            {
                                var telemetryEvent = TelemetryHelper.TelemetryService.CreateEvent(TelemetryEventPath);
                                telemetryEvent.SetStringProperty(TelemetryErrorId, errorDetail.ErrorId);

                                string projectGuid = _projectGuidCache.GetProjectGuidFromProjectPath(document.Project.FilePath);
                                telemetryEvent.SetStringProperty(TelemetryProjectGuid, string.IsNullOrEmpty(projectGuid) ? UnspecifiedProjectGuid : projectGuid.ToString());

                                if (!string.IsNullOrEmpty(errorDetail.UnresolvedMemberName))
                                {
                                    telemetryEvent.SetStringProperty(TelemetryUnresolvedMemberName, GetHashedString(errorDetail.UnresolvedMemberName, hashProvider));
                                }

                                if (!string.IsNullOrEmpty(errorDetail.LeftExpressionDocId))
                                {
                                    telemetryEvent.SetStringProperty(TelemetryLeftExpressionDocId, GetHashedString(errorDetail.LeftExpressionDocId, hashProvider));
                                }

                                if (!IsArrayNullOrEmpty(errorDetail.LeftExpressionBaseTypeDocIds))
                                {
                                    string telemetryBaseTypes = string.Join(";", errorDetail.LeftExpressionBaseTypeDocIds.Select(docId => GetHashedString(docId, hashProvider)));
                                    telemetryEvent.SetStringProperty(TelemetryBaseTypes, telemetryBaseTypes);
                                }

                                if (!IsArrayNullOrEmpty(errorDetail.GenericArguments))
                                {
                                    string telemetryGenericArguments = string.Join(";", errorDetail.GenericArguments.Select(docId => GetHashedString(docId, hashProvider)));
                                    telemetryEvent.SetStringProperty(TelemetryGenericArguments, telemetryGenericArguments);
                                }

                                if (!string.IsNullOrEmpty(errorDetail.MethodName))
                                {
                                    telemetryEvent.SetStringProperty(TelemetryMethodName, GetHashedString(errorDetail.MethodName, hashProvider));
                                }

                                if (!IsArrayNullOrEmpty(errorDetail.ArgumentTypes))
                                {
                                    string telemetryMisMatchedArgumentTypeDocIds = string.Join(";", errorDetail.ArgumentTypes.Select(docId => GetHashedString(docId, hashProvider)));
                                    telemetryEvent.SetStringProperty(TelemetryMismatchedArgumentTypeDocIds, telemetryMisMatchedArgumentTypeDocIds);
                                }

                                TelemetryHelper.DefaultTelemetrySession.PostEvent(telemetryEvent);
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    // The telemetry service itself can throw.
                    // So, to be very careful, put this in a try/catch too.
                    try
                    {
                        var exceptionEvent = TelemetryHelper.TelemetryService.CreateEvent(TelemetryExceptionEventPath);
                        exceptionEvent.SetStringProperty("Type", e.GetTypeDisplayName());
                        exceptionEvent.SetStringProperty("Message", e.Message);
                        exceptionEvent.SetStringProperty("StackTrace", e.StackTrace);
                        TelemetryHelper.DefaultTelemetrySession.PostEvent(exceptionEvent);
                    }
                    catch
                    {
                    }
                }
            }
开发者ID:vslsnap,项目名称:roslyn,代码行数:87,代码来源:CSharpCompilationErrorTelemetryIncrementalAnalyzer.cs


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