From 5d7a3d375b7a8e78ab8e4e3a9af0a22b19365331 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacek=20G=C4=85siorowski?= Date: Wed, 25 Sep 2019 00:04:37 +0200 Subject: [PATCH 1/4] Introduce new field for coverage settings --- AxoCover/Models/Storage/IOptions.cs | 1 + AxoCover/Models/Storage/Options.cs | 6 ++++++ AxoCover/Properties/Settings.Designer.cs | 12 ++++++++++++ AxoCover/Properties/Settings.settings | 3 +++ AxoCover/Resources.Designer.cs | 9 +++++++++ AxoCover/Resources.resx | 3 +++ AxoCover/Views/SettingsView.xaml | 4 ++++ AxoCover/app.config | 3 +++ 8 files changed, 41 insertions(+) diff --git a/AxoCover/Models/Storage/IOptions.cs b/AxoCover/Models/Storage/IOptions.cs index aa2e111..45aaed5 100644 --- a/AxoCover/Models/Storage/IOptions.cs +++ b/AxoCover/Models/Storage/IOptions.cs @@ -49,6 +49,7 @@ public interface IOptions int DebuggerTimeout { get; set; } bool IsDebugModeEnabled { get; set; } bool IsAutoBuildEnabled { get; set; } + string RegisterAs { get; set; } event PropertyChangedEventHandler PropertyChanged; } diff --git a/AxoCover/Models/Storage/Options.cs b/AxoCover/Models/Storage/Options.cs index a0b9c9c..4088515 100644 --- a/AxoCover/Models/Storage/Options.cs +++ b/AxoCover/Models/Storage/Options.cs @@ -159,6 +159,12 @@ public int VisitorCountLimit get { return Settings.Default.VisitorCountLimit; } set { Settings.Default.VisitorCountLimit = value; } } + + public string RegisterAs + { + get { return Settings.Default.RegisterAs; } + set { Settings.Default.RegisterAs = value; } + } #endregion #region Visualization settings diff --git a/AxoCover/Properties/Settings.Designer.cs b/AxoCover/Properties/Settings.Designer.cs index 79d90b8..a4d3be0 100644 --- a/AxoCover/Properties/Settings.Designer.cs +++ b/AxoCover/Properties/Settings.Designer.cs @@ -561,5 +561,17 @@ public bool IsShowingAnchors { this["IsShowingAnchors"] = value; } } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("user")] + public string RegisterAs { + get { + return ((string)(this["RegisterAs"])); + } + set { + this["RegisterAs"] = value; + } + } } } diff --git a/AxoCover/Properties/Settings.settings b/AxoCover/Properties/Settings.settings index 2ef3fc5..c2b3bdb 100644 --- a/AxoCover/Properties/Settings.settings +++ b/AxoCover/Properties/Settings.settings @@ -140,5 +140,8 @@ True + + user + \ No newline at end of file diff --git a/AxoCover/Resources.Designer.cs b/AxoCover/Resources.Designer.cs index 7b2331c..e77282a 100644 --- a/AxoCover/Resources.Designer.cs +++ b/AxoCover/Resources.Designer.cs @@ -1023,6 +1023,15 @@ public static string Ready { } } + /// + /// Looks up a localized string similar to Register coverage tool as. + /// + public static string RegisterAs { + get { + return ResourceManager.GetString("RegisterAs", resourceCulture); + } + } + /// /// Looks up a localized string similar to The release branch offers the most stable experience and it is recommended for most users.. /// diff --git a/AxoCover/Resources.resx b/AxoCover/Resources.resx index 3bb87de..1e23de6 100644 --- a/AxoCover/Resources.resx +++ b/AxoCover/Resources.resx @@ -672,4 +672,7 @@ Cannot import OpenCover coverage file {0}. + + Register coverage tool as + \ No newline at end of file diff --git a/AxoCover/Views/SettingsView.xaml b/AxoCover/Views/SettingsView.xaml index 9e4fcd5..00533ff 100644 --- a/AxoCover/Views/SettingsView.xaml +++ b/AxoCover/Views/SettingsView.xaml @@ -200,6 +200,10 @@ + + + + diff --git a/AxoCover/app.config b/AxoCover/app.config index e4542ac..bf98265 100644 --- a/AxoCover/app.config +++ b/AxoCover/app.config @@ -133,6 +133,9 @@ True + + user + From 4917e1f550a4f5a62ba979f2a6b3e7448098a2c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacek=20G=C4=85siorowski?= Date: Wed, 25 Sep 2019 00:21:47 +0200 Subject: [PATCH 2/4] Use RegisterAs setting on OpenCover execution --- AxoCover/Models/Testing/Data/OpenCoverOptions.cs | 3 ++- AxoCover/Models/Testing/Execution/AxoTestRunner.cs | 5 ++++- AxoCover/Models/Testing/Execution/OpenCoverProcessInfo.cs | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/AxoCover/Models/Testing/Data/OpenCoverOptions.cs b/AxoCover/Models/Testing/Data/OpenCoverOptions.cs index 9aaaa04..8db7591 100644 --- a/AxoCover/Models/Testing/Data/OpenCoverOptions.cs +++ b/AxoCover/Models/Testing/Data/OpenCoverOptions.cs @@ -18,6 +18,7 @@ public class OpenCoverOptions public string ExcludeDirectories { get; set; } public string Filters { get; set; } public bool IsVisitorCountLimited { get; set; } - public int VisitorCountLimit { get; set; } + public int VisitorCountLimit { get; set; } + public string RegisterAs { get; set; } } } diff --git a/AxoCover/Models/Testing/Execution/AxoTestRunner.cs b/AxoCover/Models/Testing/Execution/AxoTestRunner.cs index b581e07..ede3af8 100644 --- a/AxoCover/Models/Testing/Execution/AxoTestRunner.cs +++ b/AxoCover/Models/Testing/Execution/AxoTestRunner.cs @@ -11,6 +11,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; +using System.Security.Principal; using System.Threading; namespace AxoCover.Models.Testing.Execution @@ -85,7 +86,9 @@ protected override TestReport RunTests(TestItem testItem, bool isCovering, bool Filters = _options.Filters, IsVisitorCountLimited = _options.IsVisitorCountLimited, VisitorCountLimit = _options.VisitorCountLimit, - PdbDirectories = solution.Children.OfType().Select(p => p.OutputDirectory) + PdbDirectories = solution.Children.OfType().Select(p => p.OutputDirectory), + RegisterAs = string.IsNullOrEmpty(_options.RegisterAs) ? + new WindowsPrincipal(WindowsIdentity.GetCurrent()).IsInRole(WindowsBuiltInRole.Administrator) ? "administrator" : "user" : _options.RegisterAs }; hostProcessInfo = new OpenCoverProcessInfo(openCoverOptions); } diff --git a/AxoCover/Models/Testing/Execution/OpenCoverProcessInfo.cs b/AxoCover/Models/Testing/Execution/OpenCoverProcessInfo.cs index f17c864..affdb1d 100644 --- a/AxoCover/Models/Testing/Execution/OpenCoverProcessInfo.cs +++ b/AxoCover/Models/Testing/Execution/OpenCoverProcessInfo.cs @@ -42,7 +42,7 @@ public string FilePath public OpenCoverProcessInfo(OpenCoverOptions options) { CoverageReportPath = options.CoverageReportPath; - _baseArguments = GetSettingsBasedArguments(options) + $" -output:\"{options.CoverageReportPath}\" -register:user"; + _baseArguments = GetSettingsBasedArguments(options) + $" -output:\"{options.CoverageReportPath}\" -register:{options.RegisterAs}"; } private static string GetSettingsBasedArguments(OpenCoverOptions options) From 4910f868a002573066c5b11d5267c25d9281943d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacek=20G=C4=85siorowski?= Date: Wed, 25 Sep 2019 00:39:28 +0200 Subject: [PATCH 3/4] Make if statement more readable --- AxoCover/Models/Testing/Execution/AxoTestRunner.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AxoCover/Models/Testing/Execution/AxoTestRunner.cs b/AxoCover/Models/Testing/Execution/AxoTestRunner.cs index ede3af8..8b0572b 100644 --- a/AxoCover/Models/Testing/Execution/AxoTestRunner.cs +++ b/AxoCover/Models/Testing/Execution/AxoTestRunner.cs @@ -87,8 +87,8 @@ protected override TestReport RunTests(TestItem testItem, bool isCovering, bool IsVisitorCountLimited = _options.IsVisitorCountLimited, VisitorCountLimit = _options.VisitorCountLimit, PdbDirectories = solution.Children.OfType().Select(p => p.OutputDirectory), - RegisterAs = string.IsNullOrEmpty(_options.RegisterAs) ? - new WindowsPrincipal(WindowsIdentity.GetCurrent()).IsInRole(WindowsBuiltInRole.Administrator) ? "administrator" : "user" : _options.RegisterAs + RegisterAs = !string.IsNullOrWhiteSpace(_options.RegisterAs) ? _options.RegisterAs : + new WindowsPrincipal(WindowsIdentity.GetCurrent()).IsInRole(WindowsBuiltInRole.Administrator) ? "administrator" : "user" }; hostProcessInfo = new OpenCoverProcessInfo(openCoverOptions); } From f3b8b4046972f1cc10a6c8fda766d71f49aca060 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacek=20G=C4=85siorowski?= Date: Wed, 25 Sep 2019 00:53:46 +0200 Subject: [PATCH 4/4] Add new setting description --- AxoCover/Resources.Designer.cs | 11 ++++++++++- AxoCover/Resources.resx | 5 ++++- AxoCover/Views/SettingsView.xaml | 3 ++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/AxoCover/Resources.Designer.cs b/AxoCover/Resources.Designer.cs index e77282a..fc191fe 100644 --- a/AxoCover/Resources.Designer.cs +++ b/AxoCover/Resources.Designer.cs @@ -1024,7 +1024,7 @@ public static string Ready { } /// - /// Looks up a localized string similar to Register coverage tool as. + /// Looks up a localized string similar to Register coverage profiler as. /// public static string RegisterAs { get { @@ -1032,6 +1032,15 @@ public static string RegisterAs { } } + /// + /// Looks up a localized string similar to User under which OpenCover coverage profiler gets registered. Empty value will setup type of user "administrator" or "user" based on IDE current user.. + /// + public static string RegisterAsDescription { + get { + return ResourceManager.GetString("RegisterAsDescription", resourceCulture); + } + } + /// /// Looks up a localized string similar to The release branch offers the most stable experience and it is recommended for most users.. /// diff --git a/AxoCover/Resources.resx b/AxoCover/Resources.resx index 1e23de6..9d5420c 100644 --- a/AxoCover/Resources.resx +++ b/AxoCover/Resources.resx @@ -673,6 +673,9 @@ Cannot import OpenCover coverage file {0}. - Register coverage tool as + Register coverage profiler as + + + User under which OpenCover coverage profiler gets registered. Empty value will setup type of user "administrator" or "user" based on IDE current user. \ No newline at end of file diff --git a/AxoCover/Views/SettingsView.xaml b/AxoCover/Views/SettingsView.xaml index 00533ff..41fd647 100644 --- a/AxoCover/Views/SettingsView.xaml +++ b/AxoCover/Views/SettingsView.xaml @@ -202,7 +202,8 @@ - + +