├── .github └── workflows │ └── continuous-integration-workflow.yml ├── .gitignore ├── Changelog.txt ├── CppCoveragePlugin.sln ├── CppCoveragePluginVS2013.sln ├── Externals └── ICSharpCode.TreeView.dll ├── IntegrationTests.testsettings ├── IntegrationTestsVS2013.testsettings ├── LICENSE.txt ├── README.md ├── RunOpenCover.bat ├── UnitTests.testsettings ├── VSPackage ├── CommandLineBuilder.cs ├── CommandRunner.cs ├── ConfigurationManager.cs ├── CoverageData │ ├── CoverageData.proto │ ├── CoverageDataDeserializer.cs │ └── CoverageResult.cs ├── CoverageRateBuilder │ ├── CoverageRate.cs │ └── CoverageRateBuilder.cs ├── CoverageRunner.cs ├── CoverageTree │ ├── BasicCoverageTreeNode.cs │ ├── CoverageTreeControl.xaml │ ├── CoverageTreeControl.xaml.cs │ ├── CoverageTreeController.cs │ ├── CoverageTreeManager.cs │ ├── CoverageTreeToolWindow.cs │ ├── CoverageViewManager.cs │ ├── DoubleMultiplyConverter.cs │ ├── FileCoverageAggregator.cs │ ├── ICoverageViewManager.cs │ ├── Images │ │ ├── 48px-Gnome-application-x-executable.svg.png │ │ ├── 48px-Gnome-folder.svg.png │ │ └── 48px-Gnome-text-x-generic.svg.png │ ├── NullCollapsedConverter.cs │ ├── RootCoverageTreeNode.cs │ └── TreeNodeVisibilityManager.cs ├── DynamicVCCLCompilerTool.cs ├── DynamicVCConfiguration.cs ├── DynamicVCDebugSettings.cs ├── DynamicVCFile.cs ├── DynamicVCProject.cs ├── ErrorHandler.cs ├── ExtendedProject.cs ├── GlobalSuppressions.cs ├── Guids.cs ├── Helper │ ├── DataGridFileSystemSelectionColumn.cs │ ├── FileSystemSelectionControl.xaml │ ├── FileSystemSelectionControl.xaml.cs │ ├── ObservableItemCollection.cs │ ├── PathHelper.cs │ └── PropertyChangedNotifier.cs ├── IConfigurationManager.cs ├── IOpenCppCoverageCmdLine.cs ├── IWindowFinder.cs ├── Key.snk ├── OpenCppCoverage-x64 │ └── Plugins │ │ └── Exporter │ │ └── ForceFolderCreation.txt ├── OpenCppCoverage-x86 │ └── Plugins │ │ └── Exporter │ │ └── ForceFolderCreation.txt ├── OpenCppCoverageCmdLine.cs ├── OpenCppCoveragePackage.cs ├── OpenCppCoverageRunner.cs ├── OutputWindowWriter.cs ├── PackageInterfaces.cs ├── PkgCmdID.cs ├── ProjectBuilder.cs ├── Properties │ └── AssemblyInfo.cs ├── Resources.Designer.cs ├── Resources.resx ├── Resources │ ├── Images.png │ └── Package.ico ├── Settings │ ├── ISettingsStorage.cs │ ├── IStartUpProjectSettingsBuilder.cs │ ├── MainSettings.cs │ ├── MainWindowsManager.cs │ ├── SettingsStorage.cs │ ├── StartUpProjectSettings.cs │ ├── StartUpProjectSettingsBuilder.cs │ └── UI │ │ ├── BasicSettingControl.xaml │ │ ├── BasicSettingControl.xaml.cs │ │ ├── BasicSettingController.cs │ │ ├── BindableString.cs │ │ ├── FilterSettingControl.xaml │ │ ├── FilterSettingControl.xaml.cs │ │ ├── FilterSettingController.cs │ │ ├── ImportExportSettingControl.xaml │ │ ├── ImportExportSettingControl.xaml.cs │ │ ├── ImportExportSettingController.cs │ │ ├── MainSettingControl.xaml │ │ ├── MainSettingControl.xaml.cs │ │ ├── MainSettingController.cs │ │ ├── MiscellaneousSettingControl.xaml │ │ ├── MiscellaneousSettingControl.xaml.cs │ │ ├── MiscellaneousSettingController.cs │ │ ├── SettingToolWindow.cs │ │ └── UserInterfaceSettings.cs ├── Styles │ ├── AllStyles.xaml │ ├── ButtonStyle.xaml │ ├── ComboBoxItemStyle.xaml │ ├── ComboBoxStyle.xaml │ ├── TabItemStyle.xaml │ ├── VsBrushes.cs │ └── VsColors.cs ├── TemporaryFile.cs ├── Themes.xml ├── VSPackage.csproj ├── VSPackage.resx ├── VSPackage.vsct ├── VSPackageException.cs ├── VSPackageVS2013.csproj ├── gpl-3.0.txt ├── packages.config └── source.extension.vsixmanifest ├── VSPackage_IntegrationTests ├── CoverageTreeTests.cs ├── CoverageViewManagerTests.cs ├── DialogBoxMessageRetriever.cs ├── IntegrationTestsSolution │ ├── CSharpConsoleApplication │ │ ├── App.config │ │ ├── CSharpConsoleApplication.csproj │ │ ├── Program.cs │ │ └── Properties │ │ │ └── AssemblyInfo.cs │ ├── ConsoleApplicationInFolder │ │ ├── ConsoleApplicationInFolder.cpp │ │ └── ConsoleApplicationInFolder.vcxproj │ ├── CppConsoleApplication │ │ ├── CppConsoleApplication.cpp │ │ └── CppConsoleApplication.vcxproj │ ├── CppConsoleApplication2 │ │ ├── CppConsoleApplication2.cpp │ │ └── CppConsoleApplication2.vcxproj │ ├── CppConsoleApplicationDll │ │ ├── CppConsoleApplicationDll.cpp │ │ ├── CppConsoleApplicationDll.h │ │ ├── CppConsoleApplicationDll.vcxproj │ │ ├── stdafx.cpp │ │ └── stdafx.h │ ├── IntegrationTestsSolution.sln │ └── ZERO_CHECK │ │ └── ZERO_CHECK.vcxproj ├── Key.snk ├── MainSettingInitialValuesTests.cs ├── MainSettingTests.cs ├── RunCoverageTests.cs ├── SolutionConfigurationHelpers.cs ├── TestHelpers.cs ├── VSPackage_IntegrationTests.csproj ├── VSPackage_IntegrationTestsVS2013.csproj └── packages.config └── VSPackage_UnitTests ├── BasicCoverageTreeNodeTests.cs ├── BindableValue.cs ├── CommandLineBuilderTests.cs ├── CoverageDataDeserializerTests.cs ├── CoverageRateBuilderTests.cs ├── CoverageTreeControllerTests.cs ├── DataGridFileSystemSelectionColumnTests.cs ├── FileCoverageAggregatorTests.cs ├── Key.snk ├── MainSettingControllerTests.cs ├── ObservableItemCollectionTests.cs ├── OpenCppCoverageCmdLineTests.cs ├── PathHelperTests.cs ├── Program.cs ├── PropertyHelper.cs ├── RootCoverageTreeNodeTests.cs ├── Settings ├── SettingsStorageTests.cs └── UI │ └── BasicSettingControllerTests.cs ├── TemporayPath.cs ├── TestHelper.cs ├── TreeNodeVisibilityManagerTests.cs ├── VSPackage_UnitTests.csproj ├── VSPackage_UnitTestsVS2013.csproj └── packages.config /.github/workflows/continuous-integration-workflow.yml: -------------------------------------------------------------------------------- 1 | name: Unit tests 2 | on: [push] 3 | 4 | jobs: 5 | build: 6 | name: Unit tests 7 | runs-on: windows-latest 8 | steps: 9 | - name: Checkout 10 | uses: actions/checkout@v2 11 | 12 | - name: Setup Nuget 13 | uses: nuget/setup-nuget@v1 14 | 15 | - name: Nuget restore packages 16 | run: nuget restore CppCoveragePlugin.sln 17 | 18 | - name: Download OpenCppCoverage x64 19 | run: Invoke-WebRequest -OutFile OpenCppCoverageSetup-x64-0.9.8.0.exe https://github.com/OpenCppCoverage/OpenCppCoverage/releases/download/release-0.9.8.0/OpenCppCoverageSetup-x64-0.9.8.0.exe 20 | 21 | - name: Install OpenCppCoverage x64 22 | run: ./OpenCppCoverageSetup-x64-0.9.8.0.exe /VERYSILENT /SUPPRESSMSGBOXES /DIR=VSPackage\OpenCppCoverage-x64 23 | 24 | - name: Download OpenCppCoverage x86 25 | run: Invoke-WebRequest -OutFile OpenCppCoverageSetup-x86-0.9.8.0.exe https://github.com/OpenCppCoverage/OpenCppCoverage/releases/download/release-0.9.8.0/OpenCppCoverageSetup-x86-0.9.8.0.exe 26 | 27 | - name: Install OpenCppCoverage x86 28 | run: ./OpenCppCoverageSetup-x86-0.9.8.0.exe /VERYSILENT /SUPPRESSMSGBOXES /DIR=VSPackage\OpenCppCoverage-x86 29 | 30 | - name: Setup MSBuild 31 | uses: microsoft/setup-msbuild@v1.0.0 32 | 33 | - name: Copy extra files 34 | run: | 35 | cp .\packages\Newtonsoft.Json.*\lib\net45\Newtonsoft.Json.dll VSPackage 36 | cp C:\Windows\System32\msvcp140.dll VSPackage\OpenCppCoverage-x64 37 | cp C:\Windows\System32\vcruntime140.dll VSPackage\OpenCppCoverage-x64 38 | cp C:\Windows\SysWOW64\msvcp140.dll VSPackage\OpenCppCoverage-x86 39 | cp C:\Windows\SysWOW64\vcruntime140.dll VSPackage\OpenCppCoverage-x86 40 | 41 | - name: Build VSPackage 42 | run: msbuild CppCoveragePlugin.sln /target:VSPackage /p:Platform="Any CPU" 43 | 44 | - name: Build VSPackage_UnitTests 45 | run: msbuild CppCoveragePlugin.sln /target:VSPackage_UnitTests /p:Platform="Any CPU" 46 | 47 | - name: Setup VSTest 48 | uses: darenm/Setup-VSTest@v1 49 | 50 | - name: Run unit tests 51 | run: VSTest.Console.exe VSPackage_UnitTests\\bin\\Debug\\VSPackage_UnitTests.exe -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | packages/ 2 | TestResults/ 3 | */bin 4 | */obj 5 | **/Debug/ 6 | .vs/ 7 | *.user 8 | *.sdf 9 | *.db 10 | *.ipch 11 | LastCoverageResults.log 12 | 13 | # Template files / OpenCppCoverage binaries 14 | VSPackage/OpenCppCoverage-x64/* 15 | !VSPackage/OpenCppCoverage-x64/Plugins 16 | 17 | VSPackage/OpenCppCoverage-x86/* 18 | !VSPackage/OpenCppCoverage-x86/Plugins 19 | 20 | # ProtBuff file 21 | VSPackage/CoverageData/CoverageData.cs 22 | 23 | # Generated files 24 | Themes.pkgdef 25 | 26 | # Open Cover / ReportGenerator files 27 | CoverageReport/ 28 | OpenCover.xml 29 | 30 | # Ignore the assembly included by source.extension.vsixmanifest 31 | Newtonsoft.Json.dll -------------------------------------------------------------------------------- /Changelog.txt: -------------------------------------------------------------------------------- 1 | Version 0.9.7.1 2 | - Fix `System.ArgumentNullException` when using GIT-compare: https://github.com/OpenCppCoverage/OpenCppCoveragePlugin/issues/33 3 | - Fix `The filename or extension is too long` when running OpenCppCoveragePlugin on a lot of projects: https://github.com/OpenCppCoverage/OpenCppCoverage/issues/103 4 | 5 | Version 0.9.7.0 6 | - All settings are saved by project. 7 | - There are two commands: 8 | - OpenCppCoverage Settings (Ctrl+R, Ctrl+S): Open the OpenCppCoverage settings window. 9 | - Run OpenCppCoverage (Ctrl+R, Ctrl+C): Run OpenCppCoverage without opening the settings window and without displaying the program output. 10 | - Update OpenCppCoverage to the version 0.9.8.0. 11 | - Fix an issue when the plugin R Tools is installed: https://github.com/OpenCppCoverage/OpenCppCoveragePlugin/issues/18 12 | - Fix "Reset" button when opening the settings window from the project contextual menu. 13 | 14 | Version 0.9.6.1 15 | - Remove the reference to PresentationFramework.Aero2 (Not available on Windows 7). 16 | 17 | Version 0.9.6.0 18 | - Update OpenCppCoverage 0.9.6.1 to 0.9.7.0. 19 | - Use theme colors (https://github.com/OpenCppCoverage/OpenCppCoveragePlugin/issues/16). 20 | - Move "Run OpenCppCoverage" button down in project menu (https://github.com/OpenCppCoverage/OpenCppCoveragePlugin/issues/15). 21 | - Always use OpenCppCoverage 64 bits on Windows 64 bits (https://github.com/OpenCppCoverage/OpenCppCoverage/issues/55). 22 | 23 | Version 0.9.4.2 24 | - Add a button to select and deselect all projects (https://github.com/OpenCppCoverage/OpenCppCoveragePlugin/pull/9) 25 | - Add better colors for different themes for covered and not covered lines (https://github.com/OpenCppCoverage/OpenCppCoveragePlugin/pull/10) 26 | - Fix an issue when defining an environment variable in Visual Studio that alreay exists in the system environment. 27 | 28 | Version 0.9.4.1 29 | - Coverage can be directly run from project contextual menu in the window Solution Explorer 30 | - Fix the issue Cannot find tool: VCCLCompilerTool for projects generated by CMake 31 | - Fix a random issue in Visual Studio 2017. Run Coverage button builds the project but not always run the code coverage 32 | -------------------------------------------------------------------------------- /CppCoveragePlugin.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.29009.5 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{2D036BFA-5FAC-467B-9648-5B2BBC5B872C}" 7 | ProjectSection(SolutionItems) = preProject 8 | IntegrationTests.testsettings = IntegrationTests.testsettings 9 | UnitTests.testsettings = UnitTests.testsettings 10 | EndProjectSection 11 | EndProject 12 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VSPackage", "VSPackage\VSPackage.csproj", "{DF742CAB-0446-4867-A437-719390CC028A}" 13 | EndProject 14 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VSPackage_IntegrationTests", "VSPackage_IntegrationTests\VSPackage_IntegrationTests.csproj", "{7670EBBB-F516-4180-8E72-4933763D5C74}" 15 | EndProject 16 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VSPackage_UnitTests", "VSPackage_UnitTests\VSPackage_UnitTests.csproj", "{A900757D-A179-4D53-B1E9-76E880E89131}" 17 | EndProject 18 | Global 19 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 20 | Debug|Any CPU = Debug|Any CPU 21 | Release|Any CPU = Release|Any CPU 22 | EndGlobalSection 23 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 24 | {DF742CAB-0446-4867-A437-719390CC028A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 25 | {DF742CAB-0446-4867-A437-719390CC028A}.Debug|Any CPU.Build.0 = Debug|Any CPU 26 | {DF742CAB-0446-4867-A437-719390CC028A}.Release|Any CPU.ActiveCfg = Release|Any CPU 27 | {DF742CAB-0446-4867-A437-719390CC028A}.Release|Any CPU.Build.0 = Release|Any CPU 28 | {7670EBBB-F516-4180-8E72-4933763D5C74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 29 | {7670EBBB-F516-4180-8E72-4933763D5C74}.Debug|Any CPU.Build.0 = Debug|Any CPU 30 | {7670EBBB-F516-4180-8E72-4933763D5C74}.Release|Any CPU.ActiveCfg = Release|Any CPU 31 | {7670EBBB-F516-4180-8E72-4933763D5C74}.Release|Any CPU.Build.0 = Release|Any CPU 32 | {A900757D-A179-4D53-B1E9-76E880E89131}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 33 | {A900757D-A179-4D53-B1E9-76E880E89131}.Debug|Any CPU.Build.0 = Debug|Any CPU 34 | {A900757D-A179-4D53-B1E9-76E880E89131}.Release|Any CPU.ActiveCfg = Release|Any CPU 35 | {A900757D-A179-4D53-B1E9-76E880E89131}.Release|Any CPU.Build.0 = Release|Any CPU 36 | EndGlobalSection 37 | GlobalSection(SolutionProperties) = preSolution 38 | HideSolutionNode = FALSE 39 | EndGlobalSection 40 | EndGlobal 41 | -------------------------------------------------------------------------------- /CppCoveragePluginVS2013.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.24720.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{2D036BFA-5FAC-467B-9648-5B2BBC5B872C}" 7 | ProjectSection(SolutionItems) = preProject 8 | IntegrationTestsVS2013.testsettings = IntegrationTestsVS2013.testsettings 9 | UnitTests.testsettings = UnitTests.testsettings 10 | EndProjectSection 11 | EndProject 12 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VSPackage", "VSPackage\VSPackageVS2013.csproj", "{DF742CAB-0446-4867-A437-719390CC028A}" 13 | EndProject 14 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VSPackage_IntegrationTests", "VSPackage_IntegrationTests\VSPackage_IntegrationTestsVS2013.csproj", "{7670EBBB-F516-4180-8E72-4933763D5C74}" 15 | EndProject 16 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VSPackage_UnitTests", "VSPackage_UnitTests\VSPackage_UnitTestsVS2013.csproj", "{A900757D-A179-4D53-B1E9-76E880E89131}" 17 | EndProject 18 | Global 19 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 20 | Debug|Any CPU = Debug|Any CPU 21 | Release|Any CPU = Release|Any CPU 22 | EndGlobalSection 23 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 24 | {DF742CAB-0446-4867-A437-719390CC028A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 25 | {DF742CAB-0446-4867-A437-719390CC028A}.Debug|Any CPU.Build.0 = Debug|Any CPU 26 | {DF742CAB-0446-4867-A437-719390CC028A}.Release|Any CPU.ActiveCfg = Release|Any CPU 27 | {DF742CAB-0446-4867-A437-719390CC028A}.Release|Any CPU.Build.0 = Release|Any CPU 28 | {7670EBBB-F516-4180-8E72-4933763D5C74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 29 | {7670EBBB-F516-4180-8E72-4933763D5C74}.Debug|Any CPU.Build.0 = Debug|Any CPU 30 | {7670EBBB-F516-4180-8E72-4933763D5C74}.Release|Any CPU.ActiveCfg = Release|Any CPU 31 | {7670EBBB-F516-4180-8E72-4933763D5C74}.Release|Any CPU.Build.0 = Release|Any CPU 32 | {A900757D-A179-4D53-B1E9-76E880E89131}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 33 | {A900757D-A179-4D53-B1E9-76E880E89131}.Debug|Any CPU.Build.0 = Debug|Any CPU 34 | {A900757D-A179-4D53-B1E9-76E880E89131}.Release|Any CPU.ActiveCfg = Release|Any CPU 35 | {A900757D-A179-4D53-B1E9-76E880E89131}.Release|Any CPU.Build.0 = Release|Any CPU 36 | EndGlobalSection 37 | GlobalSection(SolutionProperties) = preSolution 38 | HideSolutionNode = FALSE 39 | EndGlobalSection 40 | EndGlobal 41 | -------------------------------------------------------------------------------- /Externals/ICSharpCode.TreeView.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenCppCoverage/OpenCppCoveragePlugin/6e39733d1e8643c99c2174d2334628fca1d0561e/Externals/ICSharpCode.TreeView.dll -------------------------------------------------------------------------------- /IntegrationTests.testsettings: -------------------------------------------------------------------------------- 1 |  2 | 3 | This test run configuration uses the VS IDE host type in the test run. 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /IntegrationTestsVS2013.testsettings: -------------------------------------------------------------------------------- 1 |  2 | 3 | This test run configuration uses the VS IDE host type in the test run. 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![](https://github.com/OpenCppCoverage/OpenCppCoveragePlugin/workflows/Unit%20tests/badge.svg) 2 | # OpenCppCoveragePlugin 3 | Official Visual Studio Plugin for OpenCppCoverage 4 | 5 | **OpenCppCoverage** is an open source code coverage tool for C++ under Windows. You can find more information about this project [here](https://opencppcoverage.codeplex.com/). 6 | 7 | This repository contains only the Visual Studio plugin sources. 8 | 9 | ## Usage 10 | 11 | To install and use this plugin, please see the [Visual Studio Gallery page](https://visualstudiogallery.msdn.microsoft.com/f45b8e13-f847-4b3b-92df-984df633b60e). 12 | You can also install the NuGet package **OpenCppCoverage Plugin**. 13 | 14 | **Documentation is available [here](https://github.com/OpenCppCoverage/OpenCppCoveragePlugin/wiki)**. 15 | 16 | For questions, you can create a discussion [here](https://opencppcoverage.codeplex.com/discussions). 17 | If you find a bug, you can create an issue [here](https://opencppcoverage.codeplex.com/workitem/list/basic). 18 | 19 | ## Development 20 | 21 | ### Compilation 22 | You have 2 Visual Studio solution files but **Visual Studio 2017 is always required**. 23 | Please also make sure you have Visual Studio 2017 **version 15.8.X**. 24 | 25 | #### CppCoveragePlugin.sln 26 | This is the default solution file and it requires only Visual Studio 2017. 27 | 28 | #### CppCoveragePluginVS2013.sln 29 | **This is a Visual Studio 2017 solution file** but it also requires: 30 | * Visual Studio 2013 Update 5. 31 | * [Microsoft Visual Studio 2013 SDK](https://visualstudiogallery.msdn.microsoft.com/842766ba-1f32-40cf-8617-39365ebfc134/view/). If you have any trouble to install the SDK, [this stack overflow question](https://stackoverflow.com/questions/22949411/visual-studio-2012-install-fails-program-compatibility-mode-is-on/23114542) can help. 32 | * Visual Studio 2015 Update 3 may be required. 33 | 34 | This solution should be used only to generate a plugin compatible with Visual Studio 2013, 2015 and 2017. 35 | 36 | #### OpenCppCoverage 37 | You should install the latest version of [OpenCppCoverage](https://github.com/OpenCppCoverage/OpenCppCoverage/releases/tag/release-0.9.7.0): 38 | * *OpenCppCoverageSetup-x64-X.X.X.exe*: into *VSPackage\OpenCppCoverage-x64* 39 | * *OpenCppCoverageSetup-x86-X.X.X.exe*: into *VSPackage\OpenCppCoverage-x86* 40 | 41 | You can also copy past the binaries from an existing installation into these folders. 42 | Binaries inside *VSPackage\OpenCppCoverage-x86* can be the same as *VSPackage\OpenCppCoverage-x64* (The opposite is not true). 43 | 44 | ### Run the plugin 45 | 46 | * Set *VSPackage* as *StartUp Project*. 47 | * In *VSPackage Properties*, tab *Debug*: 48 | * Select *Start external program* and set value to `C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\devenv.exe` (Update this path if you installed Visual Studio to another location). 49 | * Add `/RootSuffix Exp` as *Command line arguments*. 50 | 51 | If you have an issue when running the plugin, you can try to reset Visual Studio Experimental instance: 52 | 53 | `"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VSSDK\VisualStudioIntegration\Tools\Bin\CreateExpInstance.exe" /Reset /VSInstance=15.0 /RootSuffix=Exp` 54 | 55 | ### Run unit tests 56 | 57 | You can run the tests with *Test Explorer window*. 58 | To run *VSPackage_IntegrationTests* you need to expand *Solution items* in *Solution Explorer* and set *Active Load and Web Test Settings* for *IntegrationTests.testsettings*. If you have a COM error when running tests, you can select *IntegrationTests.testsettings* file from Visual Studio menu: Test/Test Settings/Select Test Settings File. 59 | For *VSPackage_UnitTests* you need to do the same but with *UnitTests.testsettings*. 60 | 61 | If a test failed, you can try to run it again. You can also reset Visual Studio Experimental instance. 62 | -------------------------------------------------------------------------------- /RunOpenCover.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | SET OPEN_COVER="%~dp0\packages\OpenCover.4.7.922\tools\OpenCover.Console.exe" 3 | SET VSTEST_CONSOLE="%ProgramFiles(x86)%\Microsoft Visual Studio\2019\Community\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe" 4 | SET UNIT_TEST="%~dp0\VSPackage_UnitTests\bin\Debug\VSPackage_UnitTests.exe" 5 | SET REPORT_GENERATOR="%~dp0\packages\ReportGenerator.4.3.2\tools\net47\ReportGenerator.exe" 6 | SET OUTPUT="OpenCover.xml" 7 | 8 | %OPEN_COVER% -target:%VSTEST_CONSOLE% -targetargs:%UNIT_TEST% -filter:"+[*]* -[GalaSoft*]*" -register:user -output:%OUTPUT% 9 | %REPORT_GENERATOR% "-reports:%OUTPUT%" "-targetdir:CoverageReport" -------------------------------------------------------------------------------- /UnitTests.testsettings: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | This test run configuration is used for running the unit tests 9 | 10 | -------------------------------------------------------------------------------- /VSPackage/CommandLineBuilder.cs: -------------------------------------------------------------------------------- 1 | // OpenCppCoverage is an open source code coverage for C++. 2 | // Copyright (C) 2016 OpenCppCoverage 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | 17 | using System; 18 | using System.Collections.Generic; 19 | using System.Text; 20 | 21 | namespace OpenCppCoverage.VSPackage 22 | { 23 | class CommandLineBuilder 24 | { 25 | readonly List commandLines = new List(); 26 | 27 | //--------------------------------------------------------------------- 28 | public string GetCommandLine(string separator = " ") 29 | { 30 | return String.Join(separator, this.commandLines); 31 | } 32 | 33 | //--------------------------------------------------------------------- 34 | public CommandLineBuilder AppendArgument( 35 | string argumentName, 36 | string optionalArgumentValue) 37 | { 38 | var line = argumentName; 39 | if (optionalArgumentValue != null) 40 | line += ' ' + EscapeValue(optionalArgumentValue); 41 | commandLines.Add(line); 42 | return this; 43 | } 44 | 45 | //--------------------------------------------------------------------- 46 | public CommandLineBuilder Append(string str) 47 | { 48 | commandLines.Add(str); 49 | return this; 50 | } 51 | 52 | //--------------------------------------------------------------------- 53 | public static string EscapeValue(string str) 54 | { 55 | var builder = new StringBuilder(); 56 | int consecutiveBackSlashCount = 0; 57 | 58 | builder.Append('\"'); 59 | foreach (var c in str) 60 | { 61 | if (c != '\"') 62 | builder.Append(c); 63 | else 64 | { 65 | // Back slash before quote need to be escaped 66 | // so add the same number of back slash. 67 | builder.Append('\\', consecutiveBackSlashCount); 68 | 69 | // Quote need to be escaped too. 70 | builder.Append(@"\"""); 71 | } 72 | consecutiveBackSlashCount = (c == '\\') ? consecutiveBackSlashCount + 1 : 0; 73 | } 74 | 75 | // We need to escape last slash because we add '"' just after 76 | builder.Append('\\', consecutiveBackSlashCount); 77 | builder.Append('\"'); 78 | 79 | return builder.ToString(); 80 | } 81 | } 82 | } -------------------------------------------------------------------------------- /VSPackage/CoverageData/CoverageData.proto: -------------------------------------------------------------------------------- 1 | package ProtoBuff; 2 | 3 | message LineCoverage 4 | { 5 | required uint32 lineNumber = 1; 6 | required bool hasBeenExecuted = 2; 7 | } 8 | 9 | message FileCoverage 10 | { 11 | required string path = 1; 12 | repeated LineCoverage lines = 2; 13 | } 14 | 15 | message ModuleCoverage 16 | { 17 | required string path = 1; 18 | repeated FileCoverage files = 2; 19 | } 20 | 21 | message CoverageData 22 | { 23 | required string name = 1; 24 | required int32 exitCode = 2; 25 | required uint64 moduleCount = 3; 26 | } -------------------------------------------------------------------------------- /VSPackage/CoverageData/CoverageDataDeserializer.cs: -------------------------------------------------------------------------------- 1 | // OpenCppCoverage is an open source code coverage for C++. 2 | // Copyright (C) 2014 OpenCppCoverage 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | 17 | using Google.ProtocolBuffers; 18 | using System; 19 | using System.Collections.Generic; 20 | using System.IO; 21 | 22 | namespace OpenCppCoverage.VSPackage.CoverageData 23 | { 24 | class CoverageDataDeserializer 25 | { 26 | public static uint FileTypeId = 1351727964; 27 | 28 | //--------------------------------------------------------------------- 29 | public CoverageResult Deserialize(Stream stream) 30 | { 31 | var codedInputStream = CodedInputStream.CreateInstance(stream); 32 | 33 | uint fileTypeId = 0; 34 | if (!codedInputStream.ReadUInt32(ref fileTypeId) || fileTypeId != FileTypeId) 35 | throw new Exception("Binary format is not valid."); 36 | 37 | var coverageData = ReadMessage(codedInputStream, ProtoBuff.CoverageData.ParseFrom); 38 | 39 | var modules = new List(); 40 | for (ulong i = 0; i < coverageData.ModuleCount; ++i) 41 | modules.Add(ReadMessage(codedInputStream, ProtoBuff.ModuleCoverage.ParseFrom)); 42 | 43 | return new CoverageResult(coverageData, modules); 44 | } 45 | 46 | //--------------------------------------------------------------------- 47 | static T ReadMessage(CodedInputStream input, Func parseFrom) 48 | { 49 | uint size = 0; 50 | 51 | if (!input.ReadUInt32(ref size)) 52 | throw new Exception("Cannot read message size."); 53 | 54 | var data = input.ReadRawBytes((int)size); 55 | return parseFrom(data); 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /VSPackage/CoverageData/CoverageResult.cs: -------------------------------------------------------------------------------- 1 | // OpenCppCoverage is an open source code coverage for C++. 2 | // Copyright (C) 2014 OpenCppCoverage 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | 17 | using System.Collections.Generic; 18 | 19 | namespace OpenCppCoverage.VSPackage.CoverageData 20 | { 21 | class CoverageResult 22 | { 23 | public CoverageResult( 24 | ProtoBuff.CoverageData coverageData, 25 | IEnumerable modules) 26 | { 27 | this.CoverageData = coverageData; 28 | this.Modules = modules; 29 | } 30 | 31 | public ProtoBuff.CoverageData CoverageData { get; } 32 | public IEnumerable Modules { get; } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /VSPackage/CoverageRateBuilder/CoverageRate.cs: -------------------------------------------------------------------------------- 1 | // OpenCppCoverage is an open source code coverage for C++. 2 | // Copyright (C) 2014 OpenCppCoverage 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | 17 | using System.Collections.Generic; 18 | using System.Linq; 19 | 20 | namespace OpenCppCoverage.VSPackage.CoverageRateBuilder 21 | { 22 | //------------------------------------------------------------------------- 23 | public class BaseCoverage 24 | { 25 | protected BaseCoverage() {} 26 | public int CoverLineCount { get; protected set; } 27 | public int TotalLineCount { get; protected set; } 28 | } 29 | 30 | //------------------------------------------------------------------------- 31 | public class HierarchicalCoverage : BaseCoverage where T : BaseCoverage 32 | { 33 | readonly List children; 34 | 35 | //--------------------------------------------------------------------- 36 | public HierarchicalCoverage(string name) 37 | { 38 | this.Name = name; 39 | this.children = new List(); 40 | } 41 | 42 | //--------------------------------------------------------------------- 43 | public string Name { get; } 44 | 45 | //--------------------------------------------------------------------- 46 | public IEnumerable Children 47 | { 48 | get 49 | { 50 | return this.children; 51 | } 52 | } 53 | 54 | //--------------------------------------------------------------------- 55 | public void AddChild(T child) 56 | { 57 | this.children.Add(child); 58 | this.CoverLineCount += child.CoverLineCount; 59 | this.TotalLineCount += child.TotalLineCount; 60 | } 61 | } 62 | 63 | //------------------------------------------------------------------------- 64 | public class LineCoverage 65 | { 66 | public LineCoverage(int lineNumber, bool hasBeenExecuted) 67 | { 68 | this.LineNumber = lineNumber; 69 | this.HasBeenExecuted = hasBeenExecuted; 70 | } 71 | 72 | public int LineNumber { get; } 73 | public bool HasBeenExecuted { get; } 74 | } 75 | 76 | //------------------------------------------------------------------------- 77 | public class FileCoverage : BaseCoverage 78 | { 79 | //--------------------------------------------------------------------- 80 | public FileCoverage(string path, List lineCoverages ) 81 | { 82 | this.CoverLineCount = lineCoverages.Where(l => l.HasBeenExecuted).Count(); 83 | this.TotalLineCount = lineCoverages.Count; 84 | this.Path = path; 85 | this.LineCoverages = lineCoverages; 86 | } 87 | 88 | //--------------------------------------------------------------------- 89 | public string Path { get; } 90 | 91 | //--------------------------------------------------------------------- 92 | public IEnumerable LineCoverages { get; } 93 | } 94 | 95 | //------------------------------------------------------------------------- 96 | public class ModuleCoverage : HierarchicalCoverage 97 | { 98 | public ModuleCoverage(string name) : base(name) { } 99 | } 100 | 101 | //------------------------------------------------------------------------- 102 | public class CoverageRate : HierarchicalCoverage 103 | { 104 | public CoverageRate(string name, int exitCode) 105 | : base(name) 106 | { 107 | this.ExitCode = exitCode; 108 | } 109 | 110 | //--------------------------------------------------------------------- 111 | public int ExitCode { get; } 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /VSPackage/CoverageRateBuilder/CoverageRateBuilder.cs: -------------------------------------------------------------------------------- 1 | // OpenCppCoverage is an open source code coverage for C++. 2 | // Copyright (C) 2014 OpenCppCoverage 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | 17 | using OpenCppCoverage.VSPackage.CoverageData; 18 | using System.Linq; 19 | 20 | using ProtoBuff = global::OpenCppCoverage.VSPackage.CoverageData.ProtoBuff; 21 | 22 | namespace OpenCppCoverage.VSPackage.CoverageRateBuilder 23 | { 24 | //-------------------------------------------------------------------------- 25 | class CoverageRateBuilder 26 | { 27 | //--------------------------------------------------------------------- 28 | public CoverageRate Build(CoverageResult result) 29 | { 30 | var protoBuffCoverageData = result.CoverageData; 31 | var coverageRate = new CoverageRate( 32 | protoBuffCoverageData.Name, 33 | protoBuffCoverageData.ExitCode); 34 | foreach (var protoModule in result.Modules) 35 | { 36 | var module = new ModuleCoverage(protoModule.Path); 37 | foreach (var protoFile in protoModule.FilesList) 38 | module.AddChild(BuildFileCoverage(protoFile)); 39 | coverageRate.AddChild(module); 40 | } 41 | 42 | return coverageRate; 43 | } 44 | 45 | //--------------------------------------------------------------------- 46 | FileCoverage BuildFileCoverage(ProtoBuff.FileCoverage protoFile) 47 | { 48 | var lines = protoFile.LinesList; 49 | 50 | return new FileCoverage( 51 | protoFile.Path, 52 | lines.Select(l => new LineCoverage( 53 | (int)l.LineNumber, l.HasBeenExecuted)).ToList()); 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /VSPackage/CoverageTree/CoverageTreeControl.xaml.cs: -------------------------------------------------------------------------------- 1 | // OpenCppCoverage is an open source code coverage for C++. 2 | // Copyright (C) 2016 OpenCppCoverage 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | 17 | using System.Windows.Controls; 18 | 19 | namespace OpenCppCoverage.VSPackage.CoverageTree 20 | { 21 | /// 22 | /// Interaction logic for CoverageTreeControl.xaml 23 | /// 24 | public partial class CoverageTreeControl : UserControl 25 | { 26 | public CoverageTreeControl() 27 | { 28 | InitializeComponent(); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /VSPackage/CoverageTree/CoverageTreeManager.cs: -------------------------------------------------------------------------------- 1 | // OpenCppCoverage is an open source code coverage for C++. 2 | // Copyright (C) 2016 OpenCppCoverage 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | 17 | using EnvDTE80; 18 | using Microsoft.VisualStudio.Shell; 19 | using Microsoft.VisualStudio.Shell.Interop; 20 | using OpenCppCoverage.VSPackage.CoverageRateBuilder; 21 | using System; 22 | 23 | namespace OpenCppCoverage.VSPackage.CoverageTree 24 | { 25 | class CoverageTreeManager 26 | { 27 | readonly IWindowFinder windowFinder; 28 | //--------------------------------------------------------------------- 29 | public CoverageTreeManager(IWindowFinder windowFinder) 30 | { 31 | this.windowFinder = windowFinder; 32 | } 33 | 34 | //--------------------------------------------------------------------- 35 | public void ShowTreeCoverage( 36 | DTE2 dte, 37 | ICoverageViewManager coverageViewManager, 38 | CoverageRate coverageRate) 39 | { 40 | ShowTreeCoverage(window => window.Controller.UpdateCoverageRate( 41 | coverageRate, dte, coverageViewManager)); 42 | } 43 | 44 | //--------------------------------------------------------------------- 45 | public void ShowTreeCoverage() 46 | { 47 | ShowTreeCoverage(windows => {}); 48 | } 49 | 50 | //--------------------------------------------------------------------- 51 | void ShowTreeCoverage(Action action) 52 | { 53 | var window = this.windowFinder.FindToolWindow(); 54 | 55 | action(window); 56 | var frame = (IVsWindowFrame)window.Frame; 57 | Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(frame.Show()); 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /VSPackage/CoverageTree/CoverageTreeToolWindow.cs: -------------------------------------------------------------------------------- 1 | // OpenCppCoverage is an open source code coverage for C++. 2 | // Copyright (C) 2014 OpenCppCoverage 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | 17 | using Microsoft.VisualStudio.Shell; 18 | using Microsoft.VisualStudio.Shell.Interop; 19 | using System; 20 | using System.Runtime.InteropServices; 21 | 22 | namespace OpenCppCoverage.VSPackage.CoverageTree 23 | { 24 | [Guid("2731AD3B-8E0A-46D2-B8F6-CA40C387732F")] 25 | class CoverageTreeToolWindow : ToolWindowPane, IVsExtensibleObject 26 | { 27 | //--------------------------------------------------------------------- 28 | public CoverageTreeToolWindow() : base(null) 29 | { 30 | this.Caption = "Coverage"; 31 | 32 | // This is the user control hosted by the tool window; 33 | // Note that, even if this class implements IDisposable, 34 | // we are not calling Dispose on this object. 35 | // This is because ToolWindowPane calls Dispose on 36 | // the object returned by the Content property. 37 | var coverageTreeControl = new CoverageTreeControl(); 38 | 39 | this.Controller = new CoverageTreeController(); 40 | coverageTreeControl.DataContext = this.Controller; 41 | this.Content = coverageTreeControl; 42 | } 43 | 44 | //--------------------------------------------------------------------- 45 | public CoverageTreeController Controller { get; } 46 | 47 | //--------------------------------------------------------------------- 48 | public int GetAutomationObject(string pszPropName, out object ppDisp) 49 | { 50 | ppDisp = this.Controller; 51 | return Microsoft.VisualStudio.VSConstants.S_OK; 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /VSPackage/CoverageTree/DoubleMultiplyConverter.cs: -------------------------------------------------------------------------------- 1 | // OpenCppCoverage is an open source code coverage for C++. 2 | // Copyright (C) 2014 OpenCppCoverage 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | 17 | using System; 18 | using System.Globalization; 19 | using System.Windows.Data; 20 | 21 | namespace OpenCppCoverage.VSPackage.CoverageTree 22 | { 23 | class DoubleMultiplyConverter : IValueConverter 24 | { 25 | //----------------------------------------------------------------------- 26 | public object Convert( 27 | object value, Type targetType, object parameter, CultureInfo culture) 28 | { 29 | if (value == null) 30 | return 0.0; 31 | return (double)value * System.Convert.ToDouble(parameter); 32 | } 33 | 34 | //----------------------------------------------------------------------- 35 | public object ConvertBack( 36 | object value, Type targetType, object parameter, CultureInfo culture) 37 | { 38 | throw new InvalidOperationException(); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /VSPackage/CoverageTree/FileCoverageAggregator.cs: -------------------------------------------------------------------------------- 1 | // OpenCppCoverage is an open source code coverage for C++. 2 | // Copyright (C) 2016 OpenCppCoverage 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | 17 | using OpenCppCoverage.VSPackage.CoverageRateBuilder; 18 | using System; 19 | using System.Collections.Generic; 20 | using System.Linq; 21 | 22 | namespace OpenCppCoverage.VSPackage.CoverageTree 23 | { 24 | class FileCoverageAggregator 25 | { 26 | //--------------------------------------------------------------------- 27 | public Dictionary Aggregate( 28 | CoverageRate coverageRate, 29 | Func normalizePath) 30 | { 31 | var fileCoverages = coverageRate.Children.SelectMany(module => module.Children); 32 | 33 | return CreateDictionary( 34 | fileCoverages, 35 | fileCoverage => normalizePath(fileCoverage.Path), 36 | MergeFileCoverage); 37 | } 38 | 39 | //--------------------------------------------------------------------- 40 | FileCoverage MergeFileCoverage( 41 | FileCoverage fileCoverage, 42 | FileCoverage fileCoverage2) 43 | { 44 | var lineCoverages = fileCoverage.LineCoverages 45 | .Concat(fileCoverage2.LineCoverages); 46 | 47 | var lineCoverageByLine = CreateDictionary( 48 | lineCoverages, 49 | lineCoverage => lineCoverage.LineNumber, 50 | MergeLineCoverage); 51 | var mergedLineCoverages = lineCoverageByLine.Select(kvp => kvp.Value).ToList(); 52 | 53 | return new FileCoverage(fileCoverage.Path, mergedLineCoverages); 54 | } 55 | 56 | //--------------------------------------------------------------------- 57 | LineCoverage MergeLineCoverage( 58 | LineCoverage lineCoverage, 59 | LineCoverage lineCoverage2) 60 | { 61 | if (lineCoverage.LineNumber != lineCoverage2.LineNumber) 62 | throw new InvalidOperationException("Line numbers are not the same."); 63 | return new LineCoverage( 64 | lineCoverage.LineNumber, 65 | lineCoverage.HasBeenExecuted || lineCoverage2.HasBeenExecuted); 66 | } 67 | 68 | //--------------------------------------------------------------------- 69 | Dictionary CreateDictionary( 70 | IEnumerable collection, 71 | Func getKey, 72 | Func merge) 73 | { 74 | var dictionary = new Dictionary(); 75 | 76 | foreach (var value in collection) 77 | { 78 | var key = getKey(value); 79 | Value existingValue; 80 | if (dictionary.TryGetValue(key, out existingValue)) 81 | dictionary[key] = merge(existingValue, value); 82 | else 83 | dictionary.Add(key, value); 84 | } 85 | 86 | return dictionary; 87 | } 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /VSPackage/CoverageTree/ICoverageViewManager.cs: -------------------------------------------------------------------------------- 1 | // OpenCppCoverage is an open source code coverage for C++. 2 | // Copyright (C) 2016 OpenCppCoverage 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | 17 | using OpenCppCoverage.VSPackage.CoverageRateBuilder; 18 | 19 | namespace OpenCppCoverage.VSPackage.CoverageTree 20 | { 21 | public interface ICoverageViewManager 22 | { 23 | CoverageRate CoverageRate { set; } 24 | bool ShowCoverage { set; } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /VSPackage/CoverageTree/Images/48px-Gnome-application-x-executable.svg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenCppCoverage/OpenCppCoveragePlugin/6e39733d1e8643c99c2174d2334628fca1d0561e/VSPackage/CoverageTree/Images/48px-Gnome-application-x-executable.svg.png -------------------------------------------------------------------------------- /VSPackage/CoverageTree/Images/48px-Gnome-folder.svg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenCppCoverage/OpenCppCoveragePlugin/6e39733d1e8643c99c2174d2334628fca1d0561e/VSPackage/CoverageTree/Images/48px-Gnome-folder.svg.png -------------------------------------------------------------------------------- /VSPackage/CoverageTree/Images/48px-Gnome-text-x-generic.svg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenCppCoverage/OpenCppCoveragePlugin/6e39733d1e8643c99c2174d2334628fca1d0561e/VSPackage/CoverageTree/Images/48px-Gnome-text-x-generic.svg.png -------------------------------------------------------------------------------- /VSPackage/CoverageTree/NullCollapsedConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows; 4 | using System.Windows.Data; 5 | 6 | namespace OpenCppCoverage.VSPackage.CoverageTree 7 | { 8 | class NullCollapsedConverter : IValueConverter 9 | { 10 | //----------------------------------------------------------------------- 11 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 12 | { 13 | if (value == null) 14 | return Visibility.Collapsed; 15 | return Visibility.Visible; 16 | } 17 | 18 | //----------------------------------------------------------------------- 19 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 20 | { 21 | throw new NotSupportedException(); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /VSPackage/CoverageTree/RootCoverageTreeNode.cs: -------------------------------------------------------------------------------- 1 | // OpenCppCoverage is an open source code coverage for C++. 2 | // Copyright (C) 2016 OpenCppCoverage 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | 17 | using OpenCppCoverage.VSPackage.CoverageRateBuilder; 18 | using System.Collections.Generic; 19 | 20 | namespace OpenCppCoverage.VSPackage.CoverageTree 21 | { 22 | //--------------------------------------------------------------------------- 23 | class RootCoverageTreeNode : BasicCoverageTreeNode 24 | { 25 | readonly CoverageRate coverage; 26 | 27 | //----------------------------------------------------------------------- 28 | public static readonly string IconFilename = "48px-Gnome-folder.svg.png"; 29 | 30 | //----------------------------------------------------------------------- 31 | public RootCoverageTreeNode(CoverageRate coverage) 32 | : base(coverage.Name, coverage, IconFilename, false) 33 | { 34 | this.coverage = coverage; 35 | } 36 | 37 | //----------------------------------------------------------------------- 38 | protected override void LoadChildren() 39 | { 40 | this.Modules = this.AddChildrenNode(this.coverage.Children, c => new ModuleTreeNode(c)); 41 | } 42 | 43 | //----------------------------------------------------------------------- 44 | public IEnumerable Modules { get; private set; } 45 | } 46 | 47 | //----------------------------------------------------------------------- 48 | class ModuleTreeNode : BasicCoverageTreeNode 49 | { 50 | readonly ModuleCoverage coverage; 51 | 52 | //----------------------------------------------------------------------- 53 | public ModuleTreeNode(ModuleCoverage coverage) 54 | : base(coverage.Name, coverage, "48px-Gnome-application-x-executable.svg.png", false) 55 | { 56 | this.coverage = coverage; 57 | } 58 | 59 | //----------------------------------------------------------------------- 60 | public IEnumerable Files { get; private set; } 61 | 62 | //----------------------------------------------------------------------- 63 | protected override void LoadChildren() 64 | { 65 | this.Files = this.AddChildrenNode(this.coverage.Children, c => new FileTreeNode(c.Path, c)); 66 | } 67 | } 68 | 69 | //----------------------------------------------------------------------- 70 | class FileTreeNode : BasicCoverageTreeNode 71 | { 72 | //----------------------------------------------------------------------- 73 | public FileTreeNode(string name, FileCoverage coverage) 74 | : base(name, coverage, "48px-Gnome-text-x-generic.svg.png", true) 75 | { 76 | this.Coverage = coverage; 77 | } 78 | 79 | //----------------------------------------------------------------------- 80 | public FileCoverage Coverage { get; } 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /VSPackage/CoverageTree/TreeNodeVisibilityManager.cs: -------------------------------------------------------------------------------- 1 | // OpenCppCoverage is an open source code coverage for C++. 2 | // Copyright (C) 2016 OpenCppCoverage 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | 17 | using ICSharpCode.TreeView; 18 | using System; 19 | using System.Collections.Generic; 20 | 21 | namespace OpenCppCoverage.VSPackage.CoverageTree 22 | { 23 | class TreeNodeVisibilityManager 24 | { 25 | //--------------------------------------------------------------------------- 26 | public void UpdateVisibility(RootCoverageTreeNode node, string filter) 27 | { 28 | node.EnsureLazyChildren(); 29 | foreach (var module in node.Modules) 30 | { 31 | var fileVisibilities = new List(); 32 | bool oneChildVisible = false; 33 | 34 | module.EnsureLazyChildren(); 35 | foreach (var file in module.Files) 36 | { 37 | bool newVisibility = NewVisibility(file, filter); 38 | oneChildVisible = oneChildVisible || newVisibility; 39 | 40 | if (newVisibility != !file.IsHidden) 41 | fileVisibilities.Add(new FileVisibility { File = file, Visibility = newVisibility }); 42 | } 43 | module.IsHidden = !oneChildVisible && !NewVisibility(module, filter); 44 | 45 | if (!module.IsHidden) 46 | { 47 | foreach (var fileVisibility in fileVisibilities) 48 | fileVisibility.File.IsHidden = !fileVisibility.Visibility; 49 | } 50 | } 51 | } 52 | 53 | //--------------------------------------------------------------------------- 54 | class FileVisibility 55 | { 56 | public FileTreeNode File { get; set; } 57 | public bool Visibility { get; set; } 58 | } 59 | 60 | //--------------------------------------------------------------------------- 61 | static bool NewVisibility(SharpTreeNode node, string filter) 62 | { 63 | var text = (string)node.Text; 64 | return text.IndexOf(filter, StringComparison.InvariantCultureIgnoreCase) >= 0; 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /VSPackage/DynamicVCCLCompilerTool.cs: -------------------------------------------------------------------------------- 1 | // OpenCppCoverage is an open source code coverage for C++. 2 | // Copyright (C) 2017 OpenCppCoverage 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | 17 | namespace OpenCppCoverage.VSPackage 18 | { 19 | class DynamicVCCLCompilerTool 20 | { 21 | //--------------------------------------------------------------------- 22 | public DynamicVCCLCompilerTool(dynamic compilerTool) 23 | { 24 | this.compilerTool = compilerTool; 25 | } 26 | 27 | //--------------------------------------------------------------------- 28 | public bool IsOptimizeDisabled 29 | { 30 | get 31 | { 32 | return (int)compilerTool.Optimization == (int)OptimizeOption.optimizeDisabled; 33 | } 34 | } 35 | 36 | //--------------------------------------------------------------------- 37 | enum OptimizeOption 38 | { 39 | optimizeDisabled = 0 40 | } 41 | 42 | readonly dynamic compilerTool; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /VSPackage/DynamicVCConfiguration.cs: -------------------------------------------------------------------------------- 1 | // OpenCppCoverage is an open source code coverage for C++. 2 | // Copyright (C) 2016 OpenCppCoverage 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | 17 | namespace OpenCppCoverage.VSPackage 18 | { 19 | class DynamicVCConfiguration 20 | { 21 | //--------------------------------------------------------------------- 22 | public DynamicVCConfiguration(dynamic configuration) 23 | { 24 | this.configuration_ = configuration; 25 | this.DebugSettings = new DynamicVCDebugSettings(configuration_.DebugSettings); 26 | 27 | var compilerTool = GetTool(configuration, "VCCLCompilerTool"); 28 | if (compilerTool != null) 29 | this.OptionalVCCLCompilerTool = new DynamicVCCLCompilerTool(compilerTool); 30 | } 31 | 32 | //--------------------------------------------------------------------- 33 | static dynamic GetTool(dynamic configuration, string toolKindToFind) 34 | { 35 | foreach (dynamic tool in configuration.Tools) 36 | { 37 | if (tool.ToolKind == toolKindToFind) 38 | return tool; 39 | } 40 | 41 | return null; 42 | } 43 | 44 | //--------------------------------------------------------------------- 45 | public string ConfigurationName 46 | { 47 | get 48 | { 49 | return configuration_.ConfigurationName; 50 | } 51 | } 52 | 53 | //--------------------------------------------------------------------- 54 | public string PlatformName 55 | { 56 | get 57 | { 58 | return configuration_.Platform.Name; 59 | } 60 | } 61 | 62 | //--------------------------------------------------------------------- 63 | public string Evaluate(string str) 64 | { 65 | return configuration_.Evaluate(str); 66 | } 67 | 68 | //--------------------------------------------------------------------- 69 | public DynamicVCDebugSettings DebugSettings { get; } 70 | 71 | //--------------------------------------------------------------------- 72 | public DynamicVCCLCompilerTool OptionalVCCLCompilerTool { get; } 73 | 74 | //--------------------------------------------------------------------- 75 | public string PrimaryOutput 76 | { 77 | get 78 | { 79 | return configuration_.PrimaryOutput; 80 | } 81 | } 82 | 83 | readonly dynamic configuration_; 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /VSPackage/DynamicVCDebugSettings.cs: -------------------------------------------------------------------------------- 1 | // OpenCppCoverage is an open source code coverage for C++. 2 | // Copyright (C) 2016 OpenCppCoverage 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | 17 | namespace OpenCppCoverage.VSPackage 18 | { 19 | class DynamicVCDebugSettings 20 | { 21 | //--------------------------------------------------------------------- 22 | public DynamicVCDebugSettings(dynamic settings) 23 | { 24 | settings_ = settings; 25 | } 26 | 27 | //--------------------------------------------------------------------- 28 | public string WorkingDirectory 29 | { 30 | get 31 | { 32 | return settings_.WorkingDirectory; 33 | } 34 | } 35 | 36 | //--------------------------------------------------------------------- 37 | public string CommandArguments 38 | { 39 | get 40 | { 41 | return settings_.CommandArguments; 42 | } 43 | } 44 | 45 | //--------------------------------------------------------------------- 46 | public string Command 47 | { 48 | get 49 | { 50 | return settings_.Command; 51 | } 52 | } 53 | 54 | 55 | readonly dynamic settings_; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /VSPackage/DynamicVCFile.cs: -------------------------------------------------------------------------------- 1 | // OpenCppCoverage is an open source code coverage for C++. 2 | // Copyright (C) 2016 OpenCppCoverage 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | 17 | namespace OpenCppCoverage.VSPackage 18 | { 19 | class DynamicVCFile 20 | { 21 | //--------------------------------------------------------------------- 22 | public DynamicVCFile(dynamic file) 23 | { 24 | file_ = file; 25 | } 26 | 27 | //--------------------------------------------------------------------- 28 | public string FullPath 29 | { 30 | get 31 | { 32 | return file_.FullPath; 33 | } 34 | } 35 | 36 | readonly dynamic file_; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /VSPackage/DynamicVCProject.cs: -------------------------------------------------------------------------------- 1 | // OpenCppCoverage is an open source code coverage for C++. 2 | // Copyright (C) 2016 OpenCppCoverage 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | 17 | using System.Collections.Generic; 18 | 19 | namespace OpenCppCoverage.VSPackage 20 | { 21 | class DynamicVCProject 22 | { 23 | //--------------------------------------------------------------------- 24 | public DynamicVCProject(dynamic project) 25 | { 26 | project_ = project; 27 | } 28 | 29 | //--------------------------------------------------------------------- 30 | public List Configurations 31 | { 32 | get 33 | { 34 | var configurations = new List(); 35 | foreach (var configuration in project_.Configurations) 36 | configurations.Add(new DynamicVCConfiguration(configuration)); 37 | 38 | return configurations; 39 | } 40 | } 41 | 42 | //--------------------------------------------------------------------- 43 | public List Files 44 | { 45 | get 46 | { 47 | var files = new List(); 48 | foreach (var file in project_.Files) 49 | files.Add(new DynamicVCFile(file)); 50 | return files; 51 | } 52 | } 53 | 54 | readonly dynamic project_; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /VSPackage/ErrorHandler.cs: -------------------------------------------------------------------------------- 1 | // OpenCppCoverage is an open source code coverage for C++. 2 | // Copyright (C) 2014 OpenCppCoverage 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | 17 | using Microsoft.VisualStudio.Shell.Interop; 18 | using System; 19 | using System.Threading.Tasks; 20 | 21 | namespace OpenCppCoverage.VSPackage 22 | { 23 | class ErrorHandler 24 | { 25 | //--------------------------------------------------------------------- 26 | public ErrorHandler(IVsUIShell uiShell) 27 | { 28 | uiShell_ = uiShell; 29 | } 30 | 31 | //--------------------------------------------------------------------- 32 | public OutputWindowWriter OutputWriter { get; set; } 33 | 34 | //--------------------------------------------------------------------- 35 | public async Task ExecuteAsync(Func action) 36 | { 37 | try 38 | { 39 | await action(); 40 | } 41 | catch (VSPackageException exception) 42 | { 43 | if (OutputWriter != null) 44 | OutputWriter.WriteLine(exception.Message); 45 | ShowMessage(exception.Message); 46 | } 47 | catch (Exception exception) 48 | { 49 | if (OutputWriter != null && OutputWriter.WriteLine(exception.ToString())) 50 | ShowMessage("Unknow error. Please see the output console for more information."); 51 | else 52 | ShowMessage(exception.ToString()); 53 | } 54 | } 55 | 56 | //--------------------------------------------------------------------- 57 | public void Execute(Action action) 58 | { 59 | ExecuteAsync(() => 60 | { 61 | action(); 62 | return Task.FromResult(0); 63 | }).Wait(); 64 | } 65 | 66 | //--------------------------------------------------------------------- 67 | void ShowMessage(string message) 68 | { 69 | Guid clsid = Guid.Empty; 70 | int result; 71 | Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(uiShell_.ShowMessageBox( 72 | 0, 73 | ref clsid, 74 | "OpenCppCoverage", 75 | message, 76 | string.Empty, 77 | 0, 78 | OLEMSGBUTTON.OLEMSGBUTTON_OK, 79 | OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST, 80 | OLEMSGICON.OLEMSGICON_INFO, 81 | 0, // false 82 | out result)); 83 | } 84 | 85 | readonly IVsUIShell uiShell_; 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /VSPackage/ExtendedProject.cs: -------------------------------------------------------------------------------- 1 | // OpenCppCoverage is an open source code coverage for C++. 2 | // Copyright (C) 2014 OpenCppCoverage 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | 17 | using EnvDTE; 18 | using System.Collections.Generic; 19 | 20 | namespace OpenCppCoverage.VSPackage 21 | { 22 | class ExtendedProject 23 | { 24 | //--------------------------------------------------------------------- 25 | public ExtendedProject(Project project, DynamicVCProject vcProject) 26 | { 27 | this.project_ = project; 28 | this.vcProject_ = vcProject; 29 | } 30 | 31 | //--------------------------------------------------------------------- 32 | public string UniqueName 33 | { 34 | get 35 | { 36 | return project_.UniqueName; 37 | } 38 | } 39 | 40 | //--------------------------------------------------------------------- 41 | public string Path 42 | { 43 | get 44 | { 45 | return project_.FullName; 46 | } 47 | } 48 | 49 | //--------------------------------------------------------------------- 50 | public List Configurations 51 | { 52 | get 53 | { 54 | return vcProject_.Configurations; 55 | } 56 | } 57 | 58 | //--------------------------------------------------------------------- 59 | public List Files 60 | { 61 | get 62 | { 63 | return vcProject_.Files; 64 | } 65 | } 66 | 67 | readonly Project project_; 68 | readonly DynamicVCProject vcProject_; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /VSPackage/GlobalSuppressions.cs: -------------------------------------------------------------------------------- 1 | // This file is used by Code Analysis to maintain SuppressMessage 2 | // attributes that are applied to this project. Project-level 3 | // suppressions either have no target or are given a specific target 4 | // and scoped to a namespace, type, member, etc. 5 | // 6 | // To add a suppression to this file, right-click the message in the 7 | // Error List, point to "Suppress Message(s)", and click "In Project 8 | // Suppression File". You do not need to add suppressions to this 9 | // file manually. 10 | 11 | [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1017:MarkAssembliesWithComVisible")] 12 | -------------------------------------------------------------------------------- /VSPackage/Guids.cs: -------------------------------------------------------------------------------- 1 | // Guids.cs 2 | // MUST match guids.h 3 | using System; 4 | 5 | namespace OpenCppCoverage.VSPackage 6 | { 7 | static class GuidList 8 | { 9 | public const string guidVSPackagePkgString = "c6a77aca-f53c-4cd1-97d7-0ed595751347"; 10 | public const string guidVSPackageCmdSetString = "fe1f442f-480d-4a2b-bf8a-adc8a0fc569d"; 11 | 12 | public static readonly Guid guidVSPackageCmdSet = new Guid(guidVSPackageCmdSetString); 13 | }; 14 | } -------------------------------------------------------------------------------- /VSPackage/Helper/DataGridFileSystemSelectionColumn.cs: -------------------------------------------------------------------------------- 1 | // OpenCppCoverage is an open source code coverage for C++. 2 | // Copyright (C) 2016 OpenCppCoverage 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | 17 | using System.Windows; 18 | using System.Windows.Controls; 19 | using System.Windows.Data; 20 | 21 | namespace OpenCppCoverage.VSPackage.Helper 22 | { 23 | class DataGridFileSystemSelectionColumn : DataGridBoundColumn 24 | { 25 | public BindingBase FileFilterBinding { get; set; } 26 | public string FileFilter { get; set; } 27 | 28 | public BindingBase ModeBinding { get; set; } 29 | public FileSystemSelectionControl.SelectionMode Mode { get; set; } 30 | 31 | //----------------------------------------------------------------------- 32 | protected override FrameworkElement GenerateEditingElement( 33 | DataGridCell cell, 34 | object dataItem) 35 | { 36 | var fileSystemSelectionControl = new FileSystemSelectionControl(); 37 | 38 | if (!BindIfNotNull( 39 | fileSystemSelectionControl, 40 | FileSystemSelectionControl.FileFilterProperty, 41 | this.FileFilterBinding)) 42 | fileSystemSelectionControl.FileFilter = this.FileFilter; 43 | 44 | if (!BindIfNotNull( 45 | fileSystemSelectionControl, 46 | FileSystemSelectionControl.ModeProperty, 47 | this.ModeBinding)) 48 | fileSystemSelectionControl.Mode = this.Mode; 49 | 50 | fileSystemSelectionControl.SetBinding( 51 | FileSystemSelectionControl.SelectedPathProperty, 52 | this.Binding); 53 | cell.SetBinding(DataGridCell.ToolTipProperty, this.Binding); 54 | 55 | return fileSystemSelectionControl; 56 | } 57 | 58 | //----------------------------------------------------------------------- 59 | protected override FrameworkElement GenerateElement( 60 | DataGridCell cell, 61 | object dataItem) 62 | { 63 | var currentTextBlock = new TextBlock(); 64 | currentTextBlock.SetBinding(TextBlock.TextProperty, this.Binding); 65 | 66 | return currentTextBlock; 67 | } 68 | 69 | //----------------------------------------------------------------------- 70 | bool BindIfNotNull( 71 | FrameworkElement element, 72 | DependencyProperty property, 73 | BindingBase binding) 74 | { 75 | if (binding != null) 76 | { 77 | element.SetBinding(property, binding); 78 | return true; 79 | } 80 | 81 | return false; 82 | } 83 | } 84 | } -------------------------------------------------------------------------------- /VSPackage/Helper/FileSystemSelectionControl.xaml: -------------------------------------------------------------------------------- 1 |  9 | 10 | 11 | 12 | 13 | 14 | 22 |