Exemple #1
0
        public async Task <bool?> IsActiveStatementInExceptionRegionAsync(ActiveInstructionId instructionId, CancellationToken cancellationToken)
        {
            try
            {
                if (_editSession == null)
                {
                    return(null);
                }

                Debug.Assert(_debuggingSession != null);

                // TODO: Avoid enumerating active statements for unchanged documents.
                // We would need to add a document path parameter to be able to find the document we need to check for changes.
                // https://github.com/dotnet/roslyn/issues/24324
                var baseActiveStatements = await _editSession.BaseActiveStatements.GetValueAsync(cancellationToken).ConfigureAwait(false);

                if (!baseActiveStatements.InstructionMap.TryGetValue(instructionId, out var baseActiveStatement))
                {
                    return(null);
                }

                // TODO: avoid waiting for ERs of all active statements to be calculated and just calculate the one we are interested in at this moment:
                // https://github.com/dotnet/roslyn/issues/24324
                var baseExceptionRegions = await _editSession.BaseActiveExceptionRegions.GetValueAsync(cancellationToken).ConfigureAwait(false);

                return(baseExceptionRegions[baseActiveStatement.Ordinal].IsActiveStatementCovered);
            }
            catch (Exception e) when(FatalError.ReportWithoutCrashUnlessCanceled(e))
            {
                return(null);
            }
        }
Exemple #2
0
        public ActiveStatement(int ordinal, int primaryDocumentOrdinal, ImmutableArray <DocumentId> documentIds, ActiveStatementFlags flags, LinePositionSpan span, ActiveInstructionId instructionId, ImmutableArray <Guid> threadIds)
        {
            Debug.Assert(ordinal >= 0);
            Debug.Assert(primaryDocumentOrdinal >= 0);
            Debug.Assert(!documentIds.IsDefaultOrEmpty);

            Ordinal = ordinal;
            PrimaryDocumentOrdinal = primaryDocumentOrdinal;
            DocumentIds            = documentIds;
            Flags         = flags;
            Span          = span;
            ThreadIds     = threadIds;
            InstructionId = instructionId;
        }
        public ActiveStatementDebugInfo(
            ActiveInstructionId instructionId,
            string documentNameOpt,
            LinePositionSpan linePositionSpan,
            ImmutableArray <Guid> threadIds,
            ActiveStatementFlags flags)
        {
            Debug.Assert(!threadIds.IsDefaultOrEmpty);

            ThreadIds        = threadIds;
            InstructionId    = instructionId;
            Flags            = flags;
            DocumentNameOpt  = documentNameOpt;
            LinePositionSpan = linePositionSpan;
        }
Exemple #4
0
        public async Task <LinePositionSpan?> GetCurrentActiveStatementPositionAsync(ActiveInstructionId instructionId, CancellationToken cancellationToken)
        {
            try
            {
                // It is allowed to call this method before entering or after exiting break mode. In fact, the VS debugger does so.
                // We return null since there the concept of active statement only makes sense during break mode.
                if (_editSession == null)
                {
                    return(null);
                }

                Debug.Assert(_debuggingSession != null);

                // TODO: Avoid enumerating active statements for unchanged documents.
                // We would need to add a document path parameter to be able to find the document we need to check for changes.
                // https://github.com/dotnet/roslyn/issues/24324
                var baseActiveStatements = await _editSession.BaseActiveStatements.GetValueAsync(cancellationToken).ConfigureAwait(false);

                if (!baseActiveStatements.InstructionMap.TryGetValue(instructionId, out var baseActiveStatement))
                {
                    return(null);
                }

                Document primaryDocument  = _debuggingSession.InitialSolution.Workspace.CurrentSolution.GetDocument(baseActiveStatement.PrimaryDocumentId);
                var      documentAnalysis = await _editSession.GetDocumentAnalysis(primaryDocument).GetValueAsync(cancellationToken).ConfigureAwait(false);

                var currentActiveStatements = documentAnalysis.ActiveStatements;
                if (currentActiveStatements.IsDefault)
                {
                    // The document has syntax errors.
                    return(null);
                }

                return(currentActiveStatements[baseActiveStatement.PrimaryDocumentOrdinal].Span);
            }
            catch (Exception e) when(FatalError.ReportWithoutCrashUnlessCanceled(e))
            {
                return(null);
            }
        }