Skip to content

Commit 10133cb

Browse files
Merge pull request #1953 from PowerShell/andschwa/workaround-omnisharp
Fix `IsExternalInit` bug, re-enable tests, and update OmniSharp to v0.19.7
2 parents ee53878 + 4ddb93f commit 10133cb

File tree

9 files changed

+79
-51
lines changed

9 files changed

+79
-51
lines changed

PowerShellEditorServices.build.ps1

+19-11
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,36 @@ param(
55
[ValidateSet("Debug", "Release")]
66
[string]$Configuration = "Debug",
77

8+
[switch]$LocalOmniSharp,
9+
810
[string]$PsesSubmodulePath = "$PSScriptRoot/module",
911

1012
[string]$ModulesJsonPath = "$PSScriptRoot/modules.json",
1113

1214
[string]$DefaultModuleRepository = "PSGallery",
1315

14-
[string[]]$VerbosityArgs = @("--verbosity", "quiet", "--nologo"),
16+
[string]$Verbosity = "quiet",
1517

1618
# See: https://docs.microsoft.com/en-us/dotnet/core/testing/selective-unit-tests
1719
[string]$TestFilter = '',
1820

1921
# See: https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-test
20-
[string[]]$TestArgs = $VerbosityArgs + @("--logger", "console;verbosity=normal", "--logger", "trx")
22+
[string[]]$TestArgs = @("--logger", "console;verbosity=normal", "--logger", "trx")
2123
)
2224

2325
#Requires -Modules @{ModuleName="InvokeBuild"; ModuleVersion="5.0.0"}
2426
#Requires -Modules @{ModuleName="platyPS"; ModuleVersion="0.14.0"}
2527

26-
$script:dotnetTestArgs = @(
27-
"test"
28-
$TestArgs
28+
$script:dotnetBuildArgs = @(
29+
"--verbosity"
30+
$Verbosity
31+
"--nologo"
32+
"-c"
33+
$Configuration
34+
if ($LocalOmniSharp) { "-property:LocalOmniSharp=true" }
35+
)
36+
37+
$script:dotnetTestArgs = @("test") + $script:dotnetBuildArgs + $TestArgs + @(
2938
if ($TestFilter) { "--filter", $TestFilter }
3039
"--framework"
3140
)
@@ -80,7 +89,7 @@ Task BinClean {
8089
}
8190

8291
Task Clean FindDotNet, BinClean, {
83-
Invoke-BuildExec { & dotnet clean $VerbosityArgs }
92+
Invoke-BuildExec { & dotnet clean --verbosity $Verbosity }
8493
Get-ChildItem -Recurse $PSScriptRoot\src\*.nupkg | Remove-BuildItem
8594
Get-ChildItem $PSScriptRoot\PowerShellEditorServices*.zip | Remove-BuildItem
8695
Get-ChildItem $PSScriptRoot\module\PowerShellEditorServices\Commands\en-US\*-help.xml | Remove-BuildItem
@@ -162,15 +171,14 @@ Task SetupHelpForTests {
162171
}
163172

164173
Task Build FindDotNet, CreateBuildInfo, {
165-
Invoke-BuildExec { & dotnet restore $VerbosityArgs }
166-
Invoke-BuildExec { & dotnet publish $VerbosityArgs -c $Configuration .\src\PowerShellEditorServices\PowerShellEditorServices.csproj -f $script:NetRuntime.Standard }
167-
Invoke-BuildExec { & dotnet publish $VerbosityArgs -c $Configuration .\src\PowerShellEditorServices.Hosting\PowerShellEditorServices.Hosting.csproj -f $script:NetRuntime.PS7 }
174+
Invoke-BuildExec { & dotnet publish $script:dotnetBuildArgs .\src\PowerShellEditorServices\PowerShellEditorServices.csproj -f $script:NetRuntime.Standard }
175+
Invoke-BuildExec { & dotnet publish $script:dotnetBuildArgs .\src\PowerShellEditorServices.Hosting\PowerShellEditorServices.Hosting.csproj -f $script:NetRuntime.PS7 }
168176
if (-not $script:IsNix) {
169-
Invoke-BuildExec { & dotnet publish $VerbosityArgs -c $Configuration .\src\PowerShellEditorServices.Hosting\PowerShellEditorServices.Hosting.csproj -f $script:NetRuntime.Desktop }
177+
Invoke-BuildExec { & dotnet publish $script:dotnetBuildArgs .\src\PowerShellEditorServices.Hosting\PowerShellEditorServices.Hosting.csproj -f $script:NetRuntime.Desktop }
170178
}
171179

172180
# Build PowerShellEditorServices.VSCode module
173-
Invoke-BuildExec { & dotnet publish $VerbosityArgs -c $Configuration .\src\PowerShellEditorServices.VSCode\PowerShellEditorServices.VSCode.csproj -f $script:NetRuntime.Standard }
181+
Invoke-BuildExec { & dotnet publish $script:dotnetBuildArgs .\src\PowerShellEditorServices.VSCode\PowerShellEditorServices.VSCode.csproj -f $script:NetRuntime.Standard }
174182
}
175183

176184
Task Test TestServer, TestE2E

src/PowerShellEditorServices.Hosting/PowerShellEditorServices.Hosting.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<ProjectReference Include="..\PowerShellEditorServices\PowerShellEditorServices.csproj" PrivateAssets="all" />
2222
</ItemGroup>
2323

24-
<ItemGroup Condition="'$(TargetFramework)'=='net462'">
24+
<ItemGroup Condition=" '$(TargetFramework)' == 'net462' ">
2525
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
2626

2727
<Compile Remove="Internal/PsesLoadContext.cs" />
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#pragma warning disable IDE0073
2+
#if NET5_0_OR_GREATER
3+
[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Runtime.CompilerServices.IsExternalInit))]
4+
#else
5+
6+
using System.ComponentModel;
7+
8+
namespace System.Runtime.CompilerServices
9+
{
10+
/// <summary>
11+
/// Reserved to be used by the compiler for tracking metadata.
12+
/// This class should not be used by developers in source code.
13+
/// </summary>
14+
[EditorBrowsable(EditorBrowsableState.Never)]
15+
internal static class IsExternalInit
16+
{
17+
}
18+
}
19+
#endif

