Skip to content

Commit c616c3d

Browse files
author
krisszk
committed
Configuration option for app data folder
1 parent 936aadf commit c616c3d

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

SharedProject/Core/AppDataFolder.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.IO;
44
using System.Linq;
55
using System.Threading;
6+
using FineCodeCoverage.Options;
67

78
namespace FineCodeCoverage.Engine
89
{
@@ -12,13 +13,15 @@ internal class AppDataFolder : IAppDataFolder
1213
{
1314
private readonly ILogger logger;
1415
private readonly IEnvironmentVariable environmentVariable;
16+
private readonly IAppOptionsProvider appOptionsProvider;
1517
internal const string fccDebugCleanInstallEnvironmentVariable = "FCCDebugCleanInstall";
1618

1719
[ImportingConstructor]
18-
public AppDataFolder(ILogger logger,IEnvironmentVariable environmentVariable)
20+
public AppDataFolder(ILogger logger,IEnvironmentVariable environmentVariable, IAppOptionsProvider appOptionsProvider)
1921
{
2022
this.logger = logger;
2123
this.environmentVariable = environmentVariable;
24+
this.appOptionsProvider = appOptionsProvider;
2225
}
2326
public string DirectoryPath { get; private set; }
2427

@@ -34,7 +37,7 @@ public void Initialize(CancellationToken camcellationToken)
3437

3538
private void CreateAppDataFolder()
3639
{
37-
DirectoryPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), Vsix.Code);
40+
DirectoryPath = Path.Combine(GetAppDataFolder(), Vsix.Code);
3841
if (environmentVariable.Get(fccDebugCleanInstallEnvironmentVariable) != null)
3942
{
4043
logger.Log("FCCDebugCleanInstall");
@@ -58,6 +61,13 @@ private void CreateAppDataFolder()
5861
Directory.CreateDirectory(DirectoryPath);
5962
}
6063

64+
private string GetAppDataFolder()
65+
{
66+
var dir = appOptionsProvider.Get().ToolsDirectory;
67+
68+
return Directory.Exists(dir) ? dir : Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
69+
}
70+
6171
private void CleanupLegacyFolders()
6272
{
6373
Directory

SharedProject/Options/AppOptions.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ namespace FineCodeCoverage.Options
99
internal class AppOptions : DialogPage, IAppOptions
1010
{
1111
private const string runCategory = "Run";
12+
private const string environmentCategory = "Environment";
1213
private const string excludeIncludeCategory = "Exclude / Include";
1314
private const string coverletCategory = "Coverlet";
1415
private const string openCoverCategory = "OpenCover";
@@ -115,6 +116,10 @@ You can also ignore additional attributes by adding to this list (short name or
115116
[Category(runCategory)]
116117
public int RunWhenTestsExceed { get; set; }
117118

119+
[Description("Folder to which copy tools subfolder. Must alredy exist. Requires restart of VS.")]
120+
[Category(environmentCategory)]
121+
public string ToolsDirectory { get; set; }
122+
118123
[Description("Specify false for global and project options to be used for coverlet data collector configuration elements when not specified in runsettings")]
119124
[Category(coverletCategory)]
120125
public bool RunSettingsOnly { get; set; } = true;

SharedProject/Options/IAppOptions.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ public interface IAppOptions
1010
bool IncludeTestAssembly { get; }
1111
bool RunInParallel { get; }
1212
int RunWhenTestsExceed { get; }
13+
string ToolsDirectory { get; }
1314
bool RunWhenTestsFail { get; }
1415
bool RunSettingsOnly { get; }
1516
bool CoverletConsoleGlobal { get; }

0 commit comments

Comments
 (0)