Skip to content

Commit a515d4f

Browse files
committed
Merge branch 'master' of https://github.com/FortuneN/FineCodeCoverage into mscodecoverage
2 parents 3c89938 + e8cd069 commit a515d4f

File tree

5 files changed

+24
-3
lines changed

5 files changed

+24
-3
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ but there may be a preview version that you want to use. This can be configured
3131
Configuration is available with Visual Studio settings and project msbuild properties. All visual studio settings can be overridden from test project settings and some settings
3232
can only be set in project files.
3333

34+
The coverage tools that FCC leverages are by default installed into the FineCodeCoverage directory within `Environment.SpecialFolder.LocalApplicationData`.
35+
This can be changed with the ToolsDirectory Visual Studio option. Ensure that this containing directory exists and upon restart the tools will be installed within.
36+
3437
---
3538

3639
### <a href="https://www.youtube.com/watch?v=Rae5bTE2D3o" target="_blank">Watch Introduction Video</a>
@@ -146,6 +149,8 @@ CoverletConsoleGlobal Specify true to use your own dotnet tools global inst
146149
FCCSolutionOutputDirectoryName To have fcc output visible in a sub folder of your solution provide this name
147150
AdjacentBuildOutput If your tests are dependent upon their path set this to true.
148151
152+
ToolsDirectory Folder to which copy tools subfolder. Must alredy exist. Requires restart of VS.
153+
149154
The "CoverletConsole" settings have precedence Local / CustomPath / Global.
150155
151156
Both 'Exclude' and 'Include' options can be used together but 'Exclude' takes precedence.

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/Core/FCCEngine.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ protected virtual void Dispose(bool disposing)
380380
{
381381
if (!this.disposed)
382382
{
383-
if (disposing)
383+
if (disposing && cancellationTokenSource != null)
384384
{
385385
cancellationTokenSource.Dispose();
386386
}

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";
@@ -120,6 +121,10 @@ You can also ignore additional attributes by adding to this list (short name or
120121
[Category(runCategory)]
121122
public int RunWhenTestsExceed { get; set; }
122123

124+
[Description("Folder to which copy tools subfolder. Must alredy exist. Requires restart of VS.")]
125+
[Category(environmentCategory)]
126+
public string ToolsDirectory { get; set; }
127+
123128
[Description("Specify false for global and project options to be used for coverlet data collector configuration elements when not specified in runsettings")]
124129
[Category(coverletCategory)]
125130
public bool RunSettingsOnly { get; set; } = true;

SharedProject/Options/IAppOptions.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ internal interface IAppOptions : IMsCodeCoverageOptions, IFCCCommonOptions
3131
string[] Include { get; }
3232
bool RunInParallel { get; }
3333
int RunWhenTestsExceed { get; }
34+
string ToolsDirectory { get; }
3435
bool RunWhenTestsFail { get; }
3536
bool RunSettingsOnly { get; }
3637
bool CoverletConsoleGlobal { get; }

0 commit comments

Comments
 (0)