src/PowerShellEditorServices/PowerShellEditorServices.csproj

+18-4
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,8 @@
2828
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
2929
<PackageReference Include="Microsoft.Extensions.FileSystemGlobbing" Version="6.0.0" />
3030
<PackageReference Include="Microsoft.Extensions.Logging" Version="6.0.0" />
31-
<!-- TODO: Manually pull in the updated version of Newtonsoft.Json after OmniSharp updates. -->
32-
<!-- PackageReference Include="Newtonsoft.Json" Version="13.0.1" -->
33-
<PackageReference Include="OmniSharp.Extensions.LanguageServer" Version="0.19.6" />
34-
<PackageReference Include="OmniSharp.Extensions.DebugAdapter.Server" Version="0.19.6" />
31+
<PackageReference Include="OmniSharp.Extensions.LanguageServer" Version="0.19.7" />
32+
<PackageReference Include="OmniSharp.Extensions.DebugAdapter.Server" Version="0.19.7" />
3533
<PackageReference Include="PowerShellStandard.Library" Version="5.1.1" />
3634
<PackageReference Include="Serilog" Version="2.12.0" />
3735
<PackageReference Include="Serilog.Extensions.Logging" Version="3.1.0" />
@@ -42,6 +40,22 @@
4240
<PackageReference Include="System.Security.Principal.Windows" Version="5.0.0" />
4341
</ItemGroup>
4442

43+
<Choose>
44+
<When Condition=" '$(LocalOmniSharp)' == 'true' ">
45+
<ItemGroup>
46+
<ProjectReference Include="..\..\..\csharp-language-server-protocol\src\Server\Server.csproj" />
47+
<ProjectReference Include="..\..\..\csharp-language-server-protocol\src\Dap.Server\Dap.Server.csproj" />
48+
</ItemGroup>
49+
</When>
50+
<Otherwise>
51+
<ItemGroup>
52+
<PackageReference Include="OmniSharp.Extensions.LanguageServer" Version="0.19.7" />
53+
<PackageReference Include="OmniSharp.Extensions.DebugAdapter.Server" Version="0.19.7" />
54+
</ItemGroup>
55+
</Otherwise>
56+
</Choose>
57+
58+
<!-- TODO: Remove these entirely. -->
4559
<ItemGroup>
4660
<Compile Remove="Extensions\Api\DocumentSymbolService.cs" />
4761
<Compile Remove="Services\Extension\Templating\**" />

