From 8ec323d4bc69d9bb0c4d0cf7287d178b5f71f110 Mon Sep 17 00:00:00 2001 From: Fred Silberberg Date: Fri, 27 Sep 2024 10:25:14 -0700 Subject: [PATCH] Revert "Updates content exclusion for on-the-fly-docs (#75172)" This reverts commit 2f6b493db1f460fa8e5d96b3c81b1c9f4f57a314. --- .../QuickInfo/OnTheFlyDocsView.xaml.cs | 7 +++--- .../QuickInfo/OnTheFlyDocsViewFactory.cs | 5 +++- .../Core/EditorFeaturesResources.resx | 3 --- .../Core/xlf/EditorFeaturesResources.cs.xlf | 5 ---- .../Core/xlf/EditorFeaturesResources.de.xlf | 5 ---- .../Core/xlf/EditorFeaturesResources.es.xlf | 5 ---- .../Core/xlf/EditorFeaturesResources.fr.xlf | 5 ---- .../Core/xlf/EditorFeaturesResources.it.xlf | 5 ---- .../Core/xlf/EditorFeaturesResources.ja.xlf | 5 ---- .../Core/xlf/EditorFeaturesResources.ko.xlf | 5 ---- .../Core/xlf/EditorFeaturesResources.pl.xlf | 5 ---- .../xlf/EditorFeaturesResources.pt-BR.xlf | 5 ---- .../Core/xlf/EditorFeaturesResources.ru.xlf | 5 ---- .../Core/xlf/EditorFeaturesResources.tr.xlf | 5 ---- .../xlf/EditorFeaturesResources.zh-Hans.xlf | 5 ---- .../xlf/EditorFeaturesResources.zh-Hant.xlf | 5 ---- ...xternalCSharpCopilotCodeAnalysisService.cs | 3 +-- .../AbstractCopilotCodeAnalysisService.cs | 7 +++--- ...otCodeAnalysisService.ReflectionWrapper.cs | 17 +++++++------ .../CSharpCopilotCodeAnalysisService.cs | 4 ++-- .../Copilot/InternalAPI.Unshipped.txt | 2 +- .../Test2/CodeFixes/CodeFixServiceTests.vb | 2 +- .../CSharpSemanticQuickInfoProvider.cs | 24 +++++++------------ .../Copilot/ICopilotCodeAnalysisService.cs | 5 ++-- .../Portable/QuickInfo/OnTheFlyDocsElement.cs | 3 +-- .../Compiler/Core/Log/FunctionId.cs | 1 - 26 files changed, 35 insertions(+), 113 deletions(-) diff --git a/src/EditorFeatures/Core.Wpf/QuickInfo/OnTheFlyDocsView.xaml.cs b/src/EditorFeatures/Core.Wpf/QuickInfo/OnTheFlyDocsView.xaml.cs index defb3a0d337cc..1c5afaf46ef1b 100644 --- a/src/EditorFeatures/Core.Wpf/QuickInfo/OnTheFlyDocsView.xaml.cs +++ b/src/EditorFeatures/Core.Wpf/QuickInfo/OnTheFlyDocsView.xaml.cs @@ -69,9 +69,6 @@ public OnTheFlyDocsView(ITextView textView, IViewElementFactoryService viewEleme _document = editorFeaturesOnTheFlyDocsElement.Document; var sparkle = new ImageElement(new VisualStudio.Core.Imaging.ImageId(CopilotConstants.CopilotIconMonikerGuid, CopilotConstants.CopilotIconSparkleId)); - object onDemandLinkText = _onTheFlyDocsElement.IsContentExcluded - ? ToUIElement(new ContainerElement(ContainerElementStyle.Wrapped, new ClassifiedTextElement([new ClassifiedTextRun(ClassificationTypeNames.Text, EditorFeaturesResources.Describe_with_Copilot_is_unavailable_since_the_referenced_document_is_excluded_by_your_organization)]))) - : ClassifiedTextElement.CreateHyperlink(EditorFeaturesResources.Describe_with_Copilot, EditorFeaturesResources.Generate_summary_with_Copilot, () => RequestResults()); OnDemandLinkContent = ToUIElement( new ContainerElement( @@ -79,7 +76,8 @@ public OnTheFlyDocsView(ITextView textView, IViewElementFactoryService viewEleme new object[] { sparkle, - onDemandLinkText, + ClassifiedTextElement.CreateHyperlink(EditorFeaturesResources.Describe_with_Copilot, EditorFeaturesResources.Generate_summary_with_Copilot, () => + RequestResults()), })); LoadingContent = ToUIElement( @@ -204,6 +202,7 @@ public void RequestResults() CurrentState = OnTheFlyDocsState.Loading; Logger.Log(FunctionId.Copilot_On_The_Fly_Docs_Loading_State_Entered, KeyValueLogMessage.Create(m => { + m["SymbolHeaderText"] = _onTheFlyDocsElement.SymbolSignature; m["HasDocumentationComments"] = _onTheFlyDocsElement.HasComments; }, LogLevel.Information)); diff --git a/src/EditorFeatures/Core.Wpf/QuickInfo/OnTheFlyDocsViewFactory.cs b/src/EditorFeatures/Core.Wpf/QuickInfo/OnTheFlyDocsViewFactory.cs index 75937919f9cd0..9cb2e12e18edf 100644 --- a/src/EditorFeatures/Core.Wpf/QuickInfo/OnTheFlyDocsViewFactory.cs +++ b/src/EditorFeatures/Core.Wpf/QuickInfo/OnTheFlyDocsViewFactory.cs @@ -48,7 +48,10 @@ public OnTheFlyDocsViewFactory(IViewElementFactoryService factoryService, IAsync var editorFeaturesOnTheFlyDocsElement = (EditorFeaturesOnTheFlyDocsElement)model; - Logger.Log(FunctionId.Copilot_On_The_Fly_Docs_Showed_Link, logLevel: LogLevel.Information); + Logger.Log(FunctionId.Copilot_On_The_Fly_Docs_Showed_Link, KeyValueLogMessage.Create(m => + { + m["SymbolHeaderText"] = editorFeaturesOnTheFlyDocsElement.OnTheFlyDocsElement.SymbolSignature; + }, LogLevel.Information)); var quickInfoSession = _asyncQuickInfoBroker.GetSession(textView); diff --git a/src/EditorFeatures/Core/EditorFeaturesResources.resx b/src/EditorFeatures/Core/EditorFeaturesResources.resx index ff479357f6a54..2935410db3198 100644 --- a/src/EditorFeatures/Core/EditorFeaturesResources.resx +++ b/src/EditorFeatures/Core/EditorFeaturesResources.resx @@ -953,7 +953,4 @@ Do you want to proceed? An error occurred while generating documentation for this code. - - 'Describe with Copilot' is unavailable since the referenced document is excluded by your organization. - \ No newline at end of file diff --git a/src/EditorFeatures/Core/xlf/EditorFeaturesResources.cs.xlf b/src/EditorFeatures/Core/xlf/EditorFeaturesResources.cs.xlf index a25741b5f717c..368461da36dce 100644 --- a/src/EditorFeatures/Core/xlf/EditorFeaturesResources.cs.xlf +++ b/src/EditorFeatures/Core/xlf/EditorFeaturesResources.cs.xlf @@ -42,11 +42,6 @@ Popis s využitím Copilotu - - 'Describe with Copilot' is unavailable since the referenced document is excluded by your organization. - 'Describe with Copilot' is unavailable since the referenced document is excluded by your organization. - - Do not prefer 'this.' or 'Me.' Nepreferovat this. ani Me. diff --git a/src/EditorFeatures/Core/xlf/EditorFeaturesResources.de.xlf b/src/EditorFeatures/Core/xlf/EditorFeaturesResources.de.xlf index 12b3fca95419d..73d17a0576a0b 100644 --- a/src/EditorFeatures/Core/xlf/EditorFeaturesResources.de.xlf +++ b/src/EditorFeatures/Core/xlf/EditorFeaturesResources.de.xlf @@ -42,11 +42,6 @@ Mit Copilot beschreiben - - 'Describe with Copilot' is unavailable since the referenced document is excluded by your organization. - 'Describe with Copilot' is unavailable since the referenced document is excluded by your organization. - - Do not prefer 'this.' or 'Me.' "this." oder "Me." nicht bevorzugen diff --git a/src/EditorFeatures/Core/xlf/EditorFeaturesResources.es.xlf b/src/EditorFeatures/Core/xlf/EditorFeaturesResources.es.xlf index e5ba499c82b8b..a078c06273a14 100644 --- a/src/EditorFeatures/Core/xlf/EditorFeaturesResources.es.xlf +++ b/src/EditorFeatures/Core/xlf/EditorFeaturesResources.es.xlf @@ -42,11 +42,6 @@ Describir con Copilot - - 'Describe with Copilot' is unavailable since the referenced document is excluded by your organization. - 'Describe with Copilot' is unavailable since the referenced document is excluded by your organization. - - Do not prefer 'this.' or 'Me.' No preferir "this." ni "Me." diff --git a/src/EditorFeatures/Core/xlf/EditorFeaturesResources.fr.xlf b/src/EditorFeatures/Core/xlf/EditorFeaturesResources.fr.xlf index 0b66e733e9d05..71ec07f37b095 100644 --- a/src/EditorFeatures/Core/xlf/EditorFeaturesResources.fr.xlf +++ b/src/EditorFeatures/Core/xlf/EditorFeaturesResources.fr.xlf @@ -42,11 +42,6 @@ Décrire avec Copilot - - 'Describe with Copilot' is unavailable since the referenced document is excluded by your organization. - 'Describe with Copilot' is unavailable since the referenced document is excluded by your organization. - - Do not prefer 'this.' or 'Me.' Ne pas préférer 'this.' ou 'Me.' diff --git a/src/EditorFeatures/Core/xlf/EditorFeaturesResources.it.xlf b/src/EditorFeatures/Core/xlf/EditorFeaturesResources.it.xlf index 6231f64742e53..9d4f216815ab8 100644 --- a/src/EditorFeatures/Core/xlf/EditorFeaturesResources.it.xlf +++ b/src/EditorFeatures/Core/xlf/EditorFeaturesResources.it.xlf @@ -42,11 +42,6 @@ Descrivi con Copilot - - 'Describe with Copilot' is unavailable since the referenced document is excluded by your organization. - 'Describe with Copilot' is unavailable since the referenced document is excluded by your organization. - - Do not prefer 'this.' or 'Me.' Non preferire 'this.' o 'Me.' diff --git a/src/EditorFeatures/Core/xlf/EditorFeaturesResources.ja.xlf b/src/EditorFeatures/Core/xlf/EditorFeaturesResources.ja.xlf index 6b8b4caf72654..7c1c5397d7c4b 100644 --- a/src/EditorFeatures/Core/xlf/EditorFeaturesResources.ja.xlf +++ b/src/EditorFeatures/Core/xlf/EditorFeaturesResources.ja.xlf @@ -42,11 +42,6 @@ Copilot で説明する - - 'Describe with Copilot' is unavailable since the referenced document is excluded by your organization. - 'Describe with Copilot' is unavailable since the referenced document is excluded by your organization. - - Do not prefer 'this.' or 'Me.' 'this.' または 'Me' を優先しない diff --git a/src/EditorFeatures/Core/xlf/EditorFeaturesResources.ko.xlf b/src/EditorFeatures/Core/xlf/EditorFeaturesResources.ko.xlf index 4cf5ef46a1654..5551bdf08ec3d 100644 --- a/src/EditorFeatures/Core/xlf/EditorFeaturesResources.ko.xlf +++ b/src/EditorFeatures/Core/xlf/EditorFeaturesResources.ko.xlf @@ -42,11 +42,6 @@ Copilot으로 설명 - - 'Describe with Copilot' is unavailable since the referenced document is excluded by your organization. - 'Describe with Copilot' is unavailable since the referenced document is excluded by your organization. - - Do not prefer 'this.' or 'Me.' 'this.' 또는 'Me.'를 기본으로 사용하지 마세요. diff --git a/src/EditorFeatures/Core/xlf/EditorFeaturesResources.pl.xlf b/src/EditorFeatures/Core/xlf/EditorFeaturesResources.pl.xlf index aac3e348ff453..edd3298f66a38 100644 --- a/src/EditorFeatures/Core/xlf/EditorFeaturesResources.pl.xlf +++ b/src/EditorFeatures/Core/xlf/EditorFeaturesResources.pl.xlf @@ -42,11 +42,6 @@ Opisz za pomocą funkcji Copilot - - 'Describe with Copilot' is unavailable since the referenced document is excluded by your organization. - 'Describe with Copilot' is unavailable since the referenced document is excluded by your organization. - - Do not prefer 'this.' or 'Me.' Nie preferuj zapisu „this.” lub „me.” diff --git a/src/EditorFeatures/Core/xlf/EditorFeaturesResources.pt-BR.xlf b/src/EditorFeatures/Core/xlf/EditorFeaturesResources.pt-BR.xlf index ceddf983b7b54..eb1a663a3611e 100644 --- a/src/EditorFeatures/Core/xlf/EditorFeaturesResources.pt-BR.xlf +++ b/src/EditorFeatures/Core/xlf/EditorFeaturesResources.pt-BR.xlf @@ -42,11 +42,6 @@ Descrever com o Copilot - - 'Describe with Copilot' is unavailable since the referenced document is excluded by your organization. - 'Describe with Copilot' is unavailable since the referenced document is excluded by your organization. - - Do not prefer 'this.' or 'Me.' Não preferir 'this.' nem 'Me'. diff --git a/src/EditorFeatures/Core/xlf/EditorFeaturesResources.ru.xlf b/src/EditorFeatures/Core/xlf/EditorFeaturesResources.ru.xlf index 5343cbc8b6007..aa2e59485bf36 100644 --- a/src/EditorFeatures/Core/xlf/EditorFeaturesResources.ru.xlf +++ b/src/EditorFeatures/Core/xlf/EditorFeaturesResources.ru.xlf @@ -42,11 +42,6 @@ Описать с помощью Copilot - - 'Describe with Copilot' is unavailable since the referenced document is excluded by your organization. - 'Describe with Copilot' is unavailable since the referenced document is excluded by your organization. - - Do not prefer 'this.' or 'Me.' Не предпочитать "this." или "Me". diff --git a/src/EditorFeatures/Core/xlf/EditorFeaturesResources.tr.xlf b/src/EditorFeatures/Core/xlf/EditorFeaturesResources.tr.xlf index a3fbff3a42ab7..a9cec135218a6 100644 --- a/src/EditorFeatures/Core/xlf/EditorFeaturesResources.tr.xlf +++ b/src/EditorFeatures/Core/xlf/EditorFeaturesResources.tr.xlf @@ -42,11 +42,6 @@ Copilot ile açıkla - - 'Describe with Copilot' is unavailable since the referenced document is excluded by your organization. - 'Describe with Copilot' is unavailable since the referenced document is excluded by your organization. - - Do not prefer 'this.' or 'Me.' 'this.' veya 'Me.' tercih etme diff --git a/src/EditorFeatures/Core/xlf/EditorFeaturesResources.zh-Hans.xlf b/src/EditorFeatures/Core/xlf/EditorFeaturesResources.zh-Hans.xlf index b3ea85144f991..726e2fb43938f 100644 --- a/src/EditorFeatures/Core/xlf/EditorFeaturesResources.zh-Hans.xlf +++ b/src/EditorFeatures/Core/xlf/EditorFeaturesResources.zh-Hans.xlf @@ -42,11 +42,6 @@ 使用 Copilot 进行描述 - - 'Describe with Copilot' is unavailable since the referenced document is excluded by your organization. - 'Describe with Copilot' is unavailable since the referenced document is excluded by your organization. - - Do not prefer 'this.' or 'Me.' 不首选 "this." 或 "Me." diff --git a/src/EditorFeatures/Core/xlf/EditorFeaturesResources.zh-Hant.xlf b/src/EditorFeatures/Core/xlf/EditorFeaturesResources.zh-Hant.xlf index 48e5a3c4026f3..afe5660870c72 100644 --- a/src/EditorFeatures/Core/xlf/EditorFeaturesResources.zh-Hant.xlf +++ b/src/EditorFeatures/Core/xlf/EditorFeaturesResources.zh-Hant.xlf @@ -42,11 +42,6 @@ 使用 Copilot 加以描述 - - 'Describe with Copilot' is unavailable since the referenced document is excluded by your organization. - 'Describe with Copilot' is unavailable since the referenced document is excluded by your organization. - - Do not prefer 'this.' or 'Me.' 不建議使用 'this.' 或 'Me.' diff --git a/src/EditorFeatures/ExternalAccess/Copilot/Analyzer/IExternalCSharpCopilotCodeAnalysisService.cs b/src/EditorFeatures/ExternalAccess/Copilot/Analyzer/IExternalCSharpCopilotCodeAnalysisService.cs index 3a8485c1f14b2..799fe9c51e731 100644 --- a/src/EditorFeatures/ExternalAccess/Copilot/Analyzer/IExternalCSharpCopilotCodeAnalysisService.cs +++ b/src/EditorFeatures/ExternalAccess/Copilot/Analyzer/IExternalCSharpCopilotCodeAnalysisService.cs @@ -2,7 +2,6 @@ // 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.Collections.Immutable; using System.Threading; using System.Threading.Tasks; @@ -19,5 +18,5 @@ internal interface IExternalCSharpCopilotCodeAnalysisService Task> GetCachedDiagnosticsAsync(Document document, string promptTitle, CancellationToken cancellationToken); Task StartRefinementSessionAsync(Document oldDocument, Document newDocument, Diagnostic? primaryDiagnostic, CancellationToken cancellationToken); Task GetOnTheFlyDocsAsync(string symbolSignature, ImmutableArray declarationCode, string language, CancellationToken cancellationToken); - Task IsFileExcludedAsync(string filePath, CancellationToken cancellationToken); + Task IsAnyExclusionAsync(CancellationToken cancellationToken); } diff --git a/src/EditorFeatures/ExternalAccess/Copilot/Internal/Analyzer/AbstractCopilotCodeAnalysisService.cs b/src/EditorFeatures/ExternalAccess/Copilot/Internal/Analyzer/AbstractCopilotCodeAnalysisService.cs index 1c0353b079b42..1762a2cdc460e 100644 --- a/src/EditorFeatures/ExternalAccess/Copilot/Internal/Analyzer/AbstractCopilotCodeAnalysisService.cs +++ b/src/EditorFeatures/ExternalAccess/Copilot/Internal/Analyzer/AbstractCopilotCodeAnalysisService.cs @@ -2,7 +2,6 @@ // 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.Collections.Concurrent; using System.Collections.Generic; using System.Collections.Immutable; @@ -40,7 +39,7 @@ internal abstract class AbstractCopilotCodeAnalysisService(IDiagnosticsRefresher protected abstract Task> GetCachedDiagnosticsCoreAsync(Document document, string promptTitle, CancellationToken cancellationToken); protected abstract Task StartRefinementSessionCoreAsync(Document oldDocument, Document newDocument, Diagnostic? primaryDiagnostic, CancellationToken cancellationToken); protected abstract Task GetOnTheFlyDocsCoreAsync(string symbolSignature, ImmutableArray declarationCode, string language, CancellationToken cancellationToken); - protected abstract Task IsFileExcludedCoreAsync(string filePath, CancellationToken cancellationToken); + protected abstract Task IsAnyExclusionCoreAsync(CancellationToken cancellationToken); public Task IsAvailableAsync(CancellationToken cancellationToken) => IsAvailableCoreAsync(cancellationToken); @@ -181,11 +180,11 @@ public async Task GetOnTheFlyDocsAsync(string symbolSignature, Immutable return await GetOnTheFlyDocsCoreAsync(symbolSignature, declarationCode, language, cancellationToken).ConfigureAwait(false); } - public async Task IsFileExcludedAsync(string filePath, CancellationToken cancellationToken) + public async Task IsAnyExclusionAsync(CancellationToken cancellationToken) { if (!await IsAvailableAsync(cancellationToken).ConfigureAwait(false)) return false; - return await IsFileExcludedCoreAsync(filePath, cancellationToken).ConfigureAwait(false); + return await IsAnyExclusionCoreAsync(cancellationToken).ConfigureAwait(false); } } diff --git a/src/EditorFeatures/ExternalAccess/Copilot/Internal/Analyzer/CSharp/CSharpCopilotCodeAnalysisService.ReflectionWrapper.cs b/src/EditorFeatures/ExternalAccess/Copilot/Internal/Analyzer/CSharp/CSharpCopilotCodeAnalysisService.ReflectionWrapper.cs index 7b3b41c63c1c6..d96f5ea40147b 100644 --- a/src/EditorFeatures/ExternalAccess/Copilot/Internal/Analyzer/CSharp/CSharpCopilotCodeAnalysisService.ReflectionWrapper.cs +++ b/src/EditorFeatures/ExternalAccess/Copilot/Internal/Analyzer/CSharp/CSharpCopilotCodeAnalysisService.ReflectionWrapper.cs @@ -21,7 +21,6 @@ namespace Microsoft.CodeAnalysis.ExternalAccess.Copilot.Internal.Analyzer.CSharp using StartRefinementSessionAsyncDelegateType = Func; using GetOnTheFlyDocsAsyncDelegateType = Func, string, CancellationToken, Task>; using IsAnyExclusionAsyncDelegateType = Func>; -using IsFileExcludedAsyncDelegateType = Func>; internal sealed partial class CSharpCopilotCodeAnalysisService { @@ -37,7 +36,7 @@ private sealed class ReflectionWrapper : IExternalCSharpCopilotCodeAnalysisServi private const string GetCachedDiagnosticsAsyncMethodName = "GetCachedDiagnosticsAsync"; private const string StartRefinementSessionAsyncMethodName = "StartRefinementSessionAsync"; private const string GetOnTheFlyDocsAsyncMethodName = "GetOnTheFlyDocsAsync"; - private const string IsFileExcludedAsyncMethodName = "IsFileExcludedAsync"; + private const string IsAnyExclusionAsyncMethodName = "IsAnyExclusionAsync"; // Create and cache closed delegate to ensure we use a singleton object and with better performance. private readonly Type? _analyzerType; @@ -48,7 +47,7 @@ private sealed class ReflectionWrapper : IExternalCSharpCopilotCodeAnalysisServi private readonly Lazy _lazyGetCachedDiagnosticsAsyncDelegate; private readonly Lazy _lazyStartRefinementSessionAsyncDelegate; private readonly Lazy _lazyGetOnTheFlyDocsAsyncDelegate; - private readonly Lazy _lazyIsFileExcludedAsyncDelegate; + private readonly Lazy _lazyIsAnyExclusionAsyncDelegate; public ReflectionWrapper(IServiceProvider serviceProvider, IVsService brokeredServiceContainer) { @@ -77,7 +76,7 @@ public ReflectionWrapper(IServiceProvider serviceProvider, IVsService(string methodName, Type[] types) where T : Delegate @@ -116,8 +115,8 @@ public ReflectionWrapper(IServiceProvider serviceProvider, IVsService CreateDelegate(GetOnTheFlyDocsAsyncMethodName, [typeof(string), typeof(ImmutableArray), typeof(string), typeof(CancellationToken)]); - private IsFileExcludedAsyncDelegateType? CreateIsFileExcludedAsyncDelegate() - => CreateDelegate(IsFileExcludedAsyncMethodName, [typeof(string), typeof(CancellationToken)]); + private IsAnyExclusionAsyncDelegateType? CreateIsAnyExclusionAsyncDelegate() + => CreateDelegate(IsAnyExclusionAsyncMethodName, [typeof(CancellationToken)]); public async Task IsAvailableAsync(CancellationToken cancellationToken) { @@ -167,12 +166,12 @@ public async Task GetOnTheFlyDocsAsync(string symbolSignature, Immutable return await _lazyGetOnTheFlyDocsAsyncDelegate.Value(symbolSignature, declarationCode, language, cancellationToken).ConfigureAwait(false); } - public async Task IsFileExcludedAsync(string filePath, CancellationToken cancellationToken) + public async Task IsAnyExclusionAsync(CancellationToken cancellationToken) { - if (_lazyIsFileExcludedAsyncDelegate.Value is null) + if (_lazyIsAnyExclusionAsyncDelegate.Value is null) return false; - return await _lazyIsFileExcludedAsyncDelegate.Value(filePath, cancellationToken).ConfigureAwait(false); + return await _lazyIsAnyExclusionAsyncDelegate.Value(cancellationToken).ConfigureAwait(false); } } } diff --git a/src/EditorFeatures/ExternalAccess/Copilot/Internal/Analyzer/CSharp/CSharpCopilotCodeAnalysisService.cs b/src/EditorFeatures/ExternalAccess/Copilot/Internal/Analyzer/CSharp/CSharpCopilotCodeAnalysisService.cs index 317a234a68c11..74fc9ad8b1d74 100644 --- a/src/EditorFeatures/ExternalAccess/Copilot/Internal/Analyzer/CSharp/CSharpCopilotCodeAnalysisService.cs +++ b/src/EditorFeatures/ExternalAccess/Copilot/Internal/Analyzer/CSharp/CSharpCopilotCodeAnalysisService.cs @@ -80,6 +80,6 @@ protected override async Task> GetDiagnosticsIntersec return filteredDiagnostics.ToImmutable(); } - protected override Task IsFileExcludedCoreAsync(string filePath, CancellationToken cancellationToken) - => _lazyExternalCopilotService.Value.IsFileExcludedAsync(filePath, cancellationToken); + protected override Task IsAnyExclusionCoreAsync(CancellationToken cancellationToken) + => _lazyExternalCopilotService.Value.IsAnyExclusionAsync(cancellationToken); } diff --git a/src/EditorFeatures/ExternalAccess/Copilot/InternalAPI.Unshipped.txt b/src/EditorFeatures/ExternalAccess/Copilot/InternalAPI.Unshipped.txt index 9f06d5d62b1b3..62074d860791e 100644 --- a/src/EditorFeatures/ExternalAccess/Copilot/InternalAPI.Unshipped.txt +++ b/src/EditorFeatures/ExternalAccess/Copilot/InternalAPI.Unshipped.txt @@ -9,8 +9,8 @@ Microsoft.CodeAnalysis.ExternalAccess.Copilot.IExternalCSharpCopilotCodeAnalysis Microsoft.CodeAnalysis.ExternalAccess.Copilot.IExternalCSharpCopilotCodeAnalysisService.GetAvailablePromptTitlesAsync(Microsoft.CodeAnalysis.Document! document, System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.Task>! Microsoft.CodeAnalysis.ExternalAccess.Copilot.IExternalCSharpCopilotCodeAnalysisService.GetCachedDiagnosticsAsync(Microsoft.CodeAnalysis.Document! document, string! promptTitle, System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.Task>! Microsoft.CodeAnalysis.ExternalAccess.Copilot.IExternalCSharpCopilotCodeAnalysisService.GetOnTheFlyDocsAsync(string! symbolSignature, System.Collections.Immutable.ImmutableArray declarationCode, string! language, System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.Task! +Microsoft.CodeAnalysis.ExternalAccess.Copilot.IExternalCSharpCopilotCodeAnalysisService.IsAnyExclusionAsync(System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.Task! Microsoft.CodeAnalysis.ExternalAccess.Copilot.IExternalCSharpCopilotCodeAnalysisService.IsAvailableAsync(System.Threading.CancellationToken cancellation) -> System.Threading.Tasks.Task! -Microsoft.CodeAnalysis.ExternalAccess.Copilot.IExternalCSharpCopilotCodeAnalysisService.IsFileExcludedAsync(string! filePath, System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.Task! Microsoft.CodeAnalysis.ExternalAccess.Copilot.IExternalCSharpCopilotCodeAnalysisService.StartRefinementSessionAsync(Microsoft.CodeAnalysis.Document! oldDocument, Microsoft.CodeAnalysis.Document! newDocument, Microsoft.CodeAnalysis.Diagnostic? primaryDiagnostic, System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.Task! Microsoft.CodeAnalysis.ExternalAccess.Copilot.RelatedDocuments.ICopilotRelatedDocumentsService Microsoft.CodeAnalysis.ExternalAccess.Copilot.RelatedDocuments.ICopilotRelatedDocumentsService.GetRelatedDocumentIdsAsync(Microsoft.CodeAnalysis.Document! document, int position, System.Func, System.Threading.CancellationToken, System.Threading.Tasks.ValueTask>! callbackAsync, System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.ValueTask diff --git a/src/EditorFeatures/Test2/CodeFixes/CodeFixServiceTests.vb b/src/EditorFeatures/Test2/CodeFixes/CodeFixServiceTests.vb index 75c7d563e12f8..fcb96e630d4fb 100644 --- a/src/EditorFeatures/Test2/CodeFixes/CodeFixServiceTests.vb +++ b/src/EditorFeatures/Test2/CodeFixes/CodeFixServiceTests.vb @@ -355,7 +355,7 @@ Namespace Microsoft.CodeAnalysis.Editor.Implementation.CodeFixes.UnitTests Return Task.FromResult("") End Function - Public Function IsFileExcludedAsync(filePath As String, cancellationToken As CancellationToken) As Task(Of Boolean) Implements ICopilotCodeAnalysisService.IsFileExcludedAsync + Public Function IsAnyExclusionAsync(cancellationToken As CancellationToken) As Task(Of Boolean) Implements ICopilotCodeAnalysisService.IsAnyExclusionAsync Return Task.FromResult(False) End Function End Class diff --git a/src/Features/CSharp/Portable/QuickInfo/CSharpSemanticQuickInfoProvider.cs b/src/Features/CSharp/Portable/QuickInfo/CSharpSemanticQuickInfoProvider.cs index fda0f18be53b2..58d9692f01e4a 100644 --- a/src/Features/CSharp/Portable/QuickInfo/CSharpSemanticQuickInfoProvider.cs +++ b/src/Features/CSharp/Portable/QuickInfo/CSharpSemanticQuickInfoProvider.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System; +using System.Collections.Generic; using System.Collections.Immutable; using System.Composition; using System.Diagnostics.CodeAnalysis; @@ -14,7 +15,6 @@ using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.GoToDefinition; using Microsoft.CodeAnalysis.Host.Mef; -using Microsoft.CodeAnalysis.Internal.Log; using Microsoft.CodeAnalysis.QuickInfo; using Microsoft.CodeAnalysis.Shared.Extensions; @@ -146,6 +146,13 @@ protected override NullableFlowState GetNullabilityAnalysis(SemanticModel semant return null; } + // Checks to see if there have been any files excluded at the workspace level + // since the copilot service passes along symbol information. + if (await copilotService.IsAnyExclusionAsync(cancellationToken).ConfigureAwait(false)) + { + return null; + } + if (document.GetLanguageService() is not { } service || !await service.IsOnTheFlyDocsOptionEnabledAsync().ConfigureAwait(false)) { @@ -175,19 +182,6 @@ protected override NullableFlowState GetNullabilityAnalysis(SemanticModel semant return null; } - // Checks to see if any of the files containing the symbol are excluded. - var hasContentExcluded = false; - var symbolFilePaths = symbol.DeclaringSyntaxReferences.Select(reference => reference.SyntaxTree.FilePath); - foreach (var symbolFilePath in symbolFilePaths) - { - if (await copilotService.IsFileExcludedAsync(symbolFilePath, cancellationToken).ConfigureAwait(false)) - { - hasContentExcluded = true; - Logger.Log(FunctionId.Copilot_On_The_Fly_Docs_Content_Excluded, logLevel: LogLevel.Information); - break; - } - } - var maxLength = 1000; var symbolStrings = symbol.DeclaringSyntaxReferences.Select(reference => { @@ -196,6 +190,6 @@ protected override NullableFlowState GetNullabilityAnalysis(SemanticModel semant return sourceText.GetSubText(new Text.TextSpan(span.Start, Math.Min(maxLength, span.Length))).ToString(); }).ToImmutableArray(); - return new OnTheFlyDocsElement(symbol.ToDisplayString(), symbolStrings, symbol.Language, hasContentExcluded); + return new OnTheFlyDocsElement(symbol.ToDisplayString(), symbolStrings, symbol.Language); } } diff --git a/src/Features/Core/Portable/Copilot/ICopilotCodeAnalysisService.cs b/src/Features/Core/Portable/Copilot/ICopilotCodeAnalysisService.cs index 0bdd083ad9584..13f2f65139617 100644 --- a/src/Features/Core/Portable/Copilot/ICopilotCodeAnalysisService.cs +++ b/src/Features/Core/Portable/Copilot/ICopilotCodeAnalysisService.cs @@ -2,7 +2,6 @@ // 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.Collections.Immutable; using System.Threading; using System.Threading.Tasks; @@ -73,8 +72,8 @@ internal interface ICopilotCodeAnalysisService : ILanguageService Task GetOnTheFlyDocsAsync(string symbolSignature, ImmutableArray declarationCode, string language, CancellationToken cancellationToken); /// - /// Determines if the given is excluded in the workspace. + /// Determines if there are any exclusions in the workspace. /// - Task IsFileExcludedAsync(string filePath, CancellationToken cancellationToken); + Task IsAnyExclusionAsync(CancellationToken cancellationToken); } diff --git a/src/Features/Core/Portable/QuickInfo/OnTheFlyDocsElement.cs b/src/Features/Core/Portable/QuickInfo/OnTheFlyDocsElement.cs index 434726a548de6..8879bbb5fd326 100644 --- a/src/Features/Core/Portable/QuickInfo/OnTheFlyDocsElement.cs +++ b/src/Features/Core/Portable/QuickInfo/OnTheFlyDocsElement.cs @@ -13,12 +13,11 @@ namespace Microsoft.CodeAnalysis.QuickInfo; /// the symbol's declaration code /// the language of the symbol /// whether the symbol has comments -internal sealed class OnTheFlyDocsElement(string symbolSignature, ImmutableArray declarationCode, string language, bool isContentExcluded, bool hasComments = false) +internal sealed class OnTheFlyDocsElement(string symbolSignature, ImmutableArray declarationCode, string language, bool hasComments = false) { public string SymbolSignature { get; } = symbolSignature; public ImmutableArray DeclarationCode { get; } = declarationCode; public string Language { get; } = language; - public bool IsContentExcluded { get; set; } = isContentExcluded; // Added for telemetry collection purposes. public bool HasComments { get; set; } = hasComments; diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Log/FunctionId.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Log/FunctionId.cs index 77c0c94bde897..b6484117c90ae 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Log/FunctionId.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Log/FunctionId.cs @@ -633,6 +633,5 @@ internal enum FunctionId Copilot_On_The_Fly_Docs_Error_Displayed = 813, Copilot_On_The_Fly_Docs_Results_Canceled = 814, Copilot_On_The_Fly_Docs_Get_Counts = 815, - Copilot_On_The_Fly_Docs_Content_Excluded = 816, Copilot_Rename = 851 }