Skip to content

Commit 9439e95

Browse files
committed
remove BaseTask class name
1 parent 21a30e9 commit 9439e95

File tree

1 file changed

+96
-96
lines changed

1 file changed

+96
-96
lines changed

src/coverlet.msbuild.tasks/InstrumentationTask.cs

+96-96
Original file line numberDiff line numberDiff line change
@@ -16,119 +16,119 @@
1616

1717
namespace Coverlet.MSbuild.Tasks
1818
{
19-
public class InstrumentationTask : BaseTask
20-
{
21-
private readonly MSBuildLogger _logger;
19+
public class InstrumentationTask : BaseTask
20+
{
21+
private readonly MSBuildLogger _logger;
2222

23-
[Required]
24-
public string Path { get; set; }
23+
[Required]
24+
public string Path { get; set; }
2525

26-
public string Include { get; set; }
26+
public string Include { get; set; }
2727

28-
public string IncludeDirectory { get; set; }
28+
public string IncludeDirectory { get; set; }
2929

30-
public string Exclude { get; set; }
30+
public string Exclude { get; set; }
3131

32-
public string ExcludeByFile { get; set; }
32+
public string ExcludeByFile { get; set; }
3333

34-
public string ExcludeByAttribute { get; set; }
34+
public string ExcludeByAttribute { get; set; }
3535

36-
public bool IncludeTestAssembly { get; set; }
36+
public bool IncludeTestAssembly { get; set; }
3737

38-
public bool SingleHit { get; set; }
38+
public bool SingleHit { get; set; }
3939

40-
public string MergeWith { get; set; }
40+
public string MergeWith { get; set; }
4141

42-
public bool UseSourceLink { get; set; }
42+
public bool UseSourceLink { get; set; }
4343

44-
public bool SkipAutoProps { get; set; }
44+
public bool SkipAutoProps { get; set; }
4545

46-
public string DoesNotReturnAttribute { get; set; }
46+
public string DoesNotReturnAttribute { get; set; }
4747

48-
public bool DeterministicReport { get; set; }
48+
public bool DeterministicReport { get; set; }
4949

50-
public string ExcludeAssembliesWithoutSources { get; set; }
50+
public string ExcludeAssembliesWithoutSources { get; set; }
5151

52-
[Output]
53-
public ITaskItem InstrumenterState { get; set; }
52+
[Output]
53+
public ITaskItem InstrumenterState { get; set; }
5454

55-
public InstrumentationTask()
56-
{
57-
_logger = new MSBuildLogger(Log);
58-
}
55+
public InstrumentationTask()
56+
{
57+
_logger = new MSBuildLogger(Log);
58+
}
5959

60-
private void AttachDebugger()
61-
{
62-
if (int.TryParse(Environment.GetEnvironmentVariable("COVERLET_MSBUILD_INSTRUMENTATIONTASK_DEBUG"), out int result) && result == 1)
63-
{
64-
Debugger.Launch();
65-
Debugger.Break();
66-
}
67-
}
68-
69-
public override bool Execute()
60+
private void AttachDebugger()
61+
{
62+
if (int.TryParse(Environment.GetEnvironmentVariable("COVERLET_MSBUILD_INSTRUMENTATIONTASK_DEBUG"), out int result) && result == 1)
63+
{
64+
Debugger.Launch();
65+
Debugger.Break();
66+
}
67+
}
68+
69+
public override bool Execute()
70+
{
71+
AttachDebugger();
72+
73+
IServiceCollection serviceCollection = new ServiceCollection();
74+
serviceCollection.AddTransient<IProcessExitHandler, ProcessExitHandler>();
75+
serviceCollection.AddTransient<IFileSystem, FileSystem>();
76+
serviceCollection.AddTransient<IAssemblyAdapter, AssemblyAdapter>();
77+
serviceCollection.AddTransient<IConsole, SystemConsole>();
78+
serviceCollection.AddTransient<ILogger, MSBuildLogger>(_ => _logger);
79+
serviceCollection.AddTransient<IRetryHelper, RetryHelper>();
80+
// We cache resolutions
81+
serviceCollection.AddSingleton<ISourceRootTranslator, SourceRootTranslator>(serviceProvider =>
82+
new SourceRootTranslator(Path, serviceProvider.GetRequiredService<ILogger>(), serviceProvider.GetRequiredService<IFileSystem>(), serviceProvider.GetRequiredService<IAssemblyAdapter>()));
83+
// We need to keep singleton/static semantics
84+
serviceCollection.AddSingleton<IInstrumentationHelper, InstrumentationHelper>();
85+
serviceCollection.AddSingleton<ICecilSymbolHelper, CecilSymbolHelper>();
86+
87+
ServiceProvider = serviceCollection.BuildServiceProvider();
88+
89+
try
90+
{
91+
IFileSystem fileSystem = ServiceProvider.GetService<IFileSystem>();
92+
93+
var parameters = new CoverageParameters
7094
{
71-
AttachDebugger();
72-
73-
IServiceCollection serviceCollection = new ServiceCollection();
74-
serviceCollection.AddTransient<IProcessExitHandler, ProcessExitHandler>();
75-
serviceCollection.AddTransient<IFileSystem, FileSystem>();
76-
serviceCollection.AddTransient<IAssemblyAdapter, AssemblyAdapter>();
77-
serviceCollection.AddTransient<IConsole, SystemConsole>();
78-
serviceCollection.AddTransient<ILogger, MSBuildLogger>(_ => _logger);
79-
serviceCollection.AddTransient<IRetryHelper, RetryHelper>();
80-
// We cache resolutions
81-
serviceCollection.AddSingleton<ISourceRootTranslator, SourceRootTranslator>(serviceProvider =>
82-
new SourceRootTranslator(Path, serviceProvider.GetRequiredService<ILogger>(), serviceProvider.GetRequiredService<IFileSystem>(), serviceProvider.GetRequiredService<IAssemblyAdapter>()));
83-
// We need to keep singleton/static semantics
84-
serviceCollection.AddSingleton<IInstrumentationHelper, InstrumentationHelper>();
85-
serviceCollection.AddSingleton<ICecilSymbolHelper, CecilSymbolHelper>();
86-
87-
BaseTask.ServiceProvider = serviceCollection.BuildServiceProvider();
88-
89-
try
90-
{
91-
IFileSystem fileSystem = ServiceProvider.GetService<IFileSystem>();
92-
93-
var parameters = new CoverageParameters
94-
{
95-
IncludeFilters = Include?.Split(','),
96-
IncludeDirectories = IncludeDirectory?.Split(','),
97-
ExcludeFilters = Exclude?.Split(','),
98-
ExcludedSourceFiles = ExcludeByFile?.Split(','),
99-
ExcludeAttributes = ExcludeByAttribute?.Split(','),
100-
IncludeTestAssembly = IncludeTestAssembly,
101-
SingleHit = SingleHit,
102-
MergeWith = MergeWith,
103-
UseSourceLink = UseSourceLink,
104-
SkipAutoProps = SkipAutoProps,
105-
DeterministicReport = DeterministicReport,
106-
ExcludeAssembliesWithoutSources = ExcludeAssembliesWithoutSources,
107-
DoesNotReturnAttributes = DoesNotReturnAttribute?.Split(',')
108-
};
109-
110-
var coverage = new Coverage(Path,
111-
parameters,
112-
_logger,
113-
ServiceProvider.GetService<IInstrumentationHelper>(),
114-
ServiceProvider.GetService<IFileSystem>(),
115-
ServiceProvider.GetService<ISourceRootTranslator>(),
116-
ServiceProvider.GetService<ICecilSymbolHelper>());
117-
118-
CoveragePrepareResult prepareResult = coverage.PrepareModules();
119-
string randomPath = System.IO.Path.Combine(System.IO.Path.GetTempPath(), System.IO.Path.GetRandomFileName());
120-
InstrumenterState = new TaskItem(randomPath);
121-
using Stream instrumentedStateFile = fileSystem.NewFileStream(InstrumenterState.ItemSpec, FileMode.CreateNew, FileAccess.Write);
122-
using Stream serializedState = CoveragePrepareResult.Serialize(prepareResult);
123-
serializedState.CopyTo(instrumentedStateFile);
124-
}
125-
catch (Exception ex)
126-
{
127-
_logger.LogError(ex);
128-
return false;
129-
}
130-
131-
return true;
132-
}
95+
IncludeFilters = Include?.Split(','),
96+
IncludeDirectories = IncludeDirectory?.Split(','),
97+
ExcludeFilters = Exclude?.Split(','),
98+
ExcludedSourceFiles = ExcludeByFile?.Split(','),
99+
ExcludeAttributes = ExcludeByAttribute?.Split(','),
100+
IncludeTestAssembly = IncludeTestAssembly,
101+
SingleHit = SingleHit,
102+
MergeWith = MergeWith,
103+
UseSourceLink = UseSourceLink,
104+
SkipAutoProps = SkipAutoProps,
105+
DeterministicReport = DeterministicReport,
106+
ExcludeAssembliesWithoutSources = ExcludeAssembliesWithoutSources,
107+
DoesNotReturnAttributes = DoesNotReturnAttribute?.Split(',')
108+
};
109+
110+
var coverage = new Coverage(Path,
111+
parameters,
112+
_logger,
113+
ServiceProvider.GetService<IInstrumentationHelper>(),
114+
ServiceProvider.GetService<IFileSystem>(),
115+
ServiceProvider.GetService<ISourceRootTranslator>(),
116+
ServiceProvider.GetService<ICecilSymbolHelper>());
117+
118+
CoveragePrepareResult prepareResult = coverage.PrepareModules();
119+
string randomPath = System.IO.Path.Combine(System.IO.Path.GetTempPath(), System.IO.Path.GetRandomFileName());
120+
InstrumenterState = new TaskItem(randomPath);
121+
using Stream instrumentedStateFile = fileSystem.NewFileStream(InstrumenterState.ItemSpec, FileMode.CreateNew, FileAccess.Write);
122+
using Stream serializedState = CoveragePrepareResult.Serialize(prepareResult);
123+
serializedState.CopyTo(instrumentedStateFile);
124+
}
125+
catch (Exception ex)
126+
{
127+
_logger.LogError(ex);
128+
return false;
129+
}
130+
131+
return true;
133132
}
133+
}
134134
}

0 commit comments

Comments
 (0)