diff --git a/.vs/EditorUtils/v15/sqlite3/storage.ide b/.vs/EditorUtils/v15/sqlite3/storage.ide new file mode 100644 index 0000000..35b3320 Binary files /dev/null and b/.vs/EditorUtils/v15/sqlite3/storage.ide differ diff --git a/Data/EditorUtils2017.nuspec b/Data/EditorUtils2017.nuspec new file mode 100644 index 0000000..9cf631e --- /dev/null +++ b/Data/EditorUtils2017.nuspec @@ -0,0 +1,16 @@ + + + + EditorUtils2017 + $version$ + EditorUtils 2017 + JaredPar + JaredPar + http://www.apache.org/licenses/LICENSE-2.0 + false + Utility DLL for writing Visual Studio extensions + Initial Release + Copyright 2012 + VisualStudio; VSIX + + diff --git a/Deploy.ps1 b/Deploy.ps1 index 8440f6a..d453068 100644 --- a/Deploy.ps1 +++ b/Deploy.ps1 @@ -1,45 +1,48 @@ param ( [switch]$push = $false, [switch]$fast = $false, - [switch]$skipTests = $false) -$script:scriptPath = split-path -parent $MyInvocation.MyCommand.Definition -pushd $scriptPath + [switch]$skipTests = $false, + [string]$vsDir = "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise") -function test-return() { - if ($LASTEXITCODE -ne 0) { - return $false - } - else { - return $true - } -} +Set-StrictMode -version 2.0 +$ErrorActionPreference="Stop" -function check-return() { - if (-not (test-return)) { - write-error "Command failed with code $LASTEXITCODE" - } +function Create-Directory([string]$dir) { + [IO.Directory]::CreateDirectory($dir) | Out-Null } -function build-clean() { - param ([string]$fileName = $(throw "Need a project file name")) - $name = split-path -leaf $fileName - & $msbuild /nologo /verbosity:m /t:Clean /p:Configuration=Release /p:VisualStudioVersion=10.0 $fileName - check-return - & $msbuild /nologo /verbosity:m /t:Clean /p:Configuration=Debug /p:VisualStudioVersion=10.0 $fileName - check-return +# Handy function for executing a command in powershell and throwing if it +# fails. +# +# Use this when the full command is known at script authoring time and +# doesn't require any dynamic argument build up. Example: +# +# Exec-Block { & $msbuild Test.proj } +# +# Original sample came from: http://jameskovacs.com/2010/02/25/the-exec-problem/ +function Exec-Block([scriptblock]$cmd) { + & $cmd + + # Need to check both of these cases for errors as they represent different items + # - $?: did the powershell script block throw an error + # - $lastexitcode: did a windows command executed by the script block end in error + if ((-not $?) -or ($lastexitcode -ne 0)) { + throw "Command failed to execute: $cmd" + } } -function build-release() { - param ( - [string]$fileName = $(throw "Need a project file name"), - [string]$editorVersion = $(throw "Need an editor version")) +function Build-Clean([string]$fileName) { + $name = Split-Path -leaf $fileName + Exec-Block { & $msbuild /nologo /verbosity:m /t:Clean /p:Configuration=Release /p:VisualStudioVersion=10.0 $fileName } + Exec-Block { & $msbuild /nologo /verbosity:m /t:Clean /p:Configuration=Debug /p:VisualStudioVersion=10.0 $fileName } +} - $name = split-path -leaf $fileName - & $msbuild /nologo /verbosity:q /p:Configuration=Release /p:VisualStudioVersion=10.0 /p:EditorVersion=$editorVersion $fileName - check-return +function Build-Release([string]$fileName, [string]$editorVersion) { + $name = Split-Path -leaf $fileName + Exec-Block { & $msbuild /nologo /verbosity:q /p:Configuration=Release /p:VisualStudioVersion=10.0 /p:EditorVersion=$editorVersion $fileName } } # Check to see if the given version of Visual Studio is installed -function test-vs-install() { +function Test-VSInstall() { param ([string]$version = $(throw "Need a version")) if ([IntPtr]::Size -eq 4) { @@ -48,155 +51,146 @@ function test-vs-install() { else { $path = "hklm:\Software\Wow6432Node\Microsoft\VisualStudio\{0}" -f $version } - $i = get-itemproperty $path InstallDir -ea SilentlyContinue | %{ $_.InstallDir } + $i = Get-ItemProperty $path InstallDir -ea SilentlyContinue | %{ $_.InstallDir } return $i -ne $null } # Run all of the unit tests -function test-unittests() { - param ([string]$vsVersion = $(throw "Need a VS version")) - - write-host -NoNewLine "`tRunning Unit Tests: " - if ($script:skipTests) { - write-host "skipped" +function Test-UnitTests([string]$editorVersion, [string]$vsVersion) { + Write-Host -NoNewLine "`tRunning Unit Tests: " + if ($skipTests) { + Write-Host "skipped" return } - if (-not (test-vs-install $vsVersion)) { - write-host "skipped (VS missing)" + if (-not (Test-VSInstall $vsVersion)) { + Write-Host "skipped (VS missing)" return } - $all = "Test\EditorUtilsTest\bin\Release\EditorUtils.UnitTest.dll" - $xunit = join-path $scriptPath "Tools\xunit.console.clr4.x86.exe" - $resultFilePath = "Deploy\xunit.xml" + $all = "Binaries\Release\EditorUtilsTest\$($editorVersion)\EditorUtils.UnitTest.dll" + $xunit = Join-Path $PSScriptRoot "Tools\xunit.console.clr4.x86.exe" + $resultFilePath = Join-Path $deployDir $editorVersion + $resultFilePath = Join-Path $resultFilePath "xunit.xml" foreach ($file in $all) { - $name = split-path -leaf $file - & $xunit $file /silent /xml $resultFilePath | out-null - if (-not (test-return)) { - write-host "FAILED!!!" + $name = Split-Path -leaf $file + & $xunit $file /silent /xml $resultFilePath | Out-Null + if ((-not $?) -or ($lastexitcode -ne 0)) { + Write-Host "FAILED!!!" & notepad $resultFilePath } else { - write-host "passed" + Write-Host "passed" } } } # Get the version number of the package that we are deploying -function get-version() { +function Get-Version() { $version = $null; - foreach ($line in gc "Src\EditorUtils\Constants.cs") { + foreach ($line in Get-Content "Src\EditorUtils\Constants.cs") { if ($line -match 'AssemblyVersion = "([\d.]*)"') { $version = $matches[1] } } if ($version -eq $null) { - write-error "Couldn't determine the version from Constants.cs" - return + throw "Couldn't determine the version from Constants.cs" } if (-not ($version -match "^\d+\.\d+\.\d+.\d+$")) { - write-error "Version number in unexpected format" + throw "Version number in unexpected format" } return $version } # Do the NuGet work -function invoke-nuget() { - param ( - [string]$version = $(throw "Need a version number"), - [string]$suffix = $(throw "Need a file name suffix")) - - write-host "`tCreating NuGet Package" - - $scratchPath = "Deploy\Scratch" - $libPath = join-path $scratchPath "lib\net40" - $outputPath = "Deploy" - if (test-path $scratchPath) { - rm -re -fo $scratchPath | out-null - } - mkdir $libPath | out-null +function Invoke-NuGet([string]$editorVersion, [string]$version, [string]$suffix) { + Write-Host "`tCreating NuGet Package" + + $scratchDir = Join-Path $deployDir $editorVersion + $libDir = Join-Path $scratchDir "lib\net40" + Create-Directory $scratchDir + Create-Directory $libDir $fileName = "EditorUtils$($suffix)" - copy "Src\EditorUtils\bin\Release\$($fileName).dll" (join-path $libPath "$($fileName).dll") - copy "Src\EditorUtils\bin\Release\$($fileName).pdb" (join-path $libPath "$($fileName).pdb") + Copy-Item "Binaries\Release\EditorUtils\$($editorVersion)\$($fileName).dll" (Join-Path $libDir "$($fileName).dll") + Copy-Item "Binaries\Release\EditorUtils\$($editorVersion)\$($fileName).pdb" (Join-Path $libDir "$($fileName).pdb") - $nuspecFilePath = join-path "Data" "EditorUtils$($suffix).nuspec" - & $nuget pack $nuspecFilePath -Version $version -BasePath $scratchPath -OutputDirectory $outputPath | out-null - check-return + $nuspecFilePath = Join-Path "Data" "EditorUtils$($suffix).nuspec" + Exec-Block { & $nuget pack $nuspecFilePath -Version $version -BasePath $scratchDir -OutputDirectory $deployDir } | Out-Null - if ($script:push) { - write-host "`tPushing Package" + if ($push) { + Write-Host "`tPushing Package" $name = "EditorUtils$($suffix).$version.nupkg" - $packageFile = join-path $outputPath $name - & $nuget push $packageFile | %{ write-host "`t`t$_" } - check-return + $packageFile = Join-Path $outputPath $name + Exec-Block { & $nuget push $packageFile } | Out-Host } } -function deploy-version() { - param ( - [string]$editorVersion = $(throw "Need a version number"), - [string]$vsVersion = $(throw "Need a VS version")) - +function Deploy-Version([string]$editorVersion, [string]$vsVersion) { $suffix = $editorVersion.Substring(2) - write-host "Deploying $editorVersion" + Write-Host "Deploying $editorVersion" # First clean the projects - write-host "`tCleaning Projects" - build-clean Src\EditorUtils\EditorUtils.csproj - build-clean Test\EditorUtilsTest\EditorUtilsTest.csproj + Write-Host "`tCleaning Projects" + Build-Clean Src\EditorUtils\EditorUtils.csproj + Build-Clean Test\EditorUtilsTest\EditorUtilsTest.csproj # Build all of the relevant projects. Both the deployment binaries and the # test infrastructure - write-host "`tBuilding Projects" - build-release Src\EditorUtils\EditorUtils.csproj $editorVersion - build-release Test\EditorUtilsTest\EditorUtilsTest.csproj $editorVersion + Write-Host "`tBuilding Projects" + Build-Release Src\EditorUtils\EditorUtils.csproj $editorVersion + Build-Release Test\EditorUtilsTest\EditorUtilsTest.csproj $editorVersion - write-host "`tDetermining Version Number" - $version = get-version + Write-Host "`tDetermining Version Number" + $version = Get-Version # Next run the tests - test-unittests $vsVersion + Test-UnitTests $editorVersion $vsVersion # Now do the NuGet work - invoke-nuget $version $suffix + Invoke-NuGet $editorVersion $version $suffix } -$msbuild = join-path ${env:SystemRoot} "microsoft.net\framework\v4.0.30319\msbuild.exe" -if (-not (test-path $msbuild)) { - write-error "Can't find msbuild.exe" -} +Push-Location $PSScriptRoot +try { -# Several of the projects involved use NuGet and the resulting .csproj files -# rely on the SolutionDir MSBuild property being set. Hence we set the appropriate -# environment variable for build -${env:SolutionDir} = $scriptPath + $msbuild = Join-Path $vsDir "MSBuild\15.0\Bin\msbuild.exe" + if (-not (Test-Path $msbuild)) { + Write-Host "Can't find msbuild.exe" + exit 1 + } -if (-not (test-path "Deploy")) { - mkdir Deploy | out-null -} + $deployDir = Join-Path $PSScriptRoot "Binaries\Deploy" -$nuget = resolve-path ".nuget\NuGet.exe" -if (-not (test-path $nuget)) { - write-error "Can't find NuGet.exe" -} + $nuget = Resolve-Path ".nuget\NuGet.exe" + if (-not (Test-Path $nuget)) { + Write-Host "Can't find NuGet.exe" + exit 1 + } -if ($fast) { - deploy-version "Vs2010" "10.0" + if ($fast) { + Deploy-Version "Vs2010" "10.0" + } + else { + Deploy-Version "Vs2010" "10.0" + Deploy-Version "Vs2012" "11.0" + Deploy-Version "Vs2013" "12.0" + Deploy-Version "Vs2015" "14.0" + Deploy-Version "Vs2017" "15.0" + } } -else { - deploy-version "Vs2010" "10.0" - deploy-version "Vs2012" "11.0" - deploy-version "Vs2013" "12.0" - deploy-version "Vs2015" "14.0" +catch { + Write-Host $_.ScriptStackTrace + Write-Host $_ + Write-Host "Failed" + exit 1 +} +finally { + Pop-Location } -rm env:\SolutionDir - -popd diff --git a/EditorUtils.props b/EditorUtils.props new file mode 100644 index 0000000..9477378 --- /dev/null +++ b/EditorUtils.props @@ -0,0 +1,74 @@ + + + + + Vs2010 + Vs2012 + Vs2013 + Vs2015 + Vs2017 + + + Vs2010 + + + + $(MSBuildThisFileDirectory) + $(RepoPath)Binaries\ + $(BinariesPath)obj\$(MSBuildProjectName)\ + $(BinariesPath) + $(BinariesPath)$(Configuration)\$(MSBuildProjectName) + $(MSBuildThisFileDirectory)References\$(EditorVersion)\App.config + $(ReferencePath);$(MSBuildThisFileDirectory)References\Vs2010 + $(ReferencePath);$(MSBuildThisFileDirectory)References\Vs2012 + $(ReferencePath);$(MSBuildThisFileDirectory)References\Vs2013 + $(ReferencePath);$(MSBuildThisFileDirectory)References\Vs2015 + $(ReferencePath);$(MSBuildThisFileDirectory)References\Vs2017 + $(ReferencePath);$(MSBuildThisFileDirectory)References\Common + $(RepoPath) + true + $(RepoPath)\Key.snk + false + + + + 2010 + 10.0.0.0 + 4.0 + $(DefineConstants);VS2010 + + + + 2012 + 11.0.0.0 + 4.5 + $(DefineConstants);VS2012 + + + + 2013 + 12.0.0.0 + 4.5 + $(DefineConstants);VS2013 + + + + 2015 + 14.0.0.0 + 4.5 + $(DefineConstants);VS2015 + + + + 2017 + 15.0.0.0 + 4.6 + $(DefineConstants);VS2017 + + + + + + False + + diff --git a/EditorUtils.settings b/EditorUtils.settings deleted file mode 100644 index 94977c1..0000000 --- a/EditorUtils.settings +++ /dev/null @@ -1,57 +0,0 @@ - - - - - $(MSBuildThisFileDirectory)References\Vs2010\App.config - - - - $(MSBuildThisFileDirectory)References\Vs2012\App.config - - - - $(MSBuildThisFileDirectory)References\Vs2013\App.config - - - - $(MSBuildThisFileDirectory)References\Vs2015\App.config - - - - $(ReferencePath);$(MSBuildThisFileDirectory)References\Vs2010 - 2010 - 10.0.0.0 - 4.0 - $(DefineConstants);VS2010 - - - - $(ReferencePath);$(MSBuildThisFileDirectory)References\Vs2012 - 2012 - 11.0.0.0 - 4.5 - $(DefineConstants);VS2012 - - - - $(ReferencePath);$(MSBuildThisFileDirectory)References\Vs2013 - 2013 - 12.0.0.0 - 4.5 - $(DefineConstants);VS2013 - - - - $(ReferencePath);$(MSBuildThisFileDirectory)References\Vs2015 - 2015 - 14.0.0.0 - 4.5 - $(DefineConstants);VS2015 - - - - - - False - - diff --git a/EditorUtils.sln b/EditorUtils.sln index e9a7fa1..3bf7714 100644 --- a/EditorUtils.sln +++ b/EditorUtils.sln @@ -1,17 +1,17 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 14 -VisualStudioVersion = 14.0.22823.1 +# Visual Studio 15 +VisualStudioVersion = 15.0.26621.2 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EditorUtils", "Src\EditorUtils\EditorUtils.csproj", "{FB418222-C105-4942-8EEB-832DDCFFD89D}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EditorUtilsTest", "Test\EditorUtilsTest\EditorUtilsTest.csproj", "{BAED09B7-25D9-4DD8-8558-BAC9730BA3F3}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EditorApp", "Src\EditorApp\EditorApp.csproj", "{EE06DCE3-203C-4503-9AFA-0A419F43F2B3}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WordUnderCaret", "Test\WordUnderCaret\WordUnderCaret.csproj", "{620BEC49-DF9C-406A-9492-BD157BAB95BC}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EditorUtils.Host", "Src\EditorUtils.Host\EditorUtils.Host.csproj", "{863A0141-59C5-481D-A3FC-A5812D973FEB}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cats", "Test\Cats\Cats.csproj", "{1B8425A4-6DBB-4227-92E7-EC8CC379DA63}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EditorUtils.Host.Vs2017", "Src\EditorUtils.Host.Vs2017\EditorUtils.Host.Vs2017.csproj", "{7F5978FE-07D8-414D-8A18-18343B9688D1}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EditorApp", "Src\EditorApp\EditorApp.csproj", "{EE06DCE3-203C-4503-9AFA-0A419F43F2B3}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EditorUtilsTest", "Src\EditorUtilsTest\EditorUtilsTest.csproj", "{BAED09B7-25D9-4DD8-8558-BAC9730BA3F3}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -23,24 +23,27 @@ Global {FB418222-C105-4942-8EEB-832DDCFFD89D}.Debug|Any CPU.Build.0 = Debug|Any CPU {FB418222-C105-4942-8EEB-832DDCFFD89D}.Release|Any CPU.ActiveCfg = Release|Any CPU {FB418222-C105-4942-8EEB-832DDCFFD89D}.Release|Any CPU.Build.0 = Release|Any CPU - {BAED09B7-25D9-4DD8-8558-BAC9730BA3F3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {BAED09B7-25D9-4DD8-8558-BAC9730BA3F3}.Debug|Any CPU.Build.0 = Debug|Any CPU - {BAED09B7-25D9-4DD8-8558-BAC9730BA3F3}.Release|Any CPU.ActiveCfg = Release|Any CPU - {BAED09B7-25D9-4DD8-8558-BAC9730BA3F3}.Release|Any CPU.Build.0 = Release|Any CPU - {620BEC49-DF9C-406A-9492-BD157BAB95BC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {620BEC49-DF9C-406A-9492-BD157BAB95BC}.Debug|Any CPU.Build.0 = Debug|Any CPU - {620BEC49-DF9C-406A-9492-BD157BAB95BC}.Release|Any CPU.ActiveCfg = Release|Any CPU - {620BEC49-DF9C-406A-9492-BD157BAB95BC}.Release|Any CPU.Build.0 = Release|Any CPU - {1B8425A4-6DBB-4227-92E7-EC8CC379DA63}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {1B8425A4-6DBB-4227-92E7-EC8CC379DA63}.Debug|Any CPU.Build.0 = Debug|Any CPU - {1B8425A4-6DBB-4227-92E7-EC8CC379DA63}.Release|Any CPU.ActiveCfg = Release|Any CPU - {1B8425A4-6DBB-4227-92E7-EC8CC379DA63}.Release|Any CPU.Build.0 = Release|Any CPU {EE06DCE3-203C-4503-9AFA-0A419F43F2B3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {EE06DCE3-203C-4503-9AFA-0A419F43F2B3}.Debug|Any CPU.Build.0 = Debug|Any CPU {EE06DCE3-203C-4503-9AFA-0A419F43F2B3}.Release|Any CPU.ActiveCfg = Release|Any CPU {EE06DCE3-203C-4503-9AFA-0A419F43F2B3}.Release|Any CPU.Build.0 = Release|Any CPU + {863A0141-59C5-481D-A3FC-A5812D973FEB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {863A0141-59C5-481D-A3FC-A5812D973FEB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {863A0141-59C5-481D-A3FC-A5812D973FEB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {863A0141-59C5-481D-A3FC-A5812D973FEB}.Release|Any CPU.Build.0 = Release|Any CPU + {7F5978FE-07D8-414D-8A18-18343B9688D1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7F5978FE-07D8-414D-8A18-18343B9688D1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7F5978FE-07D8-414D-8A18-18343B9688D1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7F5978FE-07D8-414D-8A18-18343B9688D1}.Release|Any CPU.Build.0 = Release|Any CPU + {BAED09B7-25D9-4DD8-8558-BAC9730BA3F3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BAED09B7-25D9-4DD8-8558-BAC9730BA3F3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BAED09B7-25D9-4DD8-8558-BAC9730BA3F3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BAED09B7-25D9-4DD8-8558-BAC9730BA3F3}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {BC9790A4-A584-4C7C-8983-37CBD160ED81} + EndGlobalSection EndGlobal diff --git a/Key.publickey b/Key.publickey deleted file mode 100644 index 1d788cf..0000000 Binary files a/Key.publickey and /dev/null differ diff --git a/References/Common/Microsoft.VisualStudio.Setup.Configuration.Interop.dll b/References/Common/Microsoft.VisualStudio.Setup.Configuration.Interop.dll new file mode 100644 index 0000000..0d2bf57 Binary files /dev/null and b/References/Common/Microsoft.VisualStudio.Setup.Configuration.Interop.dll differ diff --git a/References/Common/Microsoft.VisualStudio.Setup.Configuration.Interop.xml b/References/Common/Microsoft.VisualStudio.Setup.Configuration.Interop.xml new file mode 100644 index 0000000..f549466 --- /dev/null +++ b/References/Common/Microsoft.VisualStudio.Setup.Configuration.Interop.xml @@ -0,0 +1,643 @@ + + + + Microsoft.VisualStudio.Setup.Configuration.Interop + + + + + A reference to a failed package. + + + You can enumerate all properties of basic types by casting to an . + + + + + Gets the general package identifier. + + The general package identifier. + + + + Gets the version of the package. + + The version of the package. + + + + Gets the target process architecture of the package. + + The target process architecture of the package. + + + + Gets the language and optional region identifier. + + The language and optional region identifier. + + + + Gets the build branch of the package. + + The build branch of the package. + + + + Gets the type of the package. + + The type of the package. + + + + Gets the unique identifier consisting of all defined tokens. + + The unique identifier consisting of all defined tokens. + + + + Gets a value indicating whether the package refers to an external extension. + + A value indicating whether the package refers to an external extension. + + + + Gets the path to the optional package log. + + The path to the optional package log. + + + + Gets the description of the package failure. + + The description of the package failure. + + + + Gets the signature to use for feedback reporting. + + The signature to use for feedback reporting. + + + + Gets the array of details for this package failure. + + An array of details for this package failure. + + + + Gets an array of packages affected by this package failure. + + An array of packages affected by this package failure. This may be null. + + + + An enumerator of installed objects. + + + + + Retrieves the next set of product instances in the enumeration sequence. + + The number of product instances to retrieve. + A pointer to an array of . + A pointer to the number of product instances retrieved. If is 1 this parameter may be NULL. + + + + Skips the next set of product instances in the enumeration sequence. + + The number of product instances to skip. + + + + Resets the enumeration sequence to the beginning. + + + + + Creates a new enumeration object in the same state as the current enumeration object: the new object points to the same place in the enumeration sequence. + + A pointer to a pointer to a new interface. If the method fails, this parameter is undefined. + + + + Provides localized properties of an instance of a product. + + + + + Gets localized product-specific properties. + + An of localized product-specific properties, or null if no properties are defined. + + + + Gets localized channel-specific properties. + + An of localized channel-specific properties, or null if no properties are defined. + + + + The state of an . + + + + + The instance state has not been determined. + + + + + The instance installation path exists. + + + + + A product is registered to the instance. + + + + + No reboot is required for the instance. + + + + + No errors were reported for the instance. + + + + + The instance represents a complete install. + + + + + Gets information about product instances set up on the machine. + + + + + Enumerates all launchable product instances installed. + + An enumeration of installed product instances. + + + + Gets the instance for the current process path. + + The instance for the current process path. + + The returned instance may not be launchable. + + + + + Gets the instance for the given path. + + Path used to determine instance + The instance for the given path. + + The returned instance may not be launchable. + + + + + Enumerates all product instances. + + An enumeration of all product instances. + + + + Gets information about product instances installed on the machine. + + + + + Enumerates all launchable product instances installed. + + An enumeration of installed product instances. + + + + Gets the instance for the current process path. + + The instance for the current process path. + + The returned instance may not be launchable. + + + + + Gets the instance for the given path. + + Path used to determine instance + The instance for the given path. + + The returned instance may not be launchable. + + + + + Information about the error state of an instance. + + + + + Gets an array of failed package references. + + An array of failed package references. + + + + Gets an array of skipped package references. + + An array of skipped package references. + + + + Information about the error state of an instance. + + + + + Gets an array of failed package references. + + An array of failed package references. + + + + Gets an array of skipped package references. + + An array of skipped package references. + + + + Gets the path to the error log. + + The path to the error log. + + + + A reference to a failed package. + + + You can enumerate all properties of basic types by casting to an . + + + + + Gets the general package identifier. + + The general package identifier. + + + + Gets the version of the package. + + The version of the package. + + + + Gets the target process architecture of the package. + + The target process architecture of the package. + + + + Gets the language and optional region identifier. + + The language and optional region identifier. + + + + Gets the build branch of the package. + + The build branch of the package. + + + + Gets the type of the package. + + The type of the package. + + + + Gets the unique identifier consisting of all defined tokens. + + The unique identifier consisting of all defined tokens. + + + + Gets a value indicating whether the package refers to an external extension. + + A value indicating whether the package refers to an external extension. + + + + Helper functions. + + + + + Parses a dotted quad version string into a 64-bit unsigned integer. + + The dotted quad version string to parse, e.g. 1.2.3.4. + A 64-bit unsigned integer representing the version. You can compare this to other versions. + + + + Parses a dotted quad version string into a 64-bit unsigned integer. + + The string containing 1 or 2 dotted quad version strings to parse, e.g. [1.0,) that means 1.0.0.0 or newer. + A 64-bit unsigned integer representing the minimum version, which may be 0. You can compare this to other versions. + A 64-bit unsigned integer representing the maximum version, which may be MAXULONGLONG. You can compare this to other versions. + + + + Information about an instance of a product. + + + You can enumerate all properties of basic types by casting to an . + + + + + Gets the instance identifier (should match the name of the parent instance directory). + + The instance identifier. + + + + Gets the local date and time when the installation was originally installed. + + The local date and time when the installation was originally installed. + + + + Gets the unique name of the installation, often indicating the branch and other information used for telemetry. + + The unique name of the installation, often indicating the branch and other information used for telemetry. + + + + Gets the path to the installation root of the product. + + The path to the installation root of the product. + + + + Gets the version of the product installed in this instance. + + The version of the product installed in this instance. + + + + Gets the display name (title) of the product installed in this instance. + + The LCID for the display name. + The display name (title) of the product installed in this instance. + + + + Gets the description of the product installed in this instance. + + The LCID for the description. + The description of the product installed in this instance. + + + + Resolves the optional relative path to the root path of the instance. + + A relative path within the instance to resolve, or NULL to get the root path. + The full path to the optional relative path within the instance. If the relative path is NULL, the root path will always terminate in a backslash. + + + + Gets the state of the instance. + + The state of the instance. + + + + Gets an array of package references registered to the instance. + + An array of package references registered to the instance. + + + + Gets a package reference to the product registered to the instance + + A package reference to the product registered to the instance. This may be null if does not return . + + + + Gets the relative path to the product application, if available. + + The relative path to the product application, if available. + + + + Gets the error state of the instance, if available. + + The error state of the instance, if available. + + + + Gets a value indicating whether the instance can be launched. + + Whether the instance can be launched. + + An instance could have had errors during install but still be launched. Some features may not work correctly, but others will. + + + + + Gets a value indicating whether the instance is complete. + + Whether the instance is complete. + + An instance is complete if it had no errors during install, resume, or repair. + + + + + Gets product-specific properties. + + An of product-specific properties, or null if no properties are defined. + + + + Gets the directory path to the setup engine that installed the instance. + + The directory path to the setup engine that installed the instance. + + + + Information about an instance of a product. + + + You can enumerate all properties of basic types by casting to an . + + + + + Gets the instance identifier (should match the name of the parent instance directory). + + The instance identifier. + + + + Gets the local date and time when the installation was originally installed. + + The local date and time when the installation was originally installed. + + + + Gets the unique name of the installation, often indicating the branch and other information used for telemetry. + + The unique name of the installation, often indicating the branch and other information used for telemetry. + + + + Gets the path to the installation root of the product. + + The path to the installation root of the product. + + + + Gets the version of the product installed in this instance. + + The version of the product installed in this instance. + + + + Gets the display name (title) of the product installed in this instance. + + The LCID for the display name. + The display name (title) of the product installed in this instance. + + + + Gets the description of the product installed in this instance. + + The LCID for the description. + The description of the product installed in this instance. + + + + Resolves the optional relative path to the root path of the instance. + + A relative path within the instance to resolve, or NULL to get the root path. + The full path to the optional relative path within the instance. If the relative path is NULL, the root path will always terminate in a backslash. + + + + Provides localized named properties. + + + + + Gets an array of property names in this property store. + + The LCID for the property names. + An array of property names in this property store. + + + + Gets the value of a named property in this property store. + + The name of the property to get. + The LCID for the property. + The value of the property. + + + + A reference to a package. + + + You can enumerate all properties of basic types by casting to an . + + + + + Gets the general package identifier. + + The general package identifier. + + + + Gets the version of the package. + + The version of the package. + + + + Gets the target process architecture of the package. + + The target process architecture of the package. + + + + Gets the language and optional region identifier. + + The language and optional region identifier. + + + + Gets the build branch of the package. + + The build branch of the package. + + + + Gets the type of the package. + + The type of the package. + + + + Gets the unique identifier consisting of all defined tokens. + + The unique identifier consisting of all defined tokens. + + + + Gets a value indicating whether the package refers to an external extension. + + A value indicating whether the package refers to an external extension. + + + + Provides named properties. + + + You can get this from an , , or derivative. + + + + + Gets an array of property names in this property store. + + An array of property names in this property store. + + + + Gets the value of a named property in this property store. + + The name of the property to get. + The value of the property. + + + + The implementation of . + + + + + Class that implements . + + + + diff --git a/References/Vs2017/App.config b/References/Vs2017/App.config new file mode 100644 index 0000000..fced331 --- /dev/null +++ b/References/Vs2017/App.config @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/References/Vs2017/Microsoft.VisualStudio.CoreUtility.dll b/References/Vs2017/Microsoft.VisualStudio.CoreUtility.dll new file mode 100644 index 0000000..ab4202c Binary files /dev/null and b/References/Vs2017/Microsoft.VisualStudio.CoreUtility.dll differ diff --git a/References/Vs2017/Microsoft.VisualStudio.Language.Intellisense.dll b/References/Vs2017/Microsoft.VisualStudio.Language.Intellisense.dll new file mode 100644 index 0000000..e0d2771 Binary files /dev/null and b/References/Vs2017/Microsoft.VisualStudio.Language.Intellisense.dll differ diff --git a/References/Vs2017/Microsoft.VisualStudio.Language.StandardClassification.dll b/References/Vs2017/Microsoft.VisualStudio.Language.StandardClassification.dll new file mode 100644 index 0000000..77f2cd0 Binary files /dev/null and b/References/Vs2017/Microsoft.VisualStudio.Language.StandardClassification.dll differ diff --git a/References/Vs2017/Microsoft.VisualStudio.Telemetry.dll b/References/Vs2017/Microsoft.VisualStudio.Telemetry.dll new file mode 100644 index 0000000..268f9db Binary files /dev/null and b/References/Vs2017/Microsoft.VisualStudio.Telemetry.dll differ diff --git a/References/Vs2017/Microsoft.VisualStudio.Text.Data.dll b/References/Vs2017/Microsoft.VisualStudio.Text.Data.dll new file mode 100644 index 0000000..3a84d45 Binary files /dev/null and b/References/Vs2017/Microsoft.VisualStudio.Text.Data.dll differ diff --git a/References/Vs2017/Microsoft.VisualStudio.Text.Internal.dll b/References/Vs2017/Microsoft.VisualStudio.Text.Internal.dll new file mode 100644 index 0000000..ecb4e14 Binary files /dev/null and b/References/Vs2017/Microsoft.VisualStudio.Text.Internal.dll differ diff --git a/References/Vs2017/Microsoft.VisualStudio.Text.Logic.dll b/References/Vs2017/Microsoft.VisualStudio.Text.Logic.dll new file mode 100644 index 0000000..ba8a4f6 Binary files /dev/null and b/References/Vs2017/Microsoft.VisualStudio.Text.Logic.dll differ diff --git a/References/Vs2017/Microsoft.VisualStudio.Text.UI.Wpf.dll b/References/Vs2017/Microsoft.VisualStudio.Text.UI.Wpf.dll new file mode 100644 index 0000000..d22d512 Binary files /dev/null and b/References/Vs2017/Microsoft.VisualStudio.Text.UI.Wpf.dll differ diff --git a/References/Vs2017/Microsoft.VisualStudio.Text.UI.dll b/References/Vs2017/Microsoft.VisualStudio.Text.UI.dll new file mode 100644 index 0000000..7d5c0d6 Binary files /dev/null and b/References/Vs2017/Microsoft.VisualStudio.Text.UI.dll differ diff --git a/References/Vs2017/Microsoft.VisualStudio.Utilities.dll b/References/Vs2017/Microsoft.VisualStudio.Utilities.dll new file mode 100644 index 0000000..943107b Binary files /dev/null and b/References/Vs2017/Microsoft.VisualStudio.Utilities.dll differ diff --git a/Src/EditorApp/App.config b/Src/EditorApp/App.config index fad249e..56610f6 100644 --- a/Src/EditorApp/App.config +++ b/Src/EditorApp/App.config @@ -1,6 +1,14 @@ - + + + + + + + + + \ No newline at end of file diff --git a/Src/EditorApp/EditorApp.csproj b/Src/EditorApp/EditorApp.csproj index e6a5082..8b8a29e 100644 --- a/Src/EditorApp/EditorApp.csproj +++ b/Src/EditorApp/EditorApp.csproj @@ -1,7 +1,7 @@  - + Debug AnyCPU @@ -10,17 +10,16 @@ Properties EditorApp EditorApp - v4.5 512 {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 4 + true AnyCPU true full false - bin\Debug\ DEBUG;TRACE prompt 4 @@ -29,7 +28,6 @@ AnyCPU pdbonly true - bin\Release\ TRACE prompt 4 @@ -37,6 +35,9 @@ + + ..\..\packages\System.ValueTuple.4.3.1\lib\netstandard1.0\System.ValueTuple.dll + @@ -89,6 +90,7 @@ ResXFileCodeGenerator Resources.Designer.cs + SettingsSingleFileGenerator Settings.Designer.cs @@ -99,6 +101,14 @@ + + {7f5978fe-07d8-414d-8a18-18343b9688d1} + EditorUtils.Host.Vs2017 + + + {863a0141-59c5-481d-a3fc-a5812d973feb} + EditorUtils.Host + {fb418222-c105-4942-8eeb-832ddcffd89d} EditorUtils diff --git a/Src/EditorApp/MainWindow.xaml b/Src/EditorApp/MainWindow.xaml index 1df377a..a5cc903 100644 --- a/Src/EditorApp/MainWindow.xaml +++ b/Src/EditorApp/MainWindow.xaml @@ -3,7 +3,6 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" - xmlns:local="clr-namespace:EditorApp" mc:Ignorable="d" Title="MainWindow" Height="350" Width="525"> diff --git a/Src/EditorApp/MainWindow.xaml.cs b/Src/EditorApp/MainWindow.xaml.cs index d48f6e8..0b42577 100644 --- a/Src/EditorApp/MainWindow.xaml.cs +++ b/Src/EditorApp/MainWindow.xaml.cs @@ -25,7 +25,12 @@ public MainWindow() { InitializeComponent(); - var editorHostFactory = new EditorHostFactory(EditorVersion.Vs2015); + var editorHostFactory = new EditorHostFactory(EditorVersion.Vs2017); + CreateContent(editorHostFactory); + } + + private void CreateContent(EditorHostFactory editorHostFactory) + { var editorHost = editorHostFactory.CreateEditorHost(); var textBuffer = editorHost.TextBufferFactoryService.CreateTextBuffer(); diff --git a/Src/EditorApp/packages.config b/Src/EditorApp/packages.config new file mode 100644 index 0000000..861d33a --- /dev/null +++ b/Src/EditorApp/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/Src/EditorUtils.Host.Vs2017/BasicLoggingServiceInternal.cs b/Src/EditorUtils.Host.Vs2017/BasicLoggingServiceInternal.cs new file mode 100644 index 0000000..03d7e55 --- /dev/null +++ b/Src/EditorUtils.Host.Vs2017/BasicLoggingServiceInternal.cs @@ -0,0 +1,35 @@ +using Microsoft.VisualStudio.Telemetry; +using Microsoft.VisualStudio.Text.Utilities; +using System; +using System.Collections.Generic; +using System.ComponentModel.Composition; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace EditorUtils.Vs2017 +{ + [Export(typeof(ILoggingServiceInternal))] + internal sealed class BasicLoggingServiceInternal : ILoggingServiceInternal + { + void ILoggingServiceInternal.AdjustCounter(string key, string name, int delta) + { + + } + + void ILoggingServiceInternal.PostCounters() + { + + } + + void ILoggingServiceInternal.PostEvent(string key, params object[] namesAndProperties) + { + + } + + void ILoggingServiceInternal.PostEvent(string key, IReadOnlyList namesAndProperties) + { + + } + } +} diff --git a/Src/EditorUtils.Host.Vs2017/BasicWaitIndicator.cs b/Src/EditorUtils.Host.Vs2017/BasicWaitIndicator.cs new file mode 100644 index 0000000..3ae622e --- /dev/null +++ b/Src/EditorUtils.Host.Vs2017/BasicWaitIndicator.cs @@ -0,0 +1,74 @@ +using System; +using System.ComponentModel.Composition; +using System.ComponentModel.Composition.Primitives; +using Microsoft.VisualStudio.Language.Intellisense.Utilities; +using System.Threading; + +namespace EditorUtils +{ + [Export(typeof(IWaitIndicator))] + internal sealed class BasicWaitIndicator : IWaitIndicator + { + internal static readonly BasicWaitIndicator Default = new BasicWaitIndicator(); + + private readonly IWaitContext _waitContext; + + [ImportingConstructor] + internal BasicWaitIndicator() + : this(new UncancellableWaitContext()) + { + } + + internal BasicWaitIndicator(IWaitContext waitContext) + { + _waitContext = waitContext; + } + + IWaitContext IWaitIndicator.StartWait(string title, string message, bool allowCancel) + { + return _waitContext; + } + + WaitIndicatorResult IWaitIndicator.Wait(string title, string message, bool allowCancel, Action action) + { + try + { + action(_waitContext); + } + catch (OperationCanceledException) + { + return WaitIndicatorResult.Canceled; + } + + return WaitIndicatorResult.Completed; + } + + private sealed class UncancellableWaitContext : IWaitContext + { + public CancellationToken CancellationToken + { + get { return CancellationToken.None; } + } + + public void UpdateProgress() + { + } + + public bool AllowCancel + { + get { return false; } + set { } + } + + public string Message + { + get { return ""; } + set { } + } + + public void Dispose() + { + } + } + } +} diff --git a/Src/EditorUtils.Host.Vs2017/EditorUtils.Host.Vs2017.csproj b/Src/EditorUtils.Host.Vs2017/EditorUtils.Host.Vs2017.csproj new file mode 100644 index 0000000..f7d9cfb --- /dev/null +++ b/Src/EditorUtils.Host.Vs2017/EditorUtils.Host.Vs2017.csproj @@ -0,0 +1,68 @@ + + + + + + Release + AnyCPU + {7F5978FE-07D8-414D-8A18-18343B9688D1} + Library + EditorUtils.Host.Vs2017 + EditorUtils.Host.Vs2017 + 4.6 + + + true + full + false + $(DefineConstants);DEBUG;TRACE + prompt + 4 + + + pdbonly + true + $(DefineConstants);TRACE + prompt + 4 + + + + + + + + + + + + + + ..\..\packages\System.ValueTuple.4.3.0\lib\netstandard1.0\System.ValueTuple.dll + + + + + + + Constants.cs + + + + + + + + + + + {863a0141-59c5-481d-a3fc-a5812d973feb} + EditorUtils.Host + + + {fb418222-c105-4942-8eeb-832ddcffd89d} + EditorUtils + + + + \ No newline at end of file diff --git a/Src/EditorUtils.Host.Vs2017/Properties/AssemblyInfo.cs b/Src/EditorUtils.Host.Vs2017/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..a025f09 --- /dev/null +++ b/Src/EditorUtils.Host.Vs2017/Properties/AssemblyInfo.cs @@ -0,0 +1,42 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using EditorUtils; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("EditorUtils")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyProduct("EditorUtils")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("4826ca00-1f05-42e8-8dea-427bf872ae5e")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion(Constants.AssemblyVersion)] +[assembly: AssemblyFileVersion(Constants.AssemblyVersion)] +[assembly: InternalsVisibleTo("EditorUtils.UnitTest, PublicKey=" + + "0024000004800000940000000602000000240000525341310004000001000100c90913d9ce09ec" + + "960c03fe50c463b3a5f214fdebdcd9c33b1f5f8cddd3e82bc4ba2bf3846bbb4ddd5cd8a322a40a" + + "dc41311155ebf6a1789c66c77345923153e49003049cb798836053198008405812d4e5ff468369" + + "1e25db5930f79a1d206b864a852e1653ddf8d2bc73e085a98ef023681bf8453dc3bd29577b1ad3" + + "55f863e7")] + diff --git a/Src/EditorUtils.Host.Vs2017/README.md b/Src/EditorUtils.Host.Vs2017/README.md new file mode 100644 index 0000000..78fd7dc --- /dev/null +++ b/Src/EditorUtils.Host.Vs2017/README.md @@ -0,0 +1,6 @@ +EditorUtils.Vs2017 +====== + +This project holds all of the components specific to a VS2017 installation (or possibly higher). It +references the VS2017 Binaries R + diff --git a/Src/EditorUtils.Host.Vs2017/packages.config b/Src/EditorUtils.Host.Vs2017/packages.config new file mode 100644 index 0000000..861b440 --- /dev/null +++ b/Src/EditorUtils.Host.Vs2017/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/Src/EditorUtils/EditorHost.cs b/Src/EditorUtils.Host/EditorHost.cs similarity index 100% rename from Src/EditorUtils/EditorHost.cs rename to Src/EditorUtils.Host/EditorHost.cs diff --git a/Src/EditorUtils.Host/EditorHostFactory.JoinableTaskContextExportProvider.cs b/Src/EditorUtils.Host/EditorHostFactory.JoinableTaskContextExportProvider.cs new file mode 100644 index 0000000..12f6c02 --- /dev/null +++ b/Src/EditorUtils.Host/EditorHostFactory.JoinableTaskContextExportProvider.cs @@ -0,0 +1,56 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.Composition; +using System.ComponentModel.Composition.Hosting; +using System.ComponentModel.Composition.Primitives; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Text; +using Microsoft.VisualStudio.Text.Operations; +using Microsoft.Win32; + +namespace EditorUtils +{ + public sealed partial class EditorHostFactory + { + /// + /// Beginning in 15.0 the editor took a dependency on JoinableTaskContext. Need to provide that + /// export here. + /// + private sealed class JoinableTaskContextExportProvider : ExportProvider + { + internal const string AssemblyName = "Microsoft.VisualStudio.Threading"; + internal const string TypeShortName = "JoinableTaskContext"; + internal const string TypeFullName = AssemblyName + "." + TypeShortName; + private readonly Export _export; + private object _instance; + + internal JoinableTaskContextExportProvider() + { + _export = new Export(TypeFullName, GetValue); + } + + protected override IEnumerable GetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition) + { + if (definition.ContractName == TypeFullName) + { + yield return _export; + } + } + + private object GetValue() + { + if (_instance == null) + { + var assembly = AppDomain.CurrentDomain.GetAssemblies().Single(x => x.GetName().Name == AssemblyName); + var type = assembly.GetType(TypeFullName); + var ctor = type.GetConstructor(new Type[0] { }); + _instance = ctor.Invoke(null); + } + + return _instance; + } + } + } +} diff --git a/Src/EditorUtils.Host/EditorHostFactory.SimpleWaitIndicator.cs b/Src/EditorUtils.Host/EditorHostFactory.SimpleWaitIndicator.cs new file mode 100644 index 0000000..8a6421a --- /dev/null +++ b/Src/EditorUtils.Host/EditorHostFactory.SimpleWaitIndicator.cs @@ -0,0 +1,92 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.Composition; +using System.ComponentModel.Composition.Hosting; +using System.ComponentModel.Composition.Primitives; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Text; +using Microsoft.VisualStudio.Text.Operations; +using Microsoft.Win32; +using Microsoft.VisualStudio.Language.Intellisense.Utilities; +using System.Threading; + +namespace EditorUtils +{ + public sealed partial class EditorHostFactory + { + /// + /// The IWaitIndicator type is a new export in VS2017. This approach is a temporary work around that + /// is not a long term solution. It will only work when both running against VS2017 and using EditorUtils + /// compiled for VS2017. In all other cases it will fail because this export can only be created in + /// the versions compiled against VS2017. + /// +#if VS2017 + [Export(typeof(IWaitIndicator))] + public sealed class SimpleWaitIndicator : IWaitIndicator + { + public static readonly SimpleWaitIndicator Default = new SimpleWaitIndicator(); + + private readonly IWaitContext _waitContext; + + public SimpleWaitIndicator() + : this(new UncancellableWaitContext()) + { + } + + internal SimpleWaitIndicator(IWaitContext waitContext) + { + _waitContext = waitContext; + } + + IWaitContext IWaitIndicator.StartWait(string title, string message, bool allowCancel) + { + return _waitContext; + } + + WaitIndicatorResult IWaitIndicator.Wait(string title, string message, bool allowCancel, Action action) + { + try + { + action(_waitContext); + } + catch (OperationCanceledException) + { + return WaitIndicatorResult.Canceled; + } + + return WaitIndicatorResult.Completed; + } + + private sealed class UncancellableWaitContext : IWaitContext + { + public CancellationToken CancellationToken + { + get { return CancellationToken.None; } + } + + public void UpdateProgress() + { + } + + public bool AllowCancel + { + get { return false; } + set { } + } + + public string Message + { + get { return ""; } + set { } + } + + public void Dispose() + { + } + } + } +#endif + } +} diff --git a/Src/EditorUtils/EditorHostFactory.UndoExportProvider.cs b/Src/EditorUtils.Host/EditorHostFactory.UndoExportProvider.cs similarity index 100% rename from Src/EditorUtils/EditorHostFactory.UndoExportProvider.cs rename to Src/EditorUtils.Host/EditorHostFactory.UndoExportProvider.cs diff --git a/Src/EditorUtils.Host/EditorHostFactory.cs b/Src/EditorUtils.Host/EditorHostFactory.cs new file mode 100644 index 0000000..d127b9b --- /dev/null +++ b/Src/EditorUtils.Host/EditorHostFactory.cs @@ -0,0 +1,141 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.Composition; +using System.ComponentModel.Composition.Hosting; +using System.ComponentModel.Composition.Primitives; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Text; +using Microsoft.VisualStudio.Text.Operations; +using Microsoft.Win32; + +namespace EditorUtils +{ + public sealed partial class EditorHostFactory + { + internal static string[] CoreEditorComponents = + new[] + { + "Microsoft.VisualStudio.Platform.VSEditor.dll", + "Microsoft.VisualStudio.Text.Internal.dll", + "Microsoft.VisualStudio.Text.Logic.dll", + "Microsoft.VisualStudio.Text.UI.dll", + "Microsoft.VisualStudio.Text.UI.Wpf.dll", + }; + + private readonly List _composablePartCatalogList = new List(); + private readonly List _exportProviderList = new List(); + + public EditorHostFactory(EditorVersion? editorVersion = null) + { + BuildBaseCatalog(editorVersion); + _exportProviderList.Add(new UndoExportProvider()); + } + + public void Add(ComposablePartCatalog composablePartCatalog) + { + _composablePartCatalogList.Add(composablePartCatalog); + } + + public void Add(ExportProvider exportProvider) + { + _exportProviderList.Add(exportProvider); + } + + public CompositionContainer CreateCompositionContainer() + { + var catalog = new AggregateCatalog(_composablePartCatalogList.ToArray()); + return new CompositionContainer(catalog, _exportProviderList.ToArray()); + } + + public EditorHost CreateEditorHost() + { + return new EditorHost(CreateCompositionContainer()); + } + + private void BuildBaseCatalog(EditorVersion? editorVersion) + { + Version vsVersion; + GetEditorInfoAndHookResolve(editorVersion, out vsVersion); + BuildBaseCatalog(vsVersion); + } + + private void BuildBaseCatalog(Version vsVersion) + { + var editorAssemblyVersion = new Version(vsVersion.Major, 0); + AppendEditorAssemblies(editorAssemblyVersion); + AppendSpecificComponents(vsVersion, editorAssemblyVersion); + } + + private static void GetEditorInfoAndHookResolve(EditorVersion? editorVersion, out Version vsVersion) + { + string vsInstallDirectory; + if (!EditorLocatorUtil.TryGetEditorInfo(editorVersion, out vsVersion, out vsInstallDirectory)) + { + throw new Exception("Unable to calculate the version of Visual Studio installed on the machine"); + } + + HookResolve(vsInstallDirectory); + } + + /// + /// Need to hook so that we can load the editor assemblies from the + /// desired location for this AppDomain. + /// + private static void HookResolve(string installDirectory) + { + var dirList = new List(); + dirList.Add(Path.Combine(installDirectory, "PrivateAssemblies")); + + // Before 15.0 all of the editor assemblies were located in the GAC. Hence no resolve needs to be done + // because they will be discovered automatically when we load by the qualified name. Starting in 15.0 + // though the assemblies are not GAC'd and we need to load from the extension directory. + dirList.Add(Path.Combine(installDirectory, @"CommonExtensions\Microsoft\Editor")); + + AppDomain.CurrentDomain.AssemblyResolve += (sender, e) => + { + var assemblyName = new AssemblyName(e.Name); + var name = string.Format("{0}.dll", assemblyName.Name); + foreach (var dir in dirList) + { + var fullName = Path.Combine(dir, name); + if (File.Exists(fullName)) + { + return Assembly.LoadFrom(fullName); + } + } + + return null; + }; + } + + private void AppendEditorAssemblies(Version editorAssemblyVersion) + { + foreach (var name in CoreEditorComponents) + { + var simpleName = Path.GetFileNameWithoutExtension(name); + var assembly = GetEditorAssembly(simpleName, editorAssemblyVersion); + _composablePartCatalogList.Add(new AssemblyCatalog(assembly)); + } + } + + private void AppendSpecificComponents(Version vsVersion, Version editorAssemblyVersion) + { + if (vsVersion.Major >= 15) + { + var qualifiedName = string.Format("EditorUtils.Host.Vs2017, Version={0}, Culture=neutral, PublicKeyToken={1}, processorArchitecture=MSIL", Constants.AssemblyVersion, Constants.PublicKeyToken); + var assembly = Assembly.Load(qualifiedName); + _composablePartCatalogList.Add(new AssemblyCatalog(assembly)); + + _exportProviderList.Add(new JoinableTaskContextExportProvider()); + } + } + + private static Assembly GetEditorAssembly(string assemblyName, Version version) + { + var qualifiedName = string.Format("{0}, Version={1}, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL", assemblyName, version); + return Assembly.Load(qualifiedName); + } + } +} diff --git a/Src/EditorUtils.Host/EditorLocatorUtil.cs b/Src/EditorUtils.Host/EditorLocatorUtil.cs new file mode 100644 index 0000000..1d304e9 --- /dev/null +++ b/Src/EditorUtils.Host/EditorLocatorUtil.cs @@ -0,0 +1,153 @@ +using Microsoft.VisualStudio.Setup.Configuration; +using Microsoft.Win32; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Runtime.InteropServices; +using System.Text; +using System.Threading.Tasks; + +namespace EditorUtils +{ + /// + /// Utility for locating instances of Visual Studio on the machine. + /// + internal static class EditorLocatorUtil + { + /// + /// A list of key names for versions of Visual Studio which have the editor components + /// necessary to create an EditorHost instance. Listed in preference order + /// + internal static readonly string[] VisualStudioSkuKeyNames = + new[] + { + "VisualStudio", + "WDExpress", + "VCSExpress", + "VCExpress", + "VBExpress", + }; + + internal static bool TryGetEditorInfo(EditorVersion? editorVersion, out Version vsVersion, out string vsvsInstallDirectory) + { + if (editorVersion.HasValue) + { + return TryGetEditorInfo(editorVersion.Value, out vsVersion, out vsvsInstallDirectory); + } + + foreach (var e in EditorVersionUtil.Supported) + { + if (TryGetEditorInfo(e, out vsVersion, out vsvsInstallDirectory)) + { + return true; + } + } + + vsVersion = default(Version); + vsvsInstallDirectory = null; + return false; + } + + internal static bool TryGetEditorInfo(EditorVersion editorVersion, out Version vsVersion, out string vsInstallDirectory) + { + var majorVersion = EditorVersionUtil.GetMajorVersionNumber(editorVersion); + return majorVersion < 15 + ? TryGetEditorInfoLegacy(majorVersion, out vsVersion, out vsInstallDirectory) + : TryGetEditorInfoWillow(majorVersion, out vsVersion, out vsInstallDirectory); + } + + private static bool TryGetEditorInfoLegacy(int majorVersion, out Version vsVersion, out string vsInstallDirectory) + { + if (TryGetVsInstallDirectoryLegacy(majorVersion, out vsInstallDirectory)) + { + vsVersion = new Version(majorVersion, 0); + return true; + } + + vsVersion = default(Version); + vsInstallDirectory = null; + return false; + } + + /// + /// Try and get the installation directory for the specified SKU of Visual Studio. This + /// will fail if the specified vsVersion of Visual Studio isn't installed. Only works on + /// pre-willow VS installations (< 15.0). + /// + private static bool TryGetVsInstallDirectoryLegacy(int majorVersion, out string vsInstallDirectory) + { + foreach (var skuKeyName in VisualStudioSkuKeyNames) + { + if (TryGetvsInstallDirectoryLegacy(majorVersion, skuKeyName, out vsInstallDirectory)) + { + return true; + } + } + + vsInstallDirectory = null; + return false; + } + + private static bool TryGetvsInstallDirectoryLegacy(int majorVersion, string skuKeyName,out string vsInstallDirectory) + { + try + { + var subKeyPath = String.Format(@"Software\Microsoft\{0}\{1}.0", skuKeyName, majorVersion); + using (var key = Registry.LocalMachine.OpenSubKey(subKeyPath, writable: false)) + { + if (key != null) + { + vsInstallDirectory = key.GetValue("InstallDir", null) as string; + if (!String.IsNullOrEmpty(vsInstallDirectory)) + { + return true; + } + } + } + } + catch (Exception) + { + // Ignore and try the next vsVersion + } + + vsInstallDirectory = null; + return false; + } + + /// + /// Get the first Willow VS installation with the specified major vsVersion. + /// + private static bool TryGetEditorInfoWillow(int majorVersion, out Version vsVersion, out string directory) + { + Debug.Assert(majorVersion >= 15); + + var setup = new SetupConfiguration(); + var e = setup.EnumAllInstances(); + var array = new ISetupInstance[] { null }; + do + { + var found = 0; + e.Next(array.Length, array, out found); + if (found == 0) + { + break; + } + + var instance = array[0]; + if (Version.TryParse(instance.GetInstallationVersion(), out vsVersion) && + vsVersion.Major == majorVersion) + { + directory = Path.Combine(instance.GetInstallationPath(), @"Common7\IDE"); + return true; + } + } + while (true); + + directory = null; + vsVersion = default(Version); + return false; + } + } +} diff --git a/Src/EditorUtils.Host/EditorUtils.Host.csproj b/Src/EditorUtils.Host/EditorUtils.Host.csproj new file mode 100644 index 0000000..52d0b5a --- /dev/null +++ b/Src/EditorUtils.Host/EditorUtils.Host.csproj @@ -0,0 +1,64 @@ + + + + + + Release + AnyCPU + {863A0141-59C5-481D-A3FC-A5812D973FEB} + Library + Properties + EditorUtils.Host + EditorUtils.Host + 512 + $(OutputPath)\$(EditorVersion) + + + true + full + false + $(DefineConstants);DEBUG;TRACE + prompt + 4 + + + pdbonly + true + $(DefineConstants);TRACE + prompt + 4 + + + + + + + + + True + + + + + + + + + + Constants.cs + + + + + + + + + + + {fb418222-c105-4942-8eeb-832ddcffd89d} + EditorUtils + + + + \ No newline at end of file diff --git a/Src/EditorUtils.Host/Properties/AssemblyInfo.cs b/Src/EditorUtils.Host/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..26b490d --- /dev/null +++ b/Src/EditorUtils.Host/Properties/AssemblyInfo.cs @@ -0,0 +1,41 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using EditorUtils; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("EditorUtils")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyProduct("EditorUtils")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("4826ca00-1f05-42e8-8dea-427bf872ae5e")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion(Constants.AssemblyVersion)] +[assembly: AssemblyFileVersion(Constants.AssemblyVersion)] +[assembly: InternalsVisibleTo("EditorUtils.UnitTest, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c90913d9ce09ec" ++ "960c03fe50c463b3a5f214fdebdcd9c33b1f5f8cddd3e82bc4ba2bf3846bbb4ddd5cd8a322a40a" ++ "dc41311155ebf6a1789c66c77345923153e49003049cb798836053198008405812d4e5ff468369" ++ "1e25db5930f79a1d206b864a852e1653ddf8d2bc73e085a98ef023681bf8453dc3bd29577b1ad3" ++ "55f863e7")] + diff --git a/Src/EditorUtils.settings b/Src/EditorUtils.settings deleted file mode 100644 index 52110ee..0000000 --- a/Src/EditorUtils.settings +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/Src/EditorUtils/Constants.cs b/Src/EditorUtils/Constants.cs index b864508..2209504 100644 --- a/Src/EditorUtils/Constants.cs +++ b/Src/EditorUtils/Constants.cs @@ -1,7 +1,7 @@  namespace EditorUtils { - public static class Constants + internal static class Constants { /// /// The version of the assembly. This must be changed every time a new version of the utility @@ -13,9 +13,11 @@ public static class Constants internal const string AssemblyVersion = "1.5.0.0"; #endif + internal const string PublicKeyToken = "3d1514c4742e0252"; + /// /// Standard delay for asynchronous taggers /// - public const int DefaultAsyncDelay = 100; + internal const int DefaultAsyncDelay = 100; } } diff --git a/Src/EditorUtils/EditorHostFactory.SimpleWaitIndicator.cs b/Src/EditorUtils/EditorHostFactory.SimpleWaitIndicator.cs new file mode 100644 index 0000000..8a6421a --- /dev/null +++ b/Src/EditorUtils/EditorHostFactory.SimpleWaitIndicator.cs @@ -0,0 +1,92 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.Composition; +using System.ComponentModel.Composition.Hosting; +using System.ComponentModel.Composition.Primitives; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Text; +using Microsoft.VisualStudio.Text.Operations; +using Microsoft.Win32; +using Microsoft.VisualStudio.Language.Intellisense.Utilities; +using System.Threading; + +namespace EditorUtils +{ + public sealed partial class EditorHostFactory + { + /// + /// The IWaitIndicator type is a new export in VS2017. This approach is a temporary work around that + /// is not a long term solution. It will only work when both running against VS2017 and using EditorUtils + /// compiled for VS2017. In all other cases it will fail because this export can only be created in + /// the versions compiled against VS2017. + /// +#if VS2017 + [Export(typeof(IWaitIndicator))] + public sealed class SimpleWaitIndicator : IWaitIndicator + { + public static readonly SimpleWaitIndicator Default = new SimpleWaitIndicator(); + + private readonly IWaitContext _waitContext; + + public SimpleWaitIndicator() + : this(new UncancellableWaitContext()) + { + } + + internal SimpleWaitIndicator(IWaitContext waitContext) + { + _waitContext = waitContext; + } + + IWaitContext IWaitIndicator.StartWait(string title, string message, bool allowCancel) + { + return _waitContext; + } + + WaitIndicatorResult IWaitIndicator.Wait(string title, string message, bool allowCancel, Action action) + { + try + { + action(_waitContext); + } + catch (OperationCanceledException) + { + return WaitIndicatorResult.Canceled; + } + + return WaitIndicatorResult.Completed; + } + + private sealed class UncancellableWaitContext : IWaitContext + { + public CancellationToken CancellationToken + { + get { return CancellationToken.None; } + } + + public void UpdateProgress() + { + } + + public bool AllowCancel + { + get { return false; } + set { } + } + + public string Message + { + get { return ""; } + set { } + } + + public void Dispose() + { + } + } + } +#endif + } +} diff --git a/Src/EditorUtils/EditorHostFactory.cs b/Src/EditorUtils/EditorHostFactory.cs deleted file mode 100644 index 7a4507c..0000000 --- a/Src/EditorUtils/EditorHostFactory.cs +++ /dev/null @@ -1,310 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel.Composition; -using System.ComponentModel.Composition.Hosting; -using System.ComponentModel.Composition.Primitives; -using System.IO; -using System.Linq; -using System.Reflection; -using System.Text; -using Microsoft.VisualStudio.Text.Operations; -using Microsoft.Win32; - -namespace EditorUtils -{ - public sealed partial class EditorHostFactory - { - // Determine the Visual Studio number that we are compiled against. This is important for - // doing probing of editor binaries (okay to load later, but not earlier). -#if VS2010 - private const EditorVersion ReferencedEditorVersion = EditorVersion.Vs2010; -#elif VS2012 - private const EditorVersion ReferencedEditorVersion = EditorVersion.Vs2012; -#elif VS2013 - private const EditorVersion ReferencedEditorVersion = EditorVersion.Vs2013; -#elif VS2015 - private const EditorVersion ReferencedEditorVersion = EditorVersion.Vs2015; -#else -#error Unexpected build combination -#endif - - private static readonly string[] EditorComponents = - new[] - { - // Core editor components - "Microsoft.VisualStudio.Platform.VSEditor.dll", - - // Not entirely sure why this is suddenly needed - "Microsoft.VisualStudio.Text.Internal.dll", - - // Must include this because several editor options are actually stored as exported information - // on this DLL. Including most importantly, the tabsize information - "Microsoft.VisualStudio.Text.Logic.dll", - - // Include this DLL to get several more EditorOptions including WordWrapStyle - "Microsoft.VisualStudio.Text.UI.dll", - - // Include this DLL to get more EditorOptions values and the core editor - "Microsoft.VisualStudio.Text.UI.Wpf.dll" - }; - - /// - /// A list of key names for versions of Visual Studio which have the editor components - /// necessary to create an EditorHost instance. Listed in preference order - /// - private static readonly string[] VisualStudioSkuKeyNames = - new[] - { - // Standard non-express SKU of Visual Studio - "VisualStudio", - - // Windows Desktop express - "WDExpress", - - // Visual C# express - "VCSExpress", - - // Visual C++ express - "VCExpress", - - // Visual Basic Express - "VBExpress", - }; - - private readonly List _composablePartCatalogList = new List(); - private readonly List _exportProviderList = new List(); - - /// - /// The minimum value supported by this assembly. - /// - public static EditorVersion MinimumEditorVersion - { - get { return ReferencedEditorVersion; } - } - - public static EditorVersion MaxEditorVersion - { - get { return EditorVersion.Vs2015; } - } - - public EditorHostFactory(EditorVersion? editorVersion = null) - { - AppendEditorCatalog(_composablePartCatalogList, editorVersion); - _exportProviderList.Add(new UndoExportProvider()); - } - - public void Add(ComposablePartCatalog composablePartCatalog) - { - _composablePartCatalogList.Add(composablePartCatalog); - } - - public void Add(ExportProvider exportProvider) - { - _exportProviderList.Add(exportProvider); - } - - public CompositionContainer CreateCompositionContainer() - { - var catalog = new AggregateCatalog(_composablePartCatalogList.ToArray()); - return new CompositionContainer(catalog, _exportProviderList.ToArray()); - } - - public EditorHost CreateEditorHost() - { - return new EditorHost(CreateCompositionContainer()); - } - - /// - /// Load the list of editor assemblies into the specified catalog list. This method will - /// throw on failure - /// - private static void AppendEditorCatalog(List list, EditorVersion? editorVersion) - { - string version; - string installDirectory; - if (!TryGetEditorInfo(editorVersion, out version, out installDirectory)) - { - throw new Exception("Unable to calculate the version of Visual Studio installed on the machine"); - } - - if (!TryLoadInteropAssembly(installDirectory)) - { - var message = string.Format("Unable to load the interop assemblies. Install directory is: ", installDirectory); - throw new Exception(message); - } - - // Load the core editor compontents from the GAC - var versionInfo = string.Format(", Version={0}, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL", version); - foreach (var name in EditorComponents) - { - var simpleName = name.Substring(0, name.Length - 4); - var qualifiedName = simpleName + versionInfo; - - Assembly assembly; - try - { - assembly = Assembly.Load(qualifiedName); - } - catch (Exception e) - { - var msg = string.Format("Unable to load editor dependency {0}", name); - throw new Exception(msg, e); - } - - list.Add(new AssemblyCatalog(assembly)); - } - } - - private static bool TryGetEditorInfo(EditorVersion? editorVersion, out string fullVersion, out string installDirectory) - { - if (editorVersion.HasValue) - { - var shortVersion = GetShortVersionString(editorVersion.Value); - return TryGetEditorInfoCore(shortVersion, out fullVersion, out installDirectory); - } - - return TryCalculateEditorInfo(out fullVersion, out installDirectory); - } - - /// - /// Try and calculate the version of Visual Studio installed on this machine. Need both the version - /// and the install directory in order to load up the editor components for testing - /// - private static bool TryCalculateEditorInfo(out string fullVersion, out string installDirectory) - { - // The same pattern exists for all known versions of Visual Studio. The editor was - // introduced in version 10 (VS2010). The max of 20 is arbitrary and just meant to - // future proof this algorithm for some time into the future - var max = GetVersionNumber(MaxEditorVersion); - for (int i = GetVersionNumber(MinimumEditorVersion); i <= max; i++) - { - var shortVersion = String.Format("{0}.0", i); - if (TryGetEditorInfoCore(shortVersion, out fullVersion, out installDirectory)) - { - return true; - } - } - - installDirectory = null; - fullVersion = null; - return false; - } - - private static bool TryGetEditorInfoCore(string shortVersion, out string fullversion, out string installDirectory) - { - if (TryGetInstallDirectory(shortVersion, out installDirectory)) - { - fullversion = string.Format("{0}.0.0", shortVersion); - return true; - } - - fullversion = null; - return false; - } - - /// - /// Try and get the installation directory for the specified version of Visual Studio. This - /// will fail if the specified version of Visual Studio isn't installed - /// - private static bool TryGetInstallDirectory(string shortVersion, out string installDirectory) - { - foreach (var skuKeyName in VisualStudioSkuKeyNames) - { - if (TryGetInstallDirectory(skuKeyName, shortVersion, out installDirectory)) - { - return true; - } - } - - installDirectory = null; - return false; - } - - /// - /// Try and get the installation directory for the specified SKU of Visual Studio. This - /// will fail if the specified version of Visual Studio isn't installed - /// - private static bool TryGetInstallDirectory(string skuKeyName, string shortVersion, out string installDirectory) - { - try - { - var subKeyPath = String.Format(@"Software\Microsoft\{0}\{1}", skuKeyName, shortVersion); - using (var key = Registry.LocalMachine.OpenSubKey(subKeyPath, writable: false)) - { - if (key != null) - { - installDirectory = key.GetValue("InstallDir", null) as string; - if (!String.IsNullOrEmpty(installDirectory)) - { - return true; - } - } - } - } - catch (Exception) - { - // Ignore and try the next version - } - - installDirectory = null; - return false; - } - - /// - /// The interop assembly isn't included in the GAC and it doesn't offer any MEF components (it's - /// just a simple COM interop library). Hence it needs to be loaded a bit specially. Just find - /// the assembly on disk and hook into the resolve event - /// - private static bool TryLoadInteropAssembly(string installDirectory) - { - const string interopName = "Microsoft.VisualStudio.Platform.VSEditor.Interop"; - const string interopNameWithExtension = interopName + ".dll"; - var interopAssemblyPath = Path.Combine(installDirectory, "PrivateAssemblies"); - interopAssemblyPath = Path.Combine(interopAssemblyPath, interopNameWithExtension); - try - { - var interopAssembly = Assembly.LoadFrom(interopAssemblyPath); - if (interopAssembly == null) - { - return false; - } - - var comparer = StringComparer.OrdinalIgnoreCase; - AppDomain.CurrentDomain.AssemblyResolve += (sender, e) => - { - if (comparer.Equals(e.Name, interopAssembly.FullName)) - { - return interopAssembly; - } - - return null; - }; - - return true; - } - catch (Exception) - { - return false; - } - } - - internal static int GetVersionNumber(EditorVersion version) - { - switch (version) - { - case EditorVersion.Vs2010: return 10; - case EditorVersion.Vs2012: return 11; - case EditorVersion.Vs2013: return 12; - case EditorVersion.Vs2015: return 14; - default: - throw new Exception(string.Format("Unexpected enum value {0}", version)); - } - } - - internal static string GetShortVersionString(EditorVersion version) - { - var number = GetVersionNumber(version); - return string.Format("{0}.0", number); - } - } -} diff --git a/Src/EditorUtils/EditorUtils.csproj b/Src/EditorUtils/EditorUtils.csproj index 07136a9..f30ac15 100644 --- a/Src/EditorUtils/EditorUtils.csproj +++ b/Src/EditorUtils/EditorUtils.csproj @@ -1,28 +1,21 @@  - - + + Release - - - Debug AnyCPU - 8.0.30703 - 2.0 {FB418222-C105-4942-8EEB-832DDCFFD89D} Library Properties EditorUtils - EditorUtils$(EditorSuffix) - $(EditorFrameworkVersion) - 512 + EditorUtils + $(OutputPath)\$(EditorVersion) true full false - bin\Debug\ $(DefineConstants);DEBUG;TRACE prompt 4 @@ -30,22 +23,19 @@ pdbonly true - bin\Release\ $(DefineConstants);TRACE prompt 4 - - true - Key.snk - false - + + True + @@ -56,11 +46,9 @@ - - - + @@ -90,16 +78,5 @@ - - - - - - + \ No newline at end of file diff --git a/Src/EditorUtils/EditorVersion.cs b/Src/EditorUtils/EditorVersion.cs index 50f6c7d..84b9dad 100644 --- a/Src/EditorUtils/EditorVersion.cs +++ b/Src/EditorUtils/EditorVersion.cs @@ -15,5 +15,6 @@ public enum EditorVersion Vs2012, Vs2013, Vs2015, + Vs2017, } } diff --git a/Src/EditorUtils/EditorVersionUtil.cs b/Src/EditorUtils/EditorVersionUtil.cs new file mode 100644 index 0000000..f81aad9 --- /dev/null +++ b/Src/EditorUtils/EditorVersionUtil.cs @@ -0,0 +1,75 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace EditorUtils +{ + public static class EditorVersionUtil + { + /// + /// The version of Visual Studio this editor instance is compiled against. + /// +#if VS2010 + public static readonly EditorVersion TargetVersion = EditorVersion.Vs2010; +#elif VS2012 + public static readonly EditorVersion TargetVersion = EditorVersion.Vs2012; +#elif VS2013 + public static readonly EditorVersion TargetVersion = EditorVersion.Vs2013; +#elif VS2015 + public static readonly EditorVersion TargetVersion = EditorVersion.Vs2015; +#elif VS2017 + public static readonly EditorVersion TargetVersion = EditorVersion.Vs2017; +#else +#error Unexpected build combination +#endif + + public static IEnumerable All => Enum.GetValues(typeof(EditorVersion)).Cast().OrderBy(x => GetMajorVersionNumber(x)); + + public static IEnumerable Supported => All.Where(IsSupported); + + public static EditorVersion MaxVersion => All.OrderByDescending(x => GetMajorVersionNumber(x)).First(); + + /// + /// Whether or not this EditorVersion is supported by this particular compilation. For instance + /// the VS2012 version of this binary may not support VS2010. + /// + public static bool IsSupported(EditorVersion version) + { + return GetMajorVersionNumber(TargetVersion) <= GetMajorVersionNumber(version); + } + + public static EditorVersion GetEditorVersion(int majorVersion) + { + switch (majorVersion) + { + case 10: return EditorVersion.Vs2010; + case 11: return EditorVersion.Vs2012; + case 12: return EditorVersion.Vs2013; + case 14: return EditorVersion.Vs2015; + case 15: return EditorVersion.Vs2017; + default: throw new Exception(string.Format("Unexpected major version value {0}", majorVersion)); + } + } + + public static int GetMajorVersionNumber(EditorVersion version) + { + switch (version) + { + case EditorVersion.Vs2010: return 10; + case EditorVersion.Vs2012: return 11; + case EditorVersion.Vs2013: return 12; + case EditorVersion.Vs2015: return 14; + case EditorVersion.Vs2017: return 15; + default: throw new Exception(string.Format("Unexpected enum value {0}", version)); + } + } + + public static string GetShortVersionString(EditorVersion version) + { + var number = GetMajorVersionNumber(version); + return string.Format("{0}.0", number); + } + } +} diff --git a/Src/EditorUtils/Key.snk b/Src/EditorUtils/Key.snk deleted file mode 100644 index 25ac3cd..0000000 Binary files a/Src/EditorUtils/Key.snk and /dev/null differ diff --git a/Src/EditorUtils/Properties/AssemblyInfo.cs b/Src/EditorUtils/Properties/AssemblyInfo.cs index a025f09..26b490d 100644 --- a/Src/EditorUtils/Properties/AssemblyInfo.cs +++ b/Src/EditorUtils/Properties/AssemblyInfo.cs @@ -33,10 +33,9 @@ // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion(Constants.AssemblyVersion)] [assembly: AssemblyFileVersion(Constants.AssemblyVersion)] -[assembly: InternalsVisibleTo("EditorUtils.UnitTest, PublicKey=" + - "0024000004800000940000000602000000240000525341310004000001000100c90913d9ce09ec" + - "960c03fe50c463b3a5f214fdebdcd9c33b1f5f8cddd3e82bc4ba2bf3846bbb4ddd5cd8a322a40a" + - "dc41311155ebf6a1789c66c77345923153e49003049cb798836053198008405812d4e5ff468369" + - "1e25db5930f79a1d206b864a852e1653ddf8d2bc73e085a98ef023681bf8453dc3bd29577b1ad3" + - "55f863e7")] +[assembly: InternalsVisibleTo("EditorUtils.UnitTest, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c90913d9ce09ec" ++ "960c03fe50c463b3a5f214fdebdcd9c33b1f5f8cddd3e82bc4ba2bf3846bbb4ddd5cd8a322a40a" ++ "dc41311155ebf6a1789c66c77345923153e49003049cb798836053198008405812d4e5ff468369" ++ "1e25db5930f79a1d206b864a852e1653ddf8d2bc73e085a98ef023681bf8453dc3bd29577b1ad3" ++ "55f863e7")] diff --git a/Test/EditorUtilsTest/AdhocOutlinerTest.cs b/Src/EditorUtilsTest/AdhocOutlinerTest.cs similarity index 100% rename from Test/EditorUtilsTest/AdhocOutlinerTest.cs rename to Src/EditorUtilsTest/AdhocOutlinerTest.cs diff --git a/Src/EditorUtilsTest/App.config b/Src/EditorUtilsTest/App.config new file mode 100644 index 0000000..fced331 --- /dev/null +++ b/Src/EditorUtilsTest/App.config @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Test/EditorUtilsTest/AsyncTaggerTest.cs b/Src/EditorUtilsTest/AsyncTaggerTest.cs similarity index 100% rename from Test/EditorUtilsTest/AsyncTaggerTest.cs rename to Src/EditorUtilsTest/AsyncTaggerTest.cs diff --git a/Test/EditorUtilsTest/BasicTaggerTest.cs b/Src/EditorUtilsTest/BasicTaggerTest.cs similarity index 100% rename from Test/EditorUtilsTest/BasicTaggerTest.cs rename to Src/EditorUtilsTest/BasicTaggerTest.cs diff --git a/Test/EditorUtilsTest/BasicUndoHistoryTest.cs b/Src/EditorUtilsTest/BasicUndoHistoryTest.cs similarity index 100% rename from Test/EditorUtilsTest/BasicUndoHistoryTest.cs rename to Src/EditorUtilsTest/BasicUndoHistoryTest.cs diff --git a/Test/EditorUtilsTest/ChannelTest.cs b/Src/EditorUtilsTest/ChannelTest.cs similarity index 100% rename from Test/EditorUtilsTest/ChannelTest.cs rename to Src/EditorUtilsTest/ChannelTest.cs diff --git a/Test/EditorUtilsTest/ClassifierTest.cs b/Src/EditorUtilsTest/ClassifierTest.cs similarity index 100% rename from Test/EditorUtilsTest/ClassifierTest.cs rename to Src/EditorUtilsTest/ClassifierTest.cs diff --git a/Test/EditorUtilsTest/CountedClassifierTest.cs b/Src/EditorUtilsTest/CountedClassifierTest.cs similarity index 100% rename from Test/EditorUtilsTest/CountedClassifierTest.cs rename to Src/EditorUtilsTest/CountedClassifierTest.cs diff --git a/Test/EditorUtilsTest/CountedTaggerTest.cs b/Src/EditorUtilsTest/CountedTaggerTest.cs similarity index 100% rename from Test/EditorUtilsTest/CountedTaggerTest.cs rename to Src/EditorUtilsTest/CountedTaggerTest.cs diff --git a/Test/EditorUtilsTest/EditorHostTest.cs b/Src/EditorUtilsTest/EditorHostTest.cs similarity index 84% rename from Test/EditorUtilsTest/EditorHostTest.cs rename to Src/EditorUtilsTest/EditorHostTest.cs index 4393eab..b4379b2 100644 --- a/Test/EditorUtilsTest/EditorHostTest.cs +++ b/Src/EditorUtilsTest/EditorHostTest.cs @@ -8,6 +8,7 @@ using Microsoft.VisualStudio.Text.Outlining; using Microsoft.VisualStudio.Text.Projection; using Microsoft.VisualStudio.Utilities; +using System.Reflection; namespace EditorUtils.UnitTest { @@ -90,7 +91,22 @@ public TestableSynchronizationContext TestableSynchronizationContext public EditorHostTest() { - _editorHost = GetOrCreateEditorHost(); + try + { + _editorHost = GetOrCreateEditorHost(); + } + catch (ReflectionTypeLoadException e) + { + // When this fails in AppVeyor the error message is useless. Need to construct a more actionable + // error message here. + var builder = new StringBuilder(); + builder.AppendLine(e.Message); + foreach (var item in e.LoaderExceptions) + { + builder.AppendLine(item.Message); + } + throw new Exception(builder.ToString(), e); + } _synchronizationContext = new TestableSynchronizationContext(); _synchronizationContext.Install(); } diff --git a/Test/EditorUtilsTest/EditorUtilsTest.csproj b/Src/EditorUtilsTest/EditorUtilsTest.csproj similarity index 80% rename from Test/EditorUtilsTest/EditorUtilsTest.csproj rename to Src/EditorUtilsTest/EditorUtilsTest.csproj index 11872f5..1da4401 100644 --- a/Test/EditorUtilsTest/EditorUtilsTest.csproj +++ b/Src/EditorUtilsTest/EditorUtilsTest.csproj @@ -1,6 +1,6 @@  - + Debug AnyCPU @@ -11,16 +11,14 @@ Properties EditorUtils.UnitTest EditorUtils.UnitTest - $(EditorFrameworkVersion) 512 - ..\ true + $(OutputPath)\$(EditorVersion) true full false - bin\Debug\ $(DefineConstants);DEBUG;TRACE prompt 4 @@ -28,23 +26,18 @@ pdbonly true - bin\Release\ $(DefineConstants);TRACE prompt 4 - - true - - - Key.snk - + + ..\..\packages\Moq.4.0.10827\lib\NET40\Moq.dll @@ -70,7 +63,7 @@ - + @@ -91,6 +84,14 @@ + + {7f5978fe-07d8-414d-8a18-18343b9688d1} + EditorUtils.Host.Vs2017 + + + {863a0141-59c5-481d-a3fc-a5812d973feb} + EditorUtils.Host + {FB418222-C105-4942-8EEB-832DDCFFD89D} EditorUtils @@ -98,11 +99,10 @@ - - + diff --git a/Src/EditorUtilsTest/EditorVersionUtilTest.cs b/Src/EditorUtilsTest/EditorVersionUtilTest.cs new file mode 100644 index 0000000..201dbd2 --- /dev/null +++ b/Src/EditorUtilsTest/EditorVersionUtilTest.cs @@ -0,0 +1,53 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Xunit; + +namespace EditorUtils.UnitTest +{ + public sealed class EditorVersionUtilTest + { + [Fact] + public void GetShortVersionStringAll() + { + foreach (var e in Enum.GetValues(typeof(EditorVersion)).Cast()) + { + var value = EditorVersionUtil.GetShortVersionString(e); + Assert.NotNull(value); + } + } + + [Fact] + public void GetVersionNumberAll() + { + Assert.Equal(10, EditorVersionUtil.GetMajorVersionNumber(EditorVersion.Vs2010)); + Assert.Equal(11, EditorVersionUtil.GetMajorVersionNumber(EditorVersion.Vs2012)); + Assert.Equal(12, EditorVersionUtil.GetMajorVersionNumber(EditorVersion.Vs2013)); + Assert.Equal(14, EditorVersionUtil.GetMajorVersionNumber(EditorVersion.Vs2015)); + Assert.Equal(15, EditorVersionUtil.GetMajorVersionNumber(EditorVersion.Vs2017)); + } + + [Fact] + public void MaxEditorVersionIsMax() + { + var max = EditorVersionUtil.GetMajorVersionNumber(EditorVersionUtil.MaxVersion); + foreach (var e in Enum.GetValues(typeof(EditorVersion)).Cast()) + { + var number = EditorVersionUtil.GetMajorVersionNumber(e); + Assert.True(number <= max); + } + } + + [Fact] + public void Completeness() + { + foreach (var e in Enum.GetValues(typeof(EditorVersion)).Cast()) + { + var majorVersion = EditorVersionUtil.GetMajorVersionNumber(e); + var e2 = EditorVersionUtil.GetEditorVersion(majorVersion); + Assert.Equal(e, e2); + } + } + } +} diff --git a/Test/EditorUtilsTest/EqualityUtil.cs b/Src/EditorUtilsTest/EqualityUtil.cs similarity index 100% rename from Test/EditorUtilsTest/EqualityUtil.cs rename to Src/EditorUtilsTest/EqualityUtil.cs diff --git a/Test/EditorUtilsTest/Extensions.cs b/Src/EditorUtilsTest/Extensions.cs similarity index 87% rename from Test/EditorUtilsTest/Extensions.cs rename to Src/EditorUtilsTest/Extensions.cs index 72ff3d9..6d8f1d7 100644 --- a/Test/EditorUtilsTest/Extensions.cs +++ b/Src/EditorUtilsTest/Extensions.cs @@ -142,7 +142,25 @@ internal static void DoEvents(this Dispatcher dispatcher) DispatcherPriority.SystemIdle, action, frame); - Dispatcher.PushFrame(frame); + + var count = 3; + do + { + try + { + Dispatcher.PushFrame(frame); + break; + } + catch + { + // The core editor can surface exceptions when we run events in + // this manner. It would be nice if they could be distinguished from + // exceptions thrown from EditorUtils but can't find a way. Reluctantly + // swallow exceptions. + } + + count--; + } while (count > 0); } #endregion diff --git a/Test/EditorUtilsTest/ExtensionsTest.cs b/Src/EditorUtilsTest/ExtensionsTest.cs similarity index 100% rename from Test/EditorUtilsTest/ExtensionsTest.cs rename to Src/EditorUtilsTest/ExtensionsTest.cs diff --git a/Test/EditorUtilsTest/LineRangeTest.cs b/Src/EditorUtilsTest/LineRangeTest.cs similarity index 100% rename from Test/EditorUtilsTest/LineRangeTest.cs rename to Src/EditorUtilsTest/LineRangeTest.cs diff --git a/Test/EditorUtilsTest/MemoryLeakTest.cs b/Src/EditorUtilsTest/MemoryLeakTest.cs similarity index 100% rename from Test/EditorUtilsTest/MemoryLeakTest.cs rename to Src/EditorUtilsTest/MemoryLeakTest.cs diff --git a/Test/EditorUtilsTest/MockFactory.cs b/Src/EditorUtilsTest/MockFactory.cs similarity index 100% rename from Test/EditorUtilsTest/MockFactory.cs rename to Src/EditorUtilsTest/MockFactory.cs diff --git a/Test/EditorUtilsTest/NormalizedLineRangeCollectionTest.cs b/Src/EditorUtilsTest/NormalizedLineRangeCollectionTest.cs similarity index 100% rename from Test/EditorUtilsTest/NormalizedLineRangeCollectionTest.cs rename to Src/EditorUtilsTest/NormalizedLineRangeCollectionTest.cs diff --git a/Test/EditorUtilsTest/Properties/AssemblyInfo.cs b/Src/EditorUtilsTest/Properties/AssemblyInfo.cs similarity index 100% rename from Test/EditorUtilsTest/Properties/AssemblyInfo.cs rename to Src/EditorUtilsTest/Properties/AssemblyInfo.cs diff --git a/Test/EditorUtilsTest/ProtectedOperationsTest.cs b/Src/EditorUtilsTest/ProtectedOperationsTest.cs similarity index 100% rename from Test/EditorUtilsTest/ProtectedOperationsTest.cs rename to Src/EditorUtilsTest/ProtectedOperationsTest.cs diff --git a/Test/EditorUtilsTest/ReadOnlyStackTest.cs b/Src/EditorUtilsTest/ReadOnlyStackTest.cs similarity index 100% rename from Test/EditorUtilsTest/ReadOnlyStackTest.cs rename to Src/EditorUtilsTest/ReadOnlyStackTest.cs diff --git a/Test/EditorUtilsTest/SnapshotLineRangeTest.cs b/Src/EditorUtilsTest/SnapshotLineRangeTest.cs similarity index 100% rename from Test/EditorUtilsTest/SnapshotLineRangeTest.cs rename to Src/EditorUtilsTest/SnapshotLineRangeTest.cs diff --git a/Test/EditorUtilsTest/TaggerCommonTest.cs b/Src/EditorUtilsTest/TaggerCommonTest.cs similarity index 100% rename from Test/EditorUtilsTest/TaggerCommonTest.cs rename to Src/EditorUtilsTest/TaggerCommonTest.cs diff --git a/Test/EditorUtilsTest/TaggerUtilTest.cs b/Src/EditorUtilsTest/TaggerUtilTest.cs similarity index 100% rename from Test/EditorUtilsTest/TaggerUtilTest.cs rename to Src/EditorUtilsTest/TaggerUtilTest.cs diff --git a/Test/EditorUtilsTest/TestUtils.cs b/Src/EditorUtilsTest/TestUtils.cs similarity index 100% rename from Test/EditorUtilsTest/TestUtils.cs rename to Src/EditorUtilsTest/TestUtils.cs diff --git a/Test/EditorUtilsTest/TestableSynchronizationContext.cs b/Src/EditorUtilsTest/TestableSynchronizationContext.cs similarity index 100% rename from Test/EditorUtilsTest/TestableSynchronizationContext.cs rename to Src/EditorUtilsTest/TestableSynchronizationContext.cs diff --git a/Test/EditorUtilsTest/TextTaggerSource.cs b/Src/EditorUtilsTest/TextTaggerSource.cs similarity index 100% rename from Test/EditorUtilsTest/TextTaggerSource.cs rename to Src/EditorUtilsTest/TextTaggerSource.cs diff --git a/Test/EditorUtilsTest/VersioningTest.cs b/Src/EditorUtilsTest/VersioningTest.cs similarity index 100% rename from Test/EditorUtilsTest/VersioningTest.cs rename to Src/EditorUtilsTest/VersioningTest.cs diff --git a/Test/EditorUtilsTest/packages.config b/Src/EditorUtilsTest/packages.config similarity index 100% rename from Test/EditorUtilsTest/packages.config rename to Src/EditorUtilsTest/packages.config diff --git a/Test/Cats/CatTagger.cs b/Src/Samples/Cats/CatTagger.cs similarity index 100% rename from Test/Cats/CatTagger.cs rename to Src/Samples/Cats/CatTagger.cs diff --git a/Test/Cats/CatTaggerFormat.cs b/Src/Samples/Cats/CatTaggerFormat.cs similarity index 100% rename from Test/Cats/CatTaggerFormat.cs rename to Src/Samples/Cats/CatTaggerFormat.cs diff --git a/Test/Cats/CatTaggerProvider.cs b/Src/Samples/Cats/CatTaggerProvider.cs similarity index 100% rename from Test/Cats/CatTaggerProvider.cs rename to Src/Samples/Cats/CatTaggerProvider.cs diff --git a/Test/Cats/Cats.csproj b/Src/Samples/Cats/Cats.csproj similarity index 80% rename from Test/Cats/Cats.csproj rename to Src/Samples/Cats/Cats.csproj index 2ef9c7f..b73fe94 100644 --- a/Test/Cats/Cats.csproj +++ b/Src/Samples/Cats/Cats.csproj @@ -1,6 +1,6 @@  - + Debug AnyCPU @@ -12,14 +12,18 @@ Properties Cats Cats - v4.0 - 512 false $(MSBuildExtensionsPath)\Microsoft\VisualStudio\v$(VisualStudioVersion)\VSSDK\Microsoft.VsSDK.targets $(MSBuildExtensionsPath)\Microsoft\VisualStudio\v10.0\VSSDK\Microsoft.VsSDK.targets Program $(DevEnvDir)\devenv.exe /rootsuffix Exp + 15.0 + + + + + 4.0 @@ -37,7 +41,6 @@ true full false - bin\Debug\ DEBUG;TRACE prompt 4 @@ -45,19 +48,16 @@ pdbonly true - bin\Release\ TRACE prompt 4 - - - - - - - + + + + + diff --git a/Test/Cats/Contstants.cs b/Src/Samples/Cats/Contstants.cs similarity index 100% rename from Test/Cats/Contstants.cs rename to Src/Samples/Cats/Contstants.cs diff --git a/Test/Cats/DogClassifier.cs b/Src/Samples/Cats/DogClassifier.cs similarity index 100% rename from Test/Cats/DogClassifier.cs rename to Src/Samples/Cats/DogClassifier.cs diff --git a/Test/Cats/DogClassifierProvider.cs b/Src/Samples/Cats/DogClassifierProvider.cs similarity index 100% rename from Test/Cats/DogClassifierProvider.cs rename to Src/Samples/Cats/DogClassifierProvider.cs diff --git a/Test/Cats/DogTaggerFormat.cs b/Src/Samples/Cats/DogTaggerFormat.cs similarity index 100% rename from Test/Cats/DogTaggerFormat.cs rename to Src/Samples/Cats/DogTaggerFormat.cs diff --git a/Test/Cats/Properties/AssemblyInfo.cs b/Src/Samples/Cats/Properties/AssemblyInfo.cs similarity index 100% rename from Test/Cats/Properties/AssemblyInfo.cs rename to Src/Samples/Cats/Properties/AssemblyInfo.cs diff --git a/Test/Cats/source.extension.vsixmanifest b/Src/Samples/Cats/source.extension.vsixmanifest similarity index 100% rename from Test/Cats/source.extension.vsixmanifest rename to Src/Samples/Cats/source.extension.vsixmanifest diff --git a/Test/WordUnderCaret/Constants.cs b/Src/Samples/WordUnderCaret/Constants.cs similarity index 100% rename from Test/WordUnderCaret/Constants.cs rename to Src/Samples/WordUnderCaret/Constants.cs diff --git a/Test/WordUnderCaret/Properties/AssemblyInfo.cs b/Src/Samples/WordUnderCaret/Properties/AssemblyInfo.cs similarity index 100% rename from Test/WordUnderCaret/Properties/AssemblyInfo.cs rename to Src/Samples/WordUnderCaret/Properties/AssemblyInfo.cs diff --git a/Test/WordUnderCaret/WordUnderCaret.csproj b/Src/Samples/WordUnderCaret/WordUnderCaret.csproj similarity index 78% rename from Test/WordUnderCaret/WordUnderCaret.csproj rename to Src/Samples/WordUnderCaret/WordUnderCaret.csproj index 430557c..17df70b 100644 --- a/Test/WordUnderCaret/WordUnderCaret.csproj +++ b/Src/Samples/WordUnderCaret/WordUnderCaret.csproj @@ -1,25 +1,27 @@  - + Debug AnyCPU - 10.0.20305 - 2.0 {82b43b9b-a64c-4715-b499-d71e9ca2bd60};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} {620BEC49-DF9C-406A-9492-BD157BAB95BC} Library Properties WordUnderCaret WordUnderCaret - v4.0 - 512 false $(MSBuildExtensionsPath)\Microsoft\VisualStudio\v$(VisualStudioVersion)\VSSDK\Microsoft.VsSDK.targets $(MSBuildExtensionsPath)\Microsoft\VisualStudio\v10.0\VSSDK\Microsoft.VsSDK.targets Program $(DevEnvDir)\devenv.exe /rootsuffix Exp + 15.0 + + + + + 4.0 @@ -37,7 +39,6 @@ true full false - bin\Debug\ DEBUG;TRACE prompt 4 @@ -45,19 +46,16 @@ pdbonly true - bin\Release\ TRACE prompt 4 - - - - - - - + + + + + diff --git a/Test/WordUnderCaret/WordUnderCaret.sln b/Src/Samples/WordUnderCaret/WordUnderCaret.sln similarity index 100% rename from Test/WordUnderCaret/WordUnderCaret.sln rename to Src/Samples/WordUnderCaret/WordUnderCaret.sln diff --git a/Test/WordUnderCaret/WordUnderCaretFormat.cs b/Src/Samples/WordUnderCaret/WordUnderCaretFormat.cs similarity index 100% rename from Test/WordUnderCaret/WordUnderCaretFormat.cs rename to Src/Samples/WordUnderCaret/WordUnderCaretFormat.cs diff --git a/Test/WordUnderCaret/WordUnderCaretTagger.cs b/Src/Samples/WordUnderCaret/WordUnderCaretTagger.cs similarity index 100% rename from Test/WordUnderCaret/WordUnderCaretTagger.cs rename to Src/Samples/WordUnderCaret/WordUnderCaretTagger.cs diff --git a/Test/WordUnderCaret/WordUnderCaretTaggerProvider.cs b/Src/Samples/WordUnderCaret/WordUnderCaretTaggerProvider.cs similarity index 100% rename from Test/WordUnderCaret/WordUnderCaretTaggerProvider.cs rename to Src/Samples/WordUnderCaret/WordUnderCaretTaggerProvider.cs diff --git a/Test/WordUnderCaret/source.extension.vsixmanifest b/Src/Samples/WordUnderCaret/source.extension.vsixmanifest similarity index 100% rename from Test/WordUnderCaret/source.extension.vsixmanifest rename to Src/Samples/WordUnderCaret/source.extension.vsixmanifest diff --git a/Test/EditorUtils.settings b/Test/EditorUtils.settings deleted file mode 100644 index 52110ee..0000000 --- a/Test/EditorUtils.settings +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/Test/EditorUtilsTest/App.config b/Test/EditorUtilsTest/App.config deleted file mode 100644 index 09b8ee2..0000000 --- a/Test/EditorUtilsTest/App.config +++ /dev/null @@ -1,5 +0,0 @@ - - - - diff --git a/Test/EditorUtilsTest/EditorHostFactoryTest.cs b/Test/EditorUtilsTest/EditorHostFactoryTest.cs deleted file mode 100644 index 361e93b..0000000 --- a/Test/EditorUtilsTest/EditorHostFactoryTest.cs +++ /dev/null @@ -1,41 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Xunit; - -namespace EditorUtils.UnitTest -{ - public sealed class EditorHostFactoryTest - { - [Fact] - public void GetShortVersionStringAll() - { - foreach (var e in Enum.GetValues(typeof(EditorVersion)).Cast()) - { - var value = EditorHostFactory.GetShortVersionString(e); - Assert.NotNull(value); - } - } - - [Fact] - public void GetVersionNumberAll() - { - Assert.Equal(10, EditorHostFactory.GetVersionNumber(EditorVersion.Vs2010)); - Assert.Equal(11, EditorHostFactory.GetVersionNumber(EditorVersion.Vs2012)); - Assert.Equal(12, EditorHostFactory.GetVersionNumber(EditorVersion.Vs2013)); - Assert.Equal(14, EditorHostFactory.GetVersionNumber(EditorVersion.Vs2015)); - } - - [Fact] - public void MaxEditorVersionIsMax() - { - var max = EditorHostFactory.GetVersionNumber(EditorHostFactory.MaxEditorVersion); - foreach (var e in Enum.GetValues(typeof(EditorVersion)).Cast()) - { - var number = EditorHostFactory.GetVersionNumber(e); - Assert.True(number <= max); - } - } - } -} diff --git a/Test/EditorUtilsTest/Key.snk b/Test/EditorUtilsTest/Key.snk deleted file mode 100644 index 25ac3cd..0000000 Binary files a/Test/EditorUtilsTest/Key.snk and /dev/null differ diff --git a/appveyor.yml b/appveyor.yml index 59972f6..140734f 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,4 +1,9 @@ +image: Visual Studio 2017 + +environment: + VisualStudioVersion: 15.0 + # Branchs to build branches: only: @@ -6,10 +11,14 @@ branches: configuration: Debug +before_build: + # Updates the version number in the .vsixmanifest and updates the AppVeyor build number to match + - nuget restore EditorUtils.sln + build: project: EditorUtils.sln verbosity: minimal test_script: - - Tools\xunit.console.clr4.x86.exe Test\EditorUtilsTest\bin\Debug\EditorUtils.UnitTest.dll /silent + - Tools\xunit.console.clr4.x86.exe Binaries\Debug\EditorUtilsTest\Vs2017\EditorUtils.UnitTest.dll /silent