From e29be48af7e7e768b7a1128c2216385796506ea3 Mon Sep 17 00:00:00 2001 From: "gel@microsoft.com" Date: Fri, 27 May 2022 18:03:03 -0700 Subject: [PATCH 01/35] Update to new editotr package --- eng/Versions.props | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/eng/Versions.props b/eng/Versions.props index 59017cb7ada3d..c65c04bfaaa11 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -25,11 +25,11 @@ 0.1.132-beta 4.2.0-2.final - 17.2.3194 + 17.3.75-preview 5.0.0-alpha1.19409.1 5.0.0-preview.1.20112.8 17.3.15 - 17.2.32505.113 + 17.3.0-preview-1-32407-044 16.5.0 3.8.0 7.0.0-alpha.1.22060.1 - 3.1.4097 - 17.2.32 + 3.1.5102 + 17.3.1-alpha 13.0.1 - 2.11.35 + 2.12.7-alpha - + 4.2.0-2.final - 17.3.75-preview + 17.3.108-preview 5.0.0-alpha1.19409.1 5.0.0-preview.1.20112.8 17.3.15 From c44e8687a44b693fac859d9b4eb118a26e81866a Mon Sep 17 00:00:00 2001 From: "Gen Lu (HE/HIM)" Date: Thu, 2 Jun 2022 12:53:32 -0700 Subject: [PATCH 06/35] Fix test --- .../TestUtilities2/Intellisense/TestState.vb | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/EditorFeatures/TestUtilities2/Intellisense/TestState.vb b/src/EditorFeatures/TestUtilities2/Intellisense/TestState.vb index 4310a552a29ef..5227b8e61b470 100644 --- a/src/EditorFeatures/TestUtilities2/Intellisense/TestState.vb +++ b/src/EditorFeatures/TestUtilities2/Intellisense/TestState.vb @@ -288,15 +288,7 @@ Namespace Microsoft.CodeAnalysis.Editor.UnitTests.IntelliSense Return End If - If session.IsDismissed Then - Return - End If - - Dim completionItems = session.GetComputedItems(CancellationToken.None) - - ' During the computation we can explicitly dismiss the session or we can return no items. - ' Each of these conditions mean that there is no active completion. - Assert.True(session.IsDismissed OrElse completionItems.Items.Count() = 0, "AssertNoCompletionSession") + Assert.True(session.IsDismissed, "AssertNoCompletionSession") End Function Public Sub AssertNoCompletionSessionWithNoBlock() From 12fcecfa26cb15a021ac5fc98725f4179584253c Mon Sep 17 00:00:00 2001 From: "Gen Lu (HE/HIM)" Date: Thu, 2 Jun 2022 14:53:38 -0700 Subject: [PATCH 07/35] Revert "Fix test" This reverts commit c44e8687a44b693fac859d9b4eb118a26e81866a. --- .../TestUtilities2/Intellisense/TestState.vb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/EditorFeatures/TestUtilities2/Intellisense/TestState.vb b/src/EditorFeatures/TestUtilities2/Intellisense/TestState.vb index 5227b8e61b470..4310a552a29ef 100644 --- a/src/EditorFeatures/TestUtilities2/Intellisense/TestState.vb +++ b/src/EditorFeatures/TestUtilities2/Intellisense/TestState.vb @@ -288,7 +288,15 @@ Namespace Microsoft.CodeAnalysis.Editor.UnitTests.IntelliSense Return End If - Assert.True(session.IsDismissed, "AssertNoCompletionSession") + If session.IsDismissed Then + Return + End If + + Dim completionItems = session.GetComputedItems(CancellationToken.None) + + ' During the computation we can explicitly dismiss the session or we can return no items. + ' Each of these conditions mean that there is no active completion. + Assert.True(session.IsDismissed OrElse completionItems.Items.Count() = 0, "AssertNoCompletionSession") End Function Public Sub AssertNoCompletionSessionWithNoBlock() From b2271f6974ddd56781da6ac024c1ed3455950174 Mon Sep 17 00:00:00 2001 From: "Gen Lu (HE/HIM)" Date: Mon, 6 Jun 2022 13:02:41 -0700 Subject: [PATCH 08/35] Update Editor packages --- eng/Versions.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/Versions.props b/eng/Versions.props index 35f0f21f79241..edf4ccf93225a 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -25,7 +25,7 @@ 0.1.132-beta 4.2.0-2.final - 17.3.108-preview + 17.3.122-preview 5.0.0-alpha1.19409.1 5.0.0-preview.1.20112.8 17.3.2062-preview From 9a5bcade41643c1f7c973cfd886a9184e3a3bfa2 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Tue, 7 Jun 2022 12:42:44 -0700 Subject: [PATCH 09/35] Update package references --- eng/Versions.props | 12 ++++++------ src/EditorFeatures/Core/SpellCheck/Class1.cs | 20 ++++++++++++++++++++ 2 files changed, 26 insertions(+), 6 deletions(-) create mode 100644 src/EditorFeatures/Core/SpellCheck/Class1.cs diff --git a/eng/Versions.props b/eng/Versions.props index edd8dc74648a7..394ee1ede2355 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -25,12 +25,12 @@ 0.1.132-beta 4.2.0-2.final - 17.3.37-preview + 17.3.49-preview 5.0.0-alpha1.19409.1 5.0.0-preview.1.20112.8 17.3.2062-preview 17.3.2017 - 17.2.32505.113 + 17.3.0-preview-1-32407-044 16.5.0 3.8.0 7.0.0-alpha.1.22060.1 - 3.1.4097 - 17.2.32 + 3.1.5102 + 17.3.1-alpha 13.0.1 - 2.11.35 + 2.12.7-alpha 4.2.0-2.final - 17.3.49-preview + 17.3.133-preview 5.0.0-alpha1.19409.1 5.0.0-preview.1.20112.8 17.3.2062-preview From 495997ce89432ed72996de6c3e3da06120daee91 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Thu, 9 Jun 2022 10:50:47 -0700 Subject: [PATCH 13/35] Add ref --- src/EditorFeatures/Core/SpellCheck/Class1.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/EditorFeatures/Core/SpellCheck/Class1.cs b/src/EditorFeatures/Core/SpellCheck/Class1.cs index 305180952cac0..ab9014bd864f2 100644 --- a/src/EditorFeatures/Core/SpellCheck/Class1.cs +++ b/src/EditorFeatures/Core/SpellCheck/Class1.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using System.Text; +using Microsoft.VisualStudio.Text.SpellChecker; namespace Microsoft.CodeAnalysis.SpellCheck { From 9bd801a00363b7a120128d6b3da796b0d814447d Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Thu, 9 Jun 2022 11:28:12 -0700 Subject: [PATCH 14/35] Add spell checker --- Roslyn.sln | 12 +- src/EditorFeatures/Core/SpellCheck/Class1.cs | 21 ---- .../RoslynSpellCheckFixerProvider.cs | 110 ++++++++++++++++++ 3 files changed, 116 insertions(+), 27 deletions(-) delete mode 100644 src/EditorFeatures/Core/SpellCheck/Class1.cs create mode 100644 src/EditorFeatures/Core/SpellCheck/RoslynSpellCheckFixerProvider.cs diff --git a/Roslyn.sln b/Roslyn.sln index b5d318bcc206d..61c8682f2503f 100644 --- a/Roslyn.sln +++ b/Roslyn.sln @@ -1473,7 +1473,7 @@ Global GlobalSection(SharedMSBuildProjectFiles) = preSolution src\Analyzers\VisualBasic\CodeFixes\VisualBasicCodeFixes.projitems*{0141285d-8f6c-42c7-baf3-3c0ccd61c716}*SharedItemsImports = 5 src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\VisualBasicWorkspaceExtensions.projitems*{0141285d-8f6c-42c7-baf3-3c0ccd61c716}*SharedItemsImports = 5 - src\Compilers\CSharp\CommandLine\CscCommandLine.projitems*{0161e25c-918a-4dc8-9648-30fdcc8e31e9}*SharedItemsImports = 5 + src\Compilers\CSharp\csc\CscCommandLine.projitems*{0161e25c-918a-4dc8-9648-30fdcc8e31e9}*SharedItemsImports = 5 src\Analyzers\VisualBasic\Tests\VisualBasicAnalyzers.UnitTests.projitems*{0be66736-cdaa-4989-88b1-b3f46ebdca4a}*SharedItemsImports = 5 src\Analyzers\Core\CodeFixes\CodeFixes.projitems*{1b6c4a1a-413b-41fb-9f85-5c09118e541b}*SharedItemsImports = 13 src\Compilers\Core\AnalyzerDriver\AnalyzerDriver.projitems*{1ee8cad3-55f9-4d91-96b2-084641da9a6c}*SharedItemsImports = 5 @@ -1495,7 +1495,7 @@ Global src\Analyzers\CSharp\CodeFixes\CSharpCodeFixes.projitems*{3973b09a-4fbf-44a5-8359-3d22ceb71f71}*SharedItemsImports = 5 src\Compilers\CSharp\CSharpAnalyzerDriver\CSharpAnalyzerDriver.projitems*{3973b09a-4fbf-44a5-8359-3d22ceb71f71}*SharedItemsImports = 5 src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CSharpWorkspaceExtensions.projitems*{438db8af-f3f0-4ed9-80b5-13fddd5b8787}*SharedItemsImports = 13 - src\Compilers\CSharp\CommandLine\CscCommandLine.projitems*{4b45ca0c-03a0-400f-b454-3d4bcb16af38}*SharedItemsImports = 5 + src\Compilers\CSharp\csc\CscCommandLine.projitems*{4b45ca0c-03a0-400f-b454-3d4bcb16af38}*SharedItemsImports = 5 src\Analyzers\CSharp\Tests\CSharpAnalyzers.UnitTests.projitems*{5018d049-5870-465a-889b-c742ce1e31cb}*SharedItemsImports = 5 src\Compilers\CSharp\CSharpAnalyzerDriver\CSharpAnalyzerDriver.projitems*{54e08bf5-f819-404f-a18d-0ab9ea81ea04}*SharedItemsImports = 13 src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\VisualBasicCompilerExtensions.projitems*{57ca988d-f010-4bf2-9a2e-07d6dcd2ff2c}*SharedItemsImports = 5 @@ -1513,8 +1513,8 @@ Global src\Analyzers\Core\Analyzers\Analyzers.projitems*{76e96966-4780-4040-8197-bde2879516f4}*SharedItemsImports = 13 src\Analyzers\VisualBasic\Tests\VisualBasicAnalyzers.UnitTests.projitems*{7b7f4153-ae93-4908-b8f0-430871589f83}*SharedItemsImports = 13 src\Analyzers\VisualBasic\Analyzers\VisualBasicAnalyzers.projitems*{94faf461-2e74-4dbb-9813-6b2cde6f1880}*SharedItemsImports = 13 - src\Compilers\Server\CommandLine\VBCSCompilerCommandLine.projitems*{9508f118-f62e-4c16-a6f4-7c3b56e166ad}*SharedItemsImports = 5 - src\Compilers\VisualBasic\CommandLine\VbcCommandLine.projitems*{975cd834-45f4-4ea0-a395-cb60dbd0e214}*SharedItemsImports = 5 + src\Compilers\Server\VBCSCompiler\VBCSCompilerCommandLine.projitems*{9508f118-f62e-4c16-a6f4-7c3b56e166ad}*SharedItemsImports = 5 + src\Compilers\VisualBasic\vbc\VbcCommandLine.projitems*{975cd834-45f4-4ea0-a395-cb60dbd0e214}*SharedItemsImports = 5 src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\WorkspaceExtensions.projitems*{99f594b1-3916-471d-a761-a6731fc50e9a}*SharedItemsImports = 13 src\Analyzers\VisualBasic\CodeFixes\VisualBasicCodeFixes.projitems*{9f9ccc78-7487-4127-9d46-db23e501f001}*SharedItemsImports = 13 src\Analyzers\CSharp\CodeFixes\CSharpCodeFixes.projitems*{a07abcf5-bc43-4ee9-8fd8-b2d77fd54d73}*SharedItemsImports = 5 @@ -1535,9 +1535,9 @@ Global src\Compilers\Core\AnalyzerDriver\AnalyzerDriver.projitems*{d0bc9be7-24f6-40ca-8dc6-fcb93bd44b34}*SharedItemsImports = 13 src\Dependencies\CodeAnalysis.Debugging\Microsoft.CodeAnalysis.Debugging.projitems*{d73adf7d-2c1c-42ae-b2ab-edc9497e4b71}*SharedItemsImports = 13 src\Analyzers\CSharp\CodeFixes\CSharpCodeFixes.projitems*{da973826-c985-4128-9948-0b445e638bdb}*SharedItemsImports = 13 - src\Compilers\Server\CommandLine\VBCSCompilerCommandLine.projitems*{dc8c78cc-b6fe-47bf-93b1-b65a1c67c08d}*SharedItemsImports = 5 + src\Compilers\Server\VBCSCompiler\VBCSCompilerCommandLine.projitems*{dc8c78cc-b6fe-47bf-93b1-b65a1c67c08d}*SharedItemsImports = 5 src\Analyzers\VisualBasic\Tests\VisualBasicAnalyzers.UnitTests.projitems*{e512c6c1-f085-4ad7-b0d9-e8f1a0a2a510}*SharedItemsImports = 5 - src\Compilers\VisualBasic\CommandLine\VbcCommandLine.projitems*{e58ee9d7-1239-4961-a0c1-f9ec3952c4c1}*SharedItemsImports = 5 + src\Compilers\VisualBasic\vbc\VbcCommandLine.projitems*{e58ee9d7-1239-4961-a0c1-f9ec3952c4c1}*SharedItemsImports = 5 src\Compilers\VisualBasic\BasicAnalyzerDriver\BasicAnalyzerDriver.projitems*{e8f0baa5-7327-43d1-9a51-644e81ae55f1}*SharedItemsImports = 13 src\Dependencies\Collections\Microsoft.CodeAnalysis.Collections.projitems*{e919dd77-34f8-4f57-8058-4d3ff4c2b241}*SharedItemsImports = 13 src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\VisualBasicWorkspaceExtensions.projitems*{e9dbfa41-7a9c-49be-bd36-fd71b31aa9fe}*SharedItemsImports = 13 diff --git a/src/EditorFeatures/Core/SpellCheck/Class1.cs b/src/EditorFeatures/Core/SpellCheck/Class1.cs deleted file mode 100644 index ab9014bd864f2..0000000000000 --- a/src/EditorFeatures/Core/SpellCheck/Class1.cs +++ /dev/null @@ -1,21 +0,0 @@ -// 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.Collections.Generic; -using System.Text; -using Microsoft.VisualStudio.Text.SpellChecker; - -namespace Microsoft.CodeAnalysis.SpellCheck -{ - internal class Class1 - { - } - - - internal abstract class AbstractISpellCheckFixerProvider : ISpellCheckFixerProvider - { - - } -} diff --git a/src/EditorFeatures/Core/SpellCheck/RoslynSpellCheckFixerProvider.cs b/src/EditorFeatures/Core/SpellCheck/RoslynSpellCheckFixerProvider.cs new file mode 100644 index 0000000000000..799714a5eaafa --- /dev/null +++ b/src/EditorFeatures/Core/SpellCheck/RoslynSpellCheckFixerProvider.cs @@ -0,0 +1,110 @@ +// 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.ComponentModel.Composition; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.CodeAnalysis.Editor; +using Microsoft.CodeAnalysis.Editor.Shared.Extensions; +using Microsoft.CodeAnalysis.Editor.Shared.Utilities; +using Microsoft.CodeAnalysis.Host.Mef; +using Microsoft.CodeAnalysis.Rename; +using Microsoft.CodeAnalysis.Shared.Extensions; +using Microsoft.CodeAnalysis.Text; +using Microsoft.CodeAnalysis.Text.Shared.Extensions; +using Microsoft.VisualStudio.Text; +using Microsoft.VisualStudio.Text.SpellChecker; +using Microsoft.VisualStudio.Utilities; + +namespace Microsoft.CodeAnalysis.SpellCheck +{ + [Obsolete] + [Export(typeof(ISpellCheckFixerProvider))] + [ContentType(ContentTypeNames.RoslynContentType)] + [Name(nameof(RoslynSpellCheckFixerProvider))] + internal sealed class RoslynSpellCheckFixerProvider : ISpellCheckFixerProvider + { + private readonly IThreadingContext _threadingContext; + + [ImportingConstructor] + [Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] + public RoslynSpellCheckFixerProvider( + IThreadingContext threadingContext) + { + _threadingContext = threadingContext; + } + + public async Task RenameWordAsync( + SnapshotSpan span, + string replacement, + IUIThreadOperationContext operationContext) + { + var cancellationToken = operationContext.UserCancellationToken; + + var success = await TryRenameWordAsync(span, replacement, cancellationToken).ConfigureAwait(false); + if (success) + return; + + // failure path, just apply the text change directly. + await ApplySimpleChangeAsync(span, replacement, cancellationToken).ConfigureAwait(false); + } + + private async Task ApplySimpleChangeAsync(SnapshotSpan span, string replacement, CancellationToken cancellationToken) + { + await _threadingContext.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken); + + var buffer = span.Snapshot.TextBuffer; + var edit = buffer.CreateEdit(); + + edit.Replace(span.TranslateTo(buffer.CurrentSnapshot, SpanTrackingMode.EdgeInclusive), replacement); + edit.Apply(); + } + + private async Task TryRenameWordAsync(SnapshotSpan span, string replacement, CancellationToken cancellationToken) + { + // See if we can map this to a roslyn document. + var snapshot = span.Snapshot; + var document = snapshot.GetOpenDocumentInCurrentContextWithChanges(); + if (document is null) + return false; + + // If so, see if the language supports smart rename capabilities. + var renameService = document.GetLanguageService(); + if (renameService is null) + return false; + + // Attempt to figure out what the language would rename here given the position of the misspelled word in + // the full token. + var info = await renameService.GetRenameInfoAsync(document, span.Span.Start, cancellationToken).ConfigureAwait(false); + if (!info.CanRename) + return false; + + // The subspan we're being asked to rename better fall entirely within the span of the token we're renaming. + var fullTokenSpan = info.TriggerSpan; + var subSpanBeingRenamed = span.Span.ToTextSpan(); + if (!fullTokenSpan.Contains(subSpanBeingRenamed)) + return false; + + // The language gave us the full token span, and we know the subportion to rename, so use all of that to + // form the final full token text to rename to. + var fullTokenReplacementText = + snapshot.GetSpanFromBounds(fullTokenSpan.Start, subSpanBeingRenamed.Start).GetText() + + replacement + + snapshot.GetSpanFromBounds(subSpanBeingRenamed.End, fullTokenSpan.End).GetText(); + + // Now attempt to call into the language to actually perform the rename. + var options = new SymbolRenameOptions(); + var renameLocations = await info.FindRenameLocationsAsync(options, cancellationToken).ConfigureAwait(false); + var replacements = await renameLocations.GetReplacementsAsync(fullTokenReplacementText, options, cancellationToken).ConfigureAwait(false); + if (!replacements.ReplacementTextValid) + return false; + + // Finally, apply the rename to the solution. + await _threadingContext.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken); + var workspace = document.Project.Solution.Workspace; + return workspace.TryApplyChanges(replacements.NewSolution); + } + } +} From 14d46b65c7b5b7ba7954ad4bb4d0bc9ddfbbebba Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Thu, 9 Jun 2022 11:52:17 -0700 Subject: [PATCH 15/35] Fallout --- .../New.IntegrationTests/InProcess/EditorInProcess.cs | 2 ++ .../New.IntegrationTests/InProcess/LightBulbHelper.cs | 2 +- .../IntegrationTest/TestUtilities/InProcess/Editor_InProc.cs | 2 ++ .../IntegrationTest/TestUtilities/LightBulbHelper.cs | 2 +- .../VisualBasic/Impl/LanguageService/VisualBasicPackage.vb | 2 +- 5 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/VisualStudio/IntegrationTest/New.IntegrationTests/InProcess/EditorInProcess.cs b/src/VisualStudio/IntegrationTest/New.IntegrationTests/InProcess/EditorInProcess.cs index fe0bde28be013..1e89a854f73cb 100644 --- a/src/VisualStudio/IntegrationTest/New.IntegrationTests/InProcess/EditorInProcess.cs +++ b/src/VisualStudio/IntegrationTest/New.IntegrationTests/InProcess/EditorInProcess.cs @@ -227,10 +227,12 @@ public async Task GetLightBulbPreviewClassificationsAsync( if (!string.IsNullOrEmpty(menuText)) { +#pragma warning disable CS0618 // Type or member is obsolete if (activeSession.TryGetSuggestedActionSets(out var actionSets) != QuerySuggestedActionCompletionStatus.Completed) { actionSets = Array.Empty(); } +#pragma warning restore CS0618 // Type or member is obsolete var set = actionSets.SelectMany(s => s.Actions).FirstOrDefault(a => a.DisplayText == menuText); if (set == null) diff --git a/src/VisualStudio/IntegrationTest/New.IntegrationTests/InProcess/LightBulbHelper.cs b/src/VisualStudio/IntegrationTest/New.IntegrationTests/InProcess/LightBulbHelper.cs index 3ba8d36fc6935..1c2fc2210c2bf 100644 --- a/src/VisualStudio/IntegrationTest/New.IntegrationTests/InProcess/LightBulbHelper.cs +++ b/src/VisualStudio/IntegrationTest/New.IntegrationTests/InProcess/LightBulbHelper.cs @@ -81,7 +81,7 @@ public static async Task> WaitForItemsAsync(Test // Calling PopulateWithData ensures the underlying session will call SuggestedActionsUpdated at least once // with the latest data computed. This is needed so that if the lightbulb computation is already complete // that we hear about the results. - asyncSession.PopulateWithData(overrideRequestedActionCategories: null, operationContext: null); + await asyncSession.PopulateWithDataAsync(overrideRequestedActionCategories: null, operationContext: null); try { diff --git a/src/VisualStudio/IntegrationTest/TestUtilities/InProcess/Editor_InProc.cs b/src/VisualStudio/IntegrationTest/TestUtilities/InProcess/Editor_InProc.cs index a98e9813e14e4..9e9a34552d09f 100644 --- a/src/VisualStudio/IntegrationTest/TestUtilities/InProcess/Editor_InProc.cs +++ b/src/VisualStudio/IntegrationTest/TestUtilities/InProcess/Editor_InProc.cs @@ -378,10 +378,12 @@ private async Task GetLightbulbPreviewClassificationsAsync( if (!string.IsNullOrEmpty(menuText)) { +#pragma warning disable CS0618 // Type or member is obsolete if (activeSession.TryGetSuggestedActionSets(out var actionSets) != QuerySuggestedActionCompletionStatus.Completed) { actionSets = Array.Empty(); } +#pragma warning restore CS0618 // Type or member is obsolete var set = actionSets.SelectMany(s => s.Actions).FirstOrDefault(a => a.DisplayText == menuText); if (set == null) diff --git a/src/VisualStudio/IntegrationTest/TestUtilities/LightBulbHelper.cs b/src/VisualStudio/IntegrationTest/TestUtilities/LightBulbHelper.cs index 265822c1d045f..7b2c73053b6ab 100644 --- a/src/VisualStudio/IntegrationTest/TestUtilities/LightBulbHelper.cs +++ b/src/VisualStudio/IntegrationTest/TestUtilities/LightBulbHelper.cs @@ -102,7 +102,7 @@ public static async Task> WaitForItemsAsync(ILig // Calling PopulateWithData ensures the underlying session will call SuggestedActionsUpdated at least once // with the latest data computed. This is needed so that if the lightbulb computation is already complete // that we hear about the results. - asyncSession.PopulateWithData(overrideRequestedActionCategories: null, operationContext: null); + await asyncSession.PopulateWithDataAsync(overrideRequestedActionCategories: null, operationContext: null); try { diff --git a/src/VisualStudio/VisualBasic/Impl/LanguageService/VisualBasicPackage.vb b/src/VisualStudio/VisualBasic/Impl/LanguageService/VisualBasicPackage.vb index 7a4b6f8167fdd..3e4828425875a 100644 --- a/src/VisualStudio/VisualBasic/Impl/LanguageService/VisualBasicPackage.vb +++ b/src/VisualStudio/VisualBasic/Impl/LanguageService/VisualBasicPackage.vb @@ -57,7 +57,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.VisualBasic Public Sub New() MyBase.New() - _comAggregate = Interop.ComAggregate.CreateAggregatedObject(Me) + _comAggregate = Implementation.Interop.ComAggregate.CreateAggregatedObject(Me) End Sub Protected Overrides Async Function InitializeAsync(cancellationToken As CancellationToken, progress As IProgress(Of ServiceProgressData)) As Task From a279562cb8618ce2bc6cd65a8e88272021b2c638 Mon Sep 17 00:00:00 2001 From: Gen Lu Date: Thu, 9 Jun 2022 12:09:03 -0700 Subject: [PATCH 16/35] Update src/EditorFeatures/Core/IntelliSense/AsyncCompletion/CompletionSource.cs Co-authored-by: CyrusNajmabadi --- .../Core/IntelliSense/AsyncCompletion/CompletionSource.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/EditorFeatures/Core/IntelliSense/AsyncCompletion/CompletionSource.cs b/src/EditorFeatures/Core/IntelliSense/AsyncCompletion/CompletionSource.cs index 68a79823b9cc6..482ea5ab3e55e 100644 --- a/src/EditorFeatures/Core/IntelliSense/AsyncCompletion/CompletionSource.cs +++ b/src/EditorFeatures/Core/IntelliSense/AsyncCompletion/CompletionSource.cs @@ -442,7 +442,8 @@ public async Task GetExpandedCompletionContextAsync( document, triggerLocation, options, document.Project.Solution.Options, roslynTrigger, _roles, cancellationToken).ConfigureAwait(false); var filterSet = new FilterSet(); - var completionItemList = session.CreateCompletionList(ConvertItems()); + var completionItemList = session.CreateCompletionList( + completionList.ItemsList.Select(i => Convert(document, i, filterSet, triggerLocation, cancellationToken)); var filters = filterSet.GetFilterStatesInSet(); From 794174f79afda7d0866af51803ddf0113564ac28 Mon Sep 17 00:00:00 2001 From: Gen Lu Date: Thu, 9 Jun 2022 12:09:11 -0700 Subject: [PATCH 17/35] Update src/EditorFeatures/Core/IntelliSense/AsyncCompletion/CompletionSource.cs Co-authored-by: CyrusNajmabadi --- .../IntelliSense/AsyncCompletion/CompletionSource.cs | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/EditorFeatures/Core/IntelliSense/AsyncCompletion/CompletionSource.cs b/src/EditorFeatures/Core/IntelliSense/AsyncCompletion/CompletionSource.cs index 482ea5ab3e55e..b3dba910523a2 100644 --- a/src/EditorFeatures/Core/IntelliSense/AsyncCompletion/CompletionSource.cs +++ b/src/EditorFeatures/Core/IntelliSense/AsyncCompletion/CompletionSource.cs @@ -455,15 +455,6 @@ public async Task GetExpandedCompletionContextAsync( completionList.SuggestionModeItem.Properties.TryGetValue(CommonCompletionItem.DescriptionProperty, out var description) ? description : string.Empty); return (new(completionItemList, suggestionItemOptions, selectionHint: AsyncCompletionData.InitialSelectionHint.SoftSelection, filters, isIncomplete: false, null), completionList); - - IEnumerable ConvertItems() - { - foreach (var roslynItem in completionList.ItemsList) - { - cancellationToken.ThrowIfCancellationRequested(); - yield return Convert(document, roslynItem, filterSet, triggerLocation); - } - } } private static void UpdateSessionData(IAsyncCompletionSession session, CompletionSessionData sessionData, CompletionList completionList, SnapshotPoint triggerLocation) From b2008deea7b76e6deb318170d32256eb677e7de7 Mon Sep 17 00:00:00 2001 From: "gel@microsoft.com" Date: Thu, 9 Jun 2022 12:36:01 -0700 Subject: [PATCH 18/35] Address comments --- .../AsyncCompletion/CompletionSource.cs | 8 ++-- .../AsyncCompletion/ItemManager.cs | 42 +++++++++---------- 2 files changed, 26 insertions(+), 24 deletions(-) diff --git a/src/EditorFeatures/Core/IntelliSense/AsyncCompletion/CompletionSource.cs b/src/EditorFeatures/Core/IntelliSense/AsyncCompletion/CompletionSource.cs index b3dba910523a2..3030f47976265 100644 --- a/src/EditorFeatures/Core/IntelliSense/AsyncCompletion/CompletionSource.cs +++ b/src/EditorFeatures/Core/IntelliSense/AsyncCompletion/CompletionSource.cs @@ -443,7 +443,7 @@ public async Task GetExpandedCompletionContextAsync( var filterSet = new FilterSet(); var completionItemList = session.CreateCompletionList( - completionList.ItemsList.Select(i => Convert(document, i, filterSet, triggerLocation, cancellationToken)); + completionList.ItemsList.Select(i => Convert(document, i, filterSet, triggerLocation, cancellationToken))); var filters = filterSet.GetFilterStatesInSet(); @@ -549,10 +549,12 @@ private VSCompletionItem Convert( Document document, RoslynCompletionItem roslynItem, FilterSet filterSet, - SnapshotPoint initialTriggerLocation) + SnapshotPoint initialTriggerLocation, + CancellationToken cancellationToken) { - VSCompletionItemData itemData; + cancellationToken.ThrowIfCancellationRequested(); + VSCompletionItemData itemData; if (roslynItem.Flags.IsCached() && s_roslynItemToVsItemData.TryGetValue(roslynItem, out var boxedItemData)) { itemData = boxedItemData.Value; diff --git a/src/EditorFeatures/Core/IntelliSense/AsyncCompletion/ItemManager.cs b/src/EditorFeatures/Core/IntelliSense/AsyncCompletion/ItemManager.cs index e4b083dd2cde7..9147b3d5274dd 100644 --- a/src/EditorFeatures/Core/IntelliSense/AsyncCompletion/ItemManager.cs +++ b/src/EditorFeatures/Core/IntelliSense/AsyncCompletion/ItemManager.cs @@ -4,7 +4,6 @@ using System.Collections.Generic; using System.Collections.Immutable; -using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Threading; using System.Threading.Tasks; @@ -38,7 +37,7 @@ public Task> SortCompletionListAsync( CancellationToken cancellationToken) { var stopwatch = SharedStopwatch.StartNew(); - var items = SortCompletionitems(session, data).ToImmutableArray(); + var items = SortCompletionitems(session, data, cancellationToken).ToImmutableArray(); AsyncCompletionLogger.LogItemManagerSortTicksDataPoint((int)stopwatch.Elapsed.TotalMilliseconds); return Task.FromResult(items); @@ -50,12 +49,31 @@ public Task> SortCompletionItemListAsync( CancellationToken cancellationToken) { var stopwatch = SharedStopwatch.StartNew(); - var itemList = session.CreateCompletionList(SortCompletionitems(session, data)); + var itemList = session.CreateCompletionList(SortCompletionitems(session, data, cancellationToken)); AsyncCompletionLogger.LogItemManagerSortTicksDataPoint((int)stopwatch.Elapsed.TotalMilliseconds); return Task.FromResult(itemList); } + private static SegmentedList SortCompletionitems(IAsyncCompletionSession session, AsyncCompletionSessionInitialDataSnapshot data, CancellationToken cancellationToken) + { + var sessionData = CompletionSessionData.GetOrCreateSessionData(session); + + // This method is called exactly once, so use the opportunity to set a baseline for telemetry. + if (sessionData.TargetTypeFilterExperimentEnabled) + { + AsyncCompletionLogger.LogSessionHasTargetTypeFilterEnabled(); + if (data.InitialItemList.Any(i => i.Filters.Any(f => f.DisplayText == FeaturesResources.Target_type_matches))) + AsyncCompletionLogger.LogSessionContainsTargetTypeFilter(); + } + + cancellationToken.ThrowIfCancellationRequested(); + var items = new SegmentedList(data.InitialItemList); + items.Sort(VSItemComparer.Instance); + + return items; + } + public async Task UpdateCompletionListAsync( IAsyncCompletionSession session, AsyncCompletionSessionDataSnapshot data, @@ -118,24 +136,6 @@ public Task> SortCompletionItemListAsync( } } - private static SegmentedList SortCompletionitems(IAsyncCompletionSession session, AsyncCompletionSessionInitialDataSnapshot data) - { - var sessionData = CompletionSessionData.GetOrCreateSessionData(session); - - // This method is called exactly once, so use the opportunity to set a baseline for telemetry. - if (sessionData.TargetTypeFilterExperimentEnabled) - { - AsyncCompletionLogger.LogSessionHasTargetTypeFilterEnabled(); - if (data.InitialItemList.Any(i => i.Filters.Any(f => f.DisplayText == FeaturesResources.Target_type_matches))) - AsyncCompletionLogger.LogSessionContainsTargetTypeFilter(); - } - - var items = new SegmentedList(data.InitialItemList); - items.Sort(VSItemComparer.Instance); - - return items; - } - private sealed class VSItemComparer : IComparer { public static VSItemComparer Instance { get; } = new(); From c6af434d3c56f756362d340ec963c8b675cd131b Mon Sep 17 00:00:00 2001 From: "gel@microsoft.com" Date: Thu, 9 Jun 2022 14:23:16 -0700 Subject: [PATCH 19/35] Surpress obsolete warnings --- .../InProcess/EditorInProcess.cs | 8 +++++++- .../TestUtilities/InProcess/Editor_InProc.cs | 12 ++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/VisualStudio/IntegrationTest/New.IntegrationTests/InProcess/EditorInProcess.cs b/src/VisualStudio/IntegrationTest/New.IntegrationTests/InProcess/EditorInProcess.cs index ee37900389172..1e89a854f73cb 100644 --- a/src/VisualStudio/IntegrationTest/New.IntegrationTests/InProcess/EditorInProcess.cs +++ b/src/VisualStudio/IntegrationTest/New.IntegrationTests/InProcess/EditorInProcess.cs @@ -227,7 +227,13 @@ public async Task GetLightBulbPreviewClassificationsAsync( if (!string.IsNullOrEmpty(menuText)) { - var actionSets = await LightBulbHelper.WaitForItemsAsync(TestServices, broker, view, cancellationToken).ConfigureAwait(false); +#pragma warning disable CS0618 // Type or member is obsolete + if (activeSession.TryGetSuggestedActionSets(out var actionSets) != QuerySuggestedActionCompletionStatus.Completed) + { + actionSets = Array.Empty(); + } +#pragma warning restore CS0618 // Type or member is obsolete + var set = actionSets.SelectMany(s => s.Actions).FirstOrDefault(a => a.DisplayText == menuText); if (set == null) { diff --git a/src/VisualStudio/IntegrationTest/TestUtilities/InProcess/Editor_InProc.cs b/src/VisualStudio/IntegrationTest/TestUtilities/InProcess/Editor_InProc.cs index cb21ab8b14ddb..9e9a34552d09f 100644 --- a/src/VisualStudio/IntegrationTest/TestUtilities/InProcess/Editor_InProc.cs +++ b/src/VisualStudio/IntegrationTest/TestUtilities/InProcess/Editor_InProc.cs @@ -362,8 +362,10 @@ private async Task GetLightbulbPreviewClassificationsAsync( IWpfTextView view, IViewClassifierAggregatorService viewClassifierAggregator) { + await LightBulbHelper.WaitForLightBulbSessionAsync(broker, view).ConfigureAwait(true); + var bufferType = view.TextBuffer.ContentType.DisplayName; - if (!await LightBulbHelper.WaitForLightBulbSessionAsync(broker, view).ConfigureAwait(true)) + if (!broker.IsLightBulbSessionActive(view)) { throw new Exception(string.Format("No Active Smart Tags in View! Buffer content type={0}", bufferType)); } @@ -376,7 +378,13 @@ private async Task GetLightbulbPreviewClassificationsAsync( if (!string.IsNullOrEmpty(menuText)) { - var actionSets = await LightBulbHelper.WaitForItemsAsync(broker, view).ConfigureAwait(false); +#pragma warning disable CS0618 // Type or member is obsolete + if (activeSession.TryGetSuggestedActionSets(out var actionSets) != QuerySuggestedActionCompletionStatus.Completed) + { + actionSets = Array.Empty(); + } +#pragma warning restore CS0618 // Type or member is obsolete + var set = actionSets.SelectMany(s => s.Actions).FirstOrDefault(a => a.DisplayText == menuText); if (set == null) { From 2032a135be06ad2c908ea48b51bbaea8b698a843 Mon Sep 17 00:00:00 2001 From: "Gen Lu (HE/HIM)" Date: Thu, 9 Jun 2022 14:43:32 -0700 Subject: [PATCH 20/35] Fix --- eng/Versions.props | 2 +- .../Core.Cocoa/Preview/PreviewPane.cs | 31 +++++++++---------- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/eng/Versions.props b/eng/Versions.props index dff3371f40310..ecfa3ceaeb497 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -28,7 +28,7 @@ 17.3.122-preview - 17.3.68-preview + $(VisualStudioEditorPackagesVersion) 5.0.0-alpha1.19409.1 5.0.0-preview.1.20112.8 17.3.2062-preview diff --git a/src/EditorFeatures/Core.Cocoa/Preview/PreviewPane.cs b/src/EditorFeatures/Core.Cocoa/Preview/PreviewPane.cs index 43beaa7f46636..310dc50111ba5 100644 --- a/src/EditorFeatures/Core.Cocoa/Preview/PreviewPane.cs +++ b/src/EditorFeatures/Core.Cocoa/Preview/PreviewPane.cs @@ -4,7 +4,6 @@ using System; using System.Collections.Generic; -using System.Runtime.InteropServices; using AppKit; using Foundation; using ObjCRuntime; @@ -32,7 +31,7 @@ public PreviewPane(string? id, string? title, Uri? helpLink, string? helpLinkToo var titlePlaceholder = new NSStackView() { Orientation = NSUserInterfaceLayoutOrientation.Vertical, - EdgeInsets = new NSEdgeInsets(new NFloat(5), new NFloat(0), new(value: 5), new NFloat(0)), + EdgeInsets = new NSEdgeInsets(5, 0, 5, 0), Alignment = NSLayoutAttribute.Leading, TranslatesAutoresizingMaskIntoConstraints = false }; @@ -52,8 +51,8 @@ public PreviewPane(string? id, string? title, Uri? helpLink, string? helpLinkToo // === Preview View === // This is the actual view, that shows the diff view.TranslatesAutoresizingMaskIntoConstraints = false; - NSLayoutConstraint.Create(view, NSLayoutAttribute.Width, NSLayoutRelation.GreaterThanOrEqual, new NFloat(1), originalSize.Width).Active = true; - NSLayoutConstraint.Create(view, NSLayoutAttribute.Height, NSLayoutRelation.GreaterThanOrEqual, new NFloat(1), originalSize.Height).Active = true; + NSLayoutConstraint.Create(view, NSLayoutAttribute.Width, NSLayoutRelation.GreaterThanOrEqual, 1, originalSize.Width).Active = true; + NSLayoutConstraint.Create(view, NSLayoutAttribute.Height, NSLayoutRelation.GreaterThanOrEqual, 1, originalSize.Height).Active = true; view.Subviews[0].TranslatesAutoresizingMaskIntoConstraints = false; view.WantsLayer = true; @@ -63,20 +62,20 @@ public PreviewPane(string? id, string? title, Uri? helpLink, string? helpLinkToo var constraints = new NSLayoutConstraint[] { // Title - NSLayoutConstraint.Create(titlePlaceholder, NSLayoutAttribute.Top, NSLayoutRelation.Equal, this, NSLayoutAttribute.Top, new NFloat(1), new NFloat(0)), - NSLayoutConstraint.Create(titlePlaceholder, NSLayoutAttribute.Leading, NSLayoutRelation.Equal, this, NSLayoutAttribute.Leading, new NFloat(1), new NFloat(0)), - NSLayoutConstraint.Create(titlePlaceholder, NSLayoutAttribute.Trailing, NSLayoutRelation.Equal, this, NSLayoutAttribute.Trailing, new NFloat(1), new NFloat(0)), + NSLayoutConstraint.Create(titlePlaceholder, NSLayoutAttribute.Top, NSLayoutRelation.Equal, this, NSLayoutAttribute.Top, 1, 0), + NSLayoutConstraint.Create(titlePlaceholder, NSLayoutAttribute.Leading, NSLayoutRelation.Equal, this, NSLayoutAttribute.Leading, 1, 0), + NSLayoutConstraint.Create(titlePlaceholder, NSLayoutAttribute.Trailing, NSLayoutRelation.Equal, this, NSLayoutAttribute.Trailing, 1, 0), // Preview View - NSLayoutConstraint.Create(view, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, this, NSLayoutAttribute.Bottom, new NFloat(1), new NFloat(0)), - NSLayoutConstraint.Create(view, NSLayoutAttribute.Leading, NSLayoutRelation.Equal, this, NSLayoutAttribute.Leading, new NFloat(1), new NFloat(0)), - NSLayoutConstraint.Create(view, NSLayoutAttribute.Trailing, NSLayoutRelation.Equal, this, NSLayoutAttribute.Trailing, new NFloat(1), new NFloat(0)), + NSLayoutConstraint.Create(view, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, this, NSLayoutAttribute.Bottom, 1, 0), + NSLayoutConstraint.Create(view, NSLayoutAttribute.Leading, NSLayoutRelation.Equal, this, NSLayoutAttribute.Leading, 1, 0), + NSLayoutConstraint.Create(view, NSLayoutAttribute.Trailing, NSLayoutRelation.Equal, this, NSLayoutAttribute.Trailing, 1, 0), // subviews - NSLayoutConstraint.Create(view.Subviews[0], NSLayoutAttribute.Top, NSLayoutRelation.Equal, view, NSLayoutAttribute.Top, new NFloat(1), new NFloat(0)), - NSLayoutConstraint.Create(view.Subviews[0], NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, view, NSLayoutAttribute.Bottom, new NFloat(1), new NFloat(0)), - NSLayoutConstraint.Create(view.Subviews[0], NSLayoutAttribute.Left, NSLayoutRelation.Equal, view, NSLayoutAttribute.Left, new NFloat(1), new NFloat(0)), - NSLayoutConstraint.Create(view.Subviews[0], NSLayoutAttribute.Right, NSLayoutRelation.Equal, view, NSLayoutAttribute.Right, new NFloat(1), new NFloat(0)), + NSLayoutConstraint.Create(view.Subviews[0], NSLayoutAttribute.Top, NSLayoutRelation.Equal, view, NSLayoutAttribute.Top, 1, 0), + NSLayoutConstraint.Create(view.Subviews[0], NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, view, NSLayoutAttribute.Bottom, 1, 0), + NSLayoutConstraint.Create(view.Subviews[0], NSLayoutAttribute.Left, NSLayoutRelation.Equal, view, NSLayoutAttribute.Left, 1, 0), + NSLayoutConstraint.Create(view.Subviews[0], NSLayoutAttribute.Right, NSLayoutRelation.Equal, view, NSLayoutAttribute.Right, 1, 0), }; if (GenerateAttributeString(id, title, helpLink, helpLinkToolTipText) is NSAttributedString attributedStringTitle) @@ -84,11 +83,11 @@ public PreviewPane(string? id, string? title, Uri? helpLink, string? helpLinkToo this.titleField.AttributedStringValue = attributedStringTitle; // We do this separately, because the title sometimes isn't there (i.e. no diagnostics ID) // and we want the preview to stretch to the top - NSLayoutConstraint.Create(view, NSLayoutAttribute.Top, NSLayoutRelation.Equal, titlePlaceholder, NSLayoutAttribute.Bottom, new NFloat(1), new NFloat(0)).Active = true; + NSLayoutConstraint.Create(view, NSLayoutAttribute.Top, NSLayoutRelation.Equal, titlePlaceholder, NSLayoutAttribute.Bottom, 1, 0).Active = true; } else { - NSLayoutConstraint.Create(view, NSLayoutAttribute.Top, NSLayoutRelation.Equal, this, NSLayoutAttribute.Top, new NFloat(1), new NFloat(0)).Active = true; + NSLayoutConstraint.Create(view, NSLayoutAttribute.Top, NSLayoutRelation.Equal, this, NSLayoutAttribute.Top, 1, 0).Active = true; } NSLayoutConstraint.ActivateConstraints(constraints); From 2ae84624c058984f6dbec7cf7334f0b7dd479d73 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Thu, 9 Jun 2022 19:25:10 -0700 Subject: [PATCH 21/35] Versions --- src/VisualStudio/Core/Test/DebuggerIntelliSense/TestState.vb | 2 +- .../ProjectSystemShim/Framework/TestEnvironment.vb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/VisualStudio/Core/Test/DebuggerIntelliSense/TestState.vb b/src/VisualStudio/Core/Test/DebuggerIntelliSense/TestState.vb index cc2d03142f1e0..340705dcd8b7d 100644 --- a/src/VisualStudio/Core/Test/DebuggerIntelliSense/TestState.vb +++ b/src/VisualStudio/Core/Test/DebuggerIntelliSense/TestState.vb @@ -40,7 +40,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.DebuggerIntelliSense Dim spanDocument = Workspace.Documents.First(Function(x) x.SelectedSpans.Any()) Dim statementSpan = spanDocument.SelectedSpans.First() - Dim span = New Interop.TextSpan() {statementSpan.ToSnapshotSpan(spanDocument.GetTextBuffer().CurrentSnapshot).ToVsTextSpan()} + Dim span = New TextManager.Interop.TextSpan() {statementSpan.ToSnapshotSpan(spanDocument.GetTextBuffer().CurrentSnapshot).ToVsTextSpan()} Dim componentModel = New MockComponentModel(Workspace.ExportProvider) diff --git a/src/VisualStudio/TestUtilities2/ProjectSystemShim/Framework/TestEnvironment.vb b/src/VisualStudio/TestUtilities2/ProjectSystemShim/Framework/TestEnvironment.vb index 8cae746e36b85..89bede4b5d7c8 100644 --- a/src/VisualStudio/TestUtilities2/ProjectSystemShim/Framework/TestEnvironment.vb +++ b/src/VisualStudio/TestUtilities2/ProjectSystemShim/Framework/TestEnvironment.vb @@ -78,7 +78,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.ProjectSystemShim.Fr ExportProvider = composition.ExportProviderFactory.CreateExportProvider() _workspace = ExportProvider.GetExportedValue(Of VisualStudioWorkspaceImpl) ThreadingContext = ExportProvider.GetExportedValue(Of IThreadingContext)() - Interop.WrapperPolicy.s_ComWrapperFactory = MockComWrapperFactory.Instance + Implementation.Interop.WrapperPolicy.s_ComWrapperFactory = MockComWrapperFactory.Instance Dim mockServiceProvider As MockServiceProvider = ExportProvider.GetExportedValue(Of MockServiceProvider)() mockServiceProvider.MockMonitorSelection = New MockShellMonitorSelection(True) From a083b0a4501d87b4a9fc3fa57bfbed3c195e0eee Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Fri, 10 Jun 2022 10:14:23 -0700 Subject: [PATCH 22/35] Obsolete --- .../TestUtilities2/Intellisense/MockCompletionPresenter.vb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/EditorFeatures/TestUtilities2/Intellisense/MockCompletionPresenter.vb b/src/EditorFeatures/TestUtilities2/Intellisense/MockCompletionPresenter.vb index f9fabb85fff68..cadef8bb5544f 100644 --- a/src/EditorFeatures/TestUtilities2/Intellisense/MockCompletionPresenter.vb +++ b/src/EditorFeatures/TestUtilities2/Intellisense/MockCompletionPresenter.vb @@ -43,11 +43,11 @@ Namespace Microsoft.CodeAnalysis.Editor.UnitTests.IntelliSense Private Sub DoUpdate(presentation As CompletionPresentationViewModel) _filters = presentation.Filters - _presentedItems = presentation.Items + _presentedItems = presentation.ItemList.ToImmutableArray() If presentation.SelectSuggestionItem Then ProgrammaticallySelectItem(presentation.SuggestionItem, True) - ElseIf Not presentation.Items.IsDefaultOrEmpty Then - ProgrammaticallySelectItem(presentation.Items(presentation.SelectedItemIndex).CompletionItem, False) + ElseIf Not _presentedItems.IsDefaultOrEmpty Then + ProgrammaticallySelectItem(_presentedItems(presentation.SelectedItemIndex).CompletionItem, False) Else ProgrammaticallySelectItem(Nothing, False) End If From b4f40fd9c533a957984eca8005391ab21edfc926 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Fri, 10 Jun 2022 10:44:18 -0700 Subject: [PATCH 23/35] Simplify --- .../Core/SpellCheck/RoslynSpellCheckFixerProvider.cs | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/EditorFeatures/Core/SpellCheck/RoslynSpellCheckFixerProvider.cs b/src/EditorFeatures/Core/SpellCheck/RoslynSpellCheckFixerProvider.cs index 799714a5eaafa..aca17aa1a7cef 100644 --- a/src/EditorFeatures/Core/SpellCheck/RoslynSpellCheckFixerProvider.cs +++ b/src/EditorFeatures/Core/SpellCheck/RoslynSpellCheckFixerProvider.cs @@ -87,17 +87,10 @@ private async Task TryRenameWordAsync(SnapshotSpan span, string replacemen if (!fullTokenSpan.Contains(subSpanBeingRenamed)) return false; - // The language gave us the full token span, and we know the subportion to rename, so use all of that to - // form the final full token text to rename to. - var fullTokenReplacementText = - snapshot.GetSpanFromBounds(fullTokenSpan.Start, subSpanBeingRenamed.Start).GetText() + - replacement + - snapshot.GetSpanFromBounds(subSpanBeingRenamed.End, fullTokenSpan.End).GetText(); - // Now attempt to call into the language to actually perform the rename. var options = new SymbolRenameOptions(); var renameLocations = await info.FindRenameLocationsAsync(options, cancellationToken).ConfigureAwait(false); - var replacements = await renameLocations.GetReplacementsAsync(fullTokenReplacementText, options, cancellationToken).ConfigureAwait(false); + var replacements = await renameLocations.GetReplacementsAsync(replacement, options, cancellationToken).ConfigureAwait(false); if (!replacements.ReplacementTextValid) return false; From ad591eafc916bdf91e3c173047c6df63f5eb63a3 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Fri, 10 Jun 2022 11:13:02 -0700 Subject: [PATCH 24/35] Add telemetry --- .../RoslynSpellCheckFixerProvider.cs | 30 ++++++++++++------- .../Compiler/Core/Log/FunctionId.cs | 7 +++++ 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/src/EditorFeatures/Core/SpellCheck/RoslynSpellCheckFixerProvider.cs b/src/EditorFeatures/Core/SpellCheck/RoslynSpellCheckFixerProvider.cs index aca17aa1a7cef..cf45c5d63f8f9 100644 --- a/src/EditorFeatures/Core/SpellCheck/RoslynSpellCheckFixerProvider.cs +++ b/src/EditorFeatures/Core/SpellCheck/RoslynSpellCheckFixerProvider.cs @@ -10,6 +10,7 @@ using Microsoft.CodeAnalysis.Editor.Shared.Extensions; using Microsoft.CodeAnalysis.Editor.Shared.Utilities; using Microsoft.CodeAnalysis.Host.Mef; +using Microsoft.CodeAnalysis.Internal.Log; using Microsoft.CodeAnalysis.Rename; using Microsoft.CodeAnalysis.Shared.Extensions; using Microsoft.CodeAnalysis.Text; @@ -43,11 +44,17 @@ public async Task RenameWordAsync( { var cancellationToken = operationContext.UserCancellationToken; - var success = await TryRenameWordAsync(span, replacement, cancellationToken).ConfigureAwait(false); - if (success) + var result = await TryRenameAsync(span, replacement, cancellationToken).ConfigureAwait(false); + + // If we succeeded at renaming then nothing more to do. + if (result == null) return; - // failure path, just apply the text change directly. + // Record why we failed so we can determine what issues may be arising in the wild. + var (functionId, message) = result.Value; + Logger.Log(functionId, message); + + // Then just apply the text change directly. await ApplySimpleChangeAsync(span, replacement, cancellationToken).ConfigureAwait(false); } @@ -62,42 +69,45 @@ private async Task ApplySimpleChangeAsync(SnapshotSpan span, string replacement, edit.Apply(); } - private async Task TryRenameWordAsync(SnapshotSpan span, string replacement, CancellationToken cancellationToken) + private async Task<(FunctionId functionId, string? message)?> TryRenameAsync(SnapshotSpan span, string replacement, CancellationToken cancellationToken) { // See if we can map this to a roslyn document. var snapshot = span.Snapshot; var document = snapshot.GetOpenDocumentInCurrentContextWithChanges(); if (document is null) - return false; + return (FunctionId.SpellCheckFixer_CouldNotFindDocument, null); // If so, see if the language supports smart rename capabilities. var renameService = document.GetLanguageService(); if (renameService is null) - return false; + return (FunctionId.SpellCheckFixer_LanguageDoesNotSupportRename, null); // Attempt to figure out what the language would rename here given the position of the misspelled word in // the full token. var info = await renameService.GetRenameInfoAsync(document, span.Span.Start, cancellationToken).ConfigureAwait(false); if (!info.CanRename) - return false; + return (FunctionId.SpellCheckFixer_LanguageCouldNotGetRenameInfo, null); // The subspan we're being asked to rename better fall entirely within the span of the token we're renaming. var fullTokenSpan = info.TriggerSpan; var subSpanBeingRenamed = span.Span.ToTextSpan(); if (!fullTokenSpan.Contains(subSpanBeingRenamed)) - return false; + return (FunctionId.SpellCheckFixer_RenameSpanNotWithinTokenSpan, null); // Now attempt to call into the language to actually perform the rename. var options = new SymbolRenameOptions(); var renameLocations = await info.FindRenameLocationsAsync(options, cancellationToken).ConfigureAwait(false); var replacements = await renameLocations.GetReplacementsAsync(replacement, options, cancellationToken).ConfigureAwait(false); if (!replacements.ReplacementTextValid) - return false; + return (FunctionId.SpellCheckFixer_ReplacementTextInvalid, $"Renaming: '{span.GetText()}' to '{replacement}'"); // Finally, apply the rename to the solution. await _threadingContext.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken); var workspace = document.Project.Solution.Workspace; - return workspace.TryApplyChanges(replacements.NewSolution); + if (!workspace.TryApplyChanges(replacements.NewSolution)) + return (FunctionId.SpellCheckFixer_TryApplyChangesFailure, null); + + return null; } } } diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Log/FunctionId.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Log/FunctionId.cs index b488968f7bbe9..8a7dc7ca223bc 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Log/FunctionId.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Log/FunctionId.cs @@ -548,5 +548,12 @@ internal enum FunctionId Refactoring_FixAllOccurrencesPreviewChanges = 563, LSP_UsedForkedSolution = 571, + + SpellCheckFixer_CouldNotFindDocument = 580, + SpellCheckFixer_LanguageDoesNotSupportRename = 581, + SpellCheckFixer_LanguageCouldNotGetRenameInfo = 582, + SpellCheckFixer_RenameSpanNotWithinTokenSpan = 583, + SpellCheckFixer_CouldNotFindDocument = 580, + SpellCheckFixer_CouldNotFindDocument = 580, } } From 64919c4d35d0909a6029ce5b48bdd65cb5537a93 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Fri, 10 Jun 2022 11:13:11 -0700 Subject: [PATCH 25/35] Add telemetry --- .../Compiler/Core/Log/FunctionId.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Log/FunctionId.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Log/FunctionId.cs index 8a7dc7ca223bc..0c556ff8d88c3 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Log/FunctionId.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Log/FunctionId.cs @@ -553,7 +553,7 @@ internal enum FunctionId SpellCheckFixer_LanguageDoesNotSupportRename = 581, SpellCheckFixer_LanguageCouldNotGetRenameInfo = 582, SpellCheckFixer_RenameSpanNotWithinTokenSpan = 583, - SpellCheckFixer_CouldNotFindDocument = 580, - SpellCheckFixer_CouldNotFindDocument = 580, + SpellCheckFixer_ReplacementTextInvalid = 584, + SpellCheckFixer_TryApplyChangesFailure = 585, } } From f367f011afbdd8d5548866fadcac56695d563b70 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Fri, 10 Jun 2022 11:37:19 -0700 Subject: [PATCH 26/35] add tests --- .../SpellCheckFixerProviderTests.cs | 81 +++++++++++++++++++ .../RoslynSpellCheckFixerProvider.cs | 40 ++++++--- .../AbstractSpellCheckFixerProviderTests.cs | 59 ++++++++++++++ .../SpellCheck/AbstractSpellCheckSpanTests.cs | 1 + 4 files changed, 172 insertions(+), 9 deletions(-) create mode 100644 src/EditorFeatures/CSharpTest/SpellCheck/SpellCheckFixerProviderTests.cs create mode 100644 src/EditorFeatures/TestUtilities/SpellCheck/AbstractSpellCheckFixerProviderTests.cs diff --git a/src/EditorFeatures/CSharpTest/SpellCheck/SpellCheckFixerProviderTests.cs b/src/EditorFeatures/CSharpTest/SpellCheck/SpellCheckFixerProviderTests.cs new file mode 100644 index 0000000000000..ccc3a031eb978 --- /dev/null +++ b/src/EditorFeatures/CSharpTest/SpellCheck/SpellCheckFixerProviderTests.cs @@ -0,0 +1,81 @@ +// 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.Threading.Tasks; +using Microsoft.CodeAnalysis.Editor.UnitTests.SpellCheck; +using Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces; +using Microsoft.CodeAnalysis.Test.Utilities; +using Roslyn.Test.Utilities; + +namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.SpellCheck +{ + [UseExportProvider] + public class SpellCheckFixerProviderTests : AbstractSpellCheckFixerProviderTests + { + protected override TestWorkspace CreateWorkspace(string content) + => TestWorkspace.CreateCSharp(content); + + [WpfFact] + public async Task TestRenameClassName() + { + await TestSuccessAsync( + """ + class {|CorrectlySpelled:CrrectlySpelled|} + { + public CrrectlySpelled() { } + } + """, + """ + class CorrectlySpelled + { + public CorrectlySpelled() { } + } + """); + } + + [WpfFact] + public async Task TestBogusLocation() + { + // Should not be called inside a string. But we should still apply the change. + await TestFailureAsync( + """ + class C + { + void M() + { + var v1 = "{|word:wrd|}"; + var v2 = "wrd"; + } + } + """, + """ + class C + { + void M() + { + var v1 = "word"; + var v2 = "wrd"; + } + } + """); + } + + [WpfFact] + public async Task TestReplacementThatLanguageDoesNotSupport() + { + // Should not be called inside a string. But we should still apply the change. + await TestFailureAsync( + """ + class {|Bo()gus:Orginal|} + { + } + """, + """ + class Bo()gus + { + } + """); + } + } +} diff --git a/src/EditorFeatures/Core/SpellCheck/RoslynSpellCheckFixerProvider.cs b/src/EditorFeatures/Core/SpellCheck/RoslynSpellCheckFixerProvider.cs index cf45c5d63f8f9..9fbc76a128c15 100644 --- a/src/EditorFeatures/Core/SpellCheck/RoslynSpellCheckFixerProvider.cs +++ b/src/EditorFeatures/Core/SpellCheck/RoslynSpellCheckFixerProvider.cs @@ -14,7 +14,6 @@ using Microsoft.CodeAnalysis.Rename; using Microsoft.CodeAnalysis.Shared.Extensions; using Microsoft.CodeAnalysis.Text; -using Microsoft.CodeAnalysis.Text.Shared.Extensions; using Microsoft.VisualStudio.Text; using Microsoft.VisualStudio.Text.SpellChecker; using Microsoft.VisualStudio.Utilities; @@ -37,25 +36,34 @@ public RoslynSpellCheckFixerProvider( _threadingContext = threadingContext; } - public async Task RenameWordAsync( + public Task RenameWordAsync( SnapshotSpan span, string replacement, IUIThreadOperationContext operationContext) { var cancellationToken = operationContext.UserCancellationToken; + return RenameWordAsync(span, replacement, cancellationToken); + } + private async Task<(FunctionId functionId, string? message)?> RenameWordAsync( + SnapshotSpan span, + string replacement, + CancellationToken cancellationToken) + { var result = await TryRenameAsync(span, replacement, cancellationToken).ConfigureAwait(false); // If we succeeded at renaming then nothing more to do. - if (result == null) - return; + if (result != null) + { + // Record why we failed so we can determine what issues may be arising in the wild. + var (functionId, message) = result.Value; + Logger.Log(functionId, message); - // Record why we failed so we can determine what issues may be arising in the wild. - var (functionId, message) = result.Value; - Logger.Log(functionId, message); + // Then just apply the text change directly. + await ApplySimpleChangeAsync(span, replacement, cancellationToken).ConfigureAwait(false); + } - // Then just apply the text change directly. - await ApplySimpleChangeAsync(span, replacement, cancellationToken).ConfigureAwait(false); + return result; } private async Task ApplySimpleChangeAsync(SnapshotSpan span, string replacement, CancellationToken cancellationToken) @@ -109,5 +117,19 @@ private async Task ApplySimpleChangeAsync(SnapshotSpan span, string replacement, return null; } + + public TestAccessor GetTestAccessor() + => new(this); + + public readonly struct TestAccessor + { + private readonly RoslynSpellCheckFixerProvider _provider; + + public TestAccessor(RoslynSpellCheckFixerProvider provider) + => _provider = provider; + + public Task<(FunctionId functionId, string? message)?> TryRenameAsync(SnapshotSpan span, string replacement, CancellationToken cancellationToken) + => _provider.RenameWordAsync(span, replacement, cancellationToken); + } } } diff --git a/src/EditorFeatures/TestUtilities/SpellCheck/AbstractSpellCheckFixerProviderTests.cs b/src/EditorFeatures/TestUtilities/SpellCheck/AbstractSpellCheckFixerProviderTests.cs new file mode 100644 index 0000000000000..c2ff7a09b23c7 --- /dev/null +++ b/src/EditorFeatures/TestUtilities/SpellCheck/AbstractSpellCheckFixerProviderTests.cs @@ -0,0 +1,59 @@ +// 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.Linq; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.CodeAnalysis.Editor.Shared.Utilities; +using Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces; +using Microsoft.CodeAnalysis.SpellCheck; +using Microsoft.CodeAnalysis.Text.Shared.Extensions; +using Microsoft.VisualStudio.Text.SpellChecker; +using Roslyn.Test.Utilities; +using Roslyn.Utilities; +using Xunit; + +namespace Microsoft.CodeAnalysis.Editor.UnitTests.SpellCheck +{ + public abstract class AbstractSpellCheckFixerProviderTests + { + protected abstract TestWorkspace CreateWorkspace(string content); + +#pragma warning disable CS0612 // Type or member is obsolete +#pragma warning disable CS0618 // Type or member is obsolete + + protected Task TestSuccessAsync(string content, string expected) + => TestAsync(content, expected, expectFailure: false); + + protected Task TestFailureAsync(string content, string expected) + => TestAsync(content, expected, expectFailure: true); + + private async Task TestAsync(string content, string expected, bool expectFailure) + { + using var workspace = CreateWorkspace(content); + + var threadingContext = workspace.ExportProvider.GetExportedValue(); + + var document = workspace.Documents.Single(); + var service = (RoslynSpellCheckFixerProvider)workspace.ExportProvider.GetExportedValue(); + + var buffer = document.GetTextBuffer(); + var (replacement, span) = document.AnnotatedSpans.Single(); + var result = await service.GetTestAccessor().TryRenameAsync(buffer.CurrentSnapshot.GetSpan(span.Single().ToSpan()), replacement, CancellationToken.None); + + if (expectFailure) + { + Assert.NotNull(result); + } + else + { + Assert.Null(result); + } + + AssertEx.Equal(expected, buffer.CurrentSnapshot.GetText()); + } +#pragma warning restore CS0612 // Type or member is obsolete +#pragma warning restore CS0618 // Type or member is obsolete + } +} diff --git a/src/EditorFeatures/TestUtilities/SpellCheck/AbstractSpellCheckSpanTests.cs b/src/EditorFeatures/TestUtilities/SpellCheck/AbstractSpellCheckSpanTests.cs index 4494852a7fcc2..0c8d296d4e0fb 100644 --- a/src/EditorFeatures/TestUtilities/SpellCheck/AbstractSpellCheckSpanTests.cs +++ b/src/EditorFeatures/TestUtilities/SpellCheck/AbstractSpellCheckSpanTests.cs @@ -16,6 +16,7 @@ namespace Microsoft.CodeAnalysis.Editor.UnitTests.SpellCheck { + public abstract class AbstractSpellCheckSpanTests { protected abstract TestWorkspace CreateWorkspace(string content); From e6c206d1477336b97031c6a41aa18dfce4f9026d Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Fri, 10 Jun 2022 11:39:38 -0700 Subject: [PATCH 27/35] Add tests --- .../SpellCheckFixerProviderTests.cs | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/EditorFeatures/CSharpTest/SpellCheck/SpellCheckFixerProviderTests.cs b/src/EditorFeatures/CSharpTest/SpellCheck/SpellCheckFixerProviderTests.cs index ccc3a031eb978..41d02511731ee 100644 --- a/src/EditorFeatures/CSharpTest/SpellCheck/SpellCheckFixerProviderTests.cs +++ b/src/EditorFeatures/CSharpTest/SpellCheck/SpellCheckFixerProviderTests.cs @@ -69,11 +69,32 @@ await TestFailureAsync( """ class {|Bo()gus:Orginal|} { + public Orginal() { } } """, """ class Bo()gus { + public Orginal() { } + } + """); + } + + [WpfFact] + public async Task TestReplacementSpanLargerThanToken() + { + // Replacement span is larger than the lang token to rename. + await TestFailureAsync( + """ + class {|Replacement:Class |} + { + public Class() { } + } + """, + """ + class Replacement + { + public Class() { } } """); } From d78949dfbe8f2cc3bf1c6e7c3a30989f2897e9f0 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Fri, 10 Jun 2022 11:45:15 -0700 Subject: [PATCH 28/35] Fix test --- .../CSharpTest/SpellCheck/SpellCheckFixerProviderTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/EditorFeatures/CSharpTest/SpellCheck/SpellCheckFixerProviderTests.cs b/src/EditorFeatures/CSharpTest/SpellCheck/SpellCheckFixerProviderTests.cs index 41d02511731ee..4eb0fd12deb4e 100644 --- a/src/EditorFeatures/CSharpTest/SpellCheck/SpellCheckFixerProviderTests.cs +++ b/src/EditorFeatures/CSharpTest/SpellCheck/SpellCheckFixerProviderTests.cs @@ -92,7 +92,7 @@ public Class() { } } """, """ - class Replacement + class Replacement { public Class() { } } From 441bd9c45ed2cc667f34e883bd8b0d6327ec2f29 Mon Sep 17 00:00:00 2001 From: CyrusNajmabadi Date: Mon, 13 Jun 2022 12:17:59 -0700 Subject: [PATCH 29/35] Update src/EditorFeatures/TestUtilities2/Microsoft.CodeAnalysis.EditorFeatures.Test.Utilities2.vbproj --- ...rosoft.CodeAnalysis.EditorFeatures.Test.Utilities2.vbproj | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/EditorFeatures/TestUtilities2/Microsoft.CodeAnalysis.EditorFeatures.Test.Utilities2.vbproj b/src/EditorFeatures/TestUtilities2/Microsoft.CodeAnalysis.EditorFeatures.Test.Utilities2.vbproj index 9d7ea741079af..1bc8c32416f9b 100644 --- a/src/EditorFeatures/TestUtilities2/Microsoft.CodeAnalysis.EditorFeatures.Test.Utilities2.vbproj +++ b/src/EditorFeatures/TestUtilities2/Microsoft.CodeAnalysis.EditorFeatures.Test.Utilities2.vbproj @@ -8,11 +8,6 @@ false - - - - - From 1ee15272e4cd09259ba5e5b657ac9281e5748e80 Mon Sep 17 00:00:00 2001 From: "Gen Lu (HE/HIM)" Date: Tue, 14 Jun 2022 11:42:57 -0700 Subject: [PATCH 30/35] Fix merge conflict --- .../Core/IntelliSense/AsyncCompletion/ItemManager.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/EditorFeatures/Core/IntelliSense/AsyncCompletion/ItemManager.cs b/src/EditorFeatures/Core/IntelliSense/AsyncCompletion/ItemManager.cs index 86f4f3dad6f18..c0f9325d8622f 100644 --- a/src/EditorFeatures/Core/IntelliSense/AsyncCompletion/ItemManager.cs +++ b/src/EditorFeatures/Core/IntelliSense/AsyncCompletion/ItemManager.cs @@ -39,7 +39,7 @@ public Task> SortCompletionListAsync( var stopwatch = SharedStopwatch.StartNew(); var items = SortCompletionitems(data, cancellationToken).ToImmutableArray(); - AsyncCompletionLogger.LogItemManagerSortTicksDataPoint((int)stopwatch.Elapsed.TotalMilliseconds); + AsyncCompletionLogger.LogItemManagerSortTicksDataPoint(stopwatch.Elapsed); return Task.FromResult(items); } @@ -51,7 +51,7 @@ public Task> SortCompletionItemListAsync( var stopwatch = SharedStopwatch.StartNew(); var itemList = session.CreateCompletionList(SortCompletionitems(data, cancellationToken)); - AsyncCompletionLogger.LogItemManagerSortTicksDataPoint((int)stopwatch.Elapsed.TotalMilliseconds); + AsyncCompletionLogger.LogItemManagerSortTicksDataPoint(stopwatch.Elapsed); return Task.FromResult(itemList); } From 94fad1b9bf7257a7de75ceb3b53515327a0bbb5c Mon Sep 17 00:00:00 2001 From: Rikki Gibson Date: Tue, 5 Jul 2022 08:04:15 -0700 Subject: [PATCH 31/35] Update StructuredLoggerCheckerUtil.cs --- src/Tools/BuildBoss/StructuredLoggerCheckerUtil.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Tools/BuildBoss/StructuredLoggerCheckerUtil.cs b/src/Tools/BuildBoss/StructuredLoggerCheckerUtil.cs index 7ceecc61c4baa..99743646eac0d 100644 --- a/src/Tools/BuildBoss/StructuredLoggerCheckerUtil.cs +++ b/src/Tools/BuildBoss/StructuredLoggerCheckerUtil.cs @@ -36,6 +36,12 @@ public bool Check(TextWriter textWriter) { foreach (var doubleWrite in doubleWrites) { + // Issue https://github.com/dotnet/roslyn/issues/62372 + if (Path.GetFileName(doubleWrite.Key) == "Microsoft.VisualStudio.Text.Internal.dll") + { + continue; + } + textWriter.WriteLine($"Multiple writes to {doubleWrite.Key}"); foreach (var source in doubleWrite.Value) { From d5a3eac107cae781d58d14b7060448bee676d591 Mon Sep 17 00:00:00 2001 From: Rikki Gibson Date: Tue, 5 Jul 2022 09:36:30 -0700 Subject: [PATCH 32/35] Update StructuredLoggerCheckerUtil.cs --- src/Tools/BuildBoss/StructuredLoggerCheckerUtil.cs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/Tools/BuildBoss/StructuredLoggerCheckerUtil.cs b/src/Tools/BuildBoss/StructuredLoggerCheckerUtil.cs index 99743646eac0d..75cd4941b9343 100644 --- a/src/Tools/BuildBoss/StructuredLoggerCheckerUtil.cs +++ b/src/Tools/BuildBoss/StructuredLoggerCheckerUtil.cs @@ -32,16 +32,12 @@ public bool Check(TextWriter textWriter) { var build = Serialization.Read(_logFilePath); var doubleWrites = DoubleWritesAnalyzer.GetDoubleWrites(build).ToArray(); - if (doubleWrites.Any()) + + // Issue https://github.com/dotnet/roslyn/issues/62372 + if (doubleWrites.Any(doubleWrite => Path.GetFileName(doubleWrite.Key) != "Microsoft.VisualStudio.Text.Internal.dll")) { foreach (var doubleWrite in doubleWrites) { - // Issue https://github.com/dotnet/roslyn/issues/62372 - if (Path.GetFileName(doubleWrite.Key) == "Microsoft.VisualStudio.Text.Internal.dll") - { - continue; - } - textWriter.WriteLine($"Multiple writes to {doubleWrite.Key}"); foreach (var source in doubleWrite.Value) { From 2afffab389b716ead996a267ae53794d4c67f662 Mon Sep 17 00:00:00 2001 From: "Gen Lu (HE/HIM)" Date: Wed, 6 Jul 2022 11:50:08 -0700 Subject: [PATCH 33/35] Update to new ServiceHub host names --- eng/Versions.props | 2 +- eng/targets/GenerateServiceHubConfigurationFiles.targets | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/eng/Versions.props b/eng/Versions.props index 346bfebb5811c..e6063527ff13d 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -41,7 +41,7 @@ the generators we build would load on the command line but not load in IDEs. --> 3.8.0 7.0.0-alpha.1.22060.1 - 3.1.4097 + 4.0.117 17.2.32