Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 20 additions & 20 deletions eng/Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<_BasicReferenceAssembliesVersion>1.8.3</_BasicReferenceAssembliesVersion>
<!-- CodeStyleAnalyzerVersion should we updated together with version of dotnet-format in dotnet-tools.json -->
<CodeStyleAnalyzerVersion>4.8.0-3.final</CodeStyleAnalyzerVersion>
<VisualStudioEditorPackagesVersion>18.0.332-preview</VisualStudioEditorPackagesVersion>
<VisualStudioEditorPackagesVersion>18.0.404-preview</VisualStudioEditorPackagesVersion>
<ILAsmPackageVersion>9.0.0-rc.2.24462.10</ILAsmPackageVersion>
<ILDAsmPackageVersion>6.0.0-rtm.21518.12</ILDAsmPackageVersion>
<MicrosoftILVerificationVersion>7.0.0-alpha.1.22060.1</MicrosoftILVerificationVersion>
Expand Down Expand Up @@ -60,7 +60,7 @@
<!--
Visual Studio
-->
<PackageVersion Include="Microsoft.VisualStudio.SDK" Version="18.0.2101-preview.1" />
<PackageVersion Include="Microsoft.VisualStudio.SDK" Version="18.0.2188-preview.1" />
<PackageVersion Include="Microsoft.Internal.VisualStudio.Shell.Framework" Version="18.0.1211-preview.1" />
<PackageVersion Include="Microsoft.ServiceHub.Client" Version="4.6.3200" />
<PackageVersion Include="Microsoft.VisualStudio.Extensibility.Sdk" Version="18.0.52-preview1" />
Expand All @@ -78,7 +78,7 @@
<PackageVersion Include="Microsoft.VisualStudio.InteractiveWindow" Version="4.0.0" />
<PackageVersion Include="Microsoft.VisualStudio.VsInteractiveWindow" Version="4.0.0" />
<PackageVersion Include="Microsoft.VisualStudio.Search" Version="17.14.39337" />
<PackageVersion Include="Microsoft.VisualStudio.Shell.Styles" Version="18.0.2101-preview.1" />
<PackageVersion Include="Microsoft.VisualStudio.Shell.Styles" Version="18.0.2188-preview.1" />
<PackageVersion Include="Microsoft.VisualStudio.WinForms.Interfaces" Version="17.0.0-previews-4-31709-430" />
<PackageVersion Include="Microsoft.VisualStudio.Workspace.VSIntegration" Version="17.9.29-preview-0001" />
<PackageVersion Include="Microsoft.VisualStudio.Copilot.Roslyn.SemanticSearch" Version="18.0.634-alpha" />
Expand All @@ -94,33 +94,33 @@
Subset of Microsoft.VisualStudio.Sdk meta-package (run `csi generate-vssdk-versions.csx` to update based on VSSDK meta-package).
See https://github.com/dotnet/arcade/blob/main/Documentation/MirroringPackages.md if any of these packages fail to restore.
-->
<PackageVersion Include="Microsoft.ServiceHub.Framework" Version="4.9.11-beta" />
<PackageVersion Include="Microsoft.ServiceHub.Framework" Version="4.9.14-beta" />
<PackageVersion Include="Microsoft.VisualStudio.Composition" Version="17.13.50" />
<PackageVersion Include="Microsoft.VisualStudio.Composition.Analyzers" Version="17.13.50" />
<PackageVersion Include="Microsoft.VisualStudio.CoreUtility" Version="18.0.332-preview" />
<PackageVersion Include="Microsoft.VisualStudio.Editor" Version="18.0.332-preview" />
<PackageVersion Include="Microsoft.VisualStudio.ImageCatalog" Version="18.0.2101-preview.1" />
<PackageVersion Include="Microsoft.VisualStudio.Imaging" Version="18.0.2101-preview.1" />
<PackageVersion Include="Microsoft.VisualStudio.Imaging.Interop.14.0.DesignTime" Version="18.0.2077-preview.1" />
<PackageVersion Include="Microsoft.VisualStudio.Language" Version="18.0.332-preview" />
<PackageVersion Include="Microsoft.VisualStudio.Language.NavigateTo.Interfaces" Version="18.0.332-preview" />
<PackageVersion Include="Microsoft.VisualStudio.Language.StandardClassification" Version="18.0.332-preview" />
<PackageVersion Include="Microsoft.VisualStudio.CoreUtility" Version="$(VisualStudioEditorPackagesVersion)" />
<PackageVersion Include="Microsoft.VisualStudio.Editor" Version="$(VisualStudioEditorPackagesVersion)" />
<PackageVersion Include="Microsoft.VisualStudio.ImageCatalog" Version="18.0.2188-preview.1" />
<PackageVersion Include="Microsoft.VisualStudio.Imaging" Version="18.0.2188-preview.1" />
<PackageVersion Include="Microsoft.VisualStudio.Imaging.Interop.14.0.DesignTime" Version="18.0.2154-preview.1" />
<PackageVersion Include="Microsoft.VisualStudio.Language" Version="$(VisualStudioEditorPackagesVersion)" />
<PackageVersion Include="Microsoft.VisualStudio.Language.NavigateTo.Interfaces" Version="$(VisualStudioEditorPackagesVersion)" />
<PackageVersion Include="Microsoft.VisualStudio.Language.StandardClassification" Version="$(VisualStudioEditorPackagesVersion)" />
<PackageVersion Include="Microsoft.VisualStudio.LanguageServer.Client" Version="18.0.14-preview" />
<PackageVersion Include="Microsoft.VisualStudio.RemoteControl" Version="16.3.52" />
<PackageVersion Include="Microsoft.VisualStudio.RpcContracts" Version="17.15.25-pre" />
<PackageVersion Include="Microsoft.VisualStudio.Shell.15.0" Version="18.0.2101-preview.1" />
<PackageVersion Include="Microsoft.VisualStudio.Shell.15.0" Version="18.0.2188-preview.1" />
<PackageVersion Include="Microsoft.VisualStudio.Telemetry" Version="18.0.22" />
<PackageVersion Include="Microsoft.VisualStudio.Text.Data" Version="18.0.332-preview" />
<PackageVersion Include="Microsoft.VisualStudio.Text.Logic" Version="18.0.332-preview" />
<PackageVersion Include="Microsoft.VisualStudio.Text.UI" Version="18.0.332-preview" />
<PackageVersion Include="Microsoft.VisualStudio.Text.UI.Wpf" Version="18.0.332-preview" />
<PackageVersion Include="Microsoft.VisualStudio.Threading" Version="17.15.20-alpha" />
<PackageVersion Include="Microsoft.VisualStudio.Text.Data" Version="$(VisualStudioEditorPackagesVersion)" />
<PackageVersion Include="Microsoft.VisualStudio.Text.Logic" Version="$(VisualStudioEditorPackagesVersion)" />
<PackageVersion Include="Microsoft.VisualStudio.Text.UI" Version="$(VisualStudioEditorPackagesVersion)" />
<PackageVersion Include="Microsoft.VisualStudio.Text.UI.Wpf" Version="$(VisualStudioEditorPackagesVersion)" />
<PackageVersion Include="Microsoft.VisualStudio.Threading" Version="17.15.22-alpha" />
<PackageVersion Include="Microsoft.VisualStudio.Threading.Analyzers" Version="17.15.20-alpha" />
<PackageVersion Include="Microsoft.VisualStudio.Utilities" Version="18.0.2101-preview.1" />
<PackageVersion Include="Microsoft.VisualStudio.Utilities" Version="18.0.2188-preview.1" />
<PackageVersion Include="Microsoft.VisualStudio.Utilities.Internal" Version="16.3.90" />
<PackageVersion Include="Nerdbank.Streams" Version="2.12.87" />
<PackageVersion Include="Newtonsoft.Json" Version="13.0.3" />
<PackageVersion Include="StreamJsonRpc" Version="2.23.39-alpha" />
<PackageVersion Include="StreamJsonRpc" Version="2.23.41-alpha" />
<PackageVersion Include="MessagePack" Version="2.5.198" />

