diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index fa898e2bb..fcc259678 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -29,6 +29,9 @@ jobs: - name: Checkout repository uses: actions/checkout@v3 + - name: Install dotnet + uses: actions/setup-dotnet@v3 + # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL uses: github/codeql-action/init@v2 diff --git a/.github/workflows/emacs-test.yml b/.github/workflows/emacs-test.yml index 4a62a3ae7..ddbcb7887 100644 --- a/.github/workflows/emacs-test.yml +++ b/.github/workflows/emacs-test.yml @@ -17,6 +17,9 @@ jobs: - name: Checkout repository uses: actions/checkout@v3 + - name: Install dotnet + uses: actions/setup-dotnet@v3 + - name: Build PSES shell: pwsh run: tools/azurePipelinesBuild.ps1 diff --git a/.github/workflows/vim-test.yml b/.github/workflows/vim-test.yml index 5dcf11f88..387a98e00 100644 --- a/.github/workflows/vim-test.yml +++ b/.github/workflows/vim-test.yml @@ -17,6 +17,9 @@ jobs: - name: Checkout repository uses: actions/checkout@v3 + - name: Install dotnet + uses: actions/setup-dotnet@v3 + - name: Build PSES shell: pwsh run: tools/azurePipelinesBuild.ps1 diff --git a/.vsts-ci/templates/ci-general.yml b/.vsts-ci/templates/ci-general.yml index 33d09a746..2278dc2eb 100644 --- a/.vsts-ci/templates/ci-general.yml +++ b/.vsts-ci/templates/ci-general.yml @@ -12,9 +12,16 @@ steps: pwsh: ${{ parameters.pwsh }} - task: UseDotNet@2 - displayName: Install .NET 6.0.x SDK + displayName: Install .NET 7.0.x SDK inputs: packageType: sdk + version: 7.0.x + performMultiLevelLookup: true + +- task: UseDotNet@2 + displayName: Install .NET 6.0.x runtime + inputs: + packageType: runtime version: 6.0.x performMultiLevelLookup: true diff --git a/PowerShellEditorServices.build.ps1 b/PowerShellEditorServices.build.ps1 index 94b5d6207..2af0db8b9 100644 --- a/PowerShellEditorServices.build.ps1 +++ b/PowerShellEditorServices.build.ps1 @@ -41,6 +41,7 @@ $script:PsesCommonProps = [xml](Get-Content -Raw "$PSScriptRoot/PowerShellEditor $script:NetRuntime = @{ PS7 = 'netcoreapp3.1' PS72 = 'net6.0' + PS73 = 'net7.0' Desktop = 'net462' Standard = 'netstandard2.0' } @@ -73,16 +74,16 @@ Task FindDotNet { } Task BinClean { - Remove-Item $PSScriptRoot\.tmp -Recurse -Force -ErrorAction Ignore - Remove-Item $PSScriptRoot\module\PowerShellEditorServices\bin -Recurse -Force -ErrorAction Ignore - Remove-Item $PSScriptRoot\module\PowerShellEditorServices.VSCode\bin -Recurse -Force -ErrorAction Ignore + Remove-BuildItem $PSScriptRoot\.tmp + Remove-BuildItem $PSScriptRoot\module\PowerShellEditorServices\bin + Remove-BuildItem $PSScriptRoot\module\PowerShellEditorServices.VSCode\bin } Task Clean FindDotNet, BinClean, { - Exec { & dotnet clean $VerbosityArgs } - Get-ChildItem -Recurse $PSScriptRoot\src\*.nupkg | Remove-Item -Force -ErrorAction Ignore - Get-ChildItem $PSScriptRoot\PowerShellEditorServices*.zip | Remove-Item -Force -ErrorAction Ignore - Get-ChildItem $PSScriptRoot\module\PowerShellEditorServices\Commands\en-US\*-help.xml | Remove-Item -Force -ErrorAction Ignore + Invoke-BuildExec { & dotnet clean $VerbosityArgs } + 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 # Remove bundled component modules $moduleJsonPath = "$PSScriptRoot\modules.json" @@ -90,7 +91,7 @@ Task Clean FindDotNet, BinClean, { Get-Content -Raw $moduleJsonPath | ConvertFrom-Json | ForEach-Object { $_.PSObject.Properties.Name } | - ForEach-Object { Remove-Item -Path "$PSScriptRoot/module/$_" -Recurse -Force -ErrorAction Ignore } + ForEach-Object { Remove-BuildItem -Path "$PSScriptRoot/module/$_" } } } @@ -161,20 +162,20 @@ Task SetupHelpForTests { } Task Build FindDotNet, CreateBuildInfo, { - Exec { & dotnet restore $VerbosityArgs } - Exec { & dotnet publish $VerbosityArgs -c $Configuration .\src\PowerShellEditorServices\PowerShellEditorServices.csproj -f $script:NetRuntime.Standard } - Exec { & dotnet publish $VerbosityArgs -c $Configuration .\src\PowerShellEditorServices.Hosting\PowerShellEditorServices.Hosting.csproj -f $script:NetRuntime.PS7 } + 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 } if (-not $script:IsNix) { - Exec { & dotnet publish $VerbosityArgs -c $Configuration .\src\PowerShellEditorServices.Hosting\PowerShellEditorServices.Hosting.csproj -f $script:NetRuntime.Desktop } + Invoke-BuildExec { & dotnet publish $VerbosityArgs -c $Configuration .\src\PowerShellEditorServices.Hosting\PowerShellEditorServices.Hosting.csproj -f $script:NetRuntime.Desktop } } # Build PowerShellEditorServices.VSCode module - Exec { & dotnet publish $VerbosityArgs -c $Configuration .\src\PowerShellEditorServices.VSCode\PowerShellEditorServices.VSCode.csproj -f $script:NetRuntime.Standard } + Invoke-BuildExec { & dotnet publish $VerbosityArgs -c $Configuration .\src\PowerShellEditorServices.VSCode\PowerShellEditorServices.VSCode.csproj -f $script:NetRuntime.Standard } } Task Test TestServer, TestE2E -Task TestServer TestServerWinPS, TestServerPS7, TestServerPS72 +Task TestServer TestServerWinPS, TestServerPS7, TestServerPS72, TestServerPS73 # NOTE: While these can run under `pwsh.exe` we only want them to run under # `powershell.exe` so that the CI time isn't doubled. @@ -184,25 +185,29 @@ Task TestServerWinPS -If ($PSVersionTable.PSEdition -eq "Desktop") Build, SetupH # that is debuggable! If architecture is added, the assembly path gets an # additional folder, necesstiating fixes to find the commands definition # file and test files. - Exec { & dotnet $script:dotnetTestArgs $script:NetRuntime.Desktop } + Invoke-BuildExec { & dotnet $script:dotnetTestArgs $script:NetRuntime.Desktop } } Task TestServerPS7 -If ($PSVersionTable.PSEdition -eq "Core" -and -not $script:IsAppleM1 -and -not $script:IsArm64) Build, SetupHelpForTests, { Set-Location .\test\PowerShellEditorServices.Test\ - Exec { & dotnet $script:dotnetTestArgs $script:NetRuntime.PS7 } + Invoke-BuildExec { & dotnet $script:dotnetTestArgs $script:NetRuntime.PS7 } } Task TestServerPS72 -If ($PSVersionTable.PSEdition -eq "Core") Build, SetupHelpForTests, { Set-Location .\test\PowerShellEditorServices.Test\ - Exec { & dotnet $script:dotnetTestArgs $script:NetRuntime.PS72 } + Invoke-BuildExec { & dotnet $script:dotnetTestArgs $script:NetRuntime.PS72 } +} + +Task TestServerPS73 -If ($PSVersionTable.PSEdition -eq "Core") Build, SetupHelpForTests, { + Set-Location .\test\PowerShellEditorServices.Test\ + Invoke-BuildExec { & dotnet $script:dotnetTestArgs $script:NetRuntime.PS73 } } Task TestE2E Build, SetupHelpForTests, { Set-Location .\test\PowerShellEditorServices.Test.E2E\ $env:PWSH_EXE_NAME = if ($IsCoreCLR) { "pwsh" } else { "powershell" } - $NetRuntime = if ($IsAppleM1 -or $script:IsArm64) { $script:NetRuntime.PS72 } else { $script:NetRuntime.PS7 } - Exec { & dotnet $script:dotnetTestArgs $NetRuntime } + Invoke-BuildExec { & dotnet $script:dotnetTestArgs $script:NetRuntime.PS72 } if (!$script:IsNix) { if (-not [Security.Principal.WindowsIdentity]::GetCurrent().Owner.IsWellKnown("BuiltInAdministratorsSid")) { @@ -213,7 +218,7 @@ Task TestE2E Build, SetupHelpForTests, { try { Write-Host "Running end-to-end tests in Constrained Language Mode." [System.Environment]::SetEnvironmentVariable("__PSLockdownPolicy", "0x80000007", [System.EnvironmentVariableTarget]::Machine); - Exec { & dotnet $script:dotnetTestArgs $script:NetRuntime.PS7 } + Invoke-BuildExec { & dotnet $script:dotnetTestArgs $script:NetRuntime.PS72 } } finally { [System.Environment]::SetEnvironmentVariable("__PSLockdownPolicy", $null, [System.EnvironmentVariableTarget]::Machine); } diff --git a/global.json b/global.json index 124d3fe9b..b46f32ad3 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "6.0", + "version": "7.0.100", "rollForward": "latestFeature", "allowPrerelease": true } diff --git a/src/PowerShellEditorServices/Utility/FormatUtils.cs b/src/PowerShellEditorServices/Utility/FormatUtils.cs index 9863d7b78..b3bc791dd 100644 --- a/src/PowerShellEditorServices/Utility/FormatUtils.cs +++ b/src/PowerShellEditorServices/Utility/FormatUtils.cs @@ -23,6 +23,8 @@ internal static class FormatUtils private const string Static = "static "; + private static HashSet? usingNamespaces; + /// /// Space, new line, carriage return and tab. /// @@ -164,9 +166,9 @@ private static string GetMethodDocumentation(ReadOnlySpan toolTip, out Mar { kind = MarkupKind.Markdown; StringBuilder text = new(); - HashSet? usingNamespaces = null; while (true) { + usingNamespaces = null; toolTip = toolTip.TrimStart(s_whiteSpace.Span); toolTip = ProcessMethod(toolTip, text, ref usingNamespaces); if (toolTip.IsEmpty) diff --git a/test/PowerShellEditorServices.Test.E2E/Processes/LoggingStream.cs b/test/PowerShellEditorServices.Test.E2E/Processes/LoggingStream.cs index 1a0151ec1..9a29452b0 100644 --- a/test/PowerShellEditorServices.Test.E2E/Processes/LoggingStream.cs +++ b/test/PowerShellEditorServices.Test.E2E/Processes/LoggingStream.cs @@ -16,6 +16,15 @@ internal class LoggingStream : Stream public LoggingStream(Stream underlyingStream) => _underlyingStream = underlyingStream; + protected override void Dispose(bool disposing) + { + base.Dispose(disposing); + if (disposing) + { + _underlyingStream.Dispose(); + } + } + public override bool CanRead => _underlyingStream.CanRead; public override bool CanSeek => _underlyingStream.CanSeek; diff --git a/test/PowerShellEditorServices.Test/PowerShellEditorServices.Test.csproj b/test/PowerShellEditorServices.Test/PowerShellEditorServices.Test.csproj index 2e91ad038..26323a8d6 100644 --- a/test/PowerShellEditorServices.Test/PowerShellEditorServices.Test.csproj +++ b/test/PowerShellEditorServices.Test/PowerShellEditorServices.Test.csproj @@ -2,7 +2,7 @@ - net6.0;netcoreapp3.1;net462 + net7.0;net6.0;netcoreapp3.1;net462 Microsoft.PowerShell.EditorServices.Test x64 @@ -12,20 +12,30 @@ - + + + + + + - + + + + $(DefineConstants);CoreCLR + + @@ -48,7 +58,4 @@ - - $(DefineConstants);CoreCLR -