Skip to content

Commit 9b4eade

Browse files
committed
updated to omnisharp 0.19.2
1 parent 73e9b16 commit 9b4eade

40 files changed

+524
-402
lines changed

.github/workflows/build.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,15 @@ jobs:
6767
run: dotnet pack --configuration ${{ matrix.configuration }}
6868

6969
- name: Test
70-
run: dotnet test --configuration ${{ matrix.configuration }} --collect:"XPlat Code Coverage" --settings ./.github/workflows/codecov.runsettings
70+
run: dotnet test --configuration ${{ matrix.configuration }} --logger trx --blame --collect:"XPlat Code Coverage" --settings ./.github/workflows/codecov.runsettings --results-directory ./TestResults/
71+
72+
- name: Upload Test Results
73+
uses: actions/upload-artifact@v2
74+
if: ${{ always() }}
75+
with:
76+
name: Bicep.TestResults.${{ matrix.rid }}
77+
path: ./TestResults/**/*.trx
78+
if-no-files-found: error
7179

7280
- name: Publish Language Server
7381
if: ${{ matrix.publishLanguageServer == 'true' }}

src/Bicep.LangServer.IntegrationTests/Bicep.LangServer.IntegrationTests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<PackageReference Include="Moq" Version="4.16.1" />
1313
<PackageReference Include="MSTest.TestAdapter" Version="2.2.3" />
1414
<PackageReference Include="MSTest.TestFramework" Version="2.2.3" />
15-
<PackageReference Include="OmniSharp.Extensions.LanguageClient" Version="0.18.3" />
15+
<PackageReference Include="OmniSharp.Extensions.LanguageClient" Version="0.19.2" />
1616
<PackageReference Include="coverlet.collector" Version="3.0.3">
1717
<PrivateAssets>all</PrivateAssets>
1818
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>

