Skip to content

Commit 1ffe6db

Browse files
Merge pull request #1424 from PowerShell/andschwa/omnisharp-update
Update to use OmniSharp 0.19.0
2 parents 9d4e4c2 + 3ae17e8 commit 1ffe6db

35 files changed

+145
-311
lines changed

PowerShellEditorServices.Common.props

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<VersionSuffix>preview.1</VersionSuffix>
55
<Company>Microsoft</Company>
66
<Copyright>© Microsoft Corporation. All rights reserved.</Copyright>
7+
<LangVersion>9.0</LangVersion>
78
<PackageTags>PowerShell;editor;development;language;debugging</PackageTags>
89
<PackageLicenseUrl>https://raw.githubusercontent.com/PowerShell/PowerShellEditorServices/master/LICENSE</PackageLicenseUrl>
910
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>

src/PowerShellEditorServices.Hosting/PowerShellEditorServices.Hosting.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<Project Sdk="Microsoft.NET.Sdk">
2+
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), PowerShellEditorServices.Common.props))\PowerShellEditorServices.Common.props" />
23

34
<PropertyGroup>
45
<TargetFrameworks>netcoreapp3.1;net461</TargetFrameworks>
56
<AssemblyName>Microsoft.PowerShell.EditorServices.Hosting</AssemblyName>
6-
<LangVersion>latest</LangVersion>
77
</PropertyGroup>
88

99
<PropertyGroup Condition=" '$(TargetFramework)' == 'netcoreapp3.1' ">

src/PowerShellEditorServices.VSCode/PowerShellEditorServices.VSCode.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
<ItemGroup>
1919
<ProjectReference Include="..\PowerShellEditorServices\PowerShellEditorServices.csproj" />
20-
<PackageReference Include="PowerShellStandard.Library" Version="5.1.0">
20+
<PackageReference Include="PowerShellStandard.Library" Version="5.1.1">
2121
<PrivateAssets>All</PrivateAssets>
2222
</PackageReference>
2323
</ItemGroup>

src/PowerShellEditorServices/Logging/PsesTelemetryEvent.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
namespace Microsoft.PowerShell.EditorServices.Logging
1010
{
1111
// This inheirits from Dictionary so that it can be passed in to SendTelemetryEvent()
12-
// which takes in an IDictionary<string, JToken>
12+
// which takes in an IDictionary<string, object>
1313
// However, I wanted creation to be easy so you can do
1414
// new PsesTelemetryEvent { EventName = "eventName", Data = data }
15-
internal class PsesTelemetryEvent : Dictionary<string, JToken>
15+
internal class PsesTelemetryEvent : Dictionary<string, object>
1616
{
1717
public string EventName
1818
{

src/PowerShellEditorServices/PowerShellEditorServices.csproj

+2-12
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,9 @@
77
<Description>Provides common PowerShell editor capabilities as a .NET library.</Description>
88
<TargetFrameworks>netstandard2.0</TargetFrameworks>
99
<AssemblyName>Microsoft.PowerShell.EditorServices</AssemblyName>
10-
<LangVersion>Latest</LangVersion>
1110
<Configurations>Debug;Release</Configurations>
1211
</PropertyGroup>
1312

14-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
15-
<LangVersion>latest</LangVersion>
16-
<CheckForOverflowUnderflow></CheckForOverflowUnderflow>
17-
</PropertyGroup>
18-
19-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
20-
<LangVersion>latest</LangVersion>
21-
</PropertyGroup>
22-
2313
<ItemGroup>
2414
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
2515
<_Parameter1>Microsoft.PowerShell.EditorServices.Hosting</_Parameter1>
@@ -39,8 +29,8 @@
3929
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
4030
<PackageReference Include="Microsoft.Extensions.FileSystemGlobbing" Version="5.0.0" />
4131
<PackageReference Include="Microsoft.Extensions.Logging" Version="5.0.0" />
42-
<PackageReference Include="OmniSharp.Extensions.LanguageServer" Version="0.18.3" />
43-
<PackageReference Include="OmniSharp.Extensions.DebugAdapter.Server" Version="0.18.3" />
32+
<PackageReference Include="OmniSharp.Extensions.LanguageServer" Version="0.19.0" />
33+
<PackageReference Include="OmniSharp.Extensions.DebugAdapter.Server" Version="0.19.0" />
4434
<PackageReference Include="PowerShellStandard.Library" Version="5.1.1" />
4535
<PackageReference Include="Serilog" Version="2.10.0" />
4636
<PackageReference Include="Serilog.Extensions.Logging" Version="3.0.1" />

src/PowerShellEditorServices/Server/PsesLanguageServer.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public async Task StartAsync()
6767
.AddPsesLanguageServices(_hostDetails))
6868
.ConfigureLogging(builder => builder
6969
.AddSerilog(Log.Logger)
70-
.AddLanguageProtocolLogging(_minimumLogLevel)
70+
.AddLanguageProtocolLogging()
7171
.SetMinimumLevel(_minimumLogLevel))
7272
.WithHandler<PsesWorkspaceSymbolsHandler>()
7373
.WithHandler<PsesTextDocumentHandler>()
@@ -94,6 +94,7 @@ public async Task StartAsync()
9494
.WithHandler<ExpandAliasHandler>()
9595
.WithHandler<PsesSemanticTokensHandler>()
9696
.OnInitialize(
97+
// TODO: Either fix or ignore "method lacks 'await'" warning.
9798
async (languageServer, request, cancellationToken) =>
9899
{
99100
var serviceProvider = languageServer.Services;

src/PowerShellEditorServices/Services/CodeLens/PesterCodeLensProvider.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ private CodeLens[] GetPesterLens(PesterSymbolReference pesterSymbol, ScriptFile
5555
Data = JToken.FromObject(new {
5656
Uri = scriptFile.DocumentUri,
5757
ProviderId = nameof(PesterCodeLensProvider)
58-
}, Serializer.Instance.JsonSerializer),
58+
}, LspSerializer.Instance.JsonSerializer),
5959
Command = new Command()
6060
{
6161
Name = "PowerShell.RunPesterTests",
@@ -66,7 +66,7 @@ private CodeLens[] GetPesterLens(PesterSymbolReference pesterSymbol, ScriptFile
6666
false /* No debug */,
6767
pesterSymbol.TestName,
6868
pesterSymbol.ScriptRegion?.StartLineNumber
69-
}, Serializer.Instance.JsonSerializer)
69+
}, LspSerializer.Instance.JsonSerializer)
7070
}
7171
},
7272

