-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #65675 from dibarbet/remove_bogus_assert
[LSP] Find refs - Remove bogus assert and add test
- Loading branch information
Showing
8 changed files
with
89 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
...ures/LanguageServer/ProtocolUnitTests/References/FindAllReferencesHandlerFeaturesTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// 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.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Microsoft.CodeAnalysis.Editor.Test; | ||
using Microsoft.CodeAnalysis.Editor.UnitTests; | ||
using Microsoft.CodeAnalysis.Test.Utilities; | ||
using Roslyn.Test.Utilities; | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; | ||
|
||
namespace Microsoft.CodeAnalysis.LanguageServer.UnitTests.References; | ||
public class FindAllReferencesHandlerFeaturesTests : AbstractLanguageServerProtocolTests | ||
{ | ||
public FindAllReferencesHandlerFeaturesTests(ITestOutputHelper? testOutputHelper) : base(testOutputHelper) | ||
{ | ||
} | ||
|
||
protected override TestComposition Composition => EditorTestCompositions.LanguageServerProtocol | ||
.AddParts(typeof(TestDocumentTrackingService)) | ||
.AddParts(typeof(TestWorkspaceRegistrationService)); | ||
|
||
[Fact] | ||
public async Task TestFindAllReferencesAsync_DoesNotUseVSTypes() | ||
{ | ||
var markup = | ||
@"class A | ||
{ | ||
public int {|reference:someInt|} = 1; | ||
void M() | ||
{ | ||
var i = {|reference:someInt|} + 1; | ||
} | ||
} | ||
class B | ||
{ | ||
int someInt = A.{|reference:someInt|} + 1; | ||
void M2() | ||
{ | ||
var j = someInt + A.{|caret:|}{|reference:someInt|}; | ||
} | ||
}"; | ||
await using var testLspServer = await CreateTestLspServerAsync(markup, new LSP.ClientCapabilities()); | ||
|
||
var results = await FindAllReferencesHandlerTests.RunFindAllReferencesAsync<LSP.Location>(testLspServer, testLspServer.GetLocations("caret").First()); | ||
AssertLocationsEqual(testLspServer.GetLocations("reference"), results.Select(result => result)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters