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.
💡 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)) |
There was a problem hiding this comment.
💡 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.
❗ 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.
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.
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" /> |
There was a problem hiding this comment.
❔ 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.
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.
Unfortunately, this code will probably also eventually be needed in VS Mac.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
😕 Is this intended to be part of this change?
There was a problem hiding this comment.
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 |
| private readonly IGlobalOptionService _globalOptions; | ||
| private readonly IThreadingContext _threadingContext; | ||
| private readonly RoslynLSPSnippetExpander _roslynLSPSnippetExpander; | ||
| private readonly ILanguageServerSnippetExpander? _languageServerSnippetExpander; |
There was a problem hiding this comment.
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.
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" /> |
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.