diff --git a/.vsts-ci/azure-pipelines-ci.yml b/.vsts-ci/azure-pipelines-ci.yml index b33fb37..bc9155b 100644 --- a/.vsts-ci/azure-pipelines-ci.yml +++ b/.vsts-ci/azure-pipelines-ci.yml @@ -8,47 +8,24 @@ variables: - name: DOTNET_CLI_TELEMETRY_OPTOUT value: 'true' -trigger: - batch: true - branches: - include: - - master - paths: - exclude: - - /.dependabot/* - - /.poshchan/* - - /.github/**/* - - /.vscode/**/* - - /.vsts-ci/misc-analysis.yml - - /tools/**/* - - .editorconfig - - .gitattributes - - .gitignore - - /docs/**/* - - /CHANGELOG.md - - /CONTRIBUTING.md - - /README.md - - /LICENSE.txt - - /CODE_OF_CONDUCT.md - jobs: -- job: 'PS6_Win10' - displayName: PowerShell 6 | Windows 10 +- job: windows2022pwsh + displayName: Windows 2022 PowerShell 7 pool: - vmImage: 'vs2017-win2016' + vmImage: windows-2022 steps: - template: templates/ci-general.yml -- job: 'PS6_macOS' - displayName: PowerShell 6 | macOS +- job: macOS11 + displayName: macOS 11 pool: - vmImage: 'macOS-10.14' + vmImage: macOS-11 steps: - template: templates/ci-general.yml -- job: 'PS6_Ubuntu' - displayName: PowerShell 6 | Ubuntu +- job: ubuntu2004 + displayName: Ubuntu 20.04 pool: - vmImage: 'ubuntu-16.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 d330c5b..f127c70 100644 --- a/.vsts-ci/azure-pipelines-release.yml +++ b/.vsts-ci/azure-pipelines-release.yml @@ -1,7 +1,4 @@ -# NOTE: -# We stop signing GraphicalTools now since we aren't doing anymore work on it until MAUI - -name: PR-$(System.PullRequest.PullRequestNumber)-$(Date:yyyyMMdd)$(Rev:.rr) +name: Release-$(Build.SourceBranchName)-$(Date:yyyyMMdd)$(Rev:.rr) variables: # Don't download unneeded packages @@ -12,158 +9,68 @@ variables: value: 'true' trigger: - batch: true branches: include: - - master - paths: - exclude: - - /.dependabot/* - - /.poshchan/* - - /.github/**/* - - /.vscode/**/* - - /.vsts-ci/misc-analysis.yml - - /tools/**/* - - .editorconfig - - .gitattributes - - .gitignore - - /docs/**/* - - /CHANGELOG.md - - /CONTRIBUTING.md - - /README.md - - /LICENSE.txt - - /CODE_OF_CONDUCT.md + - release resources: repositories: - repository: ComplianceRepo type: github - endpoint: ComplianceGHRepo + endpoint: GitHub name: PowerShell/compliance stages: - stage: Build - displayName: Build + displayName: Build the release jobs: - - job: 'ReleaseBuild' - displayName: Release Build + - job: Build pool: - vmImage: 'windows-latest' + name: 1ES + demands: ImageOverride -equals PSMMS2019-Secure steps: - template: templates/ci-general.yml - - pwsh: | - Get-ChildItem -Recurse '$(Build.SourcesDirectory)' - displayName: Capture downloaded artifacts - - publish: '$(Build.SourcesDirectory)\src\Microsoft.PowerShell.ConsoleGuiTools\obj\project.assets.json' - artifact: ConsoleGuiToolsAssetsJson - displayName: Publish ConsoleGuiTools project.assets.json - - job: 'SignBuild' - displayName: Signing Build - dependsOn: 'ReleaseBuild' +- stage: Sign + displayName: Sign the release + jobs: + - job: Sign pool: - name: 'Package ES Standard Build' - demands: DotNetFramework + name: 1ES + demands: ImageOverride -equals PSMMS2019-Secure variables: - group: ESRP steps: - - powershell: | - Get-ChildItem -Path env: - displayName: Capture environment - condition: succeededOrFailed() - - - task: DownloadBuildArtifacts@0 - displayName: 'Download Build Artifacts' - inputs: - downloadType: specific - - - pwsh: | - Expand-Archive -Path "$env:BUILD_ARTIFACTSTAGINGDIRECTORY\GraphicalTools\Microsoft.PowerShell.ConsoleGuiTools-Windows_NT.zip" -DestinationPath "$env:BUILD_ARTIFACTSTAGINGDIRECTORY\Microsoft.PowerShell.ConsoleGuiTools" - displayName: 'Extract build zip' - - - template: EsrpSign.yml@ComplianceRepo - parameters: - # the folder which contains the binaries to sign - buildOutputPath: $(Build.ArtifactStagingDirectory)\Microsoft.PowerShell.ConsoleGuiTools - # the location to put the signed output - signOutputPath: $(Build.ArtifactStagingDirectory)\Microsoft.PowerShell.ConsoleGuiTools-Signed - # the certificate ID to use - certificateId: "CP-230012" - # The file pattern to use - # If not using minimatch: comma separated, with * supported - # If using minimatch: newline separated, with !, **, and * supported. - # See link in the useMinimatch comments. - pattern: 'Microsoft.PowerShell.*.dll,Microsoft.PowerShell.*.psd1,Microsoft.PowerShell.*.psm1' - # decides if the task should use minimatch for the pattern matching. - # https://github.com/isaacs/minimatch#features - useMinimatch: false - - - pwsh: | - $signed="$env:BUILD_ARTIFACTSTAGINGDIRECTORY\Microsoft.PowerShell.ConsoleGuiTools-Signed\*" - $notSigned="$env:BUILD_ARTIFACTSTAGINGDIRECTORY\Microsoft.PowerShell.ConsoleGuiTools" - Copy-Item $signed $notSigned -Recurse -Force -Verbose - displayName: 'Copy signed files to unsigned folder' - - - template: EsrpSign.yml@ComplianceRepo - parameters: - # the folder which contains the binaries to sign - buildOutputPath: $(Build.ArtifactStagingDirectory)\Microsoft.PowerShell.ConsoleGuiTools - # the location to put the signed output - signOutputPath: $(Build.ArtifactStagingDirectory)\Microsoft.PowerShell.ConsoleGuiTools-Signed - # the certificate ID to use - certificateId: "CP-231522" - # The file pattern to use - # If not using minimatch: comma separated, with * supported - # If using minimatch: newline separated, with !, **, and * supported. - # See link in the useMinimatch comments. - pattern: 'NStack.dll,Terminal.Gui.dll' - # decides if the task should use minimatch for the pattern matching. - # https://github.com/isaacs/minimatch#features - useMinimatch: false - - - pwsh: | - $signed="$(Build.ArtifactStagingDirectory)\Microsoft.PowerShell.ConsoleGuiTools-Signed\*" - $notSigned="$(Build.ArtifactStagingDirectory)\Microsoft.PowerShell.ConsoleGuiTools" - Copy-Item $signed $notSigned -Recurse -Force -Verbose - displayName: 'Copy signed files to unsigned folder' + - template: templates/release-general.yml - - publish: $(Build.ArtifactStagingDirectory)\Microsoft.PowerShell.ConsoleGuiTools - artifact: Microsoft.PowerShell.ConsoleGuiTools-Signed - displayName: 'Upload Artifacts' - condition: succeededOrFailed() - -- stage: compliance - displayName: Compliance - dependsOn: Build +- stage: PublishGitHub + displayName: Publish the draft release jobs: - - job: Compliance_Job + - deployment: Publish + environment: GraphicalTools-GitHub pool: - name: Package ES Standard Build - steps: - - checkout: self - - checkout: ComplianceRepo - - download: current - artifact: Microsoft.PowerShell.ConsoleGuiTools-Signed - - download: current - artifact: ConsoleGuiToolsAssetsJson - - - pwsh: | - Get-ChildItem -Recurse '$(Pipeline.Workspace)' - displayName: Capture downloaded artifacts - - - template: assembly-module-compliance.yml@ComplianceRepo - parameters: - # binskim - AnalyzeTarget: '$(Pipeline.Workspace)\Microsoft.PowerShell.ConsoleGuiTools-Signed\*.dll' - AnalyzeSymPath: 'SRV*' - # component-governance - sourceScanPath: '$(Pipeline.Workspace)\ConsoleGuiToolsAssetsJson' - # credscan - suppressionsFile: '' - # TermCheck - optionsRulesDBPath: '' - optionsFTPath: '' - # tsa-upload - codeBaseName: 'PSGraphicalTools_20201123' - # selections - APIScan: false # set to false when not using Windows APIs. + name: 1ES + demands: ImageOverride -equals PSMMSUbuntu20.04-Secure + variables: + - group: Publish + strategy: + runOnce: + deploy: + steps: + - template: templates/publish-github.yml + +- stage: PublishMarkets + displayName: Publish to marketplace and gallery + jobs: + - deployment: Publish + environment: GraphicalTools-Gallery + pool: + name: 1ES + demands: ImageOverride -equals PSMMSUbuntu20.04-Secure + variables: + - group: Publish + strategy: + runOnce: + deploy: + steps: + - template: templates/publish-markets.yml diff --git a/.vsts-ci/misc-analysis.yml b/.vsts-ci/misc-analysis.yml index c9dc67b..2647eb1 100644 --- a/.vsts-ci/misc-analysis.yml +++ b/.vsts-ci/misc-analysis.yml @@ -1,30 +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 +- 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 69afa9b..8eb60b2 100644 --- a/.vsts-ci/templates/ci-general.yml +++ b/.vsts-ci/templates/ci-general.yml @@ -1,25 +1,67 @@ parameters: - pwsh: true +- name: pwsh + type: boolean + default: true steps: - - 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: GraphicalTools - PathtoPublish: '$(Build.ArtifactStagingDirectory)' +- task: PowerShell@2 + displayName: PowerShell version + inputs: + targetType: inline + script: $PSVersionTable + pwsh: ${{ parameters.pwsh }} + +- task: UseDotNet@2 + displayName: Install .NET 6.0.x SDK + inputs: + packageType: sdk + version: 6.0.x + performMultiLevelLookup: true + +- task: PowerShell@2 + displayName: Build and test + inputs: + filePath: tools/azurePipelinesBuild.ps1 + pwsh: ${{ parameters.pwsh }} + +- task: PublishTestResults@2 + displayName: Publish VSTest results + inputs: + testRunner: VSTest + testResultsFiles: '**/*.trx' + condition: succeededOrFailed() + +- task: PublishTestResults@2 + displayName: Publish NUnit results + inputs: + testRunner: NUnit + testResultsFiles: '**/TestResults.xml' + condition: succeededOrFailed() + +# 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 build output + inputs: + rootFolderOrFile: module + includeRootFolder: false + archiveType: zip + archiveFile: GraphicalTools-Build.zip + verbose: true + +- publish: GraphicalTools-Build.zip + artifact: GraphicalTools-Build-$(System.JobId) + displayName: Publish build output archive + +- task: ArchiveFiles@2 + displayName: Zip sources with `project.assets.json` + inputs: + rootFolderOrFile: src + includeRootFolder: false + archiveType: zip + archiveFile: GraphicalTools-Sources.zip + verbose: true + +- publish: GraphicalTools-Sources.zip + artifact: GraphicalTools-Sources-$(System.JobId) + displayName: Publish sources archive diff --git a/.vsts-ci/templates/publish-github.yml b/.vsts-ci/templates/publish-github.yml new file mode 100644 index 0000000..b15b0b4 --- /dev/null +++ b/.vsts-ci/templates/publish-github.yml @@ -0,0 +1,31 @@ +steps: +- checkout: self + +- download: current + artifact: GraphicalTools + displayName: Download signed pipeline artifacts + +- pwsh: | + Set-PSRepository -Name PSGallery -InstallationPolicy Trusted | Out-Null + Install-Module -Name PowerShellForGitHub -Scope CurrentUser -Force + Set-GitHubConfiguration -SuppressTelemetryReminder + + $password = ConvertTo-SecureString -String $(GitHubToken) -AsPlainText -Force + Set-GitHubAuthentication -Credential (New-Object System.Management.Automation.PSCredential ("token", $password)) + + $Info = Import-PowerShellDataFile -Path ./src/Microsoft.PowerShell.ConsoleGuiTools/Microsoft.PowerShell.ConsoleGuiTools.psd1 + + $ReleaseParams = @{ + Tag = "v$($Info.ModuleVersion)" + Committish = "release" + Name = "v$($Info.ModuleVersion)" + Draft = $True + PreRelease = $False + OwnerName = "PowerShell" + RepositoryName = "GraphicalTools" + } + + $Release = New-GitHubRelease @ReleaseParams + Write-Host "Draft release URL: $($Release.html_url)" + $Release | New-GitHubReleaseAsset -Path $(Pipeline.Workspace)/GraphicalTools/GraphicalTools.zip + displayName: Drafting a GitHub Release diff --git a/.vsts-ci/templates/publish-markets.yml b/.vsts-ci/templates/publish-markets.yml new file mode 100644 index 0000000..5a62895 --- /dev/null +++ b/.vsts-ci/templates/publish-markets.yml @@ -0,0 +1,20 @@ +steps: +- checkout: self + +- download: current + artifact: GraphicalTools + displayName: Download signed artifacts + +- task: ExtractFiles@1 + displayName: Extract signed artifacts + inputs: + archiveFilePatterns: $(Pipeline.Workspace)/GraphicalTools/GraphicalTools.zip + destinationFolder: $(Pipeline.Workspace)/Publish + cleanDestinationFolder: true + +- pwsh: | + Set-PSRepository -Name PSGallery -InstallationPolicy Trusted + Install-Module -Name PowerShellGet -AllowPrerelease -Scope CurrentUser -Force + Import-Module -Name PowerShellGet -MinimumVersion 3.0.0 + Publish-PSResource -Path $(Pipeline.Workspace)/Publish/Microsoft.PowerShell.ConsoleGuiTools -Repository PSGallery -APIKey $(GalleryToken) -Verbose + displayName: Publishing ConsoleGuiTools to PowerShell Gallery diff --git a/.vsts-ci/templates/release-general.yml b/.vsts-ci/templates/release-general.yml new file mode 100644 index 0000000..96d80db --- /dev/null +++ b/.vsts-ci/templates/release-general.yml @@ -0,0 +1,89 @@ +steps: +- download: current + displayName: Download unsigned pipeline artifacts + +- task: ExtractFiles@1 + displayName: Extract unsigned artifacts + inputs: + archiveFilePatterns: $(Pipeline.Workspace)/GraphicalTools-Build-*/GraphicalTools-Build.zip + destinationFolder: $(Pipeline.Workspace)/Unsigned + cleanDestinationFolder: true + +- checkout: 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: $(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: | + **/Microsoft.PowerShell.*.{dll,psd1,psm1} + +- template: EsrpSign.yml@ComplianceRepo + parameters: + 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: | + **/NStack.dll + **/Terminal.Gui.dll + +# The SBOM generation requires our original sources with the `dotnet restore` +# produced `project.assets.json` files. +- task: ExtractFiles@1 + displayName: Extract source artifacts + inputs: + archiveFilePatterns: $(Pipeline.Workspace)/GraphicalTools-Sources-*/GraphicalTools-Sources.zip + destinationFolder: $(Pipeline.Workspace)/Sources + cleanDestinationFolder: true + +- template: Sbom.yml@ComplianceRepo + parameters: + BuildDropPath: $(Pipeline.Workspace)/ThirdPartySigned + Build_Repository_Uri: https://github.com/PowerShell/GraphicalTools.git + packageName: GraphicalTools + packageVersion: $(System.JobId) + sourceScanPath: $(Pipeline.Workspace)/Sources + +- task: ArchiveFiles@2 + displayName: Zip signed artifacts + inputs: + rootFolderOrFile: $(Pipeline.Workspace)/ThirdPartySigned + includeRootFolder: false + archiveType: zip + archiveFile: GraphicalTools.zip + replaceExistingArchive: true + verbose: true + +- checkout: self + +- template: assembly-module-compliance.yml@ComplianceRepo + parameters: + # binskim + AnalyzeTarget: $(Pipeline.Workspace)/*.dll + AnalyzeSymPath: 'SRV*' + # component-governance: requires the `project.assets.json` files + sourceScanPath: $(Pipeline.Workspace)/Sources + # credscan + suppressionsFile: '' + # TermCheck AKA PoliCheck + targetArgument: $(Build.SourcesDirectory)/GraphicalTools + optionsUEPATH: $(Build.SourcesDirectory)/GraphicalTools/tools/terms/UserExclusions.xml + optionsRulesDBPath: '' + optionsFTPath: $(Build.SourcesDirectory)/GraphicalTools/tools/terms/FileTypeSet.xml + # tsa-upload + codeBaseName: PowerShell_GraphicalTools_20220823 + # We don't use any Windows APIs directly, so we don't need API scan + APIScan: false + +- publish: GraphicalTools.zip + artifact: GraphicalTools + displayName: Publish signed pipeline artifacts diff --git a/GraphicalTools.build.ps1 b/GraphicalTools.build.ps1 index ce56bc1..cd3f276 100644 --- a/GraphicalTools.build.ps1 +++ b/GraphicalTools.build.ps1 @@ -3,9 +3,7 @@ param( [ValidateSet("Debug", "Release")] [string]$Configuration = "Debug", - [string[]]$ModuleName = @( - #"Microsoft.PowerShell.GraphicalTools", - "Microsoft.PowerShell.ConsoleGuiTools" ) + [string[]]$ModuleName = @("Microsoft.PowerShell.ConsoleGuiTools" ) ) $script:IsUnix = $PSVersionTable.PSEdition -and $PSVersionTable.PSEdition -eq "Core" -and !$IsWindows @@ -175,17 +173,4 @@ task BuildCmdletHelp { } } -task PackageModule { - foreach ($mn in $ModuleName) { - Remove-Item "$PSScriptRoot/$mn.zip" -Force -ErrorAction Ignore - Compress-Archive -Path "$PSScriptRoot/module/$mn/" -DestinationPath "$mn.zip" -CompressionLevel Optimal -Force - } -} - -task UploadArtifacts -If ($null -ne $env:TF_BUILD) { - foreach ($mn in $ModuleName) { - Copy-Item -Path "$PSScriptRoot/$mn.zip" -Destination "$env:BUILD_ARTIFACTSTAGINGDIRECTORY/$mn-$($env:AGENT_OS).zip" - } -} - -task . Clean, Build, BuildCmdletHelp, PackageModule, UploadArtifacts +task . Clean, Build, BuildCmdletHelp diff --git a/assets/OutGridView.png b/assets/OutGridView.png deleted file mode 100644 index acbd584..0000000 Binary files a/assets/OutGridView.png and /dev/null differ diff --git a/global.json b/global.json index fe0b480..4e0b0e1 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,5 @@ { "sdk": { - "version": "6.0.100" + "version": "6.0.400" } } diff --git a/src/Microsoft.PowerShell.ConsoleGuiTools/Microsoft.PowerShell.ConsoleGuiTools.csproj b/src/Microsoft.PowerShell.ConsoleGuiTools/Microsoft.PowerShell.ConsoleGuiTools.csproj index adeabd1..92854d2 100644 --- a/src/Microsoft.PowerShell.ConsoleGuiTools/Microsoft.PowerShell.ConsoleGuiTools.csproj +++ b/src/Microsoft.PowerShell.ConsoleGuiTools/Microsoft.PowerShell.ConsoleGuiTools.csproj @@ -5,9 +5,9 @@ - - - + + + diff --git a/src/Microsoft.PowerShell.GraphicalTools/AvaloniaProcessBridge.cs b/src/Microsoft.PowerShell.GraphicalTools/AvaloniaProcessBridge.cs deleted file mode 100644 index 59a6536..0000000 --- a/src/Microsoft.PowerShell.GraphicalTools/AvaloniaProcessBridge.cs +++ /dev/null @@ -1,101 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.IO; -using System.Management.Automation; -using System.Reflection; -using System.Runtime.InteropServices; -using OutGridView.Models; - -namespace OutGridView.Cmdlet -{ - class AvaloniaProcessBridge - { - private static Process _process; - - public static List SelectedIndexes { get; set; } - public static void Start(ApplicationData applicationData) - { - SelectedIndexes = new List(); - - _process = new Process(); - _process.StartInfo.FileName = GetOutgridViewApplicationLocation(); - - - _process.StartInfo.CreateNoWindow = true; - _process.StartInfo.UseShellExecute = false; - - _process.StartInfo.RedirectStandardInput = true; - _process.StartInfo.RedirectStandardOutput = true; - _process.StartInfo.RedirectStandardError = true; - - _process.OutputDataReceived += (sender, data) => - { - if (!string.IsNullOrWhiteSpace(data.Data)) - { - SelectedIndexes = Serializers.ObjectFromJson>(data.Data); - } - }; - - _process.ErrorDataReceived += (sender, data) => - { - Console.WriteLine(data.Data); - }; - - _process.Start(); - _process.BeginOutputReadLine(); - _process.BeginErrorReadLine(); - - var serializedData = Serializers.ObjectToJson(applicationData); - - _process.StandardInput.WriteLine(serializedData); - - } - public static void WaitForExit() - { - _process.WaitForExit(); - } - - public static void CloseProcess() - { - _process.Close(); - } - public static bool IsClosed() - { - if (_process == null || _process.HasExited) - { - return true; - } - else - { - return false; - } - } - - public static string GetOutgridViewApplicationLocation() - { - string osRid; - string executableName; - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - osRid = "win-x64"; - executableName = "OutGridView.Gui.exe"; - } - else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) - { - osRid = "osx-x64"; - executableName = "OutGridView.Gui"; - } - else - { - osRid = "linux-x64"; - executableName = "OutGridView.Gui"; - } - - return Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "OutGridView.Gui", osRid, executableName); - } - } -} diff --git a/src/Microsoft.PowerShell.GraphicalTools/Microsoft.PowerShell.GraphicalTools.csproj b/src/Microsoft.PowerShell.GraphicalTools/Microsoft.PowerShell.GraphicalTools.csproj deleted file mode 100644 index c19b837..0000000 --- a/src/Microsoft.PowerShell.GraphicalTools/Microsoft.PowerShell.GraphicalTools.csproj +++ /dev/null @@ -1,19 +0,0 @@ - - - - net6.0 - - - - - - - - - - - - - - - diff --git a/src/Microsoft.PowerShell.GraphicalTools/Microsoft.PowerShell.GraphicalTools.psd1 b/src/Microsoft.PowerShell.GraphicalTools/Microsoft.PowerShell.GraphicalTools.psd1 deleted file mode 100644 index 30e1e27..0000000 --- a/src/Microsoft.PowerShell.GraphicalTools/Microsoft.PowerShell.GraphicalTools.psd1 +++ /dev/null @@ -1,140 +0,0 @@ -# -# Copyright (c) Microsoft. All rights reserved. -# Licensed under the MIT license. See LICENSE file in the project root for full license information. -# - -@{ - -# Script module or binary module file associated with this manifest. -RootModule = 'Microsoft.PowerShell.GraphicalTools.psm1' - -# Version number of this module. -ModuleVersion = '0.2.0' - -# Supported PSEditions -CompatiblePSEditions = @( 'Core' ) - -# ID used to uniquely identify this module -GUID = '06028f35-8304-4460-ae73-306741982afe' - -# Author of this module -Author = 'PowerShell Team' - -# Company or vendor of this module -CompanyName = 'Microsoft' - -# Copyright statement for this module -Copyright = '(c) Microsoft Corporation. All rights reserved.' - -# Description of the functionality provided by this module -Description = 'Cross-platform GUI Tools for PowerShell' - -# Minimum version of the PowerShell engine required by this module -PowerShellVersion = '6.2' - -# 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 = @() - -# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess -NestedModules = @( 'Microsoft.PowerShell.GraphicalTools.dll' ) - -# 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 = @() - -# 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 = @( 'Out-GridView' ) - -# 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 = @( 'ogv' ) - -# 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 = @('Gui', 'Out-GridView', 'MacOS', 'Windows', 'Linux', 'Avalonia', 'PSEdition_Core') - - # A URL to the license for this module. - LicenseUri = 'https://github.com/PowerShell/GraphicalTools/blob/master/LICENSE.txt' - - # A URL to the main website for this project. - ProjectUri = 'https://github.com/PowerShell/GraphicalTools/' - - # A URL to an icon representing this module. - # IconUri = '' - - # ReleaseNotes of this module - ReleaseNotes = '# 0.2.0 -Adds support for primitives -Adds support for mixed-object arrays (e.g Get-ChildItem) -Improves window sizing - -# 0.1.1 - -Fix for non-Windows - -# v0.1.0 - -Initial Release -' - - # Prerelease string of this module - # Prerelease = '' - - # Flag to indicate whether the module requires explicit user acceptance for install/update/save - RequireLicenseAcceptance = $false - - # External dependent modules of this module - # ExternalModuleDependencies = @() - - } # 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/src/Microsoft.PowerShell.GraphicalTools/Microsoft.PowerShell.GraphicalTools.psm1 b/src/Microsoft.PowerShell.GraphicalTools/Microsoft.PowerShell.GraphicalTools.psm1 deleted file mode 100644 index ef6f736..0000000 --- a/src/Microsoft.PowerShell.GraphicalTools/Microsoft.PowerShell.GraphicalTools.psm1 +++ /dev/null @@ -1,10 +0,0 @@ -# -# Copyright (c) Microsoft. All rights reserved. -# Licensed under the MIT license. See LICENSE file in the project root for full license information. -# - -if($IsMacOS) { - chmod +x "$PSScriptRoot/OutGridView.Gui/osx-x64/OutGridView.Gui" -} elseif ($IsLinux) { - chmod +x "$PSScriptRoot/OutGridView.Gui/linux-x64/OutGridView.Gui" -} diff --git a/src/Microsoft.PowerShell.GraphicalTools/ModuleLayout.psd1 b/src/Microsoft.PowerShell.GraphicalTools/ModuleLayout.psd1 deleted file mode 100644 index dddfb29..0000000 --- a/src/Microsoft.PowerShell.GraphicalTools/ModuleLayout.psd1 +++ /dev/null @@ -1,19 +0,0 @@ -@{ - RequiredBuildAssets = @{ - 'Microsoft.PowerShell.GraphicalTools' = @( - "publish/Microsoft.PowerShell.GraphicalTools.dll", - "publish/Microsoft.PowerShell.GraphicalTools.pdb", - "publish/Microsoft.PowerShell.GraphicalTools.psd1", - "publish/Microsoft.PowerShell.GraphicalTools.psm1" - ) - - 'Microsoft.PowerShell.OutGridView.Models' = @( - 'publish/Microsoft.PowerShell.OutGridView.Models.dll', - 'publish/Microsoft.PowerShell.OutGridView.Models.pdb' - ) - } - - NativeBuildAssets = @{ - 'OutGridView.Gui' = @("win-x64", "osx-x64", "linux-x64") - } -} diff --git a/src/Microsoft.PowerShell.GraphicalTools/OutGridviewCmdletCommand.cs b/src/Microsoft.PowerShell.GraphicalTools/OutGridviewCmdletCommand.cs deleted file mode 100644 index 08dba42..0000000 --- a/src/Microsoft.PowerShell.GraphicalTools/OutGridviewCmdletCommand.cs +++ /dev/null @@ -1,176 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Management.Automation; -using System.Management.Automation.Internal; -using OutGridView.Models; -using System.Linq; - -namespace OutGridView.Cmdlet -{ - /// Enum for SelectionMode parameter. - /// - [Cmdlet(VerbsData.Out, "GridView", DefaultParameterSetName = "PassThru")] - [Alias("ogv")] - public class OutGridViewCmdletCommand : PSCmdlet - { - #region Properties - - private const string DataNotQualifiedForGridView = "DataNotQualifiedForGridView"; - - private List PSObjects = new List(); - - #endregion Properties - - #region Input Parameters - - /// - /// This parameter specifies the current pipeline object. - /// - [Parameter(ValueFromPipeline = true)] - public PSObject InputObject { get; set; } = AutomationNull.Value; - - /// - /// Gets/sets the title of the Out-GridView window. - /// - [Parameter] - [ValidateNotNullOrEmpty] - public string Title { get; set; } - - /// - /// Get or sets a value indicating whether the cmdlet should wait for the window to be closed. - /// - [Parameter(ParameterSetName = "Wait")] - public SwitchParameter Wait { get; set; } - - /// - /// Get or sets a value indicating whether the selected items should be written to the pipeline - /// and if it should be possible to select multiple or single list items. - /// - [Parameter(ParameterSetName = "OutputMode")] - public OutputModeOption OutputMode { set; get; } - - /// - /// Gets or sets a value indicating whether the selected items should be written to the pipeline. - /// Setting this to true is the same as setting the OutputMode to Multiple. - /// - [Parameter(ParameterSetName = "PassThru")] - public SwitchParameter PassThru - { - set { this.OutputMode = value.IsPresent ? OutputModeOption.Multiple : OutputModeOption.None; } - - get { return OutputMode == OutputModeOption.Multiple ? new SwitchParameter(true) : new SwitchParameter(false); } - } - - #endregion Input Parameters - - // This method gets called once for each cmdlet in the pipeline when the pipeline starts executing - protected override void BeginProcessing() - { - } - - // This method will be called for each input received from the pipeline to this cmdlet; if no input is received, this method is not called - protected override void ProcessRecord() - { - if (InputObject == null || InputObject == AutomationNull.Value) - { - return; - } - - IDictionary dictionary = InputObject.BaseObject as IDictionary; - if (dictionary != null) - { - // Dictionaries should be enumerated through because the pipeline does not enumerate through them. - foreach (DictionaryEntry entry in dictionary) - { - ProcessObject(PSObject.AsPSObject(entry)); - } - } - else - { - ProcessObject(InputObject); - } - } - - protected override void StopProcessing() - { - if (this.Wait || this.OutputMode != OutputModeOption.None) - { - AvaloniaProcessBridge.CloseProcess(); - } - } - - private void ProcessObject(PSObject input) - { - - object baseObject = input.BaseObject; - - // Throw a terminating error for types that are not supported. - if (baseObject is ScriptBlock || - baseObject is SwitchParameter || - baseObject is PSReference || - baseObject is PSObject) - { - ErrorRecord error = new ErrorRecord( - new FormatException("Invalid data type for Out-GridView"), - DataNotQualifiedForGridView, - ErrorCategory.InvalidType, - null); - - this.ThrowTerminatingError(error); - } - - PSObjects.Add(input); - } - - // This method will be called once at the end of pipeline execution; if no input is received, this method is not called - protected override void EndProcessing() - { - base.EndProcessing(); - - //Return if no objects - if (PSObjects.Count == 0) - { - return; - } - - var TG = new TypeGetter(this); - - var dataTable = TG.CastObjectsToTableView(PSObjects); - var applicationData = new ApplicationData - { - Title = Title, - OutputMode = OutputMode, - PassThru = PassThru, - DataTable = dataTable - }; - - - AvaloniaProcessBridge.Start(applicationData); - - if (this.Wait || this.OutputMode != OutputModeOption.None) - { - AvaloniaProcessBridge.WaitForExit(); - } - - var selectedIndexes = AvaloniaProcessBridge.SelectedIndexes; - - if (selectedIndexes == null) - return; - - foreach (int idx in selectedIndexes) - { - var selectedObject = PSObjects[idx]; - if (selectedObject == null) - { - continue; - } - this.WriteObject(selectedObject, false); - } - } - } -} diff --git a/src/Microsoft.PowerShell.GraphicalTools/TypeGetter.cs b/src/Microsoft.PowerShell.GraphicalTools/TypeGetter.cs deleted file mode 100644 index de5e0b3..0000000 --- a/src/Microsoft.PowerShell.GraphicalTools/TypeGetter.cs +++ /dev/null @@ -1,199 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -using System; -using System.Management.Automation; -using System.Linq; -using System.Globalization; -using System.Collections.Generic; -using Microsoft.PowerShell.Commands; -using OutGridView.Models; - -namespace OutGridView.Cmdlet -{ - public class TypeGetter - { - private PSCmdlet _cmdlet; - - public TypeGetter(PSCmdlet cmdlet) - { - _cmdlet = cmdlet; - } - public FormatViewDefinition GetFormatViewDefinitionForObject(PSObject obj) - { - var typeName = obj.BaseObject.GetType().FullName; - - var types = _cmdlet.InvokeCommand.InvokeScript(@"Microsoft.PowerShell.Utility\Get-FormatData " + typeName).ToList(); - - //No custom type definitions found - try the PowerShell specific format data - if (types == null || types.Count == 0) - { - types = _cmdlet.InvokeCommand - .InvokeScript(@"Microsoft.PowerShell.Utility\Get-FormatData -PowerShellVersion $PSVersionTable.PSVersion " + typeName).ToList(); - - if (types == null || types.Count == 0) - { - return null; - } - } - - var extendedTypeDefinition = types[0].BaseObject as ExtendedTypeDefinition; - - return extendedTypeDefinition.FormatViewDefinition[0]; - } - - public DataTableRow CastObjectToDataTableRow(PSObject ps, List dataColumns, int objectIndex) - { - Dictionary valuePairs = new Dictionary(); - - foreach (var dataColumn in dataColumns) - { - var expression = new PSPropertyExpression(ScriptBlock.Create(dataColumn.PropertyScriptAccessor)); - - var result = expression.GetValues(ps).FirstOrDefault().Result; - - var stringValue = result?.ToString() ?? String.Empty; - - var isDecimal = decimal.TryParse(stringValue, NumberStyles.Any, CultureInfo.InvariantCulture.NumberFormat, out var decimalValue); - - if (isDecimal) - { - valuePairs[dataColumn.ToString()] = new DecimalValue { DisplayValue = stringValue, SortValue = decimalValue }; - } - else - { - valuePairs[dataColumn.ToString()] = new StringValue { DisplayValue = stringValue }; - } - } - - return new DataTableRow(valuePairs, objectIndex); - } - - private void SetTypesOnDataColumns(List dataTableRows, List dataTableColumns) - { - var dataRows = dataTableRows.Select(x => x.Values); - - foreach (var dataColumn in dataTableColumns) - { - dataColumn.StringType = typeof(decimal).FullName; - } - - //If every value in a column could be a decimal, assume that it is supposed to be a decimal - foreach (var dataRow in dataRows) - { - foreach (var dataColumn in dataTableColumns) - { - if (!(dataRow[dataColumn.ToString()] is DecimalValue)) - { - dataColumn.StringType = typeof(string).FullName; - } - } - } - } - private List GetDataColumnsForObject(List psObjects) - { - var dataColumns = new List(); - - - - foreach (PSObject obj in psObjects) - { - var labels = new List(); - - FormatViewDefinition fvd = GetFormatViewDefinitionForObject(obj); - - var propertyAccessors = new List(); - - if (fvd == null) - { - if (PSObjectIsPrimitive(obj)) - { - labels = new List { obj.BaseObject.GetType().Name }; - propertyAccessors = new List { "$_" }; - } - else - { - labels = obj.Properties.Select(x => x.Name).ToList(); - propertyAccessors = obj.Properties.Select(x => $"$_.\"{x.Name}\"").ToList(); - } - } - else - { - var tableControl = fvd.Control as TableControl; - - var definedColumnLabels = tableControl.Headers.Select(x => x.Label); - - var displayEntries = tableControl.Rows[0].Columns.Select(x => x.DisplayEntry); - - var propertyLabels = displayEntries.Select(x => x.Value); - - //Use the TypeDefinition Label if availble otherwise just use the property name as a label - labels = definedColumnLabels.Zip(propertyLabels, (definedColumnLabel, propertyLabel) => - { - if (String.IsNullOrEmpty(definedColumnLabel)) - { - return propertyLabel; - } - return definedColumnLabel; - }).ToList(); - - - propertyAccessors = displayEntries.Select(x => - { - //If it's a propety access directly - if (x.ValueType == DisplayEntryValueType.Property) - { - return $"$_.\"{x.Value}\""; - } - //Otherwise return access script - return x.Value; - }).ToList(); - } - - for (var i = 0; i < labels.Count; i++) - { - dataColumns.Add(new DataTableColumn(labels[i], propertyAccessors[i])); - } - } - return dataColumns.Distinct().ToList(); - } - - public DataTable CastObjectsToTableView(List psObjects) - { - List objectFormats = psObjects.Select(GetFormatViewDefinitionForObject).ToList(); - - var dataTableColumns = GetDataColumnsForObject(psObjects); - - foreach (var dataColumn in dataTableColumns) - { - _cmdlet.WriteVerbose(dataColumn.ToString()); - } - - List dataTableRows = new List(); - for (var i = 0; i < objectFormats.Count; i++) - { - var dataTableRow = CastObjectToDataTableRow(psObjects[i], dataTableColumns, i); - dataTableRows.Add(dataTableRow); - } - - SetTypesOnDataColumns(dataTableRows, dataTableColumns); - - return new DataTable(dataTableColumns, dataTableRows); - } - - - //Types that are condisidered primitives to PowerShell but not C# - private readonly static List additionalPrimitiveTypes = new List { "System.String", - "System.Decimal", - "System.IntPtr", - "System.Security.SecureString", - "System.Numerics.BigInteger" - }; - private bool PSObjectIsPrimitive(PSObject ps) - { - var psBaseType = ps.BaseObject.GetType(); - - return psBaseType.IsPrimitive || psBaseType.IsEnum || additionalPrimitiveTypes.Contains(psBaseType.FullName); - } - } -} diff --git a/src/OutGridView.Gui/.gitignore b/src/OutGridView.Gui/.gitignore deleted file mode 100644 index dbe7c8f..0000000 --- a/src/OutGridView.Gui/.gitignore +++ /dev/null @@ -1,337 +0,0 @@ -## Ignore Visual Studio temporary files, build results, and -## files generated by popular Visual Studio add-ons. -## -## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore - -## Visual Studio Code specific files and folder -.vscode/* -!.vscode/settings.json -!.vscode/tasks.json -!.vscode/launch.json -!.vscode/extensions.jsons - -# User-specific files -*.suo -*.user -*.userosscache -*.sln.docstates - -# User-specific files (MonoDevelop/Xamarin Studio) -*.userprefs - -# Build results -[Dd]ebug/ -[Dd]ebugPublic/ -[Rr]elease/ -[Rr]eleases/ -x64/ -x86/ -bld/ -[Bb]in/ -[Oo]bj/ -[Ll]og/ - -# Visual Studio 2015/2017 cache/options directory -.vs/ -# Uncomment if you have tasks that create the project's static files in wwwroot -#wwwroot/ - -# Visual Studio 2017 auto generated files -Generated\ Files/ - -# MSTest test Results -[Tt]est[Rr]esult*/ -[Bb]uild[Ll]og.* - -# NUNIT -*.VisualState.xml -TestResult.xml - -# Build Results of an ATL Project -[Dd]ebugPS/ -[Rr]eleasePS/ -dlldata.c - -# Benchmark Results -BenchmarkDotNet.Artifacts/ - -# .NET Core -project.lock.json -project.fragment.lock.json -artifacts/ -**/Properties/launchSettings.json - -# StyleCop -StyleCopReport.xml - -# Files built by Visual Studio -*_i.c -*_p.c -*_i.h -*.ilk -*.meta -*.obj -*.iobj -*.pch -*.pdb -*.ipdb -*.pgc -*.pgd -*.rsp -*.sbr -*.tlb -*.tli -*.tlh -*.tmp -*.tmp_proj -*.log -*.vspscc -*.vssscc -.builds -*.pidb -*.svclog -*.scc - -# Chutzpah Test files -_Chutzpah* - -# Visual C++ cache files -ipch/ -*.aps -*.ncb -*.opendb -*.opensdf -*.sdf -*.cachefile -*.VC.db -*.VC.VC.opendb - -# Visual Studio profiler -*.psess -*.vsp -*.vspx -*.sap - -# Visual Studio Trace Files -*.e2e - -# TFS 2012 Local Workspace -$tf/ - -# Guidance Automation Toolkit -*.gpState - -# ReSharper is a .NET coding add-in -_ReSharper*/ -*.[Rr]e[Ss]harper -*.DotSettings.user - -# JustCode is a .NET coding add-in -.JustCode - -# TeamCity is a build add-in -_TeamCity* - -# DotCover is a Code Coverage Tool -*.dotCover - -# AxoCover is a Code Coverage Tool -.axoCover/* -!.axoCover/settings.json - -# Visual Studio code coverage results -*.coverage -*.coveragexml - -# NCrunch -_NCrunch_* -.*crunch*.local.xml -nCrunchTemp_* - -# MightyMoose -*.mm.* -AutoTest.Net/ - -# Web workbench (sass) -.sass-cache/ - -# Installshield output folder -[Ee]xpress/ - -# DocProject is a documentation generator add-in -DocProject/buildhelp/ -DocProject/Help/*.HxT -DocProject/Help/*.HxC -DocProject/Help/*.hhc -DocProject/Help/*.hhk -DocProject/Help/*.hhp -DocProject/Help/Html2 -DocProject/Help/html - -# Click-Once directory -publish/ - -# Publish Web Output -*.[Pp]ublish.xml -*.azurePubxml -# Note: Comment the next line if you want to checkin your web deploy settings, -# but database connection strings (with potential passwords) will be unencrypted -*.pubxml -*.publishproj - -# Microsoft Azure Web App publish settings. Comment the next line if you want to -# checkin your Azure Web App publish settings, but sensitive information contained -# in these scripts will be unencrypted -PublishScripts/ - -# NuGet Packages -*.nupkg -# The packages folder can be ignored because of Package Restore -**/[Pp]ackages/* -# except build/, which is used as an MSBuild target. -!**/[Pp]ackages/build/ -# Uncomment if necessary however generally it will be regenerated when needed -#!**/[Pp]ackages/repositories.config -# NuGet v3's project.json files produces more ignorable files -*.nuget.props -*.nuget.targets - -# Microsoft Azure Build Output -csx/ -*.build.csdef - -# Microsoft Azure Emulator -ecf/ -rcf/ - -# Windows Store app package directories and files -AppPackages/ -BundleArtifacts/ -Package.StoreAssociation.xml -_pkginfo.txt -*.appx - -# Visual Studio cache files -# files ending in .cache can be ignored -*.[Cc]ache -# but keep track of directories ending in .cache -!*.[Cc]ache/ - -# Others -ClientBin/ -~$* -*~ -*.dbmdl -*.dbproj.schemaview -*.jfm -*.pfx -*.publishsettings -orleans.codegen.cs - -# Including strong name files can present a security risk -# (https://github.com/github/gitignore/pull/2483#issue-259490424) -#*.snk - -# Since there are multiple workflows, uncomment next line to ignore bower_components -# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) -#bower_components/ - -# RIA/Silverlight projects -Generated_Code/ - -# Backup & report files from converting an old project file -# to a newer Visual Studio version. Backup files are not needed, -# because we have git ;-) -_UpgradeReport_Files/ -Backup*/ -UpgradeLog*.XML -UpgradeLog*.htm -ServiceFabricBackup/ -*.rptproj.bak - -# SQL Server files -*.mdf -*.ldf -*.ndf - -# Business Intelligence projects -*.rdl.data -*.bim.layout -*.bim_*.settings -*.rptproj.rsuser - -# Microsoft Fakes -FakesAssemblies/ - -# GhostDoc plugin setting file -*.GhostDoc.xml - -# Node.js Tools for Visual Studio -.ntvs_analysis.dat -node_modules/ - -# Visual Studio 6 build log -*.plg - -# Visual Studio 6 workspace options file -*.opt - -# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) -*.vbw - -# Visual Studio LightSwitch build output -**/*.HTMLClient/GeneratedArtifacts -**/*.DesktopClient/GeneratedArtifacts -**/*.DesktopClient/ModelManifest.xml -**/*.Server/GeneratedArtifacts -**/*.Server/ModelManifest.xml -_Pvt_Extensions - -# Paket dependency manager -.paket/paket.exe -paket-files/ - -# FAKE - F# Make -.fake/ - -# JetBrains Rider -.idea/ -*.sln.iml - -# CodeRush -.cr/ - -# Python Tools for Visual Studio (PTVS) -__pycache__/ -*.pyc - -# Cake - Uncomment if you are using it -# tools/** -# !tools/packages.config - -# Tabs Studio -*.tss - -# Telerik's JustMock configuration file -*.jmconfig - -# BizTalk build output -*.btp.cs -*.btm.cs -*.odx.cs -*.xsd.cs - -# OpenCover UI analysis results -OpenCover/ - -# Azure Stream Analytics local run output -ASALocalRun/ - -# MSBuild Binary and Structured Log -*.binlog - -# NVidia Nsight GPU debugger configuration file -*.nvuser - -# MFractors (Xamarin productivity tool) working folder -.mfractor/ diff --git a/src/OutGridView.Gui/App.xaml b/src/OutGridView.Gui/App.xaml deleted file mode 100644 index 622d784..0000000 --- a/src/OutGridView.Gui/App.xaml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - diff --git a/src/OutGridView.Gui/App.xaml.cs b/src/OutGridView.Gui/App.xaml.cs deleted file mode 100644 index e9351e3..0000000 --- a/src/OutGridView.Gui/App.xaml.cs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -using Avalonia.Markup.Xaml; - -namespace OutGridView.Application -{ - public class App : Avalonia.Application - { - public override void Initialize() - { - AvaloniaXamlLoader.Load(this); - } - } -} diff --git a/src/OutGridView.Gui/Assets/Powershell_black.ico b/src/OutGridView.Gui/Assets/Powershell_black.ico deleted file mode 100644 index 2ef67c7..0000000 Binary files a/src/OutGridView.Gui/Assets/Powershell_black.ico and /dev/null differ diff --git a/src/OutGridView.Gui/AvaloniaAppRunner.cs b/src/OutGridView.Gui/AvaloniaAppRunner.cs deleted file mode 100644 index abf439b..0000000 --- a/src/OutGridView.Gui/AvaloniaAppRunner.cs +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -using System; -using Avalonia; -using System.Collections.Generic; -using Avalonia.Logging.Serilog; -using OutGridView.Application.ViewModels; -using OutGridView.Application.Views; -using OutGridView.Application.Services; -using System.Threading; -using OutGridView.Application.Models; -using System.Linq; -using ReactiveUI; -using Avalonia.Threading; -using Avalonia.Controls; -using OutGridView.Models; - -namespace OutGridView.Application -{ - public static class AvaloniaAppRunner - { - public static App App; - public static AppBuilder Builder; - private static ApplicationData _applicationData; - private static Window _mainWindow; - private static CancellationTokenSource _source; - static AvaloniaAppRunner() - { - App = new App(); - Builder = BuildAvaloniaApp(); - } - - public static AppBuilder BuildAvaloniaApp() => AppBuilder.Configure(App) - .UseReactiveUI() - .UsePlatformDetect() - .UseDataGrid() - .LogToDebug() - .SetupWithoutStarting(); - public static void RunApp(ApplicationData applicationData) - { - _applicationData = applicationData; - AppMain(App); - } - private static void AppMain(Avalonia.Application app) - { - - _mainWindow = new MainWindow - { - DataContext = new MainWindowViewModel(_applicationData), - }; - - _source = new CancellationTokenSource(); - - _mainWindow.Show(); - _mainWindow.Closing += Window_Closing; - - App.MainWindow = _mainWindow; - - App.Run(_source.Token); - - _source.Dispose(); - - } - private static void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) - { - _source.Cancel(); - } - - public static void CloseProgram() - { - _mainWindow.Close(); - } - - public static List GetPassThruIndexes() - { - var mainWindowDataContext = _mainWindow.DataContext as MainWindowViewModel; - return mainWindowDataContext.OutputObjectIndexes; - } - } -} diff --git a/src/OutGridView.Gui/Converters/EnumToDescriptionConverter.cs b/src/OutGridView.Gui/Converters/EnumToDescriptionConverter.cs deleted file mode 100644 index 8b13703..0000000 --- a/src/OutGridView.Gui/Converters/EnumToDescriptionConverter.cs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -using System; -using Avalonia.Data.Converters; -using System.Globalization; - -namespace OutGridView.Application.Converters -{ - public class EnumToDescriptionConverter : IValueConverter - { - public object Convert(object value, Type targetType, object parameter, CultureInfo cultureInfo) - { - var enumValue = value as Enum; - - return enumValue?.GetDescriptionFromEnumValue() ?? Avalonia.AvaloniaProperty.UnsetValue; - } - - public object ConvertBack(object value, Type targetType, object parameter, CultureInfo cultureInfo) - { - return value; - } - } -} diff --git a/src/OutGridView.Gui/Converters/IValueToStringConverter.cs b/src/OutGridView.Gui/Converters/IValueToStringConverter.cs deleted file mode 100644 index a244a83..0000000 --- a/src/OutGridView.Gui/Converters/IValueToStringConverter.cs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -using System; -using Avalonia.Data.Converters; -using OutGridView.Application.Models; -using System.Globalization; -using OutGridView.Models; - -namespace OutGridView.Application.Converters -{ - public class IValueToStringConverter : IValueConverter - { - public object Convert(object value, Type targetType, object parameter, CultureInfo cultureInfo) - { - IValue stringValue = value as IValue; - return stringValue.DisplayValue; - } - - public object ConvertBack(object value, Type targetType, object parameter, CultureInfo cultureInfo) - { - return value; - } - } -} diff --git a/src/OutGridView.Gui/FodyWeavers.xml b/src/OutGridView.Gui/FodyWeavers.xml deleted file mode 100644 index 63fc148..0000000 --- a/src/OutGridView.Gui/FodyWeavers.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/src/OutGridView.Gui/FodyWeavers.xsd b/src/OutGridView.Gui/FodyWeavers.xsd deleted file mode 100644 index f3ac476..0000000 --- a/src/OutGridView.Gui/FodyWeavers.xsd +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - - 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed. - - - - - A comma-separated list of error codes that can be safely ignored in assembly verification. - - - - - 'false' to turn off automatic generation of the XML Schema file. - - - - - \ No newline at end of file diff --git a/src/OutGridView.Gui/Models/Column.cs b/src/OutGridView.Gui/Models/Column.cs deleted file mode 100644 index dad5662..0000000 --- a/src/OutGridView.Gui/Models/Column.cs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -using System.Reflection; -using ReactiveUI.Fody.Helpers; -using ReactiveUI; -using System; -using System.Linq; -using OutGridView.Models; -using System.Collections.Generic; - -namespace OutGridView.Application.Models -{ - public class Column : ReactiveObject - { - public DataTableColumn DataColumn { get; set; } - [Reactive] public Boolean IsVisible { get; set; } - public Column(DataTableColumn dataColumn) - { - DataColumn = dataColumn; - IsVisible = true; - } - } -} diff --git a/src/OutGridView.Gui/Models/Filter.cs b/src/OutGridView.Gui/Models/Filter.cs deleted file mode 100644 index f67857c..0000000 --- a/src/OutGridView.Gui/Models/Filter.cs +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -using System.Reflection; -using ReactiveUI.Fody.Helpers; -using ReactiveUI; -using System; -using System.Linq; -using System.Collections.Generic; -using System.Reactive.Linq; -using OutGridView.Application.Services.FilterOperators; -using OutGridView.Models; - -namespace OutGridView.Application.Models -{ - public class Filter : ReactiveObject - { - //List of Operators used in View - public static IEnumerable Operators { get; } = Enum.GetValues(typeof(StringFilterOperator)).Cast(); - public DataTableColumn DataColumn { get; set; } - [Reactive] public StringFilterOperator SelectedOperator { get; set; } - - public IStringFilterOperator SelectedFilterOperator { [ObservableAsProperty] get; } - [Reactive] public string Value { get; set; } - public Filter(DataTableColumn dataColumn) - { - this.WhenAnyValue(x => x.SelectedOperator, x => x.Value, (op, value) => FilterOperatorLookup.CreateFilterOperatorRule(op, value)) - .ToPropertyEx(this, x => x.SelectedFilterOperator, FilterOperatorLookup.CreateFilterOperatorRule(SelectedOperator, Value)); - - DataColumn = dataColumn; - SelectedOperator = StringFilterOperator.Contains; - Value = string.Empty; - } - } -} diff --git a/src/OutGridView.Gui/Models/FilterGroup.cs b/src/OutGridView.Gui/Models/FilterGroup.cs deleted file mode 100644 index 9bbf287..0000000 --- a/src/OutGridView.Gui/Models/FilterGroup.cs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -using System; -using System.Collections.Generic; -using System.Reactive; -using System.Reactive.Disposables; -using System.Reactive.Linq; -using System.Reflection; -using DynamicData.Binding; -using ReactiveUI; -using OutGridView.Models; - - -namespace OutGridView.Application.Models -{ - public class FilterGroup : ReactiveObject - { - public FilterGroup(DataTableColumn dataColumn, IEnumerable filters) - { - this.DataColumn = dataColumn; - this.Filters = filters; - } - public IEnumerable Filters { get; } - public DataTableColumn DataColumn { get; } - } -} diff --git a/src/OutGridView.Gui/Models/NumericFilter.cs b/src/OutGridView.Gui/Models/NumericFilter.cs deleted file mode 100644 index 6c90bdb..0000000 --- a/src/OutGridView.Gui/Models/NumericFilter.cs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -using System; -namespace OutGridView.Application.Models -{ - public class NumericFilter - { - - } -} diff --git a/src/OutGridView.Gui/Models/NumericFilterOperator.cs b/src/OutGridView.Gui/Models/NumericFilterOperator.cs deleted file mode 100644 index 3a455ac..0000000 --- a/src/OutGridView.Gui/Models/NumericFilterOperator.cs +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -using System; - -namespace OutGridView.Application.Models -{ - public enum NumericFilterOperator - { - - } -} diff --git a/src/OutGridView.Gui/Models/StringFilterOperator.cs b/src/OutGridView.Gui/Models/StringFilterOperator.cs deleted file mode 100644 index 9e8d8c3..0000000 --- a/src/OutGridView.Gui/Models/StringFilterOperator.cs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -using System.ComponentModel; - -namespace OutGridView.Application.Models -{ - public enum StringFilterOperator - { - [Description("Contains")] - Contains, - [Description("Equals")] - Equals, - [Description("Doesn't Contain")] - NotContains, - [Description("Starts With")] - StartsWith, - [Description("Doesn't Equal")] - NotEquals, - [Description("Ends With")] - EndwsWith, - [Description("Is Not Empty")] - NotIsEmpty, - [Description("Is Empty")] - IsEmpty - } -} diff --git a/src/OutGridView.Gui/OutGridView.Gui.csproj b/src/OutGridView.Gui/OutGridView.Gui.csproj deleted file mode 100644 index a275569..0000000 --- a/src/OutGridView.Gui/OutGridView.Gui.csproj +++ /dev/null @@ -1,32 +0,0 @@ - - - - Exe - net6.0 - - - - - %(Filename) - - - Designer - - - - - - - - - - - - - - - - - - - diff --git a/src/OutGridView.Gui/Program.cs b/src/OutGridView.Gui/Program.cs deleted file mode 100644 index e0ac658..0000000 --- a/src/OutGridView.Gui/Program.cs +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -using System; -using Avalonia; -using Avalonia.Logging.Serilog; -using OutGridView.Application.ViewModels; -using OutGridView.Application.Views; -using OutGridView.Application.Services; -using System.Collections.Generic; -using OutGridView.Models; -using System.Text; -using System.Diagnostics; - -//Used to run the module directly from Dotnet -namespace OutGridView.Application -{ - public class Program - { - // Initialization code. Don't use any Avalonia, third-party APIs or any - // SynchronizationContext-reliant code before AppMain is called: things aren't initialized - // yet and stuff might break. - [STAThread] - public static void Main(string[] args) - { - var base64ApplicationData = Console.ReadLine(); - - var applicationData = Serializers.ObjectFromJson(base64ApplicationData); - - AvaloniaAppRunner.RunApp(applicationData); - - var passThruIndexes = AvaloniaAppRunner.GetPassThruIndexes(); - - Console.WriteLine(Serializers.ObjectToJson(passThruIndexes)); - - } - } -} diff --git a/src/OutGridView.Gui/Services/EnumExtensions.cs b/src/OutGridView.Gui/Services/EnumExtensions.cs deleted file mode 100644 index 5661dab..0000000 --- a/src/OutGridView.Gui/Services/EnumExtensions.cs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -using System; -using System.ComponentModel; -using System.Linq; -using System.Reflection; - -public static class EnumExtensions -{ - public static string GetDescriptionFromEnumValue(this Enum value) - { - return value - .GetType() - .GetMember(value.ToString()) - .FirstOrDefault() - ?.GetCustomAttribute() - ?.Description - ?? value.ToString(); - } - - -} diff --git a/src/OutGridView.Gui/Services/FilterBuilder.cs b/src/OutGridView.Gui/Services/FilterBuilder.cs deleted file mode 100644 index 1b7a264..0000000 --- a/src/OutGridView.Gui/Services/FilterBuilder.cs +++ /dev/null @@ -1,96 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Text.RegularExpressions; -using OutGridView.Application.Models; -using OutGridView.Application.Services.FilterOperators; -using System.Collections.ObjectModel; -using DynamicData; -using OutGridView.Models; - - -namespace OutGridView.Application.Services -{ - static class FilterBuilder - { - public static Func BuildFilter(string searchText, IObservableList filters) - { - var filterQuery = BuildFilterQuery(filters); - var quickSearchFilter = BuildQuickSearchFilter(searchText); - return dataList => filterQuery(dataList) && quickSearchFilter(dataList); - } - public static Func BuildFilterQuery(IObservableList filterGroups) - { - - return dataList => filterGroups.Items.All(filterGroup => - { - return filterGroup.Filters.Any(f => - { - //Empty filter is always valid (if it requires a value) - if (f.SelectedFilterOperator.HasValue && String.IsNullOrEmpty(f.Value)) - { - return true; - } - var rule = f.SelectedFilterOperator; - var value = dataList.Values[f.DataColumn.ToString()]; - return rule.Execute(value?.DisplayValue ?? String.Empty); - }); - }); - } - - public static Func BuildQuickSearchFilter(string searchText) - { - List tokens = ParseSearchText(searchText); - - if (string.IsNullOrEmpty(searchText)) - { - return dataList => true; - } - - //For all terms at least-one property matches - return dataList => tokens.All(t => - { - return dataList.Values.Any(data => - { - //Quick Search is NOT case-sensitive - return data.Value != null && data.Value.DisplayValue.ToLowerInvariant().Contains(t.ToLowerInvariant()); - }); - }); - } - public static string TokenPattern = @"[^\s""']+|""([^""]*)""|'([^']*)'"; - //Seperates words by spaces unless they are quoted - public static List ParseSearchText(string searchText) - { - RegexOptions options = RegexOptions.Multiline; - - List stringMatches = new List(); - - foreach (Match m in Regex.Matches(searchText, TokenPattern, options)) - { - string token; - - if (m.Groups[1].Value != String.Empty) - { - token = m.Groups[1].Value; - } - else if (m.Groups[2].Value != String.Empty) - { - token = m.Groups[2].Value; - } - else - { - token = m.Value; - } - - stringMatches.Add(token); - } - return stringMatches; - } - } -} - - diff --git a/src/OutGridView.Gui/Services/FilterOperators/ContainsOperator.cs b/src/OutGridView.Gui/Services/FilterOperators/ContainsOperator.cs deleted file mode 100644 index 5ce2297..0000000 --- a/src/OutGridView.Gui/Services/FilterOperators/ContainsOperator.cs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -using System; -using System.Collections.Generic; - -namespace OutGridView.Application.Services.FilterOperators -{ - public class ContainsOperator : IStringFilterOperator - { - public bool HasValue { get; } = true; - public string Value { get; set; } - public bool Execute(string input) - { - return input.Contains(Value, StringComparison.CurrentCultureIgnoreCase); - } - public string GetPowerShellString() - { - var val = PowerShellCodeGenerator.EscapePowerShellLikeString(Value); - return $"-Like \'*{val}*\'"; - } - } -} diff --git a/src/OutGridView.Gui/Services/FilterOperators/EndsWithOperator.cs b/src/OutGridView.Gui/Services/FilterOperators/EndsWithOperator.cs deleted file mode 100644 index 8c82996..0000000 --- a/src/OutGridView.Gui/Services/FilterOperators/EndsWithOperator.cs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -using System.Globalization; -namespace OutGridView.Application.Services.FilterOperators -{ - public class EndsWithOperator : IStringFilterOperator - { - public bool HasValue { get; } = true; - public string Value { get; set; } - public bool Execute(string input) - { - return input.EndsWith(Value, true, CultureInfo.CurrentCulture); - } - public string GetPowerShellString() - { - var val = PowerShellCodeGenerator.EscapePowerShellLikeString(Value); - return $"-Like \'*{val}\'"; - } - } -} diff --git a/src/OutGridView.Gui/Services/FilterOperators/EqualsOperator.cs b/src/OutGridView.Gui/Services/FilterOperators/EqualsOperator.cs deleted file mode 100644 index 8f205c6..0000000 --- a/src/OutGridView.Gui/Services/FilterOperators/EqualsOperator.cs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -using System; -using System.Collections.Generic; - -namespace OutGridView.Application.Services.FilterOperators -{ - public class EqualsOperator : IStringFilterOperator - { - public bool HasValue { get; } = true; - public string Value { get; set; } - public bool Execute(string input) - { - return input.Equals(Value, StringComparison.CurrentCultureIgnoreCase); - } - public string GetPowerShellString() - { - return $"-EQ \'{Value}\'"; - } - } -} diff --git a/src/OutGridView.Gui/Services/FilterOperators/FilterOperatorLookup.cs b/src/OutGridView.Gui/Services/FilterOperators/FilterOperatorLookup.cs deleted file mode 100644 index e50be65..0000000 --- a/src/OutGridView.Gui/Services/FilterOperators/FilterOperatorLookup.cs +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -using OutGridView.Application.Models; -using System; - -namespace OutGridView.Application.Services.FilterOperators -{ - public static class FilterOperatorLookup - { - public static IStringFilterOperator CreateFilterOperatorRule(StringFilterOperator filterOp, string value) - { - switch (filterOp) - { - case StringFilterOperator.Contains: - return new ContainsOperator { Value = value }; - case StringFilterOperator.Equals: - return new EqualsOperator { Value = value }; - case StringFilterOperator.NotContains: - return new NotContainsOperator { Value = value }; - case StringFilterOperator.StartsWith: - return new StartsWithOperator { Value = value }; - case StringFilterOperator.EndwsWith: - return new EndsWithOperator { Value = value }; - case StringFilterOperator.NotEquals: - return new NotEqualsOperator { Value = value }; - case StringFilterOperator.NotIsEmpty: - return new NotIsEmptyOperator { Value = value }; - case StringFilterOperator.IsEmpty: - return new IsEmptyOperator(); - default: - throw new Exception("Invalid Rule"); - } - } - } -} diff --git a/src/OutGridView.Gui/Services/FilterOperators/IFilterOperator.cs b/src/OutGridView.Gui/Services/FilterOperators/IFilterOperator.cs deleted file mode 100644 index 622ee1d..0000000 --- a/src/OutGridView.Gui/Services/FilterOperators/IFilterOperator.cs +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -namespace OutGridView.Application.Services.FilterOperators -{ - public interface IFilterOperator - { - bool HasValue { get; } - bool Execute(string input); - string GetPowerShellString(); - } -} diff --git a/src/OutGridView.Gui/Services/FilterOperators/IStringFilterOperator.cs b/src/OutGridView.Gui/Services/FilterOperators/IStringFilterOperator.cs deleted file mode 100644 index 73ab59b..0000000 --- a/src/OutGridView.Gui/Services/FilterOperators/IStringFilterOperator.cs +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -namespace OutGridView.Application.Services.FilterOperators -{ - public interface IStringFilterOperator : IFilterOperator - { - string Value { get; } - } -} diff --git a/src/OutGridView.Gui/Services/FilterOperators/IsEmptyOperator.cs b/src/OutGridView.Gui/Services/FilterOperators/IsEmptyOperator.cs deleted file mode 100644 index 0be928e..0000000 --- a/src/OutGridView.Gui/Services/FilterOperators/IsEmptyOperator.cs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -using System; -namespace OutGridView.Application.Services.FilterOperators -{ - public class IsEmptyOperator : IStringFilterOperator - { - public bool HasValue { get; } = false; - public string Value { get; set; } - public bool Execute(string input) - { - return String.IsNullOrWhiteSpace(input); - } - public string GetPowerShellString() - { - return $"-EQ \'\'"; - } - } -} diff --git a/src/OutGridView.Gui/Services/FilterOperators/NotContainsOperators.cs b/src/OutGridView.Gui/Services/FilterOperators/NotContainsOperators.cs deleted file mode 100644 index 8892630..0000000 --- a/src/OutGridView.Gui/Services/FilterOperators/NotContainsOperators.cs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -using System; -namespace OutGridView.Application.Services.FilterOperators -{ - public class NotContainsOperator : IStringFilterOperator - { - public bool HasValue { get; } = true; - public string Value { get; set; } - public bool Execute(string input) - { - return !input.Contains(Value, StringComparison.CurrentCultureIgnoreCase); - } - public string GetPowerShellString() - { - return $"-NotContains \'{Value}\'"; - } - } -} diff --git a/src/OutGridView.Gui/Services/FilterOperators/NotEqualsOperator.cs b/src/OutGridView.Gui/Services/FilterOperators/NotEqualsOperator.cs deleted file mode 100644 index 08bf1a1..0000000 --- a/src/OutGridView.Gui/Services/FilterOperators/NotEqualsOperator.cs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -using System; -namespace OutGridView.Application.Services.FilterOperators -{ - public class NotEqualsOperator : IStringFilterOperator - { - public bool HasValue { get; } = true; - public string Value { get; set; } - public bool Execute(string input) - { - return !input.Equals(Value, StringComparison.CurrentCultureIgnoreCase); - } - public string GetPowerShellString() - { - return $"-NE \'{Value}\'"; - } - } -} diff --git a/src/OutGridView.Gui/Services/FilterOperators/NotIsEmptyOperator.cs b/src/OutGridView.Gui/Services/FilterOperators/NotIsEmptyOperator.cs deleted file mode 100644 index 8d548e9..0000000 --- a/src/OutGridView.Gui/Services/FilterOperators/NotIsEmptyOperator.cs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -using System; -namespace OutGridView.Application.Services.FilterOperators -{ - public class NotIsEmptyOperator : IStringFilterOperator - { - public bool HasValue { get; } = false; - public string Value { get; set; } - public bool Execute(string input) - { - return !String.IsNullOrEmpty(Value); - } - public string GetPowerShellString() - { - return $"-NE \'\'"; - } - } -} diff --git a/src/OutGridView.Gui/Services/FilterOperators/NumericFilterOperator.cs b/src/OutGridView.Gui/Services/FilterOperators/NumericFilterOperator.cs deleted file mode 100644 index c9b3ac5..0000000 --- a/src/OutGridView.Gui/Services/FilterOperators/NumericFilterOperator.cs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -namespace OutGridView.Application.Services.FilterOperators -{ - public abstract class NumericFilterOperator : IFilterOperator - { - public bool HasValue { get; } = true; - public decimal Value { get; set; } - public abstract bool Execute(string input); - public abstract string GetPowerShellString(); - } -} diff --git a/src/OutGridView.Gui/Services/FilterOperators/StartsWithOperator.cs b/src/OutGridView.Gui/Services/FilterOperators/StartsWithOperator.cs deleted file mode 100644 index 79c2953..0000000 --- a/src/OutGridView.Gui/Services/FilterOperators/StartsWithOperator.cs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -using System.Globalization; -namespace OutGridView.Application.Services.FilterOperators -{ - public class StartsWithOperator : IStringFilterOperator - { - public bool HasValue { get; } = true; - public string Value { get; set; } - public bool Execute(string input) - { - return input.StartsWith(Value, true, CultureInfo.CurrentCulture); - } - public string GetPowerShellString() - { - var val = PowerShellCodeGenerator.EscapePowerShellLikeString(Value); - return $"-Like \'{val}*\'"; - } - } -} diff --git a/src/OutGridView.Gui/Services/ModalService.cs b/src/OutGridView.Gui/Services/ModalService.cs deleted file mode 100644 index 04b56dd..0000000 --- a/src/OutGridView.Gui/Services/ModalService.cs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -using OutGridView.Application.ViewModels; -using OutGridView.Application.Views; -using Avalonia; - -namespace OutGridView.Application.Services -{ - public class ModalService - { - public void ShowCodeModal(string filterString) - { - var showCodeModal = new ShowCodeModal - { - DataContext = new ShowCodeModalViewModel(filterString) - }; - - showCodeModal.ShowDialog(Avalonia.Application.Current.MainWindow); - } - } -} diff --git a/src/OutGridView.Gui/Services/PowerShellCodeGenerator.cs b/src/OutGridView.Gui/Services/PowerShellCodeGenerator.cs deleted file mode 100644 index e005a9c..0000000 --- a/src/OutGridView.Gui/Services/PowerShellCodeGenerator.cs +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -using OutGridView.Application.Models; -using System; -using System.Linq; -using System.Collections.Generic; - -namespace OutGridView.Application.Services -{ - public static class PowerShellCodeGenerator - { - public static string GetPowershellForFilterGroups(IEnumerable filterGroups) - { - var whereObjectClauses = filterGroups.Select(filterGroup => - { - var operatorStrings = filterGroup.Filters.Select(filter => - { - var powerShellString = filter.SelectedFilterOperator.GetPowerShellString(); - return $" {filterGroup.DataColumn.PropertyScriptAccessor} {powerShellString} "; - }); - - var operatorString = String.Join("-or", operatorStrings); - return $"Where-Object {{ {operatorString} }}"; - }); - - //New line join for readability - return String.Join(" |" + System.Environment.NewLine, whereObjectClauses); - } - public static string EscapePowerShellLikeString(string str) - { - //PowerShell like has special escape characters - var charsToEscape = new List { "[", "]", "?", "*" }; - foreach (var character in charsToEscape) - { - str = str.Replace(character, "`" + character); - } - return str; - } - } -} diff --git a/src/OutGridView.Gui/Style.xaml b/src/OutGridView.Gui/Style.xaml deleted file mode 100644 index b0eae67..0000000 --- a/src/OutGridView.Gui/Style.xaml +++ /dev/null @@ -1,58 +0,0 @@ - diff --git a/src/OutGridView.Gui/ViewLocator.cs b/src/OutGridView.Gui/ViewLocator.cs deleted file mode 100644 index f83d089..0000000 --- a/src/OutGridView.Gui/ViewLocator.cs +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// Copyright (c) The Avalonia Project. All rights reserved. -// Licensed under the MIT license. See licence.md file in the project root for full license information. - -using System; -using Avalonia.Controls; -using Avalonia.Controls.Templates; -using OutGridView.Application.ViewModels; - -namespace OutGridView -{ - public class ViewLocator : IDataTemplate - { - public bool SupportsRecycling => false; - - public IControl Build(object data) - { - var name = data.GetType().FullName.Replace("ViewModel", "View"); - var type = Type.GetType(name); - - if (type != null) - { - return (Control)Activator.CreateInstance(type); - } - else - { - return new TextBlock { Text = "Not Found: " + name }; - } - } - - public bool Match(object data) - { - return data is ViewModelBase; - } - } -} diff --git a/src/OutGridView.Gui/ViewModels/DataGridViewModel.cs b/src/OutGridView.Gui/ViewModels/DataGridViewModel.cs deleted file mode 100644 index 7af8dd6..0000000 --- a/src/OutGridView.Gui/ViewModels/DataGridViewModel.cs +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -using System; -using System.Collections.Generic; -using OutGridView.Application.Models; -using ReactiveUI; -using System.Collections.ObjectModel; -using System.Reactive.Disposables; -using Avalonia.Controls; -using DynamicData; -using Avalonia; -using OutGridView.Application.Views; -using DynamicData.ReactiveUI; -using System.Reactive.Linq; -using System.Reflection; -using System.Linq; -using System.Reactive; -using System.Threading.Tasks; -using OutGridView.Models; - - -namespace OutGridView.Application.ViewModels -{ - public class DataGridViewModel : ViewModelBase - { - private ReadOnlyObservableCollection _viewObjects; - public ReadOnlyObservableCollection ViewObjects => _viewObjects; - - public SourceList Columns { get; } = new SourceList(); - private ReadOnlyObservableCollection _columnSelect; - public ReadOnlyObservableCollection ColumnSelect => _columnSelect; - public DataGridSelectionMode SelectionMode { get; set; } - public List SelectedRows { get; set; } - public DataGridViewModel(List dataColumns, IObservableList data, OutputModeOption outputMode) - { - var columns = dataColumns.Select(x => new Column(x)); - - Columns.AddRange(columns); - - SelectionMode = OutputModeToSelectionMode(outputMode); - - this.WhenActivated((CompositeDisposable disposables) => - { - Columns.Connect() - .AutoRefresh() - .ObserveOn(RxApp.MainThreadScheduler) - .Bind(out _columnSelect) - .Subscribe(); - - data.Connect() - .Bind(out _viewObjects) - .Subscribe(); - }); - } - - public DataGridSelectionMode OutputModeToSelectionMode(OutputModeOption outputModeOption) - { - switch (outputModeOption) - { - case OutputModeOption.None: - return DataGridSelectionMode.Extended; - case OutputModeOption.Single: - return DataGridSelectionMode.Single; - case OutputModeOption.Multiple: - return DataGridSelectionMode.Extended; - default: - return DataGridSelectionMode.Extended; - } - } - } -} diff --git a/src/OutGridView.Gui/ViewModels/FilterQueryBuilderViewModel.cs b/src/OutGridView.Gui/ViewModels/FilterQueryBuilderViewModel.cs deleted file mode 100644 index d250195..0000000 --- a/src/OutGridView.Gui/ViewModels/FilterQueryBuilderViewModel.cs +++ /dev/null @@ -1,129 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -using System; -using System.Collections.Generic; -using OutGridView.Application.Models; -using ReactiveUI; -using DynamicData; -using DynamicData.ReactiveUI; -using System.Linq; -using System.Reactive; -using System.Reactive.Disposables; -using System.Reactive.Linq; -using System.Collections.ObjectModel; -using ReactiveUI.Fody.Helpers; -using DynamicData.Aggregation; -using OutGridView.Models; -using OutGridView.Application.Services; - -namespace OutGridView.Application.ViewModels -{ - public class FilterQueryBuilderViewModel : ViewModelBase - { - private SourceList DataColumnOptions = new SourceList(); - - private ReadOnlyObservableCollection _visibleDataColumnOptions; - public ReadOnlyObservableCollection VisibleDataColumnOptions => _visibleDataColumnOptions; - [Reactive] public DataTableColumn SelectedAddColumn { get; set; } - public SourceList Filters { get; } = new SourceList(); - public IObservableList FiltersByDataColumn { get; set; } - private ReadOnlyObservableCollection _filtersByDataColumnView; - public ReadOnlyObservableCollection FiltersByDataColumnView => _filtersByDataColumnView; - public ReactiveCommand AddFilterCommand { get; } - public ReactiveCommand RemoveFilterCommand { get; } - public ReactiveCommand ClearFiltersCommand { get; } - public ReactiveCommand ShowCodeCommand { get; } - public Boolean IsColumnSelectVisible { [ObservableAsProperty] get; } - - //Placeholder hack for combo box - private DataTableColumn placeholderColumn = new DataTableColumn("Add Column Filter", "System.Int32"); - - public FilterQueryBuilderViewModel(IObservableList dataColumns) - { - - DataColumnOptions.Add(placeholderColumn); - DataColumnOptions.AddRange(dataColumns.Items); - - SelectedAddColumn = placeholderColumn; - - AddFilterCommand = ReactiveCommand.Create(AddFilter); - RemoveFilterCommand = ReactiveCommand.Create(RemoveFilter); - ClearFiltersCommand = ReactiveCommand.Create(ClearFilters); - ShowCodeCommand = ReactiveCommand.Create(ShowCode); - - - this.WhenActivated((CompositeDisposable disposables) => - { - var filterGroups = Filters.Connect() - .GroupWithImmutableState(x => x.DataColumn) - .Transform(grouping => new FilterGroup(grouping.Key, grouping.Items)); - - FiltersByDataColumn = Filters.Connect() - .AutoRefresh() - .GroupWithImmutableState(x => x.DataColumn) - .Transform(grouping => new FilterGroup(grouping.Key, grouping.Items)) - .ObserveOn(RxApp.MainThreadScheduler) - .DisposeMany() - .AsObservableList(); - - filterGroups - .AutoRefresh() - .ObserveOn(RxApp.MainThreadScheduler) - .Bind(out _filtersByDataColumnView) - .DisposeMany() - .Subscribe(); - - var activeDataColumns = Filters.Connect() - .Transform(x => x.DataColumn) - .DistinctValues(x => x) - .DisposeMany() - .ObserveOn(RxApp.MainThreadScheduler); - - var dataColumnOptions = DataColumnOptions.Connect() - .Except(activeDataColumns) - .Publish(); - - dataColumnOptions - .Bind(out _visibleDataColumnOptions) - .Subscribe(); - - dataColumnOptions - .Count() - .Select(x => x > 1) - .ToPropertyEx(this, x => x.IsColumnSelectVisible); - - dataColumnOptions.Connect(); - }); - } - - private void AddFilter(DataTableColumn dataColumn) - { - if (dataColumn == placeholderColumn) return; - - Filters.Add(new Filter(dataColumn)); - SelectedAddColumn = placeholderColumn; - } - - private void RemoveFilter(Filter filter) - { - Filters.Remove(filter); - } - - private void ShowCode() - { - var filterGroupList = _filtersByDataColumnView.ToList(); - var filterString = PowerShellCodeGenerator.GetPowershellForFilterGroups(filterGroupList); - - //TODO: Inject service - var modalService = new ModalService(); - - modalService.ShowCodeModal(filterString); - } - - private void ClearFilters() - { - Filters.Clear(); - } - } -} diff --git a/src/OutGridView.Gui/ViewModels/MainWindowViewModel.cs b/src/OutGridView.Gui/ViewModels/MainWindowViewModel.cs deleted file mode 100644 index ce7a1aa..0000000 --- a/src/OutGridView.Gui/ViewModels/MainWindowViewModel.cs +++ /dev/null @@ -1,86 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -using System; -using OutGridView.Application.Services; -using ReactiveUI; -using System.Reactive.Disposables; -using ReactiveUI.Fody.Helpers; -using DynamicData; -using System.Linq; -using System.Reactive.Linq; -using System.Reactive; -using Avalonia.Controls; -using OutGridView.Models; -using System.Collections.Generic; - -namespace OutGridView.Application.ViewModels -{ - public class MainWindowViewModel : ViewModelBase - { - private readonly DataTable dataTable; - [Reactive] public FilterQueryBuilderViewModel FilterQueryBuilder { get; set; } - [Reactive] public DataGridViewModel DataGridView { get; set; } - [Reactive] public string SearchText { get; set; } = String.Empty; - public bool IsPassThruEnabled { get; } - public string Title { get; } - public ReactiveCommand PassThruOkCommand { get; } - public ReactiveCommand PassThruCancelCommand { get; } - private readonly OutputModeOption outputMode; - public List OutputObjectIndexes { get; set; } = new List(); - public MainWindowViewModel(ApplicationData applicationData) - { - IsPassThruEnabled = applicationData.PassThru; - Title = applicationData.Title; - outputMode = applicationData.OutputMode; - dataTable = applicationData.DataTable; - - PassThruOkCommand = ReactiveCommand.Create(OnPassThruOk); - PassThruCancelCommand = ReactiveCommand.Create(OnPassThruCancel); - - - var observableColumns = new SourceList(); - - observableColumns.AddRange(dataTable.DataColumns); - - var observableData = new SourceList(); - - observableData.AddRange(dataTable.Data); - this.WhenActivated((CompositeDisposable disposables) => - { - - - - FilterQueryBuilder = new FilterQueryBuilderViewModel(observableColumns); - - var filterData = Observable.Merge(this.WhenAnyValue(x => x.SearchText).Select(_ => Unit.Default), - FilterQueryBuilder.FiltersByDataColumn.Connect().AutoRefresh().Select(_ => Unit.Default)); - - var filterPredicate = filterData.Select(x => FilterBuilder.BuildFilter(SearchText, FilterQueryBuilder.FiltersByDataColumn)); - - var filteredObjects = observableData.Connect() - .Filter(filterPredicate) - .AsObservableList(); - - DataGridView = new DataGridViewModel(dataTable.DataColumns, filteredObjects, outputMode); - }); - } - - public void OnPassThruOk(Window window) - { - OutputObjectIndexes = DataGridView.SelectedRows.Select(x => x.OriginalObjectIndex).ToList(); - - CloseProgam(window); - } - - public void OnPassThruCancel(Window window) - { - CloseProgam(window); - } - - public void CloseProgam(Window window) - { - window.Close(); - } - } -} diff --git a/src/OutGridView.Gui/ViewModels/ShowCodeModalViewModel.cs b/src/OutGridView.Gui/ViewModels/ShowCodeModalViewModel.cs deleted file mode 100644 index f89c6d9..0000000 --- a/src/OutGridView.Gui/ViewModels/ShowCodeModalViewModel.cs +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -using System; -using System.Collections.Generic; -using OutGridView.Application.Models; -using ReactiveUI; -using DynamicData; -using DynamicData.ReactiveUI; -using System.Linq; -using System.Reactive; -using Avalonia; -using System.Reactive.Disposables; - -namespace OutGridView.Application.ViewModels -{ - public class ShowCodeModalViewModel : ViewModelBase - { - public string FilterScript { get; set; } - public ReactiveCommand CopyToClipboardCommand { get; } - - private readonly string _placholderText = "Add a filter to see generated code"; - - public ShowCodeModalViewModel(string filterScript) - { - if (String.IsNullOrEmpty(filterScript)) - { - FilterScript = _placholderText; - } - else - { - FilterScript = filterScript; - } - - CopyToClipboardCommand = ReactiveCommand.Create(CopyToClipboard); - - this.WhenActivated((CompositeDisposable disposables) => - { - }); - } - - private void CopyToClipboard() - { - Avalonia.Application.Current.Clipboard.SetTextAsync(FilterScript); - } - } -} diff --git a/src/OutGridView.Gui/ViewModels/ViewModelBase.cs b/src/OutGridView.Gui/ViewModels/ViewModelBase.cs deleted file mode 100644 index c79c8d1..0000000 --- a/src/OutGridView.Gui/ViewModels/ViewModelBase.cs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -using System; -using System.Collections.Generic; -using System.Text; -using System.Reactive.Disposables; -using ReactiveUI; - -namespace OutGridView.Application.ViewModels -{ - public partial class ViewModelBase : ReactiveObject, ISupportsActivation - { - public ViewModelActivator Activator { get; } - - public ViewModelBase() - { - Activator = new ViewModelActivator(); - this.WhenActivated((CompositeDisposable disposables) => { }); - } - } -} diff --git a/src/OutGridView.Gui/Views/DataGridView.xaml b/src/OutGridView.Gui/Views/DataGridView.xaml deleted file mode 100644 index 38e203b..0000000 --- a/src/OutGridView.Gui/Views/DataGridView.xaml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - Columns - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/OutGridView.Gui/Views/DataGridView.xaml.cs b/src/OutGridView.Gui/Views/DataGridView.xaml.cs deleted file mode 100644 index 954fef4..0000000 --- a/src/OutGridView.Gui/Views/DataGridView.xaml.cs +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -using Avalonia; -using Avalonia.Controls; -using Avalonia.Markup.Xaml; -using OutGridView.Application.ViewModels; -using OutGridView.Application.Models; -using System.Reactive.Disposables; -using ReactiveUI; -using System.Collections.Generic; -using System.Linq; -using OutGridView.Application.Converters; -using DynamicData; -using Avalonia.Data; -using OutGridView.Models; -using System; - -namespace OutGridView.Application.Views -{ - public class DataGridView : ReactiveUserControl - { - - public DataGrid DataGridTable => this.FindControl("DataGridTable"); - - public DataGridView() - { - InitializeComponent(); - } - - private void InitializeComponent() - { - this.WhenActivated((CompositeDisposable disposables) => - { - DataGridTable.WhenAnyValue(x => x.SelectedItem, x => x.SelectedItems, (x, y) => y.OfType().ToList()) - .BindTo(this, x => x.ViewModel.SelectedRows) - .DisposeWith(disposables); - - //Bind the data columns directly on the DataGrid - ViewModel.Columns.Connect() - .AutoRefresh() - .Filter(x => x.IsVisible) - .Transform(ColumnToDataGridTextColumn) - .Bind(out var columns) - .DisposeMany() - .Subscribe(x => - { - DataGridTable.Columns.Clear(); //TODO incremental? - DataGridTable.Columns.AddRange(columns); - }); - }); - - AvaloniaXamlLoader.Load(this); - } - private DataGridTextColumn ColumnToDataGridTextColumn(Column column) - { - var binding = new Binding - { - Path = "Values[" + column.DataColumn.ToString() + "]", - Mode = BindingMode.OneTime - }; - - binding.Converter = new IValueToStringConverter(); - - return new DataGridTextColumn() - { - Binding = binding, - Header = column.DataColumn.Label, - CanUserReorder = true, - CanUserSort = true, - }; - } - } - -} diff --git a/src/OutGridView.Gui/Views/FilterQueryBuilderView.xaml b/src/OutGridView.Gui/Views/FilterQueryBuilderView.xaml deleted file mode 100644 index b4f7625..0000000 --- a/src/OutGridView.Gui/Views/FilterQueryBuilderView.xaml +++ /dev/null @@ -1,53 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/OutGridView.Gui/Views/MainWindow.xaml.cs b/src/OutGridView.Gui/Views/MainWindow.xaml.cs deleted file mode 100644 index c3ab87c..0000000 --- a/src/OutGridView.Gui/Views/MainWindow.xaml.cs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -using Avalonia; -using Avalonia.Controls; -using Avalonia.Markup.Xaml; -using OutGridView.Application.ViewModels; -using System.Reactive.Disposables; -using ReactiveUI; - - -namespace OutGridView.Application.Views -{ - public class MainWindow : ReactiveWindow - { - public MainWindow() - { - InitializeComponent(); - } - - private void InitializeComponent() - { - this.WhenActivated((CompositeDisposable disposables) => - { - }); - AvaloniaXamlLoader.Load(this); - } - } -} diff --git a/src/OutGridView.Gui/Views/ShowCodeModalView.xaml b/src/OutGridView.Gui/Views/ShowCodeModalView.xaml deleted file mode 100644 index ff50b8d..0000000 --- a/src/OutGridView.Gui/Views/ShowCodeModalView.xaml +++ /dev/null @@ -1,11 +0,0 @@ - - - -