@@ -76,7 +76,7 @@ private CodeLens[] GetPesterLens(PesterSymbolReference pesterSymbol, ScriptFile
7676
Data = JToken.FromObject(new {
7777
Uri = scriptFile.DocumentUri,
7878
ProviderId = nameof(PesterCodeLensProvider)
79-
}, Serializer.Instance.JsonSerializer),
79+
}, LspSerializer.Instance.JsonSerializer),
8080
Command = new Command()
8181
{
8282
Name = "PowerShell.RunPesterTests",
@@ -88,7 +88,7 @@ private CodeLens[] GetPesterLens(PesterSymbolReference pesterSymbol, ScriptFile
8888
pesterSymbol.TestName,
8989
pesterSymbol.ScriptRegion?.StartLineNumber
9090
},
91-
Serializer.Instance.JsonSerializer)
91+
LspSerializer.Instance.JsonSerializer)
9292
}
9393
}
9494
};

src/PowerShellEditorServices/Services/CodeLens/ReferencesCodeLensProvider.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public CodeLens[] ProvideCodeLenses(ScriptFile scriptFile)
6868
{
6969
Uri = scriptFile.DocumentUri,
7070
ProviderId = nameof(ReferencesCodeLensProvider)
71-
}, Serializer.Instance.JsonSerializer),
71+
}, LspSerializer.Instance.JsonSerializer),
7272
Range = sym.ScriptRegion.ToRange()
7373
});
7474
}
@@ -145,7 +145,7 @@ public CodeLens ResolveCodeLens(CodeLens codeLens, ScriptFile scriptFile)
145145
codeLens.Range.Start,
146146
referenceLocations
147147
},
148-
Serializer.Instance.JsonSerializer)
148+
LspSerializer.Instance.JsonSerializer)
149149
}
150150
};
151151
}

src/PowerShellEditorServices/Services/DebugAdapter/DebugEventHandlerService.cs

+5-3
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,11 @@ private void DebugService_BreakpointUpdated(object sender, BreakpointUpdatedEven
146146
break;
147147
}
148148