src/Bicep.LangServer.IntegrationTests/CodeActionTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public class CodeActionTests
3030
public async Task RequestingCodeActionWithFixableDiagnosticsShouldProduceQuickFixes(DataSet dataSet)
3131
{
3232
var uri = DocumentUri.From($"/{dataSet.Name}");
33-
var client = await IntegrationTestHelper.StartServerWithTextAsync(dataSet.Bicep, uri);
33+
var client = await IntegrationTestHelper.StartServerWithTextAsync(this.TestContext, dataSet.Bicep, uri);
3434

3535
// construct a parallel compilation
3636
var compilation = dataSet.CopyFilesAndCreateCompilation(TestContext, out _);

src/Bicep.LangServer.IntegrationTests/CompletionTests.cs

Lines changed: 99 additions & 89 deletions
Large diffs are not rendered by default.

src/Bicep.LangServer.IntegrationTests/DefinitionTests.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
using FluentAssertions;
1717
using FluentAssertions.Execution;
1818
using Microsoft.VisualStudio.TestTools.UnitTesting;
19+
using OmniSharp.Extensions.LanguageServer.Client;
1920
using OmniSharp.Extensions.LanguageServer.Protocol;
2021
using OmniSharp.Extensions.LanguageServer.Protocol.Document;
2122
using OmniSharp.Extensions.LanguageServer.Protocol.Models;
@@ -36,7 +37,7 @@ public async Task GoToDefinitionRequestOnValidSymbolReferenceShouldReturnLocatio
3637
{
3738
var uri = DocumentUri.From($"/{dataSet.Name}");
3839

39-
using var client = await IntegrationTestHelper.StartServerWithTextAsync(dataSet.Bicep, uri);
40+
using var client = await IntegrationTestHelper.StartServerWithTextAsync(this.TestContext, dataSet.Bicep, uri);
4041
var compilation = dataSet.CopyFilesAndCreateCompilation(TestContext, out _);
4142
var symbolTable = compilation.ReconstructSymbolTable();
4243
var lineStarts = compilation.SyntaxTreeGrouping.EntryPoint.LineStarts;
@@ -78,7 +79,7 @@ public async Task GoToDefinitionRequestOnUnsupportedOrInvalidSyntaxNodeShouldRet
7879
{
7980
var uri = DocumentUri.From($"/{dataSet.Name}");
8081

81-
using var client = await IntegrationTestHelper.StartServerWithTextAsync(dataSet.Bicep, uri);
82+
using var client = await IntegrationTestHelper.StartServerWithTextAsync(this.TestContext, dataSet.Bicep, uri);
8283
var compilation = dataSet.CopyFilesAndCreateCompilation(TestContext, out _);
8384
var symbolTable = compilation.ReconstructSymbolTable();
8485
var lineStarts = compilation.SyntaxTreeGrouping.EntryPoint.LineStarts;
@@ -111,7 +112,7 @@ public async Task GoToDefinitionOnUnboundSyntaxNodeShouldReturnEmptyResponse(Dat
111112

112113
var uri = DocumentUri.From($"/{dataSet.Name}");
113114

114-
using var client = await IntegrationTestHelper.StartServerWithTextAsync(dataSet.Bicep, uri);
115+
using var client = await IntegrationTestHelper.StartServerWithTextAsync(this.TestContext, dataSet.Bicep, uri);
115116
var compilation = dataSet.CopyFilesAndCreateCompilation(TestContext, out _);
116117
var symbolTable = compilation.ReconstructSymbolTable();
117118
var lineStarts = compilation.SyntaxTreeGrouping.EntryPoint.LineStarts;

src/Bicep.LangServer.IntegrationTests/DeploymentGraphTests.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,17 @@ namespace Bicep.LangServer.IntegrationTests
2323
[SuppressMessage("Style", "VSTHRD200:Use \"Async\" suffix for async methods", Justification = "Test methods do not need to follow this convention.")]
2424
public class DeploymentGraphTests
2525
{
26+
[NotNull]
27+
public TestContext? TestContext { get; set; }
28+
2629
[TestMethod]
2730
public async Task RequestDeploymentGraphShouldReturnDeploymentGraph()
2831
{
2932
var diagnosticsListener = new MultipleMessageListener<PublishDiagnosticsParams>();
3033
var fileSystemDict = new Dictionary<Uri, string>();
3134

3235
var client = await IntegrationTestHelper.StartServerWithClientConnectionAsync(
36+
this.TestContext,
3337
options => options.OnPublishDiagnostics(diagnosticsParams => diagnosticsListener.AddMessage(diagnosticsParams)),
3438
BuiltInTestTypes.Create(),
3539
new InMemoryFileResolver(fileSystemDict));

src/Bicep.LangServer.IntegrationTests/DocumentFormattingTests.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) Microsoft Corporation.
1+
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT License.
33
using System.Diagnostics.CodeAnalysis;
44
using System.Threading.Tasks;
@@ -16,13 +16,16 @@ namespace Bicep.LangServer.IntegrationTests
1616
[SuppressMessage("Style", "VSTHRD200:Use \"Async\" suffix for async methods", Justification = "Test methods do not need to follow this convention.")]
1717
public class DocumentFormattingTests
1818
{
19+
[NotNull]
20+
public TestContext? TestContext { get; set; }
21+
1922
[TestMethod]
2023
public async Task RequestDocumentFormattingShouldReturnFullRangeTextEdit()
2124
{
2225
var documentUri = DocumentUri.From("/template.bicep");
2326
var diagnosticsReceived = new TaskCompletionSource<PublishDiagnosticsParams>();
2427

25-
var client = await IntegrationTestHelper.StartServerWithClientConnectionAsync(options =>
28+
var client = await IntegrationTestHelper.StartServerWithClientConnectionAsync(this.TestContext, options =>
2629
{
2730
options.OnPublishDiagnostics(diagnostics => {
2831
diagnosticsReceived.SetResult(diagnostics);

src/Bicep.LangServer.IntegrationTests/DocumentSymbolTests.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,16 @@ namespace Bicep.LangServer.IntegrationTests
1717
[SuppressMessage("Style", "VSTHRD200:Use \"Async\" suffix for async methods", Justification = "Test methods do not need to follow this convention.")]
1818
public class DocumentSymbolTests
1919
{
20+
[NotNull]
21+
public TestContext? TestContext { get; set; }
22+
2023
[TestMethod]
2124
public async Task RequestDocumentSymbol_should_return_full_symbol_list()
2225
{
2326
var documentUri = DocumentUri.From("/template.bicep");
2427
var diagsReceived = new TaskCompletionSource<PublishDiagnosticsParams>();
2528

26-
var client = await IntegrationTestHelper.StartServerWithClientConnectionAsync(options =>
29+
var client = await IntegrationTestHelper.StartServerWithClientConnectionAsync(this.TestContext, options =>
2730
{
2831
options.OnPublishDiagnostics(diags => {
2932
diagsReceived.SetResult(diags);

src/Bicep.LangServer.IntegrationTests/FileWatcherTests.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ namespace Bicep.LangServer.IntegrationTests
2727
[SuppressMessage("Style", "VSTHRD200:Use \"Async\" suffix for async methods", Justification = "Test methods do not need to follow this convention.")]
2828
public class FileWatcherTests
2929
{
30+
[NotNull]
31+
public TestContext? TestContext { get; set; }
32+
3033
private static void SendDidChangeWatchedFiles(ILanguageClient client, params (DocumentUri documentUri, FileChangeType changeType)[] changes)
3134
{
3235
var fileChanges = new Container<FileEvent>(changes.Select(x => new FileEvent
@@ -47,6 +50,7 @@ public async Task Module_file_change_should_trigger_a_recompilation()
4750
var fileSystemDict = new Dictionary<Uri, string>();
4851
var diagsListener = new MultipleMessageListener<PublishDiagnosticsParams>();
4952
var client = await IntegrationTestHelper.StartServerWithClientConnectionAsync(
53+
this.TestContext,
5054
options =>
5155
{
5256
options.OnPublishDiagnostics(diags => diagsListener.AddMessage(diags));
@@ -124,6 +128,7 @@ public async Task Background_file_deletion_should_trigger_a_recompilation()
124128
var fileSystemDict = new Dictionary<Uri, string>();
125129
var diagsListener = new MultipleMessageListener<PublishDiagnosticsParams>();
126130
var client = await IntegrationTestHelper.StartServerWithClientConnectionAsync(
131+
this.TestContext,
127132
options =>
128133
{
129134
options.OnPublishDiagnostics(diags => diagsListener.AddMessage(diags));
@@ -190,6 +195,7 @@ public async Task Background_folder_deletion_should_trigger_a_recompilation()
190195
var fileSystemDict = new Dictionary<Uri, string>();
191196
var diagsListener = new MultipleMessageListener<PublishDiagnosticsParams>();
192197
var client = await IntegrationTestHelper.StartServerWithClientConnectionAsync(
198+
this.TestContext,
193199
options =>
194200
{
195201
options.OnPublishDiagnostics(diags => diagsListener.AddMessage(diags));

src/Bicep.LangServer.IntegrationTests/Helpers/IntegrationTestHelper.cs

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,18 @@
2121
using Bicep.Core.FileSystem;
2222
using Bicep.Core.Navigation;
2323
using Bicep.LanguageServer.Snippets;
24+
using OmniSharp.Extensions.LanguageServer.Protocol.Window;
25+
using System.Linq;
2426

2527
namespace Bicep.LangServer.IntegrationTests
2628
{
2729
public static class IntegrationTestHelper
2830
{
31+
private const int DefaultTimeout = 20000;
32+
2933
public static readonly ISnippetsProvider SnippetsProvider = new SnippetsProvider();
3034

31-
public static async Task<ILanguageClient> StartServerWithClientConnectionAsync(Action<LanguageClientOptions> onClientOptions, IResourceTypeProvider? resourceTypeProvider = null, IFileResolver? fileResolver = null)
35+
public static async Task<ILanguageClient> StartServerWithClientConnectionAsync(TestContext testContext, Action<LanguageClientOptions> onClientOptions, IResourceTypeProvider? resourceTypeProvider = null, IFileResolver? fileResolver = null)
3236
{
3337
resourceTypeProvider ??= TestTypeHelper.CreateEmptyProvider();
3438
fileResolver ??= new InMemoryFileResolver(new Dictionary<Uri, string>());
@@ -46,22 +50,29 @@ public static async Task<ILanguageClient> StartServerWithClientConnectionAsync(A
4650
SnippetsProvider = SnippetsProvider
4751
});
4852
var _ = server.RunAsync(CancellationToken.None); // do not wait on this async method, or you'll be waiting a long time!
49-
53+
5054
var client = LanguageClient.PreInit(options =>
51-
{
55+
{
5256
options
5357
.WithInput(clientPipe.Reader)
54-
.WithOutput(serverPipe.Writer);
58+
.WithOutput(serverPipe.Writer)
59+
.OnInitialize((client, request, cancellationToken) => { testContext.WriteLine("Language client initializing."); return Task.CompletedTask; })
60+
.OnInitialized((client, request, response, cancellationToken) => { testContext.WriteLine("Language client initialized."); return Task.CompletedTask; })
61+
.OnStarted((client, cancellationToken) => { testContext.WriteLine("Language client started."); return Task.CompletedTask; })
62+
.OnLogTrace(@params => testContext.WriteLine($"TRACE: {@params.Message} VERBOSE: {@params.Verbose}"))
63+
.OnLogMessage(@params => testContext.WriteLine($"{@params.Type}: {@params.Message}"));
5564

5665
onClientOptions(options);
5766
});
5867
await client.Initialize(CancellationToken.None);
5968

69+
testContext.WriteLine("LanguageClient initialize finished.");
70+
6071
return client;
6172
}
6273

6374
[System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "VSTHRD003:Avoid awaiting foreign Tasks", Justification = "Not an issue in test code.")]
64-
public static async Task<T> WithTimeoutAsync<T>(Task<T> task, int timeout = 10000)
75+
public static async Task<T> WithTimeoutAsync<T>(Task<T> task, int timeout = DefaultTimeout)
6576
{
6677
var completed = await Task.WhenAny(
6778
task,
@@ -77,7 +88,7 @@ public static async Task<T> WithTimeoutAsync<T>(Task<T> task, int timeout = 1000
7788
}
7889

7990
[System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "VSTHRD003:Avoid awaiting foreign Tasks", Justification = "Not an issue in test code.")]
80-
public static async Task EnsureTaskDoesntCompleteAsync<T>(Task<T> task, int timeout = 10000)
91+
public static async Task EnsureTaskDoesntCompleteAsync<T>(Task<T> task, int timeout = DefaultTimeout)
8192
{
8293
var completed = await Task.WhenAny(
8394
task,
@@ -90,22 +101,29 @@ public static async Task EnsureTaskDoesntCompleteAsync<T>(Task<T> task, int time
90101
}
91102
}
92103

93-
public static async Task<ILanguageClient> StartServerWithTextAsync(string text, DocumentUri documentUri, Action<LanguageClientOptions>? onClientOptions = null, IResourceTypeProvider? resourceTypeProvider = null, IFileResolver? fileResolver = null)
104+
public static async Task<ILanguageClient> StartServerWithTextAsync(TestContext testContext, string text, DocumentUri documentUri, Action<LanguageClientOptions>? onClientOptions = null, IResourceTypeProvider? resourceTypeProvider = null, IFileResolver? fileResolver = null)
94105
{
95106
var diagnosticsPublished = new TaskCompletionSource<PublishDiagnosticsParams>();
96107
fileResolver ??= new InMemoryFileResolver(new Dictionary<Uri, string> { [documentUri.ToUri()] = text, });
97108
var client = await IntegrationTestHelper.StartServerWithClientConnectionAsync(
109+
testContext,
98110
options =>
99111
{
100112
onClientOptions?.Invoke(options);
101-
options.OnPublishDiagnostics(p => diagnosticsPublished.SetResult(p));
113+
options.OnPublishDiagnostics(p =>
114+
{
115+
testContext.WriteLine($"Received {p.Diagnostics.Count()} diagnostic(s).");
116+
diagnosticsPublished.SetResult(p);
117+
});
102118
},
103119
resourceTypeProvider: resourceTypeProvider,
104120
fileResolver: fileResolver);
105121

106122
// send open document notification
107123
client.DidOpenTextDocument(TextDocumentParamHelper.CreateDidOpenDocumentParams(documentUri, text, 0));
108124

125+
testContext.WriteLine($"Opened file {documentUri}.");
126+
109127
// notifications don't produce responses,
110128
// but our server should send us diagnostics when it receives the notification
111129
await IntegrationTestHelper.WithTimeoutAsync(diagnosticsPublished.Task);

0 commit comments

Comments
 (0)