├── .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 | 
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 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/VSPackage/Helper/ObservableItemCollection.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.ObjectModel;
19 | using System.Collections.Specialized;
20 | using System.ComponentModel;
21 |
22 | namespace OpenCppCoverage.VSPackage.Helper
23 | {
24 | public class ObservableItemCollection
25 | : ObservableCollection where T : INotifyPropertyChanged
26 | {
27 | //---------------------------------------------------------------------
28 | public event EventHandler CollectionOrItemChanged;
29 |
30 | //---------------------------------------------------------------------
31 | public ObservableItemCollection()
32 | {
33 | this.CollectionChanged += CollectionChangedHandler;
34 | }
35 |
36 | //---------------------------------------------------------------------
37 | void CollectionChangedHandler(object sender, NotifyCollectionChangedEventArgs e)
38 | {
39 | if (e.NewItems != null)
40 | {
41 | foreach (T items in e.NewItems)
42 | items.PropertyChanged += PropertyChangedHandler;
43 | }
44 |
45 | if (e.OldItems != null)
46 | {
47 | foreach (T items in e.OldItems)
48 | items.PropertyChanged -= PropertyChangedHandler;
49 | }
50 | this?.CollectionOrItemChanged(sender, e);
51 | }
52 |
53 | //---------------------------------------------------------------------
54 | protected override void ClearItems()
55 | {
56 | foreach (var item in this)
57 | item.PropertyChanged -= PropertyChangedHandler;
58 | base.ClearItems();
59 | }
60 |
61 | //---------------------------------------------------------------------
62 | void PropertyChangedHandler(object sender, PropertyChangedEventArgs e)
63 | {
64 | this?.CollectionOrItemChanged(sender, e);
65 | }
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/VSPackage/Helper/PathHelper.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 | using System.IO;
19 |
20 | namespace OpenCppCoverage.VSPackage.Helper
21 | {
22 | static class PathHelper
23 | {
24 | //---------------------------------------------------------------------
25 | public static IEnumerable ComputeCommonFolders(IEnumerable filePaths)
26 | {
27 | var commonFolders = new List();
28 |
29 | foreach (var path in filePaths)
30 | commonFolders.Add(Path.GetDirectoryName(path));
31 | commonFolders.Sort();
32 | int index = 0;
33 | string previousFolder = null;
34 |
35 | while (index < commonFolders.Count)
36 | {
37 | string folder = commonFolders[index];
38 |
39 | if (previousFolder != null && folder.StartsWith(previousFolder))
40 | commonFolders.RemoveAt(index);
41 | else
42 | {
43 | previousFolder = folder;
44 | ++index;
45 | }
46 | }
47 |
48 | return commonFolders;
49 | }
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/VSPackage/Helper/PropertyChangedNotifier.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.ComponentModel;
19 | using System.Runtime.CompilerServices;
20 |
21 | namespace OpenCppCoverage.VSPackage.Helper
22 | {
23 | public class PropertyChangedNotifier : INotifyPropertyChanged
24 | {
25 | //-----------------------------------------------------------------------
26 | public event PropertyChangedEventHandler PropertyChanged;
27 |
28 | //-----------------------------------------------------------------------
29 | protected bool SetField(ref T field, T value, [CallerMemberName] string propertyName = null)
30 | {
31 | if (!EqualityComparer.Default.Equals(field, value))
32 | {
33 | field = value;
34 | NotifyPropertyChanged(propertyName);
35 | return true;
36 | }
37 |
38 | return false;
39 | }
40 |
41 | //-----------------------------------------------------------------------
42 | protected void NotifyPropertyChanged(string propertyName)
43 | {
44 | this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/VSPackage/IConfigurationManager.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 |
19 | namespace OpenCppCoverage.VSPackage
20 | {
21 | interface IConfigurationManager
22 | {
23 | DynamicVCConfiguration GetConfiguration(
24 | SolutionConfiguration2 activeConfiguration,
25 | ExtendedProject project);
26 | DynamicVCConfiguration FindConfiguration(
27 | SolutionConfiguration2 activeConfiguration,
28 | ExtendedProject project);
29 | string GetSolutionConfigurationName(SolutionConfiguration2 activeConfiguration);
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/VSPackage/IOpenCppCoverageCmdLine.cs:
--------------------------------------------------------------------------------
1 | // OpenCppCoverage is an open source code coverage for C++.
2 | // Copyright (C) 2020 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.Settings;
18 |
19 | namespace OpenCppCoverage.VSPackage
20 | {
21 | interface IOpenCppCoverageCmdLine
22 | {
23 | string Build(MainSettings settings, string lineSeparator = " ");
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/VSPackage/IWindowFinder.cs:
--------------------------------------------------------------------------------
1 | // OpenCppCoverage is an open source code coverage for C++.
2 | // Copyright (C) 2019 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 |
19 | namespace OpenCppCoverage.VSPackage
20 | {
21 | interface IWindowFinder
22 | {
23 | T FindToolWindow() where T : ToolWindowPane;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/VSPackage/Key.snk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OpenCppCoverage/OpenCppCoveragePlugin/6e39733d1e8643c99c2174d2334628fca1d0561e/VSPackage/Key.snk
--------------------------------------------------------------------------------
/VSPackage/OpenCppCoverage-x64/Plugins/Exporter/ForceFolderCreation.txt:
--------------------------------------------------------------------------------
1 | Empty folder cannot be created in VSIX.
--------------------------------------------------------------------------------
/VSPackage/OpenCppCoverage-x86/Plugins/Exporter/ForceFolderCreation.txt:
--------------------------------------------------------------------------------
1 | Empty folder cannot be created in VSIX.
--------------------------------------------------------------------------------
/VSPackage/OpenCppCoverageRunner.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.Settings;
18 | using System;
19 | using System.Diagnostics;
20 | using System.IO;
21 | using System.Runtime.InteropServices;
22 | using System.Threading.Tasks;
23 |
24 | namespace OpenCppCoverage.VSPackage
25 | {
26 | class OpenCppCoverageRunner
27 | {
28 | readonly OutputWindowWriter outputWindowWriter;
29 | readonly OpenCppCoverageCmdLine openCppCoverageCmdLine;
30 |
31 | //---------------------------------------------------------------------
32 | public OpenCppCoverageRunner(
33 | OutputWindowWriter outputWindowWriter,
34 | OpenCppCoverageCmdLine openCppCoverageCmdLine)
35 | {
36 | this.outputWindowWriter = outputWindowWriter;
37 | this.openCppCoverageCmdLine = openCppCoverageCmdLine;
38 | }
39 |
40 | //---------------------------------------------------------------------
41 | public Task RunCodeCoverageAsync(MainSettings settings)
42 | {
43 | var basicSettings = settings.BasicSettings;
44 | var fileName = GetOpenCppCoveragePath(basicSettings.ProgramToRun);
45 | var arguments = this.openCppCoverageCmdLine.Build(settings);
46 |
47 | this.outputWindowWriter.WriteLine("Run:");
48 | this.outputWindowWriter.WriteLine(string.Format(@"""{0}"" {1}",
49 | fileName, arguments));
50 |
51 | // Run in a new thread to not block UI thread.
52 | return Task.Run(() =>
53 | {
54 | using (var process = new Process())
55 | {
56 | var startInfo = process.StartInfo;
57 | startInfo.FileName = fileName;
58 | startInfo.Arguments = arguments;
59 | startInfo.UseShellExecute = false;
60 | startInfo.CreateNoWindow = !settings.DisplayProgramOutput;
61 |
62 | var environmentVariables = startInfo.EnvironmentVariables;
63 | foreach (var environment in basicSettings.EnvironmentVariables)
64 | environmentVariables[environment.Key] = environment.Value;
65 |
66 | if (!String.IsNullOrEmpty(basicSettings.WorkingDirectory))
67 | startInfo.WorkingDirectory = basicSettings.WorkingDirectory;
68 | process.Start();
69 | process.WaitForExit();
70 | }
71 | });
72 | }
73 |
74 | //---------------------------------------------------------------------
75 | string GetOpenCppCoveragePath(string commandPath)
76 | {
77 | var assemblyLocation = System.Reflection.Assembly.GetExecutingAssembly().Location;
78 | var assemblyFolder = Path.GetDirectoryName(assemblyLocation);
79 | var openCppCovergeFolder = Environment.Is64BitOperatingSystem ?
80 | "OpenCppCoverage-x64" : "OpenCppCoverage-x86";
81 | return Path.Combine(assemblyFolder, openCppCovergeFolder, "OpenCppCoverage.exe");
82 | }
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/VSPackage/OutputWindowWriter.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 EnvDTE80;
19 | using Microsoft.VisualStudio.Shell.Interop;
20 | using System;
21 |
22 | namespace OpenCppCoverage.VSPackage
23 | {
24 | class OutputWindowWriter
25 | {
26 | //---------------------------------------------------------------------
27 | public OutputWindowWriter(DTE2 dte, IVsOutputWindow outputWindow)
28 | {
29 | // These lines show the output windows
30 | Window output = dte.Windows.Item(EnvDTE.Constants.vsWindowKindOutput);
31 | output.Activate();
32 |
33 | if (Microsoft.VisualStudio.ErrorHandler.Failed(outputWindow.GetPane(OpenCppCoverageOutputPaneGuid, out outputWindowPane_)))
34 | {
35 | if (Microsoft.VisualStudio.ErrorHandler.Failed(outputWindow.CreatePane(OpenCppCoverageOutputPaneGuid, "OpenCppCoverage", 1, 1)))
36 | throw new Exception("Cannot create new pane.");
37 |
38 | if (Microsoft.VisualStudio.ErrorHandler.Failed(outputWindow.GetPane(OpenCppCoverageOutputPaneGuid, out outputWindowPane_)))
39 | throw new Exception("Cannot get the pane.");
40 | }
41 |
42 | outputWindowPane_.Clear();
43 | ActivatePane();
44 | }
45 |
46 | //---------------------------------------------------------------------
47 | public void ActivatePane()
48 | {
49 | outputWindowPane_.Activate();
50 | }
51 |
52 | //---------------------------------------------------------------------
53 | public bool WriteLine(string message)
54 | {
55 | return Microsoft.VisualStudio.ErrorHandler.Succeeded(outputWindowPane_.OutputString(message + "\n"));
56 | }
57 |
58 | readonly IVsOutputWindowPane outputWindowPane_;
59 | public readonly static Guid OpenCppCoverageOutputPaneGuid = new Guid("CB47C727-5E45-467B-A4CD-4A025986A8A0");
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/VSPackage/PackageInterfaces.cs:
--------------------------------------------------------------------------------
1 | // OpenCppCoverage is an open source code coverage for C++.
2 | // Copyright (C) 2019 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 System;
19 |
20 | namespace OpenCppCoverage.VSPackage
21 | {
22 | ///
23 | /// PackageInterfaces implements the interfaces for OpenCppCoveragePackage.
24 | ///
25 | /// OpenCppCoveragePackage cannot implement the interface directly, otherwise
26 | /// it would be necessary to add a reference to all interfaces (Some of them are from
27 | /// VS 15)
28 | /// Note: We use a lambda for GetService because Package.GetService is protected.
29 | ///
30 | class PackageInterfaces : IServiceProvider, IWindowFinder
31 | {
32 | readonly Package package;
33 | readonly Func getService;
34 |
35 | //---------------------------------------------------------------------
36 | public PackageInterfaces(Package package, Func getService)
37 | {
38 | this.package = package;
39 | this.getService = getService;
40 | }
41 |
42 | //---------------------------------------------------------------------
43 | public T FindToolWindow() where T : ToolWindowPane
44 | {
45 | var type = typeof(T);
46 | var window = this.package.FindToolWindow(type, 0, true) as T;
47 | if (window == null || window.Frame == null)
48 | throw new NotSupportedException("Cannot create window " + type.Name);
49 | return window;
50 | }
51 |
52 | //---------------------------------------------------------------------
53 | public object GetService(Type serviceType)
54 | {
55 | return this.getService(serviceType);
56 | }
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/VSPackage/PkgCmdID.cs:
--------------------------------------------------------------------------------
1 | // PkgCmdID.cs
2 | // MUST match PkgCmdID.h
3 | using System;
4 |
5 | namespace OpenCppCoverage.VSPackage
6 | {
7 | static class PkgCmdIDList
8 | {
9 | public const uint RunOpenCppCoverageCommand = 0x100;
10 | public const uint RunOpenCppCoverageSettingsCommand = 0x101;
11 |
12 | public const uint RunOpenCppCoverageFromSelectedProjectCommand = 0x0200;
13 | public const uint RunOpenCppCoverageFromSelectedProjectSettingsCommand = 0x0201;
14 |
15 | public const uint ShowCoverageTree = 0x0300;
16 | };
17 | }
--------------------------------------------------------------------------------
/VSPackage/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Reflection;
3 | using System.Resources;
4 | using System.Runtime.CompilerServices;
5 | using System.Runtime.InteropServices;
6 |
7 | // General Information about an assembly is controlled through the following
8 | // set of attributes. Change these attribute values to modify the information
9 | // associated with an assembly.
10 | [assembly: AssemblyTitle("OpenCppCoverage")]
11 | [assembly: AssemblyDescription("")]
12 | [assembly: AssemblyConfiguration("")]
13 | [assembly: AssemblyCompany("OpenCppCoverage")]
14 | [assembly: AssemblyProduct("OpenCppCoverage")]
15 | [assembly: AssemblyCopyright("")]
16 | [assembly: AssemblyTrademark("")]
17 | [assembly: AssemblyCulture("")]
18 | [assembly: ComVisible(false)]
19 | [assembly: CLSCompliant(false)]
20 | [assembly: NeutralResourcesLanguage("en-US")]
21 |
22 | // Version information for an assembly consists of the following four values:
23 | //
24 | // Major Version
25 | // Minor Version
26 | // Build Number
27 | // Revision
28 | //
29 | // You can specify all the values or you can default the Revision and Build Numbers
30 | // by using the '*' as shown below:
31 |
32 | [assembly: AssemblyVersion("1.0.0.0")]
33 | [assembly: AssemblyFileVersion("1.0.0.0")]
34 |
35 | [assembly: InternalsVisibleTo("VSPackage_IntegrationTests, PublicKey=00240000048000009400000006020000002400005253413100040000010001008ba749380266d3d6dfefaf54e5b092dc2c01c8e7242cfa335eb27e77200a3906c4d08556487da49cca3504c085a37db8a5e4f35f9e9147b0e7a0f40364f7071056fe67d6c02a4c51363dba75f9bbf27b954f1703c5de2d4e78ff812ec90055c13bba520fbc2241387401dc4ff41044a3afbc0ddc4879eb8abc64aa77ec97e1bb")]
36 | [assembly: InternalsVisibleTo("VSPackage_UnitTests, PublicKey=00240000048000009400000006020000002400005253413100040000010001008ba749380266d3d6dfefaf54e5b092dc2c01c8e7242cfa335eb27e77200a3906c4d08556487da49cca3504c085a37db8a5e4f35f9e9147b0e7a0f40364f7071056fe67d6c02a4c51363dba75f9bbf27b954f1703c5de2d4e78ff812ec90055c13bba520fbc2241387401dc4ff41044a3afbc0ddc4879eb8abc64aa77ec97e1bb")]
37 | [assembly: InternalsVisibleTo("DynamicProxyGenAssembly2, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7")]
--------------------------------------------------------------------------------
/VSPackage/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace OpenCppCoverage.VSPackage {
12 | using System;
13 |
14 |
15 | ///
16 | /// A strongly-typed resource class, for looking up localized strings, etc.
17 | ///
18 | // This class was auto-generated by the StronglyTypedResourceBuilder
19 | // class via a tool like ResGen or Visual Studio.
20 | // To add or remove a member, edit your .ResX file then rerun ResGen
21 | // with the /str option, or rebuild your VS project.
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources {
26 |
27 | private static global::System.Resources.ResourceManager resourceMan;
28 |
29 | private static global::System.Globalization.CultureInfo resourceCulture;
30 |
31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
32 | internal Resources() {
33 | }
34 |
35 | ///
36 | /// Returns the cached ResourceManager instance used by this class.
37 | ///
38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
39 | internal static global::System.Resources.ResourceManager ResourceManager {
40 | get {
41 | if (object.ReferenceEquals(resourceMan, null)) {
42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("OpenCppCoverage.VSPackage.Resources", typeof(Resources).Assembly);
43 | resourceMan = temp;
44 | }
45 | return resourceMan;
46 | }
47 | }
48 |
49 | ///
50 | /// Overrides the current thread's CurrentUICulture property for all
51 | /// resource lookups using this strongly typed resource class.
52 | ///
53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
54 | internal static global::System.Globalization.CultureInfo Culture {
55 | get {
56 | return resourceCulture;
57 | }
58 | set {
59 | resourceCulture = value;
60 | }
61 | }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/VSPackage/Resources/Images.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OpenCppCoverage/OpenCppCoveragePlugin/6e39733d1e8643c99c2174d2334628fca1d0561e/VSPackage/Resources/Images.png
--------------------------------------------------------------------------------
/VSPackage/Resources/Package.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OpenCppCoverage/OpenCppCoveragePlugin/6e39733d1e8643c99c2174d2334628fca1d0561e/VSPackage/Resources/Package.ico
--------------------------------------------------------------------------------
/VSPackage/Settings/ISettingsStorage.cs:
--------------------------------------------------------------------------------
1 | // OpenCppCoverage is an open source code coverage for C++.
2 | // Copyright (C) 2019 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 |
18 | using OpenCppCoverage.VSPackage.Settings.UI;
19 |
20 | namespace OpenCppCoverage.VSPackage.Settings
21 | {
22 | interface ISettingsStorage
23 | {
24 | string Save(
25 | string optionalProjectPath,
26 | string optionalSolutionConfigurationName,
27 | UserInterfaceSettings settings);
28 |
29 | UserInterfaceSettings TryLoad(string optionalProjectPath, string optionalSolutionConfigurationName);
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/VSPackage/Settings/IStartUpProjectSettingsBuilder.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.Settings
18 | {
19 | //---------------------------------------------------------------------
20 | public enum ProjectSelectionKind
21 | {
22 | StartUpProject,
23 | SelectedProject
24 | }
25 |
26 | //---------------------------------------------------------------------
27 | interface IStartUpProjectSettingsBuilder
28 | {
29 | StartUpProjectSettings ComputeSettings(ProjectSelectionKind kind);
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/VSPackage/Settings/MainSettings.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.Settings
20 | {
21 | //---------------------------------------------------------------------------
22 | class MainSettings
23 | {
24 | public BasicSettings BasicSettings { get; set; }
25 | public FilterSettings FilterSettings { get; set; }
26 | public ImportExportSettings ImportExportSettings { get; set; }
27 | public MiscellaneousSettings MiscellaneousSettings { get; set; }
28 |
29 | public bool DisplayProgramOutput { get; set; }
30 | }
31 |
32 | //---------------------------------------------------------------------------
33 | class BasicSettings
34 | {
35 | public IEnumerable ModulePaths { get; set; }
36 | public IEnumerable SourcePaths { get; set; }
37 | public string WorkingDirectory { get; set; }
38 | public string Arguments { get; set; }
39 | public string ProgramToRun { get; set; }
40 | public bool CompileBeforeRunning { get; set; }
41 | public string ProjectName { get; set; }
42 | public string SolutionConfigurationName { get; set; }
43 | public bool IsOptimizedBuildEnabled { get; set; }
44 | public IEnumerable> EnvironmentVariables { get; set; }
45 | }
46 |
47 | //---------------------------------------------------------------------------
48 | class FilterSettings
49 | {
50 | //-------------------------------------------------------------------------
51 | public class UnifiedDiff
52 | {
53 | public string UnifiedDiffPath { get; set; }
54 | public string OptionalRootFolder { get; set; }
55 | }
56 |
57 | public IEnumerable AdditionalModulePaths { get; set; }
58 | public IEnumerable AdditionalSourcePaths { get; set; }
59 | public IEnumerable ExcludedModulePaths { get; set; }
60 | public IEnumerable ExcludedSourcePaths { get; set; }
61 | public IEnumerable UnifiedDiffs { get; set; }
62 | }
63 |
64 | //---------------------------------------------------------------------------
65 | class ImportExportSettings
66 | {
67 | //---------------------------------------------------------------------
68 | public enum Type
69 | {
70 | Html,
71 | Cobertura,
72 | Binary
73 | }
74 |
75 | //---------------------------------------------------------------------
76 | public class Export
77 | {
78 | public Type Type { get; set; }
79 | public string Path { get; set; }
80 | }
81 |
82 | public IEnumerable InputCoverages { get; set; }
83 | public IEnumerable Exports { get; set; }
84 |
85 | public bool CoverChildrenProcesses { get; set; }
86 | public bool AggregateByFile { get; set; }
87 | }
88 |
89 | //---------------------------------------------------------------------------
90 | class MiscellaneousSettings
91 | {
92 | public enum LogType
93 | {
94 | Normal,
95 | Quiet,
96 | Verbose
97 | }
98 |
99 | public string OptionalConfigFile { get; set; }
100 | public LogType LogTypeValue { get; set; }
101 | public bool ContinueAfterCppExceptions { get; set; }
102 | }
103 | }
104 |
--------------------------------------------------------------------------------
/VSPackage/Settings/MainWindowsManager.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 Microsoft.VisualStudio.Shell.Interop;
18 | using OpenCppCoverage.VSPackage.Settings.UI;
19 |
20 | namespace OpenCppCoverage.VSPackage.Settings
21 | {
22 | class MainWindowsManager
23 | {
24 | readonly IWindowFinder windowFinder;
25 | readonly MainSettingController mainSettingController;
26 |
27 | //---------------------------------------------------------------------
28 | public MainWindowsManager(IWindowFinder windowFinder, MainSettingController mainSettingController)
29 | {
30 | this.windowFinder = windowFinder;
31 | this.mainSettingController = mainSettingController;
32 | }
33 |
34 | //---------------------------------------------------------------------
35 | SettingToolWindow ConfigureSettingsWindows(
36 | ProjectSelectionKind kind,
37 | bool displayProgramOutput)
38 | {
39 | this.mainSettingController.UpdateFields(kind, displayProgramOutput);
40 | var window = this.windowFinder.FindToolWindow();
41 | window.Init(this.mainSettingController);
42 |
43 | return window;
44 | }
45 |
46 | //---------------------------------------------------------------------
47 | public void OpenSettingsWindow(ProjectSelectionKind kind)
48 | {
49 | var window = ConfigureSettingsWindows(kind, true);
50 | var frame = (IVsWindowFrame)window.Frame;
51 |
52 | Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(frame.Show());
53 | }
54 |
55 | //---------------------------------------------------------------------
56 | public void RunCoverage(ProjectSelectionKind kind)
57 | {
58 | var window = ConfigureSettingsWindows(kind, false);
59 | window.Controller.RunCoverageCommand.Execute(null);
60 | }
61 | }
62 | }
--------------------------------------------------------------------------------
/VSPackage/Settings/StartUpProjectSettings.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.Settings
20 | {
21 | class StartUpProjectSettings
22 | {
23 | public class CppProject
24 | {
25 | public string ModulePath { get; set; }
26 | public IEnumerable SourcePaths { get; set; }
27 | public string Path { get; set; }
28 | }
29 |
30 | public string WorkingDir { get; set; }
31 | public string Arguments { get; set; }
32 | public string Command { get; set; }
33 | public IEnumerable CppProjects { get; set; }
34 | public string SolutionConfigurationName { get; set; }
35 | public string ProjectName { get; set; }
36 | public string ProjectPath { get; set; }
37 |
38 | public bool IsOptimizedBuildEnabled { get; set; }
39 | public IEnumerable> EnvironmentVariables { get; set; }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/VSPackage/Settings/UI/BasicSettingControl.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.Settings.UI
20 | {
21 | ///
22 | /// Interaction logic for BasicSettingControl.xaml
23 | ///
24 | public partial class BasicSettingControl : UserControl
25 | {
26 | public BasicSettingControl()
27 | {
28 | InitializeComponent();
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/VSPackage/Settings/UI/BindableString.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 | using System.Linq;
19 |
20 | namespace OpenCppCoverage.VSPackage.Settings.UI
21 | {
22 | ///
23 | /// String cannot be bind directly in a datagrid.
24 | ///
25 | class BindableString
26 | {
27 | public BindableString() { }
28 | public BindableString(string value)
29 | {
30 | this.Value = value;
31 | }
32 |
33 | public string Value { get; set; }
34 | }
35 |
36 | //-------------------------------------------------------------------------
37 | static class CollectionExtensions
38 | {
39 | public static List ToStringList(this IEnumerable collection)
40 | {
41 | return collection.Select(v => v.Value).ToList();
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/VSPackage/Settings/UI/FilterSettingControl.xaml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
54 |
55 |
61 |
62 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
--------------------------------------------------------------------------------
/VSPackage/Settings/UI/FilterSettingControl.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.Settings.UI
20 | {
21 | ///
22 | /// Interaction logic for FilterSettingControl.xaml
23 | ///
24 | public partial class FilterSettingControl : UserControl
25 | {
26 | public FilterSettingControl()
27 | {
28 | InitializeComponent();
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/VSPackage/Settings/UI/FilterSettingController.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.Helper;
18 | using System.Collections.ObjectModel;
19 |
20 | namespace OpenCppCoverage.VSPackage.Settings.UI
21 | {
22 | //-------------------------------------------------------------------------
23 | class FilterSettingController: PropertyChangedNotifier
24 | {
25 | //---------------------------------------------------------------------
26 | public class SettingsData
27 | {
28 | public SettingsData()
29 | {
30 | this.AdditionalSourcePatterns = new ObservableCollection();
31 | this.AdditionalModulePatterns = new ObservableCollection();
32 | this.ExcludedSourcePatterns = new ObservableCollection();
33 | this.ExcludedModulePatterns = new ObservableCollection();
34 | this.UnifiedDiffs = new ObservableCollection();
35 | }
36 |
37 | public ObservableCollection AdditionalSourcePatterns { get; }
38 | public ObservableCollection AdditionalModulePatterns { get; }
39 | public ObservableCollection ExcludedSourcePatterns { get; }
40 | public ObservableCollection ExcludedModulePatterns { get; }
41 | public ObservableCollection UnifiedDiffs { get; }
42 | }
43 |
44 |
45 | //---------------------------------------------------------------------
46 | public FilterSettingController()
47 | {
48 | this.Settings = new SettingsData();
49 | }
50 |
51 | //---------------------------------------------------------------------
52 | SettingsData settings;
53 | public SettingsData Settings
54 | {
55 | get { return this.settings; }
56 | private set { this.SetField(ref this.settings, value); }
57 | }
58 |
59 | //---------------------------------------------------------------------
60 | public void UpdateStartUpProject()
61 | {
62 | this.Settings.AdditionalSourcePatterns.Clear();
63 | this.Settings.AdditionalModulePatterns.Clear();
64 | this.Settings.ExcludedSourcePatterns.Clear();
65 | this.Settings.ExcludedModulePatterns.Clear();
66 | this.Settings.UnifiedDiffs.Clear();
67 | }
68 |
69 | //---------------------------------------------------------------------
70 | public void UpdateSettings(SettingsData settings)
71 | {
72 | this.Settings = settings;
73 | }
74 |
75 | //---------------------------------------------------------------------
76 | public FilterSettings GetSettings()
77 | {
78 | return new FilterSettings
79 | {
80 | AdditionalSourcePaths = this.Settings.AdditionalSourcePatterns.ToStringList(),
81 | AdditionalModulePaths = this.Settings.AdditionalModulePatterns.ToStringList(),
82 | ExcludedSourcePaths = this.Settings.ExcludedSourcePatterns.ToStringList(),
83 | ExcludedModulePaths = this.Settings.ExcludedModulePatterns.ToStringList(),
84 | UnifiedDiffs = this.Settings.UnifiedDiffs
85 | };
86 | }
87 | }
88 | }
89 |
--------------------------------------------------------------------------------
/VSPackage/Settings/UI/ImportExportSettingControl.xaml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
30 |
31 |
32 |
33 |
34 |
35 |
39 |
45 |
46 |
47 |
48 |
50 |
51 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
--------------------------------------------------------------------------------
/VSPackage/Settings/UI/ImportExportSettingControl.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.Settings.UI
20 | {
21 | ///
22 | /// Interaction logic for ImportExportSettingControl.xaml
23 | ///
24 | public partial class ImportExportSettingControl : UserControl
25 | {
26 | public ImportExportSettingControl()
27 | {
28 | InitializeComponent();
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/VSPackage/Settings/UI/MainSettingControl.xaml:
--------------------------------------------------------------------------------
1 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
41 |
46 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
73 |
80 |
87 |
88 |
89 |
90 |
--------------------------------------------------------------------------------
/VSPackage/Settings/UI/MainSettingControl.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.Settings.UI
20 | {
21 | ///
22 | /// Interaction logic for MainSettingControl.xaml
23 | ///
24 | public partial class MainSettingControl : UserControl
25 | {
26 | public MainSettingControl()
27 | {
28 | InitializeComponent();
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/VSPackage/Settings/UI/MiscellaneousSettingControl.xaml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
41 |
42 |
43 |
48 |
55 |
56 |
57 |
62 |
63 |
64 |
65 |
--------------------------------------------------------------------------------
/VSPackage/Settings/UI/MiscellaneousSettingControl.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.Settings.UI
20 | {
21 | ///
22 | /// Interaction logic for MiscelousSettingControl.xaml
23 | ///
24 | public partial class MiscellaneousSettingControl : UserControl
25 | {
26 | public MiscellaneousSettingControl()
27 | {
28 | InitializeComponent();
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/VSPackage/Settings/UI/SettingToolWindow.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 Microsoft.VisualStudio.Shell;
18 | using Microsoft.VisualStudio.Shell.Interop;
19 | using System;
20 | using System.Runtime.InteropServices;
21 |
22 | namespace OpenCppCoverage.VSPackage.Settings.UI
23 | {
24 | [Guid("1305E50A-2B2B-4168-83A7-0D57ED1EF76A")]
25 | class SettingToolWindow : ToolWindowPane, IVsExtensibleObject, IVsWindowFrameNotify2
26 | {
27 | readonly MainSettingControl mainSettingControl;
28 |
29 | //---------------------------------------------------------------------
30 | public static readonly string WindowCaption = "Settings";
31 |
32 | //---------------------------------------------------------------------
33 | public SettingToolWindow() : base(null)
34 | {
35 | this.Caption = WindowCaption;
36 | this.mainSettingControl = new MainSettingControl();
37 |
38 | // This is the user control hosted by the tool window;
39 | // Note that, even if this class implements IDisposable,
40 | // we are not calling Dispose on this object.
41 | // This is because ToolWindowPane calls Dispose on
42 | // the object returned by the Content property.
43 | this.Content = this.mainSettingControl;
44 | }
45 |
46 | //---------------------------------------------------------------------
47 | public void Init(MainSettingController controller)
48 | {
49 | if (this.Controller != null)
50 | this.Controller.CloseWindowEvent -= Close;
51 |
52 | this.Controller = controller;
53 | this.mainSettingControl.DataContext = this.Controller;
54 | this.Controller.CloseWindowEvent += Close;
55 | }
56 |
57 | //---------------------------------------------------------------------
58 | public MainSettingController Controller { get; private set; }
59 |
60 | //---------------------------------------------------------------------
61 | public int GetAutomationObject(string pszPropName, out object ppDisp)
62 | {
63 | ppDisp = this.Controller;
64 | return Microsoft.VisualStudio.VSConstants.S_OK;
65 | }
66 |
67 | //---------------------------------------------------------------------
68 | void Close(object sender, EventArgs e)
69 | {
70 | var frame = (IVsWindowFrame)this.Frame;
71 | frame.CloseFrame((uint)__FRAMECLOSE.FRAMECLOSE_NoSave);
72 | }
73 |
74 | //---------------------------------------------------------------------
75 | // This method is called when closing Visual Studio
76 | protected override void OnClose()
77 | {
78 | this.Controller.SaveSettings();
79 | }
80 |
81 | //---------------------------------------------------------------------
82 | public int OnClose(ref uint pgrfSaveOptions)
83 | {
84 | this.Controller.SaveSettings();
85 | return Microsoft.VisualStudio.VSConstants.S_OK;
86 | }
87 | }
88 | }
89 |
--------------------------------------------------------------------------------
/VSPackage/Settings/UI/UserInterfaceSettings.cs:
--------------------------------------------------------------------------------
1 | // OpenCppCoverage is an open source code coverage for C++.
2 | // Copyright (C) 2019 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.Settings.UI
18 | {
19 | class UserInterfaceSettings
20 | {
21 | public BasicSettingController.SettingsData BasicSettingController { get; set; }
22 |
23 | public FilterSettingController.SettingsData FilterSettingController { get; set; }
24 |
25 | public ImportExportSettingController.SettingsData ImportExportSettingController { get; set; }
26 |
27 | public MiscellaneousSettingController.SettingsData MiscellaneousSettingController { get; set; }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/VSPackage/Styles/AllStyles.xaml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
15 |
16 |
17 |
20 |
21 |
22 |
23 |
26 |
27 |
38 |
39 |
43 |
44 |
47 |
48 |
51 |
52 |
55 |
56 |
69 |
70 |
74 |
75 |
76 |
77 |
78 |
--------------------------------------------------------------------------------
/VSPackage/Styles/ButtonStyle.xaml:
--------------------------------------------------------------------------------
1 |
4 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
64 |
--------------------------------------------------------------------------------
/VSPackage/Styles/VsBrushes.cs:
--------------------------------------------------------------------------------
1 | using ShellVsBrushes = Microsoft.VisualStudio.Shell.VsBrushes;
2 |
3 | namespace OpenCppCoverage.VSPackage.Styles
4 | {
5 | class VsBrushes
6 | {
7 | public static object CaptionTextKey => ShellVsBrushes.CaptionTextKey;
8 | public static object ToolWindowBackgroundKey => ShellVsBrushes.ToolWindowBackgroundKey;
9 | public static object ButtonFaceKey => ShellVsBrushes.ButtonFaceKey;
10 | public static object GridLineKey => ShellVsBrushes.GridLineKey;
11 | public static object GridHeadingTextKey => ShellVsBrushes.GridHeadingTextKey;
12 | public static object GridHeadingBackgroundKey => ShellVsBrushes.GridHeadingBackgroundKey;
13 | public static object ButtonHighlightKey => ShellVsBrushes.ButtonHighlightKey;
14 | public static object InactiveBorderKey => ShellVsBrushes.InactiveBorderKey;
15 | public static object InactiveCaptionTextKey => ShellVsBrushes.InactiveCaptionTextKey;
16 | public static object ComboBoxBackgroundKey => ShellVsBrushes.ComboBoxBackgroundKey;
17 | public static object ComboBoxBorderKey => ShellVsBrushes.ComboBoxBorderKey;
18 | public static object ToolWindowTabTextKey => ShellVsBrushes.ToolWindowTabTextKey;
19 | public static object ToolWindowTabGradientBeginKey => ShellVsBrushes.ToolWindowTabGradientBeginKey;
20 | public static object ToolWindowTabMouseOverBackgroundBeginKey => ShellVsBrushes.ToolWindowTabMouseOverBackgroundBeginKey;
21 | public static object ToolWindowTabMouseOverBorderKey => ShellVsBrushes.ToolWindowTabMouseOverBorderKey;
22 | public static object ToolWindowTabSelectedTextKey => ShellVsBrushes.ToolWindowTabSelectedTextKey;
23 | public static object ToolWindowTabSelectedTabKey => ShellVsBrushes.ToolWindowTabSelectedTabKey;
24 | public static object ButtonTextKey => ShellVsBrushes.ButtonTextKey;
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/VSPackage/Styles/VsColors.cs:
--------------------------------------------------------------------------------
1 | using ShellVsColors = Microsoft.VisualStudio.Shell.VsColors;
2 |
3 | namespace OpenCppCoverage.VSPackage.Styles
4 | {
5 | class VsColors
6 | {
7 | public static object InactiveBorderKey => ShellVsColors.InactiveBorderKey;
8 | public static object ComboBoxBackgroundKey => ShellVsColors.ComboBoxBackgroundKey;
9 | public static object ComboBoxMouseOverBackgroundBeginKey => ShellVsColors.ComboBoxMouseOverBackgroundBeginKey;
10 | public static object ComboBoxMouseOverBackgroundEndKey => ShellVsColors.ComboBoxMouseOverBackgroundEndKey;
11 | public static object ComboBoxBorderKey => ShellVsColors.ComboBoxBorderKey;
12 | public static object ComboBoxMouseOverBorderKey => ShellVsColors.ComboBoxMouseOverBorderKey;
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/VSPackage/TemporaryFile.cs:
--------------------------------------------------------------------------------
1 | // OpenCppCoverage is an open source code coverage for C++.
2 | // Copyright (C) 2019 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.IO;
19 |
20 | namespace OpenCppCoverage.VSPackage
21 | {
22 | sealed class TemporaryFile: IDisposable
23 | {
24 | //---------------------------------------------------------------------
25 | public TemporaryFile()
26 | {
27 | this.Path = System.IO.Path.Combine(
28 | System.IO.Path.GetTempPath(),
29 | System.IO.Path.GetRandomFileName());
30 | }
31 |
32 | //---------------------------------------------------------------------
33 | public string Path { get; }
34 |
35 | //---------------------------------------------------------------------
36 | public void Dispose()
37 | {
38 | try
39 | {
40 | File.Delete(this.Path);
41 | }
42 | catch (FileNotFoundException)
43 | {
44 | }
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/VSPackage/Themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/VSPackage/VSPackageException.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 |
19 | namespace OpenCppCoverage.VSPackage
20 | {
21 | [Serializable]
22 | class VSPackageException: Exception
23 | {
24 | public VSPackageException(string message)
25 | : base(message)
26 | {
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/VSPackage/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/VSPackage/source.extension.vsixmanifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | OpenCppCoverage Plugin
6 | Visual Studio plugin for OpenCppCoverage to compute code coverage for C++ application.
7 | https://github.com/OpenCppCoverage/OpenCppCoveragePlugin
8 | gpl-3.0.txt
9 | https://github.com/OpenCppCoverage/OpenCppCoveragePlugin/wiki
10 | C++, Code Coverage
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/VSPackage_IntegrationTests/IntegrationTestsSolution/CSharpConsoleApplication/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/VSPackage_IntegrationTests/IntegrationTestsSolution/CSharpConsoleApplication/CSharpConsoleApplication.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {36DA7242-1BE6-44ED-9496-243BC5D72E29}
8 | Exe
9 | Properties
10 | CSharpConsoleApplication
11 | CSharpConsoleApplication
12 | v4.5
13 | 512
14 |
15 |
16 | AnyCPU
17 | true
18 | full
19 | false
20 | bin\Debug\
21 | DEBUG;TRACE
22 | prompt
23 | 4
24 |
25 |
26 | AnyCPU
27 | pdbonly
28 | true
29 | bin\Release\
30 | TRACE
31 | prompt
32 | 4
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
58 |
--------------------------------------------------------------------------------
/VSPackage_IntegrationTests/IntegrationTestsSolution/CSharpConsoleApplication/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace CSharpConsoleApplication
8 | {
9 | class Program
10 | {
11 | static void Main(string[] args)
12 | {
13 | }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/VSPackage_IntegrationTests/IntegrationTestsSolution/CSharpConsoleApplication/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("CSharpConsoleApplication")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("CSharpConsoleApplication")]
13 | [assembly: AssemblyCopyright("Copyright © 2015")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("af5f8b67-71ad-45e8-82dc-e8f5a58669d8")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/VSPackage_IntegrationTests/IntegrationTestsSolution/ConsoleApplicationInFolder/ConsoleApplicationInFolder.cpp:
--------------------------------------------------------------------------------
1 | // ConsoleApplicationInFolder.cpp : Defines the entry point for the console application.
2 | //
3 |
4 | #include
5 |
6 | int _tmain(int argc, _TCHAR* argv[])
7 | {
8 | return 0;
9 | }
10 |
11 |
--------------------------------------------------------------------------------
/VSPackage_IntegrationTests/IntegrationTestsSolution/ConsoleApplicationInFolder/ConsoleApplicationInFolder.vcxproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | Win32
7 |
8 |
9 | Release
10 | Win32
11 |
12 |
13 |
14 | {B4A3675B-8D4F-49FD-9032-52F9C8193795}
15 | Win32Proj
16 | ConsoleApplicationInFolder
17 | 10.0.15063.0
18 |
19 |
20 |
21 | Application
22 | true
23 | v141
24 | Unicode
25 |
26 |
27 | Application
28 | false
29 | v141
30 | true
31 | Unicode
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 | true
45 |
46 |
47 | false
48 |
49 |
50 |
51 | NotUsing
52 | Level3
53 | Disabled
54 | WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)
55 | true
56 |
57 |
58 | Console
59 | true
60 |
61 |
62 |
63 |
64 | Level3
65 | NotUsing
66 | MaxSpeed
67 | true
68 | true
69 | WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)
70 | true
71 |
72 |
73 | Console
74 | true
75 | true
76 | true
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
--------------------------------------------------------------------------------
/VSPackage_IntegrationTests/IntegrationTestsSolution/CppConsoleApplication/CppConsoleApplication.cpp:
--------------------------------------------------------------------------------
1 | // CppConsoleApplication.cpp : Defines the entry point for the console application.
2 | //
3 |
4 | #include
5 | #include "../CppConsoleApplicationDll/CppConsoleApplicationDll.h"
6 | #include
7 |
8 | int _tmain(int argc, _TCHAR* argv[])
9 | { // COVERED
10 | if (argc == 2 && argv[1] == std::wstring(L"TestEnvVariable")) // COVERED
11 | {
12 | char* value = nullptr; // UNCOVERED
13 | size_t size = 0; // UNCOVERED
14 | _dupenv_s(&value, &size, "EXIT_CODE"); // UNCOVERED
15 | if (value) // UNCOVERED
16 | return std::atoi(value); // UNCOVERED
17 | }
18 | if (false) // COVERED
19 | Hello(); // UNCOVERED
20 | else // UNCOVERED
21 | Hello(); // COVERED
22 | return 0; // COVERED
23 | } // COVERED
24 |
25 |
--------------------------------------------------------------------------------
/VSPackage_IntegrationTests/IntegrationTestsSolution/CppConsoleApplication2/CppConsoleApplication2.cpp:
--------------------------------------------------------------------------------
1 | // CppConsoleApplication2.cpp : Defines the entry point for the console application.
2 | //
3 |
4 | #include
5 |
6 | int _tmain(int argc, _TCHAR* argv[])
7 | {
8 | THIS_CODE_DOES_NOT_COMPILE;
9 | return 0;
10 | }
11 |
12 |
--------------------------------------------------------------------------------
/VSPackage_IntegrationTests/IntegrationTestsSolution/CppConsoleApplicationDll/CppConsoleApplicationDll.cpp:
--------------------------------------------------------------------------------
1 | // CppConsoleApplicationDll.cpp : Defines the exported functions for the DLL application.
2 | //
3 |
4 | #include "stdafx.h"
5 |
6 | #include
7 |
8 | __declspec(dllexport) void Hello()
9 | { // COVERED
10 | std::cout << "Hello!" << std::endl; // COVERED
11 | } // COVERED
12 |
13 |
--------------------------------------------------------------------------------
/VSPackage_IntegrationTests/IntegrationTestsSolution/CppConsoleApplicationDll/CppConsoleApplicationDll.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | __declspec(dllexport) void Hello();
--------------------------------------------------------------------------------
/VSPackage_IntegrationTests/IntegrationTestsSolution/CppConsoleApplicationDll/stdafx.cpp:
--------------------------------------------------------------------------------
1 | // stdafx.cpp : source file that includes just the standard includes
2 | // CppConsoleApplicationDll.pch will be the pre-compiled header
3 | // stdafx.obj will contain the pre-compiled type information
4 |
5 | #include "stdafx.h"
6 |
7 | // TODO: reference any additional headers you need in STDAFX.H
8 | // and not in this file
9 |
--------------------------------------------------------------------------------
/VSPackage_IntegrationTests/IntegrationTestsSolution/CppConsoleApplicationDll/stdafx.h:
--------------------------------------------------------------------------------
1 | // stdafx.h : include file for standard system include files,
2 | // or project specific include files that are used frequently, but
3 | // are changed infrequently
4 | //
5 |
6 | #pragma once
7 |
8 |
9 | #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
10 | // Windows Header Files:
11 | #include
12 |
13 |
14 |
15 | // TODO: reference additional headers your program requires here
16 |
--------------------------------------------------------------------------------
/VSPackage_IntegrationTests/Key.snk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OpenCppCoverage/OpenCppCoveragePlugin/6e39733d1e8643c99c2174d2334628fca1d0561e/VSPackage_IntegrationTests/Key.snk
--------------------------------------------------------------------------------
/VSPackage_IntegrationTests/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/VSPackage_UnitTests/BasicCoverageTreeNodeTests.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 Microsoft.VisualStudio.TestTools.UnitTesting;
18 | using OpenCppCoverage.VSPackage.CoverageRateBuilder;
19 | using OpenCppCoverage.VSPackage.CoverageTree;
20 |
21 | namespace VSPackage_UnitTests
22 | {
23 | [TestClass]
24 | public class BasicCoverageTreeNodeTests
25 | {
26 | //---------------------------------------------------------------------
27 | [TestMethod]
28 | public void TestCoverage()
29 | {
30 | var coverage = new BaseCoverageTest(10, 50);
31 | var node = new BasicCoverageTreeNode(null, coverage,
32 | RootCoverageTreeNode.IconFilename, false);
33 |
34 | Assert.AreEqual(10, node.CoveredLineCount);
35 | Assert.AreEqual(50, node.TotalLineCount);
36 | Assert.AreEqual(40, node.UncoveredLineCount);
37 | Assert.AreEqual(10 / 50.0, node.OptionalCoverageRate);
38 | Assert.AreEqual(40 / 50.0, node.OptionalUncoverageRate);
39 | }
40 |
41 | //---------------------------------------------------------------------
42 | [TestMethod]
43 | public void TestNullCoverage()
44 | {
45 | var coverage = new BaseCoverageTest(0, 0);
46 | var node = new BasicCoverageTreeNode(null, coverage,
47 | RootCoverageTreeNode.IconFilename, false);
48 |
49 | Assert.AreEqual(null, node.OptionalCoverageRate);
50 | Assert.AreEqual(null, node.OptionalUncoverageRate);
51 | }
52 |
53 | //---------------------------------------------------------------------
54 | class BaseCoverageTest : BaseCoverage
55 | {
56 | public BaseCoverageTest(
57 | int coverLineCount,
58 | int totalLineCount)
59 | {
60 | this.CoverLineCount = coverLineCount;
61 | this.TotalLineCount = totalLineCount;
62 | }
63 | }
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/VSPackage_UnitTests/BindableValue.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.Helper;
18 |
19 | namespace VSPackage_UnitTests
20 | {
21 | //---------------------------------------------------------------------
22 | public class BindableValue : PropertyChangedNotifier
23 | {
24 | T value;
25 |
26 | public BindableValue(T value)
27 | {
28 | this.value = value;
29 | }
30 |
31 | public T Value
32 | {
33 | get { return this.value; }
34 | set { this.SetField(ref this.value, value); }
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/VSPackage_UnitTests/CommandLineBuilderTests.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 Microsoft.VisualStudio.TestTools.UnitTesting;
18 | using OpenCppCoverage.VSPackage;
19 | using System.Collections.Generic;
20 | using System.Diagnostics;
21 | using System.Linq;
22 | using System.Reflection;
23 |
24 | namespace VSPackage_UnitTests
25 | {
26 | [TestClass]
27 | public class CommandLineBuilderTests
28 | {
29 | //---------------------------------------------------------------------
30 | [TestMethod]
31 | public void AppendArgument()
32 | {
33 | Assert.AreEqual("argument",
34 | new CommandLineBuilder().AppendArgument("argument", null).GetCommandLine());
35 | Assert.AreEqual(@"argument ""value""",
36 | new CommandLineBuilder().AppendArgument("argument", "value").GetCommandLine());
37 | }
38 |
39 | //---------------------------------------------------------------------
40 | [TestMethod]
41 | public void EscapeValue()
42 | {
43 | foreach (var value in new List {
44 | "value", @"va\lue", @"va""lue", @"va\""lue", @"va\\\""lue", @"value\", @"value\\" })
45 | {
46 | Assert.AreEqual(value, EscapeAndGetProcessOutput(value));
47 | }
48 | }
49 |
50 | //---------------------------------------------------------------------
51 | string EscapeAndGetProcessOutput(string str)
52 | {
53 | var escapedValue = CommandLineBuilder.EscapeValue(str);
54 | var output = GetOutputForCommandLineArg(escapedValue);
55 |
56 | return output.Single();
57 | }
58 |
59 | //---------------------------------------------------------------------
60 | static List GetOutputForCommandLineArg(string arguments)
61 | {
62 | var lines = new List();
63 | var assemblyPath = Assembly.GetCallingAssembly().Location;
64 | var startInfo = new ProcessStartInfo(assemblyPath, arguments);
65 | startInfo.RedirectStandardOutput = true;
66 | startInfo.UseShellExecute = false;
67 |
68 | var process = Process.Start(startInfo);
69 | var standardOutput = process.StandardOutput;
70 | while (!standardOutput.EndOfStream)
71 | lines.Add(standardOutput.ReadLine());
72 |
73 | return lines;
74 | }
75 | }
76 | }
--------------------------------------------------------------------------------
/VSPackage_UnitTests/CoverageDataDeserializerTests.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 Microsoft.VisualStudio.TestTools.UnitTesting;
19 | using OpenCppCoverage.VSPackage.CoverageData;
20 | using OpenCppCoverage.VSPackage.CoverageData.ProtoBuff;
21 | using System.IO;
22 | using System.Linq;
23 |
24 | namespace VSPackage_UnitTests
25 | {
26 | [TestClass]
27 | public class CoverageDataDeserializerTests
28 | {
29 | //---------------------------------------------------------------------
30 | static readonly string coverageName = "coverageName";
31 | static readonly ulong moduleCount = 1;
32 | static readonly int exitCode = 42;
33 | static readonly string modulePath = "modulePath";
34 | static readonly string filePath = "filePath";
35 | static readonly bool hasBeenExecuted = true;
36 | static readonly uint lineNumber = 10;
37 |
38 | //---------------------------------------------------------------------
39 | [TestMethod]
40 | public void Deserialize()
41 | {
42 | using (var stream = new MemoryStream())
43 | {
44 | WriteCoverageData(stream);
45 |
46 | var deserializer = new CoverageDataDeserializer();
47 | var coverageResult = deserializer.Deserialize(stream);
48 |
49 | Assert.AreEqual(coverageName, coverageResult.CoverageData.Name);
50 | Assert.AreEqual(exitCode, coverageResult.CoverageData.ExitCode);
51 |
52 | var module = coverageResult.Modules.First();
53 | Assert.AreEqual(modulePath, module.Path);
54 |
55 | var file = module.FilesList.First();
56 | Assert.AreEqual(filePath, file.Path);
57 |
58 | var line = file.LinesList.First();
59 | Assert.AreEqual(hasBeenExecuted, line.HasBeenExecuted);
60 | Assert.AreEqual(lineNumber, line.LineNumber);
61 | }
62 | }
63 |
64 | //---------------------------------------------------------------------
65 | static void WriteCoverageData(Stream stream)
66 | {
67 | var outputStream = CodedOutputStream.CreateInstance(stream);
68 |
69 | outputStream.WriteRawVarint32(CoverageDataDeserializer.FileTypeId);
70 | WriteCoverageDataOnly(outputStream);
71 | WriteModule(outputStream);
72 |
73 | outputStream.Flush();
74 | stream.Position = 0;
75 | }
76 |
77 | //---------------------------------------------------------------------
78 | static void WriteCoverageDataOnly(CodedOutputStream outputStream)
79 | {
80 | var coverageData = CoverageData.CreateBuilder();
81 |
82 | coverageData.SetName(coverageName);
83 | coverageData.SetModuleCount(moduleCount);
84 | coverageData.SetExitCode(exitCode);
85 | WriteMessage(outputStream, coverageData.Build());
86 | }
87 |
88 | //---------------------------------------------------------------------
89 | static void WriteModule(CodedOutputStream outputStream)
90 | {
91 | var line = LineCoverage.CreateBuilder();
92 | line.SetHasBeenExecuted(hasBeenExecuted);
93 | line.SetLineNumber(lineNumber);
94 |
95 | var file = FileCoverage.CreateBuilder();
96 | file.SetPath(filePath);
97 | file.AddLines(line);
98 |
99 | var module = ModuleCoverage.CreateBuilder();
100 | module.SetPath(modulePath);
101 | module.AddFiles(file);
102 |
103 | WriteMessage(outputStream, module.Build());
104 | }
105 |
106 | //---------------------------------------------------------------------
107 | static void WriteMessage(CodedOutputStream outputStream, IMessage message)
108 | {
109 | outputStream.WriteRawVarint32((uint)message.SerializedSize);
110 | message.WriteTo(outputStream);
111 | }
112 | }
113 | }
--------------------------------------------------------------------------------
/VSPackage_UnitTests/CoverageTreeControllerTests.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.TestTools.UnitTesting;
18 | using Moq;
19 | using OpenCppCoverage.VSPackage.CoverageRateBuilder;
20 | using OpenCppCoverage.VSPackage.CoverageTree;
21 | using System.Collections.Generic;
22 |
23 | namespace VSPackage_UnitTests
24 | {
25 | [TestClass]
26 | public class CoverageTreeControllerTests
27 | {
28 | CoverageTreeController controller;
29 | Mock coverageViewManager;
30 |
31 | //---------------------------------------------------------------------
32 | [TestInitialize]
33 | public void Initialize()
34 | {
35 | this.controller = new CoverageTreeController();
36 | this.coverageViewManager = new Mock();
37 | }
38 |
39 | //---------------------------------------------------------------------
40 | [TestMethod]
41 | public void Root()
42 | {
43 | var name = "name";
44 |
45 | bool propertyChangedCalled = false;
46 | controller.PropertyChanged += (s, e) => propertyChangedCalled = true;
47 |
48 | controller.Filter = "Filter";
49 | controller.UpdateCoverageRate(
50 | new CoverageRate(name, 0), null, this.coverageViewManager.Object);
51 | Assert.IsTrue(propertyChangedCalled);
52 | Assert.AreEqual(name, controller.Root.Text);
53 | Assert.AreEqual("", controller.Filter);
54 | }
55 |
56 | //---------------------------------------------------------------------
57 | [TestMethod]
58 | public void Filter()
59 | {
60 | this.controller.UpdateCoverageRate(
61 | new CoverageRate("", 0), null, this.coverageViewManager.Object);
62 | this.controller.Filter = "filter";
63 |
64 | bool rootChanged = false;
65 | controller.PropertyChanged += (s, e) =>
66 | {
67 | if (e.PropertyName == "Root")
68 | rootChanged = true;
69 | };
70 |
71 | controller.Filter = string.Empty;
72 | Assert.IsTrue(rootChanged);
73 | }
74 |
75 | //---------------------------------------------------------------------
76 | [TestMethod]
77 | public void Warning()
78 | {
79 | Assert.IsNull(this.controller.Warning);
80 | this.controller.UpdateCoverageRate(
81 | new CoverageRate("", 0), null, this.coverageViewManager.Object);
82 | Assert.IsNull(this.controller.Warning);
83 |
84 | this.controller.UpdateCoverageRate(
85 | new CoverageRate("", 42), null, this.coverageViewManager.Object);
86 | Assert.IsNotNull(this.controller.Warning);
87 | }
88 |
89 | //---------------------------------------------------------------------
90 | [TestMethod]
91 | public void DisplayCoverage()
92 | {
93 | this.controller.UpdateCoverageRate(
94 | new CoverageRate("", 0), null, this.coverageViewManager.Object);
95 | this.coverageViewManager.VerifySet(c => c.ShowCoverage = true);
96 |
97 | this.controller.DisplayCoverage = false;
98 | this.coverageViewManager.VerifySet(c => c.ShowCoverage = false);
99 | }
100 | }
101 | }
--------------------------------------------------------------------------------
/VSPackage_UnitTests/Key.snk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OpenCppCoverage/OpenCppCoveragePlugin/6e39733d1e8643c99c2174d2334628fca1d0561e/VSPackage_UnitTests/Key.snk
--------------------------------------------------------------------------------
/VSPackage_UnitTests/ObservableItemCollectionTests.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 Microsoft.VisualStudio.TestTools.UnitTesting;
18 | using OpenCppCoverage.VSPackage.Helper;
19 |
20 | namespace VSPackage_UnitTests
21 | {
22 | [TestClass]
23 | public class ObservableItemCollectionTests
24 | {
25 | ObservableItemCollection> collection;
26 | bool eventCalled;
27 |
28 | //---------------------------------------------------------------------
29 | [TestInitialize]
30 | public void TestInitialize()
31 | {
32 | this.collection = new ObservableItemCollection>();
33 | this.eventCalled = false;
34 | collection.CollectionOrItemChanged += (sender, e) => { this.eventCalled = true; };
35 | }
36 |
37 | //---------------------------------------------------------------------
38 | [TestMethod]
39 | public void CollectionOrItemChanged()
40 | {
41 | this.collection.Add(new BindableValue(0));
42 | Assert.IsTrue(this.eventCalled);
43 | }
44 |
45 | //---------------------------------------------------------------------
46 | [TestMethod]
47 | public void ItemChanged()
48 | {
49 | var item = new BindableValue(0);
50 | this.collection.Add(item);
51 | this.eventCalled = false;
52 |
53 | item.Value = 42;
54 | Assert.IsTrue(this.eventCalled);
55 | }
56 |
57 | //---------------------------------------------------------------------
58 | [TestMethod]
59 | public void UnregisterItemRemove()
60 | {
61 | var item = new BindableValue(0);
62 | this.collection.Add(item);
63 | this.collection.Remove(item);
64 |
65 | this.eventCalled = false;
66 | item.Value = 42;
67 | Assert.IsFalse(this.eventCalled);
68 | }
69 |
70 | //---------------------------------------------------------------------
71 | [TestMethod]
72 | public void UnregisterClear()
73 | {
74 | var item = new BindableValue(0);
75 | this.collection.Add(item);
76 | this.collection.Clear();
77 |
78 | this.eventCalled = false;
79 | item.Value = 42;
80 | Assert.IsFalse(this.eventCalled);
81 | }
82 | }
83 | }
--------------------------------------------------------------------------------
/VSPackage_UnitTests/PathHelperTests.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 Microsoft.VisualStudio.TestTools.UnitTesting;
18 | using OpenCppCoverage.VSPackage.Helper;
19 | using System.Collections.Generic;
20 | using System.IO;
21 | using System.Linq;
22 |
23 | namespace VSPackage_IntegrationTests
24 | {
25 | [TestClass]
26 | public class PathHelperTests
27 | {
28 | //---------------------------------------------------------------------
29 | [TestMethod]
30 | public void TestComputeCommonFolders()
31 | {
32 | const string file2 = @"C:\Dev\Folder2\Folder3\File2.txt";
33 | const string file4 = @"C:\Dev\Folder1\File4.txt";
34 |
35 | var paths = new List
36 | {
37 | @"C:\Dev\Folder1\Folder2\Folder3\File1.txt",
38 | file2,
39 | @"C:\Dev\Folder1\Folder2\File3.txt",
40 | file4
41 | };
42 |
43 | var commonFolders = PathHelper.ComputeCommonFolders(paths);
44 |
45 | var expectedFolders = new List {
46 | Path.GetDirectoryName(file4),
47 | Path.GetDirectoryName(file2)};
48 | CollectionAssert.AreEqual(expectedFolders, commonFolders.ToList());
49 | }
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/VSPackage_UnitTests/Program.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 |
19 | namespace VSPackage_UnitTests
20 | {
21 | class Program
22 | {
23 | static void Main(string[] args)
24 | {
25 | Console.Error.WriteLine("This function is used for " + nameof(CommandLineBuilderTests));
26 | Console.Error.WriteLine("To run unit tests, please use Test Explorer");
27 |
28 | foreach (var arg in args)
29 | Console.WriteLine(arg);
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/VSPackage_UnitTests/PropertyHelper.cs:
--------------------------------------------------------------------------------
1 | // OpenCppCoverage is an open source code coverage for C++.
2 | // Copyright (C) 2019 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;
19 | using System.Collections.Generic;
20 |
21 | namespace VSPackage_UnitTests
22 | {
23 | static class PropertyHelper
24 | {
25 | //---------------------------------------------------------------------
26 | public static void SetPropertiesValue(T value, Dictionary> factoriesByType)
27 | {
28 | var properties = value.GetType().GetProperties();
29 |
30 | foreach (var p in properties)
31 | {
32 | if (p.CanWrite)
33 | {
34 | Func