<!--
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@
using Microsoft.CodeAnalysis.Editor.Shared.Utilities;
using Microsoft.CodeAnalysis.Host.Mef;
using Microsoft.CodeAnalysis.Shared.TestHooks;
using Microsoft.VisualStudio.Language.Suggestions;
using Microsoft.VisualStudio.Text;
using Microsoft.VisualStudio.Text.Adornments;
using Microsoft.VisualStudio.Text.Editor;
using Microsoft.VisualStudio.Threading;

namespace Microsoft.CodeAnalysis.Editor.CSharp.EventHookup;

Expand All @@ -25,12 +27,15 @@ namespace Microsoft.CodeAnalysis.Editor.CSharp.EventHookup;
[method: Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
internal sealed partial class EventHookupSessionManager(
IThreadingContext threadingContext,
IToolTipService toolTipService)
IToolTipService toolTipService,
Lazy<SuggestionServiceBase> suggestionServiceBase)
{
public readonly IThreadingContext ThreadingContext = threadingContext;
private readonly IToolTipService _toolTipService = toolTipService;
internal readonly Lazy<SuggestionServiceBase> SuggestionServiceBase = suggestionServiceBase;

private IToolTipPresenter _toolTipPresenter;
private VisualStudio.Threading.IAsyncDisposable _suggestionBlocker;

internal EventHookupSession CurrentSession
{
Expand Down Expand Up @@ -58,6 +63,9 @@ public async Task EventHookupFoundInSessionAsync(
if (cancellationToken.IsCancellationRequested)
return;

// Now that we've switched to the UI thread, the rest of the work is not cancellable. We're about to be making
// mutations, and we don't want to stop somewhere in the middle of that.
cancellationToken = default;
var caretPoint = analyzedSession.TextView.GetCaretPoint(analyzedSession.SubjectBuffer);

// only generate tooltip if it is not already shown (_toolTipPresenter == null)
Expand Down Expand Up @@ -93,6 +101,16 @@ public async Task EventHookupFoundInSessionAsync(

analyzedSession.TextView.Caret.PositionChanged += Caret_PositionChanged;
CurrentSession.Dismissed += () => { analyzedSession.TextView.Caret.PositionChanged -= Caret_PositionChanged; };

// Dismiss and suppress gray text proposals for the duration of the event hookup session. Note we pass
// CancellationToken.None here as we don't actually want to cancel this operation, since we've already
// made UI changes/hookup that we now have to go through. We are technically safe, as we've cleared
// out cancellationToken above, but this is an extra level safety.
//
// Also, 'ConfigureAwait(true)' on everything here as we want to stay on the UI thread.
_suggestionBlocker?.DisposeAsync().ConfigureAwait(true);
_suggestionBlocker = await SuggestionServiceBase.Value.DismissAndBlockProposalsAsync(
analyzedSession.TextView, ReasonForDismiss.DismissedAfterBufferChange, CancellationToken.None).ConfigureAwait(true);
}
}

Expand Down Expand Up @@ -137,6 +155,8 @@ public void DismissExistingSessions()

_toolTipPresenter?.Dismiss();
_toolTipPresenter = null;
_suggestionBlocker?.DisposeAsync().Forget();
_suggestionBlocker = null;

CurrentSession = null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,26 @@ void M()
testState.AssertShowing("C_MyEvent");
}

[WpfFact]
public async Task Handler_DismissSuggestionService()
{
var markup = """
class C
{
event System.Action MyEvent;
void M()
{
MyEvent +$$
}
}
""";
using var testState = EventHookupTestState.CreateTestState(markup);
testState.SendTypeChar('=');
await testState.WaitForAsynchronousOperationsAsync();
testState.AssertShowing("C_MyEvent");
testState.AssertSuggestionServiceWasDismissed();
}

[WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/20999")]
public async Task HandlerName_EventInThisClass_CamelCaseRule()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
using Microsoft.CodeAnalysis.Options;
using Microsoft.CodeAnalysis.Shared.TestHooks;
using Microsoft.CodeAnalysis.Test.Utilities;
using Microsoft.VisualStudio.Language.Suggestions;
using Roslyn.Utilities;
using Xunit;

Expand All @@ -23,7 +24,8 @@ internal sealed class EventHookupTestState : AbstractCommandHandlerTestState
{
private static readonly TestComposition s_composition = EditorTestCompositions.EditorFeatures.AddParts(
typeof(EventHookupCommandHandler),
typeof(EventHookupSessionManager));
typeof(EventHookupSessionManager),
typeof(MockSuggestionService));

private readonly EventHookupCommandHandler _commandHandler;
private readonly Mutex _testSessionHookupMutex;
Expand Down Expand Up @@ -89,6 +91,12 @@ internal void AssertCodeIs(string expectedCode)
Assert.Equal(expectedCode, TextView.TextSnapshot.GetText());
}

internal void AssertSuggestionServiceWasDismissed()
{
var service = (MockSuggestionService)Workspace.GetService<SuggestionServiceBase>();
Assert.True(service.WasDismissAndBlockCalled);
}

public void SendTypeChar(char ch)
{
SendTypeChar(ch, _commandHandler.ExecuteCommand, () => EditorOperations.InsertText(ch.ToString()));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// 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.Composition;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Host.Mef;
using Microsoft.VisualStudio.Language.Suggestions;
using Microsoft.VisualStudio.Text.Editor;
using Microsoft.VisualStudio.Threading;
using IAsyncDisposable = Microsoft.VisualStudio.Threading.IAsyncDisposable;

namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.EventHookup;

[Export(typeof(SuggestionServiceBase)), Shared]
[method: ImportingConstructor]
[method: Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
internal sealed class MockSuggestionService() : SuggestionServiceBase
{
public bool WasDismissAndBlockCalled { get; private set; }

public override Task<IAsyncDisposable> DismissAndBlockProposalsAsync(ITextView textView, ReasonForDismiss reason, CancellationToken cancellationToken)
{
WasDismissAndBlockCalled = true;
return Task.FromResult<IAsyncDisposable>(new AsyncDisposableStub());
}

public override Task<SuggestionManagerBase?> TryRegisterProviderAsync(SuggestionProviderBase provider, ITextView view, string name, CancellationToken cancel)
{
throw new NotImplementedException();
}

private sealed class AsyncDisposableStub : IAsyncDisposable
{
Task IAsyncDisposable.DisposeAsync() => Task.CompletedTask;
}
}
Loading