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/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..8b0572b 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.IsNullOrWhiteSpace(_options.RegisterAs) ? _options.RegisterAs : + new WindowsPrincipal(WindowsIdentity.GetCurrent()).IsInRole(WindowsBuiltInRole.Administrator) ? "administrator" : "user" }; 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) 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..fc191fe 100644 --- a/AxoCover/Resources.Designer.cs +++ b/AxoCover/Resources.Designer.cs @@ -1023,6 +1023,24 @@ public static string Ready { } } + /// + /// Looks up a localized string similar to Register coverage profiler as. + /// + public static string RegisterAs { + get { + return ResourceManager.GetString("RegisterAs", resourceCulture); + } + } + + /// + /// 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 3bb87de..9d5420c 100644 --- a/AxoCover/Resources.resx +++ b/AxoCover/Resources.resx @@ -672,4 +672,10 @@ Cannot import OpenCover coverage file {0}. + + 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 9e4fcd5..41fd647 100644 --- a/AxoCover/Views/SettingsView.xaml +++ b/AxoCover/Views/SettingsView.xaml @@ -202,6 +202,11 @@ + + + + + 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 +