diff --git a/Record.md b/Record.md new file mode 100644 index 0000000..e8b12e8 --- /dev/null +++ b/Record.md @@ -0,0 +1,10 @@ +# Record + +## fixed + +- support relative path +- save config settings + +## unfixed + +- icon(not necessary) \ No newline at end of file diff --git a/VSPackage/OpenCppCoverageCmdLine.cs b/VSPackage/OpenCppCoverageCmdLine.cs index a2bd2d1..9149707 100644 --- a/VSPackage/OpenCppCoverageCmdLine.cs +++ b/VSPackage/OpenCppCoverageCmdLine.cs @@ -16,8 +16,10 @@ using OpenCppCoverage.VSPackage.Settings; using System.Collections.Generic; +using System.IO; using System.Linq; - +using System.Text.RegularExpressions; + namespace OpenCppCoverage.VSPackage { class OpenCppCoverageCmdLine @@ -127,7 +129,7 @@ static void AppendMiscellaneousSettings( MiscellaneousSettings settings) { if (!string.IsNullOrWhiteSpace(settings.OptionalConfigFile)) - builder.AppendArgument(ConfigFileFlag, settings.OptionalConfigFile); + builder.AppendArgument(ConfigFileFlag, CovertToDirectPath(settings.OptionalConfigFile)); switch (settings.LogTypeValue) { @@ -142,6 +144,40 @@ static void AppendMiscellaneousSettings( if (settings.ContinueAfterCppExceptions) builder.AppendArgument(ContinueAfterCppExceptionFlag, null); + } + + //--------------------------------------------------------------------- + static string CovertToDirectPath(string path) + { + string content = ""; + using (StreamReader reader = new StreamReader(path)) + { + string line; + while ((line = reader.ReadLine()) != null) + content += line + "\r\n"; + } + + // change current directory and replace relative path to direct path, write to new config file and return it. + string oldDirectory = Directory.GetCurrentDirectory(); + string configDirectory = Path.GetDirectoryName(path); + string newConfigFile = configDirectory + @"\tmp.txt"; + Directory.SetCurrentDirectory(configDirectory); + + foreach (Match match in Regex.Matches(content, @"=(.*)\r\n")) + { + string dict = match.Groups[1].Value; + string ndict = Path.GetFullPath(dict); + content = content.Replace(dict, ndict); + } + + using (StreamWriter writer = new StreamWriter(newConfigFile)) + { + writer.Write(content); + writer.Flush(); + } + + Directory.SetCurrentDirectory(oldDirectory); + return newConfigFile; } //--------------------------------------------------------------------- diff --git a/VSPackage/Settings/MainSettingsManager.cs b/VSPackage/Settings/MainSettingsManager.cs index b1ca1c6..8da710a 100644 --- a/VSPackage/Settings/MainSettingsManager.cs +++ b/VSPackage/Settings/MainSettingsManager.cs @@ -49,7 +49,7 @@ public void ShowSettingsWindows( window.Controller.StartUpProjectSettingsBuilder = settingsBuilder; window.Controller.CoverageRunner = coverageRunner; - window.Controller.UpdateStartUpProject(kind); + window.Controller.UpdateSettings(kind); var frame = (IVsWindowFrame)window.Frame; Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(frame.Show()); diff --git a/VSPackage/Settings/UI/BasicSettingController.cs b/VSPackage/Settings/UI/BasicSettingController.cs index 7f2ec66..28003b6 100644 --- a/VSPackage/Settings/UI/BasicSettingController.cs +++ b/VSPackage/Settings/UI/BasicSettingController.cs @@ -253,7 +253,7 @@ void OnToggleSelectAll() } //--------------------------------------------------------------------- - public IEnumerable> EnvironmentVariables { get; private set; } + public IEnumerable> EnvironmentVariables { get; set; } public ICommand ToggleSelectAllCommand { get; } } } diff --git a/VSPackage/Settings/UI/MainSettingController.cs b/VSPackage/Settings/UI/MainSettingController.cs index 77f2093..51f5b9e 100644 --- a/VSPackage/Settings/UI/MainSettingController.cs +++ b/VSPackage/Settings/UI/MainSettingController.cs @@ -15,8 +15,10 @@ // along with this program. If not, see . using GalaSoft.MvvmLight.Command; +using Newtonsoft.Json; using OpenCppCoverage.VSPackage.Helper; using System; +using System.IO; using System.Windows.Controls; using System.Windows.Input; @@ -47,17 +49,67 @@ public MainSettingController( public CoverageRunner CoverageRunner { get; set; } public IStartUpProjectSettingsBuilder StartUpProjectSettingsBuilder { get; set; } + string settingsFile = "OpenCppCoverage.settings"; + + // for serialize + public class AllControllers + { + public BasicSettingController basicSettingController; + public FilterSettingController filterSettingController; + public ImportExportSettingController importExportSettingController; + public MiscellaneousSettingController miscellaneousSettingController; + } + + //--------------------------------------------------------------------- + public void SaveSettings() + { + File.WriteAllText(settingsFile, JsonConvert.SerializeObject(new AllControllers + { + basicSettingController = this.BasicSettingController, + filterSettingController = this.FilterSettingController, + importExportSettingController = this.ImportExportSettingController, + miscellaneousSettingController = this.MiscellaneousSettingController + })); + } + + //--------------------------------------------------------------------- + public void RecoverSettings(AllControllers allControllers) + { + this.BasicSettingController = allControllers.basicSettingController; + this.FilterSettingController = allControllers.filterSettingController; + this.ImportExportSettingController = allControllers.importExportSettingController; + this.MiscellaneousSettingController = allControllers.miscellaneousSettingController; + } + + //--------------------------------------------------------------------- + public void UpdateSettings(ProjectSelectionKind kind) + { + if (this.StartUpProjectSettingsBuilder == null) + throw new InvalidOperationException("StartUpProjectSettingsBuilder should be set."); + + if (File.Exists(settingsFile)) + { + AllControllers allControllers = JsonConvert.DeserializeObject(File.ReadAllText(settingsFile)); + if (allControllers.basicSettingController.CurrentProject.Equals(this.StartUpProjectSettingsBuilder.ComputeSettings(kind).ProjectName)) + { + RecoverSettings(allControllers); + return; + } + } + + UpdateStartUpProject(kind); + } + //--------------------------------------------------------------------- public void UpdateStartUpProject(ProjectSelectionKind kind) { - if (this.StartUpProjectSettingsBuilder == null) - throw new InvalidOperationException("StartUpProjectSettingsBuilder should be set."); - var settings = this.StartUpProjectSettingsBuilder.ComputeSettings(kind); this.BasicSettingController.UpdateStartUpProject(settings); this.FilterSettingController.UpdateStartUpProject(); this.ImportExportSettingController.UpdateStartUpProject(); this.MiscellaneousSettingController.UpdateStartUpProject(); + + SaveSettings(); } //--------------------------------------------------------------------- @@ -73,10 +125,10 @@ public MainSettings GetMainSettings() } //--------------------------------------------------------------------- - public BasicSettingController BasicSettingController { get; } - public FilterSettingController FilterSettingController { get; } - public ImportExportSettingController ImportExportSettingController { get; } - public MiscellaneousSettingController MiscellaneousSettingController { get; } + public BasicSettingController BasicSettingController { get; set; } + public FilterSettingController FilterSettingController { get; set; } + public ImportExportSettingController ImportExportSettingController { get; set; } + public MiscellaneousSettingController MiscellaneousSettingController { get; set; } //--------------------------------------------------------------------- string commandLineText; diff --git a/VSPackage/Settings/UI/SettingToolWindow.cs b/VSPackage/Settings/UI/SettingToolWindow.cs index 63bca6e..5f9a8bc 100644 --- a/VSPackage/Settings/UI/SettingToolWindow.cs +++ b/VSPackage/Settings/UI/SettingToolWindow.cs @@ -61,6 +61,8 @@ void Close() { var frame = (IVsWindowFrame)this.Frame; frame.CloseFrame((uint)__FRAMECLOSE.FRAMECLOSE_NoSave); + + this.Controller.SaveSettings(); } } } diff --git a/VSPackage/VSPackage.csproj b/VSPackage/VSPackage.csproj index 9b19c11..cc895cf 100644 --- a/VSPackage/VSPackage.csproj +++ b/VSPackage/VSPackage.csproj @@ -1,552 +1,556 @@ - - - - 15.0 - 12.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - - 12.0 - publish\ - true - Disk - false - Foreground - 7 - Days - false - false - true - 0 - 1.0.0.%2a - false - false - true - - - - - Debug - AnyCPU - 2.0 - {DF742CAB-0446-4867-A437-719390CC028A} - {82b43b9b-a64c-4715-b499-d71e9ca2bd60};{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - Library - Properties - OpenCppCoverage.VSPackage - VSPackage - True - Key.snk - v4.6 - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - true - - - - False - - - False - - - ..\packages\MvvmLightLibs.5.3.0.0\lib\net45\GalaSoft.MvvmLight.dll - True - - - ..\packages\MvvmLightLibs.5.3.0.0\lib\net45\GalaSoft.MvvmLight.Extras.dll - True - - - ..\packages\MvvmLightLibs.5.3.0.0\lib\net45\GalaSoft.MvvmLight.Platform.dll - True - - - False - ..\packages\Google.ProtocolBuffers.2.4.1.555\lib\net40\Google.ProtocolBuffers.dll - - - False - ..\Externals\ICSharpCode.TreeView.dll - - - - ..\packages\CommonServiceLocator.1.3\lib\portable-net4+sl5+netcore45+wpa81+wp8\Microsoft.Practices.ServiceLocation.dll - True - - - - - - - - - - - - - - - - - True - - - - - - - - - - - - - ..\packages\MvvmLightLibs.5.3.0.0\lib\net45\System.Windows.Interactivity.dll - True - - - - - - - - {1CBA492E-7263-47BB-87FE-639000619B15} - 8 - 0 - 0 - primary - False - False - - - {00020430-0000-0000-C000-000000000046} - 2 - 0 - 0 - primary - False - False - - - - - - - - - - - - - - - CoverageTreeControl.xaml - - - - - - - - - - - FileSystemSelectionControl.xaml - - - - - - - - - - - - - - - - - - - - True - True - Resources.resx - - - - - - - BasicSettingControl.xaml - - - - - FilterSettingControl.xaml - - - - ImportExportSettingControl.xaml - - - - MainSettingControl.xaml - - - - MiscellaneousSettingControl.xaml - - - - - - - - - - - - - - ResXFileCodeGenerator - Resources.Designer.cs - Designer - - - true - VSPackage - - - - - - - Designer - - - - - - - - Menus.ctmenu - Designer - - - - - - - - true - Always - - - true - PreserveNewest - - - true - PreserveNewest - - - true - PreserveNewest - - - true - - - true - - - true - - - true - - - true - - - true - - - true - - - true - - - true - - - true - - - true - - - true - - - true - - - true - - - true - - - true - - - true - - - true - - - true - - - true - - - true - - - true - - - true - - - true - - - true - - - true - - - true - - - true - - - true - - - true - - - true - - - true - - - true - - - true - - - true - - - true - - - true - - - true - - - true - - - true - - - true - - - - true - - - true - - - true - - - true - - - true - - - true - - - true - - - true - - - true - - - true - - - true - - - true - - - true - - - true - - - true - - - true - - - true - - - true - - - true - - - true - - - true - - - true - - - true - - - true - - - true - - - true - - - true - - - true - - - true - - - true - - - Designer - - - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - - - False - .NET Framework 3.5 SP1 - false - - - - true - - - - + + + + 15.0 + 12.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + + 12.0 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + + + Debug + AnyCPU + 2.0 + {DF742CAB-0446-4867-A437-719390CC028A} + {82b43b9b-a64c-4715-b499-d71e9ca2bd60};{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + Library + Properties + OpenCppCoverage.VSPackage + VSPackage + True + Key.snk + v4.6 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + true + + + + False + + + False + + + ..\packages\MvvmLightLibs.5.3.0.0\lib\net45\GalaSoft.MvvmLight.dll + True + + + ..\packages\MvvmLightLibs.5.3.0.0\lib\net45\GalaSoft.MvvmLight.Extras.dll + True + + + ..\packages\MvvmLightLibs.5.3.0.0\lib\net45\GalaSoft.MvvmLight.Platform.dll + True + + + False + ..\packages\Google.ProtocolBuffers.2.4.1.555\lib\net40\Google.ProtocolBuffers.dll + + + False + ..\Externals\ICSharpCode.TreeView.dll + + + + ..\packages\CommonServiceLocator.1.3\lib\portable-net4+sl5+netcore45+wpa81+wp8\Microsoft.Practices.ServiceLocation.dll + True + + + + + + + + + + + + + + + + + True + + + ..\packages\Newtonsoft.Json.11.0.2\lib\net45\Newtonsoft.Json.dll + + + + + + + + + + + + + ..\packages\MvvmLightLibs.5.3.0.0\lib\net45\System.Windows.Interactivity.dll + True + + + + + + + + {1CBA492E-7263-47BB-87FE-639000619B15} + 8 + 0 + 0 + primary + False + False + + + {00020430-0000-0000-C000-000000000046} + 2 + 0 + 0 + primary + False + False + + + + + + + + + + + + + + + CoverageTreeControl.xaml + + + + + + + + + + + FileSystemSelectionControl.xaml + + + + + + + + + + + + + + + + + + + + True + True + Resources.resx + + + + + + + BasicSettingControl.xaml + + + + + FilterSettingControl.xaml + + + + ImportExportSettingControl.xaml + + + + MainSettingControl.xaml + + + + MiscellaneousSettingControl.xaml + + + + + + + + + + + + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + true + VSPackage + + + + + + + + Designer + + + + + + + + Menus.ctmenu + Designer + + + + + + + + true + Always + + + true + PreserveNewest + + + true + PreserveNewest + + + true + PreserveNewest + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + Designer + + + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + + + False + .NET Framework 3.5 SP1 + false + + + + true + + + + "$(SolutionDir)packages\Google.ProtocolBuffers.2.4.1.555\tools\ProtoGen.exe" --proto_path=$(SolutionDir)VSPackage\CoverageData -namespace=OpenCppCoverage.VSPackage.CoverageData.ProtoBuff -output_directory=$(ProjectDir)CoverageData CoverageData.proto -"$(DevEnvDir)..\..\VSSDK\VisualStudioIntegration\Tools\Bin\VsixColorCompiler.exe" "$(ProjectDir)\Themes.xml" "$(ProjectDir)\Themes.pkgdef" /noLogo - - - - - +"$(DevEnvDir)..\..\VSSDK\VisualStudioIntegration\Tools\Bin\VsixColorCompiler.exe" "$(ProjectDir)\Themes.xml" "$(ProjectDir)\Themes.pkgdef" /noLogo + + + + + + --> \ No newline at end of file diff --git a/VSPackage/packages.config b/VSPackage/packages.config index 434874f..5601452 100644 --- a/VSPackage/packages.config +++ b/VSPackage/packages.config @@ -1,6 +1,7 @@ - - - - - + + + + + + \ No newline at end of file