Skip to content

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

Merged
akhera99 merged 10 commits intodotnet:features/semantic-snippetsfrom
akhera99:features/snippets_remove_reflection
Jun 1, 2022
Merged

Semantic Snippets - Remove reflection and call the LanguageServerSnippetExpander directly#61491
akhera99 merged 10 commits intodotnet:features/semantic-snippetsfrom
akhera99:features/snippets_remove_reflection

Conversation

@akhera99
Copy link
Copy Markdown
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.

@ghost ghost added the Area-IDE label May 24, 2022
@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
Copy Markdown
Contributor

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?

var lspSnippetText = change.Properties[SnippetCompletionItem.LSPSnippetKey];

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

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
Copy Markdown
Contributor

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
Copy Markdown
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
Copy Markdown
Contributor

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.

<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
Copy Markdown
Contributor

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
Copy Markdown
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
Copy Markdown
Contributor

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
Copy Markdown
Member

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.

Public NotInheritable Class FoldingRangeTests
Private Const TestProjectAssemblyName As String = "TestProject"

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

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
Copy Markdown
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 requested a review from a team May 25, 2022 23:23
@akhera99 akhera99 requested a review from a team as a code owner 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
Copy Markdown
Member

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

@akhera99 akhera99 requested review from davidwengier and sharwell May 31, 2022 23:54
private readonly IGlobalOptionService _globalOptions;
private readonly IThreadingContext _threadingContext;
private readonly RoslynLSPSnippetExpander _roslynLSPSnippetExpander;
private readonly ILanguageServerSnippetExpander? _languageServerSnippetExpander;
Copy link
Copy Markdown
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
Copy Markdown
Contributor

@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
Copy Markdown
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
Copy Markdown
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