/
githubmirror
/
roslyn
Обзор
Документация
Войти
/
githubmirror
/
roslyn
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/VisualStudio/DevKit/Impl/SourceLink/VSCodeSourceLinkService.cs
68 строк
3 KB
David Barbet
Make C#DK service broker fully per server
06 май 2026, 04:01
06 май 2026, 04:01
6e5eadd
Код
Авторство
О чём код?
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using System; using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.BrokeredServices; using Microsoft.CodeAnalysis.PdbSourceDocument; using Microsoft.ServiceHub.Framework; using Microsoft.VisualStudio.Debugger.Contracts.SourceLink; using Microsoft.VisualStudio.Debugger.Contracts.SymbolLocator; using Microsoft.VisualStudio.LanguageServices.PdbSourceDocument; namespace Microsoft.CodeAnalysis.LanguageServer.Services.SourceLink; internal sealed class VSCodeSourceLinkService(IServiceBrokerProvider serviceBrokerProvider, IPdbSourceDocumentLogger? logger) : AbstractSourceLinkService { protected override async Task<SymbolLocatorResult?> LocateSymbolFileAsync(SymbolLocatorPdbInfo pdbInfo, SymbolLocatorSearchFlags flags, CancellationToken cancellationToken) { var proxy = await serviceBrokerProvider.ServiceBroker.GetProxyAsync<IDebuggerSymbolLocatorService>(BrokeredServiceDescriptors.DebuggerSymbolLocatorService, cancellationToken).ConfigureAwait(false); using ((IDisposable?)proxy) { if (proxy is null) { return null; } try { var result = await proxy.LocateSymbolFileAsync(pdbInfo, flags, progress: null, cancellationToken).ConfigureAwait(false); return result; } catch (StreamJsonRpc.RemoteMethodNotFoundException) { // Older versions of DevKit use an invalid service descriptor - calling it will throw a RemoteMethodNotFoundException. // Just return null as there isn't a valid service available. return null; } } } protected override async Task<SourceLinkResult?> GetSourceLinkAsync(string url, string relativePath, CancellationToken cancellationToken) { var proxy = await serviceBrokerProvider.ServiceBroker.GetProxyAsync<IDebuggerSourceLinkService>(BrokeredServiceDescriptors.DebuggerSourceLinkService, cancellationToken).ConfigureAwait(false); using ((IDisposable?)proxy) { if (proxy is null) { return null; } try { var result = await proxy.GetSourceLinkAsync(url, relativePath, allowInteractiveLogin: false, cancellationToken).ConfigureAwait(false); return result; } catch (StreamJsonRpc.RemoteMethodNotFoundException) { // Older versions of DevKit use an invalid service descriptor - calling it will throw a RemoteMethodNotFoundException. // Just return null as there isn't a valid service available. return null; } } } protected override IPdbSourceDocumentLogger? Logger => logger; }