-
-
Notifications
You must be signed in to change notification settings - Fork 200
/
CompilerInvocationTests.cs
45 lines (42 loc) · 1.57 KB
/
CompilerInvocationTests.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
using Microsoft.Build.Framework;
using Microsoft.Build.Logging.StructuredLogger;
using Xunit;
namespace StructuredLogger.Tests
{
public class CompilerInvocationTests
{
[Theory]
[InlineData(
@"C:\Program Files\dotnet\dotnet.exe exec ""C:\Program Files\dotnet\sdk\5.0.100-rc.2.20479.15\Roslyn\bincore\csc.dll"" /noconfig", "/noconfig")]
[InlineData(@"foo\csc.exe a.cs /out:a.dll", "a.cs /out:a.dll")]
public void Parse1(string arg, string expected)
{
var result = CompilerInvocationsReader.TrimCompilerExeFromCommandLine(arg, CompilerInvocation.CSharp);
Assert.Equal(expected, result);
}
//[Fact]
public void ReadRecordsTest()
{
var binlog = @"C:\temp\msbuild.binlog";
var records = BinaryLog.ReadRecords(binlog);
string lastTask = null;
foreach (var record in records)
{
if (record.Args is TaskStartedEventArgs taskStarted)
{
lastTask = taskStarted.TaskName;
}
else if (record.Args is TaskParameterEventArgs taskParameters)
{
if (lastTask == "Csc" && taskParameters.ItemType == "Compile")
{
foreach (ITaskItem item in taskParameters.Items)
{
var csFilePath = item.ItemSpec;
}
}
}
}
}
}
}