diff --git a/.editorconfig b/.editorconfig
index e0f9bbf3f..b4753066b 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -13,6 +13,33 @@ trim_trailing_whitespace = true
csharp_space_before_open_square_brackets = true
csharp_space_after_keywords_in_control_flow_statements = true
+# CS0168: The variable 'var' is declared but never used
+dotnet_diagnostic.CS0168.severity = error
+# CS0169: The private field 'class member' is never used
+dotnet_diagnostic.CS0169.severity = error
+# CS0219: The variable 'variable' is assigned but its value is never used
+dotnet_diagnostic.CS0219.severity = error
+# CS0414: The private field 'field' is assigned but its value is never used
+dotnet_diagnostic.CS0414.severity = error
+# CA1068: CancellationToken parameters must come last
+dotnet_diagnostic.CA1068.severity = error
+# CA1822: Mark members as static
+dotnet_diagnostic.CA1822.severity = error
+# CA1823: Avoid unused private fields
+dotnet_diagnostic.CA1823.severity = error
+# CA2007: Do not directly await a Task
+dotnet_diagnostic.CA2007.severity = error
+# CA2016: Forward the CancellationToken parameter to methods that take one
+dotnet_diagnostic.CA2016.severity = error
+# All maintainability issues (dead code etc.)
+# See: https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/maintainability-warnings
+dotnet_analyzer_diagnostic.category-Maintainability.severity = error
+# VSTHRD002: Synchronously waiting on tasks or awaiters may cause deadlocks
+# TODO: Fix all of these issues and explicitly ignore the intentional ones.
+dotnet_diagnostic.VSTHRD002.severity = silent
+# VSTHRD200: Use "Async" suffix for awaitable methods
+dotnet_diagnostic.VSTHRD200.severity = silent
+
[*.{json}]
indent_size = 2
trim_trailing_whitespace = true
diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS
index 76be6cf65..4d54b18d7 100644
--- a/.github/CODEOWNERS
+++ b/.github/CODEOWNERS
@@ -1,7 +1,7 @@
# https://help.github.com/articles/about-codeowners/
# Global reviewers
-* @tylerl0706 @rjmholt
+* @andschwa @rjmholt
# Area: Analysis & Formatting
src/PowerShellEditorServices/Analysis/ @rjmholt
diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml
index 31d0cd118..cf4227d7a 100644
--- a/.github/workflows/codeql-analysis.yml
+++ b/.github/workflows/codeql-analysis.yml
@@ -37,7 +37,7 @@ jobs:
- name: Build
shell: pwsh
- run: scripts/azurePipelinesBuild.ps1
+ run: tools/azurePipelinesBuild.ps1
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
diff --git a/.vsts-ci/azure-pipelines-ci.yml b/.vsts-ci/azure-pipelines-ci.yml
index d9ff9a82d..25706f2c0 100644
--- a/.vsts-ci/azure-pipelines-ci.yml
+++ b/.vsts-ci/azure-pipelines-ci.yml
@@ -9,58 +9,49 @@ variables:
value: 'true'
trigger:
- batch: true
branches:
include:
- master
- - legacy/1.x
- paths:
- exclude:
- - /.dependabot/*
- - /.poshchan/*
- - /.github/**/*
- - /.vscode/**/*
- - /.vsts-ci/misc-analysis.yml
- - /tools/**/*
- - .editorconfig
- - .gitattributes
- - .gitignore
- - /docs/**/*
- - /CHANGELOG.md
- - /CONTRIBUTING.md
- - /README.md
- - /LICENSE
- - /CODE_OF_CONDUCT.md
-# TODO: Setup matrix of image support.
+pr:
+- master
+
jobs:
-- job: 'PS51_Win10'
- displayName: PowerShell 5.1 | Windows 10
+- job: PS51_Win2016
+ displayName: PowerShell 5.1 - Windows Server 2016
+ pool:
+ vmImage: vs2017-win2016
+ steps:
+ - template: templates/ci-general.yml
+ parameters:
+ pwsh: false
+
+- job: PS51_Win2019
+ displayName: PowerShell 5.1 - Windows Server 2019
pool:
- # TODO: Update this image.
- vmImage: 'vs2017-win2016'
+ vmImage: windows-2019
steps:
- template: templates/ci-general.yml
parameters:
pwsh: false
-- job: 'PS7_Win10'
- displayName: PowerShell 7 | Windows 10
+- job: PS7_Win2019
+ displayName: PowerShell 7 - Windows Server 2019
pool:
- vmImage: 'windows-2019'
+ vmImage: windows-2019
steps:
- template: templates/ci-general.yml
-- job: 'PS7_macOS'
- displayName: PowerShell 7 | macOS
+- job: PS7_macOS
+ displayName: PowerShell 7 - macOS 10.15
pool:
- vmImage: 'macOS-10.15'
+ vmImage: macOS-10.15
steps:
- template: templates/ci-general.yml
-- job: 'PS7_Ubuntu'
- displayName: PowerShell 7 | Ubuntu
+- job: PS7_Ubuntu
+ displayName: PowerShell 7 - Ubuntu 20.04
pool:
- vmImage: 'ubuntu-20.04'
+ vmImage: ubuntu-20.04
steps:
- template: templates/ci-general.yml
diff --git a/.vsts-ci/azure-pipelines-release.yml b/.vsts-ci/azure-pipelines-release.yml
index 4b861a570..e3e1d934a 100644
--- a/.vsts-ci/azure-pipelines-release.yml
+++ b/.vsts-ci/azure-pipelines-release.yml
@@ -1,3 +1,5 @@
+name: Release-$(Build.SourceBranchName)-$(Date:yyyyMMdd)$(Rev:.rr)
+
variables:
# Don't download unneeded packages
- name: DOTNET_SKIP_FIRST_TIME_EXPERIENCE
@@ -9,33 +11,51 @@ variables:
trigger:
branches:
include:
- - release/*
- tags:
- include:
- - v*
+ - release
resources:
repositories:
- repository: ComplianceRepo
type: github
- endpoint: ComplianceGHRepo
+ endpoint: GitHub
name: PowerShell/compliance
+ - repository: vscode-powershell
+ type: git
+ name: vscode-powershell
+
+stages:
+- stage: Build
+ displayName: Build the release
+ jobs:
+ - job: Build
+ pool:
+ vmImage: windows-2019
+ steps:
+ - template: templates/ci-general.yml
-jobs:
-- job: 'ReleaseBuild'
- displayName: 'Build release'
- pool:
- vmImage: 'vs2017-win2016'
- steps:
- - template: templates/ci-general.yml
+- stage: Sign
+ displayName: Sign the release
+ jobs:
+ - job: Sign
+ pool:
+ name: 1ES
+ demands: ImageOverride -equals MMS2019
+ variables:
+ - group: ESRP
+ steps:
+ - template: templates/release-general.yml
-- job: 'SignBuild'
- displayName: Signing Build
- dependsOn: 'ReleaseBuild'
- pool:
- name: '1ES'
- demands: ImageOverride -equals MMS2019
- variables:
- - group: ESRP
- steps:
- - template: templates/release-general.yml
+- stage: Publish
+ displayName: Publish the draft release
+ jobs:
+ - deployment: Publish
+ environment: PowerShellEditorServices
+ pool:
+ vmImage: ubuntu-latest
+ variables:
+ - group: Publish
+ strategy:
+ runOnce:
+ deploy:
+ steps:
+ - template: templates/publish-general.yml
diff --git a/.vsts-ci/misc-analysis.yml b/.vsts-ci/misc-analysis.yml
index 1c229a7ae..2647eb182 100644
--- a/.vsts-ci/misc-analysis.yml
+++ b/.vsts-ci/misc-analysis.yml
@@ -1,31 +1,25 @@
name: PR-$(System.PullRequest.PullRequestNumber)-$(Date:yyyyMMdd)$(Rev:.rr)
+
trigger:
- # Batch merge builds together while a merge build is running
- batch: true
branches:
include:
- master
pr:
- branches:
- include:
- - master
- - legacy/1.x
+- master
resources:
repositories:
- repository: ComplianceRepo
type: github
- endpoint: ComplianceGHRepo
+ endpoint: GitHub
name: PowerShell/compliance
jobs:
-- job: Compliance_Job
+- job: Compliance
pool:
vmImage: windows-latest
steps:
- checkout: self
- clean: true
- checkout: ComplianceRepo
- clean: true
- template: ci-compliance.yml@ComplianceRepo
diff --git a/.vsts-ci/templates/ci-general.yml b/.vsts-ci/templates/ci-general.yml
index 34b81b7c1..016b340dc 100644
--- a/.vsts-ci/templates/ci-general.yml
+++ b/.vsts-ci/templates/ci-general.yml
@@ -1,43 +1,36 @@
parameters:
- pwsh: true
+- name: pwsh
+ type: boolean
+ default: true
steps:
- - powershell: |
- Write-Host "Installing PowerShell Daily..."
+- pwsh: $PSVersionTable
+ displayName: PowerShell version
- # Use `AGENT_TEMPDIRECTORY` to make sure the downloaded PowerShell is cleaned up.
- $powerShellPath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath 'powershell'
- Invoke-WebRequest -Uri https://aka.ms/install-powershell.ps1 -OutFile ./install-powershell.ps1
+- task: PowerShell@2
+ displayName: Build and test
+ inputs:
+ filePath: tools/azurePipelinesBuild.ps1
+ pwsh: ${{ parameters.pwsh }}
- ./install-powershell.ps1 -Destination $powerShellPath -Daily
+# NOTE: We zip the artifacts because they're ~20 MB compressed, but ~300 MB raw,
+# and we have limited pipeline artifact storage space.
+- task: ArchiveFiles@2
+ displayName: Zip pipeline artifacts
+ inputs:
+ rootFolderOrFile: module
+ includeRootFolder: false
+ archiveType: zip
+ archiveFile: PowerShellEditorServices-Build.zip
+ verbose: true
- # Using `prependpath` to update the PATH just for this build.
- Write-Host "##vso[task.prependpath]$powerShellPath"
- displayName: Install PowerShell Daily
- continueOnError: true
+- publish: PowerShellEditorServices-Build.zip
+ artifact: PowerShellEditorServices-Build-$(System.JobId)
+ displayName: Publish unsigned pipeline artifacts
- - pwsh: '$PSVersionTable'
- displayName: Display PowerShell version information
-
- - pwsh: Write-Host "##vso[build.updatebuildnumber]$env:BUILD_SOURCEBRANCHNAME-$env:BUILD_SOURCEVERSION-$((get-date).ToString("yyyyMMddhhmmss"))"
- displayName: Set Build Name for Non-PR
- condition: ne(variables['Build.Reason'], 'PullRequest')
- - task: PowerShell@2
- inputs:
- filePath: scripts/azurePipelinesBuild.ps1
- pwsh: ${{ parameters.pwsh }}
- - task: PublishTestResults@2
- inputs:
- testRunner: VSTest
- testResultsFiles: '**/*.trx'
- condition: succeededOrFailed()
- - task: PublishTestResults@2
- inputs:
- testRunner: NUnit
- testResultsFiles: '**/TestResults.xml'
- condition: succeededOrFailed()
- - task: PublishBuildArtifacts@1
- inputs:
- ArtifactName: PowerShellEditorServices-CI
- PathtoPublish: '$(Build.ArtifactStagingDirectory)'
- condition: succeededOrFailed()
+- task: PublishTestResults@2
+ displayName: Publish test results
+ inputs:
+ testRunner: VSTest
+ testResultsFiles: '**/*.trx'
+ condition: succeededOrFailed()
diff --git a/.vsts-ci/templates/publish-general.yml b/.vsts-ci/templates/publish-general.yml
new file mode 100644
index 000000000..cb26033b3
--- /dev/null
+++ b/.vsts-ci/templates/publish-general.yml
@@ -0,0 +1,12 @@
+steps:
+- checkout: self
+- checkout: vscode-powershell
+
+- download: current
+ artifact: PowerShellEditorServices
+ displayName: Download signed pipeline artifacts
+
+- pwsh: |
+ $(Build.SourcesDirectory)/vscode-powershell/tools/setupReleaseTools.ps1 -Token $(GitHubToken)
+ New-DraftRelease -RepositoryName PowerShellEditorServices -Assets $(Pipeline.Workspace)/PowerShellEditorServices/PowerShellEditorServices.zip
+ displayName: Drafting a GitHub Release
diff --git a/.vsts-ci/templates/release-general.yml b/.vsts-ci/templates/release-general.yml
index 9a9ec2029..7ef4e1479 100644
--- a/.vsts-ci/templates/release-general.yml
+++ b/.vsts-ci/templates/release-general.yml
@@ -1,27 +1,26 @@
steps:
-
-- task: DownloadBuildArtifacts@0
- displayName: 'Download Build Artifacts'
- inputs:
- downloadType: specific
+- download: current
+ displayName: Download unsigned pipeline artifacts
- task: ExtractFiles@1
- displayName: 'Extract Build Zip'
+ displayName: Extract unsigned artifacts
inputs:
- archiveFilePatterns: '$(Build.ArtifactStagingDirectory)/PowerShellEditorServices-CI/PowerShellEditorServices*.zip'
- destinationFolder: '$(Build.ArtifactStagingDirectory)/PowerShellEditorServices'
+ archiveFilePatterns: $(Pipeline.Workspace)/PowerShellEditorServices-Build-*/PowerShellEditorServices-Build.zip
+ destinationFolder: $(Pipeline.Workspace)/Unsigned
+ cleanDestinationFolder: true
- checkout: ComplianceRepo
- displayName: 'Checkout the ComplianceRepo'
+# NOTE: The signing templates explicitly copy everything along as they run, so
+# the last output path has every signed (and intentionally unsigned) file.
- template: EsrpSign.yml@ComplianceRepo
parameters:
- buildOutputPath: '$(Build.ArtifactStagingDirectory)/PowerShellEditorServices'
- signOutputPath: '$(Build.ArtifactStagingDirectory)/FirstPartySigned'
- alwaysCopy: true # So publishing works
- certificateId: 'CP-230012' # Authenticode certificate
- useMinimatch: true # This enables the use of globbing
+ buildOutputPath: $(Pipeline.Workspace)/Unsigned
+ signOutputPath: $(Pipeline.Workspace)/FirstPartySigned
+ alwaysCopy: true
+ certificateId: CP-230012 # Authenticode certificate
shouldSign: true # We always want to sign
+ useMinimatch: true # This enables the use of globbing
pattern: |
# PowerShellEditorServices Script
PowerShellEditorServices/*.{ps1,psd1,psm1,ps1xml}
@@ -35,12 +34,12 @@ steps:
- template: EsrpSign.yml@ComplianceRepo
parameters:
- buildOutputPath: '$(Build.ArtifactStagingDirectory)/FirstPartySigned'
- signOutputPath: '$(Build.ArtifactStagingDirectory)/ThirdPartySigned'
- alwaysCopy: true # So publishing works
- certificateId: 'CP-231522' # Third-party certificate
- useMinimatch: true # This enables the use of globbing
+ buildOutputPath: $(Pipeline.Workspace)/FirstPartySigned
+ signOutputPath: $(Pipeline.Workspace)/ThirdPartySigned
+ alwaysCopy: true
+ certificateId: CP-231522 # Third-party certificate
shouldSign: true # We always want to sign
+ useMinimatch: true # This enables the use of globbing
pattern: |
**/MediatR.dll
**/Nerdbank.Streams.dll
@@ -49,27 +48,37 @@ steps:
**/Serilog*.dll
**/UnixConsoleEcho.dll
-- publish: $(Build.ArtifactStagingDirectory)/ThirdPartySigned
- artifact: PowerShellEditorServices
- displayName: 'Publish signed (and unsigned) artifacts'
+- task: ArchiveFiles@2
+ displayName: Zip signed artifacts
+ inputs:
+ rootFolderOrFile: $(Pipeline.Workspace)/ThirdPartySigned
+ includeRootFolder: false
+ archiveType: zip
+ archiveFile: PowerShellEditorServices.zip
+ replaceExistingArchive: true
+ verbose: true
- checkout: self
- template: assembly-module-compliance.yml@ComplianceRepo
parameters:
# binskim
- AnalyzeTarget: '$(Build.ArtifactStagingDirectory)/*.dll'
+ AnalyzeTarget: $(Pipeline.Workspace)/*.dll
AnalyzeSymPath: 'SRV*'
# component-governance
- sourceScanPath: '$(Build.SourcesDirectory)/PowerShellEditorServices'
+ sourceScanPath: $(Build.SourcesDirectory)/PowerShellEditorServices
# credscan
suppressionsFile: ''
# TermCheck AKA PoliCheck
- targetArgument: '$(Build.SourcesDirectory)/PowerShellEditorServices'
- optionsUEPATH: '$(Build.SourcesDirectory)/PowerShellEditorServices/tools/terms/UserExclusions.xml'
+ targetArgument: $(Build.SourcesDirectory)/PowerShellEditorServices
+ optionsUEPATH: $(Build.SourcesDirectory)/PowerShellEditorServices/tools/terms/UserExclusions.xml
optionsRulesDBPath: ''
- optionsFTPath: '$(Build.SourcesDirectory)/PowerShellEditorServices/tools/terms/FileTypeSet.xml'
+ optionsFTPath: $(Build.SourcesDirectory)/PowerShellEditorServices/tools/terms/FileTypeSet.xml
# tsa-upload
- codeBaseName: 'PowerShell_PowerShellEditorServices_20210201'
- # selections
+ codeBaseName: PowerShell_PowerShellEditorServices_20210201
+ # We don't use any Windows APIs directly, so we don't need API scan
APIScan: false
+
+- publish: PowerShellEditorServices.zip
+ artifact: PowerShellEditorServices
+ displayName: Publish signed pipeline artifacts
diff --git a/PowerShellEditorServices.Common.props b/PowerShellEditorServices.Common.props
index ea41c7b43..59da7d55c 100644
--- a/PowerShellEditorServices.Common.props
+++ b/PowerShellEditorServices.Common.props
@@ -11,5 +11,8 @@
git
https://github.com/PowerShell/PowerShellEditorServices
portable
+
+ true
+
diff --git a/PowerShellEditorServices.build.ps1 b/PowerShellEditorServices.build.ps1
index fbd126708..60274440e 100644
--- a/PowerShellEditorServices.build.ps1
+++ b/PowerShellEditorServices.build.ps1
@@ -146,31 +146,6 @@ task Clean BinClean,{
}
}
-task GetProductVersion -Before PackageModule, UploadArtifacts {
- [xml]$props = Get-Content .\PowerShellEditorServices.Common.props
-
- $script:BuildNumber = 9999
- $script:VersionSuffix = $props.Project.PropertyGroup.VersionSuffix
-
- if ($env:TF_BUILD) {
- # SYSTEM_PHASENAME is the Job name.
- # Job names can only include `_` but that's not a valid character for versions.
- $jobname = $env:SYSTEM_PHASENAME -replace '_', ''
- $script:BuildNumber = "$jobname-$env:BUILD_BUILDID"
- }
-
- if ($script:VersionSuffix -ne $null) {
- $script:VersionSuffix = "$script:VersionSuffix-$script:BuildNumber"
- }
- else {
- $script:VersionSuffix = "$script:BuildNumber"
- }
-
- $script:FullVersion = "$($props.Project.PropertyGroup.VersionPrefix)-$script:VersionSuffix"
-
- Write-Host "`n### Product Version: $script:FullVersion`n" -ForegroundColor Green
-}
-
task CreateBuildInfo -Before Build {
$buildVersion = ""
$buildOrigin = "Development"
@@ -435,17 +410,5 @@ task BuildCmdletHelp {
New-ExternalHelp -Path $PSScriptRoot\module\PowerShellEditorServices.VSCode\docs -OutputPath $PSScriptRoot\module\PowerShellEditorServices.VSCode\en-US -Force
}
-task PackageModule {
- [System.IO.Compression.ZipFile]::CreateFromDirectory(
- "$PSScriptRoot/module/",
- "$PSScriptRoot/PowerShellEditorServices-$($script:FullVersion).zip",
- [System.IO.Compression.CompressionLevel]::Optimal,
- $false)
-}
-
-task UploadArtifacts -If ($null -ne $env:TF_BUILD) {
- Copy-Item -Path .\PowerShellEditorServices-$($script:FullVersion).zip -Destination $env:BUILD_ARTIFACTSTAGINGDIRECTORY -Force
-}
-
# The default task is to run the entire CI build
-task . GetProductVersion, Clean, Build, Test, BuildCmdletHelp, PackageModule, UploadArtifacts
+task . Clean, Build, Test, BuildCmdletHelp
diff --git a/src/PowerShellEditorServices.Hosting/Commands/InvokeReadLineForEditorServicesCommand.cs b/src/PowerShellEditorServices.Hosting/Commands/InvokeReadLineForEditorServicesCommand.cs
index b0adf6fc8..0cfa675d3 100644
--- a/src/PowerShellEditorServices.Hosting/Commands/InvokeReadLineForEditorServicesCommand.cs
+++ b/src/PowerShellEditorServices.Hosting/Commands/InvokeReadLineForEditorServicesCommand.cs
@@ -2,6 +2,7 @@
// Licensed under the MIT License.
using System;
+using System.Linq;
using System.Management.Automation;
using System.Management.Automation.Runspaces;
using System.Reflection;
@@ -24,7 +25,7 @@ private delegate string ReadLineInvoker(
Type type = Type.GetType("Microsoft.PowerShell.PSConsoleReadLine, Microsoft.PowerShell.PSReadLine2");
MethodInfo method = type?.GetMethod(
"ReadLine",
- new[] { typeof(Runspace), typeof(EngineIntrinsics), typeof(CancellationToken) });
+ new [] { typeof(Runspace), typeof(EngineIntrinsics), typeof(CancellationToken) });
// TODO: Handle method being null here. This shouldn't ever happen.
diff --git a/src/PowerShellEditorServices.Hosting/EditorServicesLoader.cs b/src/PowerShellEditorServices.Hosting/EditorServicesLoader.cs
index 59956df1a..10b7281af 100644
--- a/src/PowerShellEditorServices.Hosting/EditorServicesLoader.cs
+++ b/src/PowerShellEditorServices.Hosting/EditorServicesLoader.cs
@@ -2,6 +2,7 @@
// Licensed under the MIT License.
using System;
+using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Threading.Tasks;
@@ -93,7 +94,11 @@ public static EditorServicesLoader Create(
AssemblyLoadContext.Default.Resolving += (AssemblyLoadContext defaultLoadContext, AssemblyName asmName) =>
{
+#if DEBUG
+ logger.Log(PsesLogLevel.Diagnostic, $"Assembly resolve event fired for {asmName}. Stacktrace:\n{new StackTrace()}");
+#else
logger.Log(PsesLogLevel.Diagnostic, $"Assembly resolve event fired for {asmName}");
+#endif
// We only want the Editor Services DLL; the new ALC will lazily load its dependencies automatically
if (!string.Equals(asmName.Name, "Microsoft.PowerShell.EditorServices", StringComparison.Ordinal))
@@ -124,7 +129,11 @@ public static EditorServicesLoader Create(
// Unlike in .NET Core, we need to be look for all dependencies in .NET Framework, not just PSES.dll
AppDomain.CurrentDomain.AssemblyResolve += (object sender, ResolveEventArgs args) =>
{
+#if DEBUG
+ logger.Log(PsesLogLevel.Diagnostic, $"Assembly resolve event fired for {args.Name}. Stacktrace:\n{new StackTrace()}");
+#else
logger.Log(PsesLogLevel.Diagnostic, $"Assembly resolve event fired for {args.Name}");
+#endif
var asmName = new AssemblyName(args.Name);
var dllName = $"{asmName.Name}.dll";
@@ -217,7 +226,7 @@ public void Dispose()
// This is not high priority, since the PSES process shouldn't be reused
}
- private void LoadEditorServices()
+ private static void LoadEditorServices()
{
// This must be in its own method, since the actual load happens when the calling method is called
// The call within this method is therefore a total no-op
@@ -308,7 +317,7 @@ private void LogHostInformation()
LogOperatingSystemDetails();
}
- private string GetPSOutputEncoding()
+ private static string GetPSOutputEncoding()
{
using (var pwsh = SMA.PowerShell.Create())
{
@@ -337,7 +346,7 @@ private void LogOperatingSystemDetails()
");
}
- private string GetOSArchitecture()
+ private static string GetOSArchitecture()
{
#if CoreCLR
if (Environment.OSVersion.Platform != PlatformID.Win32NT)
diff --git a/src/PowerShellEditorServices.Hosting/PowerShellEditorServices.Hosting.csproj b/src/PowerShellEditorServices.Hosting/PowerShellEditorServices.Hosting.csproj
index 16ab98595..58d4fa85c 100644
--- a/src/PowerShellEditorServices.Hosting/PowerShellEditorServices.Hosting.csproj
+++ b/src/PowerShellEditorServices.Hosting/PowerShellEditorServices.Hosting.csproj
@@ -31,10 +31,6 @@
-
- all
- runtime; build; native; contentfiles; analyzers; buildtransitive
-
diff --git a/src/PowerShellEditorServices.VSCode/CustomViews/CustomViewBase.cs b/src/PowerShellEditorServices.VSCode/CustomViews/CustomViewBase.cs
index af154d105..b0cc81605 100644
--- a/src/PowerShellEditorServices.VSCode/CustomViews/CustomViewBase.cs
+++ b/src/PowerShellEditorServices.VSCode/CustomViews/CustomViewBase.cs
@@ -28,40 +28,31 @@ public CustomViewBase(
this.languageServer = languageServer;
}
- internal async Task CreateAsync()
- {
- await languageServer.SendRequestAsync(
+ internal Task CreateAsync() =>
+ languageServer.SendRequestAsync(
NewCustomViewRequest.Method,
new NewCustomViewRequest
{
Id = this.Id,
Title = this.Title,
ViewType = this.ViewType,
- }
- );
- }
+ });
- public async Task Show(ViewColumn viewColumn)
- {
- await languageServer.SendRequestAsync(
+ public Task Show(ViewColumn viewColumn) =>
+ languageServer.SendRequestAsync(
ShowCustomViewRequest.Method,
new ShowCustomViewRequest
{
Id = this.Id,
ViewColumn = viewColumn
- }
- );
- }
+ });
- public async Task Close()
- {
- await languageServer.SendRequestAsync(
+ public Task Close() =>
+ languageServer.SendRequestAsync(
CloseCustomViewRequest.Method,
new CloseCustomViewRequest
{
Id = this.Id,
- }
- );
- }
+ });
}
}
diff --git a/src/PowerShellEditorServices.VSCode/CustomViews/HtmlContentView.cs b/src/PowerShellEditorServices.VSCode/CustomViews/HtmlContentView.cs
index dcac2ba44..ca3e53ad6 100644
--- a/src/PowerShellEditorServices.VSCode/CustomViews/HtmlContentView.cs
+++ b/src/PowerShellEditorServices.VSCode/CustomViews/HtmlContentView.cs
@@ -21,9 +21,8 @@ public HtmlContentView(
{
}
- public async Task SetContentAsync(string htmlBodyContent)
- {
- await languageServer.SendRequestAsync(
+ public Task SetContentAsync(string htmlBodyContent) =>
+ languageServer.SendRequestAsync(
SetHtmlContentViewRequest.Method,
new SetHtmlContentViewRequest
{
@@ -31,31 +30,24 @@ await languageServer.SendRequestAsync(
HtmlContent = new HtmlContent { BodyContent = htmlBodyContent }
}
);
- }
-
- public async Task SetContentAsync(HtmlContent htmlContent)
- {
- HtmlContent validatedContent =
- new HtmlContent()
- {
- BodyContent = htmlContent.BodyContent,
- JavaScriptPaths = this.GetUriPaths(htmlContent.JavaScriptPaths),
- StyleSheetPaths = this.GetUriPaths(htmlContent.StyleSheetPaths)
- };
- await languageServer.SendRequestAsync(
+ public Task SetContentAsync(HtmlContent htmlContent) =>
+ languageServer.SendRequestAsync(
SetHtmlContentViewRequest.Method,
new SetHtmlContentViewRequest
{
Id = this.Id,
- HtmlContent = validatedContent
+ HtmlContent = new HtmlContent()
+ {
+ BodyContent = htmlContent.BodyContent,
+ JavaScriptPaths = HtmlContentView.GetUriPaths(htmlContent.JavaScriptPaths),
+ StyleSheetPaths = HtmlContentView.GetUriPaths(htmlContent.StyleSheetPaths)
+ }
}
);
- }
- public async Task AppendContentAsync(string appendedHtmlBodyContent)
- {
- await languageServer.SendRequestAsync(
+ public Task AppendContentAsync(string appendedHtmlBodyContent) =>
+ languageServer.SendRequestAsync(
AppendHtmlContentViewRequest.Method,
new AppendHtmlContentViewRequest
{
@@ -63,9 +55,8 @@ await languageServer.SendRequestAsync(
AppendedHtmlBodyContent = appendedHtmlBodyContent
}
);
- }
- private string[] GetUriPaths(string[] filePaths)
+ private static string[] GetUriPaths(string[] filePaths)
{
return
filePaths?
diff --git a/src/PowerShellEditorServices.VSCode/CustomViews/HtmlContentViewsFeature.cs b/src/PowerShellEditorServices.VSCode/CustomViews/HtmlContentViewsFeature.cs
index df8ac001d..dfdf5e3cb 100644
--- a/src/PowerShellEditorServices.VSCode/CustomViews/HtmlContentViewsFeature.cs
+++ b/src/PowerShellEditorServices.VSCode/CustomViews/HtmlContentViewsFeature.cs
@@ -21,7 +21,7 @@ public async Task CreateHtmlContentViewAsync(string viewTitle)
viewTitle,
languageServer);
- await htmlView.CreateAsync();
+ await htmlView.CreateAsync().ConfigureAwait(false);
this.AddView(htmlView);
return htmlView;
diff --git a/src/PowerShellEditorServices/Extensions/Api/EditorExtensionServiceProvider.cs b/src/PowerShellEditorServices/Extensions/Api/EditorExtensionServiceProvider.cs
index 661797f1d..8d25db01d 100644
--- a/src/PowerShellEditorServices/Extensions/Api/EditorExtensionServiceProvider.cs
+++ b/src/PowerShellEditorServices/Extensions/Api/EditorExtensionServiceProvider.cs
@@ -156,7 +156,7 @@ public object GetService(Type serviceType)
/// In .NET Framework, this returns null.
///
/// The assembly load context used for loading PSES, or null in .NET Framework.
- public object GetPsesAssemblyLoadContext()
+ public static object GetPsesAssemblyLoadContext()
{
if (!VersionUtils.IsNetCore)
{
@@ -172,7 +172,7 @@ public object GetPsesAssemblyLoadContext()
///
/// The absolute path of the assembly to load.
/// The loaded assembly object.
- public Assembly LoadAssemblyInPsesLoadContext(string assemblyPath)
+ public static Assembly LoadAssemblyInPsesLoadContext(string assemblyPath)
{
if (!VersionUtils.IsNetCore)
{
diff --git a/src/PowerShellEditorServices/Extensions/Api/EditorUIService.cs b/src/PowerShellEditorServices/Extensions/Api/EditorUIService.cs
index 0ab4fe497..f83dd7d20 100644
--- a/src/PowerShellEditorServices/Extensions/Api/EditorUIService.cs
+++ b/src/PowerShellEditorServices/Extensions/Api/EditorUIService.cs
@@ -116,7 +116,7 @@ public async Task PromptInputAsync(string message)
new ShowInputPromptRequest
{
Name = message,
- }).Returning(CancellationToken.None);
+ }).Returning(CancellationToken.None).ConfigureAwait(false);
if (response.PromptCancelled)
{
@@ -142,7 +142,7 @@ public async Task> PromptMultipleSelectionAsync(string mes
Message = message,
Choices = choiceDetails,
DefaultChoices = defaultChoiceIndexes?.ToArray(),
- }).Returning(CancellationToken.None);
+ }).Returning(CancellationToken.None).ConfigureAwait(false);
if (response.PromptCancelled)
{
@@ -168,7 +168,7 @@ public async Task PromptSelectionAsync(string message, IReadOnlyList -1 ? new[] { defaultChoiceIndex } : null,
- }).Returning(CancellationToken.None);
+ }).Returning(CancellationToken.None).ConfigureAwait(false);
if (response.PromptCancelled)
{
diff --git a/src/PowerShellEditorServices/Extensions/Api/WorkspaceService.cs b/src/PowerShellEditorServices/Extensions/Api/WorkspaceService.cs
index 3d2dabf7f..98eb9f06e 100644
--- a/src/PowerShellEditorServices/Extensions/Api/WorkspaceService.cs
+++ b/src/PowerShellEditorServices/Extensions/Api/WorkspaceService.cs
@@ -147,7 +147,7 @@ public IReadOnlyList GetOpenedFiles()
return files.AsReadOnly();
}
- private IEditorScriptFile GetEditorFileFromScriptFile(ScriptFile file)
+ private static IEditorScriptFile GetEditorFileFromScriptFile(ScriptFile file)
{
return new EditorScriptFile(file);
}
diff --git a/src/PowerShellEditorServices/PowerShellEditorServices.csproj b/src/PowerShellEditorServices/PowerShellEditorServices.csproj
index 5c5a7c928..562239ded 100644
--- a/src/PowerShellEditorServices/PowerShellEditorServices.csproj
+++ b/src/PowerShellEditorServices/PowerShellEditorServices.csproj
@@ -1,5 +1,4 @@
-
diff --git a/src/PowerShellEditorServices/Services/Analysis/PssaCmdletAnalysisEngine.cs b/src/PowerShellEditorServices/Services/Analysis/PssaCmdletAnalysisEngine.cs
index b842193c7..70b671e54 100644
--- a/src/PowerShellEditorServices/Services/Analysis/PssaCmdletAnalysisEngine.cs
+++ b/src/PowerShellEditorServices/Services/Analysis/PssaCmdletAnalysisEngine.cs
@@ -362,7 +362,7 @@ private PowerShellResult InvokePowerShell(PSCommand command)
///
/// The PowerShell instance to execute.
/// The output of PowerShell execution.
- private Collection InvokePowerShellWithModulePathPreservation(System.Management.Automation.PowerShell powershell)
+ private static Collection InvokePowerShellWithModulePathPreservation(System.Management.Automation.PowerShell powershell)
{
using (PSModulePathPreserver.Take())
{
diff --git a/src/PowerShellEditorServices/Services/CodeLens/PesterCodeLensProvider.cs b/src/PowerShellEditorServices/Services/CodeLens/PesterCodeLensProvider.cs
index e7d0217c9..dd0ef0d1b 100644
--- a/src/PowerShellEditorServices/Services/CodeLens/PesterCodeLensProvider.cs
+++ b/src/PowerShellEditorServices/Services/CodeLens/PesterCodeLensProvider.cs
@@ -42,7 +42,7 @@ public PesterCodeLensProvider(ConfigurationService configurationService)
/// The Pester symbol to get CodeLenses for.
/// The script file the Pester symbol comes from.
/// All CodeLenses for the given Pester symbol.
- private CodeLens[] GetPesterLens(PesterSymbolReference pesterSymbol, ScriptFile scriptFile)
+ private static CodeLens[] GetPesterLens(PesterSymbolReference pesterSymbol, ScriptFile scriptFile)
{
string word = pesterSymbol.Command == PesterCommandType.It ? "test" : "tests";
var codeLensResults = new CodeLens[]
diff --git a/src/PowerShellEditorServices/Services/CodeLens/ReferencesCodeLensProvider.cs b/src/PowerShellEditorServices/Services/CodeLens/ReferencesCodeLensProvider.cs
index 2964770d6..84119ee81 100644
--- a/src/PowerShellEditorServices/Services/CodeLens/ReferencesCodeLensProvider.cs
+++ b/src/PowerShellEditorServices/Services/CodeLens/ReferencesCodeLensProvider.cs
@@ -86,7 +86,7 @@ public CodeLens ResolveCodeLens(CodeLens codeLens, ScriptFile scriptFile)
ScriptFile[] references = _workspaceService.ExpandScriptReferences(
scriptFile);
- SymbolReference foundSymbol = _symbolsService.FindFunctionDefinitionAtLocation(
+ SymbolReference foundSymbol = SymbolsService.FindFunctionDefinitionAtLocation(
scriptFile,
codeLens.Range.Start.Line + 1,
codeLens.Range.Start.Character + 1);
diff --git a/src/PowerShellEditorServices/Services/DebugAdapter/BreakpointService.cs b/src/PowerShellEditorServices/Services/DebugAdapter/BreakpointService.cs
index 3f6bf2bf8..ab49bd21a 100644
--- a/src/PowerShellEditorServices/Services/DebugAdapter/BreakpointService.cs
+++ b/src/PowerShellEditorServices/Services/DebugAdapter/BreakpointService.cs
@@ -47,7 +47,7 @@ public async Task> GetBreakpointsAsync()
// Legacy behavior
PSCommand psCommand = new PSCommand();
psCommand.AddCommand(@"Microsoft.PowerShell.Utility\Get-PSBreakpoint");
- IEnumerable breakpoints = await _powerShellContextService.ExecuteCommandAsync(psCommand);
+ IEnumerable breakpoints = await _powerShellContextService.ExecuteCommandAsync(psCommand).ConfigureAwait(false);
return breakpoints.ToList();
}
@@ -133,7 +133,7 @@ public async Task> SetBreakpointsAsync(string esc
if (psCommand != null)
{
IEnumerable setBreakpoints =
- await _powerShellContextService.ExecuteCommandAsync(psCommand);
+ await _powerShellContextService.ExecuteCommandAsync(psCommand).ConfigureAwait(false);
configuredBreakpoints.AddRange(
setBreakpoints.Select(BreakpointDetails.Create));
}
@@ -210,7 +210,7 @@ public async Task> SetCommandBreakpoints(I
if (psCommand != null)
{
IEnumerable setBreakpoints =
- await _powerShellContextService.ExecuteCommandAsync(psCommand);
+ await _powerShellContextService.ExecuteCommandAsync(psCommand).ConfigureAwait(false);
configuredBreakpoints.AddRange(
setBreakpoints.Select(CommandBreakpointDetails.Create));
}
@@ -301,7 +301,7 @@ public async Task RemoveBreakpointsAsync(IEnumerable breakpoints)
psCommand.AddCommand(@"Microsoft.PowerShell.Utility\Remove-PSBreakpoint");
psCommand.AddParameter("Id", breakpoints.Select(b => b.Id).ToArray());
- await _powerShellContextService.ExecuteCommandAsync