diff --git a/scripts/AddCopyrightHeaders.ps1 b/scripts/AddCopyrightHeaders.ps1 deleted file mode 100644 index 1cb087f62..000000000 --- a/scripts/AddCopyrightHeaders.ps1 +++ /dev/null @@ -1,36 +0,0 @@ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. - -$copyrightHeaderString = -@' -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -'@ - -$global:updateCount = 0; - -function Add-CopyrightHeaders($basePath) -{ - Push-Location $basePath - $allSourceFiles = Get-ChildItem $basePath -Recurse -Filter *.cs | ?{ $_.FullName -notmatch "\\obj\\?" } - - foreach ($sourceFile in $allSourceFiles) - { - $fileContent = (Get-Content $sourceFile.FullName -Raw).TrimStart() - - if ($fileContent.StartsWith($copyrightHeaderString) -eq $false) - { - # Add the copyright header to the file - Set-Content $sourceFile.FullName ($copyrightHeaderString + [Environment]::NewLine + [Environment]::NewLine + $fileContent) - Write-Output ("Updated {0}" -f (Resolve-Path $sourceFile.FullName -Relative)) - $global:updateCount++ - } - } - - Pop-Location -} - -Add-CopyrightHeaders(Resolve-Path $PSScriptRoot\..\src) -Add-CopyrightHeaders(Resolve-Path $PSScriptRoot\..\test) - -Write-Output "`r`nDone, $global:updateCount file(s) updated." diff --git a/scripts/BuildDocs.ps1 b/scripts/BuildDocs.ps1 deleted file mode 100644 index 77e2fc3e2..000000000 --- a/scripts/BuildDocs.ps1 +++ /dev/null @@ -1,78 +0,0 @@ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. - -param([switch]$Serve, [switch]$Clean, [switch]$Publish) - -$toolsPath = [System.IO.Path]::GetFullPath("$PSScriptRoot\..\tools") -$docfxZipPath = [System.IO.Path]::GetFullPath("$toolsPath\docfx.zip") -$docfxBinPath = [System.IO.Path]::GetFullPath("$toolsPath\docfx\") -$docfxExePath = [System.IO.Path]::GetFullPath("$docfxBinPath\docfx.exe") -$docfxJsonPath = [System.IO.Path]::GetFullPath("$PSScriptRoot\..\docs\docfx.json") -$sitePath = [System.IO.Path]::GetFullPath("$PSScriptRoot\..\docs\_site") -$docsRepoPath = [System.IO.Path]::GetFullPath("$PSScriptRoot\..\docs\_repo") - -# Ensure the tools path exists -mkdir $toolsPath -Force | Out-Null - -if (![System.IO.File]::Exists($docfxExePath)) { - # Download DocFX - Remove-Item -Path "$docfxBinPath" -Force -ErrorAction Stop | Out-Null - (new-object net.webclient).DownloadFile('https://github.com/dotnet/docfx/releases/download/v1.8/docfx.zip', "$docfxZipPath") - - # Extract the archive - Expand-Archive $docfxZipPath -DestinationPath $docfxBinPath -Force -ErrorAction "Stop" -} - -# Clean the _site folder if necessary -if ($Clean.IsPresent) { - Remove-Item -Path $sitePath -Force -Recurse | Out-Null -} - -# Build the metadata for the C# API -& $docfxExePath metadata $docfxJsonPath - -if ($Serve.IsPresent) { - & $docfxExePath build $docfxJsonPath --serve -} -else { - & $docfxExePath build $docfxJsonPath - - if ($Publish.IsPresent) { - # Delete the existing docs repo folder - if (Test-Path $docsRepoPath) { - Remove-Item -Path $docsRepoPath -Recurse -Force -ErrorAction Stop | Out-Null - } - - # Clone the documentation site branch of the Editor Services repo - git clone -b gh-pages https://github.com/PowerShell/PowerShellEditorServices.git $docsRepoPath - - # Copy the site files into the repo path - Write-Host -ForegroundColor Green "*** Copying documentation site files ***" - Copy-Item -Recurse -Force $sitePath\* $docsRepoPath - - # Enter the repo path and commit the changes - Write-Host -ForegroundColor Green "*** Committing changes ***" - Push-Location $docsRepoPath - git add -A - git commit -m "Updated documentation site" - - # Verify that we're ready to push and then do it - $response = - $host.ui.PromptForChoice( - "Ready to push?", - "Are you ready to push the doc site changes?", - [System.Management.Automation.Host.ChoiceDescription[]]( - (New-Object System.Management.Automation.Host.ChoiceDescription "&Yes","Yes"), - (New-Object System.Management.Automation.Host.ChoiceDescription "&No","No") - ), - 1); - - if ($response -eq 0) { - Write-Host -ForegroundColor Green "*** Pushing changes ***" - git push origin gh-pages - } - else { - Write-Output "Did not push changes. Run 'git push origin gh-pages' manually when ready." - } - } -} diff --git a/scripts/FetchLatestBuild.ps1 b/scripts/FetchLatestBuild.ps1 deleted file mode 100644 index 55b3029c6..000000000 --- a/scripts/FetchLatestBuild.ps1 +++ /dev/null @@ -1,53 +0,0 @@ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. - -param($buildVersion = $null) - -$releasePath = [System.IO.Path]::GetFullPath("$PSScriptRoot\..\release") -$binariesToSignPath = [System.IO.Path]::GetFullPath("$releasePath\BinariesToSign") -$unpackedPackagesPath = [System.IO.Path]::GetFullPath("$releasePath\UnpackedPackages") - -# Ensure that the release path exists and clear out old folders -mkdir $releasePath -Force | Out-Null - -# Install prerequisite packages -#Install-Package -Name "Newtonsoft.Json" -RequiredVersion "7.0.1" -Source "nuget.org" -ProviderName "NuGet" -Destination $buildPath -Force - -if ($buildVersion -eq $null) { - # Get the current build status - $headers = @{ "Content-Type" = "application/json" } - $project = Invoke-RestMethod -Method Get -Uri "https://ci.appveyor.com/api/projects/PowerShell/PowerShellEditorServices/branch/master" -Headers $headers - $buildVersion = $project.build.version - if ($project.build.status -eq "success") { - Write-Output "Latest build version on master is $buildVersion`r`n" - } - else { - Write-Error "PowerShellEditorServices build $buildVersion was not successful!" -ErrorAction "Stop" - } -} - -function Install-BuildPackage($packageName, $extension) { - $uri = "https://ci.appveyor.com/nuget/powershelleditorservices/api/v2/package/{0}/{1}" -f $packageName.ToLower(), $buildVersion - Write-Verbose "Fetching from URI: $uri" - - # Download the package and extract it - $zipPath = "$releasePath\$packageName.zip" - $packageContentPath = "$unpackedPackagesPath\$packageName" - Invoke-WebRequest $uri -OutFile $zipPath -ErrorAction "Stop" - Expand-Archive $zipPath -DestinationPath $packageContentPath -Force -ErrorAction "Stop" - Remove-Item $zipPath -ErrorAction "Stop" - - # Copy the binary to the binary signing folder - mkdir $binariesToSignPath -Force | Out-Null - cp "$packageContentPath\lib\net45\$packageName.$extension" -Force -Destination $binariesToSignPath - - Write-Output "Extracted package $packageName ($buildVersion)" -} - -# Pull the build packages from AppVeyor -Install-BuildPackage "Microsoft.PowerShell.EditorServices" "dll" -Install-BuildPackage "Microsoft.PowerShell.EditorServices.Protocol" "dll" -Install-BuildPackage "Microsoft.PowerShell.EditorServices.Host" "dll" - -# Open the BinariesToSign folder -& start $binariesToSignPath diff --git a/scripts/PackageSignedBinaries.ps1 b/scripts/PackageSignedBinaries.ps1 deleted file mode 100644 index c96153774..000000000 --- a/scripts/PackageSignedBinaries.ps1 +++ /dev/null @@ -1,39 +0,0 @@ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. - -# This script assumes the FetchBuildBinaries.ps1 has been run and -# the binaries in 'release\BinariesToSign' have been signed and -# replaced. - -param($FailIfNotSigned = $true) - -$releasePath = [System.IO.Path]::GetFullPath("$PSScriptRoot\..\release") -$finalPackagePath = [System.IO.Path]::GetFullPath("$releasePath\FinalPackages") -$binariesToSignPath = [System.IO.Path]::GetFullPath("$releasePath\BinariesToSign") -$unpackedPackagesPath = [System.IO.Path]::GetFullPath("$releasePath\UnpackedPackages") -$nugetPath = [System.IO.Path]::GetFullPath("$PSScriptRoot\..\.nuget\NuGet.exe") - -mkdir $finalPackagePath -Force | Out-Null - -$binaries = Get-ChildItem $binariesToSignPath -foreach ($binaryPath in $binaries) { - $signature = Get-AuthenticodeSignature $binaryPath.FullName - - # TODO: More validation here? - if ($signature.Status -eq "NotSigned" -and $FailIfNotSigned) { - Write-Error "Binary file is not authenticode signed: $binaryPath" -ErrorAction Stop - } - - # Get the package name for the binary and account for 32-bit exe - $packageName = [System.IO.Path]::GetFileNameWithoutExtension($binaryPath) - $packageName = $packageName.TrimEnd(".x86") - - # Copy the binary back to its package path - $packagePath = "$unpackedPackagesPath\$packageName" - cp $binaryPath.FullName -Destination "$packagePath\lib\net45\" -Force - - # Repackage the nupkg with NuGet - Push-Location $finalPackagePath - & $nugetPath pack "$packagePath\$packageName.nuspec" - Pop-Location -} diff --git a/scripts/PublishPackages.ps1 b/scripts/PublishPackages.ps1 deleted file mode 100644 index 6bc848422..000000000 --- a/scripts/PublishPackages.ps1 +++ /dev/null @@ -1,24 +0,0 @@ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. - -$releasePath = [System.IO.Path]::GetFullPath("$PSScriptRoot\..\release") -$finalPackagePath = [System.IO.Path]::GetFullPath("$releasePath\FinalPackages") -$nugetPath = [System.IO.Path]::GetFullPath("$PSScriptRoot\..\.nuget\NuGet.exe") - -$packages = Get-ChildItem $finalPackagePath -Filter "*.nupkg" - -foreach ($package in $packages) { - & $nugetPath push -NonInteractive $package.FullName - if ($LASTEXITCODE -ne 0) - { - Write-Output "`r`n'nuget push' has failed. You may need to run the following command to set the NuGet account API key:`r`n" - Write-Output "& $nuGetPath setApiKey" - break - } - else - { - Write-Output "Pushed package $package.FullName" - } -} - -# TODO: Use Find-Package to verify that the package is there? diff --git a/scripts/ReleaseProcess.md b/scripts/ReleaseProcess.md deleted file mode 100644 index 4645d9431..000000000 --- a/scripts/ReleaseProcess.md +++ /dev/null @@ -1,16 +0,0 @@ -## PowerShell Editor Services Release Process - -1. Find the latest build version for the `master` branch on AppVeyor: - -2. Run `.\scripts\FetchLatestBuild.ps1` - -3. Once this script completes, sign the binaries in `.\release\BinariesToSign`. - -4. Once you have the authenticode-signed binaries, copy them back into - `.\release\BinariesToSign` - -5. Run `.\scripts\PackageSignedBinaries.ps1`. If any binaries didn't get signed - correctly, this script will tell you. Once this script completes, the updated - .nupkg files will be in `.\release\FinalPackages` - -6. Run `.\scripts\PublishPackages.ps1` to publish the final packages to NuGet. \ No newline at end of file diff --git a/src/PowerShellEditorServices/.vscode/launch.json b/src/PowerShellEditorServices/.vscode/launch.json deleted file mode 100644 index 8b60d4fab..000000000 --- a/src/PowerShellEditorServices/.vscode/launch.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "name": ".NET Core Launch (console)", - "type": "coreclr", - "request": "launch", - "WARNING01": "*********************************************************************************", - "WARNING02": "The C# extension was unable to automatically to decode projects in the current", - "WARNING03": "workspace to create a runnable lanch.json file. A template launch.json file has", - "WARNING04": "been created as a placeholder.", - "WARNING05": "", - "WARNING06": "If OmniSharp is currently unable to load your project, you can attempt to resolve", - "WARNING07": "this by restoring any missing project dependencies (example: run 'dotnet restore')", - "WARNING08": "and by fixing any reported errors from building the projects in your workspace.", - "WARNING09": "If this allows OmniSharp to now load your project then --", - "WARNING10": " * Delete this file", - "WARNING11": " * Open the Visual Studio Code command palette (View->Command Palette)", - "WARNING12": " * run the command: '.NET: Generate Assets for Build and Debug'.", - "WARNING13": "", - "WARNING14": "If your project requires a more complex launch configuration, you may wish to delete", - "WARNING15": "this configuration and pick a different template using the 'Add Configuration...'", - "WARNING16": "button at the bottom of this file.", - "WARNING17": "*********************************************************************************", - "preLaunchTask": "build", - "program": "${workspaceFolder}/bin/Debug//.dll", - "args": [], - "cwd": "${workspaceFolder}", - "console": "internalConsole", - "stopAtEntry": false - }, - { - "name": ".NET Core Attach", - "type": "coreclr", - "request": "attach", - "processId": "${command:pickProcess}" - } - ] -} \ No newline at end of file diff --git a/tools/PsesLogAnalyzer/.vscode/launch.json b/tools/PsesLogAnalyzer/.vscode/launch.json deleted file mode 100644 index cca4ceb41..000000000 --- a/tools/PsesLogAnalyzer/.vscode/launch.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "type": "PowerShell", - "request": "launch", - "name": "PowerShell Interactive Session", - "cwd": "" - } - ] -} diff --git a/tools/PsesLogAnalyzer/Analyze.ps1 b/tools/PsesLogAnalyzer/Analyze.ps1 deleted file mode 100644 index 72e0a9938..000000000 --- a/tools/PsesLogAnalyzer/Analyze.ps1 +++ /dev/null @@ -1,310 +0,0 @@ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. - -<# -.SYNOPSIS - Gets LSP notification messages sent from either server to the client or vice-versa. -.DESCRIPTION - Gets LSP notification messages sent from either server to the client or vice-versa. -.EXAMPLE - C:\> Get-PsesRpcNotificationMessage $log - Gets all LSP notification messages in the specified log. -.EXAMPLE - C:\> Get-PsesRpcNotificationMessage $log -MessageName '$/cancelRequest' - Gets all LSP $/cancelRequest notification messages in the specified log. -.EXAMPLE - C:\> Get-PsesRpcNotificationMessage $log -Pattern powershell/.* - Gets all LSP powershell notification messages in the specified log. -.INPUTS - System.String or PsesLogEntry -.OUTPUTS - PsesLogEntry -#> -function Get-PsesRpcNotificationMessage { - [CmdletBinding(DefaultParameterSetName = "PsesLogEntry")] - param( - # Specifies a path to one or more PSES EditorServices log files. - [Parameter(Mandatory = $true, Position = 0, ParameterSetName = "Path")] - [Alias("PSPath")] - [ValidateNotNullOrEmpty()] - [string] - $Path, - - # Specifies PsesLogEntry objects to analyze. - [Parameter(Mandatory = $true, Position = 0, ParameterSetName = "PsesLogEntry", ValueFromPipeline = $true)] - [ValidateNotNull()] - [psobject[]] - $LogEntry, - - # Specifies a specific LSP notification. - [Parameter(Position=1)] - [ValidateSet( - "$/cancelRequest", - "initialized", - "powerShell/executionStatusChanged", - "textDocument/didChange", - "textDocument/didClose", - "textDocument/didOpen", - "textDocument/didSave", - "textDocument/publishDiagnostics", - "workspace/didChangeConfiguration")] - [string] - $MessageName, - - # Specifies a regular expression pattern that filters the output based on the message name - # e.g. 'cancelRequest' - [Parameter()] - [string] - $Pattern, - - # Specifies a filter for either client or server sourced notifications. By default both are output. - [Parameter()] - [ValidateSet('Client', 'Server')] - [string] - $Source - ) - - begin { - if ($PSCmdlet.ParameterSetName -eq "Path") { - $logEntries = Parse-PsesLog $Path - } - } - - process { - if ($PSCmdlet.ParameterSetName -eq "PsesLogEntry") { - $logEntries = $LogEntry - } - - foreach ($entry in $logEntries) { - if ($entry.LogMessageType -ne 'Notification') { continue } - - if ((!$MessageName -or ($entry.Message.Name -eq $MessageName)) -and - (!$Pattern -or ($entry.Message.Name -match $Pattern)) -and - (!$Source -or ($entry.Message.Source -eq $Source))) { - - $entry - } - } - } -} - -<# -.SYNOPSIS - Outputs the response time for message LSP message. -.DESCRIPTION - Outputs the response time for message LSP message. Use the MessageNamePattern to - limit the response time output to a specific message (or pattern of messages). -.EXAMPLE - C:\> Get-PsesRpcMessageResponseTime $log - Gets the response time of all LSP messages. -.EXAMPLE - C:\> Get-PsesRpcMessageResponseTime $log -MessageName textDocument/foldingRange - Gets the response time of all foldingRange LSP messages. -.EXAMPLE - C:\> Get-PsesRpcMessageResponseTime $log -Pattern 'textDocument/.*Formatting' - Gets the response time of all formatting LSP messages. -.INPUTS - System.String or PsesLogEntry -.OUTPUTS - PsesLogEntryElapsed -#> -function Get-PsesRpcMessageResponseTime { - [CmdletBinding(DefaultParameterSetName = "PsesLogEntry")] - param( - # Specifies a path to one or more PSES EditorServices log files. - [Parameter(Mandatory=$true, Position=0, ParameterSetName="Path")] - [Alias("PSPath")] - [ValidateNotNullOrEmpty()] - [string] - $Path, - - # Specifies PsesLogEntry objects to analyze. - [Parameter(Mandatory=$true, Position=0, ParameterSetName="PsesLogEntry", ValueFromPipeline=$true)] - [ValidateNotNull()] - [psobject[]] - $LogEntry, - - # Specifies a specific LSP message for which to get response times. - [Parameter(Position=1)] - [ValidateSet( - "textDocument/codeAction", - "textDocument/codeLens", - "textDocument/completion", - "textDocument/documentSymbol", - "textDocument/foldingRange", - "textDocument/formatting", - "textDocument/hover", - "textDocument/rangeFormatting")] - [string] - $MessageName, - - # Specifies a regular expression pattern that filters the output based on the message name - # e.g. 'textDocument/.*Formatting' - [Parameter()] - [string] - $Pattern - ) - - begin { - if ($PSCmdlet.ParameterSetName -eq "Path") { - $logEntries = Parse-PsesLog $Path - } - } - - process { - if ($PSCmdlet.ParameterSetName -eq "PsesLogEntry") { - $logEntries += $LogEntry - } - } - - end { - # Populate $requests hashtable with request timestamps - $requests = @{} - - foreach ($entry in $logEntries) { - if (($entry.LogMessageType -ne 'Request') -and ($entry.LogMessageType -ne 'Response')) { continue } - - if ((!$MessageName -or ($entry.Message.Name -eq $MessageName)) -and - (!$Pattern -or ($entry.Message.Name -match $Pattern))) { - - $key = "$($entry.Message.Name)-$($entry.Message.Id)" - if ($entry.LogMessageType -eq 'Request') { - $requests[$key] = $entry - } - else { - $request = $requests[$key] - if (!$request) { - Write-Warning "No corresponding request for response: $($entry.Message)" - continue - } - - $elapsedMilliseconds = [int]($entry.Timestamp - $request.Timestamp).TotalMilliseconds - [PsesLogEntryElapsed]::new($entry, $elapsedMilliseconds) - } - } - } - } -} - -function Get-PsesScriptAnalysisCompletionTime { - [CmdletBinding(DefaultParameterSetName = "PsesLogEntry")] - param( - # Specifies a path to one or more PSES EditorServices log files. - [Parameter(Mandatory = $true, Position = 0, ParameterSetName = "Path")] - [Alias("PSPath")] - [ValidateNotNullOrEmpty()] - [string] - $Path, - - # Specifies PsesLogEntry objects to analyze. - [Parameter(Mandatory = $true, Position = 0, ParameterSetName = "PsesLogEntry", ValueFromPipeline = $true)] - [ValidateNotNull()] - [psobject[]] - $LogEntry - ) - - begin { - if ($PSCmdlet.ParameterSetName -eq "Path") { - $logEntries = Parse-PsesLog $Path - } - } - - process { - if ($PSCmdlet.ParameterSetName -eq "PsesLogEntry") { - $logEntries = $LogEntry - } - - foreach ($entry in $logEntries) { - if (($entry.LogMessageType -eq 'Log') -and ($entry.Message.Data -match '^\s*Script analysis of.*\[(?\d+)ms\]\s*$')) { - $elapsedMilliseconds = [int]$matches["ms"] - [PsesLogEntryElapsed]::new($entry, $elapsedMilliseconds) - } - } - } -} - -function Get-PsesIntelliSenseCompletionTime { - [CmdletBinding(DefaultParameterSetName = "PsesLogEntry")] - param( - # Specifies a path to one or more PSES EditorServices log files. - [Parameter(Mandatory = $true, Position = 0, ParameterSetName = "Path")] - [Alias("PSPath")] - [ValidateNotNullOrEmpty()] - [string] - $Path, - - # Specifies PsesLogEntry objects to analyze. - [Parameter(Mandatory = $true, Position = 0, ParameterSetName = "PsesLogEntry", ValueFromPipeline = $true)] - [ValidateNotNull()] - [psobject[]] - $LogEntry - ) - - begin { - if ($PSCmdlet.ParameterSetName -eq "Path") { - $logEntries = Parse-PsesLog $Path - } - } - - process { - if ($PSCmdlet.ParameterSetName -eq "PsesLogEntry") { - $logEntries = $LogEntry - } - - foreach ($entry in $logEntries) { - # IntelliSense completed in 320ms. - if (($entry.LogMessageType -eq 'Log') -and ($entry.Message.Data -match '^\s*IntelliSense completed in\s+(?\d+)ms.\s*$')) { - $elapsedMilliseconds = [int]$matches["ms"] - [PsesLogEntryElapsed]::new($entry, $elapsedMilliseconds) - } - } - } -} - -function Get-PsesMessage { - [CmdletBinding(DefaultParameterSetName = "PsesLogEntry")] - param( - # Specifies a path to one or more PSES EditorServices log files. - [Parameter(Mandatory = $true, Position = 0, ParameterSetName = "Path")] - [Alias("PSPath")] - [ValidateNotNullOrEmpty()] - [string] - $Path, - - # Specifies PsesLogEntry objects to analyze. - [Parameter(Mandatory = $true, Position = 0, ParameterSetName = "PsesLogEntry", ValueFromPipeline = $true)] - [ValidateNotNull()] - [psobject[]] - $LogEntry, - - # Specifies the log level entries to return. Default returns Normal and above. - # Use StrictMatch to return only the specified log level entries. - [Parameter()] - [PsesLogLevel] - $LogLevel = $([PsesLogLevel]::Normal), - - # Use StrictMatch to return only the specified log level entries. - [Parameter()] - [switch] - $StrictMatch - ) - - begin { - if ($PSCmdlet.ParameterSetName -eq "Path") { - $logEntries = Parse-PsesLog $Path - } - } - - process { - if ($PSCmdlet.ParameterSetName -eq "PsesLogEntry") { - $logEntries = $LogEntry - } - - foreach ($entry in $logEntries) { - if (($StrictMatch -and ($entry.LogLevel -eq $LogLevel)) -or - (!$StrictMatch -and ($entry.LogLevel -ge $LogLevel))) { - $entry - } - } - } -} diff --git a/tools/PsesLogAnalyzer/Parse-PsesLog.ps1 b/tools/PsesLogAnalyzer/Parse-PsesLog.ps1 deleted file mode 100644 index 96adbb46c..000000000 --- a/tools/PsesLogAnalyzer/Parse-PsesLog.ps1 +++ /dev/null @@ -1,288 +0,0 @@ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. - -$peekBuf = $null -$currentLineNum = 0 -$logEntryIndex = 0 - -function Parse-PsesLog { - param( - # Specifies a path to a PSES EditorServices log file. - [Parameter(Mandatory=$true, Position=0)] - [Alias("PSPath")] - [ValidateNotNullOrEmpty()] - [string] - $Path, - - # Old log file format <= v1.9.0 - [Parameter()] - [switch] - $OldLogFormat, - - # Hides the progress bar. - [Parameter()] - [switch] - $HideProgress, - - # Skips conversion from JSON & storage of the JsonRpc message body which can be large. - [Parameter()] - [switch] - $SkipRpcMessageBody, - - # Emit debug timing info on time to parse each log entry - [Parameter()] - [switch] - $DebugTimingInfo, - - # Threshold for emitting debug timing info. Default is 100 ms. - [Parameter()] - [int] - $DebugTimingThresholdMs = 100 - ) - - begin { - $script:peekBuf = $null - $script:currentLineNum = 1 - $script:logEntryIndex = 0 - - if ($OldLogFormat) { - # Example old log entry start: - # 2018-11-15 19:49:06.979 [NORMAL] C:\PowerShellEditorServices\src\PowerShellEditorServices.Host\EditorServicesHost.cs: In method 'StartLogging', line 160: - $logEntryRegex = - [regex]::new( - '^(?[^\[]+)\[(?([^\]]+))\]\s+(?..[^:]+):\s+In method\s+''(?\w+)'',\s+line\s+(?\d+)', - [System.Text.RegularExpressions.RegexOptions]::Compiled -bor [System.Text.RegularExpressions.RegexOptions]::IgnoreCase) - } - else { - # Example new log entry start: - # 2018-11-24 12:26:58.302 [DIAGNOSTIC] tid:28 in 'ReadMessage' C:\Users\Keith\GitHub\rkeithhill\PowerShellEditorServices\src\PowerShellEditorServices.Protocol\MessageProtocol\MessageReader.cs: line 114 - $logEntryRegex = - [regex]::new( - '^(?[^\[]+)\[(?([^\]]+))\]\s+tid:(?\d+)\s+in\s+''(?\w+)''\s+(?..[^:]+):\s+line\s+(?\d+)', - [System.Text.RegularExpressions.RegexOptions]::Compiled -bor [System.Text.RegularExpressions.RegexOptions]::IgnoreCase) - } - - $filestream = - [System.IO.FileStream]::new( - $Path, - [System.IO.FileMode]:: Open, - [System.IO.FileAccess]::Read, - [System.IO.FileShare]::ReadWrite, - 4096, - [System.IO.FileOptions]::SequentialScan) - $streamReader = [System.IO.StreamReader]::new($filestream, [System.Text.Encoding]::UTF8) - - # Count number of lines so we can provide % progress while parsing - $numLines = 0 - while ($null -ne $streamReader.ReadLine()) { - $numLines++ - } - - # Recreate the stream & reader. Tried seeking to 0 on the stream and having the - # reader discard buffered data but still wound up with in an invalid $log[0] entry. - $streamReader.Dispose() - $filestream = - [System.IO.FileStream]::new( - $Path, - [System.IO.FileMode]:: Open, - [System.IO.FileAccess]::Read, - [System.IO.FileShare]::ReadWrite, - 4096, - [System.IO.FileOptions]::SequentialScan) - $streamReader = [System.IO.StreamReader]::new($filestream, [System.Text.Encoding]::UTF8) - - function nextLine() { - if ($null -ne $peekBuf) { - $line = $peekBuf - $script:peekBuf = $null - } - else { - $line = $streamReader.ReadLine() - } - - $script:currentLineNum++ - $line - } - - function peekLine() { - if ($null -ne $peekBuf) { - $line = $peekBuf; - } - else { - $line = $script:peekBuf = $streamReader.ReadLine() - } - - $line - } - - function parseLogEntryStart([string]$line) { - if ($DebugTimingInfo) { - $sw = [System.Diagnostics.Stopwatch]::StartNew() - } - - while ($line -notmatch $logEntryRegex) { - Write-Warning "Ignoring line:${currentLineNum} '$line'" - $line = nextLine - } - - if (!$HideProgress -and ($script:logEntryIndex % 100 -eq 0)) { - Write-Progress "Processing log entry ${script:logEntryIndex} on line: ${script:currentLineNum}" ` - -PercentComplete (100 * $script:currentLineNum / $numLines) - } - - [string]$timestampStr = $matches["ts"] - [DateTime]$timestamp = $timestampStr - [PsesLogLevel]$logLevel = $matches["lev"] - [int]$threadId = $matches["tid"] - [string]$method = $matches["meth"] - [string]$file = $matches["file"] - [int]$lineNumber = $matches["line"] - - $message = parseLogMessage $method - - [PsesLogEntry]::new($script:logEntryIndex, $timestamp, $timestampStr, $logLevel, $threadId, $method, - $file, $lineNumber, $message.LogMessageType, $message.LogMessage) - - if ($DebugTimingInfo) { - $sw.Stop() - if ($sw.ElapsedMilliseconds -gt $DebugTimingThresholdMs) { - Write-Warning "Time to parse log entry ${script:logEntryIndex} - $($sw.ElapsedMilliseconds) ms" - } - } - - $script:logEntryIndex++ - } - - function parseLogMessage([string]$Method) { - $result = [PSCustomObject]@{ - LogMessageType = [PsesLogMessageType]::Log - LogMessage = $null - } - - $line = nextLine - if ($null -eq $line) { - Write-Warning "$($MyInvocation.MyCommand.Name) encountered end of file early." - return $result - } - - if (($Method -eq 'ReadMessageAsync' -or $Method -eq 'ReadMessage') -and - ($line -match '^\s+Received Request ''(?[^'']+)'' with id (?\d+)')) { - $result.LogMessageType = [PsesLogMessageType]::Request - $msg = $matches["msg"] - $id = $matches["id"] - $json = parseLogMessageBodyAsJson - $result.LogMessage = [PsesJsonRpcMessage]::new($msg, $id, $json.Data, $json.DataSize) - } - elseif (($Method -eq 'ReadMessageAsync' -or $Method -eq 'ReadMessage') -and - ($line -match '^\s+Received event ''(?[^'']+)''')) { - $result.LogMessageType = [PsesLogMessageType]::Notification - $msg = $matches["msg"] - $json = parseLogMessageBodyAsJson - $result.LogMessage = [PsesNotificationMessage]::new($msg, [PsesNotificationSource]::Client, $json.Data, $json.DataSize) - } - elseif (($Method -eq 'WriteMessageAsync' -or $Method -eq 'WriteMessage') -and - ($line -match '^\s+Writing Response ''(?[^'']+)'' with id (?\d+)')) { - $result.LogMessageType = [PsesLogMessageType]::Response - $msg = $matches["msg"] - $id = $matches["id"] - $json = parseLogMessageBodyAsJson - $result.LogMessage = [PsesJsonRpcMessage]::new($msg, $id, $json.Data, $json.DataSize) - } - elseif (($Method -eq 'WriteMessageAsync' -or $Method -eq 'WriteMessage') -and - ($line -match '^\s+Writing event ''(?[^'']+)''')) { - $result.LogMessageType = [PsesLogMessageType]::Notification - $msg = $matches["msg"] - $json = parseLogMessageBodyAsJson - $result.LogMessage = [PsesNotificationMessage]::new($msg, [PsesNotificationSource]::Server, $json.Data, $json.DataSize) - } - else { - if ($line -match '^\s+Exception: ') { - $result.LogMessageType = [PsesLogMessageType]::Exception - } - elseif ($line -match '^\s+Handled exception: ') { - $result.LogMessageType = [PsesLogMessageType]::HandledException - } - else { - $result.LogMessageType = [PsesLogMessageType]::Log - } - - $body = parseLogMessageBody $line - $result.LogMessage = [PsesLogMessage]::new($body) - } - - $result - } - - function parseLogMessageBody([string]$startLine = '', [switch]$Discard) { - if (!$Discard) { - $strBld = [System.Text.StringBuilder]::new($startLine, 4096) - $newLine = "`r`n" - } - - try { - while ($true) { - $peekLine = peekLine - if ($null -eq $peekLine) { - break - } - - if (($peekLine.Length -gt 0) -and ($peekLine[0] -ne ' ') -and ($peekLine -match $logEntryRegex)) { - break - } - - $nextLine = nextLine - if (!$Discard) { - [void]$strBld.Append($nextLine).Append($newLine) - } - } - } - catch { - Write-Error "Failed parsing message body with error: $_" - } - - if (!$Discard) { - $msgBody = $strBld.ToString().Trim() - $msgBody - } - else { - $startLine - } - } - - function parseLogMessageBodyAsJson() { - $result = [PSCustomObject]@{ - Data = $null - DataSize = 0 - } - - $obj = $null - - if ($SkipRpcMessageBody) { - parseLogMessageBody -Discard - return $result - } - - $result.Data = parseLogMessageBody - $result.DataSize = $result.Data.Length - - try { - $result.Data = $result.Data.Trim() | ConvertFrom-Json - } - catch { - Write-Error "Failed parsing JSON message body with error: $_" - } - - $result - } - } - - process { - while ($null -ne ($line = nextLine)) { - parseLogEntryStart $line - } - } - - end { - if ($streamReader) { $streamReader.Dispose() } - } -} diff --git a/tools/PsesLogAnalyzer/PsesLogAnalyzer.format.ps1xml b/tools/PsesLogAnalyzer/PsesLogAnalyzer.format.ps1xml deleted file mode 100644 index 5c6ba1823..000000000 --- a/tools/PsesLogAnalyzer/PsesLogAnalyzer.format.ps1xml +++ /dev/null @@ -1,123 +0,0 @@ - - - - PsesLogEntry - - PsesLogEntry - - - - - - 6 - right - - - - 24 - left - - - - 5 - right - - - - 15 - left - - - - 11 - left - - - - left - - - - - - - Index - - - TimestampStr - - - ThreadId - - - LogMessageType - - - LogLevel - - - ($_.Message -split "`r`n")[0] - - - - - - - - - PsesLogEntryElapsed - - PsesLogEntryElapsed - - - - - - 6 - right - - - - 24 - left - - - - 5 - right - - - - 13 - right - - - - left - - - - - - - Index - - - TimestampStr - - - ThreadId - - - $_.ElapsedMilliseconds - - - $_.Message - - - - - - - - diff --git a/tools/PsesLogAnalyzer/PsesLogAnalyzer.psd1 b/tools/PsesLogAnalyzer/PsesLogAnalyzer.psd1 deleted file mode 100644 index d8f963df4..000000000 --- a/tools/PsesLogAnalyzer/PsesLogAnalyzer.psd1 +++ /dev/null @@ -1,130 +0,0 @@ -# -# Module manifest for module 'Pses-LogAnalyzer' -# -# Generated by: Keith -# -# Generated on: 11/23/2018 -# - -@{ - -# Script module or binary module file associated with this manifest. -RootModule = 'PsesLogAnalyzer.psm1' - -# Version number of this module. -ModuleVersion = '1.0.0' - -# Supported PSEditions -# CompatiblePSEditions = @() - -# ID used to uniquely identify this module -GUID = '99116548-ad0f-4087-a425-7edab3aa9e57' - -# Author of this module -Author = 'Microsoft' - -# Company or vendor of this module -CompanyName = 'Microsoft' - -# Copyright statement for this module -Copyright = '(c) 2021 Microsoft Corporation.' - -# Description of the functionality provided by this module -Description = 'PowerShellEditorServices log file parser and analysis commands.' - -# Minimum version of the PowerShell engine required by this module -PowerShellVersion = '5.1' - -# Name of the PowerShell host required by this module -# PowerShellHostName = '' - -# Minimum version of the PowerShell host required by this module -# PowerShellHostVersion = '' - -# Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only. -# DotNetFrameworkVersion = '' - -# Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only. -# CLRVersion = '' - -# Processor architecture (None, X86, Amd64) required by this module -# ProcessorArchitecture = '' - -# Modules that must be imported into the global environment prior to importing this module -# RequiredModules = @() - -# Assemblies that must be loaded prior to importing this module -# RequiredAssemblies = @() - -# Script files (.ps1) that are run in the caller's environment prior to importing this module. -# ScriptsToProcess = @() - -# Type files (.ps1xml) to be loaded when importing this module -# TypesToProcess = @() - -# Format files (.ps1xml) to be loaded when importing this module -FormatsToProcess = @('PsesLogAnalyzer.format.ps1xml') - -# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess -# NestedModules = @() - -# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export. -FunctionsToExport = @( - 'Parse-PsesLog', - 'Get-PsesRpcMessageResponseTime', - 'Get-PsesRpcNotificationMessage', - 'Get-PsesScriptAnalysisCompletionTime', - 'Get-PsesIntelliSenseCompletionTime', - 'Get-PsesMessage' -) - -# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export. -CmdletsToExport = @() - -# Variables to export from this module -VariablesToExport = '' - -# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export. -AliasesToExport = @() - -# DSC resources to export from this module -# DscResourcesToExport = @() - -# List of all modules packaged with this module -# ModuleList = @() - -# List of all files packaged with this module -# FileList = @() - -# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell. -PrivateData = @{ - - PSData = @{ - - # Tags applied to this module. These help with module discovery in online galleries. - # Tags = @() - - # A URL to the license for this module. - # LicenseUri = '' - - # A URL to the main website for this project. - # ProjectUri = '' - - # A URL to an icon representing this module. - # IconUri = '' - - # ReleaseNotes of this module - # ReleaseNotes = '' - - } # End of PSData hashtable - -} # End of PrivateData hashtable - -# HelpInfo URI of this module -# HelpInfoURI = '' - -# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix. -# DefaultCommandPrefix = '' - -} - diff --git a/tools/PsesLogAnalyzer/PsesLogAnalyzer.psm1 b/tools/PsesLogAnalyzer/PsesLogAnalyzer.psm1 deleted file mode 100644 index 700946c40..000000000 --- a/tools/PsesLogAnalyzer/PsesLogAnalyzer.psm1 +++ /dev/null @@ -1,3 +0,0 @@ -. $PSScriptRoot\Types.ps1 -. $PSScriptRoot\Parse-PsesLog.ps1 -. $PSScriptRoot\Analyze.ps1 diff --git a/tools/PsesLogAnalyzer/Types.ps1 b/tools/PsesLogAnalyzer/Types.ps1 deleted file mode 100644 index 0ab62b748..000000000 --- a/tools/PsesLogAnalyzer/Types.ps1 +++ /dev/null @@ -1,157 +0,0 @@ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. - -enum PsesLogLevel { - Diagnostic - Verbose - Normal - Warning - Error -} - -enum PsesLogMessageType { - Log - Exception - HandledException - Request - Response - Notification -} - -enum PsesNotificationSource { - Unknown - Client - Server -} - -class PsesLogMessage { - [string]$Data - [int]$DataSize - - PsesLogMessage([string]$Data) { - $this.Data = $Data - $this.DataSize = $Data.Length - } - - [string] ToString() { - $ofs = '' - $ellipsis = if ($this.Data.Length -ge 100) { "..." } else { "" } - return "$($this.Data[0..99])$ellipsis, DataSize: $($this.Data.Length)" - } -} - -class PsesJsonRpcMessage { - [string]$Name - [int]$Id - [psobject]$Data - [int]$DataSize - - PsesJsonRpcMessage([string]$Name, [int]$Id, [psobject]$Data, [int]$DataSize) { - $this.Name = $Name - $this.Id = $Id - $this.Data = $Data - $this.DataSize = $DataSize - } - - [string] ToString() { - return "Name: $($this.Name) Id: $($this.Id), DataSize: $($this.DataSize)" - } -} - -class PsesNotificationMessage { - [string]$Name - [PsesNotificationSource]$Source - [psobject]$Data - [int]$DataSize - - PsesNotificationMessage([string]$Name, [PsesNotificationSource]$Source, [psobject]$Data, [int]$DataSize) { - $this.Name = $Name - $this.Source = $Source - $this.Data = $Data - $this.DataSize = $DataSize - } - - [string] ToString() { - if (($this.Name -eq '$/cancelRequest') -and ($this.Data -ne $null)) { - return "Name: $($this.Name) Source: $($this.Source), Id: $($this.Data.params.id)" - } - - return "Name: $($this.Name) Source: $($this.Source), DataSize: $($this.DataSize)" - } -} - -class PsesLogEntry { - [int]$Index - [DateTime]$Timestamp - [string]$TimestampStr - [PsesLogLevel]$LogLevel - [int]$ThreadId - [string]$Method - [string]$File - [int]$LineNumber - [PsesLogMessageType]$LogMessageType - [psobject]$Message - - PsesLogEntry( - [int] - $Index, - [DateTime] - $Timestamp, - [string] - $TimestampStr, - [PsesLogLevel] - $LogLevel, - [int] - $ThreadId, - [string] - $Method, - [string] - $File, - [int] - $LineNumber, - [PsesLogMessageType] - $LogMessageType, - [psobject] - $Message) { - - $this.Index = $Index - $this.Timestamp = $Timestamp - $this.TimestampStr = $TimestampStr - $this.LogLevel = $LogLevel - $this.ThreadId = $ThreadId - $this.Method = $Method - $this.File = $File - $this.LineNumber = $LineNumber - $this.LogMessageType = $LogMessageType - $this.Message = $Message - } -} - -class PsesLogEntryElapsed { - [int]$Index - [DateTime]$Timestamp - [string]$TimestampStr - [int]$ElapsedMilliseconds - [PsesLogLevel]$LogLevel - [int]$ThreadId - [string]$Method - [string]$File - [int]$LineNumber - [PsesLogMessageType]$LogMessageType - [psobject]$Message - - PsesLogEntryElapsed([PsesLogEntry]$LogEntry, [int]$ElapsedMilliseconds) { - $this.Index = $LogEntry.Index - $this.Timestamp = $LogEntry.Timestamp - $this.TimestampStr = $LogEntry.TimestampStr - $this.LogLevel = $LogEntry.LogLevel - $this.ThreadId = $LogEntry.ThreadId - $this.Method = $LogEntry.Method - $this.File = $LogEntry.File - $this.LineNumber = $LogEntry.LineNumber - $this.LogMessageType = $LogEntry.LogMessageType - $this.Message = $LogEntry.Message - - $this.ElapsedMilliseconds = $ElapsedMilliseconds - } -} diff --git a/tools/releaseBuild/FileCatalogSigning.xml b/tools/releaseBuild/FileCatalogSigning.xml deleted file mode 100644 index e8fd287a6..000000000 --- a/tools/releaseBuild/FileCatalogSigning.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - -