Exemplo n.º 1
0
            public int ResolveName(string pszName, uint dwFlags, out IVsEnumDebugName?ppNames)
            {
                using (
                    Logger.LogBlock(
                        FunctionId.Debugging_VsLanguageDebugInfo_ResolveName,
                        CancellationToken.None
                        )
                    )
                {
                    // In VS, this method frequently get's called with an empty string to test if the language service
                    // supports this method (some language services, like F#, implement IVsLanguageDebugInfo but don't
                    // implement this method).  In that scenario, there's no sense doing work, so we'll just return
                    // S_FALSE (as the old VB language service did).
                    if (string.IsNullOrEmpty(pszName))
                    {
                        ppNames = null;
                        return(VSConstants.S_FALSE);
                    }

                    VsEnumDebugName?enumName = null;
                    _waitIndicator.Wait(
                        title: ServicesVSResources.Debugger,
                        message: ServicesVSResources.Resolving_breakpoint_location,
                        allowCancel: true,
                        action: waitContext =>
                    {
                        var cancellationToken = waitContext.CancellationToken;
                        if (dwFlags == (uint)RESOLVENAMEFLAGS.RNF_BREAKPOINT)
                        {
                            var solution = _languageService.Workspace.CurrentSolution;

                            // NOTE(cyrusn): We have to wait here because the debuggers' ResolveName
                            // call is synchronous.  In the future it would be nice to make it async.
                            if (_breakpointService != null)
                            {
                                var breakpoints = _breakpointService
                                                  .ResolveBreakpointsAsync(
                                    solution,
                                    pszName,
                                    cancellationToken
                                    )
                                                  .WaitAndGetResult(cancellationToken);
                                var debugNames = breakpoints
                                                 .Select(
                                    bp => CreateDebugName(bp, solution, cancellationToken)
                                    )
                                                 .WhereNotNull()
                                                 .ToList();

                                enumName = new VsEnumDebugName(debugNames);
                            }
                        }
                    }
                        );

                    ppNames = enumName;
                    return(ppNames != null ? VSConstants.S_OK : VSConstants.E_NOTIMPL);
                }
            }
            public int ResolveName(string pszName, uint dwFlags, out IVsEnumDebugName?ppNames)
            {
                using (Logger.LogBlock(FunctionId.Debugging_VsLanguageDebugInfo_ResolveName, CancellationToken.None))
                {
                    // In VS, this method frequently get's called with an empty string to test if the language service
                    // supports this method (some language services, like F#, implement IVsLanguageDebugInfo but don't
                    // implement this method).  In that scenario, there's no sense doing work, so we'll just return
                    // S_FALSE (as the old VB language service did).
                    if (string.IsNullOrEmpty(pszName))
                    {
                        ppNames = null;
                        return(VSConstants.S_FALSE);
                    }

                    VsEnumDebugName?enumName = null;
                    _uiThreadOperationExecutor.Execute(
                        title: ServicesVSResources.Debugger,
                        defaultDescription: ServicesVSResources.Resolving_breakpoint_location,
                        allowCancellation: true,
                        showProgress: false,
                        action: waitContext =>
                    {
                        _threadingContext.JoinableTaskFactory.Run(async() =>
                        {
                            var cancellationToken = waitContext.UserCancellationToken;
                            if (dwFlags == (uint)RESOLVENAMEFLAGS.RNF_BREAKPOINT)
                            {
                                var solution = _languageService.Workspace.CurrentSolution;

                                // NOTE(cyrusn): We have to wait here because the debuggers' ResolveName
                                // call is synchronous.  In the future it would be nice to make it async.
                                if (_breakpointService != null)
                                {
                                    var breakpoints = await _breakpointService.ResolveBreakpointsAsync(
                                        solution, pszName, cancellationToken).ConfigureAwait(false);
                                    var debugNames = await breakpoints.SelectAsArrayAsync(
                                        bp => CreateDebugNameAsync(bp, cancellationToken)).ConfigureAwait(false);

                                    enumName = new VsEnumDebugName(debugNames);
                                }
                            }
                        });
                    });

                    ppNames = enumName;
                    return(ppNames != null ? VSConstants.S_OK : VSConstants.E_NOTIMPL);
                }
            }