149-
OmniSharp.Extensions.DebugAdapter.Protocol.Models.Breakpoint breakpoint;
149+
var breakpoint = new OmniSharp.Extensions.DebugAdapter.Protocol.Models.Breakpoint
150+
{
151+
Verified = e.UpdateType != BreakpointUpdateType.Disabled
152+
};
153+
150154
if (e.Breakpoint is LineBreakpoint)
151155
{
152156
breakpoint = LspDebugUtils.CreateBreakpoint(BreakpointDetails.Create(e.Breakpoint));
@@ -162,8 +166,6 @@ private void DebugService_BreakpointUpdated(object sender, BreakpointUpdatedEven
162166
return;
163167
}
164168

165-
breakpoint.Verified = e.UpdateType != BreakpointUpdateType.Disabled;
166-
167169
_debugAdapterServer.SendNotification(EventNames.Breakpoint,
168170
new BreakpointEvent
169171
{

src/PowerShellEditorServices/Services/DebugAdapter/Handlers/DebuggerActionHandlers.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
namespace Microsoft.PowerShell.EditorServices.Handlers
1515
{
16+
// TODO: Inherit from ABCs instead of satisfying interfaces.
1617
internal class DebuggerActionHandlers : IContinueHandler, INextHandler, IPauseHandler, IStepInHandler, IStepOutHandler
1718
{
1819
private readonly ILogger _logger;
@@ -22,7 +23,7 @@ public DebuggerActionHandlers(
2223
ILoggerFactory loggerFactory,
2324
DebugService debugService)
2425
{
25-
_logger = loggerFactory.CreateLogger<ContinueHandler>();
26+
_logger = loggerFactory.CreateLogger<ContinueHandlerBase>();
2627
_debugService = debugService;
2728
}
2829

src/PowerShellEditorServices/Services/DebugAdapter/Handlers/LaunchAndAttachHandler.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
namespace Microsoft.PowerShell.EditorServices.Handlers
2424
{
25-
internal class PsesLaunchRequestArguments : LaunchRequestArguments
25+
internal record PsesLaunchRequestArguments : LaunchRequestArguments
2626
{
2727
/// <summary>
2828
/// Gets or sets the absolute path to the script to debug.
@@ -70,7 +70,7 @@ internal class PsesLaunchRequestArguments : LaunchRequestArguments
7070
public Dictionary<string, string> Env { get; set; }
7171
}
7272

73-
internal class PsesAttachRequestArguments : AttachRequestArguments
73+
internal record PsesAttachRequestArguments : AttachRequestArguments
7474
{
7575
public string ComputerName { get; set; }
7676

src/PowerShellEditorServices/Services/DebugAdapter/Handlers/ThreadsHandler.cs

+2-7
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,8 @@ public Task<ThreadsResponse> Handle(ThreadsArguments request, CancellationToken
1616
{
1717
return Task.FromResult(new ThreadsResponse
1818
{
19-
// TODO: What do I do with these?
20-
Threads = new Container<OmniSharp.Extensions.DebugAdapter.Protocol.Models.Thread>(
21-
new OmniSharp.Extensions.DebugAdapter.Protocol.Models.Thread
22-
{
23-
Id = 1,
24-
Name = "Main Thread"
25-
})
19+
// TODO: This is an empty container of threads...do we need to make a thread?
20+
Threads = new Container<System.Threading.Thread>()
2621
});
2722
}
2823
}

src/PowerShellEditorServices/Services/TextDocument/Handlers/CodeActionHandler.cs

+17-25
Original file line numberDiff line numberDiff line change
@@ -19,46 +19,38 @@
1919

2020
namespace Microsoft.PowerShell.EditorServices.Handlers
2121
{
22-
internal class PsesCodeActionHandler : ICodeActionHandler
22+
internal class PsesCodeActionHandler : CodeActionHandlerBase
2323
{
24-
private static readonly CodeActionKind[] s_supportedCodeActions = new[]
25-
{
26-
CodeActionKind.QuickFix
27-
};
28-
29-
private readonly CodeActionRegistrationOptions _registrationOptions;
30-
3124
private readonly ILogger _logger;
32-
3325
private readonly AnalysisService _analysisService;
34-
3526
private readonly WorkspaceService _workspaceService;
3627

37-
private CodeActionCapability _capability;
38-
3928
public PsesCodeActionHandler(ILoggerFactory factory, AnalysisService analysisService, WorkspaceService workspaceService)
4029
{
4130
_logger = factory.CreateLogger<PsesCodeActionHandler>();
4231
_analysisService = analysisService;
4332
_workspaceService = workspaceService;
44-
_registrationOptions = new CodeActionRegistrationOptions
45-
{
46-
DocumentSelector = LspUtils.PowerShellDocumentSelector,
47-
CodeActionKinds = s_supportedCodeActions
48-
};
4933
}
5034

51-
public CodeActionRegistrationOptions GetRegistrationOptions()
52-
{
53-
return _registrationOptions;
54-
}
35+
protected override CodeActionRegistrationOptions CreateRegistrationOptions(CodeActionCapability capability, ClientCapabilities clientCapabilities) => new CodeActionRegistrationOptions
36+
{
37+
// TODO: What do we do with the arguments?
38+
DocumentSelector = LspUtils.PowerShellDocumentSelector,
39+
CodeActionKinds = new CodeActionKind[] { CodeActionKind.QuickFix }
40+
};
5541

56-
public void SetCapability(CodeActionCapability capability)
42+
// TODO: Either fix or ignore "method lacks 'await'" warning.
43+
public override async Task<CodeAction> Handle(CodeAction request, CancellationToken cancellationToken)
5744
{
58-
_capability = capability;
45+
// TODO: How on earth do we handle a CodeAction? This is new...
46+
if (cancellationToken.IsCancellationRequested)
47+
{
48+
_logger.LogDebug("CodeAction request canceled for: {0}", request.Title);
49+
}
50+
return request;
5951
}
6052

61-
public async Task<CommandOrCodeActionContainer> Handle(CodeActionParams request, CancellationToken cancellationToken)
53+
public override async Task<CommandOrCodeActionContainer> Handle(CodeActionParams request, CancellationToken cancellationToken)
6254
{
6355
if (cancellationToken.IsCancellationRequested)
6456
{
@@ -101,7 +93,7 @@ public async Task<CommandOrCodeActionContainer> Handle(CodeActionParams request,
10193
new WorkspaceEditDocumentChange(
10294
new TextDocumentEdit
10395
{
104-
TextDocument = new VersionedTextDocumentIdentifier
96+
TextDocument = new OptionalVersionedTextDocumentIdentifier
10597
{
10698
Uri = request.TextDocument.Uri
10799
},

src/PowerShellEditorServices/Services/TextDocument/Handlers/CodeLensHandlers.cs

+11-18
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,21 @@
1515
using Microsoft.PowerShell.EditorServices.Services;
1616
using Microsoft.PowerShell.EditorServices.Services.TextDocument;
1717
using Microsoft.PowerShell.EditorServices.Utility;
18-
using OmniSharp.Extensions.LanguageServer.Protocol;
1918
using OmniSharp.Extensions.LanguageServer.Protocol.Client.Capabilities;
2019
using OmniSharp.Extensions.LanguageServer.Protocol.Document;
2120
using OmniSharp.Extensions.LanguageServer.Protocol.Models;
2221

2322
namespace Microsoft.PowerShell.EditorServices.Handlers
2423
{
24+
// TODO: Use ABCs.
2525
internal class PsesCodeLensHandlers : ICodeLensHandler, ICodeLensResolveHandler
2626
{
27-
private readonly Guid _id = new Guid();
2827
private readonly ILogger _logger;
2928
private readonly SymbolsService _symbolsService;
3029
private readonly WorkspaceService _workspaceService;
31-
3230
private CodeLensCapability _capability;
33-
public Guid Id => _id;
31+
private readonly Guid _id = Guid.NewGuid();
32+
Guid ICanBeIdentifiedHandler.Id => _id;
3433

3534
public PsesCodeLensHandlers(ILoggerFactory factory, SymbolsService symbolsService, WorkspaceService workspaceService, ConfigurationService configurationService)
3635
{
@@ -39,13 +38,15 @@ public PsesCodeLensHandlers(ILoggerFactory factory, SymbolsService symbolsServic
3938
_symbolsService = symbolsService;
4039
}
4140

42-
CodeLensRegistrationOptions IRegistration<CodeLensRegistrationOptions>.GetRegistrationOptions()
41+
public CodeLensRegistrationOptions GetRegistrationOptions(CodeLensCapability capability, ClientCapabilities clientCapabilities) => new CodeLensRegistrationOptions
4342
{
44-
return new CodeLensRegistrationOptions
45-
{
46-
DocumentSelector = LspUtils.PowerShellDocumentSelector,
47-
ResolveProvider = true
48-
};
43+
DocumentSelector = LspUtils.PowerShellDocumentSelector,
44+
ResolveProvider = true
45+
};
46+
47+
public void SetCapability(CodeLensCapability capability, ClientCapabilities clientCapabilities)
48+
{
49+
_capability = capability;
4950
}
5051

5152
public Task<CodeLensContainer> Handle(CodeLensParams request, CancellationToken cancellationToken)
@@ -57,14 +58,6 @@ public Task<CodeLensContainer> Handle(CodeLensParams request, CancellationToken
5758
return Task.FromResult(new CodeLensContainer(codeLensResults));
5859
}
5960

60-
public TextDocumentRegistrationOptions GetRegistrationOptions()
61-
{
62-
return new TextDocumentRegistrationOptions
63-
{
64-
DocumentSelector = LspUtils.PowerShellDocumentSelector,
65-
};
66-
}
67-
6861
public bool CanResolve(CodeLens value)
6962
{
7063
CodeLensData codeLensData = value.Data.ToObject<CodeLensData>();

0 commit comments

Comments
 (0)