src/PowerShellEditorServices/Utility/IsExternalInit.cs

-15
This file was deleted.

test/PowerShellEditorServices.Test.E2E/PowerShellEditorServices.Test.E2E.csproj

+15-2
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,26 @@
1010
<PackageReference Include="Microsoft.Extensions.Logging" Version="6.0.0" />
1111
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.0" />
1212
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
13-
<PackageReference Include="OmniSharp.Extensions.LanguageClient" Version="0.19.6" />
14-
<PackageReference Include="OmniSharp.Extensions.DebugAdapter.Client" Version="0.19.6" />
1513
<PackageReference Include="xunit" Version="2.4.2" />
1614
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5" />
1715
<PackageReference Include="Xunit.SkippableFact" Version="1.4.13" />
1816
</ItemGroup>
1917

18+
<Choose>
19+
<When Condition=" '$(LocalOmniSharp)' == 'true' ">
20+
<ItemGroup>
21+
<ProjectReference Include="..\..\..\csharp-language-server-protocol\src\Client\Client.csproj" />
22+
<ProjectReference Include="..\..\..\csharp-language-server-protocol\src\Dap.Client\Dap.client.csproj" />
23+
</ItemGroup>
24+
</When>
25+
<Otherwise>
26+
<ItemGroup>
27+
<PackageReference Include="OmniSharp.Extensions.LanguageClient" Version="0.19.7" />
28+
<PackageReference Include="OmniSharp.Extensions.DebugAdapter.Client" Version="0.19.7" />
29+
</ItemGroup>
30+
</Otherwise>
31+
</Choose>
32+
2033
<ItemGroup>
2134
<ProjectReference Include="..\..\src\PowerShellEditorServices\PowerShellEditorServices.csproj" />
2235
</ItemGroup>

test/PowerShellEditorServices.Test/Language/CompletionHandlerTests.cs

+5-12
Original file line numberDiff line numberDiff line change
@@ -53,19 +53,17 @@ private Task<CompletionResults> GetCompletionResultsAsync(ScriptRegion scriptReg
5353
CancellationToken.None);
5454
}
5555

56-
[SkippableFact]
56+
[Fact]
5757
public async Task CompletesCommandInFile()
5858
{
59-
Skip.If(VersionUtils.PSEdition == "Core", "OmniSharp records are broken!");
6059
(_, IEnumerable<CompletionItem> results) = await GetCompletionResultsAsync(CompleteCommandInFile.SourceDetails).ConfigureAwait(true);
6160
CompletionItem actual = Assert.Single(results);
6261
Assert.Equal(CompleteCommandInFile.ExpectedCompletion, actual);
6362
}
6463

65-
[SkippableFact]
64+
[Fact]
6665
public async Task CompletesCommandFromModule()
6766
{
68-
Skip.If(VersionUtils.PSEdition == "Core", "OmniSharp records are broken!");
6967
(_, IEnumerable<CompletionItem> results) = await GetCompletionResultsAsync(CompleteCommandFromModule.SourceDetails).ConfigureAwait(true);
7068
CompletionItem actual = Assert.Single(results);
7169
// NOTE: The tooltip varies across PowerShell and OS versions, so we ignore it.
@@ -76,7 +74,6 @@ public async Task CompletesCommandFromModule()
7674
[SkippableFact]
7775
public async Task CompletesTypeName()
7876
{
79-
Skip.If(VersionUtils.PSEdition == "Core", "OmniSharp records are broken!");
8077
Skip.If(VersionUtils.PSEdition == "Desktop", "Windows PowerShell has trouble with this test right now.");
8178
(_, IEnumerable<CompletionItem> results) = await GetCompletionResultsAsync(CompleteTypeName.SourceDetails).ConfigureAwait(true);
8279
CompletionItem actual = Assert.Single(results);
@@ -98,26 +95,23 @@ public async Task CompletesTypeName()
9895
[SkippableFact]
9996
public async Task CompletesNamespace()
10097
{
101-
Skip.If(VersionUtils.PSEdition == "Core", "OmniSharp records are broken!");
10298
Skip.If(VersionUtils.PSEdition == "Desktop", "Windows PowerShell has trouble with this test right now.");
10399
(_, IEnumerable<CompletionItem> results) = await GetCompletionResultsAsync(CompleteNamespace.SourceDetails).ConfigureAwait(true);
104100
CompletionItem actual = Assert.Single(results);
105101
Assert.Equal(CompleteNamespace.ExpectedCompletion, actual);
106102
}
107103

108-
[SkippableFact]
104+
[Fact]
109105
public async Task CompletesVariableInFile()
110106
{
111-
Skip.If(VersionUtils.PSEdition == "Core", "OmniSharp records are broken!");
112107
(_, IEnumerable<CompletionItem> results) = await GetCompletionResultsAsync(CompleteVariableInFile.SourceDetails).ConfigureAwait(true);
113108
CompletionItem actual = Assert.Single(results);
114109
Assert.Equal(CompleteVariableInFile.ExpectedCompletion, actual);
115110
}
116111

117-
[SkippableFact]
112+
[Fact]
118113
public async Task CompletesAttributeValue()
119114
{
120-
Skip.If(VersionUtils.PSEdition == "Core", "OmniSharp records are broken!");
121115
(_, IEnumerable<CompletionItem> results) = await GetCompletionResultsAsync(CompleteAttributeValue.SourceDetails).ConfigureAwait(true);
122116
// NOTE: Since the completions come through un-ordered from PowerShell, their SortText
123117
// (which has an index prepended from the original order) will mis-match our assumed
@@ -128,10 +122,9 @@ public async Task CompletesAttributeValue()
128122
actual => Assert.Equal(actual with { Data = null, SortText = null }, CompleteAttributeValue.ExpectedCompletion3));
129123
}
130124

131-
[SkippableFact]
125+
[Fact]
132126
public async Task CompletesFilePath()
133127
{
134-
Skip.If(VersionUtils.PSEdition == "Core", "OmniSharp records are broken!");
135128
(_, IEnumerable<CompletionItem> results) = await GetCompletionResultsAsync(CompleteFilePath.SourceDetails).ConfigureAwait(true);
136129
Assert.NotEmpty(results);
137130
CompletionItem actual = results.First();

test/PowerShellEditorServices.Test/PowerShellEditorServices.Test.csproj

-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
<PackageReference Include="xunit" Version="2.4.2" />
4242
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5" />
4343
<PackageReference Include="Xunit.SkippableFact" Version="1.4.13" />
44-
<PackageReference Include="OmniSharp.Extensions.LanguageServer" Version="0.19.6" />
4544
</ItemGroup>
4645

4746
<ItemGroup>

test/PowerShellEditorServices.Test/Services/Symbols/PSScriptAnalyzerTests.cs

+2-5
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
using Microsoft.PowerShell.EditorServices.Services;
99
using Microsoft.PowerShell.EditorServices.Services.TextDocument;
1010
using Microsoft.PowerShell.EditorServices.Test;
11-
using Microsoft.PowerShell.EditorServices.Utility;
1211
using Xunit;
1312

1413
namespace PowerShellEditorServices.Test.Services.Symbols
@@ -66,10 +65,9 @@ public async Task CanLoadPSScriptAnalyzerAsync()
6665
});
6766
}
6867

69-
[SkippableFact]
68+
[Fact]
7069
public async Task DoesNotDuplicateScriptMarkersAsync()
7170
{
72-
Skip.If(VersionUtils.PSEdition == "Core", "OmniSharp records are broken!");
7371
ScriptFile scriptFile = workspaceService.GetFileBuffer("untitled:Untitled-1", script);
7472
ScriptFile[] scriptFiles = { scriptFile };
7573

@@ -85,10 +83,9 @@ await analysisService
8583
Assert.Single(scriptFile.DiagnosticMarkers);
8684
}
8785

88-
[SkippableFact]
86+
[Fact]
8987
public async Task DoesNotClearParseErrorsAsync()
9088
{
91-
Skip.If(VersionUtils.PSEdition == "Core", "OmniSharp records are broken!");
9289
// Causing a missing closing } parser error
9390
ScriptFile scriptFile = workspaceService.GetFileBuffer("untitled:Untitled-2", script.TrimEnd('}'));
9491
ScriptFile[] scriptFiles = { scriptFile };

0 commit comments

Comments
 (0)