|
1 | 1 | using FineCodeCoverage.Options; |
| 2 | +using System; |
| 3 | +using System.Collections.Generic; |
2 | 4 | using System.ComponentModel.Composition; |
3 | 5 | using System.IO; |
| 6 | +using System.Linq; |
4 | 7 | using System.Threading.Tasks; |
5 | 8 |
|
6 | 9 | namespace FineCodeCoverage.Engine.Model |
@@ -32,7 +35,44 @@ public async Task<IAppOptions> GetSettingsAsync(ICoverageProject coverageProject |
32 | 35 | var projectDirectory = Path.GetDirectoryName(coverageProject.ProjectFile); |
33 | 36 | var settingsFilesElements = fccSettingsFilesProvider.Provide(projectDirectory); |
34 | 37 | var projectSettingsElement = await coverageProjectSettingsProvider.ProvideAsync(coverageProject); |
35 | | - return settingsMerger.Merge(appOptionsProvider.Get(), settingsFilesElements, projectSettingsElement); |
| 38 | + var merged = settingsMerger.Merge(appOptionsProvider.Get(), settingsFilesElements, projectSettingsElement); |
| 39 | + AddCommonAssemblyExcludesIncludes(merged); |
| 40 | + return merged; |
| 41 | + } |
| 42 | + |
| 43 | + private void AddCommonAssemblyExcludesIncludes(IAppOptions appOptions) |
| 44 | + { |
| 45 | + var (newOldStyleExclude,newMsExclude) = AddCommon(appOptions.Exclude, appOptions.ModulePathsExclude, appOptions.ExcludeAssemblies); |
| 46 | + var (newOldStyleInclude,newMsInclude) = AddCommon(appOptions.Include, appOptions.ModulePathsInclude, appOptions.IncludeAssemblies); |
| 47 | + appOptions.Exclude = newOldStyleExclude; |
| 48 | + appOptions.Include = newOldStyleInclude; |
| 49 | + appOptions.ModulePathsExclude = newMsExclude; |
| 50 | + appOptions.ModulePathsInclude = newMsInclude; |
| 51 | + } |
| 52 | + |
| 53 | + private (string[] newOldStyle,string[] newMs) AddCommon(string[] oldStyle,string[] ms, string[] common ) |
| 54 | + { |
| 55 | + if(common == null) |
| 56 | + { |
| 57 | + return(oldStyle,ms); |
| 58 | + } |
| 59 | + var newMs = ListFromExisting(ms); |
| 60 | + var newOldStyle = ListFromExisting(oldStyle); |
| 61 | + |
| 62 | + common.ToList().ForEach(assemblyFileName => |
| 63 | + { |
| 64 | + var msModulePath = $".*\\{assemblyFileName}.dll$"; |
| 65 | + newMs.Add(msModulePath); |
| 66 | + var old = $"[{assemblyFileName}]*"; |
| 67 | + newOldStyle.Add(old); |
| 68 | + }); |
| 69 | + |
| 70 | + return (newOldStyle.ToArray(), newMs.ToArray()); |
| 71 | + } |
| 72 | + |
| 73 | + private List<string> ListFromExisting(string[] existing) |
| 74 | + { |
| 75 | + return new List<string>(existing ?? new string[0]); |
36 | 76 | } |
37 | 77 | } |
38 | 78 |
|
|
0 commit comments