From f617fb4ef6e7656e249b08e63f2c959f2ab14b9a Mon Sep 17 00:00:00 2001 From: Andy Jordan Date: Mon, 7 Nov 2022 15:19:35 -0800 Subject: [PATCH 1/4] Revert "Skip tests broken by OmniSharp update" This reverts commit e1817dedb6cab77d71672ebb2669a8f97c857c0c. --- .../Language/CompletionHandlerTests.cs | 17 +++++------------ .../Services/Symbols/PSScriptAnalyzerTests.cs | 7 ++----- 2 files changed, 7 insertions(+), 17 deletions(-) diff --git a/test/PowerShellEditorServices.Test/Language/CompletionHandlerTests.cs b/test/PowerShellEditorServices.Test/Language/CompletionHandlerTests.cs index c7cb1765b..d47afa38e 100644 --- a/test/PowerShellEditorServices.Test/Language/CompletionHandlerTests.cs +++ b/test/PowerShellEditorServices.Test/Language/CompletionHandlerTests.cs @@ -53,19 +53,17 @@ private Task GetCompletionResultsAsync(ScriptRegion scriptReg CancellationToken.None); } - [SkippableFact] + [Fact] public async Task CompletesCommandInFile() { - Skip.If(VersionUtils.PSEdition == "Core", "OmniSharp records are broken!"); (_, IEnumerable results) = await GetCompletionResultsAsync(CompleteCommandInFile.SourceDetails).ConfigureAwait(true); CompletionItem actual = Assert.Single(results); Assert.Equal(CompleteCommandInFile.ExpectedCompletion, actual); } - [SkippableFact] + [Fact] public async Task CompletesCommandFromModule() { - Skip.If(VersionUtils.PSEdition == "Core", "OmniSharp records are broken!"); (_, IEnumerable results) = await GetCompletionResultsAsync(CompleteCommandFromModule.SourceDetails).ConfigureAwait(true); CompletionItem actual = Assert.Single(results); // NOTE: The tooltip varies across PowerShell and OS versions, so we ignore it. @@ -76,7 +74,6 @@ public async Task CompletesCommandFromModule() [SkippableFact] public async Task CompletesTypeName() { - Skip.If(VersionUtils.PSEdition == "Core", "OmniSharp records are broken!"); Skip.If(VersionUtils.PSEdition == "Desktop", "Windows PowerShell has trouble with this test right now."); (_, IEnumerable results) = await GetCompletionResultsAsync(CompleteTypeName.SourceDetails).ConfigureAwait(true); CompletionItem actual = Assert.Single(results); @@ -98,26 +95,23 @@ public async Task CompletesTypeName() [SkippableFact] public async Task CompletesNamespace() { - Skip.If(VersionUtils.PSEdition == "Core", "OmniSharp records are broken!"); Skip.If(VersionUtils.PSEdition == "Desktop", "Windows PowerShell has trouble with this test right now."); (_, IEnumerable results) = await GetCompletionResultsAsync(CompleteNamespace.SourceDetails).ConfigureAwait(true); CompletionItem actual = Assert.Single(results); Assert.Equal(CompleteNamespace.ExpectedCompletion, actual); } - [SkippableFact] + [Fact] public async Task CompletesVariableInFile() { - Skip.If(VersionUtils.PSEdition == "Core", "OmniSharp records are broken!"); (_, IEnumerable results) = await GetCompletionResultsAsync(CompleteVariableInFile.SourceDetails).ConfigureAwait(true); CompletionItem actual = Assert.Single(results); Assert.Equal(CompleteVariableInFile.ExpectedCompletion, actual); } - [SkippableFact] + [Fact] public async Task CompletesAttributeValue() { - Skip.If(VersionUtils.PSEdition == "Core", "OmniSharp records are broken!"); (_, IEnumerable results) = await GetCompletionResultsAsync(CompleteAttributeValue.SourceDetails).ConfigureAwait(true); // NOTE: Since the completions come through un-ordered from PowerShell, their SortText // (which has an index prepended from the original order) will mis-match our assumed @@ -128,10 +122,9 @@ public async Task CompletesAttributeValue() actual => Assert.Equal(actual with { Data = null, SortText = null }, CompleteAttributeValue.ExpectedCompletion3)); } - [SkippableFact] + [Fact] public async Task CompletesFilePath() { - Skip.If(VersionUtils.PSEdition == "Core", "OmniSharp records are broken!"); (_, IEnumerable results) = await GetCompletionResultsAsync(CompleteFilePath.SourceDetails).ConfigureAwait(true); Assert.NotEmpty(results); CompletionItem actual = results.First(); diff --git a/test/PowerShellEditorServices.Test/Services/Symbols/PSScriptAnalyzerTests.cs b/test/PowerShellEditorServices.Test/Services/Symbols/PSScriptAnalyzerTests.cs index 3f9a7ecb7..ca3f3ae04 100644 --- a/test/PowerShellEditorServices.Test/Services/Symbols/PSScriptAnalyzerTests.cs +++ b/test/PowerShellEditorServices.Test/Services/Symbols/PSScriptAnalyzerTests.cs @@ -8,7 +8,6 @@ using Microsoft.PowerShell.EditorServices.Services; using Microsoft.PowerShell.EditorServices.Services.TextDocument; using Microsoft.PowerShell.EditorServices.Test; -using Microsoft.PowerShell.EditorServices.Utility; using Xunit; namespace PowerShellEditorServices.Test.Services.Symbols @@ -66,10 +65,9 @@ public async Task CanLoadPSScriptAnalyzerAsync() }); } - [SkippableFact] + [Fact] public async Task DoesNotDuplicateScriptMarkersAsync() { - Skip.If(VersionUtils.PSEdition == "Core", "OmniSharp records are broken!"); ScriptFile scriptFile = workspaceService.GetFileBuffer("untitled:Untitled-1", script); ScriptFile[] scriptFiles = { scriptFile }; @@ -85,10 +83,9 @@ await analysisService Assert.Single(scriptFile.DiagnosticMarkers); } - [SkippableFact] + [Fact] public async Task DoesNotClearParseErrorsAsync() { - Skip.If(VersionUtils.PSEdition == "Core", "OmniSharp records are broken!"); // Causing a missing closing } parser error ScriptFile scriptFile = workspaceService.GetFileBuffer("untitled:Untitled-2", script.TrimEnd('}')); ScriptFile[] scriptFiles = { scriptFile }; From f7517b38e61e2f499c3e8a24e719c3b7cc0f5427 Mon Sep 17 00:00:00 2001 From: Andy Jordan Date: Mon, 7 Nov 2022 17:10:31 -0800 Subject: [PATCH 2/4] Add `-LocalOmniSharp` build flag To build against project at `../csharp-language-server-protocol`. --- PowerShellEditorServices.build.ps1 | 30 ++++++++++++------- .../PowerShellEditorServices.Hosting.csproj | 2 +- .../PowerShellEditorServices.csproj | 16 ++++++++++ .../PowerShellEditorServices.Test.E2E.csproj | 17 +++++++++-- .../PowerShellEditorServices.Test.csproj | 1 - 5 files changed, 51 insertions(+), 15 deletions(-) diff --git a/PowerShellEditorServices.build.ps1 b/PowerShellEditorServices.build.ps1 index 2af0db8b9..136a0547b 100644 --- a/PowerShellEditorServices.build.ps1 +++ b/PowerShellEditorServices.build.ps1 @@ -5,27 +5,36 @@ param( [ValidateSet("Debug", "Release")] [string]$Configuration = "Debug", + [switch]$LocalOmniSharp, + [string]$PsesSubmodulePath = "$PSScriptRoot/module", [string]$ModulesJsonPath = "$PSScriptRoot/modules.json", [string]$DefaultModuleRepository = "PSGallery", - [string[]]$VerbosityArgs = @("--verbosity", "quiet", "--nologo"), + [string]$Verbosity = "quiet", # See: https://docs.microsoft.com/en-us/dotnet/core/testing/selective-unit-tests [string]$TestFilter = '', # See: https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-test - [string[]]$TestArgs = $VerbosityArgs + @("--logger", "console;verbosity=normal", "--logger", "trx") + [string[]]$TestArgs = @("--logger", "console;verbosity=normal", "--logger", "trx") ) #Requires -Modules @{ModuleName="InvokeBuild"; ModuleVersion="5.0.0"} #Requires -Modules @{ModuleName="platyPS"; ModuleVersion="0.14.0"} -$script:dotnetTestArgs = @( - "test" - $TestArgs +$script:dotnetBuildArgs = @( + "--verbosity" + $Verbosity + "--nologo" + "-c" + $Configuration + if ($LocalOmniSharp) { "-property:LocalOmniSharp=true" } +) + +$script:dotnetTestArgs = @("test") + $script:dotnetBuildArgs + $TestArgs + @( if ($TestFilter) { "--filter", $TestFilter } "--framework" ) @@ -80,7 +89,7 @@ Task BinClean { } Task Clean FindDotNet, BinClean, { - Invoke-BuildExec { & dotnet clean $VerbosityArgs } + Invoke-BuildExec { & dotnet clean --verbosity $Verbosity } Get-ChildItem -Recurse $PSScriptRoot\src\*.nupkg | Remove-BuildItem Get-ChildItem $PSScriptRoot\PowerShellEditorServices*.zip | Remove-BuildItem Get-ChildItem $PSScriptRoot\module\PowerShellEditorServices\Commands\en-US\*-help.xml | Remove-BuildItem @@ -162,15 +171,14 @@ Task SetupHelpForTests { } Task Build FindDotNet, CreateBuildInfo, { - Invoke-BuildExec { & dotnet restore $VerbosityArgs } - Invoke-BuildExec { & dotnet publish $VerbosityArgs -c $Configuration .\src\PowerShellEditorServices\PowerShellEditorServices.csproj -f $script:NetRuntime.Standard } - Invoke-BuildExec { & dotnet publish $VerbosityArgs -c $Configuration .\src\PowerShellEditorServices.Hosting\PowerShellEditorServices.Hosting.csproj -f $script:NetRuntime.PS7 } + Invoke-BuildExec { & dotnet publish $script:dotnetBuildArgs .\src\PowerShellEditorServices\PowerShellEditorServices.csproj -f $script:NetRuntime.Standard } + Invoke-BuildExec { & dotnet publish $script:dotnetBuildArgs .\src\PowerShellEditorServices.Hosting\PowerShellEditorServices.Hosting.csproj -f $script:NetRuntime.PS7 } if (-not $script:IsNix) { - Invoke-BuildExec { & dotnet publish $VerbosityArgs -c $Configuration .\src\PowerShellEditorServices.Hosting\PowerShellEditorServices.Hosting.csproj -f $script:NetRuntime.Desktop } + Invoke-BuildExec { & dotnet publish $script:dotnetBuildArgs .\src\PowerShellEditorServices.Hosting\PowerShellEditorServices.Hosting.csproj -f $script:NetRuntime.Desktop } } # Build PowerShellEditorServices.VSCode module - Invoke-BuildExec { & dotnet publish $VerbosityArgs -c $Configuration .\src\PowerShellEditorServices.VSCode\PowerShellEditorServices.VSCode.csproj -f $script:NetRuntime.Standard } + Invoke-BuildExec { & dotnet publish $script:dotnetBuildArgs .\src\PowerShellEditorServices.VSCode\PowerShellEditorServices.VSCode.csproj -f $script:NetRuntime.Standard } } Task Test TestServer, TestE2E diff --git a/src/PowerShellEditorServices.Hosting/PowerShellEditorServices.Hosting.csproj b/src/PowerShellEditorServices.Hosting/PowerShellEditorServices.Hosting.csproj index c5aa05dd4..2a172f2fc 100644 --- a/src/PowerShellEditorServices.Hosting/PowerShellEditorServices.Hosting.csproj +++ b/src/PowerShellEditorServices.Hosting/PowerShellEditorServices.Hosting.csproj @@ -21,7 +21,7 @@ - + diff --git a/src/PowerShellEditorServices/PowerShellEditorServices.csproj b/src/PowerShellEditorServices/PowerShellEditorServices.csproj index 6d2b5e3d5..69d938f59 100644 --- a/src/PowerShellEditorServices/PowerShellEditorServices.csproj +++ b/src/PowerShellEditorServices/PowerShellEditorServices.csproj @@ -42,6 +42,22 @@ + + + + + + + + + + + + + + + + diff --git a/test/PowerShellEditorServices.Test.E2E/PowerShellEditorServices.Test.E2E.csproj b/test/PowerShellEditorServices.Test.E2E/PowerShellEditorServices.Test.E2E.csproj index 5f7618193..07f04bb99 100644 --- a/test/PowerShellEditorServices.Test.E2E/PowerShellEditorServices.Test.E2E.csproj +++ b/test/PowerShellEditorServices.Test.E2E/PowerShellEditorServices.Test.E2E.csproj @@ -10,13 +10,26 @@ - - + + + + + + + + + + + + + + + diff --git a/test/PowerShellEditorServices.Test/PowerShellEditorServices.Test.csproj b/test/PowerShellEditorServices.Test/PowerShellEditorServices.Test.csproj index 26323a8d6..9a32254b9 100644 --- a/test/PowerShellEditorServices.Test/PowerShellEditorServices.Test.csproj +++ b/test/PowerShellEditorServices.Test/PowerShellEditorServices.Test.csproj @@ -41,7 +41,6 @@ - From aa63263df2327a2cfa7cf898a272c4eaed514b0c Mon Sep 17 00:00:00 2001 From: Andy Jordan Date: Tue, 8 Nov 2022 16:09:53 -0800 Subject: [PATCH 3/4] Fix our `IsExternalInit` workaround We were also missing the conditional type forward. --- .../IsExternalInit.cs | 19 +++++++++++++++++++ .../Utility/IsExternalInit.cs | 15 --------------- 2 files changed, 19 insertions(+), 15 deletions(-) create mode 100644 src/PowerShellEditorServices/IsExternalInit.cs delete mode 100644 src/PowerShellEditorServices/Utility/IsExternalInit.cs diff --git a/src/PowerShellEditorServices/IsExternalInit.cs b/src/PowerShellEditorServices/IsExternalInit.cs new file mode 100644 index 000000000..c2a9d8275 --- /dev/null +++ b/src/PowerShellEditorServices/IsExternalInit.cs @@ -0,0 +1,19 @@ +#pragma warning disable IDE0073 +#if NET5_0_OR_GREATER +[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Runtime.CompilerServices.IsExternalInit))] +#else + +using System.ComponentModel; + +namespace System.Runtime.CompilerServices +{ + /// + /// Reserved to be used by the compiler for tracking metadata. + /// This class should not be used by developers in source code. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + internal static class IsExternalInit + { + } +} +#endif diff --git a/src/PowerShellEditorServices/Utility/IsExternalInit.cs b/src/PowerShellEditorServices/Utility/IsExternalInit.cs deleted file mode 100644 index 1f0f8f07c..000000000 --- a/src/PowerShellEditorServices/Utility/IsExternalInit.cs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -using System.ComponentModel; - -namespace System.Runtime.CompilerServices -{ - /// - /// This type must be defined to use init property accessors, - /// but is not in .NET Standard 2.0. - /// So instead we define the type in our own code. - /// - [EditorBrowsable(EditorBrowsableState.Never)] - internal class IsExternalInit { } -} From 4ddb93f642554a00620caf64ed98db060eea67b0 Mon Sep 17 00:00:00 2001 From: Andy Jordan Date: Fri, 2 Dec 2022 13:51:16 -0800 Subject: [PATCH 4/4] Bump OmniSharp to v0.19.7 --- .../PowerShellEditorServices.csproj | 10 ++++------ .../PowerShellEditorServices.Test.E2E.csproj | 4 ++-- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/PowerShellEditorServices/PowerShellEditorServices.csproj b/src/PowerShellEditorServices/PowerShellEditorServices.csproj index 69d938f59..2e06e66e3 100644 --- a/src/PowerShellEditorServices/PowerShellEditorServices.csproj +++ b/src/PowerShellEditorServices/PowerShellEditorServices.csproj @@ -28,10 +28,8 @@ - - - - + + @@ -51,8 +49,8 @@ - - + + diff --git a/test/PowerShellEditorServices.Test.E2E/PowerShellEditorServices.Test.E2E.csproj b/test/PowerShellEditorServices.Test.E2E/PowerShellEditorServices.Test.E2E.csproj index 07f04bb99..a20809070 100644 --- a/test/PowerShellEditorServices.Test.E2E/PowerShellEditorServices.Test.E2E.csproj +++ b/test/PowerShellEditorServices.Test.E2E/PowerShellEditorServices.Test.E2E.csproj @@ -24,8 +24,8 @@ - - + +