Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Semantic Snippets - Remove reflection and call the LanguageServerSnippetExpander directly #61491

Conversation

akhera99
Copy link
Member

Needed to update the FoldingRangeTests to account for changes from FoldingRangeKind being an enum to being a struct.

Need to remove the TestRoslynLanguageServerSnippetExpander as well as the RoslynLSPSnippetExpander files as they are no longer necessary.

@akhera99 akhera99 marked this pull request as ready for review May 24, 2022 19:47
@akhera99 akhera99 requested review from a team as code owners May 24, 2022 19:47
davidwengier
davidwengier previously approved these changes May 24, 2022
Comment on lines 156 to 157
<MicrosoftVisualStudioLanguageServerClientVersion>17.3.2062-preview</MicrosoftVisualStudioLanguageServerClientVersion>
<MicrosoftVisualStudioLanguageServerClientImplementationVersion>17.3.2062-preview</MicrosoftVisualStudioLanguageServerClientImplementationVersion>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Can we define a new variable MicrosoftVisualStudioLanguageServerClientPackagesVersion to cover both of these?

if (SnippetCompletionItem.IsSnippet(roslynItem))
{
var lspSnippetText = change.Properties[SnippetCompletionItem.LSPSnippetKey];

_roslynLSPSnippetExpander.Expand(change.TextChange.Span, lspSnippetText, _textView, triggerSnapshot);
if (!_languageServerSnippetExpander.TryExpand(lspSnippetText!, triggerSnapshotSpan, _textView))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 I think I'd rather have Contract.ThrowIfNull(lspSnippetText) on the previous line

Comment on lines 12 to 13
<!-- CA1416 can go away when we target net6.0-macos -->
<NoWarn>$(NoWarn);NU1701;</NoWarn>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❗ This is covered by suppressions on the specific PackageReference lines, and not here (transitive dependencies which trigger this can be explicitly included with their own NoWarn attributes)

Copy link
Member Author

@akhera99 akhera99 May 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a NoWarn on here:
<PackageReference Include="Microsoft.VisualStudio.LanguageServer.Client.Implementation" Version="$(MicrosoftVisualStudioLanguageServerClientImplementationVersion)" PrivateAssets="all" NoWarn="NU1701" />

I was still getting issues because the packages seemingly had implicit dependencies.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to deal with similar in #61234 and can help update this.

@@ -39,6 +42,7 @@
<PackageReference Include="Microsoft.VisualStudio.Language" Version="$(MicrosoftVisualStudioLanguageVersion)" />
<!-- No warn on NU1701 until the LSP client targets netstandard2.0 https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1369985/ -->
<PackageReference Include="Microsoft.VisualStudio.LanguageServer.Client" Version="$(MicrosoftVisualStudioLanguageServerClientVersion)" PrivateAssets="all" NoWarn="NU1701" />
<PackageReference Include="Microsoft.VisualStudio.LanguageServer.Client.Implementation" Version="$(MicrosoftVisualStudioLanguageServerClientImplementationVersion)" PrivateAssets="all" NoWarn="NU1701" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❔ What API are we using from this, and why can't it be relocated to the WPF assembly?

Copy link
Member Author

@akhera99 akhera99 May 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the LanguageServerSnippetExpander, we need to use the TryExpand method. We are specifically calling it in the CommitManager, so not sure if it can be relocated to the WPF assembly?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, this code will probably also eventually be needed in VS Mac.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think moving to EditorFeatures.WPF makes sense, even if we have to mirror the change in EditorFeatures.Cocoa (and ideally that would be done at the same time), as it prevents someone else from later adding some new usage of a Windows-only aspect of the implementation assembly without realizing it.

@@ -13,6 +13,19 @@ Namespace Microsoft.CodeAnalysis.LanguageServerIndexFormat.Generator.UnitTests
Public NotInheritable Class FoldingRangeTests
Private Const TestProjectAssemblyName As String = "TestProject"

' Expected 'FoldingRangeKind' argument would likely change for some of the tests when
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😕 Is this intended to be part of this change?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#61496

This was discussed here, it's already been changed in a PR David made. I'm waiting for the above PR to go in prior to fixing this one up.

@akhera99 akhera99 requested review from a team as code owners May 25, 2022 23:23
@akhera99 akhera99 changed the base branch from features/semantic-snippets to main May 26, 2022 01:52
@akhera99 akhera99 changed the base branch from main to features/semantic-snippets May 26, 2022 01:53
@jmarolf jmarolf self-assigned this May 26, 2022
@akhera99 akhera99 force-pushed the features/snippets_remove_reflection branch 4 times, most recently from d55b83b to fb46e1d Compare May 26, 2022 18:16
@sharwell sharwell force-pushed the features/snippets_remove_reflection branch from fb46e1d to b61c0dd Compare May 26, 2022 18:25
@akhera99 akhera99 changed the base branch from features/semantic-snippets to main May 26, 2022 20:24
@akhera99 akhera99 changed the base branch from main to features/semantic-snippets May 26, 2022 20:24
@JoeRobich
Copy link
Member

The failing MacOS test has previously been reported as flaky - #61474

@@ -39,7 +38,7 @@ internal sealed class CommitManager : IAsyncCompletionCommitManager
private readonly ITextView _textView;
private readonly IGlobalOptionService _globalOptions;
private readonly IThreadingContext _threadingContext;
private readonly RoslynLSPSnippetExpander _roslynLSPSnippetExpander;
private readonly ILanguageServerSnippetExpander? _languageServerSnippetExpander;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this nullable? won't this always be imported successfully if the VS version is new enough?

Copy link
Member

@sharwell sharwell May 31, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it is exported by a higher layer (EditorFeatures is WPF+Cocoa, but this is only exported for WPF). It will likely become required in a future change to move this implementation down to a cross-platform layer.

<!-- No warn on NU1701 until the LSP client targets netstandard2.0 https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1369985/ -->
<PackageReference Include="Microsoft.VisualStudio.LanguageServer.Client" Version="$(MicrosoftVisualStudioLanguageServerClientVersion)" PrivateAssets="all" NoWarn="NU1701" />
<!-- Explicit reference to Shell.15.0 et. al. with NU1701 only until the LSP client targets netstandard2.0 https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1369985/ -->
<PackageReference Include="Microsoft.VisualStudio.Shell.15.0" Version="$(MicrosoftVisualStudioShell150Version)" PrivateAssets="all" ExcludeAssets="all" NoWarn="NU1701" />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

u love to see it!

Copy link
Contributor

@jmarolf jmarolf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@akhera99 akhera99 merged commit 83d3426 into dotnet:features/semantic-snippets Jun 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants