From fc62b73cf8750e51ba7f90d58b7b9e60c0cbd735 Mon Sep 17 00:00:00 2001 From: Mathieu Guindon Date: Thu, 15 Jun 2023 00:18:18 -0400 Subject: [PATCH 01/20] version bump to 2.5.9.x --- RubberduckBaseProject.csproj | 2 +- appveyor.yml | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/RubberduckBaseProject.csproj b/RubberduckBaseProject.csproj index 4bfe3d7072..448c141e8d 100644 --- a/RubberduckBaseProject.csproj +++ b/RubberduckBaseProject.csproj @@ -20,7 +20,7 @@ $(DisabledWarnings);4011;1001;1591 - 2.5.2 + 2.5.9 diff --git a/appveyor.yml b/appveyor.yml index 32721582a9..e62b560daf 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,8 +1,8 @@ -version: '2.5.2.{build}' +version: '2.5.9.{build}' # enforce crlf fixing init: - git config --global core.autocrlf true + - git config --global core.autocrlf true # history limited to 15 commits, since we ran into trouble with a limit of 3 # the limit can be rather generous @@ -36,7 +36,7 @@ cache: - '%USERPROFILE%/.gradle/wrapper/dists' install: - set PATH=C:\Program Files (x86)\MSBuild\15.0\Bin;C:\Program Files (x86)\Java\jdk1.8.0;%PATH% + - set PATH=C:\Program Files (x86)\MSBuild\15.0\Bin;C:\Program Files (x86)\Java\jdk1.8.0;%PATH% # set up the environment variables used later in the build process environment: From b02ddbc6157601de23640df53183104b11ec77b7 Mon Sep 17 00:00:00 2001 From: Mathieu Guindon Date: Thu, 15 Jun 2023 00:30:31 -0400 Subject: [PATCH 02/20] add version-swapping script from RD3 repo --- development/SetRegistryForRDVersion.ps1 | 654 ++++++++++++++++++++++++ 1 file changed, 654 insertions(+) create mode 100644 development/SetRegistryForRDVersion.ps1 diff --git a/development/SetRegistryForRDVersion.ps1 b/development/SetRegistryForRDVersion.ps1 new file mode 100644 index 0000000000..f016972fc5 --- /dev/null +++ b/development/SetRegistryForRDVersion.ps1 @@ -0,0 +1,654 @@ +#Requires -RunAsAdministrator + +[cmdletbinding(SupportsShouldProcess = $True)] +param ( + [Parameter(Mandatory = $True)] + [ValidateSet("CurrentVersion", "rd2", "rd3", "2", "3")] + [string]$targetMajorVersion +) + +################################ Script starts at line 532 ################################ + + +$HKLMClsidPath = "Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID\" +$HKCRClsidPath = "Registry::HKEY_CLASSES_ROOT\CLSID\" + +$extensionClsid = "69E0F697-43F0-3B33-B105-9B8188A6F040" +$dockableToolWindowClsid = "69E0F699-43F0-3B33-B105-9B8188A6F040" + +$script:rd3Version = "3.0.0.0" +$script:rd2Version = "2.5.2.0" + +#There are currently(4/23) 2 registry keys to be added for RD3: +#Rubberduck.Extension and Rubberduck.DockableToolWindow +$numberOfRD3Keys = 2 + +$rdExtension = @{ + HKLMPath = "${HKLMClsidPath}{${extensionClsid}}" + ShortHKLMPath = "HKLM:\SOFTWARE\Classes\CLSID\{}" + HKCRPath = "${HKCRClsidPath}{${extensionClsid}}" + ShortHKCRPath = "HKCR:\CLSID\{}" + RD2ValuesPrototypeKey = "Registry::HKEY_CLASSES_ROOT\CLSID\{${extensionClsid}}\InProcServer32\${rd2Version}" +} + +$rdDockableToolWindow = @{ + HKLMPath = "${HKLMClsidPath}{${dockableToolWindowClsid}}" + ShortHKLMPath = "HKLM:\SOFTWARE\Classes\CLSID\{}" + HKCRPath = "${HKCRClsidPath}{${dockableToolWindowClsid}}" + ShortHKCRPath = "HKCR:\CLSID\{}" + RD2ValuesPrototypeKey = "Registry::HKEY_CLASSES_ROOT\CLSID\{${dockableToolWindowClsid}}\InProcServer32\${rd2Version}" +} + +$rdRegistryKeyPropertyNames = @("Assembly", "Class", "CodeBase", "RuntimeVersion") + +$rd3HKLMDataPersistancePath = (Get-ChildItem env:USERPROFILE).Value + ` + "\AppData\Roaming\Rubberduck\RD3HKLMValues.json" + + +function Test-CanProcessToTargetVersion($targetIsRD2){ + + Write-Verbose "Evaluating Registry content..." + + $result = @{CanProcess = $False} + + $rd3HKLMKeys = Get-HKLMKeysOfInterest (Get-HKLMClsidKeys) + + if ((Test-IsConfiguredForRD2 $rd3HKLMKeys) -and $targetIsRD2){ + $result.Message = "Registry is configured for Rubberduck Version 2 - Nothing to do" + $result + return + } + + if ((Test-IsConfiguredForRD3 $rd3HKLMKeys) -and (-not $targetIsRD2)){ + $result.Message = "Registry is configured for Rubberduck Version 3 - Nothing to do" + $result + return + } + + if (-not $targetIsRD2){ + + $valuesFromFileFailureMsg = "Prior RD3 values unavailable. Please build the Rubberduck3 solution to setup the registry" + if (-not (Test-Path (Get-CachedRD3KeyValuesFilepath))){ + $result.Message = $valuesFromFileFailureMsg + $result + return + } + + $regKeyModelsFromFile = New-MaybeRegistryKeyModelsFromFile + + if ($regKeyModelsFromFile.Count -ne $numberOfRD3Keys){ + $result.Message = $valuesFromFileFailureMsg + $result + return + } + + } else { + foreach ($prototypeKey in Get-RD2PrototypeKeys){ + if (-not (Test-Path $prototypeKey)){ + $result.Message = "RD2 Registry Key(s) not found - script depends on an installed version of RD2" + $result + return + } + } + } + + $result = @{ + "CanProcess" = $True + "ModelsFromFile" = $regKeyModelsFromFile + "Rd3HKLMClsidKeys" = $rd3HKLMKeys + } + $result +} + +function Restore-RubberduckV2($rdHKLMClsidKeys){ + Write-Verbose "Restoring registry values to support Rubberduck Version 2" + + $registryKeyModels = Get-RegistryKeyModels $rdHKLMClsidKeys + + if (-not (Test-FileIsLocked (Get-CachedRD3KeyValuesFilepath)) ){ + Export-RD3RegistryValues $registryKeyModels + } + + Remove-RD3RegistryKeys $rdHKLMClsidKeys + + Set-RD2InProcServer32Values + + "Registry keys set to support Rubberduck Version 2" +} + +function Restore-RubberduckV3($regKeyModels){ + + Write-Verbose "Restoring registry values to support Rubberduck Version 3" + + Set-Rd3Version $regKeyModels + + Add-RD3RegistryKeys $regKeyModels + + Set-RD3InProcServer32Values $regKeyModels + + "Registry keys set to support Rubberduck Version 3" +} + +function Set-Rd3Version($regKeyModels){ + if ($regKeyModels.Count -lt 1){ + return + } + + $assemblyValue = $regKeyModels[0].Properties.Assembly + $idxOf3 = $assemblyValue.IndexOf("3") + + $script:rd3Version = $assemblyValue.Substring(` + $idxOf3, $assemblyValue.IndexOf(",", $idxOf3) - $idxOf3) +} + +function Add-RD3RegistryKeys($regKeyModels){ + + foreach ($regModel in $regKeyModels){ + if (Test-ContainsExtensionClsid $regModel.KeyPath){ + $shortPath = $rdExtension.ShortHKLMPath + } else { + $shortPath = $rdDockableToolWindow.ShortHKLMPath + } + + Write-Verbose ("Restore RD3 values to Key ${shortPath}\InProcServer32") + + Add-RegistryKeys (Get-Rd3HKLMPaths $regModel.KeyPath) + + $rdRegistryKeyPropertyNames | + ForEach-Object { Set-RegistryKeyProperties $regModel $_ } + } +} + +function Get-CurrentRDVersionSetup(){ + + $rd3HKLMKeys = Get-HKLMKeysOfInterest (Get-HKLMClsidKeys) + + $hasRD2Key = Test-Path $rdExtension.RD2ValuesPrototypeKey + + switch ($rd3HKLMKeys.Count) + { + 0 { if ($hasRD2Key){2}else{10}} #RD2 + 2 {3} #RD3 + Default {10} #Unknown + } +} + +function Get-CachedRD3KeyValuesFilepath($filepath = $null){ + + $result = $rd3HKLMDataPersistancePath + if (-not $null -eq $filepath){ + $result = $filePath + } + + $result +} + +function Get-HKLMKeysOfInterest($keyNames){ + + if ($keyNames.Count -eq 0){ + @() + return + } + + $result = $keyNames | Where-Object { Test-IsRDClsidOfInterest $_ } | + ForEach-Object {"${HKLMClsidPath}${_}"} + + if ($null -eq $result){ + $result = @() + } + + $result +} + +function Set-RD2InProcServer32Values(){ + [cmdletbinding(SupportsShouldProcess = $True)] + param () + + foreach ($key in Get-RD2PrototypeKeys){ + + $InProcServer32Key = Get-InProcServer32PathFromKey $key + + if (Test-ContainsExtensionClsid $key){ + Write-Verbose ("Restore RD2 values to Key " + $rdExtension.ShortHKCRPath + "\InProcServer32") + } else { + Write-Verbose ("Restore RD2 values to Key " + $rdDockableToolWindow.ShortHKCRPath + "\InProcServer32") + } + + if ($PSCmdlet.ShouldProcess($InProcServer32Key)){} + + $model = New-RegistryKeyModelFromRegistryKey $key + + $model.KeyPath = $InProcServer32Key + + $rdRegistryKeyPropertyNames | ForEach-Object { + Set-RegistryKeyProperties $model $_ + } + } +} + +function Set-RD3InProcServer32Values(){ + [cmdletbinding(SupportsShouldProcess = $True)] + param ( + [Parameter (Mandatory = $true)] + [Object[]] $regKeyModels + ) + + foreach ($model in $regKeyModels){ + + if (Test-ContainsExtensionClsid $model.KeyPath){ + $shortPath = $rdExtension.ShortHKCRPath + $keyPath = $rdExtension.HKCRPath + } else { + $shortPath = $rdDockableToolWindow.ShortHKCRPath + $keyPath = $rdDockableToolWindow.HKCRPath + } + + $InProcServer32Key = $keyPath + "\InProcServer32" + Write-Verbose ("Restore RD3 values to Key ${shortPath}\InProcServer32") + + if ($PSCmdlet.ShouldProcess($InProcServer32Key)){} + + $clone = (New-RdRegistryKeyModel $model.KeyPath $model.Properties) + $clone.KeyPath = $InProcServer32Key + + $rdRegistryKeyPropertyNames | ForEach-Object { + Set-RegistryKeyProperties $clone $_ + } + } +} + +function Get-RD2PrototypeKeys(){ + @( + $rdExtension.RD2ValuesPrototypeKey + $rdDockableToolWindow.RD2ValuesPrototypeKey + ) +} + + +function Get-RegistryKeyModels($rdHKLMKeys){ + + $registryKeyModels = @() + foreach ($k in $rdHKLMKeys){ + $registryKeyModels += ` + (New-RegistryKeyModelFromRegistryKey ` + ($k + "\InProcServer32\" + $script:rd3Version)) + } + + $registryKeyModels +} + +function Remove-RD3RegistryKeys($regKeys){ + Write-Verbose "Removing RD3 HKey_LOCAL_MACHINE registry keys..." + Remove-RegistryKeys $regKeys +} + +function Export-RD3RegistryValues($registryKeyModels, $exportPath = $null){ + + Write-Verbose "Saving current RD3 HKey_LOCAL_MACHINE registry values..." + + $filepath = Get-CachedRD3KeyValuesFilepath $exportPath + + ($registryKeyModels | ConvertTo-Json) | Out-File $filepath +} + +function Get-Rd3HKLMPaths($targetKey, $scriptVersion = $null){ + + $versionToken = $script:rd3Version + if ($null -ne $scriptVersion){ + $versionToken = $scriptVersion + } + + $baseTargetKey = $rdExtension.HKLMPath + if (Test-ContainsDockableToolWindowClsid $targetKey){ + $baseTargetKey = $rdDockableToolWindow.HKLMPath + } + + @( + $baseTargetKey + ($baseTargetKey + "\InProcServer32") + ($baseTargetKey + "\InProcServer32\" + $versionToken) + ) +} + +function New-RdRegistryKeyModel($registryKey = $null, $properties = @{}){ + @{ + "KeyPath" = $registryKey + "IsRDRegistryKeyModel" = $True + 'Properties' = $properties + } +} + +function New-RegistryKeyModelFromRegistryKey($registryKey){ + + $properties = @{} + if (Test-Path $registryKey){ + $rdRegistryKeyPropertyNames | ForEach-Object { + $properties.Add($_, (Get-RegistryPropertyValue $registryKey $_))} + } + + New-RdRegistryKeyModel $registryKey $properties +} + +function New-MaybeRegistryKeyModelsFromFile($filePath = $null){ + + $results = $null + $modelsFilepath = Get-CachedRD3KeyValuesFilepath $filepath + + $content = Get-Content $modelsFilepath + if ($null -eq $content -or ($content.Trim() -eq "")){ + $results + return + } + + try { + $jsonObjs = $content | ConvertFrom-Json + } + catch { + $results + return + } + + $results = @() + foreach ($obj in $jsonObjs){ + $model = (Convert-MaybeJsonToRegistryKeyModel $obj) + if ($null -eq $model){ + $results = $null + $results + return + } else { + $results += $model + } + } + $results +} + +function Convert-MaybeJsonToRegistryKeyModel($jsonObject){ + #https://stackoverflow.com/questions/3740128/pscustomobject-to-hashtable + $props = @{} + $jsonObject.Properties.psobject.properties | ForEach-Object { $props[$_.Name] = $_.Value } + + $model = New-RdRegistryKeyModel $jsonObject.KeyPath $props + + if (Test-IsValidRegistryKeyModel $model){ + $model + return + } + $null +} + +function Get-InProcServer32PathFromKey($key){ + $target = "InProcServer32" + $key.Substring(0, $key.IndexOf($target) + $target.Length) +} + +function Test-IsValidRegistryKeyModel($model){ + + if ($null -eq $model){ + $False + return + } elseif (-not ((Test-HasAllKeys $model) -and (Test-AllKeysNotNull $model))){ + $False + return + } elseif (-not ((Test-HasAllProperties $model) -and (Test-AllPropertiesNotNull $model))){ + $False + return + } + + $True + } + +function Test-ContainsExtensionClsid($token){ + ($token -like "*${extensionClsid}*") +} + +function Test-ContainsDockableToolWindowClsid($token){ + ($token -like "*${dockableToolWindowClsid}*") +} + +function Test-IsRDClsidOfInterest($clsid){ + (Test-ContainsExtensionClsid $clsid) -or ` + (Test-ContainsDockableToolWindowClsid $clsid) +} + +function Test-HasAllKeys($model){ + (@("KeyPath", "Properties") | + Where-Object {-not $model.ContainsKey($_)}).Count -eq 0 +} + +function Test-AllKeysNotNull($model){ + (@("KeyPath", "Properties") | + Where-Object {$null -eq $model[$_]}).Count -eq 0 +} + +function Test-HasAllProperties($model){ + ($rdRegistryKeyPropertyNames | + Where-Object {-not $model.Properties.ContainsKey($_)}).Count -eq 0 +} + +function Test-AllPropertiesNotNull($model){ + ($rdRegistryKeyPropertyNames | + Where-Object {$null -eq $model.Properties[$_]}).Count -eq 0 +} + +function Test-IsConfiguredForRD2($rd3HKLMKeys){ + (Get-CurrentRDVersionSetup $rd3HKLMKeys) -eq 2 +} + +function Test-IsConfiguredForRD3($rd3HKLMKeys){ + (Get-CurrentRDVersionSetup $rd3HKLMKeys) -eq 3 +} + +function Test-FileIsLocked($file){ + #https://stackoverflow.com/questions/24992681/powershell-check-if-a-file-is-locked + try { + [IO.File]::OpenWrite($file).close() + $false + } + catch { + $true + } +} + +function Get-HKLMClsidKeys(){ + $hklmKeys = @() + try + { + $reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey(` + [Microsoft.Win32.RegistryHive]"LocalMachine", $env:COMPUTERNAME) + + $subKey = $reg.OpenSubKey("SOFTWARE\Classes\CLSID") + + $subKeyNames = $subKey | + Select-Object Name, @{ + label='SubKeys' + expression={$_.GetSubKeyNames()} + } + + $hklmKeys = $subKeyNames.SubKeys + } + catch { + $hklmKeys = @() + } + finally { + $subKey.Dispose() + } + + $hklmKeys +} + +function Remove-RegistryKeys(){ + [cmdletbinding(SupportsShouldProcess = $True)] + param ( + [Parameter(Mandatory = $True)] + [string[]]$keyPaths + ) + + foreach ($key in $keyPaths | Where-Object {Test-Path $_}){ + if ($PSCmdlet.ShouldProcess($key, "Remove-Item")){ + Write-Verbose ("Deleting Registry Key: " + $key) + Remove-Item -Path $key -Recurse + } + } +} + +function Add-RegistryKeys(){ + [cmdletbinding(SupportsShouldProcess = $True)] + param ( + [Parameter (Mandatory = $true)] + [Object] $pathsToCreate + ) + + foreach ($kp in $pathsToCreate){ + if ($PSCmdlet.ShouldProcess($kp, "New-Item")){ + New-Item -Path $kp + Write-Verbose ("Added Registry Key: " + $kp) + } + } +} + +function Set-RegistryKeyProperties(){ + [cmdletbinding(SupportsShouldProcess = $True)] + param ( + [Parameter (Mandatory = $true)] + [Object] $registryKeyModel, + [Parameter (Mandatory = $true)] + [string] $valueName + ) + + $valueData = $registryKeyModel.Properties[$valueName] + + $shouldProcessMsg = "'" + $valueName + "' = '" + $valueData + "'" + + if ($PSCmdlet.ShouldProcess($shouldProcessMsg, "Set-ItemProperty")){ + Set-ItemProperty -Path $registryKeyModel.KeyPath -Name $valueName -Value $valueData + Write-Verbose ("Set Property: '" + $shouldProcessMsg + "'") + } +} + +function Get-RegistryPropertyValue($registryKey, $propertyName){ + (Get-ItemPropertyValue -Path $registryKey -Name $propertyName) +} + +################################ Start of Script ################################ + +if ($targetMajorVersion -eq "CurrentVersion"){ + switch(Get-CurrentRDVersionSetup) + { + 2 {"Current Registry configuration: Rubberduck Version 2"} + 3 {"Current Registry configuration: Rubberduck Version 3"} + Default {"Unknown: Rubberduck2 and/or Rubberduck3 may not be installed"} + } + exit +} + +$validationResults = Test-CanProcessToTargetVersion ($targetMajorVersion -like "*2") + +if (-not $validationResults.CanProcess){ + $validationResults.Message + exit +} + +if ($targetMajorVersion -like "*2"){ + Restore-RubberduckV2 $validationResults.Rd3HKLMClsidKeys + +} else { + Restore-RubberduckV3 $validationResults.ModelsFromFile +} + +<# +.SYNOPSIS +Modifies the registry to enable either the Rubberduck 3 or the Rubberduck 2.5.2.0 VBIDE Add-In. +.DESCRIPTION +Modifies the registry to enable either the Rubberduck 3 or the Rubberduck 2.5.2.0 VBIDE Add-In. + +Why: +RD3 re-uses RD2 CLSIDs. Consequently, the two Add-Ins cannot co-exist in memory. +When the RD3 solution is built, the build process introduces new keys to the LocalMachine (HKLM) hive. +Re-building RD2 does not configure the registry to load RD2 once the HKLM keys have been introduced. + +*** The script must be invoked from a PowerShell session with Administrator privileges *** + +To run the script to see what it does WITHOUT making changes, enter the following: +(The commands below assume a Powershell session is opened in the folder containing the SetRegistryForRDVersion.ps1 script) + +Setup for RD2: PS> .\SetRegistryForRDVersion.ps1 2 -Verbose -WhatIf +Setup for RD3: PS> .\SetRegistryForRDVersion.ps1 3 -Verbose -WhatIf + +**************************************************************************************** +Note: Absence of the -WhatIf switch parameter from the above expressions will enable the +script to make changes to the registry. +***************************************************************************************** + +To see the currently active version: +PS> .\SetRegistryForRDVersion.ps1 CurrentVersion + +Alternatively, re-building the RD3 solution will also modify the Registry, enabling the RD3 Add-In + +There is more content available using the -examples, -detailed, or -full switches as indicated in REMARKS +.NOTES +Setting up for Rubberduck Version 2: + +1. Deletes two HKLM registry keys (including their children) introduced by building RD3: + HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID\{69E0F697-43F0-3B33-B105-9B8188A6F040} (Rubberduck.Extension) + HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID\{69E0F699-43F0-3B33-B105-9B8188A6F040} (Rubberuck.DockableToolWindow) + Note: before deleting, the script saves values contained in these keys to a file (RD3HKLMValues.json) located in + the same folder as the Rubberduck.config file. + +2. Modifies the values of: + HKEY_CLASSES_ROOT\CLSID\{69E0F697-43F0-3B33-B105-9B8188A6F040}\InProcServer32 and + HKEY_CLASSES_ROOT\CLSID\{69E0F699-43F0-3B33-B105-9B8188A6F040}\InProcServer32 + + to match the values contained in + + HKEY_CLASSES_ROOT\CLSID\{69E0F697-43F0-3B33-B105-9B8188A6F040}\InProcServer32\2.5.2.0 and + HKEY_CLASSES_ROOT\CLSID\{69E0F699-43F0-3B33-B105-9B8188A6F040}\InProcServer32\2.5.2.0 respectively + +Setting up for Rubberduck Version 3: + +1. Re-creates the RD3 HKLM registry keys and their children based on data contained in + RD3HKLMValues.json. The RD3HKLMValues.json file is generated/refreshed when the script is run + to update from RD3 to RD2. + +2. Modifies the following registry keys with RD3 values + + HKEY_CLASSES_ROOT\CLSID\{69E0F697-43F0-3B33-B105-9B8188A6F040}\InProcServer32 and + HKEY_CLASSES_ROOT\CLSID\{69E0F699-43F0-3B33-B105-9B8188A6F040}\InProcServer32 + + +3. If the RD3HKLMValues.json file is missing or cannot be used for any reason, the user is prompted to +rebuild the Rubbberduck3 solution. Rebuilding the solution results in the same registry changes +as described in steps 1 and 2 above. + +Note: Closing and re-opening the Registry Editor application will show that adding the two HKLM keys +in #1 above, resulted in the creation of: + HKEY_CLASSES_ROOT\CLSID\{69E0F697-43F0-3B33-B105-9B8188A6F040}\InProcServer32\3.X.X.X and + HKEY_CLASSES_ROOT\CLSID\{69E0F699-43F0-3B33-B105-9B8188A6F040}\InProcServer32\3.X.X.X + +.EXAMPLE +...\SetRegistryForRDVersion.ps1 CurrentVersion +Script output identifies the Rubberduck version currently setup in the registry + +.EXAMPLE +...\SetRegistryForRDVersion.ps1 2 -WhatIf +See operations that 'would have' taken place to setup for RD2 + +.EXAMPLE +...\SetRegistryForRDVersion.ps1 2 -Verbose -WhatIf +See operations that 'would have' taken place to setup for RD2 with the most descriptive content + +.EXAMPLE +...\SetRegistryForRDVersion.ps1 rd2 -Verbose +Allow the script to make changes to the registry to setup RD2, providing a narrative of the process + +.EXAMPLE +.\SetRegistryForRDVersion.ps1 3 -Verbose -WhatIf +See operations that 'would have' taken place to setup for RD3 with the most descriptive content + +.EXAMPLE +...\SetRegistryForRDVersion.ps1 rd3 -Verbose -WhatIf +See operations that 'would have' taken place to setup for RD3 with the most descriptive content + +.EXAMPLE +...\SetRegistryForRDVersion.ps1 rd3 +Allow the script to make changes to the registry to setup RD3 with limited descriptive content +#> From b224acf9b003eea7469bcb03b40fc9534daa25e1 Mon Sep 17 00:00:00 2001 From: Mathieu Guindon Date: Fri, 16 Jun 2023 00:22:15 -0400 Subject: [PATCH 03/20] fixed version check (added octokit) --- Rubberduck.Core/Rubberduck.Core.csproj | 1 + .../VersionCheck/VersionCheckService.cs | 42 ++++++++----------- 2 files changed, 18 insertions(+), 25 deletions(-) diff --git a/Rubberduck.Core/Rubberduck.Core.csproj b/Rubberduck.Core/Rubberduck.Core.csproj index 9af3bb0ee1..9c4dc78bb9 100644 --- a/Rubberduck.Core/Rubberduck.Core.csproj +++ b/Rubberduck.Core/Rubberduck.Core.csproj @@ -84,6 +84,7 @@ 4.5.10 + 4.5.0 diff --git a/Rubberduck.Core/VersionCheck/VersionCheckService.cs b/Rubberduck.Core/VersionCheck/VersionCheckService.cs index 86205806f6..3a99bd1eab 100644 --- a/Rubberduck.Core/VersionCheck/VersionCheckService.cs +++ b/Rubberduck.Core/VersionCheck/VersionCheckService.cs @@ -2,9 +2,10 @@ using Rubberduck.Settings; using System; using System.Linq; -using System.Net.Http; using System.Threading; using System.Threading.Tasks; +using Octokit; +using System.Net; namespace Rubberduck.VersionCheck { @@ -29,6 +30,8 @@ public async Task GetLatestVersionAsync(GeneralSettings settings, Cance try { + ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; + return settings.IncludePreRelease ? await GetGitHubNext() : await GetGitHubMain(); @@ -43,38 +46,27 @@ public async Task GetLatestVersionAsync(GeneralSettings settings, Cance public bool IsDebugBuild { get; } public string VersionString { get; } + private const string GitHubOrgName = "rubberduck-vba"; + private const string GitHubRepoName = "Rubberduck"; + private const string UserAgentProductName = "Rubberduck"; + private GitHubClient GetGitHubClient() => new GitHubClient(new ProductHeaderValue(UserAgentProductName, CurrentVersion.ToString(3))); + private async Task GetGitHubMain() { - var url = new Uri("https://github.com/repos/rubberduck-vba/Rubberduck/releases/latest"); - using (var client = new HttpClient()) - { - client.DefaultRequestHeaders.UserAgent.Add(new System.Net.Http.Headers.ProductInfoHeaderValue("rubberduck.version-check")); - using (var response = await client.GetAsync(url)) - { - var content = await response.Content.ReadAsStringAsync(); - var tagName = (string)JsonConvert.DeserializeObject(content).tag_name; + var client = GetGitHubClient(); + var response = await client.Repository.Release.GetLatest(GitHubOrgName, GitHubRepoName); + var tagName = response.TagName; - // assumes a tag name like "v2.5.3.0" - return new Version(tagName.Substring("v".Length)); - } - } + return new Version(tagName.Substring("v".Length)); } private async Task GetGitHubNext() { - var url = new Uri("https://github.com/repos/rubberduck-vba/Rubberduck/releases"); - using (var client = new HttpClient()) - { - client.DefaultRequestHeaders.UserAgent.Add(new System.Net.Http.Headers.ProductInfoHeaderValue("rubberduck.version-check")); - using (var response = await client.GetAsync(url)) - { - var content = await response.Content.ReadAsStringAsync(); - var tagName = (string)JsonConvert.DeserializeObject(content)[0].tag_name; + var client = GetGitHubClient(); + var response = await client.Repository.Release.GetAll(GitHubOrgName, GitHubRepoName); + var tagName = response.FirstOrDefault()?.TagName ?? "Prerelease-v0.0.0"; - // assumes a tag name like "Prerelease-v2.5.2.1234" - return new Version(tagName.Substring("Prerelease-v".Length)); - } - } + return new Version(tagName.Substring("Prerelease-v".Length)); } } } \ No newline at end of file From 2362f044cb84d992e1c1055c83d6abfbd9dfbda2 Mon Sep 17 00:00:00 2001 From: Mathieu Guindon Date: Fri, 16 Jun 2023 00:22:28 -0400 Subject: [PATCH 04/20] bumped to 2.5.9 --- development/SetRegistryForRDVersion.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/development/SetRegistryForRDVersion.ps1 b/development/SetRegistryForRDVersion.ps1 index f016972fc5..7a3696ca90 100644 --- a/development/SetRegistryForRDVersion.ps1 +++ b/development/SetRegistryForRDVersion.ps1 @@ -17,7 +17,7 @@ $extensionClsid = "69E0F697-43F0-3B33-B105-9B8188A6F040" $dockableToolWindowClsid = "69E0F699-43F0-3B33-B105-9B8188A6F040" $script:rd3Version = "3.0.0.0" -$script:rd2Version = "2.5.2.0" +$script:rd2Version = "2.5.9.0" #There are currently(4/23) 2 registry keys to be added for RD3: #Rubberduck.Extension and Rubberduck.DockableToolWindow From 28970783c6580fa9118490b93ad1d083cb0baada Mon Sep 17 00:00:00 2001 From: Mathieu Guindon Date: Sat, 17 Jun 2023 23:53:56 -0400 Subject: [PATCH 05/20] fix inspections link --- Rubberduck.Core/UI/Inspections/InspectionResultsViewModel.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Rubberduck.Core/UI/Inspections/InspectionResultsViewModel.cs b/Rubberduck.Core/UI/Inspections/InspectionResultsViewModel.cs index d40dceefe3..74ebb3a2c3 100644 --- a/Rubberduck.Core/UI/Inspections/InspectionResultsViewModel.cs +++ b/Rubberduck.Core/UI/Inspections/InspectionResultsViewModel.cs @@ -775,7 +775,7 @@ public bool CanDisableInspection } } - private static readonly Uri _inspectionsHomeUrl = new Uri("https://rubberduckvba.com/inspections"); + private static readonly Uri _inspectionsHomeUrl = new Uri("https://rubberduckvba.com/features/summary?name=inspections"); public Uri InspectionDetailsUrl => _selectedInspection == null ? _inspectionsHomeUrl From fa853db4784a5e04f662da0898b2346dd05fc0d9 Mon Sep 17 00:00:00 2001 From: Mathieu Guindon Date: Sat, 17 Jun 2023 23:54:28 -0400 Subject: [PATCH 06/20] update about banner --- Rubberduck.Core/UI/About/AboutControl.xaml | 4 ++-- Rubberduck.Resources/Rubberduck_Banner.png | Bin 0 -> 31873 bytes 2 files changed, 2 insertions(+), 2 deletions(-) create mode 100644 Rubberduck.Resources/Rubberduck_Banner.png diff --git a/Rubberduck.Core/UI/About/AboutControl.xaml b/Rubberduck.Core/UI/About/AboutControl.xaml index fbab3bac7e..5f9ff8f418 100644 --- a/Rubberduck.Core/UI/About/AboutControl.xaml +++ b/Rubberduck.Core/UI/About/AboutControl.xaml @@ -13,7 +13,7 @@ - + - - @@ -80,7 +80,7 @@ - + diff --git a/Rubberduck.Core/UI/Controls/GroupingGrid.xaml b/Rubberduck.Core/UI/Controls/GroupingGrid.xaml index 910b9c96f7..5418ff0505 100644 --- a/Rubberduck.Core/UI/Controls/GroupingGrid.xaml +++ b/Rubberduck.Core/UI/Controls/GroupingGrid.xaml @@ -16,7 +16,7 @@ - @@ -49,7 +49,7 @@ ItemsSource="{Binding Parameters, UpdateSourceTrigger=PropertyChanged}" SelectedIndex="0" Name="ParameterGrid" - ItemContainerStyle="{DynamicResource PrettyListBoxItemModified}" + ItemContainerStyle="{StaticResource PrettyListBoxItemModified}" AlternationCount="2"> diff --git a/Rubberduck.Core/UI/Refactorings/ReorderParameters/ReorderParametersView.xaml b/Rubberduck.Core/UI/Refactorings/ReorderParameters/ReorderParametersView.xaml index f37ed1a98b..55eeb0d7f0 100644 --- a/Rubberduck.Core/UI/Refactorings/ReorderParameters/ReorderParametersView.xaml +++ b/Rubberduck.Core/UI/Refactorings/ReorderParameters/ReorderParametersView.xaml @@ -45,7 +45,7 @@ SelectedIndex="0" Name="ParameterGrid" AllowDrop="True" - ItemContainerStyle="{DynamicResource PrettyListBoxItem}" + ItemContainerStyle="{StaticResource PrettyListBoxItem}" Drop="ParameterGrid_Drop" DragEnter="ParameterGrid_DragEnter" PreviewMouseMove="ParameterGrid_PreviewMouseMove" @@ -88,7 +88,7 @@ @@ -130,7 +130,7 @@ @@ -196,7 +196,7 @@ VerticalGridLinesBrush="Transparent" HeadersVisibility="None" ScrollViewer.HorizontalScrollBarVisibility="Disabled" - ItemContainerStyle="{DynamicResource PrettifyRow}" + ItemContainerStyle="{StaticResource PrettifyRow}" ColumnHeaderHeight="22" BorderThickness="0" Height="200" diff --git a/Rubberduck.Core/UI/Settings/SettingsControl.xaml b/Rubberduck.Core/UI/Settings/SettingsControl.xaml index aa5a9f1ac1..1f186ecd84 100644 --- a/Rubberduck.Core/UI/Settings/SettingsControl.xaml +++ b/Rubberduck.Core/UI/Settings/SettingsControl.xaml @@ -18,7 +18,7 @@ - @@ -47,7 +47,7 @@ diff --git a/Rubberduck.Core/UI/Settings/UnitTestSettings.xaml b/Rubberduck.Core/UI/Settings/UnitTestSettings.xaml index c0b517041d..0ebb2ff3a7 100644 --- a/Rubberduck.Core/UI/Settings/UnitTestSettings.xaml +++ b/Rubberduck.Core/UI/Settings/UnitTestSettings.xaml @@ -84,7 +84,7 @@ Margin="5,0,0,5" Width="210" HorizontalAlignment="Left" - ItemsSource="{Binding Source={DynamicResource BindingMode}, Converter={StaticResource BindingModeToText}, UpdateSourceTrigger=PropertyChanged}" + ItemsSource="{Binding Source={StaticResource BindingMode}, Converter={StaticResource BindingModeToText}, UpdateSourceTrigger=PropertyChanged}" SelectedItem="{Binding BindingMode, Converter={StaticResource BindingModeValueToText}}" />