-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Semantic Snippets - Remove reflection and call the LanguageServerSnippetExpander directly #61491
Conversation
src/EditorFeatures/Core/Microsoft.CodeAnalysis.EditorFeatures.csproj
Outdated
Show resolved
Hide resolved
eng/Versions.props
Outdated
<MicrosoftVisualStudioLanguageServerClientVersion>17.3.2062-preview</MicrosoftVisualStudioLanguageServerClientVersion> | ||
<MicrosoftVisualStudioLanguageServerClientImplementationVersion>17.3.2062-preview</MicrosoftVisualStudioLanguageServerClientImplementationVersion> |
There was a problem hiding this comment.
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)) |
There was a problem hiding this comment.
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
<!-- CA1416 can go away when we target net6.0-macos --> | ||
<NoWarn>$(NoWarn);NU1701;</NoWarn> |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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" /> |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
d55b83b
to
fb46e1d
Compare
…r via the EditorFeatures layer
fb46e1d
to
b61c0dd
Compare
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; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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" /